1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160 |
- import { __extends as t, __awaiter as e, __generator as n, __spreadArray as r } from "tslib";
- import { SDK_VERSION as i, _registerComponent as o, registerVersion as u, _getProvider, getApp as a, _removeServiceInstance as s } from "@firebase/app";
- import { Component as c } from "@firebase/component";
- import { Logger as l, LogLevel as h } from "@firebase/logger";
- import { FirebaseError as f, getUA as d, isSafari as p, getModularInstance as v, isIndexedDBAvailable as m, createMockUserToken as y, deepEqual as g, getDefaultEmulatorHostnameAndPort as w } from "@firebase/util";
- import { Integer as b, XhrIo as I, EventType as E, ErrorCode as T, createWebChannelTransport as S, getStatEventTarget as _, FetchXmlHttpFactory as D, WebChannel as C, Event as x, Stat as N, Md5 as A } from "@firebase/webchannel-wrapper";
- var k = "@firebase/firestore", O = function() {
- function t(t) {
- this.uid = t;
- }
- return t.prototype.isAuthenticated = function() {
- return null != this.uid;
- },
-
- t.prototype.toKey = function() {
- return this.isAuthenticated() ? "uid:" + this.uid : "anonymous-user";
- }, t.prototype.isEqual = function(t) {
- return t.uid === this.uid;
- }, t;
- }();
- O.UNAUTHENTICATED = new O(null),
- O.GOOGLE_CREDENTIALS = new O("google-credentials-uid"), O.FIRST_PARTY = new O("first-party-uid"),
- O.MOCK_USER = new O("mock-user");
- var F = "9.23.0", P = new l("@firebase/firestore");
- function R() {
- return P.logLevel;
- }
- function V(t) {
- P.setLogLevel(t);
- }
- function M(t) {
- for (var e = [], n = 1; n < arguments.length; n++) e[n - 1] = arguments[n];
- if (P.logLevel <= h.DEBUG) {
- var i = e.map(B);
- P.debug.apply(P, r([ "Firestore (".concat(F, "): ").concat(t) ], i, !1));
- }
- }
- function L(t) {
- for (var e = [], n = 1; n < arguments.length; n++) e[n - 1] = arguments[n];
- if (P.logLevel <= h.ERROR) {
- var i = e.map(B);
- P.error.apply(P, r([ "Firestore (".concat(F, "): ").concat(t) ], i, !1));
- }
- }
- function q(t) {
- for (var e = [], n = 1; n < arguments.length; n++) e[n - 1] = arguments[n];
- if (P.logLevel <= h.WARN) {
- var i = e.map(B);
- P.warn.apply(P, r([ "Firestore (".concat(F, "): ").concat(t) ], i, !1));
- }
- }
- function B(t) {
- if ("string" == typeof t) return t;
- try {
- return e = t, JSON.stringify(e);
- } catch (e) {
-
- return t;
- }
-
- var e;
- }
- function U(t) {
- void 0 === t && (t = "Unexpected state");
-
-
- var e = "FIRESTORE (".concat(F, ") INTERNAL ASSERTION FAILED: ") + t;
-
-
-
- throw L(e), new Error(e)
-
- ;
- }
- function z(t, e) {
- t || U();
- }
- function G(t, e) {
- t || U();
- }
- function j(t,
- e) {
- return t;
- }
- var K = {
-
-
-
- OK: "ok",
-
- CANCELLED: "cancelled",
-
- UNKNOWN: "unknown",
-
- INVALID_ARGUMENT: "invalid-argument",
-
- DEADLINE_EXCEEDED: "deadline-exceeded",
-
- NOT_FOUND: "not-found",
-
- ALREADY_EXISTS: "already-exists",
-
- PERMISSION_DENIED: "permission-denied",
-
- UNAUTHENTICATED: "unauthenticated",
-
- RESOURCE_EXHAUSTED: "resource-exhausted",
-
- FAILED_PRECONDITION: "failed-precondition",
-
- ABORTED: "aborted",
-
- OUT_OF_RANGE: "out-of-range",
-
- UNIMPLEMENTED: "unimplemented",
-
- INTERNAL: "internal",
-
- UNAVAILABLE: "unavailable",
-
- DATA_LOSS: "data-loss"
- }, Q = function(e) {
-
- function n(
-
- t,
-
- n) {
- var r = this;
- return (r = e.call(this, t, n) || this).code = t, r.message = n,
-
-
-
- r.toString = function() {
- return "".concat(r.name, ": [code=").concat(r.code, "]: ").concat(r.message);
- }, r;
- }
- return t(n, e), n;
- }(f), W = function() {
- var t = this;
- this.promise = new Promise((function(e, n) {
- t.resolve = e, t.reject = n;
- }));
- }, H = function(t, e) {
- this.user = e, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", "Bearer ".concat(t));
- }, Y = function() {
- function t() {}
- return t.prototype.getToken = function() {
- return Promise.resolve(null);
- }, t.prototype.invalidateToken = function() {}, t.prototype.start = function(t, e) {
-
- t.enqueueRetryable((function() {
- return e(O.UNAUTHENTICATED);
- }));
- }, t.prototype.shutdown = function() {}, t;
- }(), X = function() {
- function t(t) {
- this.token = t,
-
- this.changeListener = null;
- }
- return t.prototype.getToken = function() {
- return Promise.resolve(this.token);
- }, t.prototype.invalidateToken = function() {}, t.prototype.start = function(t, e) {
- var n = this;
- this.changeListener = e,
-
- t.enqueueRetryable((function() {
- return e(n.token.user);
- }));
- }, t.prototype.shutdown = function() {
- this.changeListener = null;
- }, t;
- }(), J = function() {
- function t(t) {
- this.t = t,
-
- this.currentUser = O.UNAUTHENTICATED,
-
- this.i = 0, this.forceRefresh = !1, this.auth = null;
- }
- return t.prototype.start = function(t, r) {
- var i = this, o = this.i, u = function(t) {
- return i.i !== o ? (o = i.i, r(t)) : Promise.resolve();
- }, a = new W;
- this.o = function() {
- i.i++, i.currentUser = i.u(), a.resolve(), a = new W, t.enqueueRetryable((function() {
- return u(i.currentUser);
- }));
- };
- var s = function() {
- var r = a;
- t.enqueueRetryable((function() {
- return e(i, void 0, void 0, (function() {
- return n(this, (function(t) {
- switch (t.label) {
- case 0:
- return [ 4 , r.promise ];
- case 1:
- return t.sent(), [ 4 , u(this.currentUser) ];
- case 2:
- return t.sent(), [ 2 ];
- }
- }));
- }));
- }));
- }, c = function(t) {
- M("FirebaseAuthCredentialsProvider", "Auth detected"), i.auth = t, i.auth.addAuthTokenListener(i.o),
- s();
- };
- this.t.onInit((function(t) {
- return c(t);
- })),
-
-
-
- setTimeout((function() {
- if (!i.auth) {
- var t = i.t.getImmediate({
- optional: !0
- });
- t ? c(t) : (
-
- M("FirebaseAuthCredentialsProvider", "Auth not yet detected"), a.resolve(), a = new W);
- }
- }), 0), s();
- }, t.prototype.getToken = function() {
- var t = this, e = this.i, n = this.forceRefresh;
-
-
-
- return this.forceRefresh = !1, this.auth ? this.auth.getToken(n).then((function(n) {
-
-
-
- return t.i !== e ? (M("FirebaseAuthCredentialsProvider", "getToken aborted due to token change."),
- t.getToken()) : n ? (z("string" == typeof n.accessToken), new H(n.accessToken, t.currentUser)) : null;
- })) : Promise.resolve(null);
- }, t.prototype.invalidateToken = function() {
- this.forceRefresh = !0;
- }, t.prototype.shutdown = function() {
- this.auth && this.auth.removeAuthTokenListener(this.o);
- },
-
-
-
-
- t.prototype.u = function() {
- var t = this.auth && this.auth.getUid();
- return z(null === t || "string" == typeof t), new O(t);
- }, t;
- }(), Z = function() {
- function t(t, e, n) {
- this.h = t, this.l = e, this.m = n, this.type = "FirstParty", this.user = O.FIRST_PARTY,
- this.g = new Map
-
- ;
- }
- return t.prototype.p = function() {
- return this.m ? this.m() : null;
- }, Object.defineProperty(t.prototype, "headers", {
- get: function() {
- this.g.set("X-Goog-AuthUser", this.h);
-
- var t = this.p();
- return t && this.g.set("Authorization", t), this.l && this.g.set("X-Goog-Iam-Authorization-Token", this.l),
- this.g;
- },
- enumerable: !1,
- configurable: !0
- }), t;
- }(), $ = function() {
- function t(t, e, n) {
- this.h = t, this.l = e, this.m = n;
- }
- return t.prototype.getToken = function() {
- return Promise.resolve(new Z(this.h, this.l, this.m));
- }, t.prototype.start = function(t, e) {
-
- t.enqueueRetryable((function() {
- return e(O.FIRST_PARTY);
- }));
- }, t.prototype.shutdown = function() {}, t.prototype.invalidateToken = function() {},
- t;
- }(), tt = function(t) {
- this.value = t, this.type = "AppCheck", this.headers = new Map, t && t.length > 0 && this.headers.set("x-firebase-appcheck", this.value);
- }, et = function() {
- function t(t) {
- this.I = t, this.forceRefresh = !1, this.appCheck = null, this.T = null;
- }
- return t.prototype.start = function(t, e) {
- var n = this, r = function(t) {
- null != t.error && M("FirebaseAppCheckTokenProvider", "Error getting App Check token; using placeholder token instead. Error: ".concat(t.error.message));
- var r = t.token !== n.T;
- return n.T = t.token, M("FirebaseAppCheckTokenProvider", "Received ".concat(r ? "new" : "existing", " token.")),
- r ? e(t.token) : Promise.resolve();
- };
- this.o = function(e) {
- t.enqueueRetryable((function() {
- return r(e);
- }));
- };
- var i = function(t) {
- M("FirebaseAppCheckTokenProvider", "AppCheck detected"), n.appCheck = t, n.appCheck.addTokenListener(n.o);
- };
- this.I.onInit((function(t) {
- return i(t);
- })),
-
-
- setTimeout((function() {
- if (!n.appCheck) {
- var t = n.I.getImmediate({
- optional: !0
- });
- t ? i(t) :
-
- M("FirebaseAppCheckTokenProvider", "AppCheck not yet detected");
- }
- }), 0);
- }, t.prototype.getToken = function() {
- var t = this, e = this.forceRefresh;
- return this.forceRefresh = !1, this.appCheck ? this.appCheck.getToken(e).then((function(e) {
- return e ? (z("string" == typeof e.token), t.T = e.token, new tt(e.token)) : null;
- })) : Promise.resolve(null);
- }, t.prototype.invalidateToken = function() {
- this.forceRefresh = !0;
- }, t.prototype.shutdown = function() {
- this.appCheck && this.appCheck.removeTokenListener(this.o);
- }, t;
- }(), nt = function() {
- function t() {}
- return t.prototype.getToken = function() {
- return Promise.resolve(new tt(""));
- }, t.prototype.invalidateToken = function() {}, t.prototype.start = function(t, e) {},
- t.prototype.shutdown = function() {}, t;
- }();
- function rt(t) {
-
- var e =
-
- "undefined" != typeof self && (self.crypto || self.msCrypto), n = new Uint8Array(t);
- if (e && "function" == typeof e.getRandomValues) e.getRandomValues(n); else
-
- for (var r = 0; r < t; r++) n[r] = Math.floor(256 * Math.random());
- return n;
- }
- var it = function() {
- function t() {}
- return t.A = function() {
- for (
-
- var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = Math.floor(256 / t.length) * t.length, n = ""
-
- ; n.length < 20; ) for (var r = rt(40), i = 0; i < r.length; ++i)
-
-
- n.length < 20 && r[i] < e && (n += t.charAt(r[i] % t.length));
- return n;
- }, t;
- }();
- function ot(t, e) {
- return t < e ? -1 : t > e ? 1 : 0;
- }
- function ut(t, e, n) {
- return t.length === e.length && t.every((function(t, r) {
- return n(t, e[r]);
- }));
- }
- function at(t) {
-
- return t + "\0";
- }
- var st = function() {
-
- function t(
-
- t,
-
- e) {
- if (this.seconds = t, this.nanoseconds = e, e < 0) throw new Q(K.INVALID_ARGUMENT, "Timestamp nanoseconds out of range: " + e);
- if (e >= 1e9) throw new Q(K.INVALID_ARGUMENT, "Timestamp nanoseconds out of range: " + e);
- if (t < -62135596800) throw new Q(K.INVALID_ARGUMENT, "Timestamp seconds out of range: " + t);
-
- if (t >= 253402300800) throw new Q(K.INVALID_ARGUMENT, "Timestamp seconds out of range: " + t);
- }
-
- return t.now = function() {
- return t.fromMillis(Date.now());
- },
-
- t.fromDate = function(e) {
- return t.fromMillis(e.getTime());
- },
-
- t.fromMillis = function(e) {
- var n = Math.floor(e / 1e3);
- return new t(n, Math.floor(1e6 * (e - 1e3 * n)));
- },
-
- t.prototype.toDate = function() {
- return new Date(this.toMillis());
- },
-
- t.prototype.toMillis = function() {
- return 1e3 * this.seconds + this.nanoseconds / 1e6;
- }, t.prototype._compareTo = function(t) {
- return this.seconds === t.seconds ? ot(this.nanoseconds, t.nanoseconds) : ot(this.seconds, t.seconds);
- },
-
- t.prototype.isEqual = function(t) {
- return t.seconds === this.seconds && t.nanoseconds === this.nanoseconds;
- },
- t.prototype.toString = function() {
- return "Timestamp(seconds=" + this.seconds + ", nanoseconds=" + this.nanoseconds + ")";
- },
- t.prototype.toJSON = function() {
- return {
- seconds: this.seconds,
- nanoseconds: this.nanoseconds
- };
- },
-
- t.prototype.valueOf = function() {
-
-
-
-
-
-
-
- var t = this.seconds - -62135596800;
-
-
- return String(t).padStart(12, "0") + "." + String(this.nanoseconds).padStart(9, "0");
- }, t;
- }(), ct = function() {
- function t(t) {
- this.timestamp = t;
- }
- return t.fromTimestamp = function(e) {
- return new t(e);
- }, t.min = function() {
- return new t(new st(0, 0));
- }, t.max = function() {
- return new t(new st(253402300799, 999999999));
- }, t.prototype.compareTo = function(t) {
- return this.timestamp._compareTo(t.timestamp);
- }, t.prototype.isEqual = function(t) {
- return this.timestamp.isEqual(t.timestamp);
- },
- t.prototype.toMicroseconds = function() {
-
- return 1e6 * this.timestamp.seconds + this.timestamp.nanoseconds / 1e3;
- }, t.prototype.toString = function() {
- return "SnapshotVersion(" + this.timestamp.toString() + ")";
- }, t.prototype.toTimestamp = function() {
- return this.timestamp;
- }, t;
- }(), lt = function() {
- function t(t, e, n) {
- void 0 === e ? e = 0 : e > t.length && U(), void 0 === n ? n = t.length - e : n > t.length - e && U(),
- this.segments = t, this.offset = e, this.len = n;
- }
- return Object.defineProperty(t.prototype, "length", {
- get: function() {
- return this.len;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.isEqual = function(e) {
- return 0 === t.comparator(this, e);
- }, t.prototype.child = function(e) {
- var n = this.segments.slice(this.offset, this.limit());
- return e instanceof t ? e.forEach((function(t) {
- n.push(t);
- })) : n.push(e), this.construct(n);
- },
- t.prototype.limit = function() {
- return this.offset + this.length;
- }, t.prototype.popFirst = function(t) {
- return t = void 0 === t ? 1 : t, this.construct(this.segments, this.offset + t, this.length - t);
- }, t.prototype.popLast = function() {
- return this.construct(this.segments, this.offset, this.length - 1);
- }, t.prototype.firstSegment = function() {
- return this.segments[this.offset];
- }, t.prototype.lastSegment = function() {
- return this.get(this.length - 1);
- }, t.prototype.get = function(t) {
- return this.segments[this.offset + t];
- }, t.prototype.isEmpty = function() {
- return 0 === this.length;
- }, t.prototype.isPrefixOf = function(t) {
- if (t.length < this.length) return !1;
- for (var e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
- return !0;
- }, t.prototype.isImmediateParentOf = function(t) {
- if (this.length + 1 !== t.length) return !1;
- for (var e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
- return !0;
- }, t.prototype.forEach = function(t) {
- for (var e = this.offset, n = this.limit(); e < n; e++) t(this.segments[e]);
- }, t.prototype.toArray = function() {
- return this.segments.slice(this.offset, this.limit());
- }, t.comparator = function(t, e) {
- for (var n = Math.min(t.length, e.length), r = 0; r < n; r++) {
- var i = t.get(r), o = e.get(r);
- if (i < o) return -1;
- if (i > o) return 1;
- }
- return t.length < e.length ? -1 : t.length > e.length ? 1 : 0;
- }, t;
- }(), ht = function(e) {
- function n() {
- return null !== e && e.apply(this, arguments) || this;
- }
- return t(n, e), n.prototype.construct = function(t, e, r) {
- return new n(t, e, r);
- }, n.prototype.canonicalString = function() {
-
-
-
- return this.toArray().join("/");
- }, n.prototype.toString = function() {
- return this.canonicalString();
- },
-
- n.fromString = function() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
-
-
-
- for (var r = [], i = 0, o = t; i < o.length; i++) {
- var u = o[i];
- if (u.indexOf("//") >= 0) throw new Q(K.INVALID_ARGUMENT, "Invalid segment (".concat(u, "). Paths must not contain // in them."));
-
- r.push.apply(r, u.split("/").filter((function(t) {
- return t.length > 0;
- })));
- }
- return new n(r);
- }, n.emptyPath = function() {
- return new n([]);
- }, n;
- }(lt), ft = /^[_a-zA-Z][_a-zA-Z0-9]*$/, dt = function(e) {
- function n() {
- return null !== e && e.apply(this, arguments) || this;
- }
- return t(n, e), n.prototype.construct = function(t, e, r) {
- return new n(t, e, r);
- },
-
- n.isValidIdentifier = function(t) {
- return ft.test(t);
- }, n.prototype.canonicalString = function() {
- return this.toArray().map((function(t) {
- return t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"), n.isValidIdentifier(t) || (t = "`" + t + "`"),
- t;
- })).join(".");
- }, n.prototype.toString = function() {
- return this.canonicalString();
- },
-
- n.prototype.isKeyField = function() {
- return 1 === this.length && "__name__" === this.get(0);
- },
-
- n.keyField = function() {
- return new n([ "__name__" ]);
- },
-
- n.fromServerFormat = function(t) {
- for (var e = [], r = "", i = 0, o = function() {
- if (0 === r.length) throw new Q(K.INVALID_ARGUMENT, "Invalid field path (".concat(t, "). Paths must not be empty, begin with '.', end with '.', or contain '..'"));
- e.push(r), r = "";
- }, u = !1; i < t.length; ) {
- var a = t[i];
- if ("\\" === a) {
- if (i + 1 === t.length) throw new Q(K.INVALID_ARGUMENT, "Path has trailing escape character: " + t);
- var s = t[i + 1];
- if ("\\" !== s && "." !== s && "`" !== s) throw new Q(K.INVALID_ARGUMENT, "Path has invalid escape sequence: " + t);
- r += s, i += 2;
- } else "`" === a ? (u = !u, i++) : "." !== a || u ? (r += a, i++) : (o(), i++);
- }
- if (o(), u) throw new Q(K.INVALID_ARGUMENT, "Unterminated ` in path: " + t);
- return new n(e);
- }, n.emptyPath = function() {
- return new n([]);
- }, n;
- }(lt), pt = function() {
- function t(t) {
- this.path = t;
- }
- return t.fromPath = function(e) {
- return new t(ht.fromString(e));
- }, t.fromName = function(e) {
- return new t(ht.fromString(e).popFirst(5));
- }, t.empty = function() {
- return new t(ht.emptyPath());
- }, Object.defineProperty(t.prototype, "collectionGroup", {
- get: function() {
- return this.path.popLast().lastSegment();
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.hasCollectionId = function(t) {
- return this.path.length >= 2 && this.path.get(this.path.length - 2) === t;
- },
- t.prototype.getCollectionGroup = function() {
- return this.path.get(this.path.length - 2);
- },
- t.prototype.getCollectionPath = function() {
- return this.path.popLast();
- }, t.prototype.isEqual = function(t) {
- return null !== t && 0 === ht.comparator(this.path, t.path);
- }, t.prototype.toString = function() {
- return this.path.toString();
- }, t.comparator = function(t, e) {
- return ht.comparator(t.path, e.path);
- }, t.isDocumentKey = function(t) {
- return t.length % 2 == 0;
- },
-
- t.fromSegments = function(e) {
- return new t(new ht(e.slice()));
- }, t;
- }(), vt = function(
- t,
- e,
- n,
- r) {
- this.indexId = t, this.collectionGroup = e, this.fields = n, this.indexState = r;
- };
- function mt(t) {
- return t.fields.find((function(t) {
- return 2 === t.kind;
- }));
- }
- function yt(t) {
- return t.fields.filter((function(t) {
- return 2 !== t.kind;
- }));
- }
- function gt(t, e) {
- var n = ot(t.collectionGroup, e.collectionGroup);
- if (0 !== n) return n;
- for (var r = 0; r < Math.min(t.fields.length, e.fields.length); ++r) if (0 !== (n = bt(t.fields[r], e.fields[r]))) return n;
- return ot(t.fields.length, e.fields.length);
- }
- vt.UNKNOWN_ID = -1;
- var wt = function(
- t,
- e) {
- this.fieldPath = t, this.kind = e;
- };
- function bt(t, e) {
- var n = dt.comparator(t.fieldPath, e.fieldPath);
- return 0 !== n ? n : ot(t.kind, e.kind);
- }
- var It = function() {
- function t(
-
- t,
-
- e) {
- this.sequenceNumber = t, this.offset = e
- ;
- }
- return t.empty = function() {
- return new t(0, St.min());
- }, t;
- }();
- function Et(t, e) {
-
-
-
-
-
-
- var n = t.toTimestamp().seconds, r = t.toTimestamp().nanoseconds + 1, i = ct.fromTimestamp(1e9 === r ? new st(n + 1, 0) : new st(n, r));
- return new St(i, pt.empty(), e);
- }
- function Tt(t) {
- return new St(t.readTime, t.key, -1);
- }
- var St = function() {
- function t(
-
- t,
-
- e,
-
- n) {
- this.readTime = t, this.documentKey = e, this.largestBatchId = n
- ;
- }
- return t.min = function() {
- return new t(ct.min(), pt.empty(), -1);
- },
- t.max = function() {
- return new t(ct.max(), pt.empty(), -1);
- }, t;
- }();
- function _t(t, e) {
- var n = t.readTime.compareTo(e.readTime);
- return 0 !== n ? n : 0 !== (n = pt.comparator(t.documentKey, e.documentKey)) ? n : ot(t.largestBatchId, e.largestBatchId);
- }
- var Dt = "The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.", Ct = function() {
- function t() {
- this.onCommittedListeners = [];
- }
- return t.prototype.addOnCommittedListener = function(t) {
- this.onCommittedListeners.push(t);
- }, t.prototype.raiseOnCommittedEvent = function() {
- this.onCommittedListeners.forEach((function(t) {
- return t();
- }));
- }, t;
- }();
- function xt(t) {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(e) {
- if (t.code !== K.FAILED_PRECONDITION || t.message !== Dt) throw t;
- return M("LocalStore", "Unexpectedly lost primary lease"), [ 2 ];
- }));
- }));
- }
- var Nt = function() {
- function t(t) {
- var e = this;
-
-
- this.nextCallback = null, this.catchCallback = null,
-
- this.result = void 0, this.error = void 0, this.isDone = !1,
-
-
- this.callbackAttached = !1, t((function(t) {
- e.isDone = !0, e.result = t, e.nextCallback &&
-
-
- e.nextCallback(t);
- }), (function(t) {
- e.isDone = !0, e.error = t, e.catchCallback && e.catchCallback(t);
- }));
- }
- return t.prototype.catch = function(t) {
- return this.next(void 0, t);
- }, t.prototype.next = function(e, n) {
- var r = this;
- return this.callbackAttached && U(), this.callbackAttached = !0, this.isDone ? this.error ? this.wrapFailure(n, this.error) : this.wrapSuccess(e, this.result) : new t((function(t, i) {
- r.nextCallback = function(n) {
- r.wrapSuccess(e, n).next(t, i);
- }, r.catchCallback = function(e) {
- r.wrapFailure(n, e).next(t, i);
- };
- }));
- }, t.prototype.toPromise = function() {
- var t = this;
- return new Promise((function(e, n) {
- t.next(e, n);
- }));
- }, t.prototype.wrapUserFunction = function(e) {
- try {
- var n = e();
- return n instanceof t ? n : t.resolve(n);
- } catch (e) {
- return t.reject(e);
- }
- }, t.prototype.wrapSuccess = function(e, n) {
- return e ? this.wrapUserFunction((function() {
- return e(n);
- })) : t.resolve(n);
- }, t.prototype.wrapFailure = function(e, n) {
- return e ? this.wrapUserFunction((function() {
- return e(n);
- })) : t.reject(n);
- }, t.resolve = function(e) {
- return new t((function(t, n) {
- t(e);
- }));
- }, t.reject = function(e) {
- return new t((function(t, n) {
- n(e);
- }));
- }, t.waitFor = function(
-
-
- e) {
- return new t((function(t, n) {
- var r = 0, i = 0, o = !1;
- e.forEach((function(e) {
- ++r, e.next((function() {
- ++i, o && i === r && t();
- }), (function(t) {
- return n(t);
- }));
- })), o = !0, i === r && t();
- }));
- },
-
- t.or = function(e) {
- for (var n = t.resolve(!1), r = function(e) {
- n = n.next((function(n) {
- return n ? t.resolve(n) : e();
- }));
- }, i = 0, o = e; i < o.length; i++) {
- r(o[i]);
- }
- return n;
- }, t.forEach = function(t, e) {
- var n = this, r = [];
- return t.forEach((function(t, i) {
- r.push(e.call(n, t, i));
- })), this.waitFor(r);
- },
-
- t.mapArray = function(e, n) {
- return new t((function(t, r) {
- for (var i = e.length, o = new Array(i), u = 0, a = function(a) {
- var s = a;
- n(e[s]).next((function(e) {
- o[s] = e, ++u === i && t(o);
- }), (function(t) {
- return r(t);
- }));
- }, s = 0; s < i; s++) a(s);
- }));
- },
-
- t.doWhile = function(e, n) {
- return new t((function(t, r) {
- var i = function() {
- !0 === e() ? n().next((function() {
- i();
- }), r) : t();
- };
- i();
- }));
- }, t;
- }(), At = function() {
- function t(t, e) {
- var n = this;
- this.action = t, this.transaction = e, this.aborted = !1,
-
- this.v = new W, this.transaction.oncomplete = function() {
- n.v.resolve();
- }, this.transaction.onabort = function() {
- e.error ? n.v.reject(new Ft(t, e.error)) : n.v.resolve();
- }, this.transaction.onerror = function(e) {
- var r = Lt(e.target.error);
- n.v.reject(new Ft(t, r));
- };
- }
- return t.open = function(e, n, r, i) {
- try {
- return new t(n, e.transaction(i, r));
- } catch (e) {
- throw new Ft(n, e);
- }
- }, Object.defineProperty(t.prototype, "R", {
- get: function() {
- return this.v.promise;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.abort = function(t) {
- t && this.v.reject(t), this.aborted || (M("SimpleDb", "Aborting transaction:", t ? t.message : "Client-initiated abort"),
- this.aborted = !0, this.transaction.abort());
- }, t.prototype.P = function() {
-
-
-
- var t = this.transaction;
- this.aborted || "function" != typeof t.commit || t.commit();
- },
-
- t.prototype.store = function(t) {
- var e = this.transaction.objectStore(t);
- return new Rt(e);
- }, t;
- }(), kt = function() {
-
- function t(e, n, r) {
- this.name = e, this.version = n, this.V = r,
-
-
-
-
- 12.2 === t.S(d()) && L("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");
- }
- return t.delete = function(t) {
- return M("SimpleDb", "Removing database:", t), Vt(window.indexedDB.deleteDatabase(t)).toPromise();
- },
- t.D = function() {
- if (!m()) return !1;
- if (t.C()) return !0;
-
-
-
-
-
-
-
- var e = d(), n = t.S(e), r = 0 < n && n < 10, i = t.N(e), o = 0 < i && i < 4.5;
-
-
-
-
-
-
-
-
- return !(e.indexOf("MSIE ") > 0 || e.indexOf("Trident/") > 0 || e.indexOf("Edge/") > 0 || r || o);
- },
-
- t.C = function() {
- var t;
- return "undefined" != typeof process && "YES" === (null === (t = process.env) || void 0 === t ? void 0 : t.k);
- },
- t.M = function(t, e) {
- return t.store(e);
- },
-
-
- t.S = function(t) {
- var e = t.match(/i(?:phone|pad|pod) os ([\d_]+)/i), n = e ? e[1].split("_").slice(0, 2).join(".") : "-1";
- return Number(n);
- },
-
-
- t.N = function(t) {
- var e = t.match(/Android ([\d.]+)/i), n = e ? e[1].split(".").slice(0, 2).join(".") : "-1";
- return Number(n);
- },
-
- t.prototype.$ = function(t) {
- return e(this, void 0, void 0, (function() {
- var e, r = this;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return this.db ? [ 3 , 2 ] : (M("SimpleDb", "Opening database:", this.name),
- e = this, [ 4 , new Promise((function(e, n) {
-
-
-
-
-
- var i = indexedDB.open(r.name, r.version);
- i.onsuccess = function(t) {
- var n = t.target.result;
- e(n);
- }, i.onblocked = function() {
- n(new Ft(t, "Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."));
- }, i.onerror = function(e) {
- var r = e.target.error;
- "VersionError" === r.name ? n(new Q(K.FAILED_PRECONDITION, "A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")) : "InvalidStateError" === r.name ? n(new Q(K.FAILED_PRECONDITION, "Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: " + r)) : n(new Ft(t, r));
- }, i.onupgradeneeded = function(t) {
- M("SimpleDb", 'Database "' + r.name + '" requires upgrade from version:', t.oldVersion);
- var e = t.target.result;
- r.V.O(e, i.transaction, t.oldVersion, r.version).next((function() {
- M("SimpleDb", "Database upgrade to version " + r.version + " complete");
- }));
- };
- })) ]);
- case 1:
- e.db = n.sent(), n.label = 2;
- case 2:
- return [ 2 , (this.F && (this.db.onversionchange = function(t) {
- return r.F(t);
- }), this.db) ];
- }
- }));
- }));
- }, t.prototype.B = function(t) {
- this.F = t, this.db && (this.db.onversionchange = function(e) {
- return t(e);
- });
- }, t.prototype.runTransaction = function(t, r, i, o) {
- return e(this, void 0, void 0, (function() {
- var e, u, a, s, c;
- return n(this, (function(l) {
- switch (l.label) {
- case 0:
- e = "readonly" === r, u = 0, a = function() {
- var r, a, c, l, h, f;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- ++u, n.label = 1;
- case 1:
- return n.trys.push([ 1, 4, , 5 ]), [ 4 , s.$(t) ];
- case 2:
-
-
-
- return s.db = n.sent(), r = At.open(s.db, t, e ? "readonly" : "readwrite", i), a = o(r).next((function(t) {
- return r.P(), t;
- })).catch((function(t) {
-
- return r.abort(t), Nt.reject(t);
- })).toPromise(), c = {}, a.catch((function() {})), [ 4 , r.R ];
- case 3:
- return [ 2 , (c.value = (
-
-
-
- n.sent(), a), c) ];
- case 4:
-
-
-
-
-
- return l = n.sent(), f = "FirebaseError" !== (h = l).name && u < 3, M("SimpleDb", "Transaction failed with error:", h.message, "Retrying:", f),
- s.close(), f ? [ 3 , 5 ] : [ 2 , {
- value: Promise.reject(h)
- } ];
- case 5:
- return [ 2 ];
- }
- }));
- }, s = this, l.label = 1;
- case 1:
- return [ 5 , a() ];
- case 2:
- if ("object" == typeof (c = l.sent())) return [ 2 , c.value ];
- l.label = 3;
- case 3:
- return [ 3 , 1 ];
- case 4:
- return [ 2 ];
- }
- }));
- }));
- }, t.prototype.close = function() {
- this.db && this.db.close(), this.db = void 0;
- }, t;
- }(), Ot = function() {
- function t(t) {
- this.L = t, this.q = !1, this.U = null;
- }
- return Object.defineProperty(t.prototype, "isDone", {
- get: function() {
- return this.q;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "K", {
- get: function() {
- return this.U;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "cursor", {
- set: function(t) {
- this.L = t;
- },
- enumerable: !1,
- configurable: !0
- }),
-
- t.prototype.done = function() {
- this.q = !0;
- },
-
- t.prototype.G = function(t) {
- this.U = t;
- },
-
- t.prototype.delete = function() {
- return Vt(this.L.delete());
- }, t;
- }(), Ft = function(e) {
- function n(t, n) {
- var r = this;
- return (r = e.call(this, K.UNAVAILABLE, "IndexedDB transaction '".concat(t, "' failed: ").concat(n)) || this).name = "IndexedDbTransactionError",
- r;
- }
- return t(n, e), n;
- }(Q);
- function Pt(t) {
-
-
- return "IndexedDbTransactionError" === t.name;
- }
- var Rt = function() {
- function t(t) {
- this.store = t;
- }
- return t.prototype.put = function(t, e) {
- var n;
- return void 0 !== e ? (M("SimpleDb", "PUT", this.store.name, t, e), n = this.store.put(e, t)) : (M("SimpleDb", "PUT", this.store.name, "<auto-key>", t),
- n = this.store.put(t)), Vt(n);
- },
-
- t.prototype.add = function(t) {
- return M("SimpleDb", "ADD", this.store.name, t, t), Vt(this.store.add(t));
- },
-
- t.prototype.get = function(t) {
- var e = this;
-
-
- return Vt(this.store.get(t)).next((function(n) {
-
- return void 0 === n && (n = null), M("SimpleDb", "GET", e.store.name, t, n), n;
- }));
- }, t.prototype.delete = function(t) {
- return M("SimpleDb", "DELETE", this.store.name, t), Vt(this.store.delete(t));
- },
-
- t.prototype.count = function() {
- return M("SimpleDb", "COUNT", this.store.name), Vt(this.store.count());
- }, t.prototype.j = function(t, e) {
- var n = this.options(t, e);
-
-
- if (n.index || "function" != typeof this.store.getAll) {
- var r = this.cursor(n), i = [];
- return this.W(r, (function(t, e) {
- i.push(e);
- })).next((function() {
- return i;
- }));
- }
- var o = this.store.getAll(n.range);
- return new Nt((function(t, e) {
- o.onerror = function(t) {
- e(t.target.error);
- }, o.onsuccess = function(e) {
- t(e.target.result);
- };
- }));
- },
-
- t.prototype.H = function(t, e) {
- var n = this.store.getAll(t, null === e ? void 0 : e);
- return new Nt((function(t, e) {
- n.onerror = function(t) {
- e(t.target.error);
- }, n.onsuccess = function(e) {
- t(e.target.result);
- };
- }));
- }, t.prototype.J = function(t, e) {
- M("SimpleDb", "DELETE ALL", this.store.name);
- var n = this.options(t, e);
- n.Y = !1;
- var r = this.cursor(n);
- return this.W(r, (function(t, e, n) {
- return n.delete();
- }));
- }, t.prototype.X = function(t, e) {
- var n;
- e ? n = t : (n = {}, e = t);
- var r = this.cursor(n);
- return this.W(r, e);
- },
-
- t.prototype.Z = function(t) {
- var e = this.cursor({});
- return new Nt((function(n, r) {
- e.onerror = function(t) {
- var e = Lt(t.target.error);
- r(e);
- }, e.onsuccess = function(e) {
- var r = e.target.result;
- r ? t(r.primaryKey, r.value).next((function(t) {
- t ? r.continue() : n();
- })) : n();
- };
- }));
- }, t.prototype.W = function(t, e) {
- var n = [];
- return new Nt((function(r, i) {
- t.onerror = function(t) {
- i(t.target.error);
- }, t.onsuccess = function(t) {
- var i = t.target.result;
- if (i) {
- var o = new Ot(i), u = e(i.primaryKey, i.value, o);
- if (u instanceof Nt) {
- var a = u.catch((function(t) {
- return o.done(), Nt.reject(t);
- }));
- n.push(a);
- }
- o.isDone ? r() : null === o.K ? i.continue() : i.continue(o.K);
- } else r();
- };
- })).next((function() {
- return Nt.waitFor(n);
- }));
- }, t.prototype.options = function(t, e) {
- var n;
- return void 0 !== t && ("string" == typeof t ? n = t : e = t), {
- index: n,
- range: e
- };
- }, t.prototype.cursor = function(t) {
- var e = "next";
- if (t.reverse && (e = "prev"), t.index) {
- var n = this.store.index(t.index);
- return t.Y ? n.openKeyCursor(t.range, e) : n.openCursor(t.range, e);
- }
- return this.store.openCursor(t.range, e);
- }, t;
- }();
- function Vt(t) {
- return new Nt((function(e, n) {
- t.onsuccess = function(t) {
- var n = t.target.result;
- e(n);
- }, t.onerror = function(t) {
- var e = Lt(t.target.error);
- n(e);
- };
- }));
- }
- var Mt = !1;
- function Lt(t) {
- var e = kt.S(d());
- if (e >= 12.2 && e < 13) {
- var n = "An internal error was encountered in the Indexed Database server";
- if (t.message.indexOf(n) >= 0) {
-
- var r = new Q("internal", "IOS_INDEXEDDB_BUG1: IndexedDb has thrown '".concat(n, "'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround."));
- return Mt || (Mt = !0,
-
-
- setTimeout((function() {
- throw r;
- }), 0)), r;
- }
- }
- return t;
- }
- var qt = function() {
- function t(t, e) {
- this.asyncQueue = t, this.tt = e, this.task = null;
- }
- return t.prototype.start = function() {
- this.et(15e3);
- }, t.prototype.stop = function() {
- this.task && (this.task.cancel(), this.task = null);
- }, Object.defineProperty(t.prototype, "started", {
- get: function() {
- return null !== this.task;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.et = function(t) {
- var r = this;
- M("IndexBackiller", "Scheduled in ".concat(t, "ms")), this.task = this.asyncQueue.enqueueAfterDelay("index_backfill" , t, (function() {
- return e(r, void 0, void 0, (function() {
- var t, e, r, i;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- this.task = null, n.label = 1;
- case 1:
- return n.trys.push([ 1, 3, , 7 ]), t = M, e = [ "IndexBackiller" ], r = "Documents written: ".concat,
- [ 4 , this.tt.nt() ];
- case 2:
- return t.apply(void 0, e.concat([ r.apply("Documents written: ", [ n.sent() ]) ])),
- [ 3 , 7 ];
- case 3:
- return Pt(i = n.sent()) ? (M("IndexBackiller", "Ignoring IndexedDB error during index backfill: ", i),
- [ 3 , 6 ]) : [ 3 , 4 ];
- case 4:
- return [ 4 , xt(i) ];
- case 5:
- n.sent(), n.label = 6;
- case 6:
- return [ 3 , 7 ];
- case 7:
- return [ 4 , this.et(6e4) ];
- case 8:
- return n.sent(), [ 2 ];
- }
- }));
- }));
- }));
- }, t;
- }(), Bt = function() {
- function t(
-
- t, e) {
- this.localStore = t, this.persistence = e;
- }
- return t.prototype.nt = function(t) {
- return void 0 === t && (t = 50), e(this, void 0, void 0, (function() {
- var e = this;
- return n(this, (function(n) {
- return [ 2 , this.persistence.runTransaction("Backfill Indexes", "readwrite-primary", (function(n) {
- return e.st(n, t);
- })) ];
- }));
- }));
- },
- t.prototype.st = function(t, e) {
- var n = this, r = new Set, i = e, o = !0;
- return Nt.doWhile((function() {
- return !0 === o && i > 0;
- }), (function() {
- return n.localStore.indexManager.getNextCollectionGroupToUpdate(t).next((function(e) {
- if (null !== e && !r.has(e)) return M("IndexBackiller", "Processing collection: ".concat(e)),
- n.it(t, e, i).next((function(t) {
- i -= t, r.add(e);
- }));
- o = !1;
- }));
- })).next((function() {
- return e - i;
- }));
- },
-
- t.prototype.it = function(t, e, n) {
- var r = this;
-
- return this.localStore.indexManager.getMinOffsetFromCollectionGroup(t, e).next((function(i) {
- return r.localStore.localDocuments.getNextDocuments(t, e, i, n).next((function(n) {
- var o = n.changes;
- return r.localStore.indexManager.updateIndexEntries(t, o).next((function() {
- return r.rt(i, n);
- })).next((function(n) {
- return M("IndexBackiller", "Updating offset: ".concat(n)), r.localStore.indexManager.updateCollectionGroup(t, e, n);
- })).next((function() {
- return o.size;
- }));
- }));
- }));
- },
- t.prototype.rt = function(t, e) {
- var n = t;
- return e.changes.forEach((function(t, e) {
- var r = Tt(e);
- _t(r, n) > 0 && (n = r);
- })), new St(n.readTime, n.documentKey, Math.max(e.batchId, t.largestBatchId));
- }, t;
- }(), Ut = function() {
- function t(t, e) {
- var n = this;
- this.previousValue = t, e && (e.sequenceNumberHandler = function(t) {
- return n.ot(t);
- }, this.ut = function(t) {
- return e.writeSequenceNumber(t);
- });
- }
- return t.prototype.ot = function(t) {
- return this.previousValue = Math.max(t, this.previousValue), this.previousValue;
- }, t.prototype.next = function() {
- var t = ++this.previousValue;
- return this.ut && this.ut(t), t;
- }, t;
- }();
- function zt(t) {
- return null == t;
- }
- function Gt(t) {
-
-
- return 0 === t && 1 / t == -1 / 0;
- }
- function jt(t) {
- return "number" == typeof t && Number.isInteger(t) && !Gt(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
- }
- function Kt(t) {
- for (var e = "", n = 0; n < t.length; n++) e.length > 0 && (e = Wt(e)), e = Qt(t.get(n), e);
- return Wt(e);
- }
- function Qt(t, e) {
- for (var n = e, r = t.length, i = 0; i < r; i++) {
- var o = t.charAt(i);
- switch (o) {
- case "\0":
- n += "";
- break;
- case "":
- n += "";
- break;
- default:
- n += o;
- }
- }
- return n;
- }
- function Wt(t) {
- return t + "";
- }
- function Ht(t) {
-
-
- var e = t.length;
- if (z(e >= 2), 2 === e) return z("" === t.charAt(0) && "" === t.charAt(1)), ht.emptyPath();
-
-
- for (var n = e - 2, r = [], i = "", o = 0; o < e; ) {
-
-
- var u = t.indexOf("", o);
- switch ((u < 0 || u > n) && U(), t.charAt(u + 1)) {
- case "":
- var a = t.substring(o, u), s = void 0;
- 0 === i.length ?
-
-
- s = a : (s = i += a, i = ""), r.push(s);
- break;
- case "":
- i += t.substring(o, u), i += "\0";
- break;
- case "":
-
- i += t.substring(o, u + 1);
- break;
- default:
- U();
- }
- o = u + 2;
- }
- return new ht(r);
- }
- Ut.ct = -1;
- var Yt = [ "userId", "batchId" ];
- function Xt(t, e) {
- return [ t, Kt(e) ];
- }
- function Jt(t, e, n) {
- return [ t, Kt(e), n ];
- }
- var Zt = {}, $t = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], te = [ "prefixPath", "collectionGroup", "documentId" ], ee = [ "collectionGroup", "readTime", "prefixPath", "documentId" ], ne = [ "canonicalId", "targetId" ], re = [ "targetId", "path" ], ie = [ "path", "targetId" ], oe = [ "collectionId", "parent" ], ue = [ "indexId", "uid" ], ae = [ "uid", "sequenceNumber" ], se = [ "indexId", "uid", "arrayValue", "directionalValue", "orderedDocumentKey", "documentKey" ], ce = [ "indexId", "uid", "orderedDocumentKey" ], le = [ "userId", "collectionPath", "documentId" ], he = [ "userId", "collectionPath", "largestBatchId" ], fe = [ "userId", "collectionGroup", "largestBatchId" ], de = r(r([], r(r([], r(r([], r(r([], [ "mutationQueues", "mutations", "documentMutations", "remoteDocuments", "targets", "owner", "targetGlobal", "targetDocuments" ], !1), [ "clientMetadata" ], !1), !0), [ "remoteDocumentGlobal" ], !1), !0), [ "collectionParents" ], !1), !0), [ "bundles", "namedQueries" ], !1), pe = r(r([], de, !0), [ "documentOverlays" ], !1), ve = [ "mutationQueues", "mutations", "documentMutations", "remoteDocumentsV14", "targets", "owner", "targetGlobal", "targetDocuments", "clientMetadata", "remoteDocumentGlobal", "collectionParents", "bundles", "namedQueries", "documentOverlays" ], me = ve, ye = r(r([], me, !0), [ "indexConfiguration", "indexState", "indexEntries" ], !1), ge = function(e) {
- function n(t, n) {
- var r = this;
- return (r = e.call(this) || this).ht = t, r.currentSequenceNumber = n, r;
- }
- return t(n, e), n;
- }(Ct);
- function we(t, e) {
- var n = j(t);
- return kt.M(n.ht, e);
- }
- function be(t) {
- var e = 0;
- for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
- return e;
- }
- function Ie(t, e) {
- for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
- }
- function Ee(t) {
- for (var e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
- return !0;
- }
- var Te = function() {
- function t(t, e) {
- this.comparator = t, this.root = e || _e.EMPTY;
- }
-
- return t.prototype.insert = function(e, n) {
- return new t(this.comparator, this.root.insert(e, n, this.comparator).copy(null, null, _e.BLACK, null, null));
- },
-
- t.prototype.remove = function(e) {
- return new t(this.comparator, this.root.remove(e, this.comparator).copy(null, null, _e.BLACK, null, null));
- },
-
- t.prototype.get = function(t) {
- for (var e = this.root; !e.isEmpty(); ) {
- var n = this.comparator(t, e.key);
- if (0 === n) return e.value;
- n < 0 ? e = e.left : n > 0 && (e = e.right);
- }
- return null;
- },
-
-
- t.prototype.indexOf = function(t) {
- for (
-
- var e = 0, n = this.root; !n.isEmpty(); ) {
- var r = this.comparator(t, n.key);
- if (0 === r) return e + n.left.size;
- r < 0 ? n = n.left : (
-
- e += n.left.size + 1, n = n.right);
- }
-
- return -1;
- }, t.prototype.isEmpty = function() {
- return this.root.isEmpty();
- }, Object.defineProperty(t.prototype, "size", {
-
- get: function() {
- return this.root.size;
- },
- enumerable: !1,
- configurable: !0
- }),
-
- t.prototype.minKey = function() {
- return this.root.minKey();
- },
-
- t.prototype.maxKey = function() {
- return this.root.maxKey();
- },
-
-
-
-
- t.prototype.inorderTraversal = function(t) {
- return this.root.inorderTraversal(t);
- }, t.prototype.forEach = function(t) {
- this.inorderTraversal((function(e, n) {
- return t(e, n), !1;
- }));
- }, t.prototype.toString = function() {
- var t = [];
- return this.inorderTraversal((function(e, n) {
- return t.push("".concat(e, ":").concat(n)), !1;
- })), "{".concat(t.join(", "), "}");
- },
-
-
-
-
-
- t.prototype.reverseTraversal = function(t) {
- return this.root.reverseTraversal(t);
- },
-
- t.prototype.getIterator = function() {
- return new Se(this.root, null, this.comparator, !1);
- }, t.prototype.getIteratorFrom = function(t) {
- return new Se(this.root, t, this.comparator, !1);
- }, t.prototype.getReverseIterator = function() {
- return new Se(this.root, null, this.comparator, !0);
- }, t.prototype.getReverseIteratorFrom = function(t) {
- return new Se(this.root, t, this.comparator, !0);
- }, t;
- }(), Se = function() {
- function t(t, e, n, r) {
- this.isReverse = r, this.nodeStack = [];
- for (var i = 1; !t.isEmpty(); ) if (i = e ? n(t.key, e) : 1,
-
- e && r && (i *= -1), i < 0)
-
- t = this.isReverse ? t.left : t.right; else {
- if (0 === i) {
-
-
- this.nodeStack.push(t);
- break;
- }
-
-
- this.nodeStack.push(t), t = this.isReverse ? t.right : t.left;
- }
- }
- return t.prototype.getNext = function() {
- var t = this.nodeStack.pop(), e = {
- key: t.key,
- value: t.value
- };
- if (this.isReverse) for (t = t.left; !t.isEmpty(); ) this.nodeStack.push(t), t = t.right; else for (t = t.right; !t.isEmpty(); ) this.nodeStack.push(t),
- t = t.left;
- return e;
- }, t.prototype.hasNext = function() {
- return this.nodeStack.length > 0;
- }, t.prototype.peek = function() {
- if (0 === this.nodeStack.length) return null;
- var t = this.nodeStack[this.nodeStack.length - 1];
- return {
- key: t.key,
- value: t.value
- };
- }, t;
- }(), _e = function() {
- function t(e, n, r, i, o) {
- this.key = e, this.value = n, this.color = null != r ? r : t.RED, this.left = null != i ? i : t.EMPTY,
- this.right = null != o ? o : t.EMPTY, this.size = this.left.size + 1 + this.right.size;
- }
-
- return t.prototype.copy = function(e, n, r, i, o) {
- 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);
- }, t.prototype.isEmpty = function() {
- return !1;
- },
-
-
-
-
- t.prototype.inorderTraversal = function(t) {
- return this.left.inorderTraversal(t) || t(this.key, this.value) || this.right.inorderTraversal(t);
- },
-
-
-
-
- t.prototype.reverseTraversal = function(t) {
- return this.right.reverseTraversal(t) || t(this.key, this.value) || this.left.reverseTraversal(t);
- },
-
- t.prototype.min = function() {
- return this.left.isEmpty() ? this : this.left.min();
- },
-
- t.prototype.minKey = function() {
- return this.min().key;
- },
-
- t.prototype.maxKey = function() {
- return this.right.isEmpty() ? this.key : this.right.maxKey();
- },
-
- t.prototype.insert = function(t, e, n) {
- var r = this, i = n(t, r.key);
- 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();
- }, t.prototype.removeMin = function() {
- if (this.left.isEmpty()) return t.EMPTY;
- var e = this;
- return e.left.isRed() || e.left.left.isRed() || (e = e.moveRedLeft()), (e = e.copy(null, null, null, e.left.removeMin(), null)).fixUp();
- },
-
- t.prototype.remove = function(e, n) {
- var r, i = this;
- if (n(e, i.key) < 0) i.left.isEmpty() || i.left.isRed() || i.left.left.isRed() || (i = i.moveRedLeft()),
- i = i.copy(null, null, null, i.left.remove(e, n), null); else {
- if (i.left.isRed() && (i = i.rotateRight()), i.right.isEmpty() || i.right.isRed() || i.right.left.isRed() || (i = i.moveRedRight()),
- 0 === n(e, i.key)) {
- if (i.right.isEmpty()) return t.EMPTY;
- r = i.right.min(), i = i.copy(r.key, r.value, null, null, i.right.removeMin());
- }
- i = i.copy(null, null, null, null, i.right.remove(e, n));
- }
- return i.fixUp();
- }, t.prototype.isRed = function() {
- return this.color;
- },
-
- t.prototype.fixUp = function() {
- var t = this;
- return t.right.isRed() && !t.left.isRed() && (t = t.rotateLeft()), t.left.isRed() && t.left.left.isRed() && (t = t.rotateRight()),
- t.left.isRed() && t.right.isRed() && (t = t.colorFlip()), t;
- }, t.prototype.moveRedLeft = function() {
- var t = this.colorFlip();
- return t.right.left.isRed() && (t = (t = (t = t.copy(null, null, null, null, t.right.rotateRight())).rotateLeft()).colorFlip()),
- t;
- }, t.prototype.moveRedRight = function() {
- var t = this.colorFlip();
- return t.left.left.isRed() && (t = (t = t.rotateRight()).colorFlip()), t;
- }, t.prototype.rotateLeft = function() {
- var e = this.copy(null, null, t.RED, null, this.right.left);
- return this.right.copy(null, null, this.color, e, null);
- }, t.prototype.rotateRight = function() {
- var e = this.copy(null, null, t.RED, this.left.right, null);
- return this.left.copy(null, null, this.color, null, e);
- }, t.prototype.colorFlip = function() {
- var t = this.left.copy(null, null, !this.left.color, null, null), e = this.right.copy(null, null, !this.right.color, null, null);
- return this.copy(null, null, !this.color, t, e);
- },
-
- t.prototype.checkMaxDepth = function() {
- var t = this.check();
- return Math.pow(2, t) <= this.size + 1;
- },
-
-
- t.prototype.check = function() {
- if (this.isRed() && this.left.isRed()) throw U();
- if (this.right.isRed()) throw U();
- var t = this.left.check();
- if (t !== this.right.check()) throw U();
- return t + (this.isRed() ? 0 : 1);
- }, t;
- }();
- _e.EMPTY = null, _e.RED = !0, _e.BLACK = !1,
- _e.EMPTY = new ( function() {
- function t() {
- this.size = 0;
- }
- return Object.defineProperty(t.prototype, "key", {
- get: function() {
- throw U();
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "value", {
- get: function() {
- throw U();
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "color", {
- get: function() {
- throw U();
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "left", {
- get: function() {
- throw U();
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "right", {
- get: function() {
- throw U();
- },
- enumerable: !1,
- configurable: !0
- }),
-
- t.prototype.copy = function(t, e, n, r, i) {
- return this;
- },
-
- t.prototype.insert = function(t, e, n) {
- return new _e(t, e);
- },
-
- t.prototype.remove = function(t, e) {
- return this;
- }, t.prototype.isEmpty = function() {
- return !0;
- }, t.prototype.inorderTraversal = function(t) {
- return !1;
- }, t.prototype.reverseTraversal = function(t) {
- return !1;
- }, t.prototype.minKey = function() {
- return null;
- }, t.prototype.maxKey = function() {
- return null;
- }, t.prototype.isRed = function() {
- return !1;
- },
-
- t.prototype.checkMaxDepth = function() {
- return !0;
- }, t.prototype.check = function() {
- return 0;
- }, t;
- }());
- var De = function() {
- function t(t) {
- this.comparator = t, this.data = new Te(this.comparator);
- }
- return t.prototype.has = function(t) {
- return null !== this.data.get(t);
- }, t.prototype.first = function() {
- return this.data.minKey();
- }, t.prototype.last = function() {
- return this.data.maxKey();
- }, Object.defineProperty(t.prototype, "size", {
- get: function() {
- return this.data.size;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.indexOf = function(t) {
- return this.data.indexOf(t);
- },
- t.prototype.forEach = function(t) {
- this.data.inorderTraversal((function(e, n) {
- return t(e), !1;
- }));
- },
- t.prototype.forEachInRange = function(t, e) {
- for (var n = this.data.getIteratorFrom(t[0]); n.hasNext(); ) {
- var r = n.getNext();
- if (this.comparator(r.key, t[1]) >= 0) return;
- e(r.key);
- }
- },
-
- t.prototype.forEachWhile = function(t, e) {
- var n;
- for (n = void 0 !== e ? this.data.getIteratorFrom(e) : this.data.getIterator(); n.hasNext(); ) if (!t(n.getNext().key)) return;
- },
- t.prototype.firstAfterOrEqual = function(t) {
- var e = this.data.getIteratorFrom(t);
- return e.hasNext() ? e.getNext().key : null;
- }, t.prototype.getIterator = function() {
- return new Ce(this.data.getIterator());
- }, t.prototype.getIteratorFrom = function(t) {
- return new Ce(this.data.getIteratorFrom(t));
- },
- t.prototype.add = function(t) {
- return this.copy(this.data.remove(t).insert(t, !0));
- },
- t.prototype.delete = function(t) {
- return this.has(t) ? this.copy(this.data.remove(t)) : this;
- }, t.prototype.isEmpty = function() {
- return this.data.isEmpty();
- }, t.prototype.unionWith = function(t) {
- var e = this;
-
- return e.size < t.size && (e = t, t = this), t.forEach((function(t) {
- e = e.add(t);
- })), e;
- }, t.prototype.isEqual = function(e) {
- if (!(e instanceof t)) return !1;
- if (this.size !== e.size) return !1;
- for (var n = this.data.getIterator(), r = e.data.getIterator(); n.hasNext(); ) {
- var i = n.getNext().key, o = r.getNext().key;
- if (0 !== this.comparator(i, o)) return !1;
- }
- return !0;
- }, t.prototype.toArray = function() {
- var t = [];
- return this.forEach((function(e) {
- t.push(e);
- })), t;
- }, t.prototype.toString = function() {
- var t = [];
- return this.forEach((function(e) {
- return t.push(e);
- })), "SortedSet(" + t.toString() + ")";
- }, t.prototype.copy = function(e) {
- var n = new t(this.comparator);
- return n.data = e, n;
- }, t;
- }(), Ce = function() {
- function t(t) {
- this.iter = t;
- }
- return t.prototype.getNext = function() {
- return this.iter.getNext().key;
- }, t.prototype.hasNext = function() {
- return this.iter.hasNext();
- }, t;
- }();
- function xe(t) {
- return t.hasNext() ? t.getNext() : void 0;
- }
- var Ne = function() {
- function t(t) {
- this.fields = t,
-
-
- t.sort(dt.comparator);
- }
- return t.empty = function() {
- return new t([]);
- },
-
- t.prototype.unionWith = function(e) {
- for (var n = new De(dt.comparator), r = 0, i = this.fields; r < i.length; r++) {
- var o = i[r];
- n = n.add(o);
- }
- for (var u = 0, a = e; u < a.length; u++) {
- var s = a[u];
- n = n.add(s);
- }
- return new t(n.toArray());
- },
-
- t.prototype.covers = function(t) {
- for (var e = 0, n = this.fields; e < n.length; e++) {
- if (n[e].isPrefixOf(t)) return !0;
- }
- return !1;
- }, t.prototype.isEqual = function(t) {
- return ut(this.fields, t.fields, (function(t, e) {
- return t.isEqual(e);
- }));
- }, t;
- }(), Ae = function(e) {
- function n() {
- var t = this;
- return (t = e.apply(this, arguments) || this).name = "Base64DecodeError", t;
- }
- return t(n, e), n;
- }(Error);
- function ke() {
- return "undefined" != typeof atob;
- }
- var Oe = function() {
- function t(t) {
- this.binaryString = t;
- }
- return t.fromBase64String = function(e) {
- var n = function(t) {
- try {
- return atob(t);
- } catch (t) {
-
-
-
- throw "undefined" != typeof DOMException && t instanceof DOMException ? new Ae("Invalid base64 string: " + t) : t;
- }
- }(e);
- return new t(n);
- }, t.fromUint8Array = function(e) {
-
-
- var n =
-
- function(t) {
- for (var e = "", n = 0; n < t.length; ++n) e += String.fromCharCode(t[n]);
- return e;
- }(e);
- return new t(n);
- }, t.prototype[Symbol.iterator] = function() {
- var t = this, e = 0;
- return {
- next: function() {
- return e < t.binaryString.length ? {
- value: t.binaryString.charCodeAt(e++),
- done: !1
- } : {
- value: void 0,
- done: !0
- };
- }
- };
- }, t.prototype.toBase64 = function() {
- return t = this.binaryString, btoa(t);
- var t;
- }, t.prototype.toUint8Array = function() {
- return function(t) {
- for (var e = new Uint8Array(t.length), n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
- return e;
- }(this.binaryString);
- }, t.prototype.approximateByteSize = function() {
- return 2 * this.binaryString.length;
- }, t.prototype.compareTo = function(t) {
- return ot(this.binaryString, t.binaryString);
- }, t.prototype.isEqual = function(t) {
- return this.binaryString === t.binaryString;
- }, t;
- }();
- Oe.EMPTY_BYTE_STRING = new Oe("");
- var Fe = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
- function Pe(t) {
-
-
-
- if (z(!!t), "string" == typeof t) {
-
-
-
- var e = 0, n = Fe.exec(t);
- if (z(!!n), n[1]) {
-
- var r = n[1];
- r = (r + "000000000").substr(0, 9), e = Number(r);
- }
-
- var i = new Date(t);
- return {
- seconds: Math.floor(i.getTime() / 1e3),
- nanos: e
- };
- }
- return {
- seconds: Re(t.seconds),
- nanos: Re(t.nanos)
- };
- }
- function Re(t) {
-
- return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
- }
- function Ve(t) {
- return "string" == typeof t ? Oe.fromBase64String(t) : Oe.fromUint8Array(t);
- }
- function Me(t) {
- var e, n;
- 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);
- }
- function Le(t) {
- var e = t.mapValue.fields.__previous_value__;
- return Me(e) ? Le(e) : e;
- }
- function qe(t) {
- var e = Pe(t.mapValue.fields.__local_write_time__.timestampValue);
- return new st(e.seconds, e.nanos);
- }
- var Be =
- function(t, e, n, r, i, o, u, a, s) {
- this.databaseId = t, this.appId = e, this.persistenceKey = n, this.host = r, this.ssl = i,
- this.forceLongPolling = o, this.autoDetectLongPolling = u, this.longPollingOptions = a,
- this.useFetchStreams = s;
- }, Ue = function() {
- function t(t, e) {
- this.projectId = t, this.database = e || "(default)";
- }
- return t.empty = function() {
- return new t("", "");
- }, Object.defineProperty(t.prototype, "isDefaultDatabase", {
- get: function() {
- return "(default)" === this.database;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.isEqual = function(e) {
- return e instanceof t && e.projectId === this.projectId && e.database === this.database;
- }, t;
- }(), ze = {
- mapValue: {
- fields: {
- __type__: {
- stringValue: "__max__"
- }
- }
- }
- }, Ge = {
- nullValue: "NULL_VALUE"
- };
- function je(t) {
- return "nullValue" in t ? 0 : "booleanValue" in t ? 1 : "integerValue" in t || "doubleValue" in t ? 2 : "timestampValue" in t ? 3 : "stringValue" in t ? 5 : "bytesValue" in t ? 6 : "referenceValue" in t ? 7 : "geoPointValue" in t ? 8 : "arrayValue" in t ? 9 : "mapValue" in t ? Me(t) ? 4 : un(t) ? 9007199254740991 : 10 : U();
- }
- function Ke(t, e) {
- if (t === e) return !0;
- var n = je(t);
- if (n !== je(e)) return !1;
- switch (n) {
- case 0 :
- case 9007199254740991 :
- return !0;
- case 1 :
- return t.booleanValue === e.booleanValue;
- case 4 :
- return qe(t).isEqual(qe(e));
- case 3 :
- return function(t, e) {
- if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
-
- return t.timestampValue === e.timestampValue;
- var n = Pe(t.timestampValue), r = Pe(e.timestampValue);
- return n.seconds === r.seconds && n.nanos === r.nanos;
- }(t, e);
- case 5 :
- return t.stringValue === e.stringValue;
- case 6 :
- return function(t, e) {
- return Ve(t.bytesValue).isEqual(Ve(e.bytesValue));
- }(t, e);
- case 7 :
- return t.referenceValue === e.referenceValue;
- case 8 :
- return function(t, e) {
- return Re(t.geoPointValue.latitude) === Re(e.geoPointValue.latitude) && Re(t.geoPointValue.longitude) === Re(e.geoPointValue.longitude);
- }(t, e);
- case 2 :
- return function(t, e) {
- if ("integerValue" in t && "integerValue" in e) return Re(t.integerValue) === Re(e.integerValue);
- if ("doubleValue" in t && "doubleValue" in e) {
- var n = Re(t.doubleValue), r = Re(e.doubleValue);
- return n === r ? Gt(n) === Gt(r) : isNaN(n) && isNaN(r);
- }
- return !1;
- }(t, e);
- case 9 :
- return ut(t.arrayValue.values || [], e.arrayValue.values || [], Ke);
- case 10 :
- return function(t, e) {
- var n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
- if (be(n) !== be(r)) return !1;
- for (var i in n) if (n.hasOwnProperty(i) && (void 0 === r[i] || !Ke(n[i], r[i]))) return !1;
- return !0;
- }(t, e);
- default:
- return U();
- }
- }
- function Qe(t, e) {
- return void 0 !== (t.values || []).find((function(t) {
- return Ke(t, e);
- }));
- }
- function We(t, e) {
- if (t === e) return 0;
- var n = je(t), r = je(e);
- if (n !== r) return ot(n, r);
- switch (n) {
- case 0 :
- case 9007199254740991 :
- return 0;
- case 1 :
- return ot(t.booleanValue, e.booleanValue);
- case 2 :
- return function(t, e) {
- var n = Re(t.integerValue || t.doubleValue), r = Re(e.integerValue || e.doubleValue);
- return n < r ? -1 : n > r ? 1 : n === r ? 0 :
-
- isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
- }(t, e);
- case 3 :
- return He(t.timestampValue, e.timestampValue);
- case 4 :
- return He(qe(t), qe(e));
- case 5 :
- return ot(t.stringValue, e.stringValue);
- case 6 :
- return function(t, e) {
- var n = Ve(t), r = Ve(e);
- return n.compareTo(r);
- }(t.bytesValue, e.bytesValue);
- case 7 :
- return function(t, e) {
- for (var n = t.split("/"), r = e.split("/"), i = 0; i < n.length && i < r.length; i++) {
- var o = ot(n[i], r[i]);
- if (0 !== o) return o;
- }
- return ot(n.length, r.length);
- }(t.referenceValue, e.referenceValue);
- case 8 :
- return function(t, e) {
- var n = ot(Re(t.latitude), Re(e.latitude));
- return 0 !== n ? n : ot(Re(t.longitude), Re(e.longitude));
- }(t.geoPointValue, e.geoPointValue);
- case 9 :
- return function(t, e) {
- for (var n = t.values || [], r = e.values || [], i = 0; i < n.length && i < r.length; ++i) {
- var o = We(n[i], r[i]);
- if (o) return o;
- }
- return ot(n.length, r.length);
- }(t.arrayValue, e.arrayValue);
- case 10 :
- return function(t, e) {
- if (t === ze.mapValue && e === ze.mapValue) return 0;
- if (t === ze.mapValue) return 1;
- if (e === ze.mapValue) return -1;
- var n = t.fields || {}, r = Object.keys(n), i = e.fields || {}, o = Object.keys(i);
-
-
-
-
- r.sort(), o.sort();
- for (var u = 0; u < r.length && u < o.length; ++u) {
- var a = ot(r[u], o[u]);
- if (0 !== a) return a;
- var s = We(n[r[u]], i[o[u]]);
- if (0 !== s) return s;
- }
- return ot(r.length, o.length);
- }(t.mapValue, e.mapValue);
- default:
- throw U();
- }
- }
- function He(t, e) {
- if ("string" == typeof t && "string" == typeof e && t.length === e.length) return ot(t, e);
- var n = Pe(t), r = Pe(e), i = ot(n.seconds, r.seconds);
- return 0 !== i ? i : ot(n.nanos, r.nanos);
- }
- function Ye(t) {
- return Xe(t);
- }
- function Xe(t) {
- return "nullValue" in t ? "null" : "booleanValue" in t ? "" + t.booleanValue : "integerValue" in t ? "" + t.integerValue : "doubleValue" in t ? "" + t.doubleValue : "timestampValue" in t ? function(t) {
- var e = Pe(t);
- return "time(".concat(e.seconds, ",").concat(e.nanos, ")");
- }(t.timestampValue) : "stringValue" in t ? t.stringValue : "bytesValue" in t ? Ve(t.bytesValue).toBase64() : "referenceValue" in t ? (n = t.referenceValue,
- pt.fromName(n).toString()) : "geoPointValue" in t ? "geo(".concat((e = t.geoPointValue).latitude, ",").concat(e.longitude, ")") : "arrayValue" in t ? function(t) {
- for (var e = "[", n = !0, r = 0, i = t.values || []; r < i.length; r++) {
- n ? n = !1 : e += ",", e += Xe(i[r]);
- }
- return e + "]";
- }(t.arrayValue) : "mapValue" in t ? function(t) {
- for (
-
-
- var e = "{", n = !0, r = 0, i = Object.keys(t.fields || {}).sort(); r < i.length; r++) {
- var o = i[r];
- n ? n = !1 : e += ",", e += "".concat(o, ":").concat(Xe(t.fields[o]));
- }
- return e + "}";
- }(t.mapValue) : U();
- var e, n;
- }
- function Je(t) {
- switch (je(t)) {
- case 0 :
- case 1 :
- return 4;
- case 2 :
- return 8;
- case 3 :
- case 8 :
-
- return 16;
- case 4 :
- var e = Le(t);
- return e ? 16 + Je(e) : 16;
- case 5 :
-
-
-
- return 2 * t.stringValue.length;
- case 6 :
- return Ve(t.bytesValue).approximateByteSize();
- case 7 :
- return t.referenceValue.length;
- case 9 :
- return (t.arrayValue.values || []).reduce((function(t, e) {
- return t + Je(e);
- }), 0);
- case 10 :
- return function(t) {
- var e = 0;
- return Ie(t.fields, (function(t, n) {
- e += t.length + Je(n);
- })), e;
- }(t.mapValue);
- default:
- throw U();
- }
- }
- function Ze(t, e) {
- return {
- referenceValue: "projects/".concat(t.projectId, "/databases/").concat(t.database, "/documents/").concat(e.path.canonicalString())
- };
- }
- function $e(t) {
- return !!t && "integerValue" in t;
- }
- function tn(t) {
- return !!t && "arrayValue" in t;
- }
- function en(t) {
- return !!t && "nullValue" in t;
- }
- function nn(t) {
- return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
- }
- function rn(t) {
- return !!t && "mapValue" in t;
- }
- function on(t) {
- if (t.geoPointValue) return {
- geoPointValue: Object.assign({}, t.geoPointValue)
- };
- if (t.timestampValue && "object" == typeof t.timestampValue) return {
- timestampValue: Object.assign({}, t.timestampValue)
- };
- if (t.mapValue) {
- var e = {
- mapValue: {
- fields: {}
- }
- };
- return Ie(t.mapValue.fields, (function(t, n) {
- return e.mapValue.fields[t] = on(n);
- })), e;
- }
- if (t.arrayValue) {
- for (var n = {
- arrayValue: {
- values: []
- }
- }, r = 0; r < (t.arrayValue.values || []).length; ++r) n.arrayValue.values[r] = on(t.arrayValue.values[r]);
- return n;
- }
- return Object.assign({}, t);
- }
- function un(t) {
- return "__max__" === (((t.mapValue || {}).fields || {}).__type__ || {}).stringValue;
- }
- function an(t) {
- return "nullValue" in t ? Ge : "booleanValue" in t ? {
- booleanValue: !1
- } : "integerValue" in t || "doubleValue" in t ? {
- doubleValue: NaN
- } : "timestampValue" in t ? {
- timestampValue: {
- seconds: Number.MIN_SAFE_INTEGER
- }
- } : "stringValue" in t ? {
- stringValue: ""
- } : "bytesValue" in t ? {
- bytesValue: ""
- } : "referenceValue" in t ? Ze(Ue.empty(), pt.empty()) : "geoPointValue" in t ? {
- geoPointValue: {
- latitude: -90,
- longitude: -180
- }
- } : "arrayValue" in t ? {
- arrayValue: {}
- } : "mapValue" in t ? {
- mapValue: {}
- } : U();
- }
- function sn(t) {
- return "nullValue" in t ? {
- booleanValue: !1
- } : "booleanValue" in t ? {
- doubleValue: NaN
- } : "integerValue" in t || "doubleValue" in t ? {
- timestampValue: {
- seconds: Number.MIN_SAFE_INTEGER
- }
- } : "timestampValue" in t ? {
- stringValue: ""
- } : "stringValue" in t ? {
- bytesValue: ""
- } : "bytesValue" in t ? Ze(Ue.empty(), pt.empty()) : "referenceValue" in t ? {
- geoPointValue: {
- latitude: -90,
- longitude: -180
- }
- } : "geoPointValue" in t ? {
- arrayValue: {}
- } : "arrayValue" in t ? {
- mapValue: {}
- } : "mapValue" in t ? ze : U();
- }
- function cn(t, e) {
- var n = We(t.value, e.value);
- return 0 !== n ? n : t.inclusive && !e.inclusive ? -1 : !t.inclusive && e.inclusive ? 1 : 0;
- }
- function ln(t, e) {
- var n = We(t.value, e.value);
- return 0 !== n ? n : t.inclusive && !e.inclusive ? 1 : !t.inclusive && e.inclusive ? -1 : 0;
- }
- var hn = function() {
- function t(t) {
- this.value = t;
- }
- return t.empty = function() {
- return new t({
- mapValue: {}
- });
- },
-
- t.prototype.field = function(t) {
- if (t.isEmpty()) return this.value;
- for (var e = this.value, n = 0; n < t.length - 1; ++n) if (!rn(e = (e.mapValue.fields || {})[t.get(n)])) return null;
- return (e = (e.mapValue.fields || {})[t.lastSegment()]) || null;
- },
-
- t.prototype.set = function(t, e) {
- this.getFieldsMap(t.popLast())[t.lastSegment()] = on(e);
- },
-
- t.prototype.setAll = function(t) {
- var e = this, n = dt.emptyPath(), r = {}, i = [];
- t.forEach((function(t, o) {
- if (!n.isImmediateParentOf(o)) {
-
- var u = e.getFieldsMap(n);
- e.applyChanges(u, r, i), r = {}, i = [], n = o.popLast();
- }
- t ? r[o.lastSegment()] = on(t) : i.push(o.lastSegment());
- }));
- var o = this.getFieldsMap(n);
- this.applyChanges(o, r, i);
- },
-
- t.prototype.delete = function(t) {
- var e = this.field(t.popLast());
- rn(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
- }, t.prototype.isEqual = function(t) {
- return Ke(this.value, t.value);
- },
-
- t.prototype.getFieldsMap = function(t) {
- var e = this.value;
- e.mapValue.fields || (e.mapValue = {
- fields: {}
- });
- for (var n = 0; n < t.length; ++n) {
- var r = e.mapValue.fields[t.get(n)];
- rn(r) && r.mapValue.fields || (r = {
- mapValue: {
- fields: {}
- }
- }, e.mapValue.fields[t.get(n)] = r), e = r;
- }
- return e.mapValue.fields;
- },
-
- t.prototype.applyChanges = function(t, e, n) {
- Ie(e, (function(e, n) {
- return t[e] = n;
- }));
- for (var r = 0, i = n; r < i.length; r++) {
- var o = i[r];
- delete t[o];
- }
- }, t.prototype.clone = function() {
- return new t(on(this.value));
- }, t;
- }();
- function fn(t) {
- var e = [];
- return Ie(t.fields, (function(t, n) {
- var r = new dt([ t ]);
- if (rn(n)) {
- var i = fn(n.mapValue).fields;
- if (0 === i.length)
-
- e.push(r); else
-
-
- for (var o = 0, u = i; o < u.length; o++) {
- var a = u[o];
- e.push(r.child(a));
- }
- } else
-
-
- e.push(r);
- })), new Ne(e)
-
-
- ;
- }
- var dn = function() {
- function t(t, e, n, r, i, o, u) {
- this.key = t, this.documentType = e, this.version = n, this.readTime = r, this.createTime = i,
- this.data = o, this.documentState = u
-
- ;
- }
- return t.newInvalidDocument = function(e) {
- return new t(e, 0 ,
- ct.min(),
- ct.min(),
- ct.min(), hn.empty(), 0 );
- },
-
- t.newFoundDocument = function(e, n, r, i) {
- return new t(e, 1 ,
- n,
- ct.min(),
- r, i, 0 );
- },
- t.newNoDocument = function(e, n) {
- return new t(e, 2 ,
- n,
- ct.min(),
- ct.min(), hn.empty(), 0 );
- },
-
- t.newUnknownDocument = function(e, n) {
- return new t(e, 3 ,
- n,
- ct.min(),
- ct.min(), hn.empty(), 2 );
- },
-
- t.prototype.convertToFoundDocument = function(t, e) {
-
-
-
-
-
- return !this.createTime.isEqual(ct.min()) || 2 !== this.documentType && 0 !== this.documentType || (this.createTime = t),
- this.version = t, this.documentType = 1 , this.data = e,
- this.documentState = 0 , this;
- },
-
- t.prototype.convertToNoDocument = function(t) {
- return this.version = t, this.documentType = 2 ,
- this.data = hn.empty(), this.documentState = 0 , this;
- },
-
- t.prototype.convertToUnknownDocument = function(t) {
- return this.version = t, this.documentType = 3 ,
- this.data = hn.empty(), this.documentState = 2 ,
- this;
- }, t.prototype.setHasCommittedMutations = function() {
- return this.documentState = 2 , this;
- }, t.prototype.setHasLocalMutations = function() {
- return this.documentState = 1 , this.version = ct.min(),
- this;
- }, t.prototype.setReadTime = function(t) {
- return this.readTime = t, this;
- }, Object.defineProperty(t.prototype, "hasLocalMutations", {
- get: function() {
- return 1 === this.documentState;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "hasCommittedMutations", {
- get: function() {
- return 2 === this.documentState;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "hasPendingWrites", {
- get: function() {
- return this.hasLocalMutations || this.hasCommittedMutations;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.isValidDocument = function() {
- return 0 !== this.documentType;
- }, t.prototype.isFoundDocument = function() {
- return 1 === this.documentType;
- }, t.prototype.isNoDocument = function() {
- return 2 === this.documentType;
- }, t.prototype.isUnknownDocument = function() {
- return 3 === this.documentType;
- }, t.prototype.isEqual = function(e) {
- 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);
- }, t.prototype.mutableCopy = function() {
- return new t(this.key, this.documentType, this.version, this.readTime, this.createTime, this.data.clone(), this.documentState);
- }, t.prototype.toString = function() {
- 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, "})");
- }, t;
- }(), pn = function(t, e) {
- this.position = t, this.inclusive = e;
- };
- function vn(t, e, n) {
- for (var r = 0, i = 0; i < t.position.length; i++) {
- var o = e[i], u = t.position[i];
- if (r = o.field.isKeyField() ? pt.comparator(pt.fromName(u.referenceValue), n.key) : We(u, n.data.field(o.field)),
- "desc" === o.dir && (r *= -1), 0 !== r) break;
- }
- return r;
- }
- function mn(t, e) {
- if (null === t) return null === e;
- if (null === e) return !1;
- if (t.inclusive !== e.inclusive || t.position.length !== e.position.length) return !1;
- for (var n = 0; n < t.position.length; n++) if (!Ke(t.position[n], e.position[n])) return !1;
- return !0;
- }
- var yn = function(t, e ) {
- void 0 === e && (e = "asc"), this.field = t, this.dir = e;
- };
- function gn(t, e) {
- return t.dir === e.dir && t.field.isEqual(e.field);
- }
- var wn = function() {}, bn = function(e) {
- function n(t, n, r) {
- var i = this;
- return (i = e.call(this) || this).field = t, i.op = n, i.value = r, i;
- }
-
- return t(n, e), n.create = function(t, e, r) {
- return t.isKeyField() ? "in" === e || "not-in" === e ? this.createKeyFieldInFilter(t, e, r) : new An(t, e, r) : "array-contains" === e ? new Pn(t, r) : "in" === e ? new Rn(t, r) : "not-in" === e ? new Vn(t, r) : "array-contains-any" === e ? new Mn(t, r) : new n(t, e, r);
- }, n.createKeyFieldInFilter = function(t, e, n) {
- return "in" === e ? new kn(t, n) : new On(t, n);
- }, n.prototype.matches = function(t) {
- var e = t.data.field(this.field);
-
- return "!=" === this.op ? null !== e && this.matchesComparison(We(e, this.value)) : null !== e && je(this.value) === je(e) && this.matchesComparison(We(e, this.value));
-
- }, n.prototype.matchesComparison = function(t) {
- switch (this.op) {
- case "<" :
- return t < 0;
- case "<=" :
- return t <= 0;
- case "==" :
- return 0 === t;
- case "!=" :
- return 0 !== t;
- case ">" :
- return t > 0;
- case ">=" :
- return t >= 0;
- default:
- return U();
- }
- }, n.prototype.isInequality = function() {
- return [ "<" , "<=" , ">" , ">=" , "!=" , "not-in" ].indexOf(this.op) >= 0;
- }, n.prototype.getFlattenedFilters = function() {
- return [ this ];
- }, n.prototype.getFilters = function() {
- return [ this ];
- }, n.prototype.getFirstInequalityField = function() {
- return this.isInequality() ? this.field : null;
- }, n;
- }(wn), In = function(e) {
- function n(t, n) {
- var r = this;
- return (r = e.call(this) || this).filters = t, r.op = n, r.lt = null, r;
- }
-
- return t(n, e), n.create = function(t, e) {
- return new n(t, e);
- }, n.prototype.matches = function(t) {
- return En(this) ? void 0 === this.filters.find((function(e) {
- return !e.matches(t);
- })) : void 0 !== this.filters.find((function(e) {
- return e.matches(t);
- }));
- }, n.prototype.getFlattenedFilters = function() {
- return null !== this.lt || (this.lt = this.filters.reduce((function(t, e) {
- return t.concat(e.getFlattenedFilters());
- }), [])), this.lt;
- },
-
- n.prototype.getFilters = function() {
- return Object.assign([], this.filters);
- }, n.prototype.getFirstInequalityField = function() {
- var t = this.ft((function(t) {
- return t.isInequality();
- }));
- return null !== t ? t.field : null;
- },
-
-
-
- n.prototype.ft = function(t) {
- for (var e = 0, n = this.getFlattenedFilters(); e < n.length; e++) {
- var r = n[e];
- if (t(r)) return r;
- }
- return null;
- }, n;
- }(wn);
- function En(t) {
- return "and" === t.op;
- }
- function Tn(t) {
- return "or" === t.op;
- }
- function Sn(t) {
- return _n(t) && En(t);
- }
- function _n(t) {
- for (var e = 0, n = t.filters; e < n.length; e++) {
- if (n[e] instanceof In) return !1;
- }
- return !0;
- }
- function Dn(t) {
- if (t instanceof bn)
-
-
-
- return t.field.canonicalString() + t.op.toString() + Ye(t.value);
- if (Sn(t))
-
-
-
-
-
-
- return t.filters.map((function(t) {
- return Dn(t);
- })).join(",");
-
- var e = t.filters.map((function(t) {
- return Dn(t);
- })).join(",");
- return "".concat(t.op, "(").concat(e, ")");
- }
- function Cn(t, e) {
- return t instanceof bn ? function(t, e) {
- return e instanceof bn && t.op === e.op && t.field.isEqual(e.field) && Ke(t.value, e.value);
- }(t, e) : t instanceof In ? function(t, e) {
- return e instanceof In && t.op === e.op && t.filters.length === e.filters.length && t.filters.reduce((function(t, n, r) {
- return t && Cn(n, e.filters[r]);
- }), !0);
- }(t, e) : void U();
- }
- function xn(t, e) {
- var n = t.filters.concat(e);
- return In.create(n, t.op);
- }
- function Nn(t) {
- return t instanceof bn ? function(t) {
- return "".concat(t.field.canonicalString(), " ").concat(t.op, " ").concat(Ye(t.value));
- }(t) : t instanceof In ? function(t) {
- return t.op.toString() + " {" + t.getFilters().map(Nn).join(" ,") + "}";
- }(t) : "Filter";
- }
- var An = function(e) {
- function n(t, n, r) {
- var i = this;
- return (i = e.call(this, t, n, r) || this).key = pt.fromName(r.referenceValue),
- i;
- }
- return t(n, e), n.prototype.matches = function(t) {
- var e = pt.comparator(t.key, this.key);
- return this.matchesComparison(e);
- }, n;
- }(bn), kn = function(e) {
- function n(t, n) {
- var r = this;
- return (r = e.call(this, t, "in" , n) || this).keys = Fn("in" , n),
- r;
- }
- return t(n, e), n.prototype.matches = function(t) {
- return this.keys.some((function(e) {
- return e.isEqual(t.key);
- }));
- }, n;
- }(bn), On = function(e) {
- function n(t, n) {
- var r = this;
- return (r = e.call(this, t, "not-in" , n) || this).keys = Fn("not-in" , n),
- r;
- }
- return t(n, e), n.prototype.matches = function(t) {
- return !this.keys.some((function(e) {
- return e.isEqual(t.key);
- }));
- }, n;
- }(bn);
- function Fn(t, e) {
- var n;
- return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((function(t) {
- return pt.fromName(t.referenceValue);
- }));
- }
- var Pn = function(e) {
- function n(t, n) {
- return e.call(this, t, "array-contains" , n) || this;
- }
- return t(n, e), n.prototype.matches = function(t) {
- var e = t.data.field(this.field);
- return tn(e) && Qe(e.arrayValue, this.value);
- }, n;
- }(bn), Rn = function(e) {
- function n(t, n) {
- return e.call(this, t, "in" , n) || this;
- }
- return t(n, e), n.prototype.matches = function(t) {
- var e = t.data.field(this.field);
- return null !== e && Qe(this.value.arrayValue, e);
- }, n;
- }(bn), Vn = function(e) {
- function n(t, n) {
- return e.call(this, t, "not-in" , n) || this;
- }
- return t(n, e), n.prototype.matches = function(t) {
- if (Qe(this.value.arrayValue, {
- nullValue: "NULL_VALUE"
- })) return !1;
- var e = t.data.field(this.field);
- return null !== e && !Qe(this.value.arrayValue, e);
- }, n;
- }(bn), Mn = function(e) {
- function n(t, n) {
- return e.call(this, t, "array-contains-any" , n) || this;
- }
- return t(n, e), n.prototype.matches = function(t) {
- var e = this, n = t.data.field(this.field);
- return !(!tn(n) || !n.arrayValue.values) && n.arrayValue.values.some((function(t) {
- return Qe(e.value.arrayValue, t);
- }));
- }, n;
- }(bn), Ln = function(t, e, n, r, i, o, u) {
- void 0 === e && (e = null), void 0 === n && (n = []), void 0 === r && (r = []),
- void 0 === i && (i = null), void 0 === o && (o = null), void 0 === u && (u = null),
- this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = i,
- this.startAt = o, this.endAt = u, this.dt = null;
- };
- function qn(t, e, n, r, i, o, u) {
- return void 0 === e && (e = null), void 0 === n && (n = []), void 0 === r && (r = []),
- void 0 === i && (i = null), void 0 === o && (o = null), void 0 === u && (u = null),
- new Ln(t, e, n, r, i, o, u);
- }
- function Bn(t) {
- var e = j(t);
- if (null === e.dt) {
- var n = e.path.canonicalString();
- null !== e.collectionGroup && (n += "|cg:" + e.collectionGroup), n += "|f:", n += e.filters.map((function(t) {
- return Dn(t);
- })).join(","), n += "|ob:", n += e.orderBy.map((function(t) {
- return function(t) {
-
- return t.field.canonicalString() + t.dir;
- }(t);
- })).join(","), zt(e.limit) || (n += "|l:", n += e.limit), e.startAt && (n += "|lb:",
- n += e.startAt.inclusive ? "b:" : "a:", n += e.startAt.position.map((function(t) {
- return Ye(t);
- })).join(",")), e.endAt && (n += "|ub:", n += e.endAt.inclusive ? "a:" : "b:", n += e.endAt.position.map((function(t) {
- return Ye(t);
- })).join(",")), e.dt = n;
- }
- return e.dt;
- }
- function Un(t, e) {
- if (t.limit !== e.limit) return !1;
- if (t.orderBy.length !== e.orderBy.length) return !1;
- for (var n = 0; n < t.orderBy.length; n++) if (!gn(t.orderBy[n], e.orderBy[n])) return !1;
- if (t.filters.length !== e.filters.length) return !1;
- for (var r = 0; r < t.filters.length; r++) if (!Cn(t.filters[r], e.filters[r])) return !1;
- return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!mn(t.startAt, e.startAt) && mn(t.endAt, e.endAt);
- }
- function zn(t) {
- return pt.isDocumentKey(t.path) && null === t.collectionGroup && 0 === t.filters.length;
- }
- function Gn(t, e) {
- return t.filters.filter((function(t) {
- return t instanceof bn && t.field.isEqual(e);
- }));
- }
- function jn(t, e, n) {
-
- for (var r = Ge, i = !0, o = 0, u = Gn(t, e); o < u.length; o++) {
- var a = u[o], s = Ge, c = !0;
- switch (a.op) {
- case "<" :
- case "<=" :
- s = an(a.value);
- break;
- case "==" :
- case "in" :
- case ">=" :
- s = a.value;
- break;
- case ">" :
- s = a.value, c = !1;
- break;
- case "!=" :
- case "not-in" :
- s = Ge;
-
- }
- cn({
- value: r,
- inclusive: i
- }, {
- value: s,
- inclusive: c
- }) < 0 && (r = s, i = c);
- }
-
-
- if (null !== n) for (var l = 0; l < t.orderBy.length; ++l) if (t.orderBy[l].field.isEqual(e)) {
- var h = n.position[l];
- cn({
- value: r,
- inclusive: i
- }, {
- value: h,
- inclusive: n.inclusive
- }) < 0 && (r = h, i = n.inclusive);
- break;
- }
- return {
- value: r,
- inclusive: i
- };
- }
- function Kn(t, e, n) {
-
- for (var r = ze, i = !0, o = 0, u = Gn(t, e); o < u.length; o++) {
- var a = u[o], s = ze, c = !0;
- switch (a.op) {
- case ">=" :
- case ">" :
- s = sn(a.value), c = !1;
- break;
- case "==" :
- case "in" :
- case "<=" :
- s = a.value;
- break;
- case "<" :
- s = a.value, c = !1;
- break;
- case "!=" :
- case "not-in" :
- s = ze;
-
- }
- ln({
- value: r,
- inclusive: i
- }, {
- value: s,
- inclusive: c
- }) > 0 && (r = s, i = c);
- }
-
-
- if (null !== n) for (var l = 0; l < t.orderBy.length; ++l) if (t.orderBy[l].field.isEqual(e)) {
- var h = n.position[l];
- ln({
- value: r,
- inclusive: i
- }, {
- value: h,
- inclusive: n.inclusive
- }) > 0 && (r = h, i = n.inclusive);
- break;
- }
- return {
- value: r,
- inclusive: i
- };
- }
- var Qn =
- function(t, e, n, r, i, o , u, a) {
- void 0 === e && (e = null), void 0 === n && (n = []), void 0 === r && (r = []),
- void 0 === i && (i = null), void 0 === o && (o = "F"), void 0 === u && (u = null),
- void 0 === a && (a = null), this.path = t, this.collectionGroup = e, this.explicitOrderBy = n,
- this.filters = r, this.limit = i, this.limitType = o, this.startAt = u, this.endAt = a,
- this.wt = null,
-
- this._t = null, this.startAt, this.endAt;
- };
- function Wn(t, e, n, r, i, o, u, a) {
- return new Qn(t, e, n, r, i, o, u, a);
- }
- function Hn(t) {
- return new Qn(t);
- }
- function Yn(t) {
- return 0 === t.filters.length && null === t.limit && null == t.startAt && null == t.endAt && (0 === t.explicitOrderBy.length || 1 === t.explicitOrderBy.length && t.explicitOrderBy[0].field.isKeyField());
- }
- function Xn(t) {
- return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
- }
- function Jn(t) {
- for (var e = 0, n = t.filters; e < n.length; e++) {
- var r = n[e].getFirstInequalityField();
- if (null !== r) return r;
- }
- return null;
- }
- function Zn(t) {
- return null !== t.collectionGroup;
- }
- function $n(t) {
- var e = j(t);
- if (null === e.wt) {
- e.wt = [];
- var n = Jn(e), r = Xn(e);
- if (null !== n && null === r)
-
-
-
- n.isKeyField() || e.wt.push(new yn(n)), e.wt.push(new yn(dt.keyField(), "asc" )); else {
- for (var i = !1, o = 0, u = e.explicitOrderBy; o < u.length; o++) {
- var a = u[o];
- e.wt.push(a), a.field.isKeyField() && (i = !0);
- }
- if (!i) {
-
-
- var s = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" ;
- e.wt.push(new yn(dt.keyField(), s));
- }
- }
- }
- return e.wt;
- }
- function tr(t) {
- var e = j(t);
- if (!e._t) if ("F" === e.limitType) e._t = qn(e.path, e.collectionGroup, $n(e), e.filters, e.limit, e.startAt, e.endAt); else {
- for (
-
- var n = [], r = 0, i = $n(e); r < i.length; r++) {
- var o = i[r], u = "desc" === o.dir ? "asc" : "desc" ;
- n.push(new yn(o.field, u));
- }
-
- var a = e.endAt ? new pn(e.endAt.position, e.endAt.inclusive) : null, s = e.startAt ? new pn(e.startAt.position, e.startAt.inclusive) : null;
-
- e._t = qn(e.path, e.collectionGroup, n, e.filters, e.limit, a, s);
- }
- return e._t;
- }
- function er(t, e) {
- e.getFirstInequalityField(), Jn(t);
- var n = t.filters.concat([ e ]);
- return new Qn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
- }
- function nr(t, e, n) {
- return new Qn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
- }
- function rr(t, e) {
- return Un(tr(t), tr(e)) && t.limitType === e.limitType;
- }
- function ir(t) {
- return "".concat(Bn(tr(t)), "|lt:").concat(t.limitType);
- }
- function or(t) {
- return "Query(target=".concat(function(t) {
- var e = t.path.canonicalString();
- return null !== t.collectionGroup && (e += " collectionGroup=" + t.collectionGroup),
- t.filters.length > 0 && (e += ", filters: [".concat(t.filters.map((function(t) {
- return Nn(t);
- })).join(", "), "]")), zt(t.limit) || (e += ", limit: " + t.limit), t.orderBy.length > 0 && (e += ", orderBy: [".concat(t.orderBy.map((function(t) {
- return function(t) {
- return "".concat(t.field.canonicalString(), " (").concat(t.dir, ")");
- }(t);
- })).join(", "), "]")), t.startAt && (e += ", startAt: ", e += t.startAt.inclusive ? "b:" : "a:",
- e += t.startAt.position.map((function(t) {
- return Ye(t);
- })).join(",")), t.endAt && (e += ", endAt: ", e += t.endAt.inclusive ? "a:" : "b:",
- e += t.endAt.position.map((function(t) {
- return Ye(t);
- })).join(",")), "Target(".concat(e, ")");
- }(tr(t)), "; limitType=").concat(t.limitType, ")");
- }
- function ur(t, e) {
- return e.isFoundDocument() && function(t, e) {
- var n = e.key.path;
- return null !== t.collectionGroup ? e.key.hasCollectionId(t.collectionGroup) && t.path.isPrefixOf(n) : pt.isDocumentKey(t.path) ? t.path.isEqual(n) : t.path.isImmediateParentOf(n);
- }(t, e) && function(t, e) {
-
-
-
-
-
-
- for (var n = 0, r = $n(t); n < r.length; n++) {
- var i = r[n];
-
- if (!i.field.isKeyField() && null === e.data.field(i.field)) return !1;
- }
- return !0;
- }(t, e) && function(t, e) {
- for (var n = 0, r = t.filters; n < r.length; n++) {
- if (!r[n].matches(e)) return !1;
- }
- return !0;
- }(t, e) && function(t, e) {
- return !(t.startAt &&
-
- !function(t, e, n) {
- var r = vn(t, e, n);
- return t.inclusive ? r <= 0 : r < 0;
- }(t.startAt, $n(t), e)) && !(t.endAt && !function(t, e, n) {
- var r = vn(t, e, n);
- return t.inclusive ? r >= 0 : r > 0;
- }(t.endAt, $n(t), e));
- }(t, e);
- }
- function ar(t) {
- return t.collectionGroup || (t.path.length % 2 == 1 ? t.path.lastSegment() : t.path.get(t.path.length - 2));
- }
- function sr(t) {
- return function(e, n) {
- for (var r = !1, i = 0, o = $n(t); i < o.length; i++) {
- var u = o[i], a = cr(u, e, n);
- if (0 !== a) return a;
- r = r || u.field.isKeyField();
- }
- return 0;
- };
- }
- function cr(t, e, n) {
- var r = t.field.isKeyField() ? pt.comparator(e.key, n.key) : function(t, e, n) {
- var r = e.data.field(t), i = n.data.field(t);
- return null !== r && null !== i ? We(r, i) : U();
- }(t.field, e, n);
- switch (t.dir) {
- case "asc" :
- return r;
- case "desc" :
- return -1 * r;
- default:
- return U();
- }
- }
- var lr = function() {
- function t(t, e) {
- this.mapKeyFn = t, this.equalsFn = e,
-
- this.inner = {},
-
- this.innerSize = 0
- ;
- }
- return t.prototype.get = function(t) {
- var e = this.mapKeyFn(t), n = this.inner[e];
- if (void 0 !== n) for (var r = 0, i = n; r < i.length; r++) {
- var o = i[r], u = o[0], a = o[1];
- if (this.equalsFn(u, t)) return a;
- }
- }, t.prototype.has = function(t) {
- return void 0 !== this.get(t);
- },
- t.prototype.set = function(t, e) {
- var n = this.mapKeyFn(t), r = this.inner[n];
- if (void 0 === r) return this.inner[n] = [ [ t, e ] ], void this.innerSize++;
- for (var i = 0; i < r.length; i++) if (this.equalsFn(r[i][0], t))
-
- return void (r[i] = [ t, e ]);
- r.push([ t, e ]), this.innerSize++;
- },
-
- t.prototype.delete = function(t) {
- var e = this.mapKeyFn(t), n = this.inner[e];
- if (void 0 === n) return !1;
- for (var r = 0; r < n.length; r++) if (this.equalsFn(n[r][0], t)) return 1 === n.length ? delete this.inner[e] : n.splice(r, 1),
- this.innerSize--, !0;
- return !1;
- }, t.prototype.forEach = function(t) {
- Ie(this.inner, (function(e, n) {
- for (var r = 0, i = n; r < i.length; r++) {
- var o = i[r], u = o[0], a = o[1];
- t(u, a);
- }
- }));
- }, t.prototype.isEmpty = function() {
- return Ee(this.inner);
- }, t.prototype.size = function() {
- return this.innerSize;
- }, t;
- }(), hr = new Te(pt.comparator);
- function fr() {
- return hr;
- }
- var dr = new Te(pt.comparator);
- function pr() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
- for (var n = dr, r = 0, i = t; r < i.length; r++) {
- var o = i[r];
- n = n.insert(o.key, o);
- }
- return n;
- }
- function vr(t) {
- var e = dr;
- return t.forEach((function(t, n) {
- return e = e.insert(t, n.overlayedDocument);
- })), e;
- }
- function mr() {
- return gr();
- }
- function yr() {
- return gr();
- }
- function gr() {
- return new lr((function(t) {
- return t.toString();
- }), (function(t, e) {
- return t.isEqual(e);
- }));
- }
- var wr = new Te(pt.comparator), br = new De(pt.comparator);
- function Ir() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
- for (var n = br, r = 0, i = t; r < i.length; r++) {
- var o = i[r];
- n = n.add(o);
- }
- return n;
- }
- var Er = new De(ot);
- function Tr() {
- return Er;
- }
- function Sr(t, e) {
- if (t.useProto3Json) {
- if (isNaN(e)) return {
- doubleValue: "NaN"
- };
- if (e === 1 / 0) return {
- doubleValue: "Infinity"
- };
- if (e === -1 / 0) return {
- doubleValue: "-Infinity"
- };
- }
- return {
- doubleValue: Gt(e) ? "-0" : e
- };
- }
- function _r(t) {
- return {
- integerValue: "" + t
- };
- }
- function Dr(t, e) {
- return jt(e) ? _r(e) : Sr(t, e);
- }
- var Cr = function() {
-
-
- this._ = void 0;
- };
- function xr(t, e, n) {
- return t instanceof kr ? function(t, e) {
- var n = {
- fields: {
- __type__: {
- stringValue: "server_timestamp"
- },
- __local_write_time__: {
- timestampValue: {
- seconds: t.seconds,
- nanos: t.nanoseconds
- }
- }
- }
- };
-
-
-
-
-
-
-
-
- return e && Me(e) && (e = Le(e)), e && (n.fields.__previous_value__ = e),
- {
- mapValue: n
- };
- }(n, e) : t instanceof Or ? Fr(t, e) : t instanceof Pr ? Rr(t, e) : function(t, e) {
-
-
-
- var n = Ar(t, e), r = Mr(n) + Mr(t.gt);
- return $e(n) && $e(t.gt) ? _r(r) : Sr(t.serializer, r);
- }(t, e);
- }
- function Nr(t, e, n) {
-
-
-
- return t instanceof Or ? Fr(t, e) : t instanceof Pr ? Rr(t, e) : n;
- }
- function Ar(t, e) {
- return t instanceof Vr ? $e(n = e) || function(t) {
- return !!t && "doubleValue" in t;
- }(n) ? e : {
- integerValue: 0
- } : null;
- var n;
- }
- var kr = function(e) {
- function n() {
- return null !== e && e.apply(this, arguments) || this;
- }
- return t(n, e), n;
- }(Cr), Or = function(e) {
- function n(t) {
- var n = this;
- return (n = e.call(this) || this).elements = t, n;
- }
- return t(n, e), n;
- }(Cr);
- function Fr(t, e) {
- for (var n = Lr(e), r = function(t) {
- n.some((function(e) {
- return Ke(e, t);
- })) || n.push(t);
- }, i = 0, o = t.elements; i < o.length; i++) {
- r(o[i]);
- }
- return {
- arrayValue: {
- values: n
- }
- };
- }
- var Pr = function(e) {
- function n(t) {
- var n = this;
- return (n = e.call(this) || this).elements = t, n;
- }
- return t(n, e), n;
- }(Cr);
- function Rr(t, e) {
- for (var n = Lr(e), r = function(t) {
- n = n.filter((function(e) {
- return !Ke(e, t);
- }));
- }, i = 0, o = t.elements; i < o.length; i++) {
- r(o[i]);
- }
- return {
- arrayValue: {
- values: n
- }
- };
- }
- var Vr = function(e) {
- function n(t, n) {
- var r = this;
- return (r = e.call(this) || this).serializer = t, r.gt = n, r;
- }
- return t(n, e), n;
- }(Cr);
- function Mr(t) {
- return Re(t.integerValue || t.doubleValue);
- }
- function Lr(t) {
- return tn(t) && t.arrayValue.values ? t.arrayValue.values.slice() : [];
- }
- var qr = function(t, e) {
- this.field = t, this.transform = e;
- };
- var Br = function(
- t,
- e) {
- this.version = t, this.transformResults = e;
- }, Ur = function() {
- function t(t, e) {
- this.updateTime = t, this.exists = e
- ;
- }
- return t.none = function() {
- return new t;
- },
- t.exists = function(e) {
- return new t(void 0, e);
- },
- t.updateTime = function(e) {
- return new t(e);
- }, Object.defineProperty(t.prototype, "isNone", {
- get: function() {
- return void 0 === this.updateTime && void 0 === this.exists;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.isEqual = function(t) {
- return this.exists === t.exists && (this.updateTime ? !!t.updateTime && this.updateTime.isEqual(t.updateTime) : !t.updateTime);
- }, t;
- }();
- function zr(t, e) {
- return void 0 !== t.updateTime ? e.isFoundDocument() && e.version.isEqual(t.updateTime) : void 0 === t.exists || t.exists === e.isFoundDocument();
- }
- var Gr = function() {};
- function jr(t, e) {
- if (!t.hasLocalMutations || e && 0 === e.fields.length) return null;
-
- if (null === e) return t.isNoDocument() ? new ni(t.key, Ur.none()) : new Yr(t.key, t.data, Ur.none());
- for (var n = t.data, r = hn.empty(), i = new De(dt.comparator), o = 0, u = e.fields; o < u.length; o++) {
- var a = u[o];
- if (!i.has(a)) {
- var s = n.field(a);
-
-
-
-
-
-
-
-
-
- null === s && a.length > 1 && (a = a.popLast(), s = n.field(a)), null === s ? r.delete(a) : r.set(a, s),
- i = i.add(a);
- }
- }
- return new Xr(t.key, r, new Ne(i.toArray()), Ur.none());
- }
- function Kr(t, e, n) {
- t instanceof Yr ? function(t, e, n) {
-
-
-
- var r = t.value.clone(), i = Zr(t.fieldTransforms, e, n.transformResults);
- r.setAll(i), e.convertToFoundDocument(n.version, r).setHasCommittedMutations();
- }(t, e, n) : t instanceof Xr ? function(t, e, n) {
- if (zr(t.precondition, e)) {
- var r = Zr(t.fieldTransforms, e, n.transformResults), i = e.data;
- i.setAll(Jr(t)), i.setAll(r), e.convertToFoundDocument(n.version, i).setHasCommittedMutations();
- } else e.convertToUnknownDocument(n.version);
- }(t, e, n) : function(t, e, n) {
-
-
-
- e.convertToNoDocument(n.version).setHasCommittedMutations();
- }(0, e, n);
- }
- function Qr(t, e, n, r) {
- return t instanceof Yr ? function(t, e, n, r) {
- if (!zr(t.precondition, e))
-
-
- return n;
- var i = t.value.clone(), o = $r(t.fieldTransforms, r, e);
- return i.setAll(o), e.convertToFoundDocument(e.version, i).setHasLocalMutations(),
- null;
-
- }(t, e, n, r) : t instanceof Xr ? function(t, e, n, r) {
- if (!zr(t.precondition, e)) return n;
- var i = $r(t.fieldTransforms, r, e), o = e.data;
- return o.setAll(Jr(t)), o.setAll(i), e.convertToFoundDocument(e.version, o).setHasLocalMutations(),
- null === n ? null : n.unionWith(t.fieldMask.fields).unionWith(t.fieldTransforms.map((function(t) {
- return t.field;
- })));
- }(t, e, n, r) : function(t, e, n) {
- return zr(t.precondition, e) ? (e.convertToNoDocument(e.version).setHasLocalMutations(),
- null) : n;
- }(t, e, n);
- }
- function Wr(t, e) {
- for (var n = null, r = 0, i = t.fieldTransforms; r < i.length; r++) {
- var o = i[r], u = e.data.field(o.field), a = Ar(o.transform, u || null);
- null != a && (null === n && (n = hn.empty()), n.set(o.field, a));
- }
- return n || null;
- }
- function Hr(t, e) {
- return t.type === e.type && !!t.key.isEqual(e.key) && !!t.precondition.isEqual(e.precondition) && !!function(t, e) {
- return void 0 === t && void 0 === e || !(!t || !e) && ut(t, e, (function(t, e) {
- return function(t, e) {
- return t.field.isEqual(e.field) && function(t, e) {
- return t instanceof Or && e instanceof Or || t instanceof Pr && e instanceof Pr ? ut(t.elements, e.elements, Ke) : t instanceof Vr && e instanceof Vr ? Ke(t.gt, e.gt) : t instanceof kr && e instanceof kr;
- }(t.transform, e.transform);
- }(t, e);
- }));
- }(t.fieldTransforms, e.fieldTransforms) && (0 === t.type ? t.value.isEqual(e.value) : 1 !== t.type || t.data.isEqual(e.data) && t.fieldMask.isEqual(e.fieldMask));
- }
- var Yr = function(e) {
- function n(t, n, r, i) {
- void 0 === i && (i = []);
- var o = this;
- return (o = e.call(this) || this).key = t, o.value = n, o.precondition = r, o.fieldTransforms = i,
- o.type = 0 , o;
- }
- return t(n, e), n.prototype.getFieldMask = function() {
- return null;
- }, n;
- }(Gr), Xr = function(e) {
- function n(t, n, r, i, o) {
- void 0 === o && (o = []);
- var u = this;
- return (u = e.call(this) || this).key = t, u.data = n, u.fieldMask = r, u.precondition = i,
- u.fieldTransforms = o, u.type = 1 , u;
- }
- return t(n, e), n.prototype.getFieldMask = function() {
- return this.fieldMask;
- }, n;
- }(Gr);
- function Jr(t) {
- var e = new Map;
- return t.fieldMask.fields.forEach((function(n) {
- if (!n.isEmpty()) {
- var r = t.data.field(n);
- e.set(n, r);
- }
- })), e
-
- ;
- }
- function Zr(t, e, n) {
- var r = new Map;
- z(t.length === n.length);
- for (var i = 0; i < n.length; i++) {
- var o = t[i], u = o.transform, a = e.data.field(o.field);
- r.set(o.field, Nr(u, a, n[i]));
- }
- return r;
- }
- function $r(t, e, n) {
- for (var r = new Map, i = 0, o = t; i < o.length; i++) {
- var u = o[i], a = u.transform, s = n.data.field(u.field);
- r.set(u.field, xr(a, s, e));
- }
- return r;
- }
- var ti, ei, ni = function(e) {
- function n(t, n) {
- var r = this;
- return (r = e.call(this) || this).key = t, r.precondition = n, r.type = 2 ,
- r.fieldTransforms = [], r;
- }
- return t(n, e), n.prototype.getFieldMask = function() {
- return null;
- }, n;
- }(Gr), ri = function(e) {
- function n(t, n) {
- var r = this;
- return (r = e.call(this) || this).key = t, r.precondition = n, r.type = 3 ,
- r.fieldTransforms = [], r;
- }
- return t(n, e), n.prototype.getFieldMask = function() {
- return null;
- }, n;
- }(Gr), ii = function() {
-
- function t(t, e, n, r) {
- this.batchId = t, this.localWriteTime = e, this.baseMutations = n, this.mutations = r
-
- ;
- }
- return t.prototype.applyToRemoteDocument = function(t, e) {
- for (var n = e.mutationResults, r = 0; r < this.mutations.length; r++) {
- var i = this.mutations[r];
- i.key.isEqual(t.key) && Kr(i, t, n[r]);
- }
- },
-
- t.prototype.applyToLocalView = function(t, e) {
-
-
- for (var n = 0, r = this.baseMutations; n < r.length; n++) {
- var i = r[n];
- i.key.isEqual(t.key) && (e = Qr(i, t, e, this.localWriteTime));
- }
-
- for (var o = 0, u = this.mutations; o < u.length; o++) {
- var a = u[o];
- a.key.isEqual(t.key) && (e = Qr(a, t, e, this.localWriteTime));
- }
- return e;
- },
-
- t.prototype.applyToLocalDocumentSet = function(t, e) {
- var n = this, r = yr();
-
-
-
- return this.mutations.forEach((function(i) {
- var o = t.get(i.key), u = o.overlayedDocument, a = n.applyToLocalView(u, o.mutatedFields), s = jr(u,
-
-
-
- a = e.has(i.key) ? null : a);
-
-
- null !== s && r.set(i.key, s), u.isValidDocument() || u.convertToNoDocument(ct.min());
- })), r;
- }, t.prototype.keys = function() {
- return this.mutations.reduce((function(t, e) {
- return t.add(e.key);
- }), Ir());
- }, t.prototype.isEqual = function(t) {
- return this.batchId === t.batchId && ut(this.mutations, t.mutations, (function(t, e) {
- return Hr(t, e);
- })) && ut(this.baseMutations, t.baseMutations, (function(t, e) {
- return Hr(t, e);
- }));
- }, t;
- }(), oi = function() {
- function t(t, e, n,
-
- r) {
- this.batch = t, this.commitVersion = e, this.mutationResults = n, this.docVersions = r
-
- ;
- }
- return t.from = function(e, n, r) {
- z(e.mutations.length === r.length);
- for (var i = wr, o = e.mutations, u = 0; u < o.length; u++) i = i.insert(o[u].key, r[u].version);
- return new t(e, n, r, i);
- }, t;
- }(), ui = function() {
- function t(t, e) {
- this.largestBatchId = t, this.mutation = e;
- }
- return t.prototype.getKey = function() {
- return this.mutation.key;
- }, t.prototype.isEqual = function(t) {
- return null !== t && this.mutation === t.mutation;
- }, t.prototype.toString = function() {
- return "Overlay{\n largestBatchId: ".concat(this.largestBatchId, ",\n mutation: ").concat(this.mutation.toString(), "\n }");
- }, t;
- }(), ai = function(t, e, n) {
- this.alias = t, this.yt = e, this.fieldPath = n;
- }, si = function(t, e) {
- this.count = t, this.unchangedNames = e;
- };
- function ci(t) {
- switch (t) {
- default:
- return U();
- case K.CANCELLED:
- case K.UNKNOWN:
- case K.DEADLINE_EXCEEDED:
- case K.RESOURCE_EXHAUSTED:
- case K.INTERNAL:
- case K.UNAVAILABLE:
-
-
- case K.UNAUTHENTICATED:
- return !1;
- case K.INVALID_ARGUMENT:
- case K.NOT_FOUND:
- case K.ALREADY_EXISTS:
- case K.PERMISSION_DENIED:
- case K.FAILED_PRECONDITION:
-
-
-
- case K.ABORTED:
- case K.OUT_OF_RANGE:
- case K.UNIMPLEMENTED:
- case K.DATA_LOSS:
- return !0;
- }
- }
- function li(t) {
- if (void 0 === t)
-
-
- return L("GRPC error has no .code"), K.UNKNOWN;
- switch (t) {
- case ti.OK:
- return K.OK;
- case ti.CANCELLED:
- return K.CANCELLED;
- case ti.UNKNOWN:
- return K.UNKNOWN;
- case ti.DEADLINE_EXCEEDED:
- return K.DEADLINE_EXCEEDED;
- case ti.RESOURCE_EXHAUSTED:
- return K.RESOURCE_EXHAUSTED;
- case ti.INTERNAL:
- return K.INTERNAL;
- case ti.UNAVAILABLE:
- return K.UNAVAILABLE;
- case ti.UNAUTHENTICATED:
- return K.UNAUTHENTICATED;
- case ti.INVALID_ARGUMENT:
- return K.INVALID_ARGUMENT;
- case ti.NOT_FOUND:
- return K.NOT_FOUND;
- case ti.ALREADY_EXISTS:
- return K.ALREADY_EXISTS;
- case ti.PERMISSION_DENIED:
- return K.PERMISSION_DENIED;
- case ti.FAILED_PRECONDITION:
- return K.FAILED_PRECONDITION;
- case ti.ABORTED:
- return K.ABORTED;
- case ti.OUT_OF_RANGE:
- return K.OUT_OF_RANGE;
- case ti.UNIMPLEMENTED:
- return K.UNIMPLEMENTED;
- case ti.DATA_LOSS:
- return K.DATA_LOSS;
- default:
- return U();
- }
- }
- (ei = ti || (ti = {}))[ei.OK = 0] = "OK", ei[ei.CANCELLED = 1] = "CANCELLED",
- ei[ei.UNKNOWN = 2] = "UNKNOWN", ei[ei.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT",
- ei[ei.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED", ei[ei.NOT_FOUND = 5] = "NOT_FOUND",
- ei[ei.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", ei[ei.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
- ei[ei.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", ei[ei.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
- ei[ei.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", ei[ei.ABORTED = 10] = "ABORTED",
- ei[ei.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", ei[ei.UNIMPLEMENTED = 12] = "UNIMPLEMENTED",
- ei[ei.INTERNAL = 13] = "INTERNAL", ei[ei.UNAVAILABLE = 14] = "UNAVAILABLE", ei[ei.DATA_LOSS = 15] = "DATA_LOSS";
- var hi = function() {
- function t() {
- this.onExistenceFilterMismatchCallbacks = new Map;
- }
- return Object.defineProperty(t, "instance", {
-
- get: function() {
- return fi;
- },
- enumerable: !1,
- configurable: !0
- }),
-
- t.getOrCreateInstance = function() {
- return null === fi && (fi = new t), fi;
- },
-
- t.prototype.onExistenceFilterMismatch = function(t) {
- var e = this, n = Symbol();
- return this.onExistenceFilterMismatchCallbacks.set(n, t), function() {
- return e.onExistenceFilterMismatchCallbacks.delete(n);
- };
- },
-
- t.prototype.notifyOnExistenceFilterMismatch = function(t) {
- this.onExistenceFilterMismatchCallbacks.forEach((function(e) {
- return e(t);
- }));
- }, t;
- }(), fi = null;
- function di() {
- return new TextEncoder;
- }
- var pi = new b([ 4294967295, 4294967295 ], 0);
- function vi(t) {
- var e = di().encode(t), n = new A;
- return n.update(e), new Uint8Array(n.digest());
- }
- function mi(t) {
- var e = new DataView(t.buffer), n = e.getUint32(0, !0), r = e.getUint32(4, !0), i = e.getUint32(8, !0), o = e.getUint32(12, !0);
- return [ new b([ n, r ], 0), new b([ i, o ], 0) ];
- }
- var yi = function() {
- function t(t, e, n) {
- if (this.bitmap = t, this.padding = e, this.hashCount = n, e < 0 || e >= 8) throw new gi("Invalid padding: ".concat(e));
- if (n < 0) throw new gi("Invalid hash count: ".concat(n));
- if (t.length > 0 && 0 === this.hashCount)
-
- throw new gi("Invalid hash count: ".concat(n));
- if (0 === t.length && 0 !== e)
-
- throw new gi("Invalid padding when bitmap length is 0: ".concat(e));
- this.It = 8 * t.length - e,
-
- this.Tt = b.fromNumber(this.It);
- }
-
-
- return t.prototype.Et = function(t, e, n) {
-
- var r = t.add(e.multiply(b.fromNumber(n)));
-
- return 1 === r.compare(pi) && (r = new b([ r.getBits(0), r.getBits(1) ], 0)),
- r.modulo(this.Tt).toNumber();
- },
-
- t.prototype.At = function(t) {
- return 0 != (this.bitmap[Math.floor(t / 8)] & 1 << t % 8);
- }, t.prototype.vt = function(t) {
-
- if (0 === this.It) return !1;
- for (var e = mi(vi(t)), n = e[0], r = e[1], i = 0; i < this.hashCount; i++) {
- var o = this.Et(n, r, i);
- if (!this.At(o)) return !1;
- }
- return !0;
- },
- t.create = function(e, n, r) {
- var i = e % 8 == 0 ? 0 : 8 - e % 8, o = new t(new Uint8Array(Math.ceil(e / 8)), i, n);
- return r.forEach((function(t) {
- return o.insert(t);
- })), o;
- }, t.prototype.insert = function(t) {
- if (0 !== this.It) for (var e = mi(vi(t)), n = e[0], r = e[1], i = 0; i < this.hashCount; i++) {
- var o = this.Et(n, r, i);
- this.Rt(o);
- }
- }, t.prototype.Rt = function(t) {
- var e = Math.floor(t / 8), n = t % 8;
- this.bitmap[e] |= 1 << n;
- }, t;
- }(), gi = function(e) {
- function n() {
- var t = this;
- return (t = e.apply(this, arguments) || this).name = "BloomFilterError", t;
- }
- return t(n, e), n;
- }(Error), wi = function() {
- function t(
-
- t,
-
- e,
-
- n,
-
- r,
-
- i) {
- this.snapshotVersion = t, this.targetChanges = e, this.targetMismatches = n, this.documentUpdates = r,
- this.resolvedLimboDocuments = i;
- }
-
-
- return t.createSynthesizedRemoteEventForCurrentChange = function(e, n, r) {
- var i = new Map;
- return i.set(e, bi.createSynthesizedTargetChangeForCurrentChange(e, n, r)), new t(ct.min(), i, new Te(ot), fr(), Ir());
- }, t;
- }(), bi = function() {
- function t(
-
- t,
-
- e,
-
- n,
-
- r,
-
- i) {
- this.resumeToken = t, this.current = e, this.addedDocuments = n, this.modifiedDocuments = r,
- this.removedDocuments = i
-
- ;
- }
- return t.createSynthesizedTargetChangeForCurrentChange = function(e, n, r) {
- return new t(r, n, Ir(), Ir(), Ir());
- }, t;
- }(), Ii = function(
- t,
- e,
- n,
- r) {
- this.Pt = t, this.removedTargetIds = e, this.key = n, this.bt = r;
- }, Ei = function(t, e) {
- this.targetId = t, this.Vt = e;
- }, Ti = function(
- t,
- e,
- n
- , r) {
- void 0 === n && (n = Oe.EMPTY_BYTE_STRING), void 0 === r && (r = null), this.state = t,
- this.targetIds = e, this.resumeToken = n, this.cause = r;
- }, Si = function() {
- function t() {
-
- this.St = 0,
-
- this.Dt = Ci(),
-
- this.Ct = Oe.EMPTY_BYTE_STRING, this.xt = !1,
-
- this.Nt = !0;
- }
- return Object.defineProperty(t.prototype, "current", {
-
- get: function() {
- return this.xt;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "resumeToken", {
- get: function() {
- return this.Ct;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "kt", {
- get: function() {
- return 0 !== this.St;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "Mt", {
- get: function() {
- return this.Nt;
- },
- enumerable: !1,
- configurable: !0
- }),
-
- t.prototype.$t = function(t) {
- t.approximateByteSize() > 0 && (this.Nt = !0, this.Ct = t);
- },
-
- t.prototype.Ot = function() {
- var t = Ir(), e = Ir(), n = Ir();
- return this.Dt.forEach((function(r, i) {
- switch (i) {
- case 0 :
- t = t.add(r);
- break;
- case 2 :
- e = e.add(r);
- break;
- case 1 :
- n = n.add(r);
- break;
- default:
- U();
- }
- })), new bi(this.Ct, this.xt, t, e, n);
- },
-
- t.prototype.Ft = function() {
- this.Nt = !1, this.Dt = Ci();
- }, t.prototype.Bt = function(t, e) {
- this.Nt = !0, this.Dt = this.Dt.insert(t, e);
- }, t.prototype.Lt = function(t) {
- this.Nt = !0, this.Dt = this.Dt.remove(t);
- }, t.prototype.qt = function() {
- this.St += 1;
- }, t.prototype.Ut = function() {
- this.St -= 1;
- }, t.prototype.Kt = function() {
- this.Nt = !0, this.xt = !0;
- }, t;
- }(), _i = function() {
- function t(t) {
- this.Gt = t,
-
- this.Qt = new Map,
-
- this.jt = fr(),
-
- this.zt = Di(),
-
- this.Wt = new Te(ot)
-
- ;
- }
- return t.prototype.Ht = function(t) {
- for (var e = 0, n = t.Pt; e < n.length; e++) {
- var r = n[e];
- t.bt && t.bt.isFoundDocument() ? this.Jt(r, t.bt) : this.Yt(r, t.key, t.bt);
- }
- for (var i = 0, o = t.removedTargetIds; i < o.length; i++) {
- var u = o[i];
- this.Yt(u, t.key, t.bt);
- }
- },
- t.prototype.Xt = function(t) {
- var e = this;
- this.forEachTarget(t, (function(n) {
- var r = e.Zt(n);
- switch (t.state) {
- case 0 :
- e.te(n) && r.$t(t.resumeToken);
- break;
- case 1 :
-
-
- r.Ut(), r.kt ||
-
-
-
- r.Ft(), r.$t(t.resumeToken);
- break;
- case 2 :
-
-
-
-
- r.Ut(), r.kt || e.removeTarget(n);
- break;
- case 3 :
- e.te(n) && (r.Kt(), r.$t(t.resumeToken));
- break;
- case 4 :
- e.te(n) && (
-
-
-
- e.ee(n), r.$t(t.resumeToken));
- break;
- default:
- U();
- }
- }));
- },
-
- t.prototype.forEachTarget = function(t, e) {
- var n = this;
- t.targetIds.length > 0 ? t.targetIds.forEach(e) : this.Qt.forEach((function(t, r) {
- n.te(r) && e(r);
- }));
- },
-
- t.prototype.ne = function(t) {
- var e, n = t.targetId, r = t.Vt.count, i = this.se(n);
- if (i) {
- var o = i.target;
- if (zn(o)) if (0 === r) {
-
-
-
-
-
-
- var u = new pt(o.path);
- this.Yt(n, u, dn.newNoDocument(u, ct.min()));
- } else z(1 === r); else {
- var a = this.ie(n);
-
-
- if (a !== r) {
-
- var s = this.re(t, a);
- if (0 !== s) {
-
-
- this.ee(n);
- var c = 2 === s ? "TargetPurposeExistenceFilterMismatchBloom" : "TargetPurposeExistenceFilterMismatch" ;
- this.Wt = this.Wt.insert(n, c);
- }
- null === (e = hi.instance) || void 0 === e || e.notifyOnExistenceFilterMismatch(function(t, e, n) {
- var r, i, o, u, a, s, c = {
- localCacheCount: e,
- existenceFilterCount: n.count
- }, l = n.unchangedNames;
- return l && (c.bloomFilter = {
- applied: 0 === t,
- hashCount: null !== (r = null == l ? void 0 : l.hashCount) && void 0 !== r ? r : 0,
- bitmapLength: null !== (u = null === (o = null === (i = null == l ? void 0 : l.bits) || void 0 === i ? void 0 : i.bitmap) || void 0 === o ? void 0 : o.length) && void 0 !== u ? u : 0,
- padding: null !== (s = null === (a = null == l ? void 0 : l.bits) || void 0 === a ? void 0 : a.padding) && void 0 !== s ? s : 0
- }), c;
- }(s, a, t.Vt));
- }
- }
- }
- },
-
- t.prototype.re = function(t, e) {
- var n = t.Vt, r = n.unchangedNames, i = n.count;
- if (!r || !r.bits) return 1 ;
- var o, u, a = r.bits, s = a.bitmap, c = void 0 === s ? "" : s, l = a.padding, h = void 0 === l ? 0 : l, f = r.hashCount, d = void 0 === f ? 0 : f;
- try {
- o = Ve(c).toUint8Array();
- } catch (t) {
- if (t instanceof Ae) return q("Decoding the base64 bloom filter in existence filter failed (" + t.message + "); ignoring the bloom filter and falling back to full re-query."),
- 1 ;
- throw t;
- }
- try {
-
- u = new yi(o, h, d);
- } catch (t) {
- return q(t instanceof gi ? "BloomFilter error: " : "Applying bloom filter failed: ", t),
- 1 ;
- }
- return 0 === u.It ? 1 : i !== e - this.oe(t.targetId, u) ? 2 : 0 ;
- },
-
- t.prototype.oe = function(t, e) {
- var n = this, r = this.Gt.getRemoteKeysForTarget(t), i = 0;
- return r.forEach((function(r) {
- var o = n.Gt.ue(), u = "projects/".concat(o.projectId, "/databases/").concat(o.database, "/documents/").concat(r.path.canonicalString());
- e.vt(u) || (n.Yt(t, r, null), i++);
- })), i;
- },
-
- t.prototype.ce = function(t) {
- var e = this, n = new Map;
- this.Qt.forEach((function(r, i) {
- var o = e.se(i);
- if (o) {
- if (r.current && zn(o.target)) {
-
-
-
-
-
-
-
-
- var u = new pt(o.target.path);
- null !== e.jt.get(u) || e.ae(i, u) || e.Yt(i, u, dn.newNoDocument(u, t));
- }
- r.Mt && (n.set(i, r.Ot()), r.Ft());
- }
- }));
- var r = Ir();
-
-
-
-
- this.zt.forEach((function(t, n) {
- var i = !0;
- n.forEachWhile((function(t) {
- var n = e.se(t);
- return !n || "TargetPurposeLimboResolution" === n.purpose || (i = !1,
- !1);
- })), i && (r = r.add(t));
- })), this.jt.forEach((function(e, n) {
- return n.setReadTime(t);
- }));
- var i = new wi(t, n, this.Wt, this.jt, r);
- return this.jt = fr(), this.zt = Di(), this.Wt = new Te(ot), i;
- },
-
-
- t.prototype.Jt = function(t, e) {
- if (this.te(t)) {
- var n = this.ae(t, e.key) ? 2 : 0 ;
- this.Zt(t).Bt(e.key, n), this.jt = this.jt.insert(e.key, e), this.zt = this.zt.insert(e.key, this.he(e.key).add(t));
- }
- },
-
-
- t.prototype.Yt = function(t, e, n) {
- if (this.te(t)) {
- var r = this.Zt(t);
- this.ae(t, e) ? r.Bt(e, 1 ) :
-
-
- r.Lt(e), this.zt = this.zt.insert(e, this.he(e).delete(t)), n && (this.jt = this.jt.insert(e, n));
- }
- }, t.prototype.removeTarget = function(t) {
- this.Qt.delete(t);
- },
-
- t.prototype.ie = function(t) {
- var e = this.Zt(t).Ot();
- return this.Gt.getRemoteKeysForTarget(t).size + e.addedDocuments.size - e.removedDocuments.size;
- },
-
- t.prototype.qt = function(t) {
- this.Zt(t).qt();
- }, t.prototype.Zt = function(t) {
- var e = this.Qt.get(t);
- return e || (e = new Si, this.Qt.set(t, e)), e;
- }, t.prototype.he = function(t) {
- var e = this.zt.get(t);
- return e || (e = new De(ot), this.zt = this.zt.insert(t, e)), e;
- },
-
- t.prototype.te = function(t) {
- var e = null !== this.se(t);
- return e || M("WatchChangeAggregator", "Detected inactive target", t), e;
- },
-
- t.prototype.se = function(t) {
- var e = this.Qt.get(t);
- return e && e.kt ? null : this.Gt.le(t);
- },
-
- t.prototype.ee = function(t) {
- var e = this;
- this.Qt.set(t, new Si), this.Gt.getRemoteKeysForTarget(t).forEach((function(n) {
- e.Yt(t, n, null);
- }));
- },
-
- t.prototype.ae = function(t, e) {
- return this.Gt.getRemoteKeysForTarget(t).has(e);
- }, t;
- }();
- function Di() {
- return new Te(pt.comparator);
- }
- function Ci() {
- return new Te(pt.comparator);
- }
- var xi = {
- asc: "ASCENDING",
- desc: "DESCENDING"
- }, Ni = {
- "<": "LESS_THAN",
- "<=": "LESS_THAN_OR_EQUAL",
- ">": "GREATER_THAN",
- ">=": "GREATER_THAN_OR_EQUAL",
- "==": "EQUAL",
- "!=": "NOT_EQUAL",
- "array-contains": "ARRAY_CONTAINS",
- in: "IN",
- "not-in": "NOT_IN",
- "array-contains-any": "ARRAY_CONTAINS_ANY"
- }, Ai = {
- and: "AND",
- or: "OR"
- }, ki = function(t, e) {
- this.databaseId = t, this.useProto3Json = e;
- };
- function Oi(t, e) {
- return t.useProto3Json || zt(e) ? e : {
- value: e
- };
- }
- function Fi(t, e) {
- return t.useProto3Json ? "".concat(new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", ""), ".").concat(("000000000" + e.nanoseconds).slice(-9), "Z") : {
- seconds: "" + e.seconds,
- nanos: e.nanoseconds
- };
- }
- function Pi(t, e) {
- return t.useProto3Json ? e.toBase64() : e.toUint8Array();
- }
- function Ri(t, e) {
- return Fi(t, e.toTimestamp());
- }
- function Vi(t) {
- return z(!!t), ct.fromTimestamp(function(t) {
- var e = Pe(t);
- return new st(e.seconds, e.nanos);
- }(t));
- }
- function Mi(t, e) {
- return function(t) {
- return new ht([ "projects", t.projectId, "databases", t.database ]);
- }(t).child("documents").child(e).canonicalString();
- }
- function Li(t) {
- var e = ht.fromString(t);
- return z(uo(e)), e;
- }
- function qi(t, e) {
- return Mi(t.databaseId, e.path);
- }
- function Bi(t, e) {
- var n = Li(e);
- if (n.get(1) !== t.databaseId.projectId) throw new Q(K.INVALID_ARGUMENT, "Tried to deserialize key from different project: " + n.get(1) + " vs " + t.databaseId.projectId);
- if (n.get(3) !== t.databaseId.database) throw new Q(K.INVALID_ARGUMENT, "Tried to deserialize key from different database: " + n.get(3) + " vs " + t.databaseId.database);
- return new pt(ji(n));
- }
- function Ui(t, e) {
- return Mi(t.databaseId, e);
- }
- function zi(t) {
- var e = Li(t);
-
-
-
-
- return 4 === e.length ? ht.emptyPath() : ji(e);
- }
- function Gi(t) {
- return new ht([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
- }
- function ji(t) {
- return z(t.length > 4 && "documents" === t.get(4)), t.popFirst(5)
- ;
- }
- function Ki(t, e, n) {
- return {
- name: qi(t, e),
- fields: n.value.mapValue.fields
- };
- }
- function Qi(t, e, n) {
- var r = Bi(t, e.name), i = Vi(e.updateTime), o = e.createTime ? Vi(e.createTime) : ct.min(), u = new hn({
- mapValue: {
- fields: e.fields
- }
- }), a = dn.newFoundDocument(r, i, o, u);
- return n && a.setHasCommittedMutations(), n ? a.setHasCommittedMutations() : a;
- }
- function Wi(t, e) {
- var n;
- if (e instanceof Yr) n = {
- update: Ki(t, e.key, e.value)
- }; else if (e instanceof ni) n = {
- delete: qi(t, e.key)
- }; else if (e instanceof Xr) n = {
- update: Ki(t, e.key, e.data),
- updateMask: oo(e.fieldMask)
- }; else {
- if (!(e instanceof ri)) return U();
- n = {
- verify: qi(t, e.key)
- };
- }
- return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((function(t) {
- return function(t, e) {
- var n = e.transform;
- if (n instanceof kr) return {
- fieldPath: e.field.canonicalString(),
- setToServerValue: "REQUEST_TIME"
- };
- if (n instanceof Or) return {
- fieldPath: e.field.canonicalString(),
- appendMissingElements: {
- values: n.elements
- }
- };
- if (n instanceof Pr) return {
- fieldPath: e.field.canonicalString(),
- removeAllFromArray: {
- values: n.elements
- }
- };
- if (n instanceof Vr) return {
- fieldPath: e.field.canonicalString(),
- increment: n.gt
- };
- throw U();
- }(0, t);
- }))), e.precondition.isNone || (n.currentDocument = function(t, e) {
- return void 0 !== e.updateTime ? {
- updateTime: Ri(t, e.updateTime)
- } : void 0 !== e.exists ? {
- exists: e.exists
- } : U();
- }(t, e.precondition)), n;
- }
- function Hi(t, e) {
- var n = e.currentDocument ? function(t) {
- return void 0 !== t.updateTime ? Ur.updateTime(Vi(t.updateTime)) : void 0 !== t.exists ? Ur.exists(t.exists) : Ur.none();
- }(e.currentDocument) : Ur.none(), r = e.updateTransforms ? e.updateTransforms.map((function(e) {
- return function(t, e) {
- var n = null;
- if ("setToServerValue" in e) z("REQUEST_TIME" === e.setToServerValue), n = new kr; else if ("appendMissingElements" in e) {
- var r = e.appendMissingElements.values || [];
- n = new Or(r);
- } else if ("removeAllFromArray" in e) {
- var i = e.removeAllFromArray.values || [];
- n = new Pr(i);
- } else "increment" in e ? n = new Vr(t, e.increment) : U();
- var o = dt.fromServerFormat(e.fieldPath);
- return new qr(o, n);
- }(t, e);
- })) : [];
- if (e.update) {
- e.update.name;
- var i = Bi(t, e.update.name), o = new hn({
- mapValue: {
- fields: e.update.fields
- }
- });
- if (e.updateMask) {
- var u = function(t) {
- var e = t.fieldPaths || [];
- return new Ne(e.map((function(t) {
- return dt.fromServerFormat(t);
- })));
- }(e.updateMask);
- return new Xr(i, o, u, n, r);
- }
- return new Yr(i, o, n, r);
- }
- if (e.delete) {
- var a = Bi(t, e.delete);
- return new ni(a, n);
- }
- if (e.verify) {
- var s = Bi(t, e.verify);
- return new ri(s, n);
- }
- return U();
- }
- function Yi(t, e) {
- return {
- documents: [ Ui(t, e.path) ]
- };
- }
- function Xi(t, e) {
-
- var n = {
- structuredQuery: {}
- }, r = e.path;
- null !== e.collectionGroup ? (n.parent = Ui(t, r), n.structuredQuery.from = [ {
- collectionId: e.collectionGroup,
- allDescendants: !0
- } ]) : (n.parent = Ui(t, r.popLast()), n.structuredQuery.from = [ {
- collectionId: r.lastSegment()
- } ]);
- var i = function(t) {
- if (0 !== t.length) return io(In.create(t, "and" ));
- }(e.filters);
- i && (n.structuredQuery.where = i);
- var o = function(t) {
- if (0 !== t.length) return t.map((function(t) {
-
- return function(t) {
- return {
- field: no(t.field),
- direction: $i(t.dir)
- };
- }(t);
- }));
- }(e.orderBy);
- o && (n.structuredQuery.orderBy = o);
- var u, a = Oi(t, e.limit);
- return null !== a && (n.structuredQuery.limit = a), e.startAt && (n.structuredQuery.startAt = {
- before: (u = e.startAt).inclusive,
- values: u.position
- }), e.endAt && (n.structuredQuery.endAt = function(t) {
- return {
- before: !t.inclusive,
- values: t.position
- };
- }(e.endAt)), n;
- }
- function Ji(t) {
- var e = zi(t.parent), n = t.structuredQuery, r = n.from ? n.from.length : 0, i = null;
- if (r > 0) {
- z(1 === r);
- var o = n.from[0];
- o.allDescendants ? i = o.collectionId : e = e.child(o.collectionId);
- }
- var u = [];
- n.where && (u = function(t) {
- var e = Zi(t);
- return e instanceof In && Sn(e) ? e.getFilters() : [ e ];
- }(n.where));
- var a = [];
- n.orderBy && (a = n.orderBy.map((function(t) {
- return function(t) {
- return new yn(ro(t.field),
-
- function(t) {
- switch (t) {
- case "ASCENDING":
- return "asc" ;
- case "DESCENDING":
- return "desc" ;
- default:
- return;
- }
- }(t.direction));
- }(t);
- })));
- var s = null;
- n.limit && (s = function(t) {
- var e;
- return zt(e = "object" == typeof t ? t.value : t) ? null : e;
- }(n.limit));
- var c = null;
- n.startAt && (c = function(t) {
- var e = !!t.before, n = t.values || [];
- return new pn(n, e);
- }(n.startAt));
- var l = null;
- return n.endAt && (l = function(t) {
- var e = !t.before, n = t.values || [];
- return new pn(n, e);
- }(n.endAt)), Wn(e, i, a, u, s, "F" , c, l);
- }
- function Zi(t) {
- return void 0 !== t.unaryFilter ? function(t) {
- switch (t.unaryFilter.op) {
- case "IS_NAN":
- var e = ro(t.unaryFilter.field);
- return bn.create(e, "==" , {
- doubleValue: NaN
- });
- case "IS_NULL":
- var n = ro(t.unaryFilter.field);
- return bn.create(n, "==" , {
- nullValue: "NULL_VALUE"
- });
- case "IS_NOT_NAN":
- var r = ro(t.unaryFilter.field);
- return bn.create(r, "!=" , {
- doubleValue: NaN
- });
- case "IS_NOT_NULL":
- var i = ro(t.unaryFilter.field);
- return bn.create(i, "!=" , {
- nullValue: "NULL_VALUE"
- });
- default:
- return U();
- }
- }(t) : void 0 !== t.fieldFilter ? function(t) {
- return bn.create(ro(t.fieldFilter.field), function(t) {
- switch (t) {
- case "EQUAL":
- return "==" ;
- case "NOT_EQUAL":
- return "!=" ;
- case "GREATER_THAN":
- return ">" ;
- case "GREATER_THAN_OR_EQUAL":
- return ">=" ;
- case "LESS_THAN":
- return "<" ;
- case "LESS_THAN_OR_EQUAL":
- return "<=" ;
- case "ARRAY_CONTAINS":
- return "array-contains" ;
- case "IN":
- return "in" ;
- case "NOT_IN":
- return "not-in" ;
- case "ARRAY_CONTAINS_ANY":
- return "array-contains-any" ;
- default:
- return U();
- }
- }(t.fieldFilter.op), t.fieldFilter.value);
- }(t) : void 0 !== t.compositeFilter ? function(t) {
- return In.create(t.compositeFilter.filters.map((function(t) {
- return Zi(t);
- })), function(t) {
- switch (t) {
- case "AND":
- return "and" ;
- case "OR":
- return "or" ;
- default:
- return U();
- }
- }(t.compositeFilter.op));
- }(t) : U();
- }
- function $i(t) {
- return xi[t];
- }
- function to(t) {
- return Ni[t];
- }
- function eo(t) {
- return Ai[t];
- }
- function no(t) {
- return {
- fieldPath: t.canonicalString()
- };
- }
- function ro(t) {
- return dt.fromServerFormat(t.fieldPath);
- }
- function io(t) {
- return t instanceof bn ? function(t) {
- if ("==" === t.op) {
- if (nn(t.value)) return {
- unaryFilter: {
- field: no(t.field),
- op: "IS_NAN"
- }
- };
- if (en(t.value)) return {
- unaryFilter: {
- field: no(t.field),
- op: "IS_NULL"
- }
- };
- } else if ("!=" === t.op) {
- if (nn(t.value)) return {
- unaryFilter: {
- field: no(t.field),
- op: "IS_NOT_NAN"
- }
- };
- if (en(t.value)) return {
- unaryFilter: {
- field: no(t.field),
- op: "IS_NOT_NULL"
- }
- };
- }
- return {
- fieldFilter: {
- field: no(t.field),
- op: to(t.op),
- value: t.value
- }
- };
- }(t) : t instanceof In ? function(t) {
- var e = t.getFilters().map((function(t) {
- return io(t);
- }));
- return 1 === e.length ? e[0] : {
- compositeFilter: {
- op: eo(t.op),
- filters: e
- }
- };
- }(t) : U();
- }
- function oo(t) {
- var e = [];
- return t.fields.forEach((function(t) {
- return e.push(t.canonicalString());
- })), {
- fieldPaths: e
- };
- }
- function uo(t) {
-
- return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
- }
- var ao = function() {
- function t(
-
- t,
-
- e,
-
- n,
-
- r,
-
- i
-
- , o
-
- , u
-
- , a) {
- void 0 === i && (i = ct.min()), void 0 === o && (o = ct.min()), void 0 === u && (u = Oe.EMPTY_BYTE_STRING),
- void 0 === a && (a = null), this.target = t, this.targetId = e, this.purpose = n,
- this.sequenceNumber = r, this.snapshotVersion = i, this.lastLimboFreeSnapshotVersion = o,
- this.resumeToken = u, this.expectedCount = a;
- }
- return t.prototype.withSequenceNumber = function(e) {
- return new t(this.target, this.targetId, this.purpose, e, this.snapshotVersion, this.lastLimboFreeSnapshotVersion, this.resumeToken, this.expectedCount);
- },
-
- t.prototype.withResumeToken = function(e, n) {
- return new t(this.target, this.targetId, this.purpose, this.sequenceNumber, n, this.lastLimboFreeSnapshotVersion, e,
- null);
- },
-
- t.prototype.withExpectedCount = function(e) {
- return new t(this.target, this.targetId, this.purpose, this.sequenceNumber, this.snapshotVersion, this.lastLimboFreeSnapshotVersion, this.resumeToken, e);
- },
-
- t.prototype.withLastLimboFreeSnapshotVersion = function(e) {
- return new t(this.target, this.targetId, this.purpose, this.sequenceNumber, this.snapshotVersion, e, this.resumeToken, this.expectedCount);
- }, t;
- }(), so = function(t) {
- this.fe = t;
- };
- function co(t, e) {
- var n = e.key, r = {
- prefixPath: n.getCollectionPath().popLast().toArray(),
- collectionGroup: n.collectionGroup,
- documentId: n.path.lastSegment(),
- readTime: lo(e.readTime),
- hasCommittedMutations: e.hasCommittedMutations
- };
- if (e.isFoundDocument()) r.document = function(t, e) {
- return {
- name: qi(t, e.key),
- fields: e.data.value.mapValue.fields,
- updateTime: Fi(t, e.version.toTimestamp()),
- createTime: Fi(t, e.createTime.toTimestamp())
- };
- }(t.fe, e); else if (e.isNoDocument()) r.noDocument = {
- path: n.path.toArray(),
- readTime: ho(e.version)
- }; else {
- if (!e.isUnknownDocument()) return U();
- r.unknownDocument = {
- path: n.path.toArray(),
- version: ho(e.version)
- };
- }
- return r;
- }
- function lo(t) {
- var e = t.toTimestamp();
- return [ e.seconds, e.nanoseconds ];
- }
- function ho(t) {
- var e = t.toTimestamp();
- return {
- seconds: e.seconds,
- nanoseconds: e.nanoseconds
- };
- }
- function fo(t) {
- var e = new st(t.seconds, t.nanoseconds);
- return ct.fromTimestamp(e);
- }
- function po(t, e) {
-
-
-
-
-
- for (var n = (e.baseMutations || []).map((function(e) {
- return Hi(t.fe, e);
- })), r = 0; r < e.mutations.length - 1; ++r) {
- var i = e.mutations[r];
- if (r + 1 < e.mutations.length && void 0 !== e.mutations[r + 1].transform) {
- var o = e.mutations[r + 1];
- i.updateTransforms = o.transform.fieldTransforms, e.mutations.splice(r + 1, 1),
- ++r;
- }
- }
- var u = e.mutations.map((function(e) {
- return Hi(t.fe, e);
- })), a = st.fromMillis(e.localWriteTimeMs);
- return new ii(e.batchId, a, n, u);
- }
- function vo(t) {
- var e, n, r = fo(t.readTime), i = void 0 !== t.lastLimboFreeSnapshotVersion ? fo(t.lastLimboFreeSnapshotVersion) : ct.min();
- return void 0 !== t.query.documents ? (z(1 === (n = t.query).documents.length),
- e = tr(Hn(zi(n.documents[0])))) : e = function(t) {
- return tr(Ji(t));
- }(t.query), new ao(e, t.targetId, "TargetPurposeListen" , t.lastListenSequenceNumber, r, i, Oe.fromBase64String(t.resumeToken))
- ;
- }
- function mo(t, e) {
- var n, r = ho(e.snapshotVersion), i = ho(e.lastLimboFreeSnapshotVersion);
- n = zn(e.target) ? Yi(t.fe, e.target) : Xi(t.fe, e.target);
-
-
- var o = e.resumeToken.toBase64();
-
- return {
- targetId: e.targetId,
- canonicalId: Bn(e.target),
- readTime: r,
- resumeToken: o,
- lastListenSequenceNumber: e.sequenceNumber,
- lastLimboFreeSnapshotVersion: i,
- query: n
- };
- }
- function yo(t) {
- var e = Ji({
- parent: t.parent,
- structuredQuery: t.structuredQuery
- });
- return "LAST" === t.limitType ? nr(e, e.limit, "L" ) : e;
- }
- function go(t, e) {
- return new ui(e.largestBatchId, Hi(t.fe, e.overlayMutation));
- }
- function wo(t, e) {
- var n = e.path.lastSegment();
- return [ t, Kt(e.path.popLast()), n ];
- }
- function bo(t, e, n, r) {
- return {
- indexId: t,
- uid: e.uid || "",
- sequenceNumber: n,
- readTime: ho(r.readTime),
- documentKey: Kt(r.documentKey.path),
- largestBatchId: r.largestBatchId
- };
- }
- var Io = function() {
- function t() {}
- return t.prototype.getBundleMetadata = function(t, e) {
- return Eo(t).get(e).next((function(t) {
- if (t) return {
- id: (e = t).bundleId,
- createTime: fo(e.createTime),
- version: e.version
- };
- var e;
- }));
- }, t.prototype.saveBundleMetadata = function(t, e) {
- return Eo(t).put({
- bundleId: (n = e).id,
- createTime: ho(Vi(n.createTime)),
- version: n.version
- });
- var n;
- }, t.prototype.getNamedQuery = function(t, e) {
- return To(t).get(e).next((function(t) {
- if (t) return {
- name: (e = t).name,
- query: yo(e.bundledQuery),
- readTime: fo(e.readTime)
- };
- var e;
- }));
- }, t.prototype.saveNamedQuery = function(t, e) {
- return To(t).put(function(t) {
- return {
- name: t.name,
- readTime: ho(Vi(t.readTime)),
- bundledQuery: t.bundledQuery
- };
- }(e));
- }, t;
- }();
- function Eo(t) {
- return we(t, "bundles");
- }
- function To(t) {
- return we(t, "namedQueries");
- }
- var So = function() {
-
- function t(t, e) {
- this.serializer = t, this.userId = e;
- }
- return t.de = function(e, n) {
- return new t(e, n.uid || "");
- }, t.prototype.getOverlay = function(t, e) {
- var n = this;
- return _o(t).get(wo(this.userId, e)).next((function(t) {
- return t ? go(n.serializer, t) : null;
- }));
- }, t.prototype.getOverlays = function(t, e) {
- var n = this, r = mr();
- return Nt.forEach(e, (function(e) {
- return n.getOverlay(t, e).next((function(t) {
- null !== t && r.set(e, t);
- }));
- })).next((function() {
- return r;
- }));
- }, t.prototype.saveOverlays = function(t, e, n) {
- var r = this, i = [];
- return n.forEach((function(n, o) {
- var u = new ui(e, o);
- i.push(r.we(t, u));
- })), Nt.waitFor(i);
- }, t.prototype.removeOverlaysForBatchId = function(t, e, n) {
- var r = this, i = new Set;
-
- e.forEach((function(t) {
- return i.add(Kt(t.getCollectionPath()));
- }));
- var o = [];
- return i.forEach((function(e) {
- var i = IDBKeyRange.bound([ r.userId, e, n ], [ r.userId, e, n + 1 ],
- !1,
- !0);
- o.push(_o(t).J("collectionPathOverlayIndex", i));
- })), Nt.waitFor(o);
- }, t.prototype.getOverlaysForCollection = function(t, e, n) {
- var r = this, i = mr(), o = Kt(e), u = IDBKeyRange.bound([ this.userId, o, n ], [ this.userId, o, Number.POSITIVE_INFINITY ],
- !0);
- return _o(t).j("collectionPathOverlayIndex", u).next((function(t) {
- for (var e = 0, n = t; e < n.length; e++) {
- var o = n[e], u = go(r.serializer, o);
- i.set(u.getKey(), u);
- }
- return i;
- }));
- }, t.prototype.getOverlaysForCollectionGroup = function(t, e, n, r) {
- var i, o = this, u = mr(), a = IDBKeyRange.bound([ this.userId, e, n ], [ this.userId, e, Number.POSITIVE_INFINITY ],
- !0);
- return _o(t).X({
- index: "collectionGroupOverlayIndex",
- range: a
- }, (function(t, e, n) {
-
-
-
-
- var a = go(o.serializer, e);
- u.size() < r || a.largestBatchId === i ? (u.set(a.getKey(), a), i = a.largestBatchId) : n.done();
- })).next((function() {
- return u;
- }));
- }, t.prototype.we = function(t, e) {
- return _o(t).put(function(t, e, n) {
- var r = wo(e, n.mutation.key);
- return r[0], {
- userId: e,
- collectionPath: r[1],
- documentId: r[2],
- collectionGroup: n.mutation.key.getCollectionGroup(),
- largestBatchId: n.largestBatchId,
- overlayMutation: Wi(t.fe, n.mutation)
- };
- }(this.serializer, this.userId, e));
- }, t;
- }();
- function _o(t) {
- return we(t, "documentOverlays");
- }
- var Do = function() {
- function t() {}
-
-
-
-
-
-
- return t.prototype._e = function(t, e) {
- this.me(t, e),
-
-
- e.ge();
- }, t.prototype.me = function(t, e) {
- if ("nullValue" in t) this.ye(e, 5); else if ("booleanValue" in t) this.ye(e, 10),
- e.pe(t.booleanValue ? 1 : 0); else if ("integerValue" in t) this.ye(e, 15), e.pe(Re(t.integerValue)); else if ("doubleValue" in t) {
- var n = Re(t.doubleValue);
- isNaN(n) ? this.ye(e, 13) : (this.ye(e, 15), Gt(n) ?
-
- e.pe(0) : e.pe(n));
- } else if ("timestampValue" in t) {
- var r = t.timestampValue;
- this.ye(e, 20), "string" == typeof r ? e.Ie(r) : (e.Ie("".concat(r.seconds || "")),
- e.pe(r.nanos || 0));
- } else if ("stringValue" in t) this.Te(t.stringValue, e), this.Ee(e); else if ("bytesValue" in t) this.ye(e, 30),
- e.Ae(Ve(t.bytesValue)), this.Ee(e); else if ("referenceValue" in t) this.ve(t.referenceValue, e); else if ("geoPointValue" in t) {
- var i = t.geoPointValue;
- this.ye(e, 45), e.pe(i.latitude || 0), e.pe(i.longitude || 0);
- } else "mapValue" in t ? un(t) ? this.ye(e, Number.MAX_SAFE_INTEGER) : (this.Re(t.mapValue, e),
- this.Ee(e)) : "arrayValue" in t ? (this.Pe(t.arrayValue, e), this.Ee(e)) : U();
- }, t.prototype.Te = function(t, e) {
- this.ye(e, 25), this.be(t, e);
- }, t.prototype.be = function(t, e) {
- e.Ie(t);
- }, t.prototype.Re = function(t, e) {
- var n = t.fields || {};
- this.ye(e, 55);
- for (var r = 0, i = Object.keys(n); r < i.length; r++) {
- var o = i[r];
- this.Te(o, e), this.me(n[o], e);
- }
- }, t.prototype.Pe = function(t, e) {
- var n = t.values || [];
- this.ye(e, 50);
- for (var r = 0, i = n; r < i.length; r++) {
- var o = i[r];
- this.me(o, e);
- }
- }, t.prototype.ve = function(t, e) {
- var n = this;
- this.ye(e, 37), pt.fromName(t).path.forEach((function(t) {
- n.ye(e, 60), n.be(t, e);
- }));
- }, t.prototype.ye = function(t, e) {
- t.pe(e);
- }, t.prototype.Ee = function(t) {
-
-
-
- t.pe(2);
- }, t;
- }();
- function Co(t) {
- if (0 === t) return 8;
- var e = 0;
- return t >> 4 == 0 && (
-
- e += 4, t <<= 4), t >> 6 == 0 && (
-
- e += 2, t <<= 2), t >> 7 == 0 && (
-
- e += 1), e
-
-
- ;
- }
- function xo(t) {
-
- var e = 64 - function(t) {
- for (var e = 0, n = 0; n < 8; ++n) {
- var r = Co(255 & t[n]);
- if (e += r, 8 !== r) break;
- }
- return e;
- }(t);
- return Math.ceil(e / 8);
- }
- Do.Ve = new Do;
- var No = function() {
- function t() {
- this.buffer = new Uint8Array(1024), this.position = 0;
- }
- return t.prototype.Se = function(t) {
- for (var e = t[Symbol.iterator](), n = e.next(); !n.done; ) this.De(n.value), n = e.next();
- this.Ce();
- }, t.prototype.xe = function(t) {
- for (var e = t[Symbol.iterator](), n = e.next(); !n.done; ) this.Ne(n.value), n = e.next();
- this.ke();
- },
- t.prototype.Me = function(t) {
- for (var e = 0, n = t; e < n.length; e++) {
- var r = n[e], i = r.charCodeAt(0);
- if (i < 128) this.De(i); else if (i < 2048) this.De(960 | i >>> 6), this.De(128 | 63 & i); else if (r < "\ud800" || "\udbff" < r) this.De(480 | i >>> 12),
- this.De(128 | 63 & i >>> 6), this.De(128 | 63 & i); else {
- var o = r.codePointAt(0);
- this.De(240 | o >>> 18), this.De(128 | 63 & o >>> 12), this.De(128 | 63 & o >>> 6),
- this.De(128 | 63 & o);
- }
- }
- this.Ce();
- },
- t.prototype.$e = function(t) {
- for (var e = 0, n = t; e < n.length; e++) {
- var r = n[e], i = r.charCodeAt(0);
- if (i < 128) this.Ne(i); else if (i < 2048) this.Ne(960 | i >>> 6), this.Ne(128 | 63 & i); else if (r < "\ud800" || "\udbff" < r) this.Ne(480 | i >>> 12),
- this.Ne(128 | 63 & i >>> 6), this.Ne(128 | 63 & i); else {
- var o = r.codePointAt(0);
- this.Ne(240 | o >>> 18), this.Ne(128 | 63 & o >>> 12), this.Ne(128 | 63 & o >>> 6),
- this.Ne(128 | 63 & o);
- }
- }
- this.ke();
- }, t.prototype.Oe = function(t) {
-
-
- var e = this.Fe(t), n = xo(e);
- this.Be(1 + n), this.buffer[this.position++] = 255 & n;
-
- for (var r = e.length - n; r < e.length; ++r) this.buffer[this.position++] = 255 & e[r];
- }, t.prototype.Le = function(t) {
-
-
- var e = this.Fe(t), n = xo(e);
- this.Be(1 + n), this.buffer[this.position++] = ~(255 & n);
-
- for (var r = e.length - n; r < e.length; ++r) this.buffer[this.position++] = ~(255 & e[r]);
- },
-
- t.prototype.qe = function() {
- this.Ue(255), this.Ue(255);
- },
-
- t.prototype.Ke = function() {
- this.Ge(255), this.Ge(255);
- },
-
- t.prototype.reset = function() {
- this.position = 0;
- }, t.prototype.seed = function(t) {
- this.Be(t.length), this.buffer.set(t, this.position), this.position += t.length;
- },
- t.prototype.Qe = function() {
- return this.buffer.slice(0, this.position);
- },
-
- t.prototype.Fe = function(t) {
- var e =
-
- function(t) {
- var e = new DataView(new ArrayBuffer(8));
- return e.setFloat64(0, t, !1), new Uint8Array(e.buffer);
- }(t), n = 0 != (128 & e[0]);
-
-
-
- e[0] ^= n ? 255 : 128;
- for (var r = 1; r < e.length; ++r) e[r] ^= n ? 255 : 0;
- return e;
- },
- t.prototype.De = function(t) {
- var e = 255 & t;
- 0 === e ? (this.Ue(0), this.Ue(255)) : 255 === e ? (this.Ue(255), this.Ue(0)) : this.Ue(e);
- },
- t.prototype.Ne = function(t) {
- var e = 255 & t;
- 0 === e ? (this.Ge(0), this.Ge(255)) : 255 === e ? (this.Ge(255), this.Ge(0)) : this.Ge(t);
- }, t.prototype.Ce = function() {
- this.Ue(0), this.Ue(1);
- }, t.prototype.ke = function() {
- this.Ge(0), this.Ge(1);
- }, t.prototype.Ue = function(t) {
- this.Be(1), this.buffer[this.position++] = t;
- }, t.prototype.Ge = function(t) {
- this.Be(1), this.buffer[this.position++] = ~t;
- }, t.prototype.Be = function(t) {
- var e = t + this.position;
- if (!(e <= this.buffer.length)) {
-
- var n = 2 * this.buffer.length;
-
- n < e && (n = e);
-
- var r = new Uint8Array(n);
- r.set(this.buffer),
- this.buffer = r;
- }
- }, t;
- }(), Ao = function() {
- function t(t) {
- this.je = t;
- }
- return t.prototype.Ae = function(t) {
- this.je.Se(t);
- }, t.prototype.Ie = function(t) {
- this.je.Me(t);
- }, t.prototype.pe = function(t) {
- this.je.Oe(t);
- }, t.prototype.ge = function() {
- this.je.qe();
- }, t;
- }(), ko = function() {
- function t(t) {
- this.je = t;
- }
- return t.prototype.Ae = function(t) {
- this.je.xe(t);
- }, t.prototype.Ie = function(t) {
- this.je.$e(t);
- }, t.prototype.pe = function(t) {
- this.je.Le(t);
- }, t.prototype.ge = function() {
- this.je.Ke();
- }, t;
- }(), Oo = function() {
- function t() {
- this.je = new No, this.ze = new Ao(this.je), this.We = new ko(this.je);
- }
- return t.prototype.seed = function(t) {
- this.je.seed(t);
- }, t.prototype.He = function(t) {
- return 0 === t ? this.ze : this.We;
- }, t.prototype.Qe = function() {
- return this.je.Qe();
- }, t.prototype.reset = function() {
- this.je.reset();
- }, t;
- }(), Fo = function() {
- function t(t, e, n, r) {
- this.indexId = t, this.documentKey = e, this.arrayValue = n, this.directionalValue = r
-
- ;
- }
- return t.prototype.Je = function() {
- var e = this.directionalValue.length, n = 0 === e || 255 === this.directionalValue[e - 1] ? e + 1 : e, r = new Uint8Array(n);
- return r.set(this.directionalValue, 0), n !== e ? r.set([ 0 ], this.directionalValue.length) : ++r[r.length - 1],
- new t(this.indexId, this.documentKey, this.arrayValue, r);
- }, t;
- }();
- function Po(t, e) {
- var n = t.indexId - e.indexId;
- return 0 !== n ? n : 0 !== (n = Ro(t.arrayValue, e.arrayValue)) ? n : 0 !== (n = Ro(t.directionalValue, e.directionalValue)) ? n : pt.comparator(t.documentKey, e.documentKey);
- }
- function Ro(t, e) {
- for (var n = 0; n < t.length && n < e.length; ++n) {
- var r = t[n] - e[n];
- if (0 !== r) return r;
- }
- return t.length - e.length;
- }
- var Vo = function() {
- function t(t) {
- this.collectionId = null != t.collectionGroup ? t.collectionGroup : t.path.lastSegment(),
- this.Ye = t.orderBy, this.Xe = [];
- for (var e = 0, n = t.filters; e < n.length; e++) {
- var r = n[e];
- r.isInequality() ? this.Ze = r : this.Xe.push(r);
- }
- }
-
- return t.prototype.tn = function(t) {
- z(t.collectionGroup === this.collectionId);
-
- var e = mt(t);
- if (void 0 !== e && !this.en(e)) return !1;
-
- for (var n = yt(t), r = new Set, i = 0, o = 0; i < n.length && this.en(n[i]); ++i) r = r.add(n[i].fieldPath.canonicalString());
-
-
-
- if (i === n.length) return !0;
- if (void 0 !== this.Ze) {
-
-
-
- if (!r.has(this.Ze.field.canonicalString())) {
- var u = n[i];
- if (!this.nn(this.Ze, u) || !this.sn(this.Ye[o++], u)) return !1;
- }
- ++i;
- }
-
-
- for (;i < n.length; ++i) {
- var a = n[i];
- if (o >= this.Ye.length || !this.sn(this.Ye[o++], a)) return !1;
- }
- return !0;
- }, t.prototype.en = function(t) {
- for (var e = 0, n = this.Xe; e < n.length; e++) {
- var r = n[e];
- if (this.nn(r, t)) return !0;
- }
- return !1;
- }, t.prototype.nn = function(t, e) {
- if (void 0 === t || !t.field.isEqual(e.fieldPath)) return !1;
- var n = "array-contains" === t.op || "array-contains-any" === t.op;
- return 2 === e.kind === n;
- }, t.prototype.sn = function(t, e) {
- return !!t.field.isEqual(e.fieldPath) && (0 === e.kind && "asc" === t.dir || 1 === e.kind && "desc" === t.dir);
- }, t;
- }();
- function Mo(t) {
- var e, n;
- if (z(t instanceof bn || t instanceof In), t instanceof bn) {
- if (t instanceof Rn) {
- var r = (null === (n = null === (e = t.value.arrayValue) || void 0 === e ? void 0 : e.values) || void 0 === n ? void 0 : n.map((function(e) {
- return bn.create(t.field, "==" , e);
- }))) || [];
- return In.create(r, "or" );
- }
-
- return t;
- }
-
- var i = t.filters.map((function(t) {
- return Mo(t);
- }));
- return In.create(i, t.op);
- }
- function Lo(t) {
- if (0 === t.getFilters().length) return [];
- var e = zo(Mo(t));
- return z(Uo(e)), qo(e) || Bo(e) ? [ e ] : e.getFilters()
- ;
- }
- function qo(t) {
- return t instanceof bn;
- }
- function Bo(t) {
- return t instanceof In && Sn(t);
- }
- function Uo(t) {
- return qo(t) || Bo(t) ||
-
- function(t) {
- if (t instanceof In && Tn(t)) {
- for (var e = 0, n = t.getFilters(); e < n.length; e++) {
- var r = n[e];
- if (!qo(r) && !Bo(r)) return !1;
- }
- return !0;
- }
- return !1;
- }(t);
- }
- function zo(t) {
- if (z(t instanceof bn || t instanceof In), t instanceof bn) return t;
- if (1 === t.filters.length) return zo(t.filters[0]);
-
- var e = t.filters.map((function(t) {
- return zo(t);
- })), n = In.create(e, t.op);
- return Uo(n = Ko(n)) ? n : (z(n instanceof In), z(En(n)), z(n.filters.length > 1),
- n.filters.reduce((function(t, e) {
- return Go(t, e);
- })));
- }
- function Go(t, e) {
- var n;
- return z(t instanceof bn || t instanceof In), z(e instanceof bn || e instanceof In),
-
- n = t instanceof bn ? e instanceof bn ? function(t, e) {
-
- return In.create([ t, e ], "and" );
- }(t, e) : jo(t, e) : e instanceof bn ? jo(e, t) : function(t, e) {
-
-
-
-
-
-
- if (z(t.filters.length > 0 && e.filters.length > 0), En(t) && En(e)) return xn(t, e.getFilters());
-
-
-
- var n = Tn(t) ? t : e, r = Tn(t) ? e : t, i = n.filters.map((function(t) {
- return Go(t, r);
- }));
- return In.create(i, "or" );
- }(t, e), Ko(n);
- }
- function jo(t, e) {
-
-
-
- if (En(e))
-
- return xn(e, t.getFilters());
-
- var n = e.filters.map((function(e) {
- return Go(t, e);
- }));
- return In.create(n, "or" );
- }
- function Ko(t) {
- if (z(t instanceof bn || t instanceof In), t instanceof bn) return t;
- var e = t.getFilters();
-
- if (1 === e.length) return Ko(e[0]);
-
- if (_n(t)) return t;
-
-
- var n = e.map((function(t) {
- return Ko(t);
- })), r = [];
-
-
-
-
-
-
-
- return n.forEach((function(e) {
- e instanceof bn ? r.push(e) : e instanceof In && (e.op === t.op ?
-
-
-
- r.push.apply(
-
-
-
- r, e.filters) :
-
-
-
- r.push(e));
- })), 1 === r.length ? r[0] : In.create(r, t.op)
-
-
- ;
- }
- var Qo = function() {
- function t() {
- this.rn = new Wo;
- }
- return t.prototype.addToCollectionParentIndex = function(t, e) {
- return this.rn.add(e), Nt.resolve();
- }, t.prototype.getCollectionParents = function(t, e) {
- return Nt.resolve(this.rn.getEntries(e));
- }, t.prototype.addFieldIndex = function(t, e) {
-
- return Nt.resolve();
- }, t.prototype.deleteFieldIndex = function(t, e) {
-
- return Nt.resolve();
- }, t.prototype.getDocumentsMatchingTarget = function(t, e) {
-
- return Nt.resolve(null);
- }, t.prototype.getIndexType = function(t, e) {
-
- return Nt.resolve(0 );
- }, t.prototype.getFieldIndexes = function(t, e) {
-
- return Nt.resolve([]);
- }, t.prototype.getNextCollectionGroupToUpdate = function(t) {
-
- return Nt.resolve(null);
- }, t.prototype.getMinOffset = function(t, e) {
- return Nt.resolve(St.min());
- }, t.prototype.getMinOffsetFromCollectionGroup = function(t, e) {
- return Nt.resolve(St.min());
- }, t.prototype.updateCollectionGroup = function(t, e, n) {
-
- return Nt.resolve();
- }, t.prototype.updateIndexEntries = function(t, e) {
-
- return Nt.resolve();
- }, t;
- }(), Wo = function() {
- function t() {
- this.index = {};
- }
-
- return t.prototype.add = function(t) {
- var e = t.lastSegment(), n = t.popLast(), r = this.index[e] || new De(ht.comparator), i = !r.has(n);
- return this.index[e] = r.add(n), i;
- }, t.prototype.has = function(t) {
- var e = t.lastSegment(), n = t.popLast(), r = this.index[e];
- return r && r.has(n);
- }, t.prototype.getEntries = function(t) {
- return (this.index[t] || new De(ht.comparator)).toArray();
- }, t;
- }(), Ho = new Uint8Array(0), Yo = function() {
- function t(t, e) {
- this.user = t, this.databaseId = e,
-
- this.on = new Wo,
-
- this.un = new lr((function(t) {
- return Bn(t);
- }), (function(t, e) {
- return Un(t, e);
- })), this.uid = t.uid || ""
-
- ;
- }
- return t.prototype.addToCollectionParentIndex = function(t, e) {
- var n = this;
- if (!this.on.has(e)) {
- var r = e.lastSegment(), i = e.popLast();
- t.addOnCommittedListener((function() {
-
-
- n.on.add(e);
- }));
- var o = {
- collectionId: r,
- parent: Kt(i)
- };
- return Xo(t).put(o);
- }
- return Nt.resolve();
- }, t.prototype.getCollectionParents = function(t, e) {
- var n = [], r = IDBKeyRange.bound([ e, "" ], [ at(e), "" ],
- !1,
- !0);
- return Xo(t).j(r).next((function(t) {
- for (var r = 0, i = t; r < i.length; r++) {
- var o = i[r];
-
-
-
-
- if (o.collectionId !== e) break;
- n.push(Ht(o.parent));
- }
- return n;
- }));
- }, t.prototype.addFieldIndex = function(t, e) {
- var n = this, r = Zo(t), i = function(t) {
- return {
- indexId: t.indexId,
- collectionGroup: t.collectionGroup,
- fields: t.fields.map((function(t) {
- return [ t.fieldPath.canonicalString(), t.kind ];
- }))
- };
- }(e);
-
-
- delete i.indexId;
-
- var o = r.add(i);
- if (e.indexState) {
- var u = $o(t);
- return o.next((function(t) {
- u.put(bo(t, n.user, e.indexState.sequenceNumber, e.indexState.offset));
- }));
- }
- return o.next();
- }, t.prototype.deleteFieldIndex = function(t, e) {
- var n = Zo(t), r = $o(t), i = Jo(t);
- return n.delete(e.indexId).next((function() {
- return r.delete(IDBKeyRange.bound([ e.indexId ], [ e.indexId + 1 ],
- !1,
- !0));
- })).next((function() {
- return i.delete(IDBKeyRange.bound([ e.indexId ], [ e.indexId + 1 ],
- !1,
- !0));
- }));
- }, t.prototype.getDocumentsMatchingTarget = function(t, e) {
- var n = this, r = Jo(t), i = !0, o = new Map;
- return Nt.forEach(this.cn(e), (function(e) {
- return n.an(t, e).next((function(t) {
- i && (i = !!t), o.set(e, t);
- }));
- })).next((function() {
- if (i) {
- var t = Ir(), u = [];
- return Nt.forEach(o, (function(i, o) {
- var a;
- M("IndexedDbIndexManager", "Using index ".concat((a = i, "id=".concat(a.indexId, "|cg=").concat(a.collectionGroup, "|f=").concat(a.fields.map((function(t) {
- return "".concat(t.fieldPath, ":").concat(t.kind);
- })).join(","))), " to execute ").concat(Bn(e)));
- var s = function(t, e) {
- var n = mt(e);
- if (void 0 === n) return null;
- for (var r = 0, i = Gn(t, n.fieldPath); r < i.length; r++) {
- var o = i[r];
- switch (o.op) {
- case "array-contains-any" :
- return o.value.arrayValue.values || [];
- case "array-contains" :
- return [ o.value ];
-
- }
- }
- return null;
- }(o, i), c = function(t, e) {
- for (var n = new Map, r = 0, i = yt(e); r < i.length; r++) for (var o = i[r], u = 0, a = Gn(t, o.fieldPath); u < a.length; u++) {
- var s = a[u];
- switch (s.op) {
- case "==" :
- case "in" :
-
-
-
- n.set(o.fieldPath.canonicalString(), s.value);
- break;
- case "not-in" :
- case "!=" :
-
-
- return n.set(o.fieldPath.canonicalString(), s.value), Array.from(n.values());
-
- }
- }
- return null;
- }(o, i), l = function(t, e) {
-
-
- for (var n = [], r = !0, i = 0, o = yt(e); i < o.length; i++) {
- var u = o[i], a = 0 === u.kind ? jn(t, u.fieldPath, t.startAt) : Kn(t, u.fieldPath, t.startAt);
- n.push(a.value), r && (r = a.inclusive);
- }
- return new pn(n, r);
- }(o, i), h = function(t, e) {
-
-
- for (var n = [], r = !0, i = 0, o = yt(e); i < o.length; i++) {
- var u = o[i], a = 0 === u.kind ? Kn(t, u.fieldPath, t.endAt) : jn(t, u.fieldPath, t.endAt);
- n.push(a.value), r && (r = a.inclusive);
- }
- return new pn(n, r);
- }(o, i), f = n.hn(i, o, l), d = n.hn(i, o, h), p = n.ln(i, o, c), v = n.fn(i.indexId, s, f, l.inclusive, d, h.inclusive, p);
- return Nt.forEach(v, (function(n) {
- return r.H(n, e.limit).next((function(e) {
- e.forEach((function(e) {
- var n = pt.fromSegments(e.documentKey);
- t.has(n) || (t = t.add(n), u.push(n));
- }));
- }));
- }));
- })).next((function() {
- return u;
- }));
- }
- return Nt.resolve(null);
- }));
- }, t.prototype.cn = function(t) {
- var e = this.un.get(t);
- return e || (e = 0 === t.filters.length ? [ t ] : Lo(In.create(t.filters, "and" )).map((function(e) {
- return qn(t.path, t.collectionGroup, t.orderBy, e.getFilters(), t.limit, t.startAt, t.endAt);
- })), this.un.set(t, e), e);
- },
-
- t.prototype.fn = function(t, e, n, r, i, o, u) {
- for (var a = this, s = (null != e ? e.length : 1) * Math.max(n.length, i.length), c = s / (null != e ? e.length : 1), l = [], h = function(s) {
- var h = e ? f.dn(e[s / c]) : Ho, d = f.wn(t, h, n[s % c], r), p = f._n(t, h, i[s % c], o), v = u.map((function(e) {
- return a.wn(t, h, e,
- !0);
- }));
- l.push.apply(l, f.createRange(d, p, v));
- }, f = this, d = 0
-
-
-
-
- ; d < s; ++d) h(d);
- return l;
- },
- t.prototype.wn = function(t, e, n, r) {
- var i = new Fo(t, pt.empty(), e, n);
- return r ? i : i.Je();
- },
- t.prototype._n = function(t, e, n, r) {
- var i = new Fo(t, pt.empty(), e, n);
- return r ? i.Je() : i;
- }, t.prototype.an = function(t, e) {
- var n = new Vo(e), r = null != e.collectionGroup ? e.collectionGroup : e.path.lastSegment();
- return this.getFieldIndexes(t, r).next((function(t) {
- for (
-
- var e = null, r = 0, i = t; r < i.length; r++) {
- var o = i[r];
- n.tn(o) && (!e || o.fields.length > e.fields.length) && (e = o);
- }
- return e;
- }));
- }, t.prototype.getIndexType = function(t, e) {
- var n = this, r = 2 , i = this.cn(e);
- return Nt.forEach(i, (function(e) {
- return n.an(t, e).next((function(t) {
- t ? 0 !== r && t.fields.length < function(t) {
- for (var e = new De(dt.comparator), n = !1, r = 0, i = t.filters; r < i.length; r++) for (var o = 0, u = i[r].getFlattenedFilters(); o < u.length; o++) {
- var a = u[o];
-
-
- a.field.isKeyField() || (
-
-
-
-
- "array-contains" === a.op || "array-contains-any" === a.op ? n = !0 : e = e.add(a.field));
- }
- for (var s = 0, c = t.orderBy; s < c.length; s++) {
- var l = c[s];
-
-
- l.field.isKeyField() || (e = e.add(l.field));
- }
- return e.size + (n ? 1 : 0);
- }(e) && (r = 1 ) : r = 0 ;
- }));
- })).next((function() {
-
-
-
- return function(t) {
- return null !== t.limit;
- }(e) && i.length > 1 && 2 === r ? 1 : r;
- }));
- },
-
- t.prototype.mn = function(t, e) {
- for (var n = new Oo, r = 0, i = yt(t); r < i.length; r++) {
- var o = i[r], u = e.data.field(o.fieldPath);
- if (null == u) return null;
- var a = n.He(o.kind);
- Do.Ve._e(u, a);
- }
- return n.Qe();
- },
- t.prototype.dn = function(t) {
- var e = new Oo;
- return Do.Ve._e(t, e.He(0 )), e.Qe();
- },
-
- t.prototype.gn = function(t, e) {
- var n = new Oo;
- return Do.Ve._e(Ze(this.databaseId, e), n.He(function(t) {
- var e = yt(t);
- return 0 === e.length ? 0 : e[e.length - 1].kind;
- }(t))), n.Qe();
- },
-
- t.prototype.ln = function(t, e, n) {
- if (null === n) return [];
- var r = [];
- r.push(new Oo);
- for (var i = 0, o = 0, u = yt(t); o < u.length; o++) for (var a = u[o], s = n[i++], c = 0, l = r; c < l.length; c++) {
- var h = l[c];
- if (this.yn(e, a.fieldPath) && tn(s)) r = this.pn(r, a, s); else {
- var f = h.He(a.kind);
- Do.Ve._e(s, f);
- }
- }
- return this.In(r);
- },
-
- t.prototype.hn = function(t, e, n) {
- return this.ln(t, e, n.position);
- },
- t.prototype.In = function(t) {
- for (var e = [], n = 0; n < t.length; ++n) e[n] = t[n].Qe();
- return e;
- },
-
- t.prototype.pn = function(t, e, n) {
- for (var i = r([], t, !0), o = [], u = 0, a = n.arrayValue.values || []; u < a.length; u++) for (var s = a[u], c = 0, l = i; c < l.length; c++) {
- var h = l[c], f = new Oo;
- f.seed(h.Qe()), Do.Ve._e(s, f.He(e.kind)), o.push(f);
- }
- return o;
- }, t.prototype.yn = function(t, e) {
- return !!t.filters.find((function(t) {
- return t instanceof bn && t.field.isEqual(e) && ("in" === t.op || "not-in" === t.op);
- }));
- }, t.prototype.getFieldIndexes = function(t, e) {
- var n = this, r = Zo(t), i = $o(t);
- return (e ? r.j("collectionGroupIndex", IDBKeyRange.bound(e, e)) : r.j()).next((function(t) {
- var e = [];
- return Nt.forEach(t, (function(t) {
- return i.get([ t.indexId, n.uid ]).next((function(n) {
- e.push(function(t, e) {
- var n = e ? new It(e.sequenceNumber, new St(fo(e.readTime), new pt(Ht(e.documentKey)), e.largestBatchId)) : It.empty(), r = t.fields.map((function(t) {
- var e = t[0], n = t[1];
- return new wt(dt.fromServerFormat(e), n);
- }));
- return new vt(t.indexId, t.collectionGroup, r, n);
- }(t, n));
- }));
- })).next((function() {
- return e;
- }));
- }));
- }, t.prototype.getNextCollectionGroupToUpdate = function(t) {
- return this.getFieldIndexes(t).next((function(t) {
- return 0 === t.length ? null : (t.sort((function(t, e) {
- var n = t.indexState.sequenceNumber - e.indexState.sequenceNumber;
- return 0 !== n ? n : ot(t.collectionGroup, e.collectionGroup);
- })), t[0].collectionGroup);
- }));
- }, t.prototype.updateCollectionGroup = function(t, e, n) {
- var r = this, i = Zo(t), o = $o(t);
- return this.Tn(t).next((function(t) {
- return i.j("collectionGroupIndex", IDBKeyRange.bound(e, e)).next((function(e) {
- return Nt.forEach(e, (function(e) {
- return o.put(bo(e.indexId, r.user, t, n));
- }));
- }));
- }));
- }, t.prototype.updateIndexEntries = function(t, e) {
- var n = this, r = new Map;
-
-
-
-
-
- return Nt.forEach(e, (function(e, i) {
- var o = r.get(e.collectionGroup);
- return (o ? Nt.resolve(o) : n.getFieldIndexes(t, e.collectionGroup)).next((function(o) {
- return r.set(e.collectionGroup, o), Nt.forEach(o, (function(r) {
- return n.En(t, e, r).next((function(e) {
- var o = n.An(i, r);
- return e.isEqual(o) ? Nt.resolve() : n.vn(t, i, r, e, o);
- }));
- }));
- }));
- }));
- }, t.prototype.Rn = function(t, e, n, r) {
- return Jo(t).put({
- indexId: r.indexId,
- uid: this.uid,
- arrayValue: r.arrayValue,
- directionalValue: r.directionalValue,
- orderedDocumentKey: this.gn(n, e.key),
- documentKey: e.key.path.toArray()
- });
- }, t.prototype.Pn = function(t, e, n, r) {
- return Jo(t).delete([ r.indexId, this.uid, r.arrayValue, r.directionalValue, this.gn(n, e.key), e.key.path.toArray() ]);
- }, t.prototype.En = function(t, e, n) {
- var r = Jo(t), i = new De(Po);
- return r.X({
- index: "documentKeyIndex",
- range: IDBKeyRange.only([ n.indexId, this.uid, this.gn(n, e) ])
- }, (function(t, r) {
- i = i.add(new Fo(n.indexId, e, r.arrayValue, r.directionalValue));
- })).next((function() {
- return i;
- }));
- },
- t.prototype.An = function(t, e) {
- var n = new De(Po), r = this.mn(e, t);
- if (null == r) return n;
- var i = mt(e);
- if (null != i) {
- var o = t.data.field(i.fieldPath);
- if (tn(o)) for (var u = 0, a = o.arrayValue.values || []; u < a.length; u++) {
- var s = a[u];
- n = n.add(new Fo(e.indexId, t.key, this.dn(s), r));
- }
- } else n = n.add(new Fo(e.indexId, t.key, Ho, r));
- return n;
- },
-
- t.prototype.vn = function(t, e, n, r, i) {
- var o = this;
- M("IndexedDbIndexManager", "Updating index entries for document '%s'", e.key);
- var u = [];
- return function(t, e, n, r, i) {
-
-
- for (var o = t.getIterator(), u = e.getIterator(), a = xe(o), s = xe(u); a || s; ) {
- var c = !1, l = !1;
- if (a && s) {
- var h = n(a, s);
- h < 0 ?
-
-
- l = !0 : h > 0 && (
-
-
- c = !0);
- } else null != a ? l = !0 : c = !0;
- c ? (r(s), s = xe(u)) : l ? (i(a), a = xe(o)) : (a = xe(o), s = xe(u));
- }
- }(r, i, Po, (
- function(r) {
- u.push(o.Rn(t, e, n, r));
- }), (
- function(r) {
- u.push(o.Pn(t, e, n, r));
- })), Nt.waitFor(u);
- }, t.prototype.Tn = function(t) {
- var e = 1;
- return $o(t).X({
- index: "sequenceNumberIndex",
- reverse: !0,
- range: IDBKeyRange.upperBound([ this.uid, Number.MAX_SAFE_INTEGER ])
- }, (function(t, n, r) {
- r.done(), e = n.sequenceNumber + 1;
- })).next((function() {
- return e;
- }));
- },
-
- t.prototype.createRange = function(t, e, n) {
-
-
- n = n.sort((function(t, e) {
- return Po(t, e);
- })).filter((function(t, e, n) {
- return !e || 0 !== Po(t, n[e - 1]);
- }));
- var r = [];
- r.push(t);
- for (var i = 0, o = n; i < o.length; i++) {
- var u = o[i], a = Po(u, t), s = Po(u, e);
- if (0 === a)
-
-
- r[0] = t.Je(); else if (a > 0 && s < 0)
-
- r.push(u), r.push(u.Je()); else if (s > 0)
-
- break;
- }
- r.push(e);
- for (var c = [], l = 0; l < r.length; l += 2) {
-
-
- if (this.bn(r[l], r[l + 1])) return [];
- var h = [ r[l].indexId, this.uid, r[l].arrayValue, r[l].directionalValue, Ho, [] ], f = [ r[l + 1].indexId, this.uid, r[l + 1].arrayValue, r[l + 1].directionalValue, Ho, [] ];
- c.push(IDBKeyRange.bound(h, f));
- }
- return c;
- }, t.prototype.bn = function(t, e) {
-
-
- return Po(t, e) > 0;
- }, t.prototype.getMinOffsetFromCollectionGroup = function(t, e) {
- return this.getFieldIndexes(t, e).next(tu);
- }, t.prototype.getMinOffset = function(t, e) {
- var n = this;
- return Nt.mapArray(this.cn(e), (function(e) {
- return n.an(t, e).next((function(t) {
- return t || U();
- }));
- })).next(tu);
- }, t;
- }();
- function Xo(t) {
- return we(t, "collectionParents");
- }
- function Jo(t) {
- return we(t, "indexEntries");
- }
- function Zo(t) {
- return we(t, "indexConfiguration");
- }
- function $o(t) {
- return we(t, "indexState");
- }
- function tu(t) {
- z(0 !== t.length);
- for (var e = t[0].indexState.offset, n = e.largestBatchId, r = 1; r < t.length; r++) {
- var i = t[r].indexState.offset;
- _t(i, e) < 0 && (e = i), n < i.largestBatchId && (n = i.largestBatchId);
- }
- return new St(e.readTime, e.documentKey, n);
- }
- var eu = {
- didRun: !1,
- sequenceNumbersCollected: 0,
- targetsRemoved: 0,
- documentsRemoved: 0
- }, nu = function() {
- function t(
-
-
- t,
-
- e,
-
-
- n) {
- this.cacheSizeCollectionThreshold = t, this.percentileToCollect = e, this.maximumSequenceNumbersToCollect = n;
- }
- return t.withCacheSize = function(e) {
- return new t(e, t.DEFAULT_COLLECTION_PERCENTILE, t.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT);
- }, t;
- }();
- function ru(t, e, n) {
- var r = t.store("mutations"), i = t.store("documentMutations"), o = [], u = IDBKeyRange.only(n.batchId), a = 0, s = r.X({
- range: u
- }, (function(t, e, n) {
- return a++, n.delete();
- }));
- o.push(s.next((function() {
- z(1 === a);
- })));
- for (var c = [], l = 0, h = n.mutations; l < h.length; l++) {
- var f = h[l], d = Jt(e, f.key.path, n.batchId);
- o.push(i.delete(d)), c.push(f.key);
- }
- return Nt.waitFor(o).next((function() {
- return c;
- }));
- }
- function iu(t) {
- if (!t) return 0;
- var e;
- if (t.document) e = t.document; else if (t.unknownDocument) e = t.unknownDocument; else {
- if (!t.noDocument) throw U();
- e = t.noDocument;
- }
- return JSON.stringify(e).length;
- }
- nu.DEFAULT_COLLECTION_PERCENTILE = 10,
- nu.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT = 1e3, nu.DEFAULT = new nu(41943040, nu.DEFAULT_COLLECTION_PERCENTILE, nu.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),
- nu.DISABLED = new nu(-1, 0, 0);
- var ou = function() {
- function t(
-
- t, e, n, r) {
- this.userId = t, this.serializer = e, this.indexManager = n, this.referenceDelegate = r,
-
-
- this.Vn = {}
-
- ;
- }
- return t.de = function(e, n, r, i) {
-
-
-
-
- return z("" !== e.uid), new t(e.isAuthenticated() ? e.uid : "", n, r, i);
- }, t.prototype.checkEmpty = function(t) {
- var e = !0, n = IDBKeyRange.bound([ this.userId, Number.NEGATIVE_INFINITY ], [ this.userId, Number.POSITIVE_INFINITY ]);
- return au(t).X({
- index: "userMutationsIndex",
- range: n
- }, (function(t, n, r) {
- e = !1, r.done();
- })).next((function() {
- return e;
- }));
- }, t.prototype.addMutationBatch = function(t, e, n, r) {
- var i = this, o = su(t), u = au(t);
-
-
-
-
-
-
-
-
-
- return u.add({}).next((function(a) {
- z("number" == typeof a);
- for (var s = new ii(a, e, n, r), c = function(t, e, n) {
- var r = n.baseMutations.map((function(e) {
- return Wi(t.fe, e);
- })), i = n.mutations.map((function(e) {
- return Wi(t.fe, e);
- }));
- return {
- userId: e,
- batchId: n.batchId,
- localWriteTimeMs: n.localWriteTime.toMillis(),
- baseMutations: r,
- mutations: i
- };
- }(i.serializer, i.userId, s), l = [], h = new De((function(t, e) {
- return ot(t.canonicalString(), e.canonicalString());
- })), f = 0, d = r; f < d.length; f++) {
- var p = d[f], v = Jt(i.userId, p.key.path, a);
- h = h.add(p.key.path.popLast()), l.push(u.put(c)), l.push(o.put(v, Zt));
- }
- return h.forEach((function(e) {
- l.push(i.indexManager.addToCollectionParentIndex(t, e));
- })), t.addOnCommittedListener((function() {
- i.Vn[a] = s.keys();
- })), Nt.waitFor(l).next((function() {
- return s;
- }));
- }));
- }, t.prototype.lookupMutationBatch = function(t, e) {
- var n = this;
- return au(t).get(e).next((function(t) {
- return t ? (z(t.userId === n.userId), po(n.serializer, t)) : null;
- }));
- },
-
-
- t.prototype.Sn = function(t, e) {
- var n = this;
- return this.Vn[e] ? Nt.resolve(this.Vn[e]) : this.lookupMutationBatch(t, e).next((function(t) {
- if (t) {
- var r = t.keys();
- return n.Vn[e] = r, r;
- }
- return null;
- }));
- }, t.prototype.getNextMutationBatchAfterBatchId = function(t, e) {
- var n = this, r = e + 1, i = IDBKeyRange.lowerBound([ this.userId, r ]), o = null;
- return au(t).X({
- index: "userMutationsIndex",
- range: i
- }, (function(t, e, i) {
- e.userId === n.userId && (z(e.batchId >= r), o = po(n.serializer, e)), i.done();
- })).next((function() {
- return o;
- }));
- }, t.prototype.getHighestUnacknowledgedBatchId = function(t) {
- var e = IDBKeyRange.upperBound([ this.userId, Number.POSITIVE_INFINITY ]), n = -1;
- return au(t).X({
- index: "userMutationsIndex",
- range: e,
- reverse: !0
- }, (function(t, e, r) {
- n = e.batchId, r.done();
- })).next((function() {
- return n;
- }));
- }, t.prototype.getAllMutationBatches = function(t) {
- var e = this, n = IDBKeyRange.bound([ this.userId, -1 ], [ this.userId, Number.POSITIVE_INFINITY ]);
- return au(t).j("userMutationsIndex", n).next((function(t) {
- return t.map((function(t) {
- return po(e.serializer, t);
- }));
- }));
- }, t.prototype.getAllMutationBatchesAffectingDocumentKey = function(t, e) {
- var n = this, r = Xt(this.userId, e.path), i = IDBKeyRange.lowerBound(r), o = [];
-
-
- return su(t).X({
- range: i
- }, (function(r, i, u) {
- var a = r[0], s = r[1], c = r[2], l = Ht(s);
-
-
-
-
-
-
-
- if (a === n.userId && e.path.isEqual(l))
-
- return au(t).get(c).next((function(t) {
- if (!t) throw U();
- z(t.userId === n.userId), o.push(po(n.serializer, t));
- }));
- u.done();
- })).next((function() {
- return o;
- }));
- }, t.prototype.getAllMutationBatchesAffectingDocumentKeys = function(t, e) {
- var n = this, r = new De(ot), i = [];
- return e.forEach((function(e) {
- var o = Xt(n.userId, e.path), u = IDBKeyRange.lowerBound(o), a = su(t).X({
- range: u
- }, (function(t, i, o) {
- var u = t[0], a = t[1], s = t[2], c = Ht(a);
-
-
-
-
-
-
-
- u === n.userId && e.path.isEqual(c) ? r = r.add(s) : o.done();
- }));
- i.push(a);
- })), Nt.waitFor(i).next((function() {
- return n.Dn(t, r);
- }));
- }, t.prototype.getAllMutationBatchesAffectingQuery = function(t, e) {
- var n = this, r = e.path, i = r.length + 1, o = Xt(this.userId, r), u = IDBKeyRange.lowerBound(o), a = new De(ot);
- return su(t).X({
- range: u
- }, (function(t, e, o) {
- var u = t[0], s = t[1], c = t[2], l = Ht(s);
- u === n.userId && r.isPrefixOf(l) ?
-
-
-
-
-
- l.length === i && (a = a.add(c)) : o.done();
- })).next((function() {
- return n.Dn(t, a);
- }));
- }, t.prototype.Dn = function(t, e) {
- var n = this, r = [], i = [];
-
- return e.forEach((function(e) {
- i.push(au(t).get(e).next((function(t) {
- if (null === t) throw U();
- z(t.userId === n.userId), r.push(po(n.serializer, t));
- })));
- })), Nt.waitFor(i).next((function() {
- return r;
- }));
- }, t.prototype.removeMutationBatch = function(t, e) {
- var n = this;
- return ru(t.ht, this.userId, e).next((function(r) {
- return t.addOnCommittedListener((function() {
- n.Cn(e.batchId);
- })), Nt.forEach(r, (function(e) {
- return n.referenceDelegate.markPotentiallyOrphaned(t, e);
- }));
- }));
- },
-
-
- t.prototype.Cn = function(t) {
- delete this.Vn[t];
- }, t.prototype.performConsistencyCheck = function(t) {
- var e = this;
- return this.checkEmpty(t).next((function(n) {
- if (!n) return Nt.resolve();
-
-
- var r = IDBKeyRange.lowerBound([ e.userId ]), i = [];
- return su(t).X({
- range: r
- }, (function(t, n, r) {
- if (t[0] === e.userId) {
- var o = Ht(t[1]);
- i.push(o);
- } else r.done();
- })).next((function() {
- z(0 === i.length);
- }));
- }));
- }, t.prototype.containsKey = function(t, e) {
- return uu(t, this.userId, e);
- },
-
-
- t.prototype.xn = function(t) {
- var e = this;
- return cu(t).get(this.userId).next((function(t) {
- return t || {
- userId: e.userId,
- lastAcknowledgedBatchId: -1,
- lastStreamToken: ""
- };
- }));
- }, t;
- }();
- function uu(t, e, n) {
- var r = Xt(e, n.path), i = r[1], o = IDBKeyRange.lowerBound(r), u = !1;
- return su(t).X({
- range: o,
- Y: !0
- }, (function(t, n, r) {
- var o = t[0], a = t[1];
- t[2], o === e && a === i && (u = !0),
- r.done();
- })).next((function() {
- return u;
- }));
- }
- function au(t) {
- return we(t, "mutations");
- }
- function su(t) {
- return we(t, "documentMutations");
- }
- function cu(t) {
- return we(t, "mutationQueues");
- }
- var lu = function() {
- function t(t) {
- this.Nn = t;
- }
- return t.prototype.next = function() {
- return this.Nn += 2, this.Nn;
- }, t.kn = function() {
-
-
-
-
- return new t(0);
- }, t.Mn = function() {
-
- return new t(-1);
- }, t;
- }(), hu = function() {
- function t(t, e) {
- this.referenceDelegate = t, this.serializer = e;
- }
-
-
-
-
-
-
- return t.prototype.allocateTargetId = function(t) {
- var e = this;
- return this.$n(t).next((function(n) {
- var r = new lu(n.highestTargetId);
- return n.highestTargetId = r.next(), e.On(t, n).next((function() {
- return n.highestTargetId;
- }));
- }));
- }, t.prototype.getLastRemoteSnapshotVersion = function(t) {
- return this.$n(t).next((function(t) {
- return ct.fromTimestamp(new st(t.lastRemoteSnapshotVersion.seconds, t.lastRemoteSnapshotVersion.nanoseconds));
- }));
- }, t.prototype.getHighestSequenceNumber = function(t) {
- return this.$n(t).next((function(t) {
- return t.highestListenSequenceNumber;
- }));
- }, t.prototype.setTargetsMetadata = function(t, e, n) {
- var r = this;
- return this.$n(t).next((function(i) {
- return i.highestListenSequenceNumber = e, n && (i.lastRemoteSnapshotVersion = n.toTimestamp()),
- e > i.highestListenSequenceNumber && (i.highestListenSequenceNumber = e), r.On(t, i);
- }));
- }, t.prototype.addTargetData = function(t, e) {
- var n = this;
- return this.Fn(t, e).next((function() {
- return n.$n(t).next((function(r) {
- return r.targetCount += 1, n.Bn(e, r), n.On(t, r);
- }));
- }));
- }, t.prototype.updateTargetData = function(t, e) {
- return this.Fn(t, e);
- }, t.prototype.removeTargetData = function(t, e) {
- var n = this;
- return this.removeMatchingKeysForTargetId(t, e.targetId).next((function() {
- return fu(t).delete(e.targetId);
- })).next((function() {
- return n.$n(t);
- })).next((function(e) {
- return z(e.targetCount > 0), e.targetCount -= 1, n.On(t, e);
- }));
- },
-
- t.prototype.removeTargets = function(t, e, n) {
- var r = this, i = 0, o = [];
- return fu(t).X((function(u, a) {
- var s = vo(a);
- s.sequenceNumber <= e && null === n.get(s.targetId) && (i++, o.push(r.removeTargetData(t, s)));
- })).next((function() {
- return Nt.waitFor(o);
- })).next((function() {
- return i;
- }));
- },
-
- t.prototype.forEachTarget = function(t, e) {
- return fu(t).X((function(t, n) {
- var r = vo(n);
- e(r);
- }));
- }, t.prototype.$n = function(t) {
- return du(t).get("targetGlobalKey").next((function(t) {
- return z(null !== t), t;
- }));
- }, t.prototype.On = function(t, e) {
- return du(t).put("targetGlobalKey", e);
- }, t.prototype.Fn = function(t, e) {
- return fu(t).put(mo(this.serializer, e));
- },
-
- t.prototype.Bn = function(t, e) {
- var n = !1;
- return t.targetId > e.highestTargetId && (e.highestTargetId = t.targetId, n = !0),
- t.sequenceNumber > e.highestListenSequenceNumber && (e.highestListenSequenceNumber = t.sequenceNumber,
- n = !0), n;
- }, t.prototype.getTargetCount = function(t) {
- return this.$n(t).next((function(t) {
- return t.targetCount;
- }));
- }, t.prototype.getTargetData = function(t, e) {
-
-
-
- var n = Bn(e), r = IDBKeyRange.bound([ n, Number.NEGATIVE_INFINITY ], [ n, Number.POSITIVE_INFINITY ]), i = null;
- return fu(t).X({
- range: r,
- index: "queryTargetsIndex"
- }, (function(t, n, r) {
- var o = vo(n);
-
-
- Un(e, o.target) && (i = o, r.done());
- })).next((function() {
- return i;
- }));
- }, t.prototype.addMatchingKeys = function(t, e, n) {
- var r = this, i = [], o = pu(t);
-
-
- return e.forEach((function(e) {
- var u = Kt(e.path);
- i.push(o.put({
- targetId: n,
- path: u
- })), i.push(r.referenceDelegate.addReference(t, n, e));
- })), Nt.waitFor(i);
- }, t.prototype.removeMatchingKeys = function(t, e, n) {
- var r = this, i = pu(t);
-
-
- return Nt.forEach(e, (function(e) {
- var o = Kt(e.path);
- return Nt.waitFor([ i.delete([ n, o ]), r.referenceDelegate.removeReference(t, n, e) ]);
- }));
- }, t.prototype.removeMatchingKeysForTargetId = function(t, e) {
- var n = pu(t), r = IDBKeyRange.bound([ e ], [ e + 1 ],
- !1,
- !0);
- return n.delete(r);
- }, t.prototype.getMatchingKeysForTargetId = function(t, e) {
- var n = IDBKeyRange.bound([ e ], [ e + 1 ],
- !1,
- !0), r = pu(t), i = Ir();
- return r.X({
- range: n,
- Y: !0
- }, (function(t, e, n) {
- var r = Ht(t[1]), o = new pt(r);
- i = i.add(o);
- })).next((function() {
- return i;
- }));
- }, t.prototype.containsKey = function(t, e) {
- var n = Kt(e.path), r = IDBKeyRange.bound([ n ], [ at(n) ],
- !1,
- !0), i = 0;
- return pu(t).X({
- index: "documentTargetsIndex",
- Y: !0,
- range: r
- }, (function(t, e, n) {
- var r = t[0];
- t[1],
-
-
-
- 0 !== r && (i++, n.done());
- })).next((function() {
- return i > 0;
- }));
- },
-
-
- t.prototype.le = function(t, e) {
- return fu(t).get(e).next((function(t) {
- return t ? vo(t) : null;
- }));
- }, t;
- }();
- function fu(t) {
- return we(t, "targets");
- }
- function du(t) {
- return we(t, "targetGlobal");
- }
- function pu(t) {
- return we(t, "targetDocuments");
- }
- function vu(t, e) {
- var n = t[0], r = t[1], i = e[0], o = e[1], u = ot(n, i);
- return 0 === u ? ot(r, o) : u;
- }
- var mu = function() {
- function t(t) {
- this.Ln = t, this.buffer = new De(vu), this.qn = 0;
- }
- return t.prototype.Un = function() {
- return ++this.qn;
- }, t.prototype.Kn = function(t) {
- var e = [ t, this.Un() ];
- if (this.buffer.size < this.Ln) this.buffer = this.buffer.add(e); else {
- var n = this.buffer.last();
- vu(e, n) < 0 && (this.buffer = this.buffer.delete(n).add(e));
- }
- }, Object.defineProperty(t.prototype, "maxValue", {
- get: function() {
-
-
-
-
-
-
- return this.buffer.last()[0];
- },
- enumerable: !1,
- configurable: !0
- }), t;
- }(), yu = function() {
- function t(t, e, n) {
- this.garbageCollector = t, this.asyncQueue = e, this.localStore = n, this.Gn = null;
- }
- return t.prototype.start = function() {
- -1 !== this.garbageCollector.params.cacheSizeCollectionThreshold && this.Qn(6e4);
- }, t.prototype.stop = function() {
- this.Gn && (this.Gn.cancel(), this.Gn = null);
- }, Object.defineProperty(t.prototype, "started", {
- get: function() {
- return null !== this.Gn;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.Qn = function(t) {
- var r = this;
- M("LruGarbageCollector", "Garbage collection scheduled in ".concat(t, "ms")), this.Gn = this.asyncQueue.enqueueAfterDelay("lru_garbage_collection" , t, (function() {
- return e(r, void 0, void 0, (function() {
- var t;
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
- this.Gn = null, e.label = 1;
- case 1:
- return e.trys.push([ 1, 3, , 7 ]), [ 4 , this.localStore.collectGarbage(this.garbageCollector) ];
- case 2:
- return e.sent(), [ 3 , 7 ];
- case 3:
- return Pt(t = e.sent()) ? (M("LruGarbageCollector", "Ignoring IndexedDB error during garbage collection: ", t),
- [ 3 , 6 ]) : [ 3 , 4 ];
- case 4:
- return [ 4 , xt(t) ];
- case 5:
- e.sent(), e.label = 6;
- case 6:
- return [ 3 , 7 ];
- case 7:
- return [ 4 , this.Qn(3e5) ];
- case 8:
- return e.sent(), [ 2 ];
- }
- }));
- }));
- }));
- }, t;
- }(), gu = function() {
- function t(t, e) {
- this.jn = t, this.params = e;
- }
- return t.prototype.calculateTargetCount = function(t, e) {
- return this.jn.zn(t).next((function(t) {
- return Math.floor(e / 100 * t);
- }));
- }, t.prototype.nthSequenceNumber = function(t, e) {
- var n = this;
- if (0 === e) return Nt.resolve(Ut.ct);
- var r = new mu(e);
- return this.jn.forEachTarget(t, (function(t) {
- return r.Kn(t.sequenceNumber);
- })).next((function() {
- return n.jn.Wn(t, (function(t) {
- return r.Kn(t);
- }));
- })).next((function() {
- return r.maxValue;
- }));
- }, t.prototype.removeTargets = function(t, e, n) {
- return this.jn.removeTargets(t, e, n);
- }, t.prototype.removeOrphanedDocuments = function(t, e) {
- return this.jn.removeOrphanedDocuments(t, e);
- }, t.prototype.collect = function(t, e) {
- var n = this;
- return -1 === this.params.cacheSizeCollectionThreshold ? (M("LruGarbageCollector", "Garbage collection skipped; disabled"),
- Nt.resolve(eu)) : this.getCacheSize(t).next((function(r) {
- return r < n.params.cacheSizeCollectionThreshold ? (M("LruGarbageCollector", "Garbage collection skipped; Cache size ".concat(r, " is lower than threshold ").concat(n.params.cacheSizeCollectionThreshold)),
- eu) : n.Hn(t, e);
- }));
- }, t.prototype.getCacheSize = function(t) {
- return this.jn.getCacheSize(t);
- }, t.prototype.Hn = function(t, e) {
- var n, r, i, o, u, a, s, c = this, l = Date.now();
- return this.calculateTargetCount(t, this.params.percentileToCollect).next((function(e) {
-
- return e > c.params.maximumSequenceNumbersToCollect ? (M("LruGarbageCollector", "Capping sequence numbers to collect down to the maximum of ".concat(c.params.maximumSequenceNumbersToCollect, " from ").concat(e)),
- r = c.params.maximumSequenceNumbersToCollect) : r = e, o = Date.now(), c.nthSequenceNumber(t, r);
- })).next((function(r) {
- return n = r, u = Date.now(), c.removeTargets(t, n, e);
- })).next((function(e) {
- return i = e, a = Date.now(), c.removeOrphanedDocuments(t, n);
- })).next((function(t) {
- return s = Date.now(), R() <= h.DEBUG && M("LruGarbageCollector", "LRU Garbage Collection\n\tCounted targets in ".concat(o - l, "ms\n\tDetermined least recently used ").concat(r, " in ") + (u - o) + "ms\n" + "\tRemoved ".concat(i, " targets in ") + (a - u) + "ms\n" + "\tRemoved ".concat(t, " documents in ") + (s - a) + "ms\n" + "Total Duration: ".concat(s - l, "ms")),
- Nt.resolve({
- didRun: !0,
- sequenceNumbersCollected: r,
- targetsRemoved: i,
- documentsRemoved: t
- });
- }));
- }, t;
- }();
- function wu(t, e) {
- return new gu(t, e);
- }
- var bu = function() {
- function t(t, e) {
- this.db = t, this.garbageCollector = wu(this, e);
- }
- return t.prototype.zn = function(t) {
- var e = this.Jn(t);
- return this.db.getTargetCache().getTargetCount(t).next((function(t) {
- return e.next((function(e) {
- return t + e;
- }));
- }));
- }, t.prototype.Jn = function(t) {
- var e = 0;
- return this.Wn(t, (function(t) {
- e++;
- })).next((function() {
- return e;
- }));
- }, t.prototype.forEachTarget = function(t, e) {
- return this.db.getTargetCache().forEachTarget(t, e);
- }, t.prototype.Wn = function(t, e) {
- return this.Yn(t, (function(t, n) {
- return e(n);
- }));
- }, t.prototype.addReference = function(t, e, n) {
- return Iu(t, n);
- }, t.prototype.removeReference = function(t, e, n) {
- return Iu(t, n);
- }, t.prototype.removeTargets = function(t, e, n) {
- return this.db.getTargetCache().removeTargets(t, e, n);
- }, t.prototype.markPotentiallyOrphaned = function(t, e) {
- return Iu(t, e);
- },
-
- t.prototype.Xn = function(t, e) {
- return function(t, e) {
- var n = !1;
- return cu(t).Z((function(r) {
- return uu(t, r, e).next((function(t) {
- return t && (n = !0), Nt.resolve(!t);
- }));
- })).next((function() {
- return n;
- }));
- }(t, e);
- }, t.prototype.removeOrphanedDocuments = function(t, e) {
- var n = this, r = this.db.getRemoteDocumentCache().newChangeBuffer(), i = [], o = 0;
- return this.Yn(t, (function(u, a) {
- if (a <= e) {
- var s = n.Xn(t, u).next((function(e) {
- if (!e)
-
-
- return o++, r.getEntry(t, u).next((function() {
- return r.removeEntry(u, ct.min()), pu(t).delete([ 0, Kt(u.path) ]);
- }));
- }));
- i.push(s);
- }
- })).next((function() {
- return Nt.waitFor(i);
- })).next((function() {
- return r.apply(t);
- })).next((function() {
- return o;
- }));
- }, t.prototype.removeTarget = function(t, e) {
- var n = e.withSequenceNumber(t.currentSequenceNumber);
- return this.db.getTargetCache().updateTargetData(t, n);
- }, t.prototype.updateLimboDocument = function(t, e) {
- return Iu(t, e);
- },
-
- t.prototype.Yn = function(t, e) {
- var n, r = pu(t), i = Ut.ct;
- return r.X({
- index: "documentTargetsIndex"
- }, (function(t, r) {
- var o = t[0];
- t[1];
- var u = r.path, a = r.sequenceNumber;
- 0 === o ? (
-
-
- i !== Ut.ct && e(new pt(Ht(n)), i),
-
-
-
-
- i = a, n = u) :
-
-
- i = Ut.ct;
- })).next((function() {
-
-
-
- i !== Ut.ct && e(new pt(Ht(n)), i);
- }));
- }, t.prototype.getCacheSize = function(t) {
- return this.db.getRemoteDocumentCache().getSize(t);
- }, t;
- }();
- function Iu(t, e) {
- return pu(t).put(
-
- function(t, e) {
- return {
- targetId: 0,
- path: Kt(t.path),
- sequenceNumber: e
- };
- }(e, t.currentSequenceNumber));
- }
- var Eu = function() {
- function t() {
-
- this.changes = new lr((function(t) {
- return t.toString();
- }), (function(t, e) {
- return t.isEqual(e);
- })), this.changesApplied = !1
-
- ;
- }
- return t.prototype.addEntry = function(t) {
- this.assertNotApplied(), this.changes.set(t.key, t);
- },
-
- t.prototype.removeEntry = function(t, e) {
- this.assertNotApplied(), this.changes.set(t, dn.newInvalidDocument(t).setReadTime(e));
- },
-
- t.prototype.getEntry = function(t, e) {
- this.assertNotApplied();
- var n = this.changes.get(e);
- return void 0 !== n ? Nt.resolve(n) : this.getFromCache(t, e);
- },
-
- t.prototype.getEntries = function(t, e) {
- return this.getAllFromCache(t, e);
- },
-
- t.prototype.apply = function(t) {
- return this.assertNotApplied(), this.changesApplied = !0, this.applyChanges(t);
- },
- t.prototype.assertNotApplied = function() {},
- t;
- }(), Tu = function() {
- function t(t) {
- this.serializer = t;
- }
- return t.prototype.setIndexManager = function(t) {
- this.indexManager = t;
- },
-
- t.prototype.addEntry = function(t, e, n) {
- return Cu(t).put(n);
- },
-
- t.prototype.removeEntry = function(t, e, n) {
- return Cu(t).delete(
-
- function(t, e) {
- var n = t.path.toArray();
- return [
- n.slice(0, n.length - 2),
- n[n.length - 2], lo(e),
- n[n.length - 1] ];
- }(e, n));
- },
-
- t.prototype.updateMetadata = function(t, e) {
- var n = this;
- return this.getMetadata(t).next((function(r) {
- return r.byteSize += e, n.Zn(t, r);
- }));
- }, t.prototype.getEntry = function(t, e) {
- var n = this, r = dn.newInvalidDocument(e);
- return Cu(t).X({
- index: "documentKeyIndex",
- range: IDBKeyRange.only(xu(e))
- }, (function(t, i) {
- r = n.ts(e, i);
- })).next((function() {
- return r;
- }));
- },
-
- t.prototype.es = function(t, e) {
- var n = this, r = {
- size: 0,
- document: dn.newInvalidDocument(e)
- };
- return Cu(t).X({
- index: "documentKeyIndex",
- range: IDBKeyRange.only(xu(e))
- }, (function(t, i) {
- r = {
- document: n.ts(e, i),
- size: iu(i)
- };
- })).next((function() {
- return r;
- }));
- }, t.prototype.getEntries = function(t, e) {
- var n = this, r = fr();
- return this.ns(t, e, (function(t, e) {
- var i = n.ts(t, e);
- r = r.insert(t, i);
- })).next((function() {
- return r;
- }));
- },
-
- t.prototype.ss = function(t, e) {
- var n = this, r = fr(), i = new Te(pt.comparator);
- return this.ns(t, e, (function(t, e) {
- var o = n.ts(t, e);
- r = r.insert(t, o), i = i.insert(t, iu(e));
- })).next((function() {
- return {
- documents: r,
- rs: i
- };
- }));
- }, t.prototype.ns = function(t, e, n) {
- if (e.isEmpty()) return Nt.resolve();
- var i = new De(Au);
- e.forEach((function(t) {
- return i = i.add(t);
- }));
- var o = IDBKeyRange.bound(xu(i.first()), xu(i.last())), u = i.getIterator(), a = u.getNext();
- return Cu(t).X({
- index: "documentKeyIndex",
- range: o
- }, (function(t, e, i) {
-
- for (var o = pt.fromSegments(r(r([], e.prefixPath, !0), [ e.collectionGroup, e.documentId ], !1)); a && Au(a, o) < 0; ) n(a, null),
- a = u.getNext();
- a && a.isEqual(o) && (
-
- n(a, e), a = u.hasNext() ? u.getNext() : null),
-
- a ? i.G(xu(a)) : i.done();
- })).next((function() {
-
-
- for (;a; ) n(a, null), a = u.hasNext() ? u.getNext() : null;
- }));
- }, t.prototype.getDocumentsMatchingQuery = function(t, e, n, r) {
- var i = this, o = e.path, u = [ o.popLast().toArray(), o.lastSegment(), lo(n.readTime), n.documentKey.path.isEmpty() ? "" : n.documentKey.path.lastSegment() ], a = [ o.popLast().toArray(), o.lastSegment(), [ Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER ], "" ];
- return Cu(t).j(IDBKeyRange.bound(u, a, !0)).next((function(t) {
- for (var n = fr(), o = 0, u = t; o < u.length; o++) {
- var a = u[o], s = i.ts(pt.fromSegments(a.prefixPath.concat(a.collectionGroup, a.documentId)), a);
- s.isFoundDocument() && (ur(e, s) || r.has(s.key)) && (
-
- n = n.insert(s.key, s));
- }
- return n;
- }));
- }, t.prototype.getAllFromCollectionGroup = function(t, e, n, r) {
- var i = this, o = fr(), u = Nu(e, n), a = Nu(e, St.max());
- return Cu(t).X({
- index: "collectionGroupIndex",
- range: IDBKeyRange.bound(u, a, !0)
- }, (function(t, e, n) {
- var u = i.ts(pt.fromSegments(e.prefixPath.concat(e.collectionGroup, e.documentId)), e);
- (o = o.insert(u.key, u)).size === r && n.done();
- })).next((function() {
- return o;
- }));
- }, t.prototype.newChangeBuffer = function(t) {
- return new _u(this, !!t && t.trackRemovals);
- }, t.prototype.getSize = function(t) {
- return this.getMetadata(t).next((function(t) {
- return t.byteSize;
- }));
- }, t.prototype.getMetadata = function(t) {
- return Du(t).get("remoteDocumentGlobalKey").next((function(t) {
- return z(!!t), t;
- }));
- }, t.prototype.Zn = function(t, e) {
- return Du(t).put("remoteDocumentGlobalKey", e);
- },
-
- t.prototype.ts = function(t, e) {
- if (e) {
- var n =
- function(t, e) {
- var n;
- if (e.document) n = Qi(t.fe, e.document, !!e.hasCommittedMutations); else if (e.noDocument) {
- var r = pt.fromSegments(e.noDocument.path), i = fo(e.noDocument.readTime);
- n = dn.newNoDocument(r, i), e.hasCommittedMutations && n.setHasCommittedMutations();
- } else {
- if (!e.unknownDocument) return U();
- var o = pt.fromSegments(e.unknownDocument.path), u = fo(e.unknownDocument.version);
- n = dn.newUnknownDocument(o, u);
- }
- return e.readTime && n.setReadTime(function(t) {
- var e = new st(t[0], t[1]);
- return ct.fromTimestamp(e);
- }(e.readTime)), n;
- }(this.serializer, e);
-
-
- if (!n.isNoDocument() || !n.version.isEqual(ct.min())) return n;
- }
- return dn.newInvalidDocument(t);
- }, t;
- }();
- function Su(t) {
- return new Tu(t);
- }
- var _u = function(e) {
-
- function n(t, n) {
- var r = this;
- return (r = e.call(this) || this).os = t, r.trackRemovals = n,
-
-
- r.us = new lr((function(t) {
- return t.toString();
- }), (function(t, e) {
- return t.isEqual(e);
- })), r;
- }
- return t(n, e), n.prototype.applyChanges = function(t) {
- var e = this, n = [], r = 0, i = new De((function(t, e) {
- return ot(t.canonicalString(), e.canonicalString());
- }));
- return this.changes.forEach((function(o, u) {
- var a = e.us.get(o);
- if (n.push(e.os.removeEntry(t, o, a.readTime)), u.isValidDocument()) {
- var s = co(e.os.serializer, u);
- i = i.add(o.path.popLast());
- var c = iu(s);
- r += c - a.size, n.push(e.os.addEntry(t, o, s));
- } else if (r -= a.size, e.trackRemovals) {
-
-
-
-
- var l = co(e.os.serializer, u.convertToNoDocument(ct.min()));
- n.push(e.os.addEntry(t, o, l));
- }
- })), i.forEach((function(r) {
- n.push(e.os.indexManager.addToCollectionParentIndex(t, r));
- })), n.push(this.os.updateMetadata(t, r)), Nt.waitFor(n);
- }, n.prototype.getFromCache = function(t, e) {
- var n = this;
-
- return this.os.es(t, e).next((function(t) {
- return n.us.set(e, {
- size: t.size,
- readTime: t.document.readTime
- }), t.document;
- }));
- }, n.prototype.getAllFromCache = function(t, e) {
- var n = this;
-
-
- return this.os.ss(t, e).next((function(t) {
- var e = t.documents;
-
-
-
- return t.rs.forEach((function(t, r) {
- n.us.set(t, {
- size: r,
- readTime: e.get(t).readTime
- });
- })), e;
- }));
- }, n;
- }(Eu);
- function Du(t) {
- return we(t, "remoteDocumentGlobal");
- }
- function Cu(t) {
- return we(t, "remoteDocumentsV14");
- }
- function xu(t) {
- var e = t.path.toArray();
- return [
- e.slice(0, e.length - 2),
- e[e.length - 2],
- e[e.length - 1] ];
- }
- function Nu(t, e) {
- var n = e.documentKey.path.toArray();
- return [
- t, lo(e.readTime),
- n.slice(0, n.length - 2),
- n.length > 0 ? n[n.length - 1] : "" ];
- }
- function Au(t, e) {
- for (var n = t.path.toArray(), r = e.path.toArray(), i = 0, o = 0
-
- ; o < n.length - 2 && o < r.length - 2; ++o) if (i = ot(n[o], r[o])) return i;
- return (i = ot(n.length, r.length)) || ((i = ot(n[n.length - 2], r[r.length - 2])) || ot(n[n.length - 1], r[r.length - 1]));
- }
- var ku = function(t,
- e) {
- this.overlayedDocument = t, this.mutatedFields = e;
- }, Ou = function() {
- function t(t, e, n, r) {
- this.remoteDocumentCache = t, this.mutationQueue = e, this.documentOverlayCache = n,
- this.indexManager = r
-
- ;
- }
- return t.prototype.getDocument = function(t, e) {
- var n = this, r = null;
- return this.documentOverlayCache.getOverlay(t, e).next((function(i) {
- return r = i, n.remoteDocumentCache.getEntry(t, e);
- })).next((function(t) {
- return null !== r && Qr(r.mutation, t, Ne.empty(), st.now()), t;
- }));
- },
-
- t.prototype.getDocuments = function(t, e) {
- var n = this;
- return this.remoteDocumentCache.getEntries(t, e).next((function(e) {
- return n.getLocalViewOfDocuments(t, e, Ir()).next((function() {
- return e;
- }));
- }));
- },
-
- t.prototype.getLocalViewOfDocuments = function(t, e, n) {
- var r = this;
- void 0 === n && (n = Ir());
- var i = mr();
- return this.populateOverlays(t, i, e).next((function() {
- return r.computeViews(t, e, i, n).next((function(t) {
- var e = pr();
- return t.forEach((function(t, n) {
- e = e.insert(t, n.overlayedDocument);
- })), e;
- }));
- }));
- },
-
- t.prototype.getOverlayedDocuments = function(t, e) {
- var n = this, r = mr();
- return this.populateOverlays(t, r, e).next((function() {
- return n.computeViews(t, e, r, Ir());
- }));
- },
-
- t.prototype.populateOverlays = function(t, e, n) {
- var r = [];
- return n.forEach((function(t) {
- e.has(t) || r.push(t);
- })), this.documentOverlayCache.getOverlays(t, r).next((function(t) {
- t.forEach((function(t, n) {
- e.set(t, n);
- }));
- }));
- },
-
- t.prototype.computeViews = function(t, e, n, r) {
- var i = fr(), o = gr(), u = gr();
- return e.forEach((function(t, e) {
- var u = n.get(e.key);
-
-
-
-
-
-
-
- r.has(e.key) && (void 0 === u || u.mutation instanceof Xr) ? i = i.insert(e.key, e) : void 0 !== u ? (o.set(e.key, u.mutation.getFieldMask()),
- Qr(u.mutation, e, u.mutation.getFieldMask(), st.now())) :
-
-
- o.set(e.key, Ne.empty());
- })), this.recalculateAndSaveOverlays(t, i).next((function(t) {
- return t.forEach((function(t, e) {
- return o.set(t, e);
- })), e.forEach((function(t, e) {
- var n;
- return u.set(t, new ku(e, null !== (n = o.get(t)) && void 0 !== n ? n : null));
- })), u;
- }));
- }, t.prototype.recalculateAndSaveOverlays = function(t, e) {
- var n = this, r = gr(), i = new Te((function(t, e) {
- return t - e;
- })), o = Ir();
- return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t, e).next((function(t) {
- for (var n = function(t) {
- t.keys().forEach((function(n) {
- var o = e.get(n);
- if (null !== o) {
- var u = r.get(n) || Ne.empty();
- u = t.applyToLocalView(o, u), r.set(n, u);
- var a = (i.get(t.batchId) || Ir()).add(n);
- i = i.insert(t.batchId, a);
- }
- }));
- }, o = 0, u = t; o < u.length; o++) {
- n(u[o]);
- }
- })).next((function() {
-
-
- for (var u = [], a = i.getReverseIterator(), s = function() {
- var i = a.getNext(), s = i.key, c = i.value, l = yr();
- c.forEach((function(t) {
- if (!o.has(t)) {
- var n = jr(e.get(t), r.get(t));
- null !== n && l.set(t, n), o = o.add(t);
- }
- })), u.push(n.documentOverlayCache.saveOverlays(t, s, l));
- }; a.hasNext(); ) s();
- return Nt.waitFor(u);
- })).next((function() {
- return r;
- }));
- },
-
- t.prototype.recalculateAndSaveOverlaysForDocumentKeys = function(t, e) {
- var n = this;
- return this.remoteDocumentCache.getEntries(t, e).next((function(e) {
- return n.recalculateAndSaveOverlays(t, e);
- }));
- },
-
- t.prototype.getDocumentsMatchingQuery = function(t, e, n) {
-
- return function(t) {
- return pt.isDocumentKey(t.path) && null === t.collectionGroup && 0 === t.filters.length;
- }(e) ? this.getDocumentsMatchingDocumentQuery(t, e.path) : Zn(e) ? this.getDocumentsMatchingCollectionGroupQuery(t, e, n) : this.getDocumentsMatchingCollectionQuery(t, e, n);
- },
-
- t.prototype.getNextDocuments = function(t, e, n, r) {
- var i = this;
- return this.remoteDocumentCache.getAllFromCollectionGroup(t, e, n, r).next((function(o) {
- var u = r - o.size > 0 ? i.documentOverlayCache.getOverlaysForCollectionGroup(t, e, n.largestBatchId, r - o.size) : Nt.resolve(mr()), a = -1, s = o;
-
-
-
-
- return u.next((function(e) {
- return Nt.forEach(e, (function(e, n) {
- return a < n.largestBatchId && (a = n.largestBatchId), o.get(e) ? Nt.resolve() : i.remoteDocumentCache.getEntry(t, e).next((function(t) {
- s = s.insert(e, t);
- }));
- })).next((function() {
- return i.populateOverlays(t, e, o);
- })).next((function() {
- return i.computeViews(t, s, e, Ir());
- })).next((function(t) {
- return {
- batchId: a,
- changes: vr(t)
- };
- }));
- }));
- }));
- }, t.prototype.getDocumentsMatchingDocumentQuery = function(t, e) {
-
- return this.getDocument(t, new pt(e)).next((function(t) {
- var e = pr();
- return t.isFoundDocument() && (e = e.insert(t.key, t)), e;
- }));
- }, t.prototype.getDocumentsMatchingCollectionGroupQuery = function(t, e, n) {
- var r = this, i = e.collectionGroup, o = pr();
- return this.indexManager.getCollectionParents(t, i).next((function(u) {
- return Nt.forEach(u, (function(u) {
- var a = function(t, e) {
- return new Qn(e,
- null, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
- }(e, u.child(i));
- return r.getDocumentsMatchingCollectionQuery(t, a, n).next((function(t) {
- t.forEach((function(t, e) {
- o = o.insert(t, e);
- }));
- }));
- })).next((function() {
- return o;
- }));
- }));
- }, t.prototype.getDocumentsMatchingCollectionQuery = function(t, e, n) {
- var r, i = this;
-
- return this.documentOverlayCache.getOverlaysForCollection(t, e.path, n.largestBatchId).next((function(o) {
- return r = o, i.remoteDocumentCache.getDocumentsMatchingQuery(t, e, n, r);
- })).next((function(t) {
-
-
- r.forEach((function(e, n) {
- var r = n.getKey();
- null === t.get(r) && (t = t.insert(r, dn.newInvalidDocument(r)));
- }));
-
- var n = pr();
- return t.forEach((function(t, i) {
- var o = r.get(t);
- void 0 !== o && Qr(o.mutation, i, Ne.empty(), st.now()),
-
- ur(e, i) && (n = n.insert(t, i));
- })), n;
- }));
- }, t;
- }(), Fu = function() {
- function t(t) {
- this.serializer = t, this.cs = new Map, this.hs = new Map;
- }
- return t.prototype.getBundleMetadata = function(t, e) {
- return Nt.resolve(this.cs.get(e));
- }, t.prototype.saveBundleMetadata = function(t, e) {
-
- var n;
- return this.cs.set(e.id, {
- id: (n = e).id,
- version: n.version,
- createTime: Vi(n.createTime)
- }), Nt.resolve();
- }, t.prototype.getNamedQuery = function(t, e) {
- return Nt.resolve(this.hs.get(e));
- }, t.prototype.saveNamedQuery = function(t, e) {
- return this.hs.set(e.name, function(t) {
- return {
- name: t.name,
- query: yo(t.bundledQuery),
- readTime: Vi(t.readTime)
- };
- }(e)), Nt.resolve();
- }, t;
- }(), Pu = function() {
- function t() {
-
-
- this.overlays = new Te(pt.comparator), this.ls = new Map;
- }
- return t.prototype.getOverlay = function(t, e) {
- return Nt.resolve(this.overlays.get(e));
- }, t.prototype.getOverlays = function(t, e) {
- var n = this, r = mr();
- return Nt.forEach(e, (function(e) {
- return n.getOverlay(t, e).next((function(t) {
- null !== t && r.set(e, t);
- }));
- })).next((function() {
- return r;
- }));
- }, t.prototype.saveOverlays = function(t, e, n) {
- var r = this;
- return n.forEach((function(n, i) {
- r.we(t, e, i);
- })), Nt.resolve();
- }, t.prototype.removeOverlaysForBatchId = function(t, e, n) {
- var r = this, i = this.ls.get(n);
- return void 0 !== i && (i.forEach((function(t) {
- return r.overlays = r.overlays.remove(t);
- })), this.ls.delete(n)), Nt.resolve();
- }, t.prototype.getOverlaysForCollection = function(t, e, n) {
- for (var r = mr(), i = e.length + 1, o = new pt(e.child("")), u = this.overlays.getIteratorFrom(o); u.hasNext(); ) {
- var a = u.getNext().value, s = a.getKey();
- if (!e.isPrefixOf(s.path)) break;
-
- s.path.length === i && a.largestBatchId > n && r.set(a.getKey(), a);
- }
- return Nt.resolve(r);
- }, t.prototype.getOverlaysForCollectionGroup = function(t, e, n, r) {
- for (var i = new Te((function(t, e) {
- return t - e;
- })), o = this.overlays.getIterator(); o.hasNext(); ) {
- var u = o.getNext().value;
- if (u.getKey().getCollectionGroup() === e && u.largestBatchId > n) {
- var a = i.get(u.largestBatchId);
- null === a && (a = mr(), i = i.insert(u.largestBatchId, a)), a.set(u.getKey(), u);
- }
- }
- for (var s = mr(), c = i.getIterator(); c.hasNext() && (c.getNext().value.forEach((function(t, e) {
- return s.set(t, e);
- })), !(s.size() >= r)); ) ;
- return Nt.resolve(s);
- }, t.prototype.we = function(t, e, n) {
-
- var r = this.overlays.get(n.key);
- if (null !== r) {
- var i = this.ls.get(r.largestBatchId).delete(n.key);
- this.ls.set(r.largestBatchId, i);
- }
- this.overlays = this.overlays.insert(n.key, new ui(e, n));
-
- var o = this.ls.get(e);
- void 0 === o && (o = Ir(), this.ls.set(e, o)), this.ls.set(e, o.add(n.key));
- }, t;
- }(), Ru = function() {
- function t() {
-
- this.fs = new De(Vu.ds),
-
- this.ws = new De(Vu._s)
- ;
- }
- return t.prototype.isEmpty = function() {
- return this.fs.isEmpty();
- },
- t.prototype.addReference = function(t, e) {
- var n = new Vu(t, e);
- this.fs = this.fs.add(n), this.ws = this.ws.add(n);
- },
- t.prototype.gs = function(t, e) {
- var n = this;
- t.forEach((function(t) {
- return n.addReference(t, e);
- }));
- },
-
- t.prototype.removeReference = function(t, e) {
- this.ys(new Vu(t, e));
- }, t.prototype.ps = function(t, e) {
- var n = this;
- t.forEach((function(t) {
- return n.removeReference(t, e);
- }));
- },
-
- t.prototype.Is = function(t) {
- var e = this, n = new pt(new ht([])), r = new Vu(n, t), i = new Vu(n, t + 1), o = [];
- return this.ws.forEachInRange([ r, i ], (function(t) {
- e.ys(t), o.push(t.key);
- })), o;
- }, t.prototype.Ts = function() {
- var t = this;
- this.fs.forEach((function(e) {
- return t.ys(e);
- }));
- }, t.prototype.ys = function(t) {
- this.fs = this.fs.delete(t), this.ws = this.ws.delete(t);
- }, t.prototype.Es = function(t) {
- var e = new pt(new ht([])), n = new Vu(e, t), r = new Vu(e, t + 1), i = Ir();
- return this.ws.forEachInRange([ n, r ], (function(t) {
- i = i.add(t.key);
- })), i;
- }, t.prototype.containsKey = function(t) {
- var e = new Vu(t, 0), n = this.fs.firstAfterOrEqual(e);
- return null !== n && t.isEqual(n.key);
- }, t;
- }(), Vu = function() {
- function t(t, e) {
- this.key = t, this.As = e
- ;
- }
- return t.ds = function(t, e) {
- return pt.comparator(t.key, e.key) || ot(t.As, e.As);
- },
- t._s = function(t, e) {
- return ot(t.As, e.As) || pt.comparator(t.key, e.key);
- }, t;
- }(), Mu = function() {
- function t(t, e) {
- this.indexManager = t, this.referenceDelegate = e,
-
- this.mutationQueue = [],
-
- this.vs = 1,
-
- this.Rs = new De(Vu.ds);
- }
- return t.prototype.checkEmpty = function(t) {
- return Nt.resolve(0 === this.mutationQueue.length);
- }, t.prototype.addMutationBatch = function(t, e, n, r) {
- var i = this.vs;
- this.vs++, this.mutationQueue.length > 0 && this.mutationQueue[this.mutationQueue.length - 1];
- var o = new ii(i, e, n, r);
- this.mutationQueue.push(o);
-
- for (var u = 0, a = r; u < a.length; u++) {
- var s = a[u];
- this.Rs = this.Rs.add(new Vu(s.key, i)), this.indexManager.addToCollectionParentIndex(t, s.key.path.popLast());
- }
- return Nt.resolve(o);
- }, t.prototype.lookupMutationBatch = function(t, e) {
- return Nt.resolve(this.Ps(e));
- }, t.prototype.getNextMutationBatchAfterBatchId = function(t, e) {
- var n = e + 1, r = this.bs(n), i = r < 0 ? 0 : r;
-
-
- return Nt.resolve(this.mutationQueue.length > i ? this.mutationQueue[i] : null);
- }, t.prototype.getHighestUnacknowledgedBatchId = function() {
- return Nt.resolve(0 === this.mutationQueue.length ? -1 : this.vs - 1);
- }, t.prototype.getAllMutationBatches = function(t) {
- return Nt.resolve(this.mutationQueue.slice());
- }, t.prototype.getAllMutationBatchesAffectingDocumentKey = function(t, e) {
- var n = this, r = new Vu(e, 0), i = new Vu(e, Number.POSITIVE_INFINITY), o = [];
- return this.Rs.forEachInRange([ r, i ], (function(t) {
- var e = n.Ps(t.As);
- o.push(e);
- })), Nt.resolve(o);
- }, t.prototype.getAllMutationBatchesAffectingDocumentKeys = function(t, e) {
- var n = this, r = new De(ot);
- return e.forEach((function(t) {
- var e = new Vu(t, 0), i = new Vu(t, Number.POSITIVE_INFINITY);
- n.Rs.forEachInRange([ e, i ], (function(t) {
- r = r.add(t.As);
- }));
- })), Nt.resolve(this.Vs(r));
- }, t.prototype.getAllMutationBatchesAffectingQuery = function(t, e) {
-
-
- var n = e.path, r = n.length + 1, i = n;
-
-
-
-
- pt.isDocumentKey(i) || (i = i.child(""));
- var o = new Vu(new pt(i), 0), u = new De(ot);
-
-
- return this.Rs.forEachWhile((function(t) {
- var e = t.key.path;
- return !!n.isPrefixOf(e) && (
-
-
-
-
-
- e.length === r && (u = u.add(t.As)), !0);
- }), o), Nt.resolve(this.Vs(u));
- }, t.prototype.Vs = function(t) {
- var e = this, n = [];
-
-
- return t.forEach((function(t) {
- var r = e.Ps(t);
- null !== r && n.push(r);
- })), n;
- }, t.prototype.removeMutationBatch = function(t, e) {
- var n = this;
- z(0 === this.Ss(e.batchId, "removed")), this.mutationQueue.shift();
- var r = this.Rs;
- return Nt.forEach(e.mutations, (function(i) {
- var o = new Vu(i.key, e.batchId);
- return r = r.delete(o), n.referenceDelegate.markPotentiallyOrphaned(t, i.key);
- })).next((function() {
- n.Rs = r;
- }));
- }, t.prototype.Cn = function(t) {
-
- }, t.prototype.containsKey = function(t, e) {
- var n = new Vu(e, 0), r = this.Rs.firstAfterOrEqual(n);
- return Nt.resolve(e.isEqual(r && r.key));
- }, t.prototype.performConsistencyCheck = function(t) {
- return this.mutationQueue.length, Nt.resolve();
- },
-
- t.prototype.Ss = function(t, e) {
- return this.bs(t);
- },
-
- t.prototype.bs = function(t) {
- return 0 === this.mutationQueue.length ? 0 : t - this.mutationQueue[0].batchId;
-
-
-
-
- },
-
- t.prototype.Ps = function(t) {
- var e = this.bs(t);
- return e < 0 || e >= this.mutationQueue.length ? null : this.mutationQueue[e];
- }, t;
- }(), Lu = function() {
-
- function t(t) {
- this.Ds = t,
-
- this.docs = new Te(pt.comparator),
-
- this.size = 0;
- }
- return t.prototype.setIndexManager = function(t) {
- this.indexManager = t;
- },
-
- t.prototype.addEntry = function(t, e) {
- var n = e.key, r = this.docs.get(n), i = r ? r.size : 0, o = this.Ds(e);
- return this.docs = this.docs.insert(n, {
- document: e.mutableCopy(),
- size: o
- }), this.size += o - i, this.indexManager.addToCollectionParentIndex(t, n.path.popLast());
- },
-
- t.prototype.removeEntry = function(t) {
- var e = this.docs.get(t);
- e && (this.docs = this.docs.remove(t), this.size -= e.size);
- }, t.prototype.getEntry = function(t, e) {
- var n = this.docs.get(e);
- return Nt.resolve(n ? n.document.mutableCopy() : dn.newInvalidDocument(e));
- }, t.prototype.getEntries = function(t, e) {
- var n = this, r = fr();
- return e.forEach((function(t) {
- var e = n.docs.get(t);
- r = r.insert(t, e ? e.document.mutableCopy() : dn.newInvalidDocument(t));
- })), Nt.resolve(r);
- }, t.prototype.getDocumentsMatchingQuery = function(t, e, n, r) {
- for (var i = fr(), o = e.path, u = new pt(o.child("")), a = this.docs.getIteratorFrom(u)
-
-
- ; a.hasNext(); ) {
- var s = a.getNext(), c = s.key, l = s.value.document;
- if (!o.isPrefixOf(c.path)) break;
- c.path.length > o.length + 1 || _t(Tt(l), n) <= 0 || (r.has(l.key) || ur(e, l)) && (i = i.insert(l.key, l.mutableCopy()));
- }
- return Nt.resolve(i);
- }, t.prototype.getAllFromCollectionGroup = function(t, e, n, r) {
-
-
- U();
- }, t.prototype.Cs = function(t, e) {
- return Nt.forEach(this.docs, (function(t) {
- return e(t);
- }));
- }, t.prototype.newChangeBuffer = function(t) {
-
-
- return new qu(this);
- }, t.prototype.getSize = function(t) {
- return Nt.resolve(this.size);
- }, t;
- }(), qu = function(e) {
- function n(t) {
- var n = this;
- return (n = e.call(this) || this).os = t, n;
- }
- return t(n, e), n.prototype.applyChanges = function(t) {
- var e = this, n = [];
- return this.changes.forEach((function(r, i) {
- i.isValidDocument() ? n.push(e.os.addEntry(t, i)) : e.os.removeEntry(r);
- })), Nt.waitFor(n);
- }, n.prototype.getFromCache = function(t, e) {
- return this.os.getEntry(t, e);
- }, n.prototype.getAllFromCache = function(t, e) {
- return this.os.getEntries(t, e);
- }, n;
- }(Eu), Bu = function() {
- function t(t) {
- this.persistence = t,
-
- this.xs = new lr((function(t) {
- return Bn(t);
- }), Un),
-
- this.lastRemoteSnapshotVersion = ct.min(),
-
- this.highestTargetId = 0,
-
- this.Ns = 0,
-
- this.ks = new Ru, this.targetCount = 0, this.Ms = lu.kn();
- }
- return t.prototype.forEachTarget = function(t, e) {
- return this.xs.forEach((function(t, n) {
- return e(n);
- })), Nt.resolve();
- }, t.prototype.getLastRemoteSnapshotVersion = function(t) {
- return Nt.resolve(this.lastRemoteSnapshotVersion);
- }, t.prototype.getHighestSequenceNumber = function(t) {
- return Nt.resolve(this.Ns);
- }, t.prototype.allocateTargetId = function(t) {
- return this.highestTargetId = this.Ms.next(), Nt.resolve(this.highestTargetId);
- }, t.prototype.setTargetsMetadata = function(t, e, n) {
- return n && (this.lastRemoteSnapshotVersion = n), e > this.Ns && (this.Ns = e),
- Nt.resolve();
- }, t.prototype.Fn = function(t) {
- this.xs.set(t.target, t);
- var e = t.targetId;
- e > this.highestTargetId && (this.Ms = new lu(e), this.highestTargetId = e), t.sequenceNumber > this.Ns && (this.Ns = t.sequenceNumber);
- }, t.prototype.addTargetData = function(t, e) {
- return this.Fn(e), this.targetCount += 1, Nt.resolve();
- }, t.prototype.updateTargetData = function(t, e) {
- return this.Fn(e), Nt.resolve();
- }, t.prototype.removeTargetData = function(t, e) {
- return this.xs.delete(e.target), this.ks.Is(e.targetId), this.targetCount -= 1,
- Nt.resolve();
- }, t.prototype.removeTargets = function(t, e, n) {
- var r = this, i = 0, o = [];
- return this.xs.forEach((function(u, a) {
- a.sequenceNumber <= e && null === n.get(a.targetId) && (r.xs.delete(u), o.push(r.removeMatchingKeysForTargetId(t, a.targetId)),
- i++);
- })), Nt.waitFor(o).next((function() {
- return i;
- }));
- }, t.prototype.getTargetCount = function(t) {
- return Nt.resolve(this.targetCount);
- }, t.prototype.getTargetData = function(t, e) {
- var n = this.xs.get(e) || null;
- return Nt.resolve(n);
- }, t.prototype.addMatchingKeys = function(t, e, n) {
- return this.ks.gs(e, n), Nt.resolve();
- }, t.prototype.removeMatchingKeys = function(t, e, n) {
- this.ks.ps(e, n);
- var r = this.persistence.referenceDelegate, i = [];
- return r && e.forEach((function(e) {
- i.push(r.markPotentiallyOrphaned(t, e));
- })), Nt.waitFor(i);
- }, t.prototype.removeMatchingKeysForTargetId = function(t, e) {
- return this.ks.Is(e), Nt.resolve();
- }, t.prototype.getMatchingKeysForTargetId = function(t, e) {
- var n = this.ks.Es(e);
- return Nt.resolve(n);
- }, t.prototype.containsKey = function(t, e) {
- return Nt.resolve(this.ks.containsKey(e));
- }, t;
- }(), Uu = function() {
-
- function t(t, e) {
- var n = this;
- this.$s = {}, this.overlays = {}, this.Os = new Ut(0), this.Fs = !1, this.Fs = !0,
- this.referenceDelegate = t(this), this.Bs = new Bu(this), this.indexManager = new Qo,
- this.remoteDocumentCache = new Lu((function(t) {
- return n.referenceDelegate.Ls(t);
- })), this.serializer = new so(e), this.qs = new Fu(this.serializer);
- }
- return t.prototype.start = function() {
- return Promise.resolve();
- }, t.prototype.shutdown = function() {
-
- return this.Fs = !1, Promise.resolve();
- }, Object.defineProperty(t.prototype, "started", {
- get: function() {
- return this.Fs;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.setDatabaseDeletedListener = function() {
-
- }, t.prototype.setNetworkEnabled = function() {
-
- }, t.prototype.getIndexManager = function(t) {
-
-
- return this.indexManager;
- }, t.prototype.getDocumentOverlayCache = function(t) {
- var e = this.overlays[t.toKey()];
- return e || (e = new Pu, this.overlays[t.toKey()] = e), e;
- }, t.prototype.getMutationQueue = function(t, e) {
- var n = this.$s[t.toKey()];
- return n || (n = new Mu(e, this.referenceDelegate), this.$s[t.toKey()] = n), n;
- }, t.prototype.getTargetCache = function() {
- return this.Bs;
- }, t.prototype.getRemoteDocumentCache = function() {
- return this.remoteDocumentCache;
- }, t.prototype.getBundleCache = function() {
- return this.qs;
- }, t.prototype.runTransaction = function(t, e, n) {
- var r = this;
- M("MemoryPersistence", "Starting transaction:", t);
- var i = new zu(this.Os.next());
- return this.referenceDelegate.Us(), n(i).next((function(t) {
- return r.referenceDelegate.Ks(i).next((function() {
- return t;
- }));
- })).toPromise().then((function(t) {
- return i.raiseOnCommittedEvent(), t;
- }));
- }, t.prototype.Gs = function(t, e) {
- return Nt.or(Object.values(this.$s).map((function(n) {
- return function() {
- return n.containsKey(t, e);
- };
- })));
- }, t;
- }(), zu = function(e) {
- function n(t) {
- var n = this;
- return (n = e.call(this) || this).currentSequenceNumber = t, n;
- }
- return t(n, e), n;
- }(Ct), Gu = function() {
- function t(t) {
- this.persistence = t,
-
- this.Qs = new Ru,
-
- this.js = null;
- }
- return t.zs = function(e) {
- return new t(e);
- }, Object.defineProperty(t.prototype, "Ws", {
- get: function() {
- if (this.js) return this.js;
- throw U();
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.addReference = function(t, e, n) {
- return this.Qs.addReference(n, e), this.Ws.delete(n.toString()), Nt.resolve();
- }, t.prototype.removeReference = function(t, e, n) {
- return this.Qs.removeReference(n, e), this.Ws.add(n.toString()), Nt.resolve();
- }, t.prototype.markPotentiallyOrphaned = function(t, e) {
- return this.Ws.add(e.toString()), Nt.resolve();
- }, t.prototype.removeTarget = function(t, e) {
- var n = this;
- this.Qs.Is(e.targetId).forEach((function(t) {
- return n.Ws.add(t.toString());
- }));
- var r = this.persistence.getTargetCache();
- return r.getMatchingKeysForTargetId(t, e.targetId).next((function(t) {
- t.forEach((function(t) {
- return n.Ws.add(t.toString());
- }));
- })).next((function() {
- return r.removeTargetData(t, e);
- }));
- }, t.prototype.Us = function() {
- this.js = new Set;
- }, t.prototype.Ks = function(t) {
- var e = this, n = this.persistence.getRemoteDocumentCache().newChangeBuffer();
-
- return Nt.forEach(this.Ws, (function(r) {
- var i = pt.fromPath(r);
- return e.Hs(t, i).next((function(t) {
- t || n.removeEntry(i, ct.min());
- }));
- })).next((function() {
- return e.js = null, n.apply(t);
- }));
- }, t.prototype.updateLimboDocument = function(t, e) {
- var n = this;
- return this.Hs(t, e).next((function(t) {
- t ? n.Ws.delete(e.toString()) : n.Ws.add(e.toString());
- }));
- }, t.prototype.Ls = function(t) {
-
- return 0;
- }, t.prototype.Hs = function(t, e) {
- var n = this;
- return Nt.or([ function() {
- return Nt.resolve(n.Qs.containsKey(e));
- }, function() {
- return n.persistence.getTargetCache().containsKey(t, e);
- }, function() {
- return n.persistence.Gs(t, e);
- } ]);
- }, t;
- }(), ju = function() {
- function t(t, e) {
- this.persistence = t, this.Js = new lr((function(t) {
- return Kt(t.path);
- }), (function(t, e) {
- return t.isEqual(e);
- })), this.garbageCollector = wu(this, e);
- }
- return t.zs = function(e, n) {
- return new t(e, n);
- },
-
-
- t.prototype.Us = function() {}, t.prototype.Ks = function(t) {
- return Nt.resolve();
- }, t.prototype.forEachTarget = function(t, e) {
- return this.persistence.getTargetCache().forEachTarget(t, e);
- }, t.prototype.zn = function(t) {
- var e = this.Jn(t);
- return this.persistence.getTargetCache().getTargetCount(t).next((function(t) {
- return e.next((function(e) {
- return t + e;
- }));
- }));
- }, t.prototype.Jn = function(t) {
- var e = 0;
- return this.Wn(t, (function(t) {
- e++;
- })).next((function() {
- return e;
- }));
- }, t.prototype.Wn = function(t, e) {
- var n = this;
- return Nt.forEach(this.Js, (function(r, i) {
- return n.Xn(t, r, i).next((function(t) {
- return t ? Nt.resolve() : e(i);
- }));
- }));
- }, t.prototype.removeTargets = function(t, e, n) {
- return this.persistence.getTargetCache().removeTargets(t, e, n);
- }, t.prototype.removeOrphanedDocuments = function(t, e) {
- var n = this, r = 0, i = this.persistence.getRemoteDocumentCache(), o = i.newChangeBuffer();
- return i.Cs(t, (function(i) {
- return n.Xn(t, i, e).next((function(t) {
- t || (r++, o.removeEntry(i, ct.min()));
- }));
- })).next((function() {
- return o.apply(t);
- })).next((function() {
- return r;
- }));
- }, t.prototype.markPotentiallyOrphaned = function(t, e) {
- return this.Js.set(e, t.currentSequenceNumber), Nt.resolve();
- }, t.prototype.removeTarget = function(t, e) {
- var n = e.withSequenceNumber(t.currentSequenceNumber);
- return this.persistence.getTargetCache().updateTargetData(t, n);
- }, t.prototype.addReference = function(t, e, n) {
- return this.Js.set(n, t.currentSequenceNumber), Nt.resolve();
- }, t.prototype.removeReference = function(t, e, n) {
- return this.Js.set(n, t.currentSequenceNumber), Nt.resolve();
- }, t.prototype.updateLimboDocument = function(t, e) {
- return this.Js.set(e, t.currentSequenceNumber), Nt.resolve();
- }, t.prototype.Ls = function(t) {
- var e = t.key.toString().length;
- return t.isFoundDocument() && (e += Je(t.data.value)), e;
- }, t.prototype.Xn = function(t, e, n) {
- var r = this;
- return Nt.or([ function() {
- return r.persistence.Gs(t, e);
- }, function() {
- return r.persistence.getTargetCache().containsKey(t, e);
- }, function() {
- var t = r.Js.get(e);
- return Nt.resolve(void 0 !== t && t > n);
- } ]);
- }, t.prototype.getCacheSize = function(t) {
- return this.persistence.getRemoteDocumentCache().getSize(t);
- }, t;
- }(), Ku = function() {
- function t(t) {
- this.serializer = t;
- }
-
- return t.prototype.O = function(t, e, n, r) {
- var i = this, o = new At("createOrUpgrade", e);
- n < 1 && r >= 1 && (function(t) {
- t.createObjectStore("owner");
- }(t), function(t) {
- t.createObjectStore("mutationQueues", {
- keyPath: "userId"
- }), t.createObjectStore("mutations", {
- keyPath: "batchId",
- autoIncrement: !0
- }).createIndex("userMutationsIndex", Yt, {
- unique: !0
- }), t.createObjectStore("documentMutations");
- }(t), Qu(t), function(t) {
- t.createObjectStore("remoteDocuments");
- }(t));
-
-
- var u = Nt.resolve();
- return n < 3 && r >= 3 && (
-
-
- 0 !== n && (function(t) {
- t.deleteObjectStore("targetDocuments"), t.deleteObjectStore("targets"), t.deleteObjectStore("targetGlobal");
- }(t), Qu(t)), u = u.next((function() {
-
- return function(t) {
- var e = t.store("targetGlobal"), n = {
- highestTargetId: 0,
- highestListenSequenceNumber: 0,
- lastRemoteSnapshotVersion: ct.min().toTimestamp(),
- targetCount: 0
- };
- return e.put("targetGlobalKey", n);
- }(o);
- }))), n < 4 && r >= 4 && (0 !== n && (
-
-
-
-
-
-
- u = u.next((function() {
- return function(t, e) {
- return e.store("mutations").j().next((function(n) {
- t.deleteObjectStore("mutations"), t.createObjectStore("mutations", {
- keyPath: "batchId",
- autoIncrement: !0
- }).createIndex("userMutationsIndex", Yt, {
- unique: !0
- });
- var r = e.store("mutations"), i = n.map((function(t) {
- return r.put(t);
- }));
- return Nt.waitFor(i);
- }));
- }(t, o);
- }))), u = u.next((function() {
- !function(t) {
- t.createObjectStore("clientMetadata", {
- keyPath: "clientId"
- });
- }(t);
- }))), n < 5 && r >= 5 && (u = u.next((function() {
- return i.Ys(o);
- }))), n < 6 && r >= 6 && (u = u.next((function() {
- return function(t) {
- t.createObjectStore("remoteDocumentGlobal");
- }(t), i.Xs(o);
- }))), n < 7 && r >= 7 && (u = u.next((function() {
- return i.Zs(o);
- }))), n < 8 && r >= 8 && (u = u.next((function() {
- return i.ti(t, o);
- }))), n < 9 && r >= 9 && (u = u.next((function() {
-
-
-
- !function(t) {
- t.objectStoreNames.contains("remoteDocumentChanges") && t.deleteObjectStore("remoteDocumentChanges");
- }(t);
-
-
- }))), n < 10 && r >= 10 && (u = u.next((function() {
- return i.ei(o);
- }))), n < 11 && r >= 11 && (u = u.next((function() {
- !function(t) {
- t.createObjectStore("bundles", {
- keyPath: "bundleId"
- });
- }(t), function(t) {
- t.createObjectStore("namedQueries", {
- keyPath: "name"
- });
- }(t);
- }))), n < 12 && r >= 12 && (u = u.next((function() {
- !function(t) {
- var e = t.createObjectStore("documentOverlays", {
- keyPath: le
- });
- e.createIndex("collectionPathOverlayIndex", he, {
- unique: !1
- }), e.createIndex("collectionGroupOverlayIndex", fe, {
- unique: !1
- });
- }(t);
- }))), n < 13 && r >= 13 && (u = u.next((function() {
- return function(t) {
- var e = t.createObjectStore("remoteDocumentsV14", {
- keyPath: $t
- });
- e.createIndex("documentKeyIndex", te), e.createIndex("collectionGroupIndex", ee);
- }(t);
- })).next((function() {
- return i.ni(t, o);
- })).next((function() {
- return t.deleteObjectStore("remoteDocuments");
- }))), n < 14 && r >= 14 && (u = u.next((function() {
- return i.si(t, o);
- }))), n < 15 && r >= 15 && (u = u.next((function() {
- return function(t) {
- t.createObjectStore("indexConfiguration", {
- keyPath: "indexId",
- autoIncrement: !0
- }).createIndex("collectionGroupIndex", "collectionGroup", {
- unique: !1
- }), t.createObjectStore("indexState", {
- keyPath: ue
- }).createIndex("sequenceNumberIndex", ae, {
- unique: !1
- }), t.createObjectStore("indexEntries", {
- keyPath: se
- }).createIndex("documentKeyIndex", ce, {
- unique: !1
- });
- }(t);
- }))), u;
- }, t.prototype.Xs = function(t) {
- var e = 0;
- return t.store("remoteDocuments").X((function(t, n) {
- e += iu(n);
- })).next((function() {
- var n = {
- byteSize: e
- };
- return t.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey", n);
- }));
- }, t.prototype.Ys = function(t) {
- var e = this, n = t.store("mutationQueues"), r = t.store("mutations");
- return n.j().next((function(n) {
- return Nt.forEach(n, (function(n) {
- var i = IDBKeyRange.bound([ n.userId, -1 ], [ n.userId, n.lastAcknowledgedBatchId ]);
- return r.j("userMutationsIndex", i).next((function(r) {
- return Nt.forEach(r, (function(r) {
- z(r.userId === n.userId);
- var i = po(e.serializer, r);
- return ru(t, n.userId, i).next((function() {}));
- }));
- }));
- }));
- }));
- },
-
- t.prototype.Zs = function(t) {
- var e = t.store("targetDocuments"), n = t.store("remoteDocuments");
- return t.store("targetGlobal").get("targetGlobalKey").next((function(t) {
- var r = [];
- return n.X((function(n, i) {
- var o = new ht(n), u = function(t) {
- return [ 0, Kt(t) ];
- }(o);
- r.push(e.get(u).next((function(n) {
- return n ? Nt.resolve() : function(n) {
- return e.put({
- targetId: 0,
- path: Kt(n),
- sequenceNumber: t.highestListenSequenceNumber
- });
- }(o);
- })));
- })).next((function() {
- return Nt.waitFor(r);
- }));
- }));
- }, t.prototype.ti = function(t, e) {
-
- t.createObjectStore("collectionParents", {
- keyPath: oe
- });
- var n = e.store("collectionParents"), r = new Wo, i = function(t) {
- if (r.add(t)) {
- var e = t.lastSegment(), i = t.popLast();
- return n.put({
- collectionId: e,
- parent: Kt(i)
- });
- }
- };
-
-
- return e.store("remoteDocuments").X({
- Y: !0
- }, (function(t, e) {
- var n = new ht(t);
- return i(n.popLast());
- })).next((function() {
- return e.store("documentMutations").X({
- Y: !0
- }, (function(t, e) {
- t[0];
- var n = t[1];
- t[2];
- var r = Ht(n);
- return i(r.popLast());
- }));
- }));
- }, t.prototype.ei = function(t) {
- var e = this, n = t.store("targets");
- return n.X((function(t, r) {
- var i = vo(r), o = mo(e.serializer, i);
- return n.put(o);
- }));
- }, t.prototype.ni = function(t, e) {
- var n = e.store("remoteDocuments"), r = [];
- return n.X((function(t, n) {
- var i, o = e.store("remoteDocumentsV14"), u = (i = n, i.document ? new pt(ht.fromString(i.document.name).popFirst(5)) : i.noDocument ? pt.fromSegments(i.noDocument.path) : i.unknownDocument ? pt.fromSegments(i.unknownDocument.path) : U()).path.toArray(), a = {
- prefixPath: u.slice(0, u.length - 2),
- collectionGroup: u[u.length - 2],
- documentId: u[u.length - 1],
- readTime: n.readTime || [ 0, 0 ],
- unknownDocument: n.unknownDocument,
- noDocument: n.noDocument,
- document: n.document,
- hasCommittedMutations: !!n.hasCommittedMutations
- };
- r.push(o.put(a));
- })).next((function() {
- return Nt.waitFor(r);
- }));
- }, t.prototype.si = function(t, e) {
- var n = this, r = e.store("mutations"), i = Su(this.serializer), o = new Uu(Gu.zs, this.serializer.fe);
- return r.j().next((function(t) {
- var r = new Map;
- return t.forEach((function(t) {
- var e, i = null !== (e = r.get(t.userId)) && void 0 !== e ? e : Ir();
- po(n.serializer, t).keys().forEach((function(t) {
- return i = i.add(t);
- })), r.set(t.userId, i);
- })), Nt.forEach(r, (function(t, r) {
- var u = new O(r), a = So.de(n.serializer, u), s = o.getIndexManager(u), c = ou.de(u, n.serializer, s, o.referenceDelegate);
- return new Ou(i, c, a, s).recalculateAndSaveOverlaysForDocumentKeys(new ge(e, Ut.ct), t).next();
- }));
- }));
- }, t;
- }();
- function Qu(t) {
- t.createObjectStore("targetDocuments", {
- keyPath: re
- }).createIndex("documentTargetsIndex", ie, {
- unique: !0
- }),
-
- t.createObjectStore("targets", {
- keyPath: "targetId"
- }).createIndex("queryTargetsIndex", ne, {
- unique: !0
- }), t.createObjectStore("targetGlobal");
- }
- var Wu = "Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.", Hu = function() {
- function t(
-
- e, n, r, i, o, u, a, s, c,
-
- l, h) {
- if (void 0 === h && (h = 15), this.allowTabSynchronization = e, this.persistenceKey = n,
- this.clientId = r, this.ii = o, this.window = u, this.document = a, this.ri = c,
- this.oi = l, this.ui = h, this.Os = null, this.Fs = !1, this.isPrimary = !1, this.networkEnabled = !0,
-
- this.ci = null, this.inForeground = !1,
-
- this.ai = null,
-
- this.hi = null,
-
- this.li = Number.NEGATIVE_INFINITY,
-
- this.fi = function(t) {
- return Promise.resolve();
- }, !t.D()) throw new Q(K.UNIMPLEMENTED, "This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");
- this.referenceDelegate = new bu(this, i), this.di = n + "main", this.serializer = new so(s),
- this.wi = new kt(this.di, this.ui, new Ku(this.serializer)), this.Bs = new hu(this.referenceDelegate, this.serializer),
- this.remoteDocumentCache = Su(this.serializer), this.qs = new Io, this.window && this.window.localStorage ? this._i = this.window.localStorage : (this._i = null,
- !1 === l && L("IndexedDbPersistence", "LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."));
- }
-
- return t.prototype.start = function() {
- var t = this;
-
-
-
- return this.mi().then((function() {
- if (!t.isPrimary && !t.allowTabSynchronization)
-
-
- throw new Q(K.FAILED_PRECONDITION, Wu);
- return t.gi(), t.yi(), t.pi(), t.runTransaction("getHighestListenSequenceNumber", "readonly", (function(e) {
- return t.Bs.getHighestSequenceNumber(e);
- }));
- })).then((function(e) {
- t.Os = new Ut(e, t.ri);
- })).then((function() {
- t.Fs = !0;
- })).catch((function(e) {
- return t.wi && t.wi.close(), Promise.reject(e);
- }));
- },
-
- t.prototype.Ii = function(t) {
- var r = this;
- return this.fi = function(i) {
- return e(r, void 0, void 0, (function() {
- return n(this, (function(e) {
- return this.started ? [ 2 , t(i) ] : [ 2 ];
- }));
- }));
- }, t(this.isPrimary);
- },
-
- t.prototype.setDatabaseDeletedListener = function(t) {
- var r = this;
- this.wi.B((function(i) {
- return e(r, void 0, void 0, (function() {
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
- return null === i.newVersion ? [ 4 , t() ] : [ 3 , 2 ];
- case 1:
- e.sent(), e.label = 2;
- case 2:
- return [ 2 ];
- }
- }));
- }));
- }));
- },
-
- t.prototype.setNetworkEnabled = function(t) {
- var r = this;
- this.networkEnabled !== t && (this.networkEnabled = t,
-
-
- this.ii.enqueueAndForget((function() {
- return e(r, void 0, void 0, (function() {
- return n(this, (function(t) {
- switch (t.label) {
- case 0:
- return this.started ? [ 4 , this.mi() ] : [ 3 , 2 ];
- case 1:
- t.sent(), t.label = 2;
- case 2:
- return [ 2 ];
- }
- }));
- }));
- })));
- },
-
- t.prototype.mi = function() {
- var t = this;
- return this.runTransaction("updateClientMetadataAndTryBecomePrimary", "readwrite", (function(e) {
- return Xu(e).put({
- clientId: t.clientId,
- updateTimeMs: Date.now(),
- networkEnabled: t.networkEnabled,
- inForeground: t.inForeground
- }).next((function() {
- if (t.isPrimary) return t.Ti(e).next((function(e) {
- e || (t.isPrimary = !1, t.ii.enqueueRetryable((function() {
- return t.fi(!1);
- })));
- }));
- })).next((function() {
- return t.Ei(e);
- })).next((function(n) {
- return t.isPrimary && !n ? t.Ai(e).next((function() {
- return !1;
- })) : !!n && t.vi(e).next((function() {
- return !0;
- }));
- }));
- })).catch((function(e) {
- if (Pt(e))
-
-
- return M("IndexedDbPersistence", "Failed to extend owner lease: ", e), t.isPrimary;
- if (!t.allowTabSynchronization) throw e;
- return M("IndexedDbPersistence", "Releasing owner lease after error during lease refresh", e),
- !1;
- })).then((function(e) {
- t.isPrimary !== e && t.ii.enqueueRetryable((function() {
- return t.fi(e);
- })), t.isPrimary = e;
- }));
- }, t.prototype.Ti = function(t) {
- var e = this;
- return Yu(t).get("owner").next((function(t) {
- return Nt.resolve(e.Ri(t));
- }));
- }, t.prototype.Pi = function(t) {
- return Xu(t).delete(this.clientId);
- },
-
- t.prototype.bi = function() {
- return e(this, void 0, void 0, (function() {
- var t, e, r, i, o = this;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return !this.isPrimary || this.Vi(this.li, 18e5) ? [ 3 , 2 ] : (this.li = Date.now(),
- [ 4 , this.runTransaction("maybeGarbageCollectMultiClientState", "readwrite-primary", (function(t) {
- var e = we(t, "clientMetadata");
- return e.j().next((function(t) {
- var n = o.Si(t, 18e5), r = t.filter((function(t) {
- return -1 === n.indexOf(t);
- }));
-
- return Nt.forEach(r, (function(t) {
- return e.delete(t.clientId);
- })).next((function() {
- return r;
- }));
- }));
- })).catch((function() {
- return [];
- })) ]);
- case 1:
-
-
-
-
-
- if (t = n.sent(), this._i) for (e = 0, r = t; e < r.length; e++) i = r[e], this._i.removeItem(this.Di(i.clientId));
- n.label = 2;
- case 2:
- return [ 2 ];
- }
- }));
- }));
- },
-
- t.prototype.pi = function() {
- var t = this;
- this.hi = this.ii.enqueueAfterDelay("client_metadata_refresh" , 4e3, (function() {
- return t.mi().then((function() {
- return t.bi();
- })).then((function() {
- return t.pi();
- }));
- }));
- },
- t.prototype.Ri = function(t) {
- return !!t && t.ownerId === this.clientId;
- },
-
- t.prototype.Ei = function(t) {
- var e = this;
- return this.oi ? Nt.resolve(!0) : Yu(t).get("owner").next((function(n) {
-
-
-
-
-
-
-
-
-
- if (null !== n && e.Vi(n.leaseTimestampMs, 5e3) && !e.Ci(n.ownerId)) {
- if (e.Ri(n) && e.networkEnabled) return !0;
- if (!e.Ri(n)) {
- if (!n.allowTabSynchronization)
-
-
-
-
-
-
-
-
-
-
-
- throw new Q(K.FAILED_PRECONDITION, Wu);
- return !1;
- }
- }
- return !(!e.networkEnabled || !e.inForeground) || Xu(t).j().next((function(t) {
- return void 0 === e.Si(t, 5e3).find((function(t) {
- if (e.clientId !== t.clientId) {
- var n = !e.networkEnabled && t.networkEnabled, r = !e.inForeground && t.inForeground, i = e.networkEnabled === t.networkEnabled;
- if (n || r && i) return !0;
- }
- return !1;
- }));
- }));
- })).next((function(t) {
- return e.isPrimary !== t && M("IndexedDbPersistence", "Client ".concat(t ? "is" : "is not", " eligible for a primary lease.")),
- t;
- }));
- }, t.prototype.shutdown = function() {
- return e(this, void 0, void 0, (function() {
- var t = this;
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
-
-
-
-
- return this.Fs = !1, this.xi(), this.hi && (this.hi.cancel(), this.hi = null), this.Ni(),
- this.ki(), [ 4 , this.wi.runTransaction("shutdown", "readwrite", [ "owner", "clientMetadata" ], (function(e) {
- var n = new ge(e, Ut.ct);
- return t.Ai(n).next((function() {
- return t.Pi(n);
- }));
- })) ];
- case 1:
-
-
-
-
- return e.sent(), this.wi.close(),
-
-
- this.Mi(), [ 2 ];
- }
- }));
- }));
- },
-
- t.prototype.Si = function(t, e) {
- var n = this;
- return t.filter((function(t) {
- return n.Vi(t.updateTimeMs, e) && !n.Ci(t.clientId);
- }));
- },
-
- t.prototype.$i = function() {
- var t = this;
- return this.runTransaction("getActiveClients", "readonly", (function(e) {
- return Xu(e).j().next((function(e) {
- return t.Si(e, 18e5).map((function(t) {
- return t.clientId;
- }));
- }));
- }));
- }, Object.defineProperty(t.prototype, "started", {
- get: function() {
- return this.Fs;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.getMutationQueue = function(t, e) {
- return ou.de(t, this.serializer, e, this.referenceDelegate);
- }, t.prototype.getTargetCache = function() {
- return this.Bs;
- }, t.prototype.getRemoteDocumentCache = function() {
- return this.remoteDocumentCache;
- }, t.prototype.getIndexManager = function(t) {
- return new Yo(t, this.serializer.fe.databaseId);
- }, t.prototype.getDocumentOverlayCache = function(t) {
- return So.de(this.serializer, t);
- }, t.prototype.getBundleCache = function() {
- return this.qs;
- }, t.prototype.runTransaction = function(t, e, n) {
- var r = this;
- M("IndexedDbPersistence", "Starting transaction:", t);
- var i, o, u = "readonly" === e ? "readonly" : "readwrite", a = 15 === (i = this.ui) ? ye : 14 === i ? me : 13 === i ? ve : 12 === i ? pe : 11 === i ? de : void U();
-
-
-
- return this.wi.runTransaction(t, u, a, (function(i) {
- return o = new ge(i, r.Os ? r.Os.next() : Ut.ct), "readwrite-primary" === e ? r.Ti(o).next((function(t) {
- return !!t || r.Ei(o);
- })).next((function(e) {
- if (!e) throw L("Failed to obtain primary lease for action '".concat(t, "'.")),
- r.isPrimary = !1, r.ii.enqueueRetryable((function() {
- return r.fi(!1);
- })), new Q(K.FAILED_PRECONDITION, Dt);
- return n(o);
- })).next((function(t) {
- return r.vi(o).next((function() {
- return t;
- }));
- })) : r.Oi(o).next((function() {
- return n(o);
- }));
- })).then((function(t) {
- return o.raiseOnCommittedEvent(), t;
- }));
- },
-
-
-
- t.prototype.Oi = function(t) {
- var e = this;
- return Yu(t).get("owner").next((function(t) {
- if (null !== t && e.Vi(t.leaseTimestampMs, 5e3) && !e.Ci(t.ownerId) && !e.Ri(t) && !(e.oi || e.allowTabSynchronization && t.allowTabSynchronization)) throw new Q(K.FAILED_PRECONDITION, Wu);
- }));
- },
-
- t.prototype.vi = function(t) {
- var e = {
- ownerId: this.clientId,
- allowTabSynchronization: this.allowTabSynchronization,
- leaseTimestampMs: Date.now()
- };
- return Yu(t).put("owner", e);
- }, t.D = function() {
- return kt.D();
- },
- t.prototype.Ai = function(t) {
- var e = this, n = Yu(t);
- return n.get("owner").next((function(t) {
- return e.Ri(t) ? (M("IndexedDbPersistence", "Releasing primary lease."), n.delete("owner")) : Nt.resolve();
- }));
- },
- t.prototype.Vi = function(t, e) {
- var n = Date.now();
- return !(t < n - e || t > n && (L("Detected an update time that is in the future: ".concat(t, " > ").concat(n)),
- 1));
- }, t.prototype.gi = function() {
- var t = this;
- null !== this.document && "function" == typeof this.document.addEventListener && (this.ai = function() {
- t.ii.enqueueAndForget((function() {
- return t.inForeground = "visible" === t.document.visibilityState, t.mi();
- }));
- }, this.document.addEventListener("visibilitychange", this.ai), this.inForeground = "visible" === this.document.visibilityState);
- }, t.prototype.Ni = function() {
- this.ai && (this.document.removeEventListener("visibilitychange", this.ai), this.ai = null);
- },
-
- t.prototype.yi = function() {
- var t, e = this;
- "function" == typeof (null === (t = this.window) || void 0 === t ? void 0 : t.addEventListener) && (this.ci = function() {
-
-
-
- e.xi();
- var t = /(?:Version|Mobile)\/1[456]/;
- p() && (navigator.appVersion.match(t) || navigator.userAgent.match(t)) &&
-
-
-
-
- e.ii.enterRestrictedMode( !0), e.ii.enqueueAndForget((function() {
- return e.shutdown();
- }));
- }, this.window.addEventListener("pagehide", this.ci));
- }, t.prototype.ki = function() {
- this.ci && (this.window.removeEventListener("pagehide", this.ci), this.ci = null);
- },
-
- t.prototype.Ci = function(t) {
- var e;
- try {
- var n = null !== (null === (e = this._i) || void 0 === e ? void 0 : e.getItem(this.Di(t)));
- return M("IndexedDbPersistence", "Client '".concat(t, "' ").concat(n ? "is" : "is not", " zombied in LocalStorage")),
- n;
- } catch (t) {
-
- return L("IndexedDbPersistence", "Failed to get zombied client id.", t), !1;
- }
- },
-
- t.prototype.xi = function() {
- if (this._i) try {
- this._i.setItem(this.Di(this.clientId), String(Date.now()));
- } catch (t) {
-
- L("Failed to set zombie client id.", t);
- }
- },
- t.prototype.Mi = function() {
- if (this._i) try {
- this._i.removeItem(this.Di(this.clientId));
- } catch (t) {
-
- }
- }, t.prototype.Di = function(t) {
- return "firestore_zombie_".concat(this.persistenceKey, "_").concat(t);
- }, t;
- }();
- function Yu(t) {
- return we(t, "owner");
- }
- function Xu(t) {
- return we(t, "clientMetadata");
- }
- function Ju(t, e) {
-
-
-
-
-
- var n = t.projectId;
- return t.isDefaultDatabase || (n += "." + t.database), "firestore/" + e + "/" + n + "/"
-
-
- ;
- }
- var Zu = function() {
- function t(t, e, n, r) {
- this.targetId = t, this.fromCache = e, this.Fi = n, this.Bi = r;
- }
- return t.Li = function(e, n) {
- for (var r = Ir(), i = Ir(), o = 0, u = n.docChanges; o < u.length; o++) {
- var a = u[o];
- switch (a.type) {
- case 0 :
- r = r.add(a.doc.key);
- break;
- case 1 :
- i = i.add(a.doc.key);
-
- }
- }
- return new t(e, n.fromCache, r, i);
- }, t;
- }(), $u = function() {
- function t() {
- this.qi = !1;
- }
- return t.prototype.initialize = function(t, e) {
- this.Ui = t, this.indexManager = e, this.qi = !0;
- },
- t.prototype.getDocumentsMatchingQuery = function(t, e, n, r) {
- var i = this;
- return this.Ki(t, e).next((function(o) {
- return o || i.Gi(t, e, r, n);
- })).next((function(n) {
- return n || i.Qi(t, e);
- }));
- },
-
- t.prototype.Ki = function(t, e) {
- var n = this;
- if (Yn(e))
-
-
-
- return Nt.resolve(null);
- var r = tr(e);
- return this.indexManager.getIndexType(t, r).next((function(i) {
- return 0 === i ? null : (null !== e.limit && 1 === i && (
-
-
-
-
-
-
-
- e = nr(e, null, "F" ), r = tr(e)), n.indexManager.getDocumentsMatchingTarget(t, r).next((function(i) {
- var o = Ir.apply(void 0, i);
- return n.Ui.getDocuments(t, o).next((function(i) {
- return n.indexManager.getMinOffset(t, r).next((function(r) {
- var u = n.ji(e, i);
- return n.zi(e, u, o, r.readTime) ? n.Ki(t, nr(e, null, "F" )) : n.Wi(t, u, e, r);
- }));
- }));
- })));
- }));
- },
-
- t.prototype.Gi = function(t, e, n, r) {
- var i = this;
- return Yn(e) || r.isEqual(ct.min()) ? this.Qi(t, e) : this.Ui.getDocuments(t, n).next((function(o) {
- var u = i.ji(e, o);
- return i.zi(e, u, n, r) ? i.Qi(t, e) : (R() <= h.DEBUG && M("QueryEngine", "Re-using previous result from %s to execute query: %s", r.toString(), or(e)),
- i.Wi(t, u, e, Et(r, -1)));
- }));
-
-
- },
- t.prototype.ji = function(t, e) {
-
-
- var n = new De(sr(t));
- return e.forEach((function(e, r) {
- ur(t, r) && (n = n.add(r));
- })), n;
- },
-
- t.prototype.zi = function(t, e, n, r) {
- if (null === t.limit)
-
- return !1;
- if (n.size !== e.size)
-
-
- return !0;
-
-
-
-
-
-
-
-
- var i = "F" === t.limitType ? e.last() : e.first();
- return !!i && (i.hasPendingWrites || i.version.compareTo(r) > 0);
- }, t.prototype.Qi = function(t, e) {
- return R() <= h.DEBUG && M("QueryEngine", "Using full collection scan to execute query:", or(e)),
- this.Ui.getDocumentsMatchingQuery(t, e, St.min());
- },
-
- t.prototype.Wi = function(t, e, n, r) {
-
- return this.Ui.getDocumentsMatchingQuery(t, n, r).next((function(t) {
-
- return e.forEach((function(e) {
- t = t.insert(e.key, e);
- })), t;
- }));
- }, t;
- }(), ta = function() {
- function t(
-
- t, e, n, r) {
- this.persistence = t, this.Hi = e, this.serializer = r,
-
- this.Ji = new Te(ot),
-
-
- this.Yi = new lr((function(t) {
- return Bn(t);
- }), Un),
-
- this.Xi = new Map, this.Zi = t.getRemoteDocumentCache(), this.Bs = t.getTargetCache(),
- this.qs = t.getBundleCache(), this.tr(n);
- }
- return t.prototype.tr = function(t) {
-
-
- this.documentOverlayCache = this.persistence.getDocumentOverlayCache(t), this.indexManager = this.persistence.getIndexManager(t),
- this.mutationQueue = this.persistence.getMutationQueue(t, this.indexManager), this.localDocuments = new Ou(this.Zi, this.mutationQueue, this.documentOverlayCache, this.indexManager),
- this.Zi.setIndexManager(this.indexManager), this.Hi.initialize(this.localDocuments, this.indexManager);
- }, t.prototype.collectGarbage = function(t) {
- var e = this;
- return this.persistence.runTransaction("Collect garbage", "readwrite-primary", (function(n) {
- return t.collect(n, e.Ji);
- }));
- }, t;
- }();
- function ea(
- t, e, n, r) {
- return new ta(t, e, n, r);
- }
- function na(t, r) {
- return e(this, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , (e = j(t)).persistence.runTransaction("Handle user change", "readonly", (function(t) {
-
-
- var n;
- return e.mutationQueue.getAllMutationBatches(t).next((function(i) {
- return n = i, e.tr(r), e.mutationQueue.getAllMutationBatches(t);
- })).next((function(r) {
- for (var i = [], o = [], u = Ir(), a = 0, s = n
-
- ; a < s.length; a++) {
- var c = s[a];
- i.push(c.batchId);
- for (var l = 0, h = c.mutations; l < h.length; l++) {
- var f = h[l];
- u = u.add(f.key);
- }
- }
- for (var d = 0, p = r; d < p.length; d++) {
- var v = p[d];
- o.push(v.batchId);
- for (var m = 0, y = v.mutations; m < y.length; m++) {
- var g = y[m];
- u = u.add(g.key);
- }
- }
-
-
- return e.localDocuments.getDocuments(t, u).next((function(t) {
- return {
- er: t,
- removedBatchIds: i,
- addedBatchIds: o
- };
- }));
- }));
- })) ];
- case 1:
- return [ 2 , n.sent() ];
- }
- }));
- }));
- }
- function ra(t, e) {
- var n = j(t);
- return n.persistence.runTransaction("Acknowledge batch", "readwrite-primary", (function(t) {
- var r = e.batch.keys(), i = n.Zi.newChangeBuffer({
- trackRemovals: !0
- });
- return function(t, e, n, r) {
- var i = n.batch, o = i.keys(), u = Nt.resolve();
- return o.forEach((function(t) {
- u = u.next((function() {
- return r.getEntry(e, t);
- })).next((function(e) {
- var o = n.docVersions.get(t);
- z(null !== o), e.version.compareTo(o) < 0 && (i.applyToRemoteDocument(e, n), e.isValidDocument() && (
-
-
-
- e.setReadTime(n.commitVersion), r.addEntry(e)));
- }));
- })), u.next((function() {
- return t.mutationQueue.removeMutationBatch(e, i);
- }));
- }(n, t, e, i).next((function() {
- return i.apply(t);
- })).next((function() {
- return n.mutationQueue.performConsistencyCheck(t);
- })).next((function() {
- return n.documentOverlayCache.removeOverlaysForBatchId(t, r, e.batch.batchId);
- })).next((function() {
- return n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(t, function(t) {
- for (var e = Ir(), n = 0; n < t.mutationResults.length; ++n) t.mutationResults[n].transformResults.length > 0 && (e = e.add(t.batch.mutations[n].key));
- return e;
- }(e));
- })).next((function() {
- return n.localDocuments.getDocuments(t, r);
- }));
- }));
- }
- function ia(t) {
- var e = j(t);
- return e.persistence.runTransaction("Get last remote snapshot version", "readonly", (function(t) {
- return e.Bs.getLastRemoteSnapshotVersion(t);
- }));
- }
- function oa(t, e) {
- var n = j(t), r = e.snapshotVersion, i = n.Ji;
- return n.persistence.runTransaction("Apply remote event", "readwrite-primary", (function(t) {
- var o = n.Zi.newChangeBuffer({
- trackRemovals: !0
- });
-
- i = n.Ji;
- var u = [];
- e.targetChanges.forEach((function(o, a) {
- var s = i.get(a);
- if (s) {
-
-
-
- u.push(n.Bs.removeMatchingKeys(t, o.removedDocuments, a).next((function() {
- return n.Bs.addMatchingKeys(t, o.addedDocuments, a);
- })));
- var c = s.withSequenceNumber(t.currentSequenceNumber);
- null !== e.targetMismatches.get(a) ? c = c.withResumeToken(Oe.EMPTY_BYTE_STRING, ct.min()).withLastLimboFreeSnapshotVersion(ct.min()) : o.resumeToken.approximateByteSize() > 0 && (c = c.withResumeToken(o.resumeToken, r)),
- i = i.insert(a, c),
-
-
-
- function(t, e, n) {
-
- return 0 === t.resumeToken.approximateByteSize() || (
-
-
-
-
-
- e.snapshotVersion.toMicroseconds() - t.snapshotVersion.toMicroseconds() >= 3e8 || n.addedDocuments.size + n.modifiedDocuments.size + n.removedDocuments.size > 0);
- }(s, c, o) && u.push(n.Bs.updateTargetData(t, c));
- }
- }));
- var a = fr(), s = Ir();
-
-
-
-
- if (e.documentUpdates.forEach((function(r) {
- e.resolvedLimboDocuments.has(r) && u.push(n.persistence.referenceDelegate.updateLimboDocument(t, r));
- })),
-
-
- u.push(ua(t, o, e.documentUpdates).next((function(t) {
- a = t.nr, s = t.sr;
- }))), !r.isEqual(ct.min())) {
- var c = n.Bs.getLastRemoteSnapshotVersion(t).next((function(e) {
- return n.Bs.setTargetsMetadata(t, t.currentSequenceNumber, r);
- }));
- u.push(c);
- }
- return Nt.waitFor(u).next((function() {
- return o.apply(t);
- })).next((function() {
- return n.localDocuments.getLocalViewOfDocuments(t, a, s);
- })).next((function() {
- return a;
- }));
- })).then((function(t) {
- return n.Ji = i, t;
- }));
- }
- function ua(t, e, n) {
- var r = Ir(), i = Ir();
- return n.forEach((function(t) {
- return r = r.add(t);
- })), e.getEntries(t, r).next((function(t) {
- var r = fr();
- return n.forEach((function(n, o) {
- var u = t.get(n);
-
- o.isFoundDocument() !== u.isFoundDocument() && (i = i.add(n)),
-
-
-
-
- o.isNoDocument() && o.version.isEqual(ct.min()) ? (
-
-
-
- e.removeEntry(n, o.readTime), r = r.insert(n, o)) : !u.isValidDocument() || o.version.compareTo(u.version) > 0 || 0 === o.version.compareTo(u.version) && u.hasPendingWrites ? (e.addEntry(o),
- r = r.insert(n, o)) : M("LocalStore", "Ignoring outdated watch update for ", n, ". Current version:", u.version, " Watch version:", o.version);
- })), {
- nr: r,
- sr: i
- };
- }))
-
- ;
- }
- function aa(t, e) {
- var n = j(t);
- return n.persistence.runTransaction("Get next mutation batch", "readonly", (function(t) {
- return void 0 === e && (e = -1), n.mutationQueue.getNextMutationBatchAfterBatchId(t, e);
- }));
- }
- function sa(t, e) {
- var n = j(t);
- return n.persistence.runTransaction("Allocate target", "readwrite", (function(t) {
- var r;
- return n.Bs.getTargetData(t, e).next((function(i) {
- return i ? (
-
-
-
- r = i, Nt.resolve(r)) : n.Bs.allocateTargetId(t).next((function(i) {
- return r = new ao(e, i, "TargetPurposeListen" , t.currentSequenceNumber),
- n.Bs.addTargetData(t, r).next((function() {
- return r;
- }));
- }));
- }));
- })).then((function(t) {
-
-
- var r = n.Ji.get(t.targetId);
- return (null === r || t.snapshotVersion.compareTo(r.snapshotVersion) > 0) && (n.Ji = n.Ji.insert(t.targetId, t),
- n.Yi.set(e, t.targetId)), t;
- }));
- }
- function ca(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var e, o, u, a;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- e = j(t), o = e.Ji.get(r), u = i ? "readwrite" : "readwrite-primary", n.label = 1;
- case 1:
- return n.trys.push([ 1, 4, , 5 ]), i ? [ 3 , 3 ] : [ 4 , e.persistence.runTransaction("Release target", u, (function(t) {
- return e.persistence.referenceDelegate.removeTarget(t, o);
- })) ];
- case 2:
- n.sent(), n.label = 3;
- case 3:
- return [ 3 , 5 ];
- case 4:
- if (!Pt(a = n.sent())) throw a;
-
-
-
-
-
- return M("LocalStore", "Failed to update sequence numbers for target ".concat(r, ": ").concat(a)),
- [ 3 , 5 ];
- case 5:
- return e.Ji = e.Ji.remove(r), e.Yi.delete(o.target), [ 2 ];
- }
- }));
- }));
- }
- function la(t, e, n) {
- var r = j(t), i = ct.min(), o = Ir();
- return r.persistence.runTransaction("Execute query", "readonly", (function(t) {
- return function(t, e, n) {
- var r = j(t), i = r.Yi.get(n);
- return void 0 !== i ? Nt.resolve(r.Ji.get(i)) : r.Bs.getTargetData(e, n);
- }(r, t, tr(e)).next((function(e) {
- if (e) return i = e.lastLimboFreeSnapshotVersion, r.Bs.getMatchingKeysForTargetId(t, e.targetId).next((function(t) {
- o = t;
- }));
- })).next((function() {
- return r.Hi.getDocumentsMatchingQuery(t, e, n ? i : ct.min(), n ? o : Ir());
- })).next((function(t) {
- return da(r, ar(e), t), {
- documents: t,
- ir: o
- };
- }));
- }));
- }
- function ha(t, e) {
- var n = j(t), r = j(n.Bs), i = n.Ji.get(e);
- return i ? Promise.resolve(i.target) : n.persistence.runTransaction("Get target data", "readonly", (function(t) {
- return r.le(t, e).next((function(t) {
- return t ? t.target : null;
- }));
- }));
- }
- function fa(t, e) {
- var n = j(t), r = n.Xi.get(e) || ct.min();
-
-
-
-
- return n.persistence.runTransaction("Get new document changes", "readonly", (function(t) {
- return n.Zi.getAllFromCollectionGroup(t, e, Et(r, -1),
- Number.MAX_SAFE_INTEGER);
- })).then((function(t) {
- return da(n, e, t), t;
- }));
- }
- function da(t, e, n) {
- var r = t.Xi.get(e) || ct.min();
- n.forEach((function(t, e) {
- e.readTime.compareTo(r) > 0 && (r = e.readTime);
- })), t.Xi.set(e, r);
- }
- function pa(t, r, i, o) {
- return e(this, void 0, void 0, (function() {
- var e, u, a, s, c, l, h, f, d, p;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- for (e = j(t), u = Ir(), a = fr(), s = 0, c = i; s < c.length; s++) l = c[s], h = r.rr(l.metadata.name),
- l.document && (u = u.add(h)), (f = r.ur(l)).setReadTime(r.cr(l.metadata.readTime)),
- a = a.insert(h, f);
- return d = e.Zi.newChangeBuffer({
- trackRemovals: !0
- }), [ 4 , sa(e, function(t) {
-
-
- return tr(Hn(ht.fromString("__bundle__/docs/".concat(t))));
- }(o)) ];
- case 1:
-
-
- return p = n.sent(), [ 2 , e.persistence.runTransaction("Apply bundle documents", "readwrite", (function(t) {
- return ua(t, d, a).next((function(e) {
- return d.apply(t), e;
- })).next((function(n) {
- return e.Bs.removeMatchingKeysForTargetId(t, p.targetId).next((function() {
- return e.Bs.addMatchingKeys(t, u, p.targetId);
- })).next((function() {
- return e.localDocuments.getLocalViewOfDocuments(t, n.nr, n.sr);
- })).next((function() {
- return n.nr;
- }));
- }));
- })) ];
- }
- }));
- }));
- }
- function va(t, r, i) {
- return void 0 === i && (i = Ir()), e(this, void 0, void 0, (function() {
- var e, o;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , sa(t, tr(yo(r.bundledQuery))) ];
- case 1:
- return e = n.sent(), [ 2 , (o = j(t)).persistence.runTransaction("Save named query", "readwrite", (function(t) {
- var n = Vi(r.readTime);
-
-
- if (e.snapshotVersion.compareTo(n) >= 0) return o.qs.saveNamedQuery(t, r);
-
- var u = e.withResumeToken(Oe.EMPTY_BYTE_STRING, n);
- return o.Ji = o.Ji.insert(u.targetId, u), o.Bs.updateTargetData(t, u).next((function() {
- return o.Bs.removeMatchingKeysForTargetId(t, e.targetId);
- })).next((function() {
- return o.Bs.addMatchingKeys(t, i, e.targetId);
- })).next((function() {
- return o.qs.saveNamedQuery(t, r);
- }));
- })) ];
- }
- }));
- }));
- }
- function ma(t, e) {
- return "firestore_clients_".concat(t, "_").concat(e);
- }
- function ya(t, e, n) {
- var r = "firestore_mutations_".concat(t, "_").concat(n);
- return e.isAuthenticated() && (r += "_".concat(e.uid)), r;
- }
- function ga(t, e) {
- return "firestore_targets_".concat(t, "_").concat(e);
- }
- var wa = function() {
- function t(t, e, n, r) {
- this.user = t, this.batchId = e, this.state = n, this.error = r
-
- ;
- }
- return t.ar = function(e, n, r) {
- var i, o = JSON.parse(r), u = "object" == typeof o && -1 !== [ "pending", "acknowledged", "rejected" ].indexOf(o.state) && (void 0 === o.error || "object" == typeof o.error);
- return u && o.error && ((u = "string" == typeof o.error.message && "string" == typeof o.error.code) && (i = new Q(o.error.code, o.error.message))),
- u ? new t(e, n, o.state, i) : (L("SharedClientState", "Failed to parse mutation state for ID '".concat(n, "': ").concat(r)),
- null);
- }, t.prototype.hr = function() {
- var t = {
- state: this.state,
- updateTimeMs: Date.now()
- };
- return this.error && (t.error = {
- code: this.error.code,
- message: this.error.message
- }), JSON.stringify(t);
- }, t;
- }(), ba = function() {
- function t(t, e, n) {
- this.targetId = t, this.state = e, this.error = n
-
- ;
- }
- return t.ar = function(e, n) {
- var r, i = JSON.parse(n), o = "object" == typeof i && -1 !== [ "not-current", "current", "rejected" ].indexOf(i.state) && (void 0 === i.error || "object" == typeof i.error);
- return o && i.error && ((o = "string" == typeof i.error.message && "string" == typeof i.error.code) && (r = new Q(i.error.code, i.error.message))),
- o ? new t(e, i.state, r) : (L("SharedClientState", "Failed to parse target state for ID '".concat(e, "': ").concat(n)),
- null);
- }, t.prototype.hr = function() {
- var t = {
- state: this.state,
- updateTimeMs: Date.now()
- };
- return this.error && (t.error = {
- code: this.error.code,
- message: this.error.message
- }), JSON.stringify(t);
- }, t;
- }(), Ia = function() {
- function t(t, e) {
- this.clientId = t, this.activeTargetIds = e
-
- ;
- }
- return t.ar = function(e, n) {
- for (var r = JSON.parse(n), i = "object" == typeof r && r.activeTargetIds instanceof Array, o = Tr(), u = 0; i && u < r.activeTargetIds.length; ++u) i = jt(r.activeTargetIds[u]),
- o = o.add(r.activeTargetIds[u]);
- return i ? new t(e, o) : (L("SharedClientState", "Failed to parse client data for instance '".concat(e, "': ").concat(n)),
- null);
- }, t;
- }(), Ea = function() {
- function t(t, e) {
- this.clientId = t, this.onlineState = e
-
- ;
- }
- return t.ar = function(e) {
- var n = JSON.parse(e);
- return "object" == typeof n && -1 !== [ "Unknown", "Online", "Offline" ].indexOf(n.onlineState) && "string" == typeof n.clientId ? new t(n.clientId, n.onlineState) : (L("SharedClientState", "Failed to parse online state: ".concat(e)),
- null);
- }, t;
- }(), Ta = function() {
- function t() {
- this.activeTargetIds = Tr();
- }
- return t.prototype.lr = function(t) {
- this.activeTargetIds = this.activeTargetIds.add(t);
- }, t.prototype.dr = function(t) {
- this.activeTargetIds = this.activeTargetIds.delete(t);
- },
-
- t.prototype.hr = function() {
- var t = {
- activeTargetIds: this.activeTargetIds.toArray(),
- updateTimeMs: Date.now()
- };
- return JSON.stringify(t);
- }, t;
- }(), Sa = function() {
- function t(t, e, n, r, i) {
- this.window = t, this.ii = e, this.persistenceKey = n, this.wr = r, this.syncEngine = null,
- this.onlineStateHandler = null, this.sequenceNumberHandler = null, this._r = this.mr.bind(this),
- this.gr = new Te(ot), this.started = !1,
-
- this.yr = [];
-
-
- var o = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
- this.storage = this.window.localStorage, this.currentUser = i, this.pr = ma(this.persistenceKey, this.wr),
- this.Ir =
-
- function(t) {
- return "firestore_sequence_number_".concat(t);
- }(this.persistenceKey), this.gr = this.gr.insert(this.wr, new Ta), this.Tr = new RegExp("^firestore_clients_".concat(o, "_([^_]*)$")),
- this.Er = new RegExp("^firestore_mutations_".concat(o, "_(\\d+)(?:_(.*))?$")), this.Ar = new RegExp("^firestore_targets_".concat(o, "_(\\d+)$")),
- this.vr =
-
- function(t) {
- return "firestore_online_state_".concat(t);
- }(this.persistenceKey), this.Rr = function(t) {
- return "firestore_bundle_loaded_v2_".concat(t);
- }(this.persistenceKey),
-
-
-
-
-
-
- this.window.addEventListener("storage", this._r);
- }
- return t.D = function(t) {
- return !(!t || !t.localStorage);
- }, t.prototype.start = function() {
- return e(this, void 0, void 0, (function() {
- var t, e, r, i, o, u, a, s, c, l, h, f = this;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , this.syncEngine.$i() ];
- case 1:
- for (t = n.sent(), e = 0, r = t; e < r.length; e++) (i = r[e]) !== this.wr && (o = this.getItem(ma(this.persistenceKey, i))) && (u = Ia.ar(i, o)) && (this.gr = this.gr.insert(u.clientId, u));
- for (this.Pr(), (a = this.storage.getItem(this.vr)) && (s = this.br(a)) && this.Vr(s),
- c = 0, l = this.yr; c < l.length; c++) h = l[c], this.mr(h);
- return this.yr = [],
-
-
- this.window.addEventListener("pagehide", (function() {
- return f.shutdown();
- })), this.started = !0, [ 2 ];
- }
- }));
- }));
- }, t.prototype.writeSequenceNumber = function(t) {
- this.setItem(this.Ir, JSON.stringify(t));
- }, t.prototype.getAllActiveQueryTargets = function() {
- return this.Sr(this.gr);
- }, t.prototype.isActiveQueryTarget = function(t) {
- var e = !1;
- return this.gr.forEach((function(n, r) {
- r.activeTargetIds.has(t) && (e = !0);
- })), e;
- }, t.prototype.addPendingMutation = function(t) {
- this.Dr(t, "pending");
- }, t.prototype.updateMutationState = function(t, e, n) {
- this.Dr(t, e, n),
-
-
-
- this.Cr(t);
- }, t.prototype.addLocalQueryTarget = function(t) {
- var e = "not-current";
-
-
- if (this.isActiveQueryTarget(t)) {
- var n = this.storage.getItem(ga(this.persistenceKey, t));
- if (n) {
- var r = ba.ar(t, n);
- r && (e = r.state);
- }
- }
- return this.Nr.lr(t), this.Pr(), e;
- }, t.prototype.removeLocalQueryTarget = function(t) {
- this.Nr.dr(t), this.Pr();
- }, t.prototype.isLocalQueryTarget = function(t) {
- return this.Nr.activeTargetIds.has(t);
- }, t.prototype.clearQueryState = function(t) {
- this.removeItem(ga(this.persistenceKey, t));
- }, t.prototype.updateQueryState = function(t, e, n) {
- this.kr(t, e, n);
- }, t.prototype.handleUserChange = function(t, e, n) {
- var r = this;
- e.forEach((function(t) {
- r.Cr(t);
- })), this.currentUser = t, n.forEach((function(t) {
- r.addPendingMutation(t);
- }));
- }, t.prototype.setOnlineState = function(t) {
- this.Mr(t);
- }, t.prototype.notifyBundleLoaded = function(t) {
- this.$r(t);
- }, t.prototype.shutdown = function() {
- this.started && (this.window.removeEventListener("storage", this._r), this.removeItem(this.pr),
- this.started = !1);
- }, t.prototype.getItem = function(t) {
- var e = this.storage.getItem(t);
- return M("SharedClientState", "READ", t, e), e;
- }, t.prototype.setItem = function(t, e) {
- M("SharedClientState", "SET", t, e), this.storage.setItem(t, e);
- }, t.prototype.removeItem = function(t) {
- M("SharedClientState", "REMOVE", t), this.storage.removeItem(t);
- }, t.prototype.mr = function(t) {
- var r = this, i = t;
-
-
- if (i.storageArea === this.storage) {
- if (M("SharedClientState", "EVENT", i.key, i.newValue), i.key === this.pr) return void L("Received WebStorage notification for local change. Another client might have garbage-collected our state");
- this.ii.enqueueRetryable((function() {
- return e(r, void 0, void 0, (function() {
- var t, e, r, o, u, a, s, c = this;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return this.started ? null === i.key ? [ 3 , 7 ] : this.Tr.test(i.key) ? null == i.newValue ? (t = this.Or(i.key),
- [ 2 , this.Fr(t, null) ]) : (e = this.Br(i.key, i.newValue)) ? [ 2 , this.Fr(e.clientId, e) ] : [ 3 , 7 ] : [ 3 , 1 ] : [ 3 , 8 ];
- case 1:
- return this.Er.test(i.key) ? null !== i.newValue && (r = this.Lr(i.key, i.newValue)) ? [ 2 , this.qr(r) ] : [ 3 , 7 ] : [ 3 , 2 ];
- case 2:
- return this.Ar.test(i.key) ? null !== i.newValue && (o = this.Ur(i.key, i.newValue)) ? [ 2 , this.Kr(o) ] : [ 3 , 7 ] : [ 3 , 3 ];
- case 3:
- return i.key !== this.vr ? [ 3 , 4 ] : null !== i.newValue && (u = this.br(i.newValue)) ? [ 2 , this.Vr(u) ] : [ 3 , 7 ];
- case 4:
- return i.key !== this.Ir ? [ 3 , 5 ] : (a = function(t) {
- var e = Ut.ct;
- if (null != t) try {
- var n = JSON.parse(t);
- z("number" == typeof n), e = n;
- } catch (t) {
- L("SharedClientState", "Failed to read sequence number from WebStorage", t);
- }
- return e;
- }(i.newValue), a !== Ut.ct && this.sequenceNumberHandler(a), [ 3 , 7 ]);
- case 5:
- return i.key !== this.Rr ? [ 3 , 7 ] : (s = this.Gr(i.newValue), [ 4 , Promise.all(s.map((function(t) {
- return c.syncEngine.Qr(t);
- }))) ]);
- case 6:
- n.sent(), n.label = 7;
- case 7:
- return [ 3 , 9 ];
- case 8:
- this.yr.push(i), n.label = 9;
- case 9:
- return [ 2 ];
- }
- }));
- }));
- }));
- }
- }, Object.defineProperty(t.prototype, "Nr", {
- get: function() {
- return this.gr.get(this.wr);
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.Pr = function() {
- this.setItem(this.pr, this.Nr.hr());
- }, t.prototype.Dr = function(t, e, n) {
- var r = new wa(this.currentUser, t, e, n), i = ya(this.persistenceKey, this.currentUser, t);
- this.setItem(i, r.hr());
- }, t.prototype.Cr = function(t) {
- var e = ya(this.persistenceKey, this.currentUser, t);
- this.removeItem(e);
- }, t.prototype.Mr = function(t) {
- var e = {
- clientId: this.wr,
- onlineState: t
- };
- this.storage.setItem(this.vr, JSON.stringify(e));
- }, t.prototype.kr = function(t, e, n) {
- var r = ga(this.persistenceKey, t), i = new ba(t, e, n);
- this.setItem(r, i.hr());
- }, t.prototype.$r = function(t) {
- var e = JSON.stringify(Array.from(t));
- this.setItem(this.Rr, e);
- },
-
- t.prototype.Or = function(t) {
- var e = this.Tr.exec(t);
- return e ? e[1] : null;
- },
-
- t.prototype.Br = function(t, e) {
- var n = this.Or(t);
- return Ia.ar(n, e);
- },
-
- t.prototype.Lr = function(t, e) {
- var n = this.Er.exec(t), r = Number(n[1]), i = void 0 !== n[2] ? n[2] : null;
- return wa.ar(new O(i), r, e);
- },
-
- t.prototype.Ur = function(t, e) {
- var n = this.Ar.exec(t), r = Number(n[1]);
- return ba.ar(r, e);
- },
-
- t.prototype.br = function(t) {
- return Ea.ar(t);
- }, t.prototype.Gr = function(t) {
- return JSON.parse(t);
- }, t.prototype.qr = function(t) {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(e) {
- return t.user.uid === this.currentUser.uid ? [ 2 , this.syncEngine.jr(t.batchId, t.state, t.error) ] : (M("SharedClientState", "Ignoring mutation for non-active user ".concat(t.user.uid)),
- [ 2 ]);
- }));
- }));
- }, t.prototype.Kr = function(t) {
- return this.syncEngine.zr(t.targetId, t.state, t.error);
- }, t.prototype.Fr = function(t, e) {
- var n = this, r = e ? this.gr.insert(t, e) : this.gr.remove(t), i = this.Sr(this.gr), o = this.Sr(r), u = [], a = [];
- return o.forEach((function(t) {
- i.has(t) || u.push(t);
- })), i.forEach((function(t) {
- o.has(t) || a.push(t);
- })), this.syncEngine.Wr(u, a).then((function() {
- n.gr = r;
- }));
- }, t.prototype.Vr = function(t) {
-
-
-
-
-
- this.gr.get(t.clientId) && this.onlineStateHandler(t.onlineState);
- }, t.prototype.Sr = function(t) {
- var e = Tr();
- return t.forEach((function(t, n) {
- e = e.unionWith(n.activeTargetIds);
- })), e;
- }, t;
- }(), _a = function() {
- function t() {
- this.Hr = new Ta, this.Jr = {}, this.onlineStateHandler = null, this.sequenceNumberHandler = null;
- }
- return t.prototype.addPendingMutation = function(t) {
-
- }, t.prototype.updateMutationState = function(t, e, n) {
-
- }, t.prototype.addLocalQueryTarget = function(t) {
- return this.Hr.lr(t), this.Jr[t] || "not-current";
- }, t.prototype.updateQueryState = function(t, e, n) {
- this.Jr[t] = e;
- }, t.prototype.removeLocalQueryTarget = function(t) {
- this.Hr.dr(t);
- }, t.prototype.isLocalQueryTarget = function(t) {
- return this.Hr.activeTargetIds.has(t);
- }, t.prototype.clearQueryState = function(t) {
- delete this.Jr[t];
- }, t.prototype.getAllActiveQueryTargets = function() {
- return this.Hr.activeTargetIds;
- }, t.prototype.isActiveQueryTarget = function(t) {
- return this.Hr.activeTargetIds.has(t);
- }, t.prototype.start = function() {
- return this.Hr = new Ta, Promise.resolve();
- }, t.prototype.handleUserChange = function(t, e, n) {
-
- }, t.prototype.setOnlineState = function(t) {
-
- }, t.prototype.shutdown = function() {}, t.prototype.writeSequenceNumber = function(t) {},
- t.prototype.notifyBundleLoaded = function(t) {
-
- }, t;
- }(), Da = function() {
- function t() {}
- return t.prototype.Yr = function(t) {
-
- }, t.prototype.shutdown = function() {
-
- }, t;
- }(), Ca = function() {
- function t() {
- var t = this;
- this.Xr = function() {
- return t.Zr();
- }, this.eo = function() {
- return t.no();
- }, this.so = [], this.io();
- }
- return t.prototype.Yr = function(t) {
- this.so.push(t);
- }, t.prototype.shutdown = function() {
- window.removeEventListener("online", this.Xr), window.removeEventListener("offline", this.eo);
- }, t.prototype.io = function() {
- window.addEventListener("online", this.Xr), window.addEventListener("offline", this.eo);
- }, t.prototype.Zr = function() {
- M("ConnectivityMonitor", "Network connectivity changed: AVAILABLE");
- for (var t = 0, e = this.so; t < e.length; t++) {
- (0, e[t])(0 );
- }
- }, t.prototype.no = function() {
- M("ConnectivityMonitor", "Network connectivity changed: UNAVAILABLE");
- for (var t = 0, e = this.so; t < e.length; t++) {
- (0, e[t])(1 );
- }
- },
-
-
-
- t.D = function() {
- return "undefined" != typeof window && void 0 !== window.addEventListener && void 0 !== window.removeEventListener;
- }, t;
- }(), xa = null;
- function Na() {
- return null === xa ? xa = 268435456 + Math.round(2147483648 * Math.random()) : xa++,
- "0x" + xa.toString(16)
-
- ;
- }
- var Aa = {
- BatchGetDocuments: "batchGet",
- Commit: "commit",
- RunQuery: "runQuery",
- RunAggregationQuery: "runAggregationQuery"
- }, ka = function() {
- function t(t) {
- this.ro = t.ro, this.oo = t.oo;
- }
- return t.prototype.uo = function(t) {
- this.co = t;
- }, t.prototype.ao = function(t) {
- this.ho = t;
- }, t.prototype.onMessage = function(t) {
- this.lo = t;
- }, t.prototype.close = function() {
- this.oo();
- }, t.prototype.send = function(t) {
- this.ro(t);
- }, t.prototype.fo = function() {
- this.co();
- }, t.prototype.wo = function(t) {
- this.ho(t);
- }, t.prototype._o = function(t) {
- this.lo(t);
- }, t;
- }(), Oa = "WebChannelConnection", Fa = function(e) {
- function n(t) {
- var n = this;
- return (n = e.call(this, t) || this).forceLongPolling = t.forceLongPolling, n.autoDetectLongPolling = t.autoDetectLongPolling,
- n.useFetchStreams = t.useFetchStreams, n.longPollingOptions = t.longPollingOptions,
- n;
- }
-
- return t(n, e), n.prototype.Ao = function(t, e, n, r) {
- var i = Na();
- return new Promise((function(o, u) {
- var a = new I;
- a.setWithCredentials(!0), a.listenOnce(E.COMPLETE, (function() {
- try {
- switch (a.getLastErrorCode()) {
- case T.NO_ERROR:
- var e = a.getResponseJson();
- M(Oa, "XHR for RPC '".concat(t, "' ").concat(i, " received:"), JSON.stringify(e)),
- o(e);
- break;
- case T.TIMEOUT:
- M(Oa, "RPC '".concat(t, "' ").concat(i, " timed out")), u(new Q(K.DEADLINE_EXCEEDED, "Request time out"));
- break;
- case T.HTTP_ERROR:
- var n = a.getStatus();
- if (M(Oa, "RPC '".concat(t, "' ").concat(i, " failed with status:"), n, "response text:", a.getResponseText()),
- n > 0) {
- var r = a.getResponseJson();
- Array.isArray(r) && (r = r[0]);
- var s = null == r ? void 0 : r.error;
- if (s && s.status && s.message) {
- var c = function(t) {
- var e = t.toLowerCase().replace(/_/g, "-");
- return Object.values(K).indexOf(e) >= 0 ? e : K.UNKNOWN;
- }(s.status);
- u(new Q(c, s.message));
- } else u(new Q(K.UNKNOWN, "Server responded with status " + a.getStatus()));
- } else
-
-
- u(new Q(K.UNAVAILABLE, "Connection failed."));
- break;
- default:
- U();
- }
- } finally {
- M(Oa, "RPC '".concat(t, "' ").concat(i, " completed."));
- }
- }));
- var s = JSON.stringify(r);
- M(Oa, "RPC '".concat(t, "' ").concat(i, " sending request:"), r), a.send(e, "POST", s, n, 15);
- }));
- }, n.prototype.Ro = function(t, e, n) {
- var r = Na(), i = [ this.mo, "/", "google.firestore.v1.Firestore", "/", t, "/channel" ], o = S(), u = _(), a = {
-
-
- httpSessionIdParam: "gsessionid",
- initMessageHeaders: {},
- messageUrlParams: {
-
-
- database: "projects/".concat(this.databaseId.projectId, "/databases/").concat(this.databaseId.database)
- },
- sendRawJson: !0,
- supportsCrossDomainXhr: !0,
- internalChannelParams: {
-
-
-
-
-
-
- forwardChannelRequestTimeoutMs: 6e5
- },
- forceLongPolling: this.forceLongPolling,
- detectBufferingProxy: this.autoDetectLongPolling
- }, s = this.longPollingOptions.timeoutSeconds;
- void 0 !== s && (a.longPollingTimeout = Math.round(1e3 * s)), this.useFetchStreams && (a.xmlHttpFactory = new D({})),
- this.Eo(a.initMessageHeaders, e, n),
-
-
-
-
-
-
-
-
-
- a.encodeInitMessageHeaders = !0;
- var c = i.join("");
- M(Oa, "Creating RPC '".concat(t, "' stream ").concat(r, ": ").concat(c), a);
- var l = o.createWebChannel(c, a), h = !1, f = !1, d = new ka({
- ro: function(e) {
- f ? M(Oa, "Not sending because RPC '".concat(t, "' stream ").concat(r, " is closed:"), e) : (h || (M(Oa, "Opening RPC '".concat(t, "' stream ").concat(r, " transport.")),
- l.open(), h = !0), M(Oa, "RPC '".concat(t, "' stream ").concat(r, " sending:"), e),
- l.send(e));
- },
- oo: function() {
- return l.close();
- }
- }), p = function(t, e, n) {
-
-
- t.listen(e, (function(t) {
- try {
- n(t);
- } catch (t) {
- setTimeout((function() {
- throw t;
- }), 0);
- }
- }));
- };
-
-
-
-
-
-
-
-
-
- return p(l, C.EventType.OPEN, (function() {
- f || M(Oa, "RPC '".concat(t, "' stream ").concat(r, " transport opened."));
- })), p(l, C.EventType.CLOSE, (function() {
- f || (f = !0, M(Oa, "RPC '".concat(t, "' stream ").concat(r, " transport closed")),
- d.wo());
- })), p(l, C.EventType.ERROR, (function(e) {
- f || (f = !0, q(Oa, "RPC '".concat(t, "' stream ").concat(r, " transport errored:"), e),
- d.wo(new Q(K.UNAVAILABLE, "The operation could not be completed")));
- })), p(l, C.EventType.MESSAGE, (function(e) {
- var n;
- if (!f) {
- var i = e.data[0];
- z(!!i);
-
-
-
-
-
- var o = i, u = o.error || (null === (n = o[0]) || void 0 === n ? void 0 : n.error);
- if (u) {
- M(Oa, "RPC '".concat(t, "' stream ").concat(r, " received error:"), u);
-
- var a = u.status, s =
-
- function(t) {
-
-
- var e = ti[t];
- if (void 0 !== e) return li(e);
- }(a), c = u.message;
- void 0 === s && (s = K.INTERNAL, c = "Unknown error status: " + a + " with message " + u.message),
-
- f = !0, d.wo(new Q(s, c)), l.close();
- } else M(Oa, "RPC '".concat(t, "' stream ").concat(r, " received:"), i), d._o(i);
- }
- })), p(u, x.STAT_EVENT, (function(e) {
- e.stat === N.PROXY ? M(Oa, "RPC '".concat(t, "' stream ").concat(r, " detected buffering proxy")) : e.stat === N.NOPROXY && M(Oa, "RPC '".concat(t, "' stream ").concat(r, " detected no buffering proxy"));
- })), setTimeout((function() {
-
-
-
-
- d.fo();
- }), 0), d;
- }, n;
- }( function() {
- function t(t) {
- this.databaseInfo = t, this.databaseId = t.databaseId;
- var e = t.ssl ? "https" : "http";
- this.mo = e + "://" + t.host, this.yo = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
- }
- return Object.defineProperty(t.prototype, "po", {
- get: function() {
-
-
- return !1;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.Io = function(t, e, n, r, i) {
- var o = Na(), u = this.To(t, e);
- M("RestConnection", "Sending RPC '".concat(t, "' ").concat(o, ":"), u, n);
- var a = {};
- return this.Eo(a, r, i), this.Ao(t, u, a, n).then((function(e) {
- return M("RestConnection", "Received RPC '".concat(t, "' ").concat(o, ": "), e),
- e;
- }), (function(e) {
- throw q("RestConnection", "RPC '".concat(t, "' ").concat(o, " failed with error: "), e, "url: ", u, "request:", n),
- e;
- }));
- }, t.prototype.vo = function(t, e, n, r, i, o) {
-
-
- return this.Io(t, e, n, r, i);
- },
-
- t.prototype.Eo = function(t, e, n) {
- t["X-Goog-Api-Client"] = "gl-js/ fire/" + F,
-
-
-
-
- t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
- e && e.headers.forEach((function(e, n) {
- return t[n] = e;
- })), n && n.headers.forEach((function(e, n) {
- return t[n] = e;
- }));
- }, t.prototype.To = function(t, e) {
- var n = Aa[t];
- return "".concat(this.mo, "/v1/").concat(e, ":").concat(n);
- }, t;
- }());
- function Pa() {
-
-
- return "undefined" != typeof window ? window : null;
- }
- function Ra() {
-
-
- return "undefined" != typeof document ? document : null;
- }
- function Va(t) {
- return new ki(t, !0);
- }
- var Ma = function() {
- function t(
-
- t,
-
- e,
-
- n
-
- , r
-
- , i) {
- void 0 === n && (n = 1e3), void 0 === r && (r = 1.5), void 0 === i && (i = 6e4),
- this.ii = t, this.timerId = e, this.Po = n, this.bo = r, this.Vo = i, this.So = 0,
- this.Do = null,
-
- this.Co = Date.now(), this.reset();
- }
-
- return t.prototype.reset = function() {
- this.So = 0;
- },
-
- t.prototype.xo = function() {
- this.So = this.Vo;
- },
-
- t.prototype.No = function(t) {
- var e = this;
-
- this.cancel();
-
-
- var n = Math.floor(this.So + this.ko()), r = Math.max(0, Date.now() - this.Co), i = Math.max(0, n - r);
-
- i > 0 && M("ExponentialBackoff", "Backing off for ".concat(i, " ms (base delay: ").concat(this.So, " ms, delay with jitter: ").concat(n, " ms, last attempt: ").concat(r, " ms ago)")),
- this.Do = this.ii.enqueueAfterDelay(this.timerId, i, (function() {
- return e.Co = Date.now(), t();
- })),
-
-
- this.So *= this.bo, this.So < this.Po && (this.So = this.Po), this.So > this.Vo && (this.So = this.Vo);
- }, t.prototype.Mo = function() {
- null !== this.Do && (this.Do.skipDelay(), this.Do = null);
- }, t.prototype.cancel = function() {
- null !== this.Do && (this.Do.cancel(), this.Do = null);
- },
- t.prototype.ko = function() {
- return (Math.random() - .5) * this.So;
- }, t;
- }(), La = function() {
- function t(t, e, n, r, i, o, u, a) {
- this.ii = t, this.$o = n, this.Oo = r, this.connection = i, this.authCredentialsProvider = o,
- this.appCheckCredentialsProvider = u, this.listener = a, this.state = 0 ,
-
- this.Fo = 0, this.Bo = null, this.Lo = null, this.stream = null, this.qo = new Ma(t, e)
-
- ;
- }
- return t.prototype.Uo = function() {
- return 1 === this.state || 5 === this.state || this.Ko();
- },
-
- t.prototype.Ko = function() {
- return 2 === this.state || 3 === this.state;
- },
-
- t.prototype.start = function() {
- 4 !== this.state ? this.auth() : this.Go();
- },
-
- t.prototype.stop = function() {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(t) {
- switch (t.label) {
- case 0:
- return this.Uo() ? [ 4 , this.close(0 ) ] : [ 3 , 2 ];
- case 1:
- t.sent(), t.label = 2;
- case 2:
- return [ 2 ];
- }
- }));
- }));
- },
-
- t.prototype.Qo = function() {
- this.state = 0 , this.qo.reset();
- },
-
- t.prototype.jo = function() {
- var t = this;
-
-
- this.Ko() && null === this.Bo && (this.Bo = this.ii.enqueueAfterDelay(this.$o, 6e4, (function() {
- return t.zo();
- })));
- },
- t.prototype.Wo = function(t) {
- this.Ho(), this.stream.send(t);
- },
- t.prototype.zo = function() {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(t) {
- return this.Ko() ? [ 2 , this.close(0 ) ] : [ 2 ];
- }));
- }));
- },
- t.prototype.Ho = function() {
- this.Bo && (this.Bo.cancel(), this.Bo = null);
- },
- t.prototype.Jo = function() {
- this.Lo && (this.Lo.cancel(), this.Lo = null);
- },
-
- t.prototype.close = function(t, r) {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
-
-
- return this.Ho(), this.Jo(), this.qo.cancel(),
-
-
- this.Fo++, 4 !== t ?
-
- this.qo.reset() : r && r.code === K.RESOURCE_EXHAUSTED ? (
-
- L(r.toString()), L("Using maximum backoff delay to prevent overloading the backend."),
- this.qo.xo()) : r && r.code === K.UNAUTHENTICATED && 3 !== this.state && (
-
-
-
-
-
-
- this.authCredentialsProvider.invalidateToken(), this.appCheckCredentialsProvider.invalidateToken()),
-
- null !== this.stream && (this.Yo(), this.stream.close(), this.stream = null),
-
-
- this.state = t, [ 4 , this.listener.ao(r) ];
- case 1:
-
-
- return e.sent(), [ 2 ];
- }
- }));
- }));
- },
-
- t.prototype.Yo = function() {}, t.prototype.auth = function() {
- var t = this;
- this.state = 1 ;
- var e = this.Xo(this.Fo), n = this.Fo;
-
- Promise.all([ this.authCredentialsProvider.getToken(), this.appCheckCredentialsProvider.getToken() ]).then((function(e) {
- var r = e[0], i = e[1];
-
-
-
-
- t.Fo === n &&
-
-
-
- t.Zo(r, i);
- }), (function(n) {
- e((function() {
- var e = new Q(K.UNKNOWN, "Fetching auth token failed: " + n.message);
- return t.tu(e);
- }));
- }));
- }, t.prototype.Zo = function(t, e) {
- var n = this, r = this.Xo(this.Fo);
- this.stream = this.eu(t, e), this.stream.uo((function() {
- r((function() {
- return n.state = 2 , n.Lo = n.ii.enqueueAfterDelay(n.Oo, 1e4, (function() {
- return n.Ko() && (n.state = 3 ), Promise.resolve();
- })), n.listener.uo();
- }));
- })), this.stream.ao((function(t) {
- r((function() {
- return n.tu(t);
- }));
- })), this.stream.onMessage((function(t) {
- r((function() {
- return n.onMessage(t);
- }));
- }));
- }, t.prototype.Go = function() {
- var t = this;
- this.state = 5 , this.qo.No((function() {
- return e(t, void 0, void 0, (function() {
- return n(this, (function(t) {
- return this.state = 0 , this.start(), [ 2 ];
- }));
- }));
- }));
- },
-
- t.prototype.tu = function(t) {
-
-
-
-
- return M("PersistentStream", "close with error: ".concat(t)), this.stream = null,
- this.close(4 , t);
- },
-
- t.prototype.Xo = function(t) {
- var e = this;
- return function(n) {
- e.ii.enqueueAndForget((function() {
- return e.Fo === t ? n() : (M("PersistentStream", "stream callback skipped by getCloseGuardedDispatcher."),
- Promise.resolve());
- }));
- };
- }, t;
- }(), qa = function(e) {
- function n(t, n, r, i, o, u) {
- var a = this;
- return (a = e.call(this, t, "listen_stream_connection_backoff" , "listen_stream_idle" , "health_check_timeout" , n, r, i, u) || this).serializer = o,
- a;
- }
- return t(n, e), n.prototype.eu = function(t, e) {
- return this.connection.Ro("Listen", t, e);
- }, n.prototype.onMessage = function(t) {
-
- this.qo.reset();
- var e = function(t, e) {
- var n;
- if ("targetChange" in e) {
- e.targetChange;
-
-
- var r = function(t) {
- return "NO_CHANGE" === t ? 0 : "ADD" === t ? 1 : "REMOVE" === t ? 2 : "CURRENT" === t ? 3 : "RESET" === t ? 4 : U();
- }(e.targetChange.targetChangeType || "NO_CHANGE"), i = e.targetChange.targetIds || [], o = function(t, e) {
- return t.useProto3Json ? (z(void 0 === e || "string" == typeof e), Oe.fromBase64String(e || "")) : (z(void 0 === e || e instanceof Uint8Array),
- Oe.fromUint8Array(e || new Uint8Array));
- }(t, e.targetChange.resumeToken), u = e.targetChange.cause, a = u && function(t) {
- var e = void 0 === t.code ? K.UNKNOWN : li(t.code);
- return new Q(e, t.message || "");
- }(u);
- n = new Ti(r, i, o, a || null);
- } else if ("documentChange" in e) {
- e.documentChange;
- var s = e.documentChange;
- s.document, s.document.name, s.document.updateTime;
- var c = Bi(t, s.document.name), l = Vi(s.document.updateTime), h = s.document.createTime ? Vi(s.document.createTime) : ct.min(), f = new hn({
- mapValue: {
- fields: s.document.fields
- }
- }), d = dn.newFoundDocument(c, l, h, f), p = s.targetIds || [], v = s.removedTargetIds || [];
- n = new Ii(p, v, d.key, d);
- } else if ("documentDelete" in e) {
- e.documentDelete;
- var m = e.documentDelete;
- m.document;
- var y = Bi(t, m.document), g = m.readTime ? Vi(m.readTime) : ct.min(), w = dn.newNoDocument(y, g), b = m.removedTargetIds || [];
- n = new Ii([], b, w.key, w);
- } else if ("documentRemove" in e) {
- e.documentRemove;
- var I = e.documentRemove;
- I.document;
- var E = Bi(t, I.document), T = I.removedTargetIds || [];
- n = new Ii([], T, E, null);
- } else {
- if (!("filter" in e)) return U();
- e.filter;
- var S = e.filter;
- S.targetId;
- var _ = S.count, D = void 0 === _ ? 0 : _, C = S.unchangedNames, x = new si(D, C), N = S.targetId;
- n = new Ei(N, x);
- }
- return n;
- }(this.serializer, t), n = function(t) {
-
-
-
- if (!("targetChange" in t)) return ct.min();
- var e = t.targetChange;
- return e.targetIds && e.targetIds.length ? ct.min() : e.readTime ? Vi(e.readTime) : ct.min();
- }(t);
- return this.listener.nu(e, n);
- },
-
- n.prototype.su = function(t) {
- var e = {};
- e.database = Gi(this.serializer), e.addTarget = function(t, e) {
- var n, r = e.target;
- if ((n = zn(r) ? {
- documents: Yi(t, r)
- } : {
- query: Xi(t, r)
- }).targetId = e.targetId, e.resumeToken.approximateByteSize() > 0) {
- n.resumeToken = Pi(t, e.resumeToken);
- var i = Oi(t, e.expectedCount);
- null !== i && (n.expectedCount = i);
- } else if (e.snapshotVersion.compareTo(ct.min()) > 0) {
-
-
-
- n.readTime = Fi(t, e.snapshotVersion.toTimestamp());
- var o = Oi(t, e.expectedCount);
- null !== o && (n.expectedCount = o);
- }
- return n;
- }(this.serializer, t);
- var n = function(t, e) {
- var n = function(t) {
- switch (t) {
- case "TargetPurposeListen" :
- return null;
- case "TargetPurposeExistenceFilterMismatch" :
- return "existence-filter-mismatch";
- case "TargetPurposeExistenceFilterMismatchBloom" :
- return "existence-filter-mismatch-bloom";
- case "TargetPurposeLimboResolution" :
- return "limbo-document";
- default:
- return U();
- }
- }(e.purpose);
- return null == n ? null : {
- "goog-listen-tags": n
- };
- }(this.serializer, t);
- n && (e.labels = n), this.Wo(e);
- },
-
- n.prototype.iu = function(t) {
- var e = {};
- e.database = Gi(this.serializer), e.removeTarget = t, this.Wo(e);
- }, n;
- }(La), Ba = function(e) {
- function n(t, n, r, i, o, u) {
- var a = this;
- return (a = e.call(this, t, "write_stream_connection_backoff" , "write_stream_idle" , "health_check_timeout" , n, r, i, u) || this).serializer = o,
- a.ru = !1, a;
- }
- return t(n, e), Object.defineProperty(n.prototype, "ou", {
-
- get: function() {
- return this.ru;
- },
- enumerable: !1,
- configurable: !0
- }),
-
- n.prototype.start = function() {
- this.ru = !1, this.lastStreamToken = void 0, e.prototype.start.call(this);
- }, n.prototype.Yo = function() {
- this.ru && this.uu([]);
- }, n.prototype.eu = function(t, e) {
- return this.connection.Ro("Write", t, e);
- }, n.prototype.onMessage = function(t) {
- if (
-
- z(!!t.streamToken), this.lastStreamToken = t.streamToken, this.ru) {
-
-
-
- this.qo.reset();
- var e = function(t, e) {
- return t && t.length > 0 ? (z(void 0 !== e), t.map((function(t) {
- return function(t, e) {
-
- var n = t.updateTime ? Vi(t.updateTime) : Vi(e);
- return n.isEqual(ct.min()) && (
-
-
-
-
-
- n = Vi(e)), new Br(n, t.transformResults || []);
- }(t, e);
- }))) : [];
- }(t.writeResults, t.commitTime), n = Vi(t.commitTime);
- return this.listener.cu(n, e);
- }
-
- return z(!t.writeResults || 0 === t.writeResults.length), this.ru = !0,
- this.listener.au();
- },
-
- n.prototype.hu = function() {
-
-
- var t = {};
- t.database = Gi(this.serializer), this.Wo(t);
- },
- n.prototype.uu = function(t) {
- var e = this, n = {
- streamToken: this.lastStreamToken,
- writes: t.map((function(t) {
- return Wi(e.serializer, t);
- }))
- };
- this.Wo(n);
- }, n;
- }(La), Ua = function(e) {
- function n(t, n, r, i) {
- var o = this;
- return (o = e.call(this) || this).authCredentials = t, o.appCheckCredentials = n,
- o.connection = r, o.serializer = i, o.lu = !1, o;
- }
- return t(n, e), n.prototype.fu = function() {
- if (this.lu) throw new Q(K.FAILED_PRECONDITION, "The client has already been terminated.");
- },
- n.prototype.Io = function(t, e, n) {
- var r = this;
- return this.fu(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((function(i) {
- var o = i[0], u = i[1];
- return r.connection.Io(t, e, n, o, u);
- })).catch((function(t) {
- throw "FirebaseError" === t.name ? (t.code === K.UNAUTHENTICATED && (r.authCredentials.invalidateToken(),
- r.appCheckCredentials.invalidateToken()), t) : new Q(K.UNKNOWN, t.toString());
- }));
- },
- n.prototype.vo = function(t, e, n, r) {
- var i = this;
- return this.fu(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((function(o) {
- var u = o[0], a = o[1];
- return i.connection.vo(t, e, n, u, a, r);
- })).catch((function(t) {
- throw "FirebaseError" === t.name ? (t.code === K.UNAUTHENTICATED && (i.authCredentials.invalidateToken(),
- i.appCheckCredentials.invalidateToken()), t) : new Q(K.UNKNOWN, t.toString());
- }));
- }, n.prototype.terminate = function() {
- this.lu = !0;
- }, n;
- }((function() {}));
- var za = function() {
- function t(t, e) {
- this.asyncQueue = t, this.onlineStateHandler = e,
-
- this.state = "Unknown" ,
-
- this.wu = 0,
-
- this._u = null,
-
- this.mu = !0
-
- ;
- }
- return t.prototype.gu = function() {
- var t = this;
- 0 === this.wu && (this.yu("Unknown" ), this._u = this.asyncQueue.enqueueAfterDelay("online_state_timeout" , 1e4, (function() {
- return t._u = null, t.pu("Backend didn't respond within 10 seconds."), t.yu("Offline" ),
- Promise.resolve();
- })));
- },
-
- t.prototype.Iu = function(t) {
- "Online" === this.state ? this.yu("Unknown" ) : (this.wu++,
- this.wu >= 1 && (this.Tu(), this.pu("Connection failed 1 times. Most recent error: ".concat(t.toString())),
- this.yu("Offline" )));
- },
-
- t.prototype.set = function(t) {
- this.Tu(), this.wu = 0, "Online" === t && (
-
-
- this.mu = !1), this.yu(t);
- }, t.prototype.yu = function(t) {
- t !== this.state && (this.state = t, this.onlineStateHandler(t));
- }, t.prototype.pu = function(t) {
- var e = "Could not reach Cloud Firestore backend. ".concat(t, "\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.");
- this.mu ? (L(e), this.mu = !1) : M("OnlineStateTracker", e);
- }, t.prototype.Tu = function() {
- null !== this._u && (this._u.cancel(), this._u = null);
- }, t;
- }(), Ga = function(
- t,
- r, i, o, u) {
- var a = this;
- this.localStore = t, this.datastore = r, this.asyncQueue = i, this.remoteSyncer = {},
-
- this.Eu = [],
-
- this.Au = new Map,
-
- this.vu = new Set,
-
- this.Ru = [], this.Pu = u, this.Pu.Yr((function(t) {
- i.enqueueAndForget((function() {
- return e(a, void 0, void 0, (function() {
- return n(this, (function(t) {
- switch (t.label) {
- case 0:
- return Za(this) ? (M("RemoteStore", "Restarting streams for network reachability change."),
- [ 4 , function(t) {
- return e(this, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return (e = j(t)).vu.add(4 ), [ 4 , Ka(e) ];
- case 1:
- return n.sent(), e.bu.set("Unknown" ), e.vu.delete(4 ),
- [ 4 , ja(e) ];
- case 2:
- return n.sent(), [ 2 ];
- }
- }));
- }));
- }(this) ]) : [ 3 , 2 ];
- case 1:
- t.sent(), t.label = 2;
- case 2:
- return [ 2 ];
- }
- }));
- }));
- }));
- })), this.bu = new za(i, o);
- };
- function ja(t) {
- return e(this, void 0, void 0, (function() {
- var e, r;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- if (!Za(t)) return [ 3 , 4 ];
- e = 0, r = t.Ru, n.label = 1;
- case 1:
- return e < r.length ? [ 4 , (0, r[e])( !0) ] : [ 3 , 4 ];
- case 2:
- n.sent(), n.label = 3;
- case 3:
- return e++, [ 3 , 1 ];
- case 4:
- return [ 2 ];
- }
- }));
- }));
- }
- function Ka(t) {
- return e(this, void 0, void 0, (function() {
- var e, r;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- e = 0, r = t.Ru, n.label = 1;
- case 1:
- return e < r.length ? [ 4 , (0, r[e])( !1) ] : [ 3 , 4 ];
- case 2:
- n.sent(), n.label = 3;
- case 3:
- return e++, [ 3 , 1 ];
- case 4:
- return [ 2 ];
- }
- }));
- }));
- }
- function Qa(t, e) {
- var n = j(t);
- n.Au.has(e.targetId) || (
-
- n.Au.set(e.targetId, e), Ja(n) ?
-
- Xa(n) : ps(n).Ko() && Ha(n, e));
- }
- function Wa(t, e) {
- var n = j(t), r = ps(n);
- n.Au.delete(e), r.Ko() && Ya(n, e), 0 === n.Au.size && (r.Ko() ? r.jo() : Za(n) &&
-
-
-
- n.bu.set("Unknown" ));
- }
- function Ha(t, e) {
- if (t.Vu.qt(e.targetId), e.resumeToken.approximateByteSize() > 0 || e.snapshotVersion.compareTo(ct.min()) > 0) {
- var n = t.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;
- e = e.withExpectedCount(n);
- }
- ps(t).su(e);
- }
- function Ya(t, e) {
- t.Vu.qt(e), ps(t).iu(e);
- }
- function Xa(t) {
- t.Vu = new _i({
- getRemoteKeysForTarget: function(e) {
- return t.remoteSyncer.getRemoteKeysForTarget(e);
- },
- le: function(e) {
- return t.Au.get(e) || null;
- },
- ue: function() {
- return t.datastore.serializer.databaseId;
- }
- }), ps(t).start(), t.bu.gu()
-
- ;
- }
- function Ja(t) {
- return Za(t) && !ps(t).Uo() && t.Au.size > 0;
- }
- function Za(t) {
- return 0 === j(t).vu.size;
- }
- function $a(t) {
- t.Vu = void 0;
- }
- function ts(t) {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(e) {
- return t.Au.forEach((function(e, n) {
- Ha(t, e);
- })), [ 2 ];
- }));
- }));
- }
- function es(t, r) {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(e) {
- return $a(t),
-
- Ja(t) ? (t.bu.Iu(r), Xa(t)) :
-
-
-
- t.bu.set("Unknown" ), [ 2 ];
- }));
- }));
- }
- function ns(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var o, u, a;
- return n(this, (function(s) {
- switch (s.label) {
- case 0:
- if (t.bu.set("Online" ), !(r instanceof Ti && 2 === r.state && r.cause))
-
- return [ 3 , 6 ];
- s.label = 1;
- case 1:
- return s.trys.push([ 1, 3, , 5 ]), [ 4 ,
-
- function(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o, u;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- e = r.cause, i = 0, o = r.targetIds, n.label = 1;
- case 1:
- return i < o.length ? (u = o[i], t.Au.has(u) ? [ 4 , t.remoteSyncer.rejectListen(u, e) ] : [ 3 , 3 ]) : [ 3 , 5 ];
- case 2:
- n.sent(), t.Au.delete(u), t.Vu.removeTarget(u), n.label = 3;
- case 3:
- n.label = 4;
- case 4:
- return i++, [ 3 , 1 ];
- case 5:
- return [ 2 ];
- }
- }));
- }));
- }(t, r) ];
- case 2:
- return s.sent(), [ 3 , 5 ];
- case 3:
- return o = s.sent(), M("RemoteStore", "Failed to remove targets %s: %s ", r.targetIds.join(","), o),
- [ 4 , rs(t, o) ];
- case 4:
- return s.sent(), [ 3 , 5 ];
- case 5:
- return [ 3 , 13 ];
- case 6:
- if (r instanceof Ii ? t.Vu.Ht(r) : r instanceof Ei ? t.Vu.ne(r) : t.Vu.Xt(r), i.isEqual(ct.min())) return [ 3 , 13 ];
- s.label = 7;
- case 7:
- return s.trys.push([ 7, 11, , 13 ]), [ 4 , ia(t.localStore) ];
- case 8:
- return u = s.sent(), i.compareTo(u) >= 0 ? [ 4 ,
-
- function(t, e) {
- var n = t.Vu.ce(e);
-
-
- return n.targetChanges.forEach((function(n, r) {
- if (n.resumeToken.approximateByteSize() > 0) {
- var i = t.Au.get(r);
-
- i && t.Au.set(r, i.withResumeToken(n.resumeToken, e));
- }
- })),
-
-
- n.targetMismatches.forEach((function(e, n) {
- var r = t.Au.get(e);
- if (r) {
-
-
- t.Au.set(e, r.withResumeToken(Oe.EMPTY_BYTE_STRING, r.snapshotVersion)),
-
-
- Ya(t, e);
-
-
-
-
- var i = new ao(r.target, e, n, r.sequenceNumber);
- Ha(t, i);
- }
- })), t.remoteSyncer.applyRemoteEvent(n);
- }(t, i) ] : [ 3 , 10 ];
-
-
- case 9:
-
-
- s.sent(), s.label = 10;
- case 10:
- return [ 3 , 13 ];
- case 11:
- return M("RemoteStore", "Failed to raise snapshot:", a = s.sent()), [ 4 , rs(t, a) ];
- case 12:
- return s.sent(), [ 3 , 13 ];
- case 13:
- return [ 2 ];
- }
- }));
- }));
- }
- function rs(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var o = this;
- return n(this, (function(u) {
- switch (u.label) {
- case 0:
- if (!Pt(r)) throw r;
-
- return t.vu.add(1 ), [ 4 , Ka(t) ];
- case 1:
-
- return u.sent(), t.bu.set("Offline" ), i || (
-
-
-
- i = function() {
- return ia(t.localStore);
- }),
-
- t.asyncQueue.enqueueRetryable((function() {
- return e(o, void 0, void 0, (function() {
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
- return M("RemoteStore", "Retrying IndexedDB access"), [ 4 , i() ];
- case 1:
- return e.sent(), t.vu.delete(1 ), [ 4 , ja(t) ];
- case 2:
- return e.sent(), [ 2 ];
- }
- }));
- }));
- })), [ 2 ];
- }
- }));
- }));
- }
- function is(t, e) {
- return e().catch((function(n) {
- return rs(t, n, e);
- }));
- }
- function os(t) {
- return e(this, void 0, void 0, (function() {
- var e, r, i, o, u;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- e = j(t), r = vs(e), i = e.Eu.length > 0 ? e.Eu[e.Eu.length - 1].batchId : -1, n.label = 1;
- case 1:
- if (!
-
- function(t) {
- return Za(t) && t.Eu.length < 10;
- }
-
- (e)) return [ 3 , 7 ];
- n.label = 2;
- case 2:
- return n.trys.push([ 2, 4, , 6 ]), [ 4 , aa(e.localStore, i) ];
- case 3:
- return null === (o = n.sent()) ? (0 === e.Eu.length && r.jo(), [ 3 , 7 ]) : (i = o.batchId,
- function(t, e) {
- t.Eu.push(e);
- var n = vs(t);
- n.Ko() && n.ou && n.uu(e.mutations);
- }(e, o), [ 3 , 6 ]);
- case 4:
- return u = n.sent(), [ 4 , rs(e, u) ];
- case 5:
- return n.sent(), [ 3 , 6 ];
- case 6:
- return [ 3 , 1 ];
- case 7:
- return us(e) && as(e), [ 2 ];
- }
- }));
- }));
- }
- function us(t) {
- return Za(t) && !vs(t).Uo() && t.Eu.length > 0;
- }
- function as(t) {
- vs(t).start();
- }
- function ss(t) {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(e) {
- return vs(t).hu(), [ 2 ];
- }));
- }));
- }
- function cs(t) {
- return e(this, void 0, void 0, (function() {
- var e, r, i, o;
- return n(this, (function(n) {
-
- for (e = vs(t), r = 0, i = t.Eu; r < i.length; r++) o = i[r], e.uu(o.mutations);
- return [ 2 ];
- }));
- }));
- }
- function ls(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var e, o;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = t.Eu.shift(), o = oi.from(e, r, i), [ 4 , is(t, (function() {
- return t.remoteSyncer.applySuccessfulWrite(o);
- })) ];
- case 1:
-
-
- return n.sent(), [ 4 , os(t) ];
- case 2:
-
-
- return n.sent(), [ 2 ];
- }
- }));
- }));
- }
- function hs(t, r) {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(i) {
- switch (i.label) {
- case 0:
- return r && vs(t).ou ? [ 4 , function(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return ci(i = r.code) && i !== K.ABORTED ? (e = t.Eu.shift(),
-
-
-
- vs(t).Qo(), [ 4 , is(t, (function() {
- return t.remoteSyncer.rejectFailedWrite(e.batchId, r);
- })) ]) : [ 3 , 3 ];
- case 1:
-
-
- return n.sent(), [ 4 , os(t) ];
- case 2:
-
-
-
-
-
- n.sent(), n.label = 3;
- case 3:
- return [ 2 ];
- }
- }));
- }));
- }(t, r) ] : [ 3 , 2 ];
-
- case 1:
-
- i.sent(), i.label = 2;
- case 2:
-
-
-
-
- return us(t) && as(t), [ 2 ];
- }
- }));
- }));
- }
- function fs(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return (e = j(t)).asyncQueue.verifyOperationInProgress(), M("RemoteStore", "RemoteStore received new credentials"),
- i = Za(e),
-
-
-
- e.vu.add(3 ), [ 4 , Ka(e) ];
- case 1:
- return n.sent(), i &&
-
- e.bu.set("Unknown" ), [ 4 , e.remoteSyncer.handleCredentialChange(r) ];
- case 2:
- return n.sent(), e.vu.delete(3 ), [ 4 , ja(e) ];
- case 3:
-
-
-
- return n.sent(), [ 2 ];
- }
- }));
- }));
- }
- function ds(t, r) {
- return e(this, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = j(t), r ? (e.vu.delete(2 ), [ 4 , ja(e) ]) : [ 3 , 2 ];
- case 1:
- return n.sent(), [ 3 , 5 ];
- case 2:
- return r ? [ 3 , 4 ] : (e.vu.add(2 ), [ 4 , Ka(e) ]);
- case 3:
- n.sent(), e.bu.set("Unknown" ), n.label = 4;
- case 4:
- n.label = 5;
- case 5:
- return [ 2 ];
- }
- }));
- }));
- }
- function ps(t) {
- var r = this;
- return t.Su || (
-
- t.Su = function(t, e, n) {
- var r = j(t);
- return r.fu(), new qa(e, r.connection, r.authCredentials, r.appCheckCredentials, r.serializer, n);
- }(t.datastore, t.asyncQueue, {
- uo: ts.bind(null, t),
- ao: es.bind(null, t),
- nu: ns.bind(null, t)
- }), t.Ru.push((function(i) {
- return e(r, void 0, void 0, (function() {
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
- return i ? (t.Su.Qo(), Ja(t) ? Xa(t) : t.bu.set("Unknown" ),
- [ 3 , 3 ]) : [ 3 , 1 ];
- case 1:
- return [ 4 , t.Su.stop() ];
- case 2:
- e.sent(), $a(t), e.label = 3;
- case 3:
- return [ 2 ];
- }
- }));
- }));
- }))), t.Su
-
- ;
- }
- function vs(t) {
- var r = this;
- return t.Du || (
-
- t.Du = function(t, e, n) {
- var r = j(t);
- return r.fu(), new Ba(e, r.connection, r.authCredentials, r.appCheckCredentials, r.serializer, n);
- }(t.datastore, t.asyncQueue, {
- uo: ss.bind(null, t),
- ao: hs.bind(null, t),
- au: cs.bind(null, t),
- cu: ls.bind(null, t)
- }), t.Ru.push((function(i) {
- return e(r, void 0, void 0, (function() {
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
- return i ? (t.Du.Qo(), [ 4 , os(t) ]) : [ 3 , 2 ];
- case 1:
-
- return e.sent(), [ 3 , 4 ];
- case 2:
- return [ 4 , t.Du.stop() ];
- case 3:
- e.sent(), t.Eu.length > 0 && (M("RemoteStore", "Stopping write stream with ".concat(t.Eu.length, " pending writes")),
- t.Eu = []), e.label = 4;
- case 4:
- return [ 2 ];
- }
- }));
- }));
- }))), t.Du
-
-
- ;
- }
- var ms = function() {
- function t(t, e, n, r, i) {
- this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = i,
- this.deferred = new W, this.then = this.deferred.promise.then.bind(this.deferred.promise),
-
-
-
- this.deferred.promise.catch((function(t) {}))
-
- ;
- }
- return t.createAndSchedule = function(e, n, r, i, o) {
- var u = new t(e, n, Date.now() + r, i, o);
- return u.start(r), u;
- },
-
- t.prototype.start = function(t) {
- var e = this;
- this.timerHandle = setTimeout((function() {
- return e.handleDelayElapsed();
- }), t);
- },
-
- t.prototype.skipDelay = function() {
- return this.handleDelayElapsed();
- },
-
- t.prototype.cancel = function(t) {
- null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new Q(K.CANCELLED, "Operation cancelled" + (t ? ": " + t : ""))));
- }, t.prototype.handleDelayElapsed = function() {
- var t = this;
- this.asyncQueue.enqueueAndForget((function() {
- return null !== t.timerHandle ? (t.clearTimeout(), t.op().then((function(e) {
- return t.deferred.resolve(e);
- }))) : Promise.resolve();
- }));
- }, t.prototype.clearTimeout = function() {
- null !== this.timerHandle && (this.removalCallback(this), clearTimeout(this.timerHandle),
- this.timerHandle = null);
- }, t;
- }();
- function ys(t, e) {
- if (L("AsyncQueue", "".concat(e, ": ").concat(t)), Pt(t)) return new Q(K.UNAVAILABLE, "".concat(e, ": ").concat(t));
- throw t;
- }
- var gs = function() {
-
- function t(t) {
-
-
- this.comparator = t ? function(e, n) {
- return t(e, n) || pt.comparator(e.key, n.key);
- } : function(t, e) {
- return pt.comparator(t.key, e.key);
- }, this.keyedMap = pr(), this.sortedSet = new Te(this.comparator)
-
- ;
- }
- return t.emptySet = function(e) {
- return new t(e.comparator);
- }, t.prototype.has = function(t) {
- return null != this.keyedMap.get(t);
- }, t.prototype.get = function(t) {
- return this.keyedMap.get(t);
- }, t.prototype.first = function() {
- return this.sortedSet.minKey();
- }, t.prototype.last = function() {
- return this.sortedSet.maxKey();
- }, t.prototype.isEmpty = function() {
- return this.sortedSet.isEmpty();
- },
-
- t.prototype.indexOf = function(t) {
- var e = this.keyedMap.get(t);
- return e ? this.sortedSet.indexOf(e) : -1;
- }, Object.defineProperty(t.prototype, "size", {
- get: function() {
- return this.sortedSet.size;
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.forEach = function(t) {
- this.sortedSet.inorderTraversal((function(e, n) {
- return t(e), !1;
- }));
- },
- t.prototype.add = function(t) {
-
- var e = this.delete(t.key);
- return e.copy(e.keyedMap.insert(t.key, t), e.sortedSet.insert(t, null));
- },
- t.prototype.delete = function(t) {
- var e = this.get(t);
- return e ? this.copy(this.keyedMap.remove(t), this.sortedSet.remove(e)) : this;
- }, t.prototype.isEqual = function(e) {
- if (!(e instanceof t)) return !1;
- if (this.size !== e.size) return !1;
- for (var n = this.sortedSet.getIterator(), r = e.sortedSet.getIterator(); n.hasNext(); ) {
- var i = n.getNext().key, o = r.getNext().key;
- if (!i.isEqual(o)) return !1;
- }
- return !0;
- }, t.prototype.toString = function() {
- var t = [];
- return this.forEach((function(e) {
- t.push(e.toString());
- })), 0 === t.length ? "DocumentSet ()" : "DocumentSet (\n " + t.join(" \n") + "\n)";
- }, t.prototype.copy = function(e, n) {
- var r = new t;
- return r.comparator = this.comparator, r.keyedMap = e, r.sortedSet = n, r;
- }, t;
- }(), ws = function() {
- function t() {
- this.Cu = new Te(pt.comparator);
- }
- return t.prototype.track = function(t) {
- var e = t.doc.key, n = this.Cu.get(e);
- n ?
-
- 0 !== t.type && 3 === n.type ? this.Cu = this.Cu.insert(e, t) : 3 === t.type && 1 !== n.type ? this.Cu = this.Cu.insert(e, {
- type: n.type,
- doc: t.doc
- }) : 2 === t.type && 2 === n.type ? this.Cu = this.Cu.insert(e, {
- type: 2 ,
- doc: t.doc
- }) : 2 === t.type && 0 === n.type ? this.Cu = this.Cu.insert(e, {
- type: 0 ,
- doc: t.doc
- }) : 1 === t.type && 0 === n.type ? this.Cu = this.Cu.remove(e) : 1 === t.type && 2 === n.type ? this.Cu = this.Cu.insert(e, {
- type: 1 ,
- doc: n.doc
- }) : 0 === t.type && 1 === n.type ? this.Cu = this.Cu.insert(e, {
- type: 2 ,
- doc: t.doc
- }) :
-
-
-
-
-
-
-
- U() : this.Cu = this.Cu.insert(e, t);
- }, t.prototype.xu = function() {
- var t = [];
- return this.Cu.inorderTraversal((function(e, n) {
- t.push(n);
- })), t;
- }, t;
- }(), bs = function() {
- function t(t, e, n, r, i, o, u, a, s) {
- this.query = t, this.docs = e, this.oldDocs = n, this.docChanges = r, this.mutatedKeys = i,
- this.fromCache = o, this.syncStateChanged = u, this.excludesMetadataChanges = a,
- this.hasCachedResults = s
- ;
- }
- return t.fromInitialDocuments = function(e, n, r, i, o) {
- var u = [];
- return n.forEach((function(t) {
- u.push({
- type: 0 ,
- doc: t
- });
- })), new t(e, n, gs.emptySet(n), u, r, i,
- !0,
- !1, o);
- }, Object.defineProperty(t.prototype, "hasPendingWrites", {
- get: function() {
- return !this.mutatedKeys.isEmpty();
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.isEqual = function(t) {
- if (!(this.fromCache === t.fromCache && this.hasCachedResults === t.hasCachedResults && this.syncStateChanged === t.syncStateChanged && this.mutatedKeys.isEqual(t.mutatedKeys) && rr(this.query, t.query) && this.docs.isEqual(t.docs) && this.oldDocs.isEqual(t.oldDocs))) return !1;
- var e = this.docChanges, n = t.docChanges;
- if (e.length !== n.length) return !1;
- for (var r = 0; r < e.length; r++) if (e[r].type !== n[r].type || !e[r].doc.isEqual(n[r].doc)) return !1;
- return !0;
- }, t;
- }(), Is = function() {
- this.Nu = void 0, this.listeners = [];
- }, Es = function() {
- this.queries = new lr((function(t) {
- return ir(t);
- }), rr), this.onlineState = "Unknown" , this.ku = new Set;
- };
- function Ts(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o, u, a, s, c;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- if (e = j(t), i = r.query, o = !1, (u = e.queries.get(i)) || (o = !0, u = new Is),
- !o) return [ 3 , 4 ];
- n.label = 1;
- case 1:
- return n.trys.push([ 1, 3, , 4 ]), a = u, [ 4 , e.onListen(i) ];
- case 2:
- return a.Nu = n.sent(), [ 3 , 4 ];
- case 3:
- return s = n.sent(), c = ys(s, "Initialization of query '".concat(or(r.query), "' failed")),
- [ 2 , void r.onError(c) ];
- case 4:
- return e.queries.set(i, u), u.listeners.push(r),
-
- r.Mu(e.onlineState), u.Nu && r.$u(u.Nu) && Cs(e), [ 2 ];
- }
- }));
- }));
- }
- function Ss(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o, u, a;
- return n(this, (function(n) {
- return e = j(t), i = r.query, o = !1, (u = e.queries.get(i)) && (a = u.listeners.indexOf(r)) >= 0 && (u.listeners.splice(a, 1),
- o = 0 === u.listeners.length), o ? [ 2 , (e.queries.delete(i), e.onUnlisten(i)) ] : [ 2 ];
- }));
- }));
- }
- function _s(t, e) {
- for (var n = j(t), r = !1, i = 0, o = e; i < o.length; i++) {
- var u = o[i], a = u.query, s = n.queries.get(a);
- if (s) {
- for (var c = 0, l = s.listeners; c < l.length; c++) {
- l[c].$u(u) && (r = !0);
- }
- s.Nu = u;
- }
- }
- r && Cs(n);
- }
- function Ds(t, e, n) {
- var r = j(t), i = r.queries.get(e);
- if (i) for (var o = 0, u = i.listeners; o < u.length; o++) {
- u[o].onError(n);
- }
-
-
- r.queries.delete(e);
- }
- function Cs(t) {
- t.ku.forEach((function(t) {
- t.next();
- }));
- }
- var xs = function() {
- function t(t, e, n) {
- this.query = t, this.Ou = e,
-
- this.Fu = !1, this.Bu = null, this.onlineState = "Unknown" ,
- this.options = n || {}
-
- ;
- }
- return t.prototype.$u = function(t) {
- if (!this.options.includeMetadataChanges) {
- for (
-
- var e = [], n = 0, r = t.docChanges; n < r.length; n++) {
- var i = r[n];
- 3 !== i.type && e.push(i);
- }
- t = new bs(t.query, t.docs, t.oldDocs, e, t.mutatedKeys, t.fromCache, t.syncStateChanged,
- !0, t.hasCachedResults);
- }
- var o = !1;
- return this.Fu ? this.Lu(t) && (this.Ou.next(t), o = !0) : this.qu(t, this.onlineState) && (this.Uu(t),
- o = !0), this.Bu = t, o;
- }, t.prototype.onError = function(t) {
- this.Ou.error(t);
- },
- t.prototype.Mu = function(t) {
- this.onlineState = t;
- var e = !1;
- return this.Bu && !this.Fu && this.qu(this.Bu, t) && (this.Uu(this.Bu), e = !0),
- e;
- }, t.prototype.qu = function(t, e) {
-
- if (!t.fromCache) return !0;
-
-
- var n = "Offline" !== e;
-
-
- return (!this.options.Ku || !n) && (!t.docs.isEmpty() || t.hasCachedResults || "Offline" === e);
-
-
- }, t.prototype.Lu = function(t) {
-
-
-
-
- if (t.docChanges.length > 0) return !0;
- var e = this.Bu && this.Bu.hasPendingWrites !== t.hasPendingWrites;
- return !(!t.syncStateChanged && !e) && !0 === this.options.includeMetadataChanges;
-
-
-
- }, t.prototype.Uu = function(t) {
- t = bs.fromInitialDocuments(t.query, t.docs, t.mutatedKeys, t.fromCache, t.hasCachedResults),
- this.Fu = !0, this.Ou.next(t);
- }, t;
- }(), Ns = function() {
- function t(t,
-
- e) {
- this.Gu = t, this.byteLength = e;
- }
- return t.prototype.Qu = function() {
- return "metadata" in this.Gu;
- }, t;
- }(), As = function() {
- function t(t) {
- this.serializer = t;
- }
- return t.prototype.rr = function(t) {
- return Bi(this.serializer, t);
- },
-
- t.prototype.ur = function(t) {
- return t.metadata.exists ? Qi(this.serializer, t.document, !1) : dn.newNoDocument(this.rr(t.metadata.name), this.cr(t.metadata.readTime));
- }, t.prototype.cr = function(t) {
- return Vi(t);
- }, t;
- }(), ks = function() {
- function t(t, e, n) {
- this.ju = t, this.localStore = e, this.serializer = n,
-
- this.queries = [],
-
- this.documents = [],
-
- this.collectionGroups = new Set, this.progress = Os(t)
-
- ;
- }
- return t.prototype.zu = function(t) {
- this.progress.bytesLoaded += t.byteLength;
- var e = this.progress.documentsLoaded;
- if (t.Gu.namedQuery) this.queries.push(t.Gu.namedQuery); else if (t.Gu.documentMetadata) {
- this.documents.push({
- metadata: t.Gu.documentMetadata
- }), t.Gu.documentMetadata.exists || ++e;
- var n = ht.fromString(t.Gu.documentMetadata.name);
- this.collectionGroups.add(n.get(n.length - 2));
- } else t.Gu.document && (this.documents[this.documents.length - 1].document = t.Gu.document,
- ++e);
- return e !== this.progress.documentsLoaded ? (this.progress.documentsLoaded = e,
- Object.assign({}, this.progress)) : null;
- }, t.prototype.Wu = function(t) {
- for (var e = new Map, n = new As(this.serializer), r = 0, i = t; r < i.length; r++) {
- var o = i[r];
- if (o.metadata.queries) for (var u = n.rr(o.metadata.name), a = 0, s = o.metadata.queries; a < s.length; a++) {
- var c = s[a], l = (e.get(c) || Ir()).add(u);
- e.set(c, l);
- }
- }
- return e;
- },
-
- t.prototype.complete = function() {
- return e(this, void 0, void 0, (function() {
- var t, e, r, i, o;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , pa(this.localStore, new As(this.serializer), this.documents, this.ju.id) ];
- case 1:
- t = n.sent(), e = this.Wu(this.documents), r = 0, i = this.queries, n.label = 2;
- case 2:
- return r < i.length ? (o = i[r], [ 4 , va(this.localStore, o, e.get(o.name)) ]) : [ 3 , 5 ];
- case 3:
- n.sent(), n.label = 4;
- case 4:
- return r++, [ 3 , 2 ];
- case 5:
- return [ 2 , (this.progress.taskState = "Success", {
- progress: this.progress,
- Hu: this.collectionGroups,
- Ju: t
- }) ];
- }
- }));
- }));
- }, t;
- }();
- function Os(t) {
- return {
- taskState: "Running",
- documentsLoaded: 0,
- bytesLoaded: 0,
- totalDocuments: t.totalDocuments,
- totalBytes: t.totalBytes
- };
- }
- var Fs = function(t) {
- this.key = t;
- }, Ps = function(t) {
- this.key = t;
- }, Rs = function() {
- function t(t,
-
- e) {
- this.query = t, this.Yu = e, this.Xu = null, this.hasCachedResults = !1,
-
- this.current = !1,
-
- this.Zu = Ir(),
-
- this.mutatedKeys = Ir(), this.tc = sr(t), this.ec = new gs(this.tc);
- }
- return Object.defineProperty(t.prototype, "nc", {
-
- get: function() {
- return this.Yu;
- },
- enumerable: !1,
- configurable: !0
- }),
-
- t.prototype.sc = function(t, e) {
- var n = this, r = e ? e.ic : new ws, i = e ? e.ec : this.ec, o = e ? e.mutatedKeys : this.mutatedKeys, u = i, a = !1, s = "F" === this.query.limitType && i.size === this.query.limit ? i.last() : null, c = "L" === this.query.limitType && i.size === this.query.limit ? i.first() : null;
-
- if (t.inorderTraversal((function(t, e) {
- var l = i.get(t), h = ur(n.query, e) ? e : null, f = !!l && n.mutatedKeys.has(l.key), d = !!h && (h.hasLocalMutations ||
-
-
- n.mutatedKeys.has(h.key) && h.hasCommittedMutations), p = !1;
-
- l && h ? l.data.isEqual(h.data) ? f !== d && (r.track({
- type: 3 ,
- doc: h
- }), p = !0) : n.rc(l, h) || (r.track({
- type: 2 ,
- doc: h
- }), p = !0, (s && n.tc(h, s) > 0 || c && n.tc(h, c) < 0) && (
-
-
-
- a = !0)) : !l && h ? (r.track({
- type: 0 ,
- doc: h
- }), p = !0) : l && !h && (r.track({
- type: 1 ,
- doc: l
- }), p = !0, (s || c) && (
-
-
-
- a = !0)), p && (h ? (u = u.add(h), o = d ? o.add(t) : o.delete(t)) : (u = u.delete(t),
- o = o.delete(t)));
- })), null !== this.query.limit) for (;u.size > this.query.limit; ) {
- var l = "F" === this.query.limitType ? u.last() : u.first();
- u = u.delete(l.key), o = o.delete(l.key), r.track({
- type: 1 ,
- doc: l
- });
- }
- return {
- ec: u,
- ic: r,
- zi: a,
- mutatedKeys: o
- };
- }, t.prototype.rc = function(t, e) {
-
-
-
-
-
-
-
- return t.hasLocalMutations && e.hasCommittedMutations && !e.hasLocalMutations;
- },
-
-
- t.prototype.applyChanges = function(t, e, n) {
- var r = this, i = this.ec;
- this.ec = t.ec, this.mutatedKeys = t.mutatedKeys;
-
- var o = t.ic.xu();
- o.sort((function(t, e) {
- return function(t, e) {
- var n = function(t) {
- switch (t) {
- case 0 :
- return 1;
- case 2 :
- case 3 :
-
-
-
- return 2;
- case 1 :
- return 0;
- default:
- return U();
- }
- };
- return n(t) - n(e);
- }(t.type, e.type) || r.tc(t.doc, e.doc);
- })), this.oc(n);
- var u = e ? this.uc() : [], a = 0 === this.Zu.size && this.current ? 1 : 0 , s = a !== this.Xu;
- return this.Xu = a, 0 !== o.length || s ? {
- snapshot: new bs(this.query, t.ec, i, o, t.mutatedKeys, 0 === a, s,
- !1, !!n && n.resumeToken.approximateByteSize() > 0),
- cc: u
- } : {
- cc: u
- };
-
- },
-
- t.prototype.Mu = function(t) {
- return this.current && "Offline" === t ? (
-
-
-
-
- this.current = !1, this.applyChanges({
- ec: this.ec,
- ic: new ws,
- mutatedKeys: this.mutatedKeys,
- zi: !1
- },
- !1)) : {
- cc: []
- };
- },
-
- t.prototype.ac = function(t) {
-
- return !this.Yu.has(t) &&
-
- !!this.ec.has(t) && !this.ec.get(t).hasLocalMutations;
- },
-
- t.prototype.oc = function(t) {
- var e = this;
- t && (t.addedDocuments.forEach((function(t) {
- return e.Yu = e.Yu.add(t);
- })), t.modifiedDocuments.forEach((function(t) {})), t.removedDocuments.forEach((function(t) {
- return e.Yu = e.Yu.delete(t);
- })), this.current = t.current);
- }, t.prototype.uc = function() {
- var t = this;
-
- if (!this.current) return [];
-
-
- var e = this.Zu;
- this.Zu = Ir(), this.ec.forEach((function(e) {
- t.ac(e.key) && (t.Zu = t.Zu.add(e.key));
- }));
-
- var n = [];
- return e.forEach((function(e) {
- t.Zu.has(e) || n.push(new Ps(e));
- })), this.Zu.forEach((function(t) {
- e.has(t) || n.push(new Fs(t));
- })), n;
- },
-
-
- t.prototype.hc = function(t) {
- this.Yu = t.ir, this.Zu = Ir();
- var e = this.sc(t.documents);
- return this.applyChanges(e, !0);
- },
-
-
- t.prototype.lc = function() {
- return bs.fromInitialDocuments(this.query, this.ec, this.mutatedKeys, 0 === this.Xu, this.hasCachedResults);
- }, t;
- }(), Vs = function(
- t,
- e,
- n) {
- this.query = t, this.targetId = e, this.view = n;
- }, Ms = function(t) {
- this.key = t,
-
- this.fc = !1;
- }, Ls = function() {
- function t(t, e, n,
-
- r, i, o) {
- this.localStore = t, this.remoteStore = e, this.eventManager = n, this.sharedClientState = r,
- this.currentUser = i, this.maxConcurrentLimboResolutions = o, this.dc = {}, this.wc = new lr((function(t) {
- return ir(t);
- }), rr), this._c = new Map,
-
- this.mc = new Set,
-
- this.gc = new Te(pt.comparator),
-
- this.yc = new Map, this.Ic = new Ru,
-
- this.Tc = {},
-
- this.Ec = new Map, this.Ac = lu.Mn(), this.onlineState = "Unknown" ,
-
-
-
- this.vc = void 0;
- }
- return Object.defineProperty(t.prototype, "isPrimaryClient", {
- get: function() {
- return !0 === this.vc;
- },
- enumerable: !1,
- configurable: !0
- }), t;
- }();
- function qs(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o, u, a, s;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = pc(t), (u = e.wc.get(r)) ? (
-
-
-
-
-
-
- i = u.targetId, e.sharedClientState.addLocalQueryTarget(i), o = u.view.lc(), [ 3 , 4 ]) : [ 3 , 1 ];
- case 1:
- return [ 4 , sa(e.localStore, tr(r)) ];
- case 2:
- return a = n.sent(), s = e.sharedClientState.addLocalQueryTarget(a.targetId), i = a.targetId,
- [ 4 , Bs(e, r, i, "current" === s, a.resumeToken) ];
- case 3:
- o = n.sent(), e.isPrimaryClient && Qa(e.remoteStore, a), n.label = 4;
- case 4:
- return [ 2 , o ];
- }
- }));
- }));
- }
- function Bs(t, r, i, o, u) {
- return e(this, void 0, void 0, (function() {
- var a, s, c, l, h, f;
- return n(this, (function(d) {
- switch (d.label) {
- case 0:
-
-
-
- return t.Rc = function(r, i, o) {
- return function(t, r, i, o) {
- return e(this, void 0, void 0, (function() {
- var e, u, a;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = r.view.sc(i), e.zi ? [ 4 , la(t.localStore, r.query,
- !1).then((function(t) {
- var n = t.documents;
- return r.view.sc(n, e);
- })) ] : [ 3 , 2 ];
- case 1:
-
-
-
- e = n.sent(), n.label = 2;
- case 2:
- return u = o && o.targetChanges.get(r.targetId), a = r.view.applyChanges(e,
- t.isPrimaryClient, u), [ 2 , ($s(t, r.targetId, a.cc),
- a.snapshot) ];
- }
- }));
- }));
- }(t, r, i, o);
- }, [ 4 , la(t.localStore, r,
- !0) ];
- case 1:
- return a = d.sent(), s = new Rs(r, a.ir), c = s.sc(a.documents), l = bi.createSynthesizedTargetChangeForCurrentChange(i, o && "Offline" !== t.onlineState, u),
- h = s.applyChanges(c,
- t.isPrimaryClient, l), $s(t, i, h.cc), f = new Vs(r, i, s),
- [ 2 , (t.wc.set(r, f), t._c.has(i) ? t._c.get(i).push(r) : t._c.set(i, [ r ]),
- h.snapshot) ];
- }
- }));
- }));
- }
- function Us(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = j(t), i = e.wc.get(r), (o = e._c.get(i.targetId)).length > 1 ? [ 2 , (e._c.set(i.targetId, o.filter((function(t) {
- return !rr(t, r);
- }))), void e.wc.delete(r)) ] : e.isPrimaryClient ? (
-
-
- e.sharedClientState.removeLocalQueryTarget(i.targetId), e.sharedClientState.isActiveQueryTarget(i.targetId) ? [ 3 , 2 ] : [ 4 , ca(e.localStore, i.targetId,
- !1).then((function() {
- e.sharedClientState.clearQueryState(i.targetId), Wa(e.remoteStore, i.targetId),
- Js(e, i.targetId);
- })).catch(xt) ]) : [ 3 , 3 ];
- case 1:
- n.sent(), n.label = 2;
- case 2:
- return [ 3 , 5 ];
- case 3:
- return Js(e, i.targetId), [ 4 , ca(e.localStore, i.targetId,
- !0) ];
- case 4:
- n.sent(), n.label = 5;
- case 5:
- return [ 2 ];
- }
- }));
- }));
- }
- function zs(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var e, o, u, a;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- e = vc(t), n.label = 1;
- case 1:
- return n.trys.push([ 1, 5, , 6 ]), [ 4 , function(t, e) {
- var n, r, i = j(t), o = st.now(), u = e.reduce((function(t, e) {
- return t.add(e.key);
- }), Ir());
- return i.persistence.runTransaction("Locally write mutations", "readwrite", (function(t) {
-
-
-
-
-
-
- var a = fr(), s = Ir();
- return i.Zi.getEntries(t, u).next((function(t) {
- (a = t).forEach((function(t, e) {
- e.isValidDocument() || (s = s.add(t));
- }));
- })).next((function() {
- return i.localDocuments.getOverlayedDocuments(t, a);
- })).next((function(r) {
- n = r;
- for (
-
-
-
-
-
- var u = [], a = 0, s = e; a < s.length; a++) {
- var c = s[a], l = Wr(c, n.get(c.key).overlayedDocument);
- null != l &&
-
-
-
- u.push(new Xr(c.key, l, fn(l.value.mapValue), Ur.exists(!0)));
- }
- return i.mutationQueue.addMutationBatch(t, o, u, e);
- })).next((function(e) {
- r = e;
- var o = e.applyToLocalDocumentSet(n, s);
- return i.documentOverlayCache.saveOverlays(t, e.batchId, o);
- }));
- })).then((function() {
- return {
- batchId: r.batchId,
- changes: vr(n)
- };
- }));
- }(e.localStore, r) ];
- case 2:
- return o = n.sent(), e.sharedClientState.addPendingMutation(o.batchId), function(t, e, n) {
- var r = t.Tc[t.currentUser.toKey()];
- r || (r = new Te(ot)), r = r.insert(e, n), t.Tc[t.currentUser.toKey()] = r;
- }(e, o.batchId, i), [ 4 , nc(e, o.changes) ];
- case 3:
- return n.sent(), [ 4 , os(e.remoteStore) ];
- case 4:
- return n.sent(), [ 3 , 6 ];
- case 5:
- return u = n.sent(), a = ys(u, "Failed to persist write"), i.reject(a), [ 3 , 6 ];
- case 6:
- return [ 2 ];
- }
- }));
- }));
- }
- function Gs(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- e = j(t), n.label = 1;
- case 1:
- return n.trys.push([ 1, 4, , 6 ]), [ 4 , oa(e.localStore, r) ];
- case 2:
- return i = n.sent(),
-
- r.targetChanges.forEach((function(t, n) {
- var r = e.yc.get(n);
- r && (
-
-
- z(t.addedDocuments.size + t.modifiedDocuments.size + t.removedDocuments.size <= 1),
- t.addedDocuments.size > 0 ? r.fc = !0 : t.modifiedDocuments.size > 0 ? z(r.fc) : t.removedDocuments.size > 0 && (z(r.fc),
- r.fc = !1));
- })), [ 4 , nc(e, i, r) ];
- case 3:
-
- return n.sent(), [ 3 , 6 ];
- case 4:
- return [ 4 , xt(n.sent()) ];
- case 5:
- return n.sent(), [ 3 , 6 ];
- case 6:
- return [ 2 ];
- }
- }));
- }));
- }
- function js(t, e, n) {
- var r = j(t);
-
-
-
-
- if (r.isPrimaryClient && 0 === n || !r.isPrimaryClient && 1 === n) {
- var i = [];
- r.wc.forEach((function(t, n) {
- var r = n.view.Mu(e);
- r.snapshot && i.push(r.snapshot);
- })), function(t, e) {
- var n = j(t);
- n.onlineState = e;
- var r = !1;
- n.queries.forEach((function(t, n) {
- for (var i = 0, o = n.listeners; i < o.length; i++) {
-
- o[i].Mu(e) && (r = !0);
- }
- })), r && Cs(n);
- }(r.eventManager, e), i.length && r.dc.nu(i), r.onlineState = e, r.isPrimaryClient && r.sharedClientState.setOnlineState(e);
- }
- }
- function Ks(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var e, o, u, a, s, c;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
-
- return (e = j(t)).sharedClientState.updateQueryState(r, "rejected", i), o = e.yc.get(r),
- (u = o && o.key) ? (
-
-
-
- a = (a = new Te(pt.comparator)).insert(u, dn.newNoDocument(u, ct.min())), s = Ir().add(u),
- c = new wi(ct.min(),
- new Map,
- new Te(ot), a, s), [ 4 , Gs(e, c) ]) : [ 3 , 2 ];
- case 1:
- return n.sent(),
-
-
-
-
-
- e.gc = e.gc.remove(u), e.yc.delete(r), ec(e), [ 3 , 4 ];
- case 2:
- return [ 4 , ca(e.localStore, r,
- !1).then((function() {
- return Js(e, r, i);
- })).catch(xt) ];
- case 3:
- n.sent(), n.label = 4;
- case 4:
- return [ 2 ];
- }
- }));
- }));
- }
- function Qs(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- e = j(t), i = r.batch.batchId, n.label = 1;
- case 1:
- return n.trys.push([ 1, 4, , 6 ]), [ 4 , ra(e.localStore, r) ];
- case 2:
- return o = n.sent(),
-
-
-
-
- Xs(e, i, null), Ys(e, i), e.sharedClientState.updateMutationState(i, "acknowledged"),
- [ 4 , nc(e, o) ];
- case 3:
-
-
-
-
- return n.sent(), [ 3 , 6 ];
- case 4:
- return [ 4 , xt(n.sent()) ];
- case 5:
- return n.sent(), [ 3 , 6 ];
- case 6:
- return [ 2 ];
- }
- }));
- }));
- }
- function Ws(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var e, o;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- e = j(t), n.label = 1;
- case 1:
- return n.trys.push([ 1, 4, , 6 ]), [ 4 , function(t, e) {
- var n = j(t);
- return n.persistence.runTransaction("Reject batch", "readwrite-primary", (function(t) {
- var r;
- return n.mutationQueue.lookupMutationBatch(t, e).next((function(e) {
- return z(null !== e), r = e.keys(), n.mutationQueue.removeMutationBatch(t, e);
- })).next((function() {
- return n.mutationQueue.performConsistencyCheck(t);
- })).next((function() {
- return n.documentOverlayCache.removeOverlaysForBatchId(t, r, e);
- })).next((function() {
- return n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(t, r);
- })).next((function() {
- return n.localDocuments.getDocuments(t, r);
- }));
- }));
- }(e.localStore, r) ];
- case 2:
- return o = n.sent(),
-
-
-
-
- Xs(e, r, i), Ys(e, r), e.sharedClientState.updateMutationState(r, "rejected", i),
- [ 4 , nc(e, o) ];
- case 3:
-
-
-
-
- return n.sent(), [ 3 , 6 ];
- case 4:
- return [ 4 , xt(n.sent()) ];
- case 5:
- return n.sent(), [ 3 , 6 ];
- case 6:
- return [ 2 ];
- }
- }));
- }));
- }
- function Hs(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o, u, a;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- Za((e = j(t)).remoteStore) || M("SyncEngine", "The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),
- n.label = 1;
- case 1:
- return n.trys.push([ 1, 3, , 4 ]), [ 4 , function(t) {
- var e = j(t);
- return e.persistence.runTransaction("Get highest unacknowledged batch id", "readonly", (function(t) {
- return e.mutationQueue.getHighestUnacknowledgedBatchId(t);
- }));
- }(e.localStore) ];
- case 2:
- return -1 === (i = n.sent()) ? [ 2 , void r.resolve() ] : ((o = e.Ec.get(i) || []).push(r),
- e.Ec.set(i, o), [ 3 , 4 ]);
- case 3:
- return u = n.sent(), a = ys(u, "Initialization of waitForPendingWrites() operation failed"),
- r.reject(a), [ 3 , 4 ];
- case 4:
- return [ 2 ];
- }
- }));
- }));
- }
- function Ys(t, e) {
- (t.Ec.get(e) || []).forEach((function(t) {
- t.resolve();
- })), t.Ec.delete(e)
- ;
- }
- function Xs(t, e, n) {
- var r = j(t), i = r.Tc[r.currentUser.toKey()];
-
-
- if (i) {
- var o = i.get(e);
- o && (n ? o.reject(n) : o.resolve(), i = i.remove(e)), r.Tc[r.currentUser.toKey()] = i;
- }
- }
- function Js(t, e, n) {
- void 0 === n && (n = null), t.sharedClientState.removeLocalQueryTarget(e);
- for (var r = 0, i = t._c.get(e); r < i.length; r++) {
- var o = i[r];
- t.wc.delete(o), n && t.dc.Pc(o, n);
- }
- t._c.delete(e), t.isPrimaryClient && t.Ic.Is(e).forEach((function(e) {
- t.Ic.containsKey(e) ||
-
- Zs(t, e);
- }));
- }
- function Zs(t, e) {
- t.mc.delete(e.path.canonicalString());
-
-
- var n = t.gc.get(e);
- null !== n && (Wa(t.remoteStore, n), t.gc = t.gc.remove(e), t.yc.delete(n), ec(t));
- }
- function $s(t, e, n) {
- for (var r = 0, i = n; r < i.length; r++) {
- var o = i[r];
- o instanceof Fs ? (t.Ic.addReference(o.key, e), tc(t, o)) : o instanceof Ps ? (M("SyncEngine", "Document no longer in limbo: " + o.key),
- t.Ic.removeReference(o.key, e), t.Ic.containsKey(o.key) ||
-
- Zs(t, o.key)) : U();
- }
- }
- function tc(t, e) {
- var n = e.key, r = n.path.canonicalString();
- t.gc.get(n) || t.mc.has(r) || (M("SyncEngine", "New document in limbo: " + n), t.mc.add(r),
- ec(t));
- }
- function ec(t) {
- for (;t.mc.size > 0 && t.gc.size < t.maxConcurrentLimboResolutions; ) {
- var e = t.mc.values().next().value;
- t.mc.delete(e);
- var n = new pt(ht.fromString(e)), r = t.Ac.next();
- t.yc.set(r, new Ms(n)), t.gc = t.gc.insert(n, r), Qa(t.remoteStore, new ao(tr(Hn(n.path)), r, "TargetPurposeLimboResolution" , Ut.ct));
- }
- }
- function nc(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var o, u, a, s;
- return n(this, (function(c) {
- switch (c.label) {
- case 0:
- return o = j(t), u = [], a = [], s = [], o.wc.isEmpty() ? [ 3 , 3 ] : (o.wc.forEach((function(t, e) {
- s.push(o.Rc(e, r, i).then((function(t) {
-
- if (
-
-
- (t || i) && o.isPrimaryClient && o.sharedClientState.updateQueryState(e.targetId, (null == t ? void 0 : t.fromCache) ? "not-current" : "current"),
- t) {
- u.push(t);
- var n = Zu.Li(e.targetId, t);
- a.push(n);
- }
- })));
- })), [ 4 , Promise.all(s) ]);
- case 1:
- return c.sent(), o.dc.nu(u), [ 4 , function(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o, u, a, s, c, l, h;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- e = j(t), n.label = 1;
- case 1:
- return n.trys.push([ 1, 3, , 4 ]), [ 4 , e.persistence.runTransaction("notifyLocalViewChanges", "readwrite", (function(t) {
- return Nt.forEach(r, (function(n) {
- return Nt.forEach(n.Fi, (function(r) {
- return e.persistence.referenceDelegate.addReference(t, n.targetId, r);
- })).next((function() {
- return Nt.forEach(n.Bi, (function(r) {
- return e.persistence.referenceDelegate.removeReference(t, n.targetId, r);
- }));
- }));
- }));
- })) ];
- case 2:
- return n.sent(), [ 3 , 4 ];
- case 3:
- if (!Pt(i = n.sent())) throw i;
-
-
-
-
- return M("LocalStore", "Failed to update sequence numbers: " + i),
- [ 3 , 4 ];
- case 4:
- for (o = 0, u = r; o < u.length; o++) a = u[o], s = a.targetId, a.fromCache || (c = e.Ji.get(s),
- l = c.snapshotVersion, h = c.withLastLimboFreeSnapshotVersion(l),
-
- e.Ji = e.Ji.insert(s, h));
- return [ 2 ];
- }
- }));
- }));
- }(o.localStore, a) ];
- case 2:
- c.sent(), c.label = 3;
- case 3:
- return [ 2 ];
- }
- }));
- }));
- }
- function rc(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return (e = j(t)).currentUser.isEqual(r) ? [ 3 , 3 ] : (M("SyncEngine", "User change. New user:", r.toKey()),
- [ 4 , na(e.localStore, r) ]);
- case 1:
- return i = n.sent(), e.currentUser = r,
-
- function(t, e) {
- t.Ec.forEach((function(t) {
- t.forEach((function(t) {
- t.reject(new Q(K.CANCELLED, "'waitForPendingWrites' promise is rejected due to a user change."));
- }));
- })), t.Ec.clear();
- }(e),
-
- e.sharedClientState.handleUserChange(r, i.removedBatchIds, i.addedBatchIds), [ 4 , nc(e, i.er) ];
- case 2:
- n.sent(), n.label = 3;
- case 3:
- return [ 2 ];
- }
- }));
- }));
- }
- function ic(t, e) {
- var n = j(t), r = n.yc.get(e);
- if (r && r.fc) return Ir().add(r.key);
- var i = Ir(), o = n._c.get(e);
- if (!o) return i;
- for (var u = 0, a = o; u < a.length; u++) {
- var s = a[u], c = n.wc.get(s);
- i = i.unionWith(c.view.nc);
- }
- return i;
- }
- function oc(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , la((e = j(t)).localStore, r.query,
- !0) ];
- case 1:
- return i = n.sent(), o = r.view.hc(i), [ 2 , (e.isPrimaryClient && $s(e, r.targetId, o.cc),
- o) ];
- }
- }));
- }));
- }
- function uc(t, r) {
- return e(this, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- return [ 2 , fa((e = j(t)).localStore, r).then((function(t) {
- return nc(e, t);
- })) ];
- }));
- }));
- }
- function ac(t, r, i, o) {
- return e(this, void 0, void 0, (function() {
- var e, u;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , function(t, e) {
- var n = j(t), r = j(n.mutationQueue);
- return n.persistence.runTransaction("Lookup mutation documents", "readonly", (function(t) {
- return r.Sn(t, e).next((function(e) {
- return e ? n.localDocuments.getDocuments(t, e) : Nt.resolve(null);
- }));
- }));
- }((e = j(t)).localStore, r) ];
- case 1:
- return null === (u = n.sent()) ? [ 3 , 6 ] : "pending" !== i ? [ 3 , 3 ] : [ 4 , os(e.remoteStore) ];
- case 2:
-
-
-
- return n.sent(), [ 3 , 4 ];
- case 3:
- "acknowledged" === i || "rejected" === i ? (
-
-
- Xs(e, r, o || null), Ys(e, r), function(t, e) {
- j(j(t).mutationQueue).Cn(e);
- }(e.localStore, r)) : U(), n.label = 4;
- case 4:
- return [ 4 , nc(e, u) ];
- case 5:
- return n.sent(), [ 3 , 7 ];
- case 6:
-
-
-
-
-
-
-
- M("SyncEngine", "Cannot apply mutation batch with id: " + r), n.label = 7;
- case 7:
- return [ 2 ];
- }
- }));
- }));
- }
- function sc(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o, u, a, s, c, l;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return pc(e = j(t)), vc(e), !0 !== r || !0 === e.vc ? [ 3 , 3 ] : (i = e.sharedClientState.getAllActiveQueryTargets(),
- [ 4 , cc(e, i.toArray()) ]);
- case 1:
- return o = n.sent(), e.vc = !0, [ 4 , ds(e.remoteStore, !0) ];
- case 2:
- for (n.sent(), u = 0, a = o; u < a.length; u++) s = a[u], Qa(e.remoteStore, s);
- return [ 3 , 7 ];
- case 3:
- return !1 !== r || !1 === e.vc ? [ 3 , 7 ] : (c = [], l = Promise.resolve(),
- e._c.forEach((function(t, n) {
- e.sharedClientState.isLocalQueryTarget(n) ? c.push(n) : l = l.then((function() {
- return Js(e, n), ca(e.localStore, n,
- !0);
- })), Wa(e.remoteStore, n);
- })), [ 4 , l ]);
- case 4:
- return n.sent(), [ 4 , cc(e, c) ];
- case 5:
- return n.sent(),
-
- function(t) {
- var e = j(t);
- e.yc.forEach((function(t, n) {
- Wa(e.remoteStore, n);
- })), e.Ic.Ts(), e.yc = new Map, e.gc = new Te(pt.comparator);
- }(e), e.vc = !1, [ 4 , ds(e.remoteStore, !1) ];
- case 6:
- n.sent(), n.label = 7;
- case 7:
- return [ 2 ];
- }
- }));
- }));
- }
- function cc(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var e, i, o, u, a, s, c, l, h, f, d, p, v, m;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- e = j(t), i = [], o = [], u = 0, a = r, n.label = 1;
- case 1:
- return u < a.length ? (s = a[u], c = void 0, (l = e._c.get(s)) && 0 !== l.length ? [ 4 , sa(e.localStore, tr(l[0])) ] : [ 3 , 7 ]) : [ 3 , 13 ];
- case 2:
-
-
-
-
- c = n.sent(), h = 0, f = l, n.label = 3;
- case 3:
- return h < f.length ? (d = f[h], p = e.wc.get(d), [ 4 , oc(e, p) ]) : [ 3 , 6 ];
- case 4:
- (v = n.sent()).snapshot && o.push(v.snapshot), n.label = 5;
- case 5:
- return h++, [ 3 , 3 ];
- case 6:
- return [ 3 , 11 ];
- case 7:
- return [ 4 , ha(e.localStore, s) ];
- case 8:
- return m = n.sent(), [ 4 , sa(e.localStore, m) ];
- case 9:
- return c = n.sent(), [ 4 , Bs(e, lc(m), s,
- !1, c.resumeToken) ];
- case 10:
- n.sent(), n.label = 11;
- case 11:
- i.push(c), n.label = 12;
- case 12:
- return u++, [ 3 , 1 ];
- case 13:
- return [ 2 , (e.dc.nu(o), i) ];
- }
- }));
- }));
- }
- function lc(t) {
- return Wn(t.path, t.collectionGroup, t.orderBy, t.filters, t.limit, "F" , t.startAt, t.endAt);
- }
- function hc(t) {
- var e = j(t);
- return j(j(e.localStore).persistence).$i();
- }
- function fc(t, r, i, o) {
- return e(this, void 0, void 0, (function() {
- var e, u, a, s;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- if ((e = j(t)).vc)
-
-
- return [ 2 , void M("SyncEngine", "Ignoring unexpected query state notification.") ];
- if (!((u = e._c.get(r)) && u.length > 0)) return [ 3 , 7 ];
- switch (i) {
- case "current":
- case "not-current":
- return [ 3 , 1 ];
- case "rejected":
- return [ 3 , 4 ];
- }
- return [ 3 , 6 ];
- case 1:
- return [ 4 , fa(e.localStore, ar(u[0])) ];
- case 2:
- return a = n.sent(), s = wi.createSynthesizedRemoteEventForCurrentChange(r, "current" === i, Oe.EMPTY_BYTE_STRING),
- [ 4 , nc(e, a, s) ];
- case 3:
- return n.sent(), [ 3 , 7 ];
- case 4:
- return [ 4 , ca(e.localStore, r,
- !0) ];
- case 5:
- return n.sent(), Js(e, r, o), [ 3 , 7 ];
- case 6:
- U(), n.label = 7;
- case 7:
- return [ 2 ];
- }
- }));
- }));
- }
- function dc(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var e, o, u, a, s, c, l, h, f, d;
- return n(this, (function(p) {
- switch (p.label) {
- case 0:
- if (!(e = pc(t)).vc) return [ 3 , 10 ];
- o = 0, u = r, p.label = 1;
- case 1:
- return o < u.length ? (a = u[o], e._c.has(a) ? (
-
- M("SyncEngine", "Adding an already active target " + a), [ 3 , 5 ]) : [ 4 , ha(e.localStore, a) ]) : [ 3 , 6 ];
- case 2:
- return s = p.sent(), [ 4 , sa(e.localStore, s) ];
- case 3:
- return c = p.sent(), [ 4 , Bs(e, lc(s), c.targetId,
- !1, c.resumeToken) ];
- case 4:
- p.sent(), Qa(e.remoteStore, c), p.label = 5;
- case 5:
- return o++, [ 3 , 1 ];
- case 6:
- l = function(t) {
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e._c.has(t) ? [ 4 , ca(e.localStore, t,
- !1).then((function() {
- Wa(e.remoteStore, t), Js(e, t);
- })).catch(xt) ] : [ 3 , 2 ];
-
- case 1:
-
- n.sent(), n.label = 2;
- case 2:
- return [ 2 ];
- }
- }));
- }, h = 0, f = i, p.label = 7;
- case 7:
- return h < f.length ? (d = f[h], [ 5 , l(d) ]) : [ 3 , 10 ];
- case 8:
- p.sent(), p.label = 9;
- case 9:
- return h++, [ 3 , 7 ];
- case 10:
- return [ 2 ];
- }
- }));
- }));
- }
- function pc(t) {
- var e = j(t);
- return e.remoteStore.remoteSyncer.applyRemoteEvent = Gs.bind(null, e), e.remoteStore.remoteSyncer.getRemoteKeysForTarget = ic.bind(null, e),
- e.remoteStore.remoteSyncer.rejectListen = Ks.bind(null, e), e.dc.nu = _s.bind(null, e.eventManager),
- e.dc.Pc = Ds.bind(null, e.eventManager), e;
- }
- function vc(t) {
- var e = j(t);
- return e.remoteStore.remoteSyncer.applySuccessfulWrite = Qs.bind(null, e), e.remoteStore.remoteSyncer.rejectFailedWrite = Ws.bind(null, e),
- e
-
- ;
- }
- function mc(t, r, i) {
- var o = j(t);
-
-
- (function(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var e, o, u, a, s, c;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return n.trys.push([ 0, 14, , 15 ]), [ 4 , r.getMetadata() ];
- case 1:
- return e = n.sent(), [ 4 , function(t, e) {
- var n = j(t), r = Vi(e.createTime);
- return n.persistence.runTransaction("hasNewerBundle", "readonly", (function(t) {
- return n.qs.getBundleMetadata(t, e.id);
- })).then((function(t) {
- return !!t && t.createTime.compareTo(r) >= 0;
- }));
- }(t.localStore, e) ];
- case 2:
- return n.sent() ? [ 4 , r.close() ] : [ 3 , 4 ];
- case 3:
- return [ 2 , (n.sent(), i._completeWith(function(t) {
- return {
- taskState: "Success",
- documentsLoaded: t.totalDocuments,
- bytesLoaded: t.totalBytes,
- totalDocuments: t.totalDocuments,
- totalBytes: t.totalBytes
- };
- }(e)), Promise.resolve(new Set)) ];
- case 4:
- return i._updateProgress(Os(e)), o = new ks(e, t.localStore, r.serializer), [ 4 , r.bc() ];
- case 5:
- u = n.sent(), n.label = 6;
- case 6:
- return u ? [ 4 , o.zu(u) ] : [ 3 , 10 ];
- case 7:
- return (a = n.sent()) && i._updateProgress(a), [ 4 , r.bc() ];
- case 8:
- u = n.sent(), n.label = 9;
- case 9:
- return [ 3 , 6 ];
- case 10:
- return [ 4 , o.complete() ];
- case 11:
- return s = n.sent(), [ 4 , nc(t, s.Ju,
- void 0) ];
- case 12:
-
- return n.sent(), [ 4 , function(t, e) {
- var n = j(t);
- return n.persistence.runTransaction("Save bundle", "readwrite", (function(t) {
- return n.qs.saveBundleMetadata(t, e);
- }));
- }(t.localStore, e) ];
- case 13:
- return [ 2 , (
-
- n.sent(), i._completeWith(s.progress), Promise.resolve(s.Hu)) ];
- case 14:
- return c = n.sent(), [ 2 , (q("SyncEngine", "Loading bundle failed with ".concat(c)),
- i._failWith(c), Promise.resolve(new Set)) ];
- case 15:
- return [ 2 ];
- }
- }));
- }));
- }
-
-
- )(o, r, i).then((function(t) {
- o.sharedClientState.notifyBundleLoaded(t);
- }));
- }
- var yc = function() {
- function t() {
- this.synchronizeTabs = !1;
- }
- return t.prototype.initialize = function(t) {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
- return this.serializer = Va(t.databaseInfo.databaseId), this.sharedClientState = this.createSharedClientState(t),
- this.persistence = this.createPersistence(t), [ 4 , this.persistence.start() ];
- case 1:
- return e.sent(), this.localStore = this.createLocalStore(t), this.gcScheduler = this.createGarbageCollectionScheduler(t, this.localStore),
- this.indexBackfillerScheduler = this.createIndexBackfillerScheduler(t, this.localStore),
- [ 2 ];
- }
- }));
- }));
- }, t.prototype.createGarbageCollectionScheduler = function(t, e) {
- return null;
- }, t.prototype.createIndexBackfillerScheduler = function(t, e) {
- return null;
- }, t.prototype.createLocalStore = function(t) {
- return ea(this.persistence, new $u, t.initialUser, this.serializer);
- }, t.prototype.createPersistence = function(t) {
- return new Uu(Gu.zs, this.serializer);
- }, t.prototype.createSharedClientState = function(t) {
- return new _a;
- }, t.prototype.terminate = function() {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(t) {
- switch (t.label) {
- case 0:
- return this.gcScheduler && this.gcScheduler.stop(), [ 4 , this.sharedClientState.shutdown() ];
- case 1:
- return t.sent(), [ 4 , this.persistence.shutdown() ];
- case 2:
- return t.sent(), [ 2 ];
- }
- }));
- }));
- }, t;
- }(), gc = function(e) {
- function n(t) {
- var n = this;
- return (n = e.call(this) || this).cacheSizeBytes = t, n;
- }
- return t(n, e), n.prototype.createGarbageCollectionScheduler = function(t, e) {
- z(this.persistence.referenceDelegate instanceof ju);
- var n = this.persistence.referenceDelegate.garbageCollector;
- return new yu(n, t.asyncQueue, e);
- }, n.prototype.createPersistence = function(t) {
- var e = void 0 !== this.cacheSizeBytes ? nu.withCacheSize(this.cacheSizeBytes) : nu.DEFAULT;
- return new Uu((function(t) {
- return ju.zs(t, e);
- }), this.serializer);
- }, n;
- }(yc), wc = function(r) {
- function i(t, e, n) {
- var i = this;
- return (i = r.call(this) || this).Vc = t, i.cacheSizeBytes = e, i.forceOwnership = n,
- i.synchronizeTabs = !1, i;
- }
- return t(i, r), i.prototype.initialize = function(t) {
- return e(this, void 0, void 0, (function() {
- var e = this;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , r.prototype.initialize.call(this, t) ];
- case 1:
- return n.sent(), [ 4 , this.Vc.initialize(this, t) ];
- case 2:
-
- return n.sent(), [ 4 , vc(this.Vc.syncEngine) ];
- case 3:
-
- return n.sent(), [ 4 , os(this.Vc.remoteStore) ];
- case 4:
-
-
- return n.sent(), [ 4 , this.persistence.Ii((function() {
- return e.gcScheduler && !e.gcScheduler.started && e.gcScheduler.start(), e.indexBackfillerScheduler && !e.indexBackfillerScheduler.started && e.indexBackfillerScheduler.start(),
- Promise.resolve();
- })) ];
- case 5:
-
-
- return n.sent(), [ 2 ];
- }
- }));
- }));
- }, i.prototype.createLocalStore = function(t) {
- return ea(this.persistence, new $u, t.initialUser, this.serializer);
- }, i.prototype.createGarbageCollectionScheduler = function(t, e) {
- var n = this.persistence.referenceDelegate.garbageCollector;
- return new yu(n, t.asyncQueue, e);
- }, i.prototype.createIndexBackfillerScheduler = function(t, e) {
- var n = new Bt(e, this.persistence);
- return new qt(t.asyncQueue, n);
- }, i.prototype.createPersistence = function(t) {
- var e = Ju(t.databaseInfo.databaseId, t.databaseInfo.persistenceKey), n = void 0 !== this.cacheSizeBytes ? nu.withCacheSize(this.cacheSizeBytes) : nu.DEFAULT;
- return new Hu(this.synchronizeTabs, e, t.clientId, n, t.asyncQueue, Pa(), Ra(), this.serializer, this.sharedClientState, !!this.forceOwnership);
- }, i.prototype.createSharedClientState = function(t) {
- return new _a;
- }, i;
- }(yc), bc = function(r) {
- function i(t, e) {
- var n = this;
- return (n = r.call(this, t, e, !1) || this).Vc = t, n.cacheSizeBytes = e,
- n.synchronizeTabs = !0, n;
- }
- return t(i, r), i.prototype.initialize = function(t) {
- return e(this, void 0, void 0, (function() {
- var i, o = this;
- return n(this, (function(u) {
- switch (u.label) {
- case 0:
- return [ 4 , r.prototype.initialize.call(this, t) ];
- case 1:
- return u.sent(), i = this.Vc.syncEngine, this.sharedClientState instanceof Sa ? (this.sharedClientState.syncEngine = {
- jr: ac.bind(null, i),
- zr: fc.bind(null, i),
- Wr: dc.bind(null, i),
- $i: hc.bind(null, i),
- Qr: uc.bind(null, i)
- }, [ 4 , this.sharedClientState.start() ]) : [ 3 , 3 ];
- case 2:
- u.sent(), u.label = 3;
- case 3:
-
-
- return [ 4 , this.persistence.Ii((function(t) {
- return e(o, void 0, void 0, (function() {
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
- return [ 4 , sc(this.Vc.syncEngine, t) ];
- case 1:
- return e.sent(), this.gcScheduler && (t && !this.gcScheduler.started ? this.gcScheduler.start() : t || this.gcScheduler.stop()),
- this.indexBackfillerScheduler && (t && !this.indexBackfillerScheduler.started ? this.indexBackfillerScheduler.start() : t || this.indexBackfillerScheduler.stop()),
- [ 2 ];
- }
- }));
- }));
- })) ];
- case 4:
-
-
- return u.sent(), [ 2 ];
- }
- }));
- }));
- }, i.prototype.createSharedClientState = function(t) {
- var e = Pa();
- if (!Sa.D(e)) throw new Q(K.UNIMPLEMENTED, "IndexedDB persistence is only available on platforms that support LocalStorage.");
- var n = Ju(t.databaseInfo.databaseId, t.databaseInfo.persistenceKey);
- return new Sa(e, t.asyncQueue, n, t.clientId, t.initialUser);
- }, i;
- }(wc), Ic = function() {
- function t() {}
- return t.prototype.initialize = function(t, r) {
- return e(this, void 0, void 0, (function() {
- var e = this;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return this.localStore ? [ 3 , 2 ] : (this.localStore = t.localStore,
- this.sharedClientState = t.sharedClientState, this.datastore = this.createDatastore(r),
- this.remoteStore = this.createRemoteStore(r), this.eventManager = this.createEventManager(r),
- this.syncEngine = this.createSyncEngine(r,
- !t.synchronizeTabs), this.sharedClientState.onlineStateHandler = function(t) {
- return js(e.syncEngine, t, 1 );
- }, this.remoteStore.remoteSyncer.handleCredentialChange = rc.bind(null, this.syncEngine),
- [ 4 , ds(this.remoteStore, this.syncEngine.isPrimaryClient) ]);
- case 1:
- n.sent(), n.label = 2;
- case 2:
- return [ 2 ];
- }
- }));
- }));
- }, t.prototype.createEventManager = function(t) {
- return new Es;
- }, t.prototype.createDatastore = function(t) {
- var e, n = Va(t.databaseInfo.databaseId), r = (e = t.databaseInfo, new Fa(e));
- return function(t, e, n, r) {
- return new Ua(t, e, n, r);
- }(t.authCredentials, t.appCheckCredentials, r, n);
- }, t.prototype.createRemoteStore = function(t) {
- var e, n, r, i, o, u = this;
- return e = this.localStore, n = this.datastore, r = t.asyncQueue, i = function(t) {
- return js(u.syncEngine, t, 0 );
- }, o = Ca.D() ? new Ca : new Da, new Ga(e, n, r, i, o);
- }, t.prototype.createSyncEngine = function(t, e) {
- return function(t, e, n,
-
- r, i, o, u) {
- var a = new Ls(t, e, n, r, i, o);
- return u && (a.vc = !0), a;
- }(this.localStore, this.remoteStore, this.eventManager, this.sharedClientState, t.initialUser, t.maxConcurrentLimboResolutions, e);
- }, t.prototype.terminate = function() {
- return function(t) {
- return e(this, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = j(t), M("RemoteStore", "RemoteStore shutting down."), e.vu.add(5 ),
- [ 4 , Ka(e) ];
- case 1:
- return n.sent(), e.Pu.shutdown(),
-
-
- e.bu.set("Unknown" ), [ 2 ];
- }
- }));
- }));
- }(this.remoteStore);
- }, t;
- }();
- function Ec(t, r) {
- void 0 === r && (r = 10240);
- var i = 0;
-
-
-
-
- return {
-
- read: function() {
- return e(this, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- return i < t.byteLength ? (e = {
- value: t.slice(i, i + r),
- done: !1
- }, [ 2 , (i += r, e) ]) : [ 2 , {
- done: !0
- } ];
- }));
- }));
- },
- cancel: function() {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(t) {
- return [ 2 ];
- }));
- }));
- },
- releaseLock: function() {},
- closed: Promise.resolve()
- };
- }
- var Tc = function() {
- function t(t) {
- this.observer = t,
-
- this.muted = !1;
- }
- return t.prototype.next = function(t) {
- this.observer.next && this.Sc(this.observer.next, t);
- }, t.prototype.error = function(t) {
- this.observer.error ? this.Sc(this.observer.error, t) : L("Uncaught Error in snapshot listener:", t.toString());
- }, t.prototype.Dc = function() {
- this.muted = !0;
- }, t.prototype.Sc = function(t, e) {
- var n = this;
- this.muted || setTimeout((function() {
- n.muted || t(e);
- }), 0);
- }, t;
- }(), Sc = function() {
- function t(
-
- t, e) {
- var n = this;
- this.Cc = t, this.serializer = e,
-
- this.metadata = new W,
-
- this.buffer = new Uint8Array, this.xc = new TextDecoder("utf-8"),
-
- this.Nc().then((function(t) {
- t && t.Qu() ? n.metadata.resolve(t.Gu.metadata) : n.metadata.reject(new Error("The first element of the bundle is not a metadata, it is\n ".concat(JSON.stringify(null == t ? void 0 : t.Gu))));
- }), (function(t) {
- return n.metadata.reject(t);
- }));
- }
- return t.prototype.close = function() {
- return this.Cc.cancel();
- }, t.prototype.getMetadata = function() {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(t) {
- return [ 2 , this.metadata.promise ];
- }));
- }));
- }, t.prototype.bc = function() {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(t) {
- switch (t.label) {
- case 0:
- return [ 4 , this.getMetadata() ];
- case 1:
-
- return [ 2 , (t.sent(), this.Nc()) ];
- }
- }));
- }));
- },
-
- t.prototype.Nc = function() {
- return e(this, void 0, void 0, (function() {
- var t, e, r, i;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , this.kc() ];
- case 1:
- return null === (t = n.sent()) ? [ 2 , null ] : (e = this.xc.decode(t),
- r = Number(e), isNaN(r) && this.Mc("length string (".concat(e, ") is not valid number")),
- [ 4 , this.$c(r) ]);
- case 2:
- return i = n.sent(), [ 2 , new Ns(JSON.parse(i), t.length + r) ];
- }
- }));
- }));
- },
- t.prototype.Oc = function() {
- return this.buffer.findIndex((function(t) {
- return t === "{".charCodeAt(0);
- }));
- },
-
- t.prototype.kc = function() {
- return e(this, void 0, void 0, (function() {
- var t, e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return this.Oc() < 0 ? [ 4 , this.Fc() ] : [ 3 , 3 ];
- case 1:
- if (n.sent()) return [ 3 , 3 ];
- n.label = 2;
- case 2:
- return [ 3 , 0 ];
- case 3:
-
-
- return 0 === this.buffer.length ? [ 2 , null ] : (
-
-
- (t = this.Oc()) < 0 && this.Mc("Reached the end of bundle when a length string is expected."),
- e = this.buffer.slice(0, t), [ 2 , (this.buffer = this.buffer.slice(t),
- e) ]);
- }
- }));
- }));
- },
-
- t.prototype.$c = function(t) {
- return e(this, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return this.buffer.length < t ? [ 4 , this.Fc() ] : [ 3 , 3 ];
- case 1:
- n.sent() && this.Mc("Reached the end of bundle when more is expected."), n.label = 2;
- case 2:
- return [ 3 , 0 ];
- case 3:
-
- return e = this.xc.decode(this.buffer.slice(0, t)), [ 2 , (this.buffer = this.buffer.slice(t),
- e) ];
- }
- }));
- }));
- }, t.prototype.Mc = function(t) {
-
- throw this.Cc.cancel(), new Error("Invalid bundle format: ".concat(t));
- },
-
- t.prototype.Fc = function() {
- return e(this, void 0, void 0, (function() {
- var t, e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , this.Cc.read() ];
- case 1:
- return (t = n.sent()).done || ((e = new Uint8Array(this.buffer.length + t.value.length)).set(this.buffer),
- e.set(t.value, this.buffer.length), this.buffer = e), [ 2 , t.done ];
- }
- }));
- }));
- }, t;
- }(), _c = function() {
- function t(t) {
- this.datastore = t,
-
- this.readVersions = new Map, this.mutations = [], this.committed = !1,
-
- this.lastWriteError = null,
-
- this.writtenDocs = new Set;
- }
- return t.prototype.lookup = function(t) {
- return e(this, void 0, void 0, (function() {
- var r, i = this;
- return n(this, (function(o) {
- switch (o.label) {
- case 0:
- if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new Q(K.INVALID_ARGUMENT, "Firestore transactions require all reads to be executed before all writes.");
- return [ 4 , function(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o, u, a, s;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = j(t), i = Gi(e.serializer) + "/documents", o = {
- documents: r.map((function(t) {
- return qi(e.serializer, t);
- }))
- }, [ 4 , e.vo("BatchGetDocuments", i, o, r.length) ];
- case 1:
- return u = n.sent(), a = new Map, u.forEach((function(t) {
- var n = function(t, e) {
- return "found" in e ? function(t, e) {
- z(!!e.found), e.found.name, e.found.updateTime;
- var n = Bi(t, e.found.name), r = Vi(e.found.updateTime), i = e.found.createTime ? Vi(e.found.createTime) : ct.min(), o = new hn({
- mapValue: {
- fields: e.found.fields
- }
- });
- return dn.newFoundDocument(n, r, i, o);
- }(t, e) : "missing" in e ? function(t, e) {
- z(!!e.missing), z(!!e.readTime);
- var n = Bi(t, e.missing), r = Vi(e.readTime);
- return dn.newNoDocument(n, r);
- }(t, e) : U();
- }(e.serializer, t);
- a.set(n.key.toString(), n);
- })), s = [], [ 2 , (r.forEach((function(t) {
- var e = a.get(t.toString());
- z(!!e), s.push(e);
- })), s) ];
- }
- }));
- }));
- }(this.datastore, t) ];
- case 1:
- return [ 2 , ((r = o.sent()).forEach((function(t) {
- return i.recordVersion(t);
- })), r) ];
- }
- }));
- }));
- }, t.prototype.set = function(t, e) {
- this.write(e.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
- }, t.prototype.update = function(t, e) {
- try {
- this.write(e.toMutation(t, this.preconditionForUpdate(t)));
- } catch (t) {
- this.lastWriteError = t;
- }
- this.writtenDocs.add(t.toString());
- }, t.prototype.delete = function(t) {
- this.write(new ni(t, this.precondition(t))), this.writtenDocs.add(t.toString());
- }, t.prototype.commit = function() {
- return e(this, void 0, void 0, (function() {
- var t, r = this;
- return n(this, (function(i) {
- switch (i.label) {
- case 0:
- if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
- return t = this.readVersions,
-
- this.mutations.forEach((function(e) {
- t.delete(e.key.toString());
- })),
-
-
- t.forEach((function(t, e) {
- var n = pt.fromPath(e);
- r.mutations.push(new ri(n, r.precondition(n)));
- })), [ 4 , function(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i, o;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = j(t), i = Gi(e.serializer) + "/documents", o = {
- writes: r.map((function(t) {
- return Wi(e.serializer, t);
- }))
- }, [ 4 , e.Io("Commit", i, o) ];
- case 1:
- return n.sent(), [ 2 ];
- }
- }));
- }));
- }(this.datastore, this.mutations) ];
- case 1:
-
- return i.sent(), this.committed = !0, [ 2 ];
- }
- }));
- }));
- }, t.prototype.recordVersion = function(t) {
- var e;
- if (t.isFoundDocument()) e = t.version; else {
- if (!t.isNoDocument()) throw U();
-
- e = ct.min();
- }
- var n = this.readVersions.get(t.key.toString());
- if (n) {
- if (!e.isEqual(n))
-
- throw new Q(K.ABORTED, "Document version changed between two reads.");
- } else this.readVersions.set(t.key.toString(), e);
- },
-
- t.prototype.precondition = function(t) {
- var e = this.readVersions.get(t.toString());
- return !this.writtenDocs.has(t.toString()) && e ? e.isEqual(ct.min()) ? Ur.exists(!1) : Ur.updateTime(e) : Ur.none();
- },
-
- t.prototype.preconditionForUpdate = function(t) {
- var e = this.readVersions.get(t.toString());
-
-
- if (!this.writtenDocs.has(t.toString()) && e) {
- if (e.isEqual(ct.min()))
-
-
-
-
-
-
-
-
-
- throw new Q(K.INVALID_ARGUMENT, "Can't update a document that doesn't exist.");
-
- return Ur.updateTime(e);
- }
-
-
- return Ur.exists(!0);
- }, t.prototype.write = function(t) {
- this.ensureCommitNotCalled(), this.mutations.push(t);
- }, t.prototype.ensureCommitNotCalled = function() {}, t;
- }(), Dc = function() {
- function t(t, e, n, r, i) {
- this.asyncQueue = t, this.datastore = e, this.options = n, this.updateFunction = r,
- this.deferred = i, this.Bc = n.maxAttempts, this.qo = new Ma(this.asyncQueue, "transaction_retry" )
- ;
- }
- return t.prototype.run = function() {
- this.Bc -= 1, this.Lc();
- }, t.prototype.Lc = function() {
- var t = this;
- this.qo.No((function() {
- return e(t, void 0, void 0, (function() {
- var t, e, r = this;
- return n(this, (function(n) {
- return t = new _c(this.datastore), (e = this.qc(t)) && e.then((function(e) {
- r.asyncQueue.enqueueAndForget((function() {
- return t.commit().then((function() {
- r.deferred.resolve(e);
- })).catch((function(t) {
- r.Uc(t);
- }));
- }));
- })).catch((function(t) {
- r.Uc(t);
- })), [ 2 ];
- }));
- }));
- }));
- }, t.prototype.qc = function(t) {
- try {
- var e = this.updateFunction(t);
- return !zt(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
- null);
- } catch (t) {
-
- return this.deferred.reject(t), null;
- }
- }, t.prototype.Uc = function(t) {
- var e = this;
- this.Bc > 0 && this.Kc(t) ? (this.Bc -= 1, this.asyncQueue.enqueueAndForget((function() {
- return e.Lc(), Promise.resolve();
- }))) : this.deferred.reject(t);
- }, t.prototype.Kc = function(t) {
- if ("FirebaseError" === t.name) {
-
-
- var e = t.code;
- return "aborted" === e || "failed-precondition" === e || "already-exists" === e || !ci(e);
- }
- return !1;
- }, t;
- }(), Cc = function() {
- function t(t, r,
-
- i, o) {
- var u = this;
- this.authCredentials = t, this.appCheckCredentials = r, this.asyncQueue = i, this.databaseInfo = o,
- this.user = O.UNAUTHENTICATED, this.clientId = it.A(), this.authCredentialListener = function() {
- return Promise.resolve();
- }, this.appCheckCredentialListener = function() {
- return Promise.resolve();
- }, this.authCredentials.start(i, (function(t) {
- return e(u, void 0, void 0, (function() {
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
- return M("FirestoreClient", "Received user=", t.uid), [ 4 , this.authCredentialListener(t) ];
- case 1:
- return e.sent(), this.user = t, [ 2 ];
- }
- }));
- }));
- })), this.appCheckCredentials.start(i, (function(t) {
- return M("FirestoreClient", "Received new app check token=", t), u.appCheckCredentialListener(t, u.user);
- }));
- }
- return t.prototype.getConfiguration = function() {
- return e(this, void 0, void 0, (function() {
- return n(this, (function(t) {
- return [ 2 , {
- asyncQueue: this.asyncQueue,
- databaseInfo: this.databaseInfo,
- clientId: this.clientId,
- authCredentials: this.authCredentials,
- appCheckCredentials: this.appCheckCredentials,
- initialUser: this.user,
- maxConcurrentLimboResolutions: 100
- } ];
- }));
- }));
- }, t.prototype.setCredentialChangeListener = function(t) {
- this.authCredentialListener = t;
- }, t.prototype.setAppCheckTokenChangeListener = function(t) {
- this.appCheckCredentialListener = t;
- },
-
- t.prototype.verifyNotTerminated = function() {
- if (this.asyncQueue.isShuttingDown) throw new Q(K.FAILED_PRECONDITION, "The client has already been terminated.");
- }, t.prototype.terminate = function() {
- var t = this;
- this.asyncQueue.enterRestrictedMode();
- var r = new W;
- return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((function() {
- return e(t, void 0, void 0, (function() {
- var t, e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return n.trys.push([ 0, 5, , 6 ]), this._onlineComponents ? [ 4 , this._onlineComponents.terminate() ] : [ 3 , 2 ];
- case 1:
- n.sent(), n.label = 2;
- case 2:
- return this._offlineComponents ? [ 4 , this._offlineComponents.terminate() ] : [ 3 , 4 ];
- case 3:
- n.sent(), n.label = 4;
- case 4:
-
-
-
- return this.authCredentials.shutdown(), this.appCheckCredentials.shutdown(), r.resolve(),
- [ 3 , 6 ];
- case 5:
- return t = n.sent(), e = ys(t, "Failed to shutdown persistence"), r.reject(e), [ 3 , 6 ];
- case 6:
- return [ 2 ];
- }
- }));
- }));
- })), r.promise;
- }, t;
- }();
- function xc(t, r) {
- return e(this, void 0, void 0, (function() {
- var i, o, u = this;
- return n(this, (function(a) {
- switch (a.label) {
- case 0:
- return t.asyncQueue.verifyOperationInProgress(), M("FirestoreClient", "Initializing OfflineComponentProvider"),
- [ 4 , t.getConfiguration() ];
- case 1:
- return i = a.sent(), [ 4 , r.initialize(i) ];
- case 2:
- return a.sent(), o = i.initialUser, t.setCredentialChangeListener((function(t) {
- return e(u, void 0, void 0, (function() {
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
- return o.isEqual(t) ? [ 3 , 2 ] : [ 4 , na(r.localStore, t) ];
- case 1:
- e.sent(), o = t, e.label = 2;
- case 2:
- return [ 2 ];
- }
- }));
- }));
- })),
-
-
- r.persistence.setDatabaseDeletedListener((function() {
- return t.terminate();
- })), t._offlineComponents = r, [ 2 ];
- }
- }));
- }));
- }
- function Nc(t, r) {
- return e(this, void 0, void 0, (function() {
- var e, i;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return t.asyncQueue.verifyOperationInProgress(), [ 4 , kc(t) ];
- case 1:
- return e = n.sent(), M("FirestoreClient", "Initializing OnlineComponentProvider"),
- [ 4 , t.getConfiguration() ];
- case 2:
- return i = n.sent(), [ 4 , r.initialize(e, i) ];
- case 3:
- return n.sent(),
-
-
- t.setCredentialChangeListener((function(t) {
- return fs(r.remoteStore, t);
- })), t.setAppCheckTokenChangeListener((function(t, e) {
- return fs(r.remoteStore, e);
- })), t._onlineComponents = r, [ 2 ];
- }
- }));
- }));
- }
- function Ac(t) {
- return "FirebaseError" === t.name ? t.code === K.FAILED_PRECONDITION || t.code === K.UNIMPLEMENTED : !("undefined" != typeof DOMException && t instanceof DOMException) ||
-
-
-
- 22 === t.code || 20 === t.code ||
-
-
- 11 === t.code;
- }
- function kc(t) {
- return e(this, void 0, void 0, (function() {
- var e, r;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- if (t._offlineComponents) return [ 3 , 8 ];
- if (!t._uninitializedComponentsProvider) return [ 3 , 6 ];
- M("FirestoreClient", "Using user provided OfflineComponentProvider"), n.label = 1;
- case 1:
- return n.trys.push([ 1, 3, , 5 ]), [ 4 , xc(t, t._uninitializedComponentsProvider._offline) ];
- case 2:
- return n.sent(), [ 3 , 5 ];
- case 3:
- if (e = n.sent(), !Ac(r = e)) throw r;
- return q("Error using user provided cache. Falling back to memory cache: " + r),
- [ 4 , xc(t, new yc) ];
- case 4:
- return n.sent(), [ 3 , 5 ];
- case 5:
- return [ 3 , 8 ];
- case 6:
- return M("FirestoreClient", "Using default OfflineComponentProvider"), [ 4 , xc(t, new yc) ];
- case 7:
- n.sent(), n.label = 8;
- case 8:
- return [ 2 , t._offlineComponents ];
- }
- }));
- }));
- }
- function Oc(t) {
- return e(this, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return t._onlineComponents ? [ 3 , 5 ] : t._uninitializedComponentsProvider ? (M("FirestoreClient", "Using user provided OnlineComponentProvider"),
- [ 4 , Nc(t, t._uninitializedComponentsProvider._online) ]) : [ 3 , 2 ];
- case 1:
- return e = n.sent(), [ 3 , 4 ];
- case 2:
- return M("FirestoreClient", "Using default OnlineComponentProvider"), [ 4 , Nc(t, new Ic) ];
- case 3:
- e = n.sent(), n.label = 4;
- case 4:
- e, n.label = 5;
- case 5:
- return [ 2 , t._onlineComponents ];
- }
- }));
- }));
- }
- function Fc(t) {
- return kc(t).then((function(t) {
- return t.persistence;
- }));
- }
- function Pc(t) {
- return kc(t).then((function(t) {
- return t.localStore;
- }));
- }
- function Rc(t) {
- return Oc(t).then((function(t) {
- return t.remoteStore;
- }));
- }
- function Vc(t) {
- return Oc(t).then((function(t) {
- return t.syncEngine;
- }));
- }
- function Mc(t) {
- return Oc(t).then((function(t) {
- return t.datastore;
- }));
- }
- function Lc(t) {
- return e(this, void 0, void 0, (function() {
- var e, r;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , Oc(t) ];
- case 1:
- return e = n.sent(), [ 2 , ((r = e.eventManager).onListen = qs.bind(null, e.syncEngine),
- r.onUnlisten = Us.bind(null, e.syncEngine), r) ];
- }
- }));
- }));
- }
- function qc(t, r, i) {
- var o = this;
- void 0 === i && (i = {});
- var u = new W;
- return t.asyncQueue.enqueueAndForget((function() {
- return e(o, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = function(t, e, n, r, i) {
- var o = new Tc({
- next: function(o) {
-
-
- e.enqueueAndForget((function() {
- return Ss(t, u);
- }));
- var a = o.docs.has(n);
- !a && o.fromCache ?
-
-
-
-
-
-
-
- i.reject(new Q(K.UNAVAILABLE, "Failed to get document because the client is offline.")) : a && o.fromCache && r && "server" === r.source ? i.reject(new Q(K.UNAVAILABLE, 'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')) : i.resolve(o);
- },
- error: function(t) {
- return i.reject(t);
- }
- }), u = new xs(Hn(n.path), o, {
- includeMetadataChanges: !0,
- Ku: !0
- });
- return Ts(t, u);
- }, [ 4 , Lc(t) ];
- case 1:
- return [ 2 , e.apply(void 0, [ n.sent(), t.asyncQueue, r, i, u ]) ];
- }
- }));
- }));
- })), u.promise;
- }
- function Bc(t, r, i) {
- var o = this;
- void 0 === i && (i = {});
- var u = new W;
- return t.asyncQueue.enqueueAndForget((function() {
- return e(o, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = function(t, e, n, r, i) {
- var o = new Tc({
- next: function(n) {
-
-
- e.enqueueAndForget((function() {
- return Ss(t, u);
- })), n.fromCache && "server" === r.source ? i.reject(new Q(K.UNAVAILABLE, 'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')) : i.resolve(n);
- },
- error: function(t) {
- return i.reject(t);
- }
- }), u = new xs(n, o, {
- includeMetadataChanges: !0,
- Ku: !0
- });
- return Ts(t, u);
- }, [ 4 , Lc(t) ];
- case 1:
- return [ 2 , e.apply(void 0, [ n.sent(), t.asyncQueue, r, i, u ]) ];
- }
- }));
- }));
- })), u.promise;
- }
- function Uc(t) {
- var e = {};
- return void 0 !== t.timeoutSeconds && (e.timeoutSeconds = t.timeoutSeconds), e
-
- ;
- }
- var zc = new Map;
- function Gc(t, e, n) {
- if (!n) throw new Q(K.INVALID_ARGUMENT, "Function ".concat(t, "() cannot be called with an empty ").concat(e, "."));
- }
- function jc(t, e, n, r) {
- if (!0 === e && !0 === r) throw new Q(K.INVALID_ARGUMENT, "".concat(t, " and ").concat(n, " cannot be used together."));
- }
- function Kc(t) {
- if (!pt.isDocumentKey(t)) throw new Q(K.INVALID_ARGUMENT, "Invalid document reference. Document references must have an even number of segments, but ".concat(t, " has ").concat(t.length, "."));
- }
- function Qc(t) {
- if (pt.isDocumentKey(t)) throw new Q(K.INVALID_ARGUMENT, "Invalid collection reference. Collection references must have an odd number of segments, but ".concat(t, " has ").concat(t.length, "."));
- }
- function Wc(t) {
- if (void 0 === t) return "undefined";
- if (null === t) return "null";
- if ("string" == typeof t) return t.length > 20 && (t = "".concat(t.substring(0, 20), "...")),
- JSON.stringify(t);
- if ("number" == typeof t || "boolean" == typeof t) return "" + t;
- if ("object" == typeof t) {
- if (t instanceof Array) return "an array";
- var e =
-
- function(t) {
- return t.constructor ? t.constructor.name : null;
- }(t);
- return e ? "a custom ".concat(e, " object") : "an object";
- }
- return "function" == typeof t ? "a function" : U();
- }
- function Hc(t,
- e) {
- if ("_delegate" in t && (
-
-
- t = t._delegate), !(t instanceof e)) {
- if (e.name === t.constructor.name) throw new Q(K.INVALID_ARGUMENT, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
- var n = Wc(t);
- throw new Q(K.INVALID_ARGUMENT, "Expected type '".concat(e.name, "', but it was: ").concat(n));
- }
- return t;
- }
- function Yc(t, e) {
- if (e <= 0) throw new Q(K.INVALID_ARGUMENT, "Function ".concat(t, "() requires a positive number, but it was: ").concat(e, "."));
- }
- var Xc = function() {
- function t(t) {
- var e, n;
- if (void 0 === t.host) {
- if (void 0 !== t.ssl) throw new Q(K.INVALID_ARGUMENT, "Can't provide ssl option if host option is not set");
- this.host = "firestore.googleapis.com", this.ssl = !0;
- } else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
- if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
- this.cache = t.localCache, void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
- if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new Q(K.INVALID_ARGUMENT, "cacheSizeBytes must be at least 1048576");
- this.cacheSizeBytes = t.cacheSizeBytes;
- }
- jc("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling),
- this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalForceLongPolling ? this.experimentalAutoDetectLongPolling = !1 : void 0 === t.experimentalAutoDetectLongPolling ? this.experimentalAutoDetectLongPolling = !0 :
-
-
-
- this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
- this.experimentalLongPollingOptions = Uc(null !== (n = t.experimentalLongPollingOptions) && void 0 !== n ? n : {}),
- function(t) {
- if (void 0 !== t.timeoutSeconds) {
- if (isNaN(t.timeoutSeconds)) throw new Q(K.INVALID_ARGUMENT, "invalid long polling timeout: ".concat(t.timeoutSeconds, " (must not be NaN)"));
- if (t.timeoutSeconds < 5) throw new Q(K.INVALID_ARGUMENT, "invalid long polling timeout: ".concat(t.timeoutSeconds, " (minimum allowed value is 5)"));
- if (t.timeoutSeconds > 30) throw new Q(K.INVALID_ARGUMENT, "invalid long polling timeout: ".concat(t.timeoutSeconds, " (maximum allowed value is 30)"));
- }
- }(this.experimentalLongPollingOptions), this.useFetchStreams = !!t.useFetchStreams;
- }
- return t.prototype.isEqual = function(t) {
- return this.host === t.host && this.ssl === t.ssl && this.credentials === t.credentials && this.cacheSizeBytes === t.cacheSizeBytes && this.experimentalForceLongPolling === t.experimentalForceLongPolling && this.experimentalAutoDetectLongPolling === t.experimentalAutoDetectLongPolling && (e = this.experimentalLongPollingOptions,
- n = t.experimentalLongPollingOptions, e.timeoutSeconds === n.timeoutSeconds) && this.ignoreUndefinedProperties === t.ignoreUndefinedProperties && this.useFetchStreams === t.useFetchStreams;
- var e, n;
- }, t;
- }(), Jc = function() {
-
- function t(t, e, n, r) {
- this._authCredentials = t, this._appCheckCredentials = e, this._databaseId = n,
- this._app = r,
-
- this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new Xc({}),
- this._settingsFrozen = !1;
- }
- return Object.defineProperty(t.prototype, "app", {
-
- get: function() {
- if (!this._app) throw new Q(K.FAILED_PRECONDITION, "Firestore was not initialized using the Firebase SDK. 'app' is not available");
- return this._app;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "_initialized", {
- get: function() {
- return this._settingsFrozen;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "_terminated", {
- get: function() {
- return void 0 !== this._terminateTask;
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype._setSettings = function(t) {
- if (this._settingsFrozen) throw new Q(K.FAILED_PRECONDITION, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
- this._settings = new Xc(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
- if (!t) return new Y;
- switch (t.type) {
- case "firstParty":
- return new $(t.sessionIndex || "0", t.iamToken || null, t.authTokenFactory || null);
- case "provider":
- return t.client;
- default:
- throw new Q(K.INVALID_ARGUMENT, "makeAuthCredentialsProvider failed due to invalid credential type");
- }
- }(t.credentials));
- }, t.prototype._getSettings = function() {
- return this._settings;
- }, t.prototype._freezeSettings = function() {
- return this._settingsFrozen = !0, this._settings;
- }, t.prototype._delete = function() {
- return this._terminateTask || (this._terminateTask = this._terminate()), this._terminateTask;
- },
- t.prototype.toJSON = function() {
- return {
- app: this._app,
- databaseId: this._databaseId,
- settings: this._settings
- };
- },
-
- t.prototype._terminate = function() {
-
- return t = this, (e = zc.get(t)) && (M("ComponentProvider", "Removing Datastore"),
- zc.delete(t), e.terminate()), Promise.resolve();
- var t, e;
- }, t;
- }();
- function Zc(t, e, n, r) {
- var i;
- void 0 === r && (r = {});
- var o = (t = Hc(t, Jc))._getSettings(), u = "".concat(e, ":").concat(n);
- if ("firestore.googleapis.com" !== o.host && o.host !== u && q("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),
- t._setSettings(Object.assign(Object.assign({}, o), {
- host: u,
- ssl: !1
- })), r.mockUserToken) {
- var a, s;
- if ("string" == typeof r.mockUserToken) a = r.mockUserToken, s = O.MOCK_USER; else {
-
-
- a = y(r.mockUserToken, null === (i = t._app) || void 0 === i ? void 0 : i.options.projectId);
- var c = r.mockUserToken.sub || r.mockUserToken.user_id;
- if (!c) throw new Q(K.INVALID_ARGUMENT, "mockUserToken must contain 'sub' or 'user_id' field!");
- s = new O(c);
- }
- t._authCredentials = new X(new H(a, s));
- }
- }
- var $c = function() {
-
- function t(t,
-
- e, n) {
- this.converter = e, this._key = n,
-
- this.type = "document", this.firestore = t;
- }
- return Object.defineProperty(t.prototype, "_path", {
- get: function() {
- return this._key.path;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "id", {
-
- get: function() {
- return this._key.path.lastSegment();
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "path", {
-
- get: function() {
- return this._key.path.canonicalString();
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "parent", {
-
- get: function() {
- return new el(this.firestore, this.converter, this._key.path.popLast());
- },
- enumerable: !1,
- configurable: !0
- }), t.prototype.withConverter = function(e) {
- return new t(this.firestore, e, this._key);
- }, t;
- }(), tl = function() {
-
-
- function t(t,
-
- e, n) {
- this.converter = e, this._query = n,
-
- this.type = "query", this.firestore = t;
- }
- return t.prototype.withConverter = function(e) {
- return new t(this.firestore, e, this._query);
- }, t;
- }(), el = function(e) {
-
- function n(t, n, r) {
- var i = this;
- return (i = e.call(this, t, n, Hn(r)) || this)._path = r,
-
- i.type = "collection", i;
- }
- return t(n, e), Object.defineProperty(n.prototype, "id", {
- get: function() {
- return this._query.path.lastSegment();
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(n.prototype, "path", {
-
- get: function() {
- return this._query.path.canonicalString();
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(n.prototype, "parent", {
-
- get: function() {
- var t = this._path.popLast();
- return t.isEmpty() ? null : new $c(this.firestore,
- null, new pt(t));
- },
- enumerable: !1,
- configurable: !0
- }), n.prototype.withConverter = function(t) {
- return new n(this.firestore, t, this._path);
- }, n;
- }(tl);
- function nl(t, e) {
- for (var n = [], i = 2; i < arguments.length; i++) n[i - 2] = arguments[i];
- if (t = v(t), Gc("collection", "path", e), t instanceof Jc) {
- var o = ht.fromString.apply(ht, r([ e ], n, !1));
- return Qc(o), new el(t, null, o);
- }
- if (!(t instanceof $c || t instanceof el)) throw new Q(K.INVALID_ARGUMENT, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
- var u = t._path.child(ht.fromString.apply(ht, r([ e ], n, !1)));
- return Qc(u), new el(t.firestore,
- null, u);
- }
- function rl(t, e) {
- if (t = Hc(t, Jc), Gc("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new Q(K.INVALID_ARGUMENT, "Invalid collection ID '".concat(e, "' passed to function collectionGroup(). Collection IDs must not contain '/'."));
- return new tl(t,
- null, function(t) {
- return new Qn(ht.emptyPath(), t);
- }(e));
- }
- function il(t, e) {
- for (var n = [], i = 2; i < arguments.length; i++) n[i - 2] = arguments[i];
- if (t = v(t),
-
-
- 1 === arguments.length && (e = it.A()), Gc("doc", "path", e), t instanceof Jc) {
- var o = ht.fromString.apply(ht, r([ e ], n, !1));
- return Kc(o), new $c(t,
- null, new pt(o));
- }
- if (!(t instanceof $c || t instanceof el)) throw new Q(K.INVALID_ARGUMENT, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
- var u = t._path.child(ht.fromString.apply(ht, r([ e ], n, !1)));
- return Kc(u), new $c(t.firestore, t instanceof el ? t.converter : null, new pt(u));
- }
- function ol(t, e) {
- return t = v(t), e = v(e), (t instanceof $c || t instanceof el) && (e instanceof $c || e instanceof el) && t.firestore === e.firestore && t.path === e.path && t.converter === e.converter
-
- ;
- }
- function ul(t, e) {
- return t = v(t), e = v(e), t instanceof tl && e instanceof tl && t.firestore === e.firestore && rr(t._query, e._query) && t.converter === e.converter
-
- ;
- }
- var al = function() {
- function t() {
- var t = this;
-
- this.Gc = Promise.resolve(),
-
-
- this.Qc = [],
-
-
- this.jc = !1,
-
-
- this.zc = [],
-
- this.Wc = null,
-
-
- this.Hc = !1,
-
- this.Jc = !1,
-
- this.Yc = [],
-
- this.qo = new Ma(this, "async_queue_retry" ),
-
-
-
- this.Xc = function() {
- var e = Ra();
- e && M("AsyncQueue", "Visibility state changed to " + e.visibilityState), t.qo.Mo();
- };
- var e = Ra();
- e && "function" == typeof e.addEventListener && e.addEventListener("visibilitychange", this.Xc);
- }
- return Object.defineProperty(t.prototype, "isShuttingDown", {
- get: function() {
- return this.jc;
- },
- enumerable: !1,
- configurable: !0
- }),
-
- t.prototype.enqueueAndForget = function(t) {
-
- this.enqueue(t);
- }, t.prototype.enqueueAndForgetEvenWhileRestricted = function(t) {
- this.Zc(),
-
- this.ta(t);
- }, t.prototype.enterRestrictedMode = function(t) {
- if (!this.jc) {
- this.jc = !0, this.Jc = t || !1;
- var e = Ra();
- e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Xc);
- }
- }, t.prototype.enqueue = function(t) {
- var e = this;
- if (this.Zc(), this.jc)
-
- return new Promise((function() {}));
-
-
-
- var n = new W;
- return this.ta((function() {
- return e.jc && e.Jc ? Promise.resolve() : (t().then(n.resolve, n.reject), n.promise);
- })).then((function() {
- return n.promise;
- }));
- }, t.prototype.enqueueRetryable = function(t) {
- var e = this;
- this.enqueueAndForget((function() {
- return e.Qc.push(t), e.ea();
- }));
- },
-
- t.prototype.ea = function() {
- return e(this, void 0, void 0, (function() {
- var t, e = this;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- if (0 === this.Qc.length) return [ 3 , 5 ];
- n.label = 1;
- case 1:
- return n.trys.push([ 1, 3, , 4 ]), [ 4 , this.Qc[0]() ];
- case 2:
- return n.sent(), this.Qc.shift(), this.qo.reset(), [ 3 , 4 ];
- case 3:
- if (!Pt(t = n.sent())) throw t;
-
- return M("AsyncQueue", "Operation failed with retryable error: " + t),
- [ 3 , 4 ];
- case 4:
- this.Qc.length > 0 &&
-
-
-
-
-
-
-
-
-
-
- this.qo.No((function() {
- return e.ea();
- })), n.label = 5;
- case 5:
- return [ 2 ];
- }
- }));
- }));
- }, t.prototype.ta = function(t) {
- var e = this, n = this.Gc.then((function() {
- return e.Hc = !0, t().catch((function(t) {
- e.Wc = t, e.Hc = !1;
- var n =
-
- function(t) {
- var e = t.message || "";
- return t.stack && (e = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack),
- e;
- }(t);
-
-
-
- throw L("INTERNAL UNHANDLED ERROR: ", n), t;
- })).then((function(t) {
- return e.Hc = !1, t;
- }));
- }));
- return this.Gc = n, n;
- }, t.prototype.enqueueAfterDelay = function(t, e, n) {
- var r = this;
- this.Zc(),
-
- this.Yc.indexOf(t) > -1 && (e = 0);
- var i = ms.createAndSchedule(this, t, e, n, (function(t) {
- return r.na(t);
- }));
- return this.zc.push(i), i;
- }, t.prototype.Zc = function() {
- this.Wc && U();
- }, t.prototype.verifyOperationInProgress = function() {},
-
- t.prototype.sa = function() {
- return e(this, void 0, void 0, (function() {
- var t;
- return n(this, (function(e) {
- switch (e.label) {
- case 0:
- return [ 4 , t = this.Gc ];
- case 1:
- e.sent(), e.label = 2;
- case 2:
- if (t !== this.Gc) return [ 3 , 0 ];
- e.label = 3;
- case 3:
- return [ 2 ];
- }
- }));
- }));
- },
-
- t.prototype.ia = function(t) {
- for (var e = 0, n = this.zc; e < n.length; e++) {
- if (n[e].timerId === t) return !0;
- }
- return !1;
- },
-
- t.prototype.ra = function(t) {
- var e = this;
-
- return this.sa().then((function() {
-
- e.zc.sort((function(t, e) {
- return t.targetTimeMs - e.targetTimeMs;
- }));
- for (var n = 0, r = e.zc; n < r.length; n++) {
- var i = r[n];
- if (i.skipDelay(), "all" !== t && i.timerId === t) break;
- }
- return e.sa();
- }));
- },
-
- t.prototype.oa = function(t) {
- this.Yc.push(t);
- },
- t.prototype.na = function(t) {
-
- var e = this.zc.indexOf(t);
- this.zc.splice(e, 1);
- }, t;
- }();
- function sl(t) {
-
- return function(t, e) {
- if ("object" != typeof t || null === t) return !1;
- for (var n = t, r = 0, i = [ "next", "error", "complete" ]; r < i.length; r++) {
- var o = i[r];
- if (o in n && "function" == typeof n[o]) return !0;
- }
- return !1;
- }(t);
- }
- var cl = function() {
- function t() {
- this._progressObserver = {}, this._taskCompletionResolver = new W, this._lastProgress = {
- taskState: "Running",
- totalBytes: 0,
- totalDocuments: 0,
- bytesLoaded: 0,
- documentsLoaded: 0
- }
-
- ;
- }
- return t.prototype.onProgress = function(t, e, n) {
- this._progressObserver = {
- next: t,
- error: e,
- complete: n
- };
- },
-
- t.prototype.catch = function(t) {
- return this._taskCompletionResolver.promise.catch(t);
- },
-
- t.prototype.then = function(t, e) {
- return this._taskCompletionResolver.promise.then(t, e);
- },
-
- t.prototype._completeWith = function(t) {
- this._updateProgress(t), this._progressObserver.complete && this._progressObserver.complete(),
- this._taskCompletionResolver.resolve(t);
- },
-
- t.prototype._failWith = function(t) {
- this._lastProgress.taskState = "Error", this._progressObserver.next && this._progressObserver.next(this._lastProgress),
- this._progressObserver.error && this._progressObserver.error(t), this._taskCompletionResolver.reject(t);
- },
-
- t.prototype._updateProgress = function(t) {
- this._lastProgress = t, this._progressObserver.next && this._progressObserver.next(t);
- }, t;
- }(), ll = -1, hl = function(e) {
-
- function n(t, n, r, i) {
- var o = this;
-
- return (o = e.call(this, t, n, r, i) || this).type = "firestore", o._queue = new al,
- o._persistenceKey = (null == i ? void 0 : i.name) || "[DEFAULT]", o;
- }
- return t(n, e), n.prototype._terminate = function() {
- return this._firestoreClient ||
-
-
- vl(this), this._firestoreClient.terminate();
- }, n;
- }(Jc);
- function fl(t, e, n) {
- n || (n = "(default)");
- var r = _getProvider(t, "firestore");
- if (r.isInitialized(n)) {
- var i = r.getImmediate({
- identifier: n
- }), o = r.getOptions(n);
- if (g(o, e)) return i;
- throw new Q(K.FAILED_PRECONDITION, "initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.");
- }
- if (void 0 !== e.cacheSizeBytes && void 0 !== e.localCache) throw new Q(K.INVALID_ARGUMENT, "cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");
- if (void 0 !== e.cacheSizeBytes && -1 !== e.cacheSizeBytes && e.cacheSizeBytes < 1048576) throw new Q(K.INVALID_ARGUMENT, "cacheSizeBytes must be at least 1048576");
- return r.initialize({
- options: e,
- instanceIdentifier: n
- });
- }
- function dl(t, e) {
- var n = "object" == typeof t ? t : a(), i = "string" == typeof t ? t : e || "(default)", o = _getProvider(n, "firestore").getImmediate({
- identifier: i
- });
- if (!o._initialized) {
- var u = w("firestore");
- u && Zc.apply(void 0, r([ o ], u, !1));
- }
- return o;
- }
- function pl(t) {
- return t._firestoreClient || vl(t), t._firestoreClient.verifyNotTerminated(), t._firestoreClient;
- }
- function vl(t) {
- var e, n, r, i = t._freezeSettings(), o = function(t, e, n, r) {
- return new Be(t, e, n, r.host, r.ssl, r.experimentalForceLongPolling, r.experimentalAutoDetectLongPolling, Uc(r.experimentalLongPollingOptions), r.useFetchStreams);
- }(t._databaseId, (null === (e = t._app) || void 0 === e ? void 0 : e.options.appId) || "", t._persistenceKey, i);
- t._firestoreClient = new Cc(t._authCredentials, t._appCheckCredentials, t._queue, o),
- (null === (n = i.cache) || void 0 === n ? void 0 : n._offlineComponentProvider) && (null === (r = i.cache) || void 0 === r ? void 0 : r._onlineComponentProvider) && (t._firestoreClient._uninitializedComponentsProvider = {
- _offlineKind: i.cache.kind,
- _offline: i.cache._offlineComponentProvider,
- _online: i.cache._onlineComponentProvider
- });
- }
- function ml(t, e) {
- Dl(t = Hc(t, hl));
- var n = pl(t);
- if (n._uninitializedComponentsProvider) throw new Q(K.FAILED_PRECONDITION, "SDK cache is already specified.");
- q("enableIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");
- var r = t._freezeSettings(), i = new Ic;
- return gl(n, i, new wc(i, r.cacheSizeBytes, null == e ? void 0 : e.forceOwnership));
- }
- function yl(t) {
- Dl(t = Hc(t, hl));
- var e = pl(t);
- if (e._uninitializedComponentsProvider) throw new Q(K.FAILED_PRECONDITION, "SDK cache is already specified.");
- q("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");
- var n = t._freezeSettings(), r = new Ic;
- return gl(e, r, new bc(r, n.cacheSizeBytes));
- }
- function gl(t, r, i) {
- var o = this, u = new W;
- return t.asyncQueue.enqueue((function() {
- return e(o, void 0, void 0, (function() {
- var e, o;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return n.trys.push([ 0, 3, , 4 ]), [ 4 , xc(t, i) ];
- case 1:
- return n.sent(), [ 4 , Nc(t, r) ];
- case 2:
- return n.sent(), u.resolve(), [ 3 , 4 ];
- case 3:
- if (e = n.sent(), !Ac(o = e)) throw o;
- return q("Error enabling indexeddb cache. Falling back to memory cache: " + o),
- u.reject(o), [ 3 , 4 ];
- case 4:
- return [ 2 ];
- }
- }));
- }));
- })).then((function() {
- return u.promise;
- }));
- }
- function wl(t) {
- var r = this;
- if (t._initialized && !t._terminated) throw new Q(K.FAILED_PRECONDITION, "Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");
- var i = new W;
- return t._queue.enqueueAndForgetEvenWhileRestricted((function() {
- return e(r, void 0, void 0, (function() {
- var r;
- return n(this, (function(o) {
- switch (o.label) {
- case 0:
- return o.trys.push([ 0, 2, , 3 ]), [ 4 , function(t) {
- return e(this, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return kt.D() ? (e = t + "main", [ 4 , kt.delete(e) ]) : [ 2 , Promise.resolve() ];
- case 1:
- return n.sent(), [ 2 ];
- }
- }));
- }));
- }(Ju(t._databaseId, t._persistenceKey)) ];
- case 1:
- return o.sent(), i.resolve(), [ 3 , 3 ];
- case 2:
- return r = o.sent(), i.reject(r), [ 3 , 3 ];
- case 3:
- return [ 2 ];
- }
- }));
- }));
- })), i.promise
-
- ;
- }
- function bl(t) {
- return function(t) {
- var r = this, i = new W;
- return t.asyncQueue.enqueueAndForget((function() {
- return e(r, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = Hs, [ 4 , Vc(t) ];
- case 1:
- return [ 2 , e.apply(void 0, [ n.sent(), i ]) ];
- }
- }));
- }));
- })), i.promise;
- }(pl(t = Hc(t, hl)));
- }
- function Il(t) {
- return function(t) {
- var r = this;
- return t.asyncQueue.enqueue((function() {
- return e(r, void 0, void 0, (function() {
- var e, r;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , Fc(t) ];
- case 1:
- return e = n.sent(), [ 4 , Rc(t) ];
- case 2:
- return r = n.sent(), [ 2 , (e.setNetworkEnabled(!0), function(t) {
- var e = j(t);
- return e.vu.delete(0 ), ja(e);
- }(r)) ];
- }
- }));
- }));
- }));
- }
- (pl(t = Hc(t, hl)));
- }
- function El(t) {
- return function(t) {
- var r = this;
- return t.asyncQueue.enqueue((function() {
- return e(r, void 0, void 0, (function() {
- var r, i;
- return n(this, (function(o) {
- switch (o.label) {
- case 0:
- return [ 4 , Fc(t) ];
- case 1:
- return r = o.sent(), [ 4 , Rc(t) ];
- case 2:
- return i = o.sent(), [ 2 , (r.setNetworkEnabled(!1), function(t) {
- return e(this, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return (e = j(t)).vu.add(0 ), [ 4 , Ka(e) ];
- case 1:
- return n.sent(),
-
- e.bu.set("Offline" ), [ 2 ];
- }
- }));
- }));
- }(i)) ];
- }
- }));
- }));
- }));
- }
-
- (pl(t = Hc(t, hl)));
- }
- function Tl(t) {
- return s(t.app, "firestore", t._databaseId.database), t._delete()
-
- ;
- }
- function Sl(t, r) {
- var i = pl(t = Hc(t, hl)), o = new cl;
-
- return function(t, r, i, o) {
- var u = this, a = function(t, e) {
- return function(t, e) {
- return new Sc(t, e);
- }(function(t, e) {
- if (t instanceof Uint8Array) return Ec(t, e);
- if (t instanceof ArrayBuffer) return Ec(new Uint8Array(t), e);
- if (t instanceof ReadableStream) return t.getReader();
- throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream");
- }("string" == typeof t ? di().encode(t) : t), e);
- }(i, Va(r));
- t.asyncQueue.enqueueAndForget((function() {
- return e(u, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = mc, [ 4 , Vc(t) ];
- case 1:
- return e.apply(void 0, [ n.sent(), a, o ]), [ 2 ];
- }
- }));
- }));
- }));
- }(i, t._databaseId, r, o), o
-
- ;
- }
- function _l(t, r) {
- return function(t, r) {
- var i = this;
- return t.asyncQueue.enqueue((function() {
- return e(i, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = function(t, e) {
- var n = j(t);
- return n.persistence.runTransaction("Get named query", "readonly", (function(t) {
- return n.qs.getNamedQuery(t, e);
- }));
- }, [ 4 , Pc(t) ];
- case 1:
- return [ 2 , e.apply(void 0, [ n.sent(), r ]) ];
- }
- }));
- }));
- }));
- }(pl(t = Hc(t, hl)), r).then((function(e) {
- return e ? new tl(t, null, e.query) : null;
- }));
- }
- function Dl(t) {
- if (t._initialized || t._terminated) throw new Q(K.FAILED_PRECONDITION, "Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.");
- }
- var Cl =
- function(
- t, e) {
- void 0 === t && (t = "count"), this._aggregateType = t, this._internalFieldPath = e,
-
- this.type = "AggregateField";
- }, xl = function() {
-
- function t(t, e, n) {
- this._userDataWriter = e, this._data = n,
-
- this.type = "AggregateQuerySnapshot", this.query = t
-
- ;
- }
- return t.prototype.data = function() {
- return this._userDataWriter.convertObjectMap(this._data);
- }, t;
- }(), Nl = function() {
-
- function t(t) {
- this._byteString = t;
- }
-
- return t.fromBase64String = function(e) {
- try {
- return new t(Oe.fromBase64String(e));
- } catch (e) {
- throw new Q(K.INVALID_ARGUMENT, "Failed to construct data from Base64 string: " + e);
- }
- },
-
- t.fromUint8Array = function(e) {
- return new t(Oe.fromUint8Array(e));
- },
-
- t.prototype.toBase64 = function() {
- return this._byteString.toBase64();
- },
-
- t.prototype.toUint8Array = function() {
- return this._byteString.toUint8Array();
- },
-
- t.prototype.toString = function() {
- return "Bytes(base64: " + this.toBase64() + ")";
- },
-
- t.prototype.isEqual = function(t) {
- return this._byteString.isEqual(t._byteString);
- }, t;
- }(), Al = function() {
-
- function t() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
- for (var n = 0; n < t.length; ++n) if (0 === t[n].length) throw new Q(K.INVALID_ARGUMENT, "Invalid field name at argument $(i + 1). Field names must not be empty.");
- this._internalPath = new dt(t);
- }
-
- return t.prototype.isEqual = function(t) {
- return this._internalPath.isEqual(t._internalPath);
- }, t;
- }();
- function kl() {
- return new Al("__name__");
- }
- var Ol =
- function(t) {
- this._methodName = t;
- }, Fl = function() {
-
- function t(t, e) {
- if (!isFinite(t) || t < -90 || t > 90) throw new Q(K.INVALID_ARGUMENT, "Latitude must be a number between -90 and 90, but was: " + t);
- if (!isFinite(e) || e < -180 || e > 180) throw new Q(K.INVALID_ARGUMENT, "Longitude must be a number between -180 and 180, but was: " + e);
- this._lat = t, this._long = e;
- }
- return Object.defineProperty(t.prototype, "latitude", {
-
- get: function() {
- return this._lat;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "longitude", {
-
- get: function() {
- return this._long;
- },
- enumerable: !1,
- configurable: !0
- }),
-
- t.prototype.isEqual = function(t) {
- return this._lat === t._lat && this._long === t._long;
- },
- t.prototype.toJSON = function() {
- return {
- latitude: this._lat,
- longitude: this._long
- };
- },
-
- t.prototype._compareTo = function(t) {
- return ot(this._lat, t._lat) || ot(this._long, t._long);
- }, t;
- }(), Pl = /^__.*__$/, Rl = function() {
- function t(t, e, n) {
- this.data = t, this.fieldMask = e, this.fieldTransforms = n;
- }
- return t.prototype.toMutation = function(t, e) {
- return null !== this.fieldMask ? new Xr(t, this.data, this.fieldMask, e, this.fieldTransforms) : new Yr(t, this.data, e, this.fieldTransforms);
- }, t;
- }(), Vl = function() {
- function t(t,
-
- e, n) {
- this.data = t, this.fieldMask = e, this.fieldTransforms = n;
- }
- return t.prototype.toMutation = function(t, e) {
- return new Xr(t, this.data, this.fieldMask, e, this.fieldTransforms);
- }, t;
- }();
- function Ml(t) {
- switch (t) {
- case 0 :
-
- case 2 :
-
- case 1 :
- return !0;
- case 3 :
- case 4 :
- return !1;
- default:
- throw U();
- }
- }
- var Ll = function() {
-
- function t(t, e, n, r, i, o) {
- this.settings = t, this.databaseId = e, this.serializer = n, this.ignoreUndefinedProperties = r,
-
-
- void 0 === i && this.ua(), this.fieldTransforms = i || [], this.fieldMask = o || [];
- }
- return Object.defineProperty(t.prototype, "path", {
- get: function() {
- return this.settings.path;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "ca", {
- get: function() {
- return this.settings.ca;
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.aa = function(e) {
- return new t(Object.assign(Object.assign({}, this.settings), e), this.databaseId, this.serializer, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
- }, t.prototype.ha = function(t) {
- var e, n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.aa({
- path: n,
- la: !1
- });
- return r.fa(t), r;
- }, t.prototype.da = function(t) {
- var e, n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.aa({
- path: n,
- la: !1
- });
- return r.ua(), r;
- }, t.prototype.wa = function(t) {
-
-
- return this.aa({
- path: void 0,
- la: !0
- });
- }, t.prototype._a = function(t) {
- return ih(t, this.settings.methodName, this.settings.ma || !1, this.path, this.settings.ga);
- },
- t.prototype.contains = function(t) {
- return void 0 !== this.fieldMask.find((function(e) {
- return t.isPrefixOf(e);
- })) || void 0 !== this.fieldTransforms.find((function(e) {
- return t.isPrefixOf(e.field);
- }));
- }, t.prototype.ua = function() {
-
-
- if (this.path) for (var t = 0; t < this.path.length; t++) this.fa(this.path.get(t));
- }, t.prototype.fa = function(t) {
- if (0 === t.length) throw this._a("Document fields must not be empty");
- if (Ml(this.ca) && Pl.test(t)) throw this._a('Document fields cannot begin and end with "__"');
- }, t;
- }(), ql = function() {
- function t(t, e, n) {
- this.databaseId = t, this.ignoreUndefinedProperties = e, this.serializer = n || Va(t)
- ;
- }
- return t.prototype.ya = function(t, e, n, r) {
- return void 0 === r && (r = !1), new Ll({
- ca: t,
- methodName: e,
- ga: n,
- path: dt.emptyPath(),
- la: !1,
- ma: r
- }, this.databaseId, this.serializer, this.ignoreUndefinedProperties);
- }, t;
- }();
- function Bl(t) {
- var e = t._freezeSettings(), n = Va(t._databaseId);
- return new ql(t._databaseId, !!e.ignoreUndefinedProperties, n);
- }
- function Ul(t, e, n, r, i, o) {
- void 0 === o && (o = {});
- var u = t.ya(o.merge || o.mergeFields ? 2 : 0 , e, n, i);
- th("Data must be an object, but it was:", u, r);
- var a, s, c = Zl(r, u);
- if (o.merge) a = new Ne(u.fieldMask), s = u.fieldTransforms; else if (o.mergeFields) {
- for (var l = [], h = 0, f = o.mergeFields; h < f.length; h++) {
- var d = eh(e, f[h], n);
- if (!u.contains(d)) throw new Q(K.INVALID_ARGUMENT, "Field '".concat(d, "' is specified in your field mask but missing from your input data."));
- oh(l, d) || l.push(d);
- }
- a = new Ne(l), s = u.fieldTransforms.filter((function(t) {
- return a.covers(t.field);
- }));
- } else a = null, s = u.fieldTransforms;
- return new Rl(new hn(c), a, s);
- }
- var zl = function(e) {
- function n() {
- return null !== e && e.apply(this, arguments) || this;
- }
- return t(n, e), n.prototype._toFieldTransform = function(t) {
- if (2 !== t.ca) throw 1 === t.ca ? t._a("".concat(this._methodName, "() can only appear at the top level of your update data")) : t._a("".concat(this._methodName, "() cannot be used with set() unless you pass {merge:true}"));
-
-
- return t.fieldMask.push(t.path), null;
- }, n.prototype.isEqual = function(t) {
- return t instanceof n;
- }, n;
- }(Ol);
- function Gl(t, e, n) {
- return new Ll({
- ca: 3 ,
- ga: e.settings.ga,
- methodName: t._methodName,
- la: n
- }, e.databaseId, e.serializer, e.ignoreUndefinedProperties);
- }
- var jl = function(e) {
- function n() {
- return null !== e && e.apply(this, arguments) || this;
- }
- return t(n, e), n.prototype._toFieldTransform = function(t) {
- return new qr(t.path, new kr);
- }, n.prototype.isEqual = function(t) {
- return t instanceof n;
- }, n;
- }(Ol), Kl = function(e) {
- function n(t, n) {
- var r = this;
- return (r = e.call(this, t) || this).pa = n, r;
- }
- return t(n, e), n.prototype._toFieldTransform = function(t) {
- var e = Gl(this, t,
- !0), n = this.pa.map((function(t) {
- return Jl(t, e);
- })), r = new Or(n);
- return new qr(t.path, r);
- }, n.prototype.isEqual = function(t) {
-
- return this === t;
- }, n;
- }(Ol), Ql = function(e) {
- function n(t, n) {
- var r = this;
- return (r = e.call(this, t) || this).pa = n, r;
- }
- return t(n, e), n.prototype._toFieldTransform = function(t) {
- var e = Gl(this, t,
- !0), n = this.pa.map((function(t) {
- return Jl(t, e);
- })), r = new Pr(n);
- return new qr(t.path, r);
- }, n.prototype.isEqual = function(t) {
-
- return this === t;
- }, n;
- }(Ol), Wl = function(e) {
- function n(t, n) {
- var r = this;
- return (r = e.call(this, t) || this).Ia = n, r;
- }
- return t(n, e), n.prototype._toFieldTransform = function(t) {
- var e = new Vr(t.serializer, Dr(t.serializer, this.Ia));
- return new qr(t.path, e);
- }, n.prototype.isEqual = function(t) {
-
- return this === t;
- }, n;
- }(Ol);
- function Hl(t, e, n, r) {
- var i = t.ya(1 , e, n);
- th("Data must be an object, but it was:", i, r);
- var o = [], u = hn.empty();
- Ie(r, (function(t, r) {
- var a = rh(e, t, n);
-
-
- r = v(r);
- var s = i.da(a);
- if (r instanceof zl)
-
- o.push(a); else {
- var c = Jl(r, s);
- null != c && (o.push(a), u.set(a, c));
- }
- }));
- var a = new Ne(o);
- return new Vl(u, a, i.fieldTransforms);
- }
- function Yl(t, e, n, r, i, o) {
- var u = t.ya(1 , e, n), a = [ eh(e, r, n) ], s = [ i ];
- if (o.length % 2 != 0) throw new Q(K.INVALID_ARGUMENT, "Function ".concat(e, "() needs to be called with an even number of arguments that alternate between field names and values."));
- for (var c = 0; c < o.length; c += 2) a.push(eh(e, o[c])), s.push(o[c + 1]);
-
-
- for (var l = [], h = hn.empty(), f = a.length - 1; f >= 0; --f) if (!oh(l, a[f])) {
- var d = a[f], p = s[f];
-
-
- p = v(p);
- var m = u.da(d);
- if (p instanceof zl)
-
- l.push(d); else {
- var y = Jl(p, m);
- null != y && (l.push(d), h.set(d, y));
- }
- }
- var g = new Ne(l);
- return new Vl(h, g, u.fieldTransforms);
- }
- function Xl(t, e, n, r) {
- return void 0 === r && (r = !1), Jl(n, t.ya(r ? 4 : 3 , e));
- }
- function Jl(t, e) {
- if ($l(
-
-
- t = v(t))) return th("Unsupported field value:", e, t), Zl(t, e);
- if (t instanceof Ol)
-
-
-
-
-
-
- return function(t, e) {
-
- if (!Ml(e.ca)) throw e._a("".concat(t._methodName, "() can only be used with update() and set()"));
- if (!e.path) throw e._a("".concat(t._methodName, "() is not currently supported inside arrays"));
- var n = t._toFieldTransform(e);
- n && e.fieldTransforms.push(n);
- }(t, e), null;
- if (void 0 === t && e.ignoreUndefinedProperties)
-
-
-
- return null;
- if (
-
-
- e.path && e.fieldMask.push(e.path), t instanceof Array) {
-
-
-
-
-
-
- if (e.settings.la && 4 !== e.ca) throw e._a("Nested arrays are not supported");
- return function(t, e) {
- for (var n = [], r = 0, i = 0, o = t; i < o.length; i++) {
- var u = Jl(o[i], e.wa(r));
- null == u && (
-
-
- u = {
- nullValue: "NULL_VALUE"
- }), n.push(u), r++;
- }
- return {
- arrayValue: {
- values: n
- }
- };
- }(t, e);
- }
- return function(t, e) {
- if (null === (t = v(t))) return {
- nullValue: "NULL_VALUE"
- };
- if ("number" == typeof t) return Dr(e.serializer, t);
- if ("boolean" == typeof t) return {
- booleanValue: t
- };
- if ("string" == typeof t) return {
- stringValue: t
- };
- if (t instanceof Date) {
- var n = st.fromDate(t);
- return {
- timestampValue: Fi(e.serializer, n)
- };
- }
- if (t instanceof st) {
-
-
-
- var r = new st(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
- return {
- timestampValue: Fi(e.serializer, r)
- };
- }
- if (t instanceof Fl) return {
- geoPointValue: {
- latitude: t.latitude,
- longitude: t.longitude
- }
- };
- if (t instanceof Nl) return {
- bytesValue: Pi(e.serializer, t._byteString)
- };
- if (t instanceof $c) {
- var i = e.databaseId, o = t.firestore._databaseId;
- if (!o.isEqual(i)) throw e._a("Document reference is for database ".concat(o.projectId, "/").concat(o.database, " but should be for database ").concat(i.projectId, "/").concat(i.database));
- return {
- referenceValue: Mi(t.firestore._databaseId || e.databaseId, t._key.path)
- };
- }
- throw e._a("Unsupported field value: ".concat(Wc(t)));
- }(t, e);
- }
- function Zl(t, e) {
- var n = {};
- return Ee(t) ?
-
-
- e.path && e.path.length > 0 && e.fieldMask.push(e.path) : Ie(t, (function(t, r) {
- var i = Jl(r, e.ha(t));
- null != i && (n[t] = i);
- })), {
- mapValue: {
- fields: n
- }
- };
- }
- function $l(t) {
- return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof st || t instanceof Fl || t instanceof Nl || t instanceof $c || t instanceof Ol);
- }
- function th(t, e, n) {
- if (!$l(n) || !function(t) {
- return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
- }(n)) {
- var r = Wc(n);
- throw "an object" === r ? e._a(t + " a custom object") : e._a(t + " " + r);
- }
- }
- function eh(t, e, n) {
- if (
-
-
- (e = v(e)) instanceof Al) return e._internalPath;
- if ("string" == typeof e) return rh(t, e);
- throw ih("Field path arguments must be of type string or ", t,
- !1,
- void 0, n);
- }
- var nh = new RegExp("[~\\*/\\[\\]]");
- function rh(t, e, n) {
- if (e.search(nh) >= 0) throw ih("Invalid field path (".concat(e, "). Paths must not contain '~', '*', '/', '[', or ']'"), t,
- !1,
- void 0, n);
- try {
- return (new (Al.bind.apply(Al, r([ void 0 ], e.split("."), !1))))._internalPath;
- } catch (r) {
- throw ih("Invalid field path (".concat(e, "). Paths must not be empty, begin with '.', end with '.', or contain '..'"), t,
- !1,
- void 0, n);
- }
- }
- function ih(t, e, n, r, i) {
- var o = r && !r.isEmpty(), u = void 0 !== i, a = "Function ".concat(e, "() called with invalid data");
- n && (a += " (via `toFirestore()`)"), a += ". ";
- var s = "";
- return (o || u) && (s += " (found", o && (s += " in field ".concat(r)), u && (s += " in document ".concat(i)),
- s += ")"), new Q(K.INVALID_ARGUMENT, a + t + s)
- ;
- }
- function oh(t, e) {
- return t.some((function(t) {
- return t.isEqual(e);
- }));
- }
- var uh = function() {
-
-
-
-
-
- function t(t, e, n, r, i) {
- this._firestore = t, this._userDataWriter = e, this._key = n, this._document = r,
- this._converter = i;
- }
- return Object.defineProperty(t.prototype, "id", {
- get: function() {
- return this._key.path.lastSegment();
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "ref", {
-
- get: function() {
- return new $c(this._firestore, this._converter, this._key);
- },
- enumerable: !1,
- configurable: !0
- }),
-
- t.prototype.exists = function() {
- return null !== this._document;
- },
-
- t.prototype.data = function() {
- if (this._document) {
- if (this._converter) {
-
-
- var t = new ah(this._firestore, this._userDataWriter, this._key, this._document,
- null);
- return this._converter.fromFirestore(t);
- }
- return this._userDataWriter.convertValue(this._document.data.value);
- }
- },
-
-
-
- t.prototype.get = function(t) {
- if (this._document) {
- var e = this._document.data.field(sh("DocumentSnapshot.get", t));
- if (null !== e) return this._userDataWriter.convertValue(e);
- }
- }, t;
- }(), ah = function(e) {
- function n() {
- return null !== e && e.apply(this, arguments) || this;
- }
-
- return t(n, e), n.prototype.data = function() {
- return e.prototype.data.call(this);
- }, n;
- }(uh);
- function sh(t, e) {
- return "string" == typeof e ? rh(t, e) : e instanceof Al ? e._internalPath : e._delegate._internalPath;
- }
- function ch(t) {
- if ("L" === t.limitType && 0 === t.explicitOrderBy.length) throw new Q(K.UNIMPLEMENTED, "limitToLast() queries require specifying at least one orderBy() clause");
- }
- var lh = function() {}, hh = function(e) {
- function n() {
- return null !== e && e.apply(this, arguments) || this;
- }
- return t(n, e), n;
- }(lh);
- function fh(t, e) {
- for (var n = [], r = 2; r < arguments.length; r++) n[r - 2] = arguments[r];
- var i = [];
- e instanceof lh && i.push(e), function(t) {
- var e = t.filter((function(t) {
- return t instanceof vh;
- })).length, n = t.filter((function(t) {
- return t instanceof dh;
- })).length;
- if (e > 1 || e > 0 && n > 0) throw new Q(K.INVALID_ARGUMENT, "InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.");
- }(i = i.concat(n));
- for (var o = 0, u = i; o < u.length; o++) {
- var a = u[o];
- t = a._apply(t);
- }
- return t;
- }
- var dh = function(e) {
-
- function n(t, n, r) {
- var i = this;
- return (i = e.call(this) || this)._field = t, i._op = n, i._value = r,
-
- i.type = "where", i;
- }
- return t(n, e), n._create = function(t, e, r) {
- return new n(t, e, r);
- }, n.prototype._apply = function(t) {
- var e = this._parse(t);
- return Oh(t._query, e), new tl(t.firestore, t.converter, er(t._query, e));
- }, n.prototype._parse = function(t) {
- var e = Bl(t.firestore), n = function(t, e, n, r, i, o, u) {
- var a;
- if (i.isKeyField()) {
- if ("array-contains" === o || "array-contains-any" === o) throw new Q(K.INVALID_ARGUMENT, "Invalid Query. You can't perform '".concat(o, "' queries on documentId()."));
- if ("in" === o || "not-in" === o) {
- kh(u, o);
- for (var s = [], c = 0, l = u; c < l.length; c++) {
- var h = l[c];
- s.push(Ah(r, t, h));
- }
- a = {
- arrayValue: {
- values: s
- }
- };
- } else a = Ah(r, t, u);
- } else "in" !== o && "not-in" !== o && "array-contains-any" !== o || kh(u, o),
- a = Xl(n, "where", u,
- "in" === o || "not-in" === o);
- return bn.create(i, o, a);
- }(t._query, 0, e, t.firestore._databaseId, this._field, this._op, this._value);
- return n;
- }, n;
- }(hh);
- function ph(t, e, n) {
- var r = e, i = sh("where", t);
- return dh._create(i, r, n);
- }
- var vh = function(e) {
-
- function n(
-
- t, n) {
- var r = this;
- return (r = e.call(this) || this).type = t, r._queryConstraints = n, r;
- }
- return t(n, e), n._create = function(t, e) {
- return new n(t, e);
- }, n.prototype._parse = function(t) {
- var e = this._queryConstraints.map((function(e) {
- return e._parse(t);
- })).filter((function(t) {
- return t.getFilters().length > 0;
- }));
- return 1 === e.length ? e[0] : In.create(e, this._getOperator());
- }, n.prototype._apply = function(t) {
- var e = this._parse(t);
- return 0 === e.getFilters().length ? t : (function(t, e) {
- for (var n = t, r = 0, i = e.getFlattenedFilters(); r < i.length; r++) {
- var o = i[r];
- Oh(n, o), n = er(n, o);
- }
- }(t._query, e), new tl(t.firestore, t.converter, er(t._query, e)));
- }, n.prototype._getQueryConstraints = function() {
- return this._queryConstraints;
- }, n.prototype._getOperator = function() {
- return "and" === this.type ? "and" : "or" ;
- }, n;
- }(lh);
- function mh() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
-
- return t.forEach((function(t) {
- return Ph("or", t);
- })), vh._create("or" , t)
-
- ;
- }
- function yh() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
-
- return t.forEach((function(t) {
- return Ph("and", t);
- })), vh._create("and" , t)
-
- ;
- }
- var gh = function(e) {
-
- function n(t, n) {
- var r = this;
- return (r = e.call(this) || this)._field = t, r._direction = n,
-
- r.type = "orderBy", r;
- }
- return t(n, e), n._create = function(t, e) {
- return new n(t, e);
- }, n.prototype._apply = function(t) {
- var e = function(t, e, n) {
- if (null !== t.startAt) throw new Q(K.INVALID_ARGUMENT, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
- if (null !== t.endAt) throw new Q(K.INVALID_ARGUMENT, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
- var r = new yn(e, n);
- return function(t, e) {
- if (null === Xn(t)) {
-
- var n = Jn(t);
- null !== n && Fh(t, n, e.field);
- }
- }(t, r), r;
- }(t._query, this._field, this._direction);
- return new tl(t.firestore, t.converter, function(t, e) {
-
- var n = t.explicitOrderBy.concat([ e ]);
- return new Qn(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
- }(t._query, e));
- }, n;
- }(hh);
- function wh(t, e) {
- void 0 === e && (e = "asc");
- var n = e, r = sh("orderBy", t);
- return gh._create(r, n);
- }
- var bh = function(e) {
-
- function n(
-
- t, n, r) {
- var i = this;
- return (i = e.call(this) || this).type = t, i._limit = n, i._limitType = r, i;
- }
- return t(n, e), n._create = function(t, e, r) {
- return new n(t, e, r);
- }, n.prototype._apply = function(t) {
- return new tl(t.firestore, t.converter, nr(t._query, this._limit, this._limitType));
- }, n;
- }(hh);
- function Ih(t) {
- return Yc("limit", t), bh._create("limit", t, "F" )
-
- ;
- }
- function Eh(t) {
- return Yc("limitToLast", t), bh._create("limitToLast", t, "L" )
-
- ;
- }
- var Th = function(e) {
-
- function n(
-
- t, n, r) {
- var i = this;
- return (i = e.call(this) || this).type = t, i._docOrFields = n, i._inclusive = r,
- i;
- }
- return t(n, e), n._create = function(t, e, r) {
- return new n(t, e, r);
- }, n.prototype._apply = function(t) {
- var e = Nh(t, this.type, this._docOrFields, this._inclusive);
- return new tl(t.firestore, t.converter, function(t, e) {
- return new Qn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
- }(t._query, e));
- }, n;
- }(hh);
- function Sh() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
- return Th._create("startAt", t,
- !0);
- }
- function _h() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
- return Th._create("startAfter", t,
- !1);
- }
- var Dh = function(e) {
-
- function n(
-
- t, n, r) {
- var i = this;
- return (i = e.call(this) || this).type = t, i._docOrFields = n, i._inclusive = r,
- i;
- }
- return t(n, e), n._create = function(t, e, r) {
- return new n(t, e, r);
- }, n.prototype._apply = function(t) {
- var e = Nh(t, this.type, this._docOrFields, this._inclusive);
- return new tl(t.firestore, t.converter, function(t, e) {
- return new Qn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
- }(t._query, e));
- }, n;
- }(hh);
- function Ch() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
- return Dh._create("endBefore", t,
- !1);
- }
- function xh() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
- return Dh._create("endAt", t,
- !0);
- }
- function Nh(t, e, n, r) {
- if (n[0] = v(n[0]), n[0] instanceof uh) return function(t, e, n, r, i) {
- if (!r) throw new Q(K.NOT_FOUND, "Can't use a DocumentSnapshot that doesn't exist for ".concat(n, "()."));
-
-
-
-
-
-
-
- for (var o = [], u = 0, a = $n(t); u < a.length; u++) {
- var s = a[u];
- if (s.field.isKeyField()) o.push(Ze(e, r.key)); else {
- var c = r.data.field(s.field);
- if (Me(c)) throw new Q(K.INVALID_ARGUMENT, 'Invalid query. You are trying to start or end a query using a document for which the field "' + s.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
- if (null === c) {
- var l = s.field.canonicalString();
- throw new Q(K.INVALID_ARGUMENT, "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."));
- }
- o.push(c);
- }
- }
- return new pn(o, i);
- }(t._query, t.firestore._databaseId, e, n[0]._document, r);
- var i = Bl(t.firestore);
- return function(t, e, n, r, i, o) {
-
- var u = t.explicitOrderBy;
- if (i.length > u.length) throw new Q(K.INVALID_ARGUMENT, "Too many arguments provided to ".concat(r, "(). The number of arguments must be less than or equal to the number of orderBy() clauses"));
- for (var a = [], s = 0; s < i.length; s++) {
- var c = i[s];
- if (u[s].field.isKeyField()) {
- if ("string" != typeof c) throw new Q(K.INVALID_ARGUMENT, "Invalid query. Expected a string for document ID in ".concat(r, "(), but got a ").concat(typeof c));
- if (!Zn(t) && -1 !== c.indexOf("/")) throw new Q(K.INVALID_ARGUMENT, "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."));
- var l = t.path.child(ht.fromString(c));
- if (!pt.isDocumentKey(l)) throw new Q(K.INVALID_ARGUMENT, "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."));
- var h = new pt(l);
- a.push(Ze(e, h));
- } else {
- var f = Xl(n, r, c);
- a.push(f);
- }
- }
- return new pn(a, o);
- }(t._query, t.firestore._databaseId, i, e, n, r);
- }
- function Ah(t, e, n) {
- if ("string" == typeof (n = v(n))) {
- if ("" === n) throw new Q(K.INVALID_ARGUMENT, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
- if (!Zn(e) && -1 !== n.indexOf("/")) throw new Q(K.INVALID_ARGUMENT, "Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '".concat(n, "' contains a '/' character."));
- var r = e.path.child(ht.fromString(n));
- if (!pt.isDocumentKey(r)) throw new Q(K.INVALID_ARGUMENT, "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, ")."));
- return Ze(t, new pt(r));
- }
- if (n instanceof $c) return Ze(t, n._key);
- throw new Q(K.INVALID_ARGUMENT, "Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ".concat(Wc(n), "."));
- }
- function kh(t, e) {
- if (!Array.isArray(t) || 0 === t.length) throw new Q(K.INVALID_ARGUMENT, "Invalid Query. A non-empty array is required for '".concat(e.toString(), "' filters."));
- }
- function Oh(t, e) {
- if (e.isInequality()) {
- var n = Jn(t), r = e.field;
- if (null !== n && !n.isEqual(r)) throw new Q(K.INVALID_ARGUMENT, "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(), "'"));
- var i = Xn(t);
- null !== i && Fh(t, r, i);
- }
- var o = function(t, e) {
- for (var n = 0, r = t; n < r.length; n++) for (var i = 0, o = r[n].getFlattenedFilters(); i < o.length; i++) {
- var u = o[i];
- if (e.indexOf(u.op) >= 0) return u.op;
- }
- return null;
- }(t.filters, function(t) {
- switch (t) {
- case "!=" :
- return [ "!=" , "not-in" ];
- case "array-contains-any" :
- case "in" :
- return [ "not-in" ];
- case "not-in" :
- return [ "array-contains-any" , "in" , "not-in" , "!=" ];
- default:
- return [];
- }
- }(e.op));
- if (null !== o)
-
- throw o === e.op ? new Q(K.INVALID_ARGUMENT, "Invalid query. You cannot use more than one '".concat(e.op.toString(), "' filter.")) : new Q(K.INVALID_ARGUMENT, "Invalid query. You cannot use '".concat(e.op.toString(), "' filters with '").concat(o.toString(), "' filters."));
- }
- function Fh(t, e, n) {
- if (!n.isEqual(e)) throw new Q(K.INVALID_ARGUMENT, "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."));
- }
- function Ph(t, e) {
- if (!(e instanceof dh || e instanceof vh)) throw new Q(K.INVALID_ARGUMENT, "Function ".concat(t, "() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'."));
- }
- var Rh = function() {
- function t() {}
- return t.prototype.convertValue = function(t, e) {
- switch (void 0 === e && (e = "none"), je(t)) {
- case 0 :
- return null;
- case 1 :
- return t.booleanValue;
- case 2 :
- return Re(t.integerValue || t.doubleValue);
- case 3 :
- return this.convertTimestamp(t.timestampValue);
- case 4 :
- return this.convertServerTimestamp(t, e);
- case 5 :
- return t.stringValue;
- case 6 :
- return this.convertBytes(Ve(t.bytesValue));
- case 7 :
- return this.convertReference(t.referenceValue);
- case 8 :
- return this.convertGeoPoint(t.geoPointValue);
- case 9 :
- return this.convertArray(t.arrayValue, e);
- case 10 :
- return this.convertObject(t.mapValue, e);
- default:
- throw U();
- }
- }, t.prototype.convertObject = function(t, e) {
- return this.convertObjectMap(t.fields, e);
- },
-
- t.prototype.convertObjectMap = function(t, e) {
- var n = this;
- void 0 === e && (e = "none");
- var r = {};
- return Ie(t, (function(t, i) {
- r[t] = n.convertValue(i, e);
- })), r;
- }, t.prototype.convertGeoPoint = function(t) {
- return new Fl(Re(t.latitude), Re(t.longitude));
- }, t.prototype.convertArray = function(t, e) {
- var n = this;
- return (t.values || []).map((function(t) {
- return n.convertValue(t, e);
- }));
- }, t.prototype.convertServerTimestamp = function(t, e) {
- switch (e) {
- case "previous":
- var n = Le(t);
- return null == n ? null : this.convertValue(n, e);
- case "estimate":
- return this.convertTimestamp(qe(t));
- default:
- return null;
- }
- }, t.prototype.convertTimestamp = function(t) {
- var e = Pe(t);
- return new st(e.seconds, e.nanos);
- }, t.prototype.convertDocumentKey = function(t, e) {
- var n = ht.fromString(t);
- z(uo(n));
- var r = new Ue(n.get(1), n.get(3)), i = new pt(n.popFirst(5));
- return r.isEqual(e) ||
-
- L("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.")),
- i;
- }, t;
- }();
- function Vh(t, e, n) {
-
-
-
- return t ? n && (n.merge || n.mergeFields) ? t.toFirestore(e, n) : t.toFirestore(e) : e;
- }
- var Mh = function(e) {
- function n(t) {
- var n = this;
- return (n = e.call(this) || this).firestore = t, n;
- }
- return t(n, e), n.prototype.convertBytes = function(t) {
- return new Nl(t);
- }, n.prototype.convertReference = function(t) {
- var e = this.convertDocumentKey(t, this.firestore._databaseId);
- return new $c(this.firestore, null, e);
- }, n;
- }(Rh);
- function Lh(t) {
- return new Cl("sum", eh("sum", t));
- }
- function qh(t) {
- return new Cl("avg", eh("average", t));
- }
- function Bh() {
- return new Cl("count");
- }
- function Uh(t, e) {
- var n, r;
- return t instanceof Cl && e instanceof Cl && 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());
- }
- function zh(t, e) {
- return ul(t.query, e.query) && g(t.data(), e.data());
- }
- var Gh = function() {
-
- function t(t, e) {
- this.hasPendingWrites = t, this.fromCache = e
-
- ;
- }
- return t.prototype.isEqual = function(t) {
- return this.hasPendingWrites === t.hasPendingWrites && this.fromCache === t.fromCache;
- }, t;
- }(), jh = function(e) {
-
- function n(t, n, r, i, o, u) {
- var a = this;
- return (a = e.call(this, t, n, r, i, u) || this)._firestore = t, a._firestoreImpl = t,
- a.metadata = o, a;
- }
-
- return t(n, e), n.prototype.exists = function() {
- return e.prototype.exists.call(this);
- },
-
- n.prototype.data = function(t) {
- if (void 0 === t && (t = {}), this._document) {
- if (this._converter) {
-
-
- var e = new Kh(this._firestore, this._userDataWriter, this._key, this._document, this.metadata,
- null);
- return this._converter.fromFirestore(e, t);
- }
- return this._userDataWriter.convertValue(this._document.data.value, t.serverTimestamps);
- }
- },
-
-
-
- n.prototype.get = function(t, e) {
- if (void 0 === e && (e = {}), this._document) {
- var n = this._document.data.field(sh("DocumentSnapshot.get", t));
- if (null !== n) return this._userDataWriter.convertValue(n, e.serverTimestamps);
- }
- }, n;
- }(uh), Kh = function(e) {
- function n() {
- return null !== e && e.apply(this, arguments) || this;
- }
-
- return t(n, e), n.prototype.data = function(t) {
- return void 0 === t && (t = {}), e.prototype.data.call(this, t);
- }, n;
- }(jh), Qh = function() {
-
- function t(t, e, n, r) {
- this._firestore = t, this._userDataWriter = e, this._snapshot = r, this.metadata = new Gh(r.hasPendingWrites, r.fromCache),
- this.query = n;
- }
- return Object.defineProperty(t.prototype, "docs", {
- get: function() {
- var t = [];
- return this.forEach((function(e) {
- return t.push(e);
- })), t;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "size", {
- get: function() {
- return this._snapshot.docs.size;
- },
- enumerable: !1,
- configurable: !0
- }), Object.defineProperty(t.prototype, "empty", {
- get: function() {
- return 0 === this.size;
- },
- enumerable: !1,
- configurable: !0
- }),
-
- t.prototype.forEach = function(t, e) {
- var n = this;
- this._snapshot.docs.forEach((function(r) {
- t.call(e, new Kh(n._firestore, n._userDataWriter, r.key, r, new Gh(n._snapshot.mutatedKeys.has(r.key), n._snapshot.fromCache), n.query.converter));
- }));
- },
-
- t.prototype.docChanges = function(t) {
- void 0 === t && (t = {});
- var e = !!t.includeMetadataChanges;
- if (e && this._snapshot.excludesMetadataChanges) throw new Q(K.INVALID_ARGUMENT, "To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");
- return this._cachedChanges && this._cachedChangesIncludeMetadataChanges === e || (this._cachedChanges =
-
- function(t, e) {
- if (t._snapshot.oldDocs.isEmpty()) {
- var n = 0;
- return t._snapshot.docChanges.map((function(e) {
- var r = new Kh(t._firestore, t._userDataWriter, e.doc.key, e.doc, new Gh(t._snapshot.mutatedKeys.has(e.doc.key), t._snapshot.fromCache), t.query.converter);
- return e.doc, {
- type: "added",
- doc: r,
- oldIndex: -1,
- newIndex: n++
- };
- }));
- }
-
-
- var r = t._snapshot.oldDocs;
- return t._snapshot.docChanges.filter((function(t) {
- return e || 3 !== t.type;
- })).map((function(e) {
- var n = new Kh(t._firestore, t._userDataWriter, e.doc.key, e.doc, new Gh(t._snapshot.mutatedKeys.has(e.doc.key), t._snapshot.fromCache), t.query.converter), i = -1, o = -1;
- return 0 !== e.type && (i = r.indexOf(e.doc.key), r = r.delete(e.doc.key)),
- 1 !== e.type && (o = (r = r.add(e.doc)).indexOf(e.doc.key)),
- {
- type: Wh(e.type),
- doc: n,
- oldIndex: i,
- newIndex: o
- };
- }));
- }(this, e), this._cachedChangesIncludeMetadataChanges = e), this._cachedChanges;
- }, t;
- }();
- function Wh(t) {
- switch (t) {
- case 0 :
- return "added";
- case 2 :
- case 3 :
- return "modified";
- case 1 :
- return "removed";
- default:
- return U();
- }
- }
- function Hh(t, e) {
- return t instanceof jh && e instanceof jh ? 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 Qh && e instanceof Qh && t._firestore === e._firestore && ul(t.query, e.query) && t.metadata.isEqual(e.metadata) && t._snapshot.isEqual(e._snapshot);
- }
- function Yh(t) {
- t = Hc(t, $c);
- var e = Hc(t.firestore, hl);
- return qc(pl(e), t._key).then((function(n) {
- return lf(e, t, n);
- }));
- }
- var Xh = function(e) {
- function n(t) {
- var n = this;
- return (n = e.call(this) || this).firestore = t, n;
- }
- return t(n, e), n.prototype.convertBytes = function(t) {
- return new Nl(t);
- }, n.prototype.convertReference = function(t) {
- var e = this.convertDocumentKey(t, this.firestore._databaseId);
- return new $c(this.firestore, null, e);
- }, n;
- }(Rh);
- function Jh(t) {
- t = Hc(t, $c);
- var r = Hc(t.firestore, hl), i = pl(r), o = new Xh(r);
- return function(t, r) {
- var i = this, o = new W;
- return t.asyncQueue.enqueueAndForget((function() {
- return e(i, void 0, void 0, (function() {
- var i;
- return n(this, (function(u) {
- switch (u.label) {
- case 0:
- return i = function(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var e, o, u;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return n.trys.push([ 0, 2, , 3 ]), [ 4 , function(t, e) {
- var n = j(t);
- return n.persistence.runTransaction("read document", "readonly", (function(t) {
- return n.localDocuments.getDocument(t, e);
- }));
- }(t, r) ];
- case 1:
- return (e = n.sent()).isFoundDocument() ? i.resolve(e) : e.isNoDocument() ? i.resolve(null) : i.reject(new Q(K.UNAVAILABLE, "Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)")),
- [ 3 , 3 ];
- case 2:
- return o = n.sent(), u = ys(o, "Failed to get document '".concat(r, " from cache")),
- i.reject(u), [ 3 , 3 ];
- case 3:
- return [ 2 ];
- }
- }));
- }));
- }, [ 4 , Pc(t) ];
- case 1:
- return [ 2 , i.apply(void 0, [ u.sent(), r, o ]) ];
- }
- }));
- }));
- })), o.promise;
- }(i, t._key).then((function(e) {
- return new jh(r, o, t._key, e, new Gh(null !== e && e.hasLocalMutations,
- !0), t.converter);
- }));
- }
- function Zh(t) {
- t = Hc(t, $c);
- var e = Hc(t.firestore, hl);
- return qc(pl(e), t._key, {
- source: "server"
- }).then((function(n) {
- return lf(e, t, n);
- }));
- }
- function $h(t) {
- t = Hc(t, tl);
- var e = Hc(t.firestore, hl), n = pl(e), r = new Xh(e);
- return ch(t._query), Bc(n, t._query).then((function(n) {
- return new Qh(e, r, t, n);
- }))
-
- ;
- }
- function tf(t) {
- t = Hc(t, tl);
- var r = Hc(t.firestore, hl), i = pl(r), o = new Xh(r);
- return function(t, r) {
- var i = this, o = new W;
- return t.asyncQueue.enqueueAndForget((function() {
- return e(i, void 0, void 0, (function() {
- var i;
- return n(this, (function(u) {
- switch (u.label) {
- case 0:
- return i = function(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var e, o, u, a, s, c;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return n.trys.push([ 0, 2, , 3 ]), [ 4 , la(t, r,
- !0) ];
- case 1:
- return e = n.sent(), o = new Rs(r, e.ir), u = o.sc(e.documents), a = o.applyChanges(u,
- !1), i.resolve(a.snapshot), [ 3 , 3 ];
- case 2:
- return s = n.sent(), c = ys(s, "Failed to execute query '".concat(r, " against cache")),
- i.reject(c), [ 3 , 3 ];
- case 3:
- return [ 2 ];
- }
- }));
- }));
- }, [ 4 , Pc(t) ];
- case 1:
- return [ 2 , i.apply(void 0, [ u.sent(), r, o ]) ];
- }
- }));
- }));
- })), o.promise;
- }(i, t._query).then((function(e) {
- return new Qh(r, o, t, e);
- }));
- }
- function ef(t) {
- t = Hc(t, tl);
- var e = Hc(t.firestore, hl), n = pl(e), r = new Xh(e);
- return Bc(n, t._query, {
- source: "server"
- }).then((function(n) {
- return new Qh(e, r, t, n);
- }));
- }
- function nf(t, e, n) {
- t = Hc(t, $c);
- var r = Hc(t.firestore, hl), i = Vh(t.converter, e, n);
- return cf(r, [ Ul(Bl(r), "setDoc", t._key, i, null !== t.converter, n).toMutation(t._key, Ur.none()) ]);
- }
- function rf(t, e, n) {
- for (var r = [], i = 3; i < arguments.length; i++) r[i - 3] = arguments[i];
- t = Hc(t, $c);
- var o = Hc(t.firestore, hl), u = Bl(o);
- return cf(o, [ ("string" == typeof (
-
-
- e = v(e)) || e instanceof Al ? Yl(u, "updateDoc", t._key, e, n, r) : Hl(u, "updateDoc", t._key, e)).toMutation(t._key, Ur.exists(!0)) ]);
- }
- function of(t) {
- return cf(Hc(t.firestore, hl), [ new ni(t._key, Ur.none()) ]);
- }
- function uf(t, e) {
- var n = Hc(t.firestore, hl), r = il(t), i = Vh(t.converter, e);
- return cf(n, [ Ul(Bl(t.firestore), "addDoc", r._key, i, null !== t.converter, {}).toMutation(r._key, Ur.exists(!1)) ]).then((function() {
- return r;
- }));
- }
- function af(t) {
- for (var r, i, o, u = [], a = 1; a < arguments.length; a++) u[a - 1] = arguments[a];
- t = v(t);
- var s = {
- includeMetadataChanges: !1
- }, c = 0;
- "object" != typeof u[c] || sl(u[c]) || (s = u[c], c++);
- var l, h, f, d = {
- includeMetadataChanges: s.includeMetadataChanges
- };
- if (sl(u[c])) {
- var p = u[c];
- u[c] = null === (r = p.next) || void 0 === r ? void 0 : r.bind(p), u[c + 1] = null === (i = p.error) || void 0 === i ? void 0 : i.bind(p),
- u[c + 2] = null === (o = p.complete) || void 0 === o ? void 0 : o.bind(p);
- }
- if (t instanceof $c) h = Hc(t.firestore, hl), f = Hn(t._key.path), l = {
- next: function(e) {
- u[c] && u[c](lf(h, t, e));
- },
- error: u[c + 1],
- complete: u[c + 2]
- }; else {
- var m = Hc(t, tl);
- h = Hc(m.firestore, hl), f = m._query;
- var y = new Xh(h);
- l = {
- next: function(t) {
- u[c] && u[c](new Qh(h, y, m, t));
- },
- error: u[c + 1],
- complete: u[c + 2]
- }, ch(t._query);
- }
- return function(t, r, i, o) {
- var u = this, a = new Tc(o), s = new xs(r, a, i);
- return t.asyncQueue.enqueueAndForget((function() {
- return e(u, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = Ts, [ 4 , Lc(t) ];
- case 1:
- return [ 2 , e.apply(void 0, [ n.sent(), s ]) ];
- }
- }));
- }));
- })), function() {
- a.Dc(), t.asyncQueue.enqueueAndForget((function() {
- return e(u, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = Ss, [ 4 , Lc(t) ];
- case 1:
- return [ 2 , e.apply(void 0, [ n.sent(), s ]) ];
- }
- }));
- }));
- }));
- };
- }(pl(h), f, d, l);
- }
- function sf(t, r) {
- return function(t, r) {
- var i = this, o = new Tc(r);
- return t.asyncQueue.enqueueAndForget((function() {
- return e(i, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = function(t, e) {
- j(t).ku.add(e),
-
-
- e.next();
- }, [ 4 , Lc(t) ];
- case 1:
- return [ 2 , e.apply(void 0, [ n.sent(), o ]) ];
- }
- }));
- }));
- })), function() {
- o.Dc(), t.asyncQueue.enqueueAndForget((function() {
- return e(i, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = function(t, e) {
- j(t).ku.delete(e);
- }, [ 4 , Lc(t) ];
- case 1:
- return [ 2 , e.apply(void 0, [ n.sent(), o ]) ];
- }
- }));
- }));
- }));
- };
- }(pl(t = Hc(t, hl)), sl(r) ? r : {
- next: r
- });
- }
- function cf(t, r) {
- return function(t, r) {
- var i = this, o = new W;
- return t.asyncQueue.enqueueAndForget((function() {
- return e(i, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return e = zs, [ 4 , Vc(t) ];
- case 1:
- return [ 2 , e.apply(void 0, [ n.sent(), r, o ]) ];
- }
- }));
- }));
- })), o.promise;
- }(pl(t), r);
- }
- function lf(t, e, n) {
- var r = n.docs.get(e._key), i = new Xh(t);
- return new jh(t, i, e._key, r, new Gh(n.hasPendingWrites, n.fromCache), e.converter);
- }
- function hf(t) {
- return ff(t, {
- count: Bh()
- });
- }
- function ff(t, r) {
- var i = Hc(t.firestore, hl), o = pl(i), u = function(t, e) {
- var n = [];
- for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && n.push(e(t[r], r));
- return n;
- }(r, (function(t, e) {
- return new ai(e, t._aggregateType, t._internalFieldPath);
- }));
-
- return function(t, r, i) {
- var o = this, u = new W;
- return t.asyncQueue.enqueueAndForget((function() {
- return e(o, void 0, void 0, (function() {
- var o, a;
- return n(this, (function(s) {
- switch (s.label) {
- case 0:
- return s.trys.push([ 0, 2, , 3 ]), [ 4 , Mc(t) ];
- case 1:
- return o = s.sent(), u.resolve(
-
-
- function(t, r, i) {
- return e(this, void 0, void 0, (function() {
- var e, o, u, a, s, c, l, h;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return o = j(t), u = function(t, e, n) {
- var r = Xi(t, e), i = {}, o = [], u = 0;
- return n.forEach((function(t) {
-
-
-
- var e = "aggregate_" + u++;
- i[e] = t.alias, "count" === t.yt ? o.push({
- alias: e,
- count: {}
- }) : "avg" === t.yt ? o.push({
- alias: e,
- avg: {
- field: no(t.fieldPath)
- }
- }) : "sum" === t.yt && o.push({
- alias: e,
- sum: {
- field: no(t.fieldPath)
- }
- });
- })), {
- request: {
- structuredAggregationQuery: {
- aggregations: o,
- structuredQuery: r.structuredQuery
- },
- parent: r.parent
- },
- du: i
- };
- }(o.serializer, tr(r), i), a = u.request, s = u.du, c = a.parent, o.connection.po || delete a.parent,
- [ 4 , o.vo("RunAggregationQuery", c, a, 1) ];
- case 1:
- return l = n.sent().filter((function(t) {
- return !!t.result;
- })),
-
- z(1 === l.length), h = null === (e = l[0].result) || void 0 === e ? void 0 : e.aggregateFields,
- [ 2 , Object.keys(h).reduce((function(t, e) {
- return t[s[e]] = h[e], t;
- }), {}) ];
- }
- }));
- }));
- }(o, r, i)), [ 3 , 3 ];
- case 2:
- return a = s.sent(), u.reject(a), [ 3 , 3 ];
- case 3:
- return [ 2 ];
- }
- }));
- }));
- })), u.promise;
- }(o, t._query, u).then((function(e) {
-
- return function(t, e, n) {
- var r = new Xh(t);
- return new xl(e, r, n);
- }(i, t, e);
- }));
- }
- var df = function() {
- function t(t) {
- this.kind = "memory", this._onlineComponentProvider = new Ic, (null == t ? void 0 : t.garbageCollector) ? this._offlineComponentProvider = t.garbageCollector._offlineComponentProvider : this._offlineComponentProvider = new yc;
- }
- return t.prototype.toJSON = function() {
- return {
- kind: this.kind
- };
- }, t;
- }(), pf = function() {
- function t(t) {
- var e;
- this.kind = "persistent", (null == t ? void 0 : t.tabManager) ? (t.tabManager._initialize(t),
- e = t.tabManager) : (e = Tf(void 0))._initialize(t), this._onlineComponentProvider = e._onlineComponentProvider,
- this._offlineComponentProvider = e._offlineComponentProvider;
- }
- return t.prototype.toJSON = function() {
- return {
- kind: this.kind
- };
- }, t;
- }(), vf = function() {
- function t() {
- this.kind = "memoryEager", this._offlineComponentProvider = new yc;
- }
- return t.prototype.toJSON = function() {
- return {
- kind: this.kind
- };
- }, t;
- }(), mf = function() {
- function t(t) {
- this.kind = "memoryLru", this._offlineComponentProvider = new gc(t);
- }
- return t.prototype.toJSON = function() {
- return {
- kind: this.kind
- };
- }, t;
- }();
- function yf() {
- return new vf;
- }
- function gf(t) {
- return new mf(null == t ? void 0 : t.cacheSizeBytes);
- }
- function wf(t) {
- return new df(t);
- }
- function bf(t) {
- return new pf(t);
- }
- var If = function() {
- function t(t) {
- this.forceOwnership = t, this.kind = "persistentSingleTab";
- }
- return t.prototype.toJSON = function() {
- return {
- kind: this.kind
- };
- },
-
- t.prototype._initialize = function(t) {
- this._onlineComponentProvider = new Ic, this._offlineComponentProvider = new wc(this._onlineComponentProvider, null == t ? void 0 : t.cacheSizeBytes, this.forceOwnership);
- }, t;
- }(), Ef = function() {
- function t() {
- this.kind = "PersistentMultipleTab";
- }
- return t.prototype.toJSON = function() {
- return {
- kind: this.kind
- };
- },
-
- t.prototype._initialize = function(t) {
- this._onlineComponentProvider = new Ic, this._offlineComponentProvider = new bc(this._onlineComponentProvider, null == t ? void 0 : t.cacheSizeBytes);
- }, t;
- }();
- function Tf(t) {
- return new If(null == t ? void 0 : t.forceOwnership);
- }
- function Sf() {
- return new Ef;
- }
- var _f = {
- maxAttempts: 5
- }, Df = function() {
-
- function t(t, e) {
- this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
- this._dataReader = Bl(t);
- }
- return t.prototype.set = function(t, e, n) {
- this._verifyNotCommitted();
- var r = Cf(t, this._firestore), i = Vh(r.converter, e, n), o = Ul(this._dataReader, "WriteBatch.set", r._key, i, null !== r.converter, n);
- return this._mutations.push(o.toMutation(r._key, Ur.none())), this;
- }, t.prototype.update = function(t, e, n) {
- for (var r = [], i = 3; i < arguments.length; i++) r[i - 3] = arguments[i];
- this._verifyNotCommitted();
- var o, u = Cf(t, this._firestore);
-
-
- return o = "string" == typeof (e = v(e)) || e instanceof Al ? Yl(this._dataReader, "WriteBatch.update", u._key, e, n, r) : Hl(this._dataReader, "WriteBatch.update", u._key, e),
- this._mutations.push(o.toMutation(u._key, Ur.exists(!0))), this;
- },
-
- t.prototype.delete = function(t) {
- this._verifyNotCommitted();
- var e = Cf(t, this._firestore);
- return this._mutations = this._mutations.concat(new ni(e._key, Ur.none())), this;
- },
-
- t.prototype.commit = function() {
- return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();
- }, t.prototype._verifyNotCommitted = function() {
- if (this._committed) throw new Q(K.FAILED_PRECONDITION, "A write batch can no longer be used after commit() has been called.");
- }, t;
- }();
- function Cf(t, e) {
- if ((t = v(t)).firestore !== e) throw new Q(K.INVALID_ARGUMENT, "Provided document reference is from a different Firestore instance.");
- return t;
- }
- var xf, Nf = function(e) {
-
-
-
- function n(t, n) {
- var r = this;
- return (r = e.call(this, t, n) || this)._firestore = t, r;
- }
-
- return t(n, e), n.prototype.get = function(t) {
- var n = this, r = Cf(t, this._firestore), i = new Xh(this._firestore);
- return e.prototype.get.call(this, t).then((function(t) {
- return new jh(n._firestore, i, r._key, t._document, new Gh(
- !1,
- !1), r.converter);
- }));
- }, n;
- }( function() {
-
- function t(t, e) {
- this._firestore = t, this._transaction = e, this._dataReader = Bl(t)
-
- ;
- }
- return t.prototype.get = function(t) {
- var e = this, n = Cf(t, this._firestore), r = new Mh(this._firestore);
- return this._transaction.lookup([ n._key ]).then((function(t) {
- if (!t || 1 !== t.length) return U();
- var i = t[0];
- if (i.isFoundDocument()) return new uh(e._firestore, r, i.key, i, n.converter);
- if (i.isNoDocument()) return new uh(e._firestore, r, n._key, null, n.converter);
- throw U();
- }));
- }, t.prototype.set = function(t, e, n) {
- var r = Cf(t, this._firestore), i = Vh(r.converter, e, n), o = Ul(this._dataReader, "Transaction.set", r._key, i, null !== r.converter, n);
- return this._transaction.set(r._key, o), this;
- }, t.prototype.update = function(t, e, n) {
- for (var r = [], i = 3; i < arguments.length; i++) r[i - 3] = arguments[i];
- var o, u = Cf(t, this._firestore);
-
-
- return o = "string" == typeof (e = v(e)) || e instanceof Al ? Yl(this._dataReader, "Transaction.update", u._key, e, n, r) : Hl(this._dataReader, "Transaction.update", u._key, e),
- this._transaction.update(u._key, o), this;
- },
-
- t.prototype.delete = function(t) {
- var e = Cf(t, this._firestore);
- return this._transaction.delete(e._key), this;
- }, t;
- }());
- function Af(t, r, i) {
- t = Hc(t, hl);
- var o = Object.assign(Object.assign({}, _f), i);
- return function(t) {
- if (t.maxAttempts < 1) throw new Q(K.INVALID_ARGUMENT, "Max attempts must be at least 1");
- }(o), function(t, r, i) {
- var o = this, u = new W;
- return t.asyncQueue.enqueueAndForget((function() {
- return e(o, void 0, void 0, (function() {
- var e;
- return n(this, (function(n) {
- switch (n.label) {
- case 0:
- return [ 4 , Mc(t) ];
- case 1:
- return e = n.sent(), new Dc(t.asyncQueue, e, i, r, u).run(), [ 2 ];
- }
- }));
- }));
- })), u.promise;
- }(pl(t), (function(e) {
- return r(new Nf(t, e));
- }), o);
- }
- function kf() {
- return new zl("deleteField");
- }
- function Of() {
- return new jl("serverTimestamp");
- }
- function Ff() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
-
-
- return new Kl("arrayUnion", t);
- }
- function Pf() {
- for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
-
-
- return new Ql("arrayRemove", t);
- }
- function Rf(t) {
- return new Wl("increment", t);
- }
- function Vf(t) {
- return pl(t = Hc(t, hl)), new Df(t, (function(e) {
- return cf(t, e);
- }))
-
- ;
- }
- function Mf(t, i) {
- var o, u = pl(t = Hc(t, hl));
- if (!u._uninitializedComponentsProvider || "memory" === (null === (o = u._uninitializedComponentsProvider) || void 0 === o ? void 0 : o._offlineKind))
-
-
- return q("Cannot enable indexes when persistence is disabled"), Promise.resolve();
- var a = function(t) {
- var e = "string" == typeof t ? function(t) {
- try {
- return JSON.parse(t);
- } catch (t) {
- throw new Q(K.INVALID_ARGUMENT, "Failed to parse JSON: " + (null == t ? void 0 : t.message));
- }
- }(t) : t, n = [];
- if (Array.isArray(e.indexes)) for (var r = 0, i = e.indexes; r < i.length; r++) {
- var o = i[r], u = Lf(o, "collectionGroup"), a = [];
- if (Array.isArray(o.fields)) for (var s = 0, c = o.fields; s < c.length; s++) {
- var l = c[s], h = rh("setIndexConfiguration", Lf(l, "fieldPath"));
- "CONTAINS" === l.arrayConfig ? a.push(new wt(h, 2 )) : "ASCENDING" === l.order ? a.push(new wt(h, 0 )) : "DESCENDING" === l.order && a.push(new wt(h, 1 ));
- }
- n.push(new vt(vt.UNKNOWN_ID, u, a, It.empty()));
- }
- return n;
- }(i);
- return function(t, i) {
- var o = this;
- return t.asyncQueue.enqueue((function() {
- return e(o, void 0, void 0, (function() {
- var o;
- return n(this, (function(u) {
- switch (u.label) {
- case 0:
- return o = function(t, i) {
- return e(this, void 0, void 0, (function() {
- var e, o, u;
- return n(this, (function(n) {
- return e = j(t), o = e.indexManager, u = [], [ 2 , e.persistence.runTransaction("Configure indexes", "readwrite", (function(t) {
- return o.getFieldIndexes(t).next((function(e) {
-
-
- return function(t, e, n, i, o) {
- t = r([], t, !0), e = r([], e, !0), t.sort(n), e.sort(n);
- for (var u = t.length, a = e.length, s = 0, c = 0; s < a && c < u; ) {
- var l = n(t[c], e[s]);
- l < 0 ?
-
-
- o(t[c++]) : l > 0 ?
-
-
- i(e[s++]) : (s++, c++);
- }
- for (;s < a; ) i(e[s++]);
- for (;c < u; ) o(t[c++]);
- }(e, i, gt, (function(e) {
- u.push(o.addFieldIndex(t, e));
- }), (function(e) {
- u.push(o.deleteFieldIndex(t, e));
- }));
- })).next((function() {
- return Nt.waitFor(u);
- }));
- })) ];
- }));
- }));
- }, [ 4 , Pc(t) ];
- case 1:
- return [ 2 , o.apply(void 0, [ u.sent(), i ]) ];
- }
- }));
- }));
- }));
- }(u, a);
- }
- function Lf(t, e) {
- if ("string" != typeof t[e]) throw new Q(K.INVALID_ARGUMENT, "Missing string value for: " + e);
- return t[e];
- }
- void 0 === xf && (xf = !0), F = i, o(new c("firestore", (function(t, e) {
- var n = e.instanceIdentifier, r = e.options, i = t.getProvider("app").getImmediate(), o = new hl(new J(t.getProvider("auth-internal")), new et(t.getProvider("app-check-internal")), function(t, e) {
- if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new Q(K.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
- return new Ue(t.options.projectId, e);
- }(i, n), i);
- return r = Object.assign({
- useFetchStreams: xf
- }, r), o._setSettings(r), o;
- }), "PUBLIC").setMultipleInstances(!0)), u(k, "3.13.0", void 0),
- u(k, "3.13.0", "esm5");
- export { Rh as AbstractUserDataWriter, Cl as AggregateField, xl as AggregateQuerySnapshot, Nl as Bytes, ll as CACHE_SIZE_UNLIMITED, el as CollectionReference, $c as DocumentReference, jh as DocumentSnapshot, Al as FieldPath, Ol as FieldValue, hl as Firestore, Q as FirestoreError, Fl as GeoPoint, cl as LoadBundleTask, tl as Query, vh as QueryCompositeFilterConstraint, hh as QueryConstraint, Kh as QueryDocumentSnapshot, Dh as QueryEndAtConstraint, dh as QueryFieldFilterConstraint, bh as QueryLimitConstraint, gh as QueryOrderByConstraint, Qh as QuerySnapshot, Th as QueryStartAtConstraint, Gh as SnapshotMetadata, st as Timestamp, Nf as Transaction, Df as WriteBatch, Ue as _DatabaseId, pt as _DocumentKey, nt as _EmptyAppCheckTokenProvider, Y as _EmptyAuthCredentialsProvider, dt as _FieldPath, hi as _TestingHooks, Hc as _cast, G as _debugAssert, ke as _isBase64Available, q as _logWarn, jc as _validateIsNotUsedTogether, uf as addDoc, Uh as aggregateFieldEqual, zh as aggregateQuerySnapshotEqual, yh as and, Pf as arrayRemove, Ff as arrayUnion, qh as average, wl as clearIndexedDbPersistence, nl as collection, rl as collectionGroup, Zc as connectFirestoreEmulator, Bh as count, of as deleteDoc, kf as deleteField, El as disableNetwork, il as doc, kl as documentId, ml as enableIndexedDbPersistence, yl as enableMultiTabIndexedDbPersistence, Il as enableNetwork, xh as endAt, Ch as endBefore, pl as ensureFirestoreConfigured, cf as executeWrite, ff as getAggregateFromServer, hf as getCountFromServer, Yh as getDoc, Jh as getDocFromCache, Zh as getDocFromServer, $h as getDocs, tf as getDocsFromCache, ef as getDocsFromServer, dl as getFirestore, Rf as increment, fl as initializeFirestore, Ih as limit, Eh as limitToLast, Sl as loadBundle, yf as memoryEagerGarbageCollector, wf as memoryLocalCache, gf as memoryLruGarbageCollector, _l as namedQuery, af as onSnapshot, sf as onSnapshotsInSync, mh as or, wh as orderBy, bf as persistentLocalCache, Sf as persistentMultipleTabManager, Tf as persistentSingleTabManager, fh as query, ul as queryEqual, ol as refEqual, Af as runTransaction, Of as serverTimestamp, nf as setDoc, Mf as setIndexConfiguration, V as setLogLevel, Hh as snapshotEqual, _h as startAfter, Sh as startAt, Lh as sum, Tl as terminate, rf as updateDoc, bl as waitForPendingWrites, ph as where, Vf as writeBatch };
|