parse.js 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024
  1. /**
  2. * Parse JavaScript SDK v4.2.0
  3. *
  4. * The source tree of this library can be found at
  5. * https://github.com/ParsePlatform/Parse-SDK-JS
  6. */
  7. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Parse = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){
  8. "use strict";
  9. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  10. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11. _Object$defineProperty(exports, "__esModule", {
  12. value: true
  13. });
  14. exports.track = track;
  15. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  16. /**
  17. * @flow
  18. */
  19. /**
  20. * Parse.Analytics provides an interface to Parse's logging and analytics
  21. * backend.
  22. *
  23. * @class Parse.Analytics
  24. * @static
  25. * @hideconstructor
  26. */
  27. /**
  28. * Tracks the occurrence of a custom event with additional dimensions.
  29. * Parse will store a data point at the time of invocation with the given
  30. * event name.
  31. *
  32. * Dimensions will allow segmentation of the occurrences of this custom
  33. * event. Keys and values should be {@code String}s, and will throw
  34. * otherwise.
  35. *
  36. * To track a user signup along with additional metadata, consider the
  37. * following:
  38. * <pre>
  39. * var dimensions = {
  40. * gender: 'm',
  41. * source: 'web',
  42. * dayType: 'weekend'
  43. * };
  44. * Parse.Analytics.track('signup', dimensions);
  45. * </pre>
  46. *
  47. * There is a default limit of 8 dimensions per event tracked.
  48. *
  49. * @function track
  50. * @name Parse.Analytics.track
  51. * @param {string} name The name of the custom event to report to Parse as
  52. * having happened.
  53. * @param {object} dimensions The dictionary of information by which to
  54. * segment this event.
  55. * @returns {Promise} A promise that is resolved when the round-trip
  56. * to the server completes.
  57. */
  58. function track(name /*: string*/, dimensions /*: { [key: string]: string }*/) /*: Promise*/{
  59. name = name || '';
  60. name = name.replace(/^\s*/, '');
  61. name = name.replace(/\s*$/, '');
  62. if (name.length === 0) {
  63. throw new TypeError('A name for the custom event must be provided');
  64. }
  65. for (var _key in dimensions) {
  66. if (typeof _key !== 'string' || typeof dimensions[_key] !== 'string') {
  67. throw new TypeError('track() dimensions expects keys and values of type "string".');
  68. }
  69. }
  70. return _CoreManager.default.getAnalyticsController().track(name, dimensions);
  71. }
  72. var DefaultController = {
  73. track: function (name, dimensions) {
  74. var RESTController = _CoreManager.default.getRESTController();
  75. return RESTController.request('POST', 'events/' + name, {
  76. dimensions: dimensions
  77. });
  78. }
  79. };
  80. _CoreManager.default.setAnalyticsController(DefaultController);
  81. },{"./CoreManager":4,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],2:[function(_dereq_,module,exports){
  82. "use strict";
  83. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  84. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  85. _Object$defineProperty(exports, "__esModule", {
  86. value: true
  87. });
  88. exports.default = void 0;
  89. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  90. /**
  91. * @flow-weak
  92. */
  93. /*:: import type { RequestOptions } from './RESTController';*/
  94. var uuidv4 = _dereq_('./uuid');
  95. var registered = false;
  96. /**
  97. * Provides utility functions for working with Anonymously logged-in users. <br />
  98. * Anonymous users have some unique characteristics:
  99. * <ul>
  100. * <li>Anonymous users don't need a user name or password.</li>
  101. * <ul>
  102. * <li>Once logged out, an anonymous user cannot be recovered.</li>
  103. * </ul>
  104. * <li>signUp converts an anonymous user to a standard user with the given username and password.</li>
  105. * <ul>
  106. * <li>Data associated with the anonymous user is retained.</li>
  107. * </ul>
  108. * <li>logIn switches users without converting the anonymous user.</li>
  109. * <ul>
  110. * <li>Data associated with the anonymous user will be lost.</li>
  111. * </ul>
  112. * <li>Service logIn (e.g. Facebook, Twitter) will attempt to convert
  113. * the anonymous user into a standard user by linking it to the service.</li>
  114. * <ul>
  115. * <li>If a user already exists that is linked to the service, it will instead switch to the existing user.</li>
  116. * </ul>
  117. * <li>Service linking (e.g. Facebook, Twitter) will convert the anonymous user
  118. * into a standard user by linking it to the service.</li>
  119. * </ul>
  120. *
  121. * @class Parse.AnonymousUtils
  122. * @static
  123. */
  124. var AnonymousUtils = {
  125. /**
  126. * Gets whether the user has their account linked to anonymous user.
  127. *
  128. * @function isLinked
  129. * @name Parse.AnonymousUtils.isLinked
  130. * @param {Parse.User} user User to check for.
  131. * The user must be logged in on this device.
  132. * @returns {boolean} <code>true</code> if the user has their account
  133. * linked to an anonymous user.
  134. * @static
  135. */
  136. isLinked: function (user /*: ParseUser*/) {
  137. var provider = this._getAuthProvider();
  138. return user._isLinked(provider.getAuthType());
  139. },
  140. /**
  141. * Logs in a user Anonymously.
  142. *
  143. * @function logIn
  144. * @name Parse.AnonymousUtils.logIn
  145. * @param {object} options MasterKey / SessionToken.
  146. * @returns {Promise} Logged in user
  147. * @static
  148. */
  149. logIn: function (options /*:: ?: RequestOptions*/) /*: Promise<ParseUser>*/{
  150. var provider = this._getAuthProvider();
  151. return _ParseUser.default.logInWith(provider.getAuthType(), provider.getAuthData(), options);
  152. },
  153. /**
  154. * Links Anonymous User to an existing PFUser.
  155. *
  156. * @function link
  157. * @name Parse.AnonymousUtils.link
  158. * @param {Parse.User} user User to link. This must be the current user.
  159. * @param {object} options MasterKey / SessionToken.
  160. * @returns {Promise} Linked with User
  161. * @static
  162. */
  163. link: function (user /*: ParseUser*/, options /*:: ?: RequestOptions*/) /*: Promise<ParseUser>*/{
  164. var provider = this._getAuthProvider();
  165. return user.linkWith(provider.getAuthType(), provider.getAuthData(), options);
  166. },
  167. /**
  168. * Returns true if Authentication Provider has been registered for use.
  169. *
  170. * @function isRegistered
  171. * @name Parse.AnonymousUtils.isRegistered
  172. * @returns {boolean}
  173. * @static
  174. */
  175. isRegistered: function () /*: boolean*/{
  176. return registered;
  177. },
  178. _getAuthProvider: function () {
  179. var provider = {
  180. restoreAuthentication: function () {
  181. return true;
  182. },
  183. getAuthType: function () {
  184. return 'anonymous';
  185. },
  186. getAuthData: function () {
  187. return {
  188. authData: {
  189. id: uuidv4()
  190. }
  191. };
  192. }
  193. };
  194. if (!registered) {
  195. _ParseUser.default._registerAuthenticationProvider(provider);
  196. registered = true;
  197. }
  198. return provider;
  199. }
  200. };
  201. var _default = AnonymousUtils;
  202. exports.default = _default;
  203. },{"./ParseUser":35,"./uuid":54,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],3:[function(_dereq_,module,exports){
  204. "use strict";
  205. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  206. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  207. _Object$defineProperty(exports, "__esModule", {
  208. value: true
  209. });
  210. exports.getJobStatus = getJobStatus;
  211. exports.getJobsData = getJobsData;
  212. exports.run = run;
  213. exports.startJob = startJob;
  214. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  215. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  216. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  217. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  218. var _decode = _interopRequireDefault(_dereq_("./decode"));
  219. var _encode = _interopRequireDefault(_dereq_("./encode"));
  220. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  221. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  222. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  223. /**
  224. * @flow
  225. */
  226. /*:: import type { RequestOptions } from './RESTController';*/
  227. /**
  228. * Contains functions for calling and declaring
  229. * <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
  230. * <p><strong><em>
  231. * Some functions are only available from Cloud Code.
  232. * </em></strong></p>
  233. *
  234. * @class Parse.Cloud
  235. * @static
  236. * @hideconstructor
  237. */
  238. /**
  239. * Makes a call to a cloud function.
  240. *
  241. * @function run
  242. * @name Parse.Cloud.run
  243. * @param {string} name The function name.
  244. * @param {object} data The parameters to send to the cloud function.
  245. * @param {object} options
  246. * @returns {Promise} A promise that will be resolved with the result
  247. * of the function.
  248. */
  249. function run(name /*: string*/, data /*: mixed*/, options /*: RequestOptions*/) /*: Promise<mixed>*/{
  250. options = options || {};
  251. if (typeof name !== 'string' || name.length === 0) {
  252. throw new TypeError('Cloud function name must be a string.');
  253. }
  254. var requestOptions = {};
  255. if (options.useMasterKey) {
  256. requestOptions.useMasterKey = options.useMasterKey;
  257. }
  258. if (options.sessionToken) {
  259. requestOptions.sessionToken = options.sessionToken;
  260. }
  261. if (options.context && (0, _typeof2.default)(options.context) === 'object') {
  262. requestOptions.context = options.context;
  263. }
  264. return _CoreManager.default.getCloudController().run(name, data, requestOptions);
  265. }
  266. /**
  267. * Gets data for the current set of cloud jobs.
  268. *
  269. * @function getJobsData
  270. * @name Parse.Cloud.getJobsData
  271. * @returns {Promise} A promise that will be resolved with the result
  272. * of the function.
  273. */
  274. function getJobsData() /*: Promise<Object>*/{
  275. return _CoreManager.default.getCloudController().getJobsData({
  276. useMasterKey: true
  277. });
  278. }
  279. /**
  280. * Starts a given cloud job, which will process asynchronously.
  281. *
  282. * @function startJob
  283. * @name Parse.Cloud.startJob
  284. * @param {string} name The function name.
  285. * @param {object} data The parameters to send to the cloud function.
  286. * @returns {Promise} A promise that will be resolved with the jobStatusId
  287. * of the job.
  288. */
  289. function startJob(name /*: string*/, data /*: mixed*/) /*: Promise<string>*/{
  290. if (typeof name !== 'string' || name.length === 0) {
  291. throw new TypeError('Cloud job name must be a string.');
  292. }
  293. return _CoreManager.default.getCloudController().startJob(name, data, {
  294. useMasterKey: true
  295. });
  296. }
  297. /**
  298. * Gets job status by Id
  299. *
  300. * @function getJobStatus
  301. * @name Parse.Cloud.getJobStatus
  302. * @param {string} jobStatusId The Id of Job Status.
  303. * @returns {Parse.Object} Status of Job.
  304. */
  305. function getJobStatus(jobStatusId /*: string*/) /*: Promise<ParseObject>*/{
  306. var query = new _ParseQuery.default('_JobStatus');
  307. return query.get(jobStatusId, {
  308. useMasterKey: true
  309. });
  310. }
  311. var DefaultController = {
  312. run: function (name, data, options /*: RequestOptions*/) {
  313. var RESTController = _CoreManager.default.getRESTController();
  314. var payload = (0, _encode.default)(data, true);
  315. var request = RESTController.request('POST', 'functions/' + name, payload, options);
  316. return request.then(function (res) {
  317. if ((0, _typeof2.default)(res) === 'object' && (0, _keys.default)(res).length > 0 && !res.hasOwnProperty('result')) {
  318. throw new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.');
  319. }
  320. var decoded = (0, _decode.default)(res);
  321. if (decoded && decoded.hasOwnProperty('result')) {
  322. return _promise.default.resolve(decoded.result);
  323. }
  324. return _promise.default.resolve(undefined);
  325. });
  326. },
  327. getJobsData: function (options /*: RequestOptions*/) {
  328. var RESTController = _CoreManager.default.getRESTController();
  329. return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
  330. },
  331. startJob: function (name, data, options /*: RequestOptions*/) {
  332. var RESTController = _CoreManager.default.getRESTController();
  333. var payload = (0, _encode.default)(data, true);
  334. return RESTController.request('POST', 'jobs/' + name, payload, options);
  335. }
  336. };
  337. _CoreManager.default.setCloudController(DefaultController);
  338. },{"./CoreManager":4,"./ParseError":22,"./ParseObject":27,"./ParseQuery":30,"./decode":45,"./encode":46,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],4:[function(_dereq_,module,exports){
  339. (function (process){(function (){
  340. "use strict";
  341. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  342. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  343. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  344. /*
  345. * @flow
  346. */
  347. /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
  348. /*:: import type ParseFile from './ParseFile';*/
  349. /*:: import type { FileSource } from './ParseFile';*/
  350. /*:: import type { Op } from './ParseOp';*/
  351. /*:: import type ParseObject from './ParseObject';*/
  352. /*:: import type { QueryJSON } from './ParseQuery';*/
  353. /*:: import type ParseUser from './ParseUser';*/
  354. /*:: import type { AuthData } from './ParseUser';*/
  355. /*:: import type { PushData } from './Push';*/
  356. /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
  357. /*:: type AnalyticsController = {
  358. track: (name: string, dimensions: { [key: string]: string }) => Promise,
  359. };*/
  360. /*:: type CloudController = {
  361. run: (name: string, data: mixed, options: RequestOptions) => Promise,
  362. getJobsData: (options: RequestOptions) => Promise,
  363. startJob: (name: string, data: mixed, options: RequestOptions) => Promise,
  364. };*/
  365. /*:: type ConfigController = {
  366. current: () => Promise,
  367. get: () => Promise,
  368. save: (attrs: { [key: string]: any }) => Promise,
  369. };*/
  370. /*:: type CryptoController = {
  371. encrypt: (obj: any, secretKey: string) => string,
  372. decrypt: (encryptedText: string, secretKey: any) => string,
  373. };*/
  374. /*:: type FileController = {
  375. saveFile: (name: string, source: FileSource, options: FullOptions) => Promise,
  376. saveBase64: (name: string, source: FileSource, options: FullOptions) => Promise,
  377. download: (uri: string) => Promise,
  378. };*/
  379. /*:: type InstallationController = {
  380. currentInstallationId: () => Promise,
  381. };*/
  382. /*:: type ObjectController = {
  383. fetch: (
  384. object: ParseObject | Array<ParseObject>,
  385. forceFetch: boolean,
  386. options: RequestOptions
  387. ) => Promise,
  388. save: (object: ParseObject | Array<ParseObject | ParseFile>, options: RequestOptions) => Promise,
  389. destroy: (object: ParseObject | Array<ParseObject>, options: RequestOptions) => Promise,
  390. };*/
  391. /*:: type ObjectStateController = {
  392. getState: (obj: any) => ?State,
  393. initializeState: (obj: any, initial?: State) => State,
  394. removeState: (obj: any) => ?State,
  395. getServerData: (obj: any) => AttributeMap,
  396. setServerData: (obj: any, attributes: AttributeMap) => void,
  397. getPendingOps: (obj: any) => Array<OpsMap>,
  398. setPendingOp: (obj: any, attr: string, op: ?Op) => void,
  399. pushPendingState: (obj: any) => void,
  400. popPendingState: (obj: any) => OpsMap,
  401. mergeFirstPendingState: (obj: any) => void,
  402. getObjectCache: (obj: any) => ObjectCache,
  403. estimateAttribute: (obj: any, attr: string) => mixed,
  404. estimateAttributes: (obj: any) => AttributeMap,
  405. commitServerChanges: (obj: any, changes: AttributeMap) => void,
  406. enqueueTask: (obj: any, task: () => Promise) => Promise,
  407. clearAllState: () => void,
  408. duplicateState: (source: any, dest: any) => void,
  409. };*/
  410. /*:: type PushController = {
  411. send: (data: PushData) => Promise,
  412. };*/
  413. /*:: type QueryController = {
  414. find: (className: string, params: QueryJSON, options: RequestOptions) => Promise,
  415. aggregate: (className: string, params: any, options: RequestOptions) => Promise,
  416. };*/
  417. /*:: type RESTController = {
  418. request: (method: string, path: string, data: mixed, options: RequestOptions) => Promise,
  419. ajax: (method: string, url: string, data: any, headers?: any, options: FullOptions) => Promise,
  420. };*/
  421. /*:: type SchemaController = {
  422. purge: (className: string) => Promise,
  423. get: (className: string, options: RequestOptions) => Promise,
  424. delete: (className: string, options: RequestOptions) => Promise,
  425. create: (className: string, params: any, options: RequestOptions) => Promise,
  426. update: (className: string, params: any, options: RequestOptions) => Promise,
  427. send(className: string, method: string, params: any, options: RequestOptions): Promise,
  428. };*/
  429. /*:: type SessionController = {
  430. getSession: (token: RequestOptions) => Promise,
  431. };*/
  432. /*:: type StorageController =
  433. | {
  434. async: 0,
  435. getItem: (path: string) => ?string,
  436. setItem: (path: string, value: string) => void,
  437. removeItem: (path: string) => void,
  438. getItemAsync?: (path: string) => Promise,
  439. setItemAsync?: (path: string, value: string) => Promise,
  440. removeItemAsync?: (path: string) => Promise,
  441. clear: () => void,
  442. }
  443. | {
  444. async: 1,
  445. getItem?: (path: string) => ?string,
  446. setItem?: (path: string, value: string) => void,
  447. removeItem?: (path: string) => void,
  448. getItemAsync: (path: string) => Promise,
  449. setItemAsync: (path: string, value: string) => Promise,
  450. removeItemAsync: (path: string) => Promise,
  451. clear: () => void,
  452. };*/
  453. /*:: type LocalDatastoreController = {
  454. fromPinWithName: (name: string) => ?any,
  455. pinWithName: (name: string, objects: any) => void,
  456. unPinWithName: (name: string) => void,
  457. getAllContents: () => ?any,
  458. clear: () => void,
  459. };*/
  460. /*:: type UserController = {
  461. setCurrentUser: (user: ParseUser) => Promise,
  462. currentUser: () => ?ParseUser,
  463. currentUserAsync: () => Promise,
  464. signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise,
  465. logIn: (user: ParseUser, options: RequestOptions) => Promise,
  466. become: (options: RequestOptions) => Promise,
  467. hydrate: (userJSON: AttributeMap) => Promise,
  468. logOut: (options: RequestOptions) => Promise,
  469. me: (options: RequestOptions) => Promise,
  470. requestPasswordReset: (email: string, options: RequestOptions) => Promise,
  471. updateUserOnDisk: (user: ParseUser) => Promise,
  472. upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise,
  473. linkWith: (user: ParseUser, authData: AuthData) => Promise,
  474. removeUserFromDisk: () => Promise,
  475. verifyPassword: (username: string, password: string, options: RequestOptions) => Promise,
  476. requestEmailVerification: (email: string, options: RequestOptions) => Promise,
  477. };*/
  478. /*:: type HooksController = {
  479. get: (type: string, functionName?: string, triggerName?: string) => Promise,
  480. create: (hook: mixed) => Promise,
  481. delete: (hook: mixed) => Promise,
  482. update: (hook: mixed) => Promise,
  483. send: (method: string, path: string, body?: mixed) => Promise,
  484. };*/
  485. /*:: type WebSocketController = {
  486. onopen: () => void,
  487. onmessage: (message: any) => void,
  488. onclose: () => void,
  489. onerror: (error: any) => void,
  490. send: (data: any) => void,
  491. close: () => void,
  492. };*/
  493. /*:: type Config = {
  494. AnalyticsController?: AnalyticsController,
  495. CloudController?: CloudController,
  496. ConfigController?: ConfigController,
  497. FileController?: FileController,
  498. InstallationController?: InstallationController,
  499. ObjectController?: ObjectController,
  500. ObjectStateController?: ObjectStateController,
  501. PushController?: PushController,
  502. QueryController?: QueryController,
  503. RESTController?: RESTController,
  504. SchemaController?: SchemaController,
  505. SessionController?: SessionController,
  506. StorageController?: StorageController,
  507. LocalDatastoreController?: LocalDatastoreController,
  508. UserController?: UserController,
  509. HooksController?: HooksController,
  510. WebSocketController?: WebSocketController,
  511. };*/
  512. var config /*: Config & { [key: string]: mixed }*/ = {
  513. // Defaults
  514. IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node && !process.versions.electron,
  515. REQUEST_ATTEMPT_LIMIT: 5,
  516. REQUEST_BATCH_SIZE: 20,
  517. REQUEST_HEADERS: {},
  518. SERVER_URL: 'https://api.parse.com/1',
  519. SERVER_AUTH_TYPE: null,
  520. SERVER_AUTH_TOKEN: null,
  521. LIVEQUERY_SERVER_URL: null,
  522. ENCRYPTED_KEY: null,
  523. VERSION: 'js' + "4.2.0",
  524. APPLICATION_ID: null,
  525. JAVASCRIPT_KEY: null,
  526. MASTER_KEY: null,
  527. USE_MASTER_KEY: false,
  528. PERFORM_USER_REWRITE: true,
  529. FORCE_REVOCABLE_SESSION: false,
  530. ENCRYPTED_USER: false,
  531. IDEMPOTENCY: false,
  532. ALLOW_CUSTOM_OBJECT_ID: false
  533. };
  534. function requireMethods(name /*: string*/, methods /*: Array<string>*/, controller /*: any*/) {
  535. (0, _forEach.default)(methods).call(methods, function (func) {
  536. if (typeof controller[func] !== 'function') {
  537. var _context;
  538. throw new Error((0, _concat.default)(_context = "".concat(name, " must implement ")).call(_context, func, "()"));
  539. }
  540. });
  541. }
  542. module.exports = {
  543. get: function (key /*: string*/) /*: any*/{
  544. if (config.hasOwnProperty(key)) {
  545. return config[key];
  546. }
  547. throw new Error('Configuration key not found: ' + key);
  548. },
  549. set: function (key /*: string*/, value /*: any*/) /*: void*/{
  550. config[key] = value;
  551. },
  552. /* Specialized Controller Setters/Getters */setAnalyticsController: function (controller /*: AnalyticsController*/) {
  553. requireMethods('AnalyticsController', ['track'], controller);
  554. config['AnalyticsController'] = controller;
  555. },
  556. getAnalyticsController: function () /*: AnalyticsController*/{
  557. return config['AnalyticsController'];
  558. },
  559. setCloudController: function (controller /*: CloudController*/) {
  560. requireMethods('CloudController', ['run', 'getJobsData', 'startJob'], controller);
  561. config['CloudController'] = controller;
  562. },
  563. getCloudController: function () /*: CloudController*/{
  564. return config['CloudController'];
  565. },
  566. setConfigController: function (controller /*: ConfigController*/) {
  567. requireMethods('ConfigController', ['current', 'get', 'save'], controller);
  568. config['ConfigController'] = controller;
  569. },
  570. getConfigController: function () /*: ConfigController*/{
  571. return config['ConfigController'];
  572. },
  573. setCryptoController: function (controller /*: CryptoController*/) {
  574. requireMethods('CryptoController', ['encrypt', 'decrypt'], controller);
  575. config['CryptoController'] = controller;
  576. },
  577. getCryptoController: function () /*: CryptoController*/{
  578. return config['CryptoController'];
  579. },
  580. setFileController: function (controller /*: FileController*/) {
  581. requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
  582. config['FileController'] = controller;
  583. },
  584. getFileController: function () /*: FileController*/{
  585. return config['FileController'];
  586. },
  587. setInstallationController: function (controller /*: InstallationController*/) {
  588. requireMethods('InstallationController', ['currentInstallationId'], controller);
  589. config['InstallationController'] = controller;
  590. },
  591. getInstallationController: function () /*: InstallationController*/{
  592. return config['InstallationController'];
  593. },
  594. setObjectController: function (controller /*: ObjectController*/) {
  595. requireMethods('ObjectController', ['save', 'fetch', 'destroy'], controller);
  596. config['ObjectController'] = controller;
  597. },
  598. getObjectController: function () /*: ObjectController*/{
  599. return config['ObjectController'];
  600. },
  601. setObjectStateController: function (controller /*: ObjectStateController*/) {
  602. requireMethods('ObjectStateController', ['getState', 'initializeState', 'removeState', 'getServerData', 'setServerData', 'getPendingOps', 'setPendingOp', 'pushPendingState', 'popPendingState', 'mergeFirstPendingState', 'getObjectCache', 'estimateAttribute', 'estimateAttributes', 'commitServerChanges', 'enqueueTask', 'clearAllState'], controller);
  603. config['ObjectStateController'] = controller;
  604. },
  605. getObjectStateController: function () /*: ObjectStateController*/{
  606. return config['ObjectStateController'];
  607. },
  608. setPushController: function (controller /*: PushController*/) {
  609. requireMethods('PushController', ['send'], controller);
  610. config['PushController'] = controller;
  611. },
  612. getPushController: function () /*: PushController*/{
  613. return config['PushController'];
  614. },
  615. setQueryController: function (controller /*: QueryController*/) {
  616. requireMethods('QueryController', ['find', 'aggregate'], controller);
  617. config['QueryController'] = controller;
  618. },
  619. getQueryController: function () /*: QueryController*/{
  620. return config['QueryController'];
  621. },
  622. setRESTController: function (controller /*: RESTController*/) {
  623. requireMethods('RESTController', ['request', 'ajax'], controller);
  624. config['RESTController'] = controller;
  625. },
  626. getRESTController: function () /*: RESTController*/{
  627. return config['RESTController'];
  628. },
  629. setSchemaController: function (controller /*: SchemaController*/) {
  630. requireMethods('SchemaController', ['get', 'create', 'update', 'delete', 'send', 'purge'], controller);
  631. config['SchemaController'] = controller;
  632. },
  633. getSchemaController: function () /*: SchemaController*/{
  634. return config['SchemaController'];
  635. },
  636. setSessionController: function (controller /*: SessionController*/) {
  637. requireMethods('SessionController', ['getSession'], controller);
  638. config['SessionController'] = controller;
  639. },
  640. getSessionController: function () /*: SessionController*/{
  641. return config['SessionController'];
  642. },
  643. setStorageController: function (controller /*: StorageController*/) {
  644. if (controller.async) {
  645. requireMethods('An async StorageController', ['getItemAsync', 'setItemAsync', 'removeItemAsync', 'getAllKeysAsync'], controller);
  646. } else {
  647. requireMethods('A synchronous StorageController', ['getItem', 'setItem', 'removeItem', 'getAllKeys'], controller);
  648. }
  649. config['StorageController'] = controller;
  650. },
  651. setLocalDatastoreController: function (controller /*: LocalDatastoreController*/) {
  652. requireMethods('LocalDatastoreController', ['pinWithName', 'fromPinWithName', 'unPinWithName', 'getAllContents', 'clear'], controller);
  653. config['LocalDatastoreController'] = controller;
  654. },
  655. getLocalDatastoreController: function () /*: LocalDatastoreController*/{
  656. return config['LocalDatastoreController'];
  657. },
  658. setLocalDatastore: function (store /*: any*/) {
  659. config['LocalDatastore'] = store;
  660. },
  661. getLocalDatastore: function () {
  662. return config['LocalDatastore'];
  663. },
  664. getStorageController: function () /*: StorageController*/{
  665. return config['StorageController'];
  666. },
  667. setAsyncStorage: function (storage /*: any*/) {
  668. config['AsyncStorage'] = storage;
  669. },
  670. getAsyncStorage: function () {
  671. return config['AsyncStorage'];
  672. },
  673. setWebSocketController: function (controller /*: WebSocketController*/) {
  674. config['WebSocketController'] = controller;
  675. },
  676. getWebSocketController: function () /*: WebSocketController*/{
  677. return config['WebSocketController'];
  678. },
  679. setUserController: function (controller /*: UserController*/) {
  680. requireMethods('UserController', ['setCurrentUser', 'currentUser', 'currentUserAsync', 'signUp', 'logIn', 'become', 'logOut', 'me', 'requestPasswordReset', 'upgradeToRevocableSession', 'requestEmailVerification', 'verifyPassword', 'linkWith'], controller);
  681. config['UserController'] = controller;
  682. },
  683. getUserController: function () /*: UserController*/{
  684. return config['UserController'];
  685. },
  686. setLiveQueryController: function (controller /*: any*/) {
  687. requireMethods('LiveQueryController', ['setDefaultLiveQueryClient', 'getDefaultLiveQueryClient', '_clearCachedDefaultClient'], controller);
  688. config['LiveQueryController'] = controller;
  689. },
  690. getLiveQueryController: function () /*: any*/{
  691. return config['LiveQueryController'];
  692. },
  693. setHooksController: function (controller /*: HooksController*/) {
  694. requireMethods('HooksController', ['create', 'get', 'update', 'remove'], controller);
  695. config['HooksController'] = controller;
  696. },
  697. getHooksController: function () /*: HooksController*/{
  698. return config['HooksController'];
  699. }
  700. };
  701. }).call(this)}).call(this,_dereq_('_process'))
  702. },{"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"_process":148}],5:[function(_dereq_,module,exports){
  703. "use strict";
  704. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  705. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  706. var AES;
  707. var ENC;
  708. AES = _dereq_('crypto-js/aes');
  709. ENC = _dereq_('crypto-js/enc-utf8');
  710. var CryptoJS;
  711. var CryptoController = {
  712. encrypt: function (obj /*: any*/, secretKey /*: string*/) /*: ?string*/{
  713. var encrypted = AES.encrypt((0, _stringify.default)(obj), secretKey);
  714. return encrypted.toString();
  715. },
  716. decrypt: function (encryptedText /*: string*/, secretKey /*: string*/) /*: ?string*/{
  717. var decryptedStr = AES.decrypt(encryptedText, secretKey).toString(ENC);
  718. return decryptedStr;
  719. }
  720. };
  721. module.exports = CryptoController;
  722. },{"@babel/runtime-corejs3/core-js-stable/json/stringify":75,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"crypto-js/aes":611,"crypto-js/enc-utf8":615}],6:[function(_dereq_,module,exports){
  723. "use strict";
  724. /**
  725. * This is a simple wrapper to unify EventEmitter implementations across platforms.
  726. */
  727. module.exports = _dereq_('events').EventEmitter;
  728. var EventEmitter;
  729. },{"events":620}],7:[function(_dereq_,module,exports){
  730. "use strict";
  731. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  732. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  733. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  734. var _findIndex = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
  735. var _setInterval2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-interval"));
  736. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  737. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  738. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  739. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  740. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  741. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  742. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  743. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  744. /**
  745. * https://github.com/francimedia/parse-js-local-storage
  746. *
  747. * @flow
  748. */
  749. /*:: import type { SaveOptions } from './ParseObject';*/
  750. /*:: import type { RequestOptions } from './RESTController';*/
  751. /*:: type QueueObject = {
  752. queueId: string,
  753. action: string,
  754. object: ParseObject,
  755. serverOptions: SaveOptions | RequestOptions,
  756. id: string,
  757. className: string,
  758. hash: string,
  759. createdAt: Date,
  760. };*/
  761. /*:: type Queue = Array<QueueObject>;*/
  762. var QUEUE_KEY = 'Parse/Eventually/Queue';
  763. var queueCache = [];
  764. var dirtyCache = true;
  765. var polling = undefined;
  766. /**
  767. * Provides utility functions to queue objects that will be
  768. * saved to the server at a later date.
  769. *
  770. * @class Parse.EventuallyQueue
  771. * @static
  772. */
  773. var EventuallyQueue = {
  774. /**
  775. * Add object to queue with save operation.
  776. *
  777. * @function save
  778. * @name Parse.EventuallyQueue.save
  779. * @param {ParseObject} object Parse.Object to be saved eventually
  780. * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#save Parse.Object.save} options.
  781. * @returns {Promise} A promise that is fulfilled if object is added to queue.
  782. * @static
  783. * @see Parse.Object#saveEventually
  784. */
  785. save: function (object /*: ParseObject*/) /*: Promise*/{
  786. var serverOptions /*: SaveOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  787. return this.enqueue('save', object, serverOptions);
  788. },
  789. /**
  790. * Add object to queue with save operation.
  791. *
  792. * @function destroy
  793. * @name Parse.EventuallyQueue.destroy
  794. * @param {ParseObject} object Parse.Object to be destroyed eventually
  795. * @param {object} [serverOptions] See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html#destroy Parse.Object.destroy} options
  796. * @returns {Promise} A promise that is fulfilled if object is added to queue.
  797. * @static
  798. * @see Parse.Object#destroyEventually
  799. */
  800. destroy: function (object /*: ParseObject*/) /*: Promise*/{
  801. var serverOptions /*: RequestOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  802. return this.enqueue('destroy', object, serverOptions);
  803. },
  804. /**
  805. * Generate unique identifier to avoid duplicates and maintain previous state.
  806. *
  807. * @param {string} action save / destroy
  808. * @param {object} object Parse.Object to be queued
  809. * @returns {string}
  810. * @static
  811. * @ignore
  812. */
  813. generateQueueId: function (action /*: string*/, object /*: ParseObject*/) /*: string*/{
  814. object._getId();
  815. var className = object.className,
  816. id = object.id,
  817. _localId = object._localId;
  818. var uniqueId = object.get('hash') || _localId;
  819. return [action, className, id, uniqueId].join('_');
  820. },
  821. /**
  822. * Build queue object and add to queue.
  823. *
  824. * @param {string} action save / destroy
  825. * @param {object} object Parse.Object to be queued
  826. * @param {object} [serverOptions]
  827. * @returns {Promise} A promise that is fulfilled if object is added to queue.
  828. * @static
  829. * @ignore
  830. */
  831. enqueue: function (action /*: string*/, object /*: ParseObject*/, serverOptions /*: SaveOptions | RequestOptions*/) /*: Promise*/{
  832. var _this = this;
  833. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  834. var queueData, queueId, index, prop;
  835. return _regenerator.default.wrap(function (_context) {
  836. while (1) switch (_context.prev = _context.next) {
  837. case 0:
  838. _context.next = 2;
  839. return _this.getQueue();
  840. case 2:
  841. queueData = _context.sent;
  842. queueId = _this.generateQueueId(action, object);
  843. index = _this.queueItemExists(queueData, queueId);
  844. if (index > -1) {
  845. // Add cached values to new object if they don't exist
  846. for (prop in queueData[index].object) {
  847. if (typeof object.get(prop) === 'undefined') {
  848. object.set(prop, queueData[index].object[prop]);
  849. }
  850. }
  851. } else {
  852. index = queueData.length;
  853. }
  854. queueData[index] = {
  855. queueId: queueId,
  856. action: action,
  857. object: object.toJSON(),
  858. serverOptions: serverOptions,
  859. id: object.id,
  860. className: object.className,
  861. hash: object.get('hash'),
  862. createdAt: new Date()
  863. };
  864. return _context.abrupt("return", _this.setQueue(queueData));
  865. case 8:
  866. case "end":
  867. return _context.stop();
  868. }
  869. }, _callee);
  870. }))();
  871. },
  872. store: function (data) {
  873. return _Storage.default.setItemAsync(QUEUE_KEY, (0, _stringify.default)(data));
  874. },
  875. load: function () {
  876. return _Storage.default.getItemAsync(QUEUE_KEY);
  877. },
  878. /**
  879. * Sets the in-memory queue from local storage and returns.
  880. *
  881. * @function getQueue
  882. * @name Parse.EventuallyQueue.getQueue
  883. * @returns {Promise<Array>}
  884. * @static
  885. */
  886. getQueue: function () /*: Promise<Array>*/{
  887. var _this2 = this;
  888. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  889. return _regenerator.default.wrap(function (_context2) {
  890. while (1) switch (_context2.prev = _context2.next) {
  891. case 0:
  892. if (!dirtyCache) {
  893. _context2.next = 10;
  894. break;
  895. }
  896. _context2.t0 = JSON;
  897. _context2.next = 4;
  898. return _this2.load();
  899. case 4:
  900. _context2.t1 = _context2.sent;
  901. if (_context2.t1) {
  902. _context2.next = 7;
  903. break;
  904. }
  905. _context2.t1 = '[]';
  906. case 7:
  907. _context2.t2 = _context2.t1;
  908. queueCache = _context2.t0.parse.call(_context2.t0, _context2.t2);
  909. dirtyCache = false;
  910. case 10:
  911. return _context2.abrupt("return", queueCache);
  912. case 11:
  913. case "end":
  914. return _context2.stop();
  915. }
  916. }, _callee2);
  917. }))();
  918. },
  919. /**
  920. * Saves the queue to local storage
  921. *
  922. * @param {Queue} queue Queue containing Parse.Object data.
  923. * @returns {Promise} A promise that is fulfilled when queue is stored.
  924. * @static
  925. * @ignore
  926. */
  927. setQueue: function (queue /*: Queue*/) /*: Promise<void>*/{
  928. queueCache = queue;
  929. return this.store(queueCache);
  930. },
  931. /**
  932. * Removes Parse.Object data from queue.
  933. *
  934. * @param {string} queueId Unique identifier for Parse.Object data.
  935. * @returns {Promise} A promise that is fulfilled when queue is stored.
  936. * @static
  937. * @ignore
  938. */
  939. remove: function (queueId /*: string*/) /*: Promise<void>*/{
  940. var _this3 = this;
  941. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  942. var queueData, index;
  943. return _regenerator.default.wrap(function (_context3) {
  944. while (1) switch (_context3.prev = _context3.next) {
  945. case 0:
  946. _context3.next = 2;
  947. return _this3.getQueue();
  948. case 2:
  949. queueData = _context3.sent;
  950. index = _this3.queueItemExists(queueData, queueId);
  951. if (!(index > -1)) {
  952. _context3.next = 8;
  953. break;
  954. }
  955. (0, _splice.default)(queueData).call(queueData, index, 1);
  956. _context3.next = 8;
  957. return _this3.setQueue(queueData);
  958. case 8:
  959. case "end":
  960. return _context3.stop();
  961. }
  962. }, _callee3);
  963. }))();
  964. },
  965. /**
  966. * Removes all objects from queue.
  967. *
  968. * @function clear
  969. * @name Parse.EventuallyQueue.clear
  970. * @returns {Promise} A promise that is fulfilled when queue is cleared.
  971. * @static
  972. */
  973. clear: function () /*: Promise*/{
  974. queueCache = [];
  975. return this.store([]);
  976. },
  977. /**
  978. * Return the index of a queueId in the queue. Returns -1 if not found.
  979. *
  980. * @param {Queue} queue Queue containing Parse.Object data.
  981. * @param {string} queueId Unique identifier for Parse.Object data.
  982. * @returns {number}
  983. * @static
  984. * @ignore
  985. */
  986. queueItemExists: function (queue /*: Queue*/, queueId /*: string*/) /*: number*/{
  987. return (0, _findIndex.default)(queue).call(queue, function (data) {
  988. return data.queueId === queueId;
  989. });
  990. },
  991. /**
  992. * Return the number of objects in the queue.
  993. *
  994. * @function length
  995. * @name Parse.EventuallyQueue.length
  996. * @returns {number}
  997. * @static
  998. */
  999. length: function () /*: number*/{
  1000. var _this4 = this;
  1001. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
  1002. var queueData;
  1003. return _regenerator.default.wrap(function (_context4) {
  1004. while (1) switch (_context4.prev = _context4.next) {
  1005. case 0:
  1006. _context4.next = 2;
  1007. return _this4.getQueue();
  1008. case 2:
  1009. queueData = _context4.sent;
  1010. return _context4.abrupt("return", queueData.length);
  1011. case 4:
  1012. case "end":
  1013. return _context4.stop();
  1014. }
  1015. }, _callee4);
  1016. }))();
  1017. },
  1018. /**
  1019. * Sends the queue to the server.
  1020. *
  1021. * @function sendQueue
  1022. * @name Parse.EventuallyQueue.sendQueue
  1023. * @returns {Promise<boolean>} Returns true if queue was sent successfully.
  1024. * @static
  1025. */
  1026. sendQueue: function () /*: Promise<boolean>*/{
  1027. var _this5 = this;
  1028. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  1029. var queue, queueData, i, queueObject, id, hash, className, ObjectType;
  1030. return _regenerator.default.wrap(function (_context5) {
  1031. while (1) switch (_context5.prev = _context5.next) {
  1032. case 0:
  1033. _context5.next = 2;
  1034. return _this5.getQueue();
  1035. case 2:
  1036. queue = _context5.sent;
  1037. queueData = (0, _toConsumableArray2.default)(queue);
  1038. if (!(queueData.length === 0)) {
  1039. _context5.next = 6;
  1040. break;
  1041. }
  1042. return _context5.abrupt("return", false);
  1043. case 6:
  1044. i = 0;
  1045. case 7:
  1046. if (!(i < queueData.length)) {
  1047. _context5.next = 26;
  1048. break;
  1049. }
  1050. queueObject = queueData[i];
  1051. id = queueObject.id, hash = queueObject.hash, className = queueObject.className;
  1052. ObjectType = _ParseObject.default.extend(className);
  1053. if (!id) {
  1054. _context5.next = 16;
  1055. break;
  1056. }
  1057. _context5.next = 14;
  1058. return _this5.process.byId(ObjectType, queueObject);
  1059. case 14:
  1060. _context5.next = 23;
  1061. break;
  1062. case 16:
  1063. if (!hash) {
  1064. _context5.next = 21;
  1065. break;
  1066. }
  1067. _context5.next = 19;
  1068. return _this5.process.byHash(ObjectType, queueObject);
  1069. case 19:
  1070. _context5.next = 23;
  1071. break;
  1072. case 21:
  1073. _context5.next = 23;
  1074. return _this5.process.create(ObjectType, queueObject);
  1075. case 23:
  1076. i += 1;
  1077. _context5.next = 7;
  1078. break;
  1079. case 26:
  1080. return _context5.abrupt("return", true);
  1081. case 27:
  1082. case "end":
  1083. return _context5.stop();
  1084. }
  1085. }, _callee5);
  1086. }))();
  1087. },
  1088. /**
  1089. * Build queue object and add to queue.
  1090. *
  1091. * @param {ParseObject} object Parse.Object to be processed
  1092. * @param {QueueObject} queueObject Parse.Object data from the queue
  1093. * @returns {Promise} A promise that is fulfilled when operation is performed.
  1094. * @static
  1095. * @ignore
  1096. */
  1097. sendQueueCallback: function (object /*: ParseObject*/, queueObject /*: QueueObject*/) /*: Promise<void>*/{
  1098. var _this6 = this;
  1099. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  1100. return _regenerator.default.wrap(function (_context6) {
  1101. while (1) switch (_context6.prev = _context6.next) {
  1102. case 0:
  1103. if (object) {
  1104. _context6.next = 2;
  1105. break;
  1106. }
  1107. return _context6.abrupt("return", _this6.remove(queueObject.queueId));
  1108. case 2:
  1109. _context6.t0 = queueObject.action;
  1110. _context6.next = _context6.t0 === 'save' ? 5 : _context6.t0 === 'destroy' ? 20 : 33;
  1111. break;
  1112. case 5:
  1113. if (!(typeof object.updatedAt !== 'undefined' && object.updatedAt > new Date(queueObject.object.createdAt))) {
  1114. _context6.next = 7;
  1115. break;
  1116. }
  1117. return _context6.abrupt("return", _this6.remove(queueObject.queueId));
  1118. case 7:
  1119. _context6.prev = 7;
  1120. _context6.next = 10;
  1121. return object.save(queueObject.object, queueObject.serverOptions);
  1122. case 10:
  1123. _context6.next = 12;
  1124. return _this6.remove(queueObject.queueId);
  1125. case 12:
  1126. _context6.next = 19;
  1127. break;
  1128. case 14:
  1129. _context6.prev = 14;
  1130. _context6.t1 = _context6["catch"](7);
  1131. if (!(_context6.t1.message !== 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
  1132. _context6.next = 19;
  1133. break;
  1134. }
  1135. _context6.next = 19;
  1136. return _this6.remove(queueObject.queueId);
  1137. case 19:
  1138. return _context6.abrupt("break", 33);
  1139. case 20:
  1140. _context6.prev = 20;
  1141. _context6.next = 23;
  1142. return object.destroy(queueObject.serverOptions);
  1143. case 23:
  1144. _context6.next = 25;
  1145. return _this6.remove(queueObject.queueId);
  1146. case 25:
  1147. _context6.next = 32;
  1148. break;
  1149. case 27:
  1150. _context6.prev = 27;
  1151. _context6.t2 = _context6["catch"](20);
  1152. if (!(_context6.t2.message !== 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
  1153. _context6.next = 32;
  1154. break;
  1155. }
  1156. _context6.next = 32;
  1157. return _this6.remove(queueObject.queueId);
  1158. case 32:
  1159. return _context6.abrupt("break", 33);
  1160. case 33:
  1161. case "end":
  1162. return _context6.stop();
  1163. }
  1164. }, _callee6, null, [[7, 14], [20, 27]]);
  1165. }))();
  1166. },
  1167. /**
  1168. * Start polling server for network connection.
  1169. * Will send queue if connection is established.
  1170. *
  1171. * @function poll
  1172. * @name Parse.EventuallyQueue.poll
  1173. * @param [ms] Milliseconds to ping the server. Default 2000ms
  1174. * @static
  1175. */
  1176. poll: function () {
  1177. var _this7 = this;
  1178. var ms /*: number*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
  1179. if (polling) {
  1180. return;
  1181. }
  1182. polling = (0, _setInterval2.default)(function () {
  1183. var RESTController = _CoreManager.default.getRESTController();
  1184. RESTController.request('GET', 'health').then(function (_ref) {
  1185. var status = _ref.status;
  1186. if (status === 'ok') {
  1187. _this7.stopPoll();
  1188. return _this7.sendQueue();
  1189. }
  1190. }).catch(function (e) {
  1191. return e;
  1192. });
  1193. }, ms);
  1194. },
  1195. /**
  1196. * Turns off polling.
  1197. *
  1198. * @function stopPoll
  1199. * @name Parse.EventuallyQueue.stopPoll
  1200. * @static
  1201. */
  1202. stopPoll: function () {
  1203. clearInterval(polling);
  1204. polling = undefined;
  1205. },
  1206. /**
  1207. * Return true if pinging the server.
  1208. *
  1209. * @function isPolling
  1210. * @name Parse.EventuallyQueue.isPolling
  1211. * @returns {boolean}
  1212. * @static
  1213. */
  1214. isPolling: function () /*: boolean*/{
  1215. return !!polling;
  1216. },
  1217. _setPolling: function (flag /*: boolean*/) {
  1218. polling = flag;
  1219. },
  1220. process: {
  1221. create: function (ObjectType, queueObject) {
  1222. var object = new ObjectType();
  1223. return EventuallyQueue.sendQueueCallback(object, queueObject);
  1224. },
  1225. byId: function (ObjectType, queueObject) {
  1226. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
  1227. var sessionToken, query, results;
  1228. return _regenerator.default.wrap(function (_context7) {
  1229. while (1) switch (_context7.prev = _context7.next) {
  1230. case 0:
  1231. sessionToken = queueObject.serverOptions.sessionToken;
  1232. query = new _ParseQuery.default(ObjectType);
  1233. query.equalTo('objectId', queueObject.id);
  1234. _context7.next = 5;
  1235. return (0, _find.default)(query).call(query, {
  1236. sessionToken: sessionToken
  1237. });
  1238. case 5:
  1239. results = _context7.sent;
  1240. return _context7.abrupt("return", EventuallyQueue.sendQueueCallback(results[0], queueObject));
  1241. case 7:
  1242. case "end":
  1243. return _context7.stop();
  1244. }
  1245. }, _callee7);
  1246. }))();
  1247. },
  1248. byHash: function (ObjectType, queueObject) {
  1249. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
  1250. var sessionToken, query, results;
  1251. return _regenerator.default.wrap(function (_context8) {
  1252. while (1) switch (_context8.prev = _context8.next) {
  1253. case 0:
  1254. sessionToken = queueObject.serverOptions.sessionToken;
  1255. query = new _ParseQuery.default(ObjectType);
  1256. query.equalTo('hash', queueObject.hash);
  1257. _context8.next = 5;
  1258. return (0, _find.default)(query).call(query, {
  1259. sessionToken: sessionToken
  1260. });
  1261. case 5:
  1262. results = _context8.sent;
  1263. if (!(results.length > 0)) {
  1264. _context8.next = 8;
  1265. break;
  1266. }
  1267. return _context8.abrupt("return", EventuallyQueue.sendQueueCallback(results[0], queueObject));
  1268. case 8:
  1269. return _context8.abrupt("return", EventuallyQueue.process.create(ObjectType, queueObject));
  1270. case 9:
  1271. case "end":
  1272. return _context8.stop();
  1273. }
  1274. }, _callee8);
  1275. }))();
  1276. }
  1277. }
  1278. };
  1279. module.exports = EventuallyQueue;
  1280. },{"./CoreManager":4,"./ParseObject":27,"./ParseQuery":30,"./Storage":39,"@babel/runtime-corejs3/core-js-stable/instance/find":63,"@babel/runtime-corejs3/core-js-stable/instance/find-index":62,"@babel/runtime-corejs3/core-js-stable/instance/splice":72,"@babel/runtime-corejs3/core-js-stable/json/stringify":75,"@babel/runtime-corejs3/core-js-stable/set-interval":92,"@babel/runtime-corejs3/helpers/asyncToGenerator":121,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/toConsumableArray":141,"@babel/runtime-corejs3/regenerator":147}],8:[function(_dereq_,module,exports){
  1281. "use strict";
  1282. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  1283. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1284. _Object$defineProperty(exports, "__esModule", {
  1285. value: true
  1286. });
  1287. exports.default = void 0;
  1288. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  1289. /**
  1290. * @flow-weak
  1291. */
  1292. /* global FB */
  1293. var initialized = false;
  1294. var requestedPermissions;
  1295. var initOptions;
  1296. var provider = {
  1297. authenticate: function (options) {
  1298. var _this = this;
  1299. if (typeof FB === 'undefined') {
  1300. options.error(this, 'Facebook SDK not found.');
  1301. }
  1302. FB.login(function (response) {
  1303. if (response.authResponse) {
  1304. if (options.success) {
  1305. options.success(_this, {
  1306. id: response.authResponse.userID,
  1307. access_token: response.authResponse.accessToken,
  1308. expiration_date: new Date(response.authResponse.expiresIn * 1000 + new Date().getTime()).toJSON()
  1309. });
  1310. }
  1311. } else {
  1312. if (options.error) {
  1313. options.error(_this, response);
  1314. }
  1315. }
  1316. }, {
  1317. scope: requestedPermissions
  1318. });
  1319. },
  1320. restoreAuthentication: function (authData) {
  1321. if (authData) {
  1322. var newOptions = {};
  1323. if (initOptions) {
  1324. for (var key in initOptions) {
  1325. newOptions[key] = initOptions[key];
  1326. }
  1327. }
  1328. // Suppress checks for login status from the browser.
  1329. newOptions.status = false;
  1330. // If the user doesn't match the one known by the FB SDK, log out.
  1331. // Most of the time, the users will match -- it's only in cases where
  1332. // the FB SDK knows of a different user than the one being restored
  1333. // from a Parse User that logged in with username/password.
  1334. var existingResponse = FB.getAuthResponse();
  1335. if (existingResponse && existingResponse.userID !== authData.id) {
  1336. FB.logout();
  1337. }
  1338. FB.init(newOptions);
  1339. }
  1340. return true;
  1341. },
  1342. getAuthType: function () {
  1343. return 'facebook';
  1344. },
  1345. deauthenticate: function () {
  1346. this.restoreAuthentication(null);
  1347. }
  1348. };
  1349. /**
  1350. * Provides a set of utilities for using Parse with Facebook.
  1351. *
  1352. * @class Parse.FacebookUtils
  1353. * @static
  1354. * @hideconstructor
  1355. */
  1356. var FacebookUtils = {
  1357. /**
  1358. * Initializes Parse Facebook integration. Call this function after you
  1359. * have loaded the Facebook Javascript SDK with the same parameters
  1360. * as you would pass to<code>
  1361. * <a href=
  1362. * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
  1363. * FB.init()</a></code>. Parse.FacebookUtils will invoke FB.init() for you
  1364. * with these arguments.
  1365. *
  1366. * @function init
  1367. * @name Parse.FacebookUtils.init
  1368. * @param {object} options Facebook options argument as described here:
  1369. * <a href=
  1370. * "https://developers.facebook.com/docs/reference/javascript/FB.init/">
  1371. * FB.init()</a>. The status flag will be coerced to 'false' because it
  1372. * interferes with Parse Facebook integration. Call FB.getLoginStatus()
  1373. * explicitly if this behavior is required by your application.
  1374. */
  1375. init: function (options) {
  1376. if (typeof FB === 'undefined') {
  1377. throw new Error('The Facebook JavaScript SDK must be loaded before calling init.');
  1378. }
  1379. initOptions = {};
  1380. if (options) {
  1381. for (var key in options) {
  1382. initOptions[key] = options[key];
  1383. }
  1384. }
  1385. if (initOptions.status && typeof console !== 'undefined') {
  1386. var warn = console.warn || console.log || function () {}; // eslint-disable-line no-console
  1387. warn.call(console, 'The "status" flag passed into' + ' FB.init, when set to true, can interfere with Parse Facebook' + ' integration, so it has been suppressed. Please call' + ' FB.getLoginStatus() explicitly if you require this behavior.');
  1388. }
  1389. initOptions.status = false;
  1390. FB.init(initOptions);
  1391. _ParseUser.default._registerAuthenticationProvider(provider);
  1392. initialized = true;
  1393. },
  1394. /**
  1395. * Gets whether the user has their account linked to Facebook.
  1396. *
  1397. * @function isLinked
  1398. * @name Parse.FacebookUtils.isLinked
  1399. * @param {Parse.User} user User to check for a facebook link.
  1400. * The user must be logged in on this device.
  1401. * @returns {boolean} <code>true</code> if the user has their account
  1402. * linked to Facebook.
  1403. */
  1404. isLinked: function (user) {
  1405. return user._isLinked('facebook');
  1406. },
  1407. /**
  1408. * Logs in a user using Facebook. This method delegates to the Facebook
  1409. * SDK to authenticate the user, and then automatically logs in (or
  1410. * creates, in the case where it is a new user) a Parse.User.
  1411. *
  1412. * Standard API:
  1413. *
  1414. * <code>logIn(permission: string, authData: Object);</code>
  1415. *
  1416. * Advanced API: Used for handling your own oAuth tokens
  1417. * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
  1418. *
  1419. * <code>logIn(authData: Object, options?: Object);</code>
  1420. *
  1421. * @function logIn
  1422. * @name Parse.FacebookUtils.logIn
  1423. * @param {(string | object)} permissions The permissions required for Facebook
  1424. * log in. This is a comma-separated string of permissions.
  1425. * Alternatively, supply a Facebook authData object as described in our
  1426. * REST API docs if you want to handle getting facebook auth tokens
  1427. * yourself.
  1428. * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
  1429. * @returns {Promise}
  1430. */
  1431. logIn: function (permissions, options) {
  1432. if (!permissions || typeof permissions === 'string') {
  1433. if (!initialized) {
  1434. throw new Error('You must initialize FacebookUtils before calling logIn.');
  1435. }
  1436. requestedPermissions = permissions;
  1437. return _ParseUser.default.logInWith('facebook', options);
  1438. }
  1439. return _ParseUser.default.logInWith('facebook', {
  1440. authData: permissions
  1441. }, options);
  1442. },
  1443. /**
  1444. * Links Facebook to an existing PFUser. This method delegates to the
  1445. * Facebook SDK to authenticate the user, and then automatically links
  1446. * the account to the Parse.User.
  1447. *
  1448. * Standard API:
  1449. *
  1450. * <code>link(user: Parse.User, permission: string, authData?: Object);</code>
  1451. *
  1452. * Advanced API: Used for handling your own oAuth tokens
  1453. * {@link https://docs.parseplatform.org/rest/guide/#linking-users}
  1454. *
  1455. * <code>link(user: Parse.User, authData: Object, options?: FullOptions);</code>
  1456. *
  1457. * @function link
  1458. * @name Parse.FacebookUtils.link
  1459. * @param {Parse.User} user User to link to Facebook. This must be the
  1460. * current user.
  1461. * @param {(string | object)} permissions The permissions required for Facebook
  1462. * log in. This is a comma-separated string of permissions.
  1463. * Alternatively, supply a Facebook authData object as described in our
  1464. * REST API docs if you want to handle getting facebook auth tokens
  1465. * yourself.
  1466. * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
  1467. * @returns {Promise}
  1468. */
  1469. link: function (user, permissions, options) {
  1470. if (!permissions || typeof permissions === 'string') {
  1471. if (!initialized) {
  1472. throw new Error('You must initialize FacebookUtils before calling link.');
  1473. }
  1474. requestedPermissions = permissions;
  1475. return user.linkWith('facebook', options);
  1476. }
  1477. return user.linkWith('facebook', {
  1478. authData: permissions
  1479. }, options);
  1480. },
  1481. /**
  1482. * Unlinks the Parse.User from a Facebook account.
  1483. *
  1484. * @function unlink
  1485. * @name Parse.FacebookUtils.unlink
  1486. * @param {Parse.User} user User to unlink from Facebook. This must be the
  1487. * current user.
  1488. * @param {object} options Standard options object with success and error
  1489. * callbacks.
  1490. * @returns {Promise}
  1491. */
  1492. unlink: function (user, options) {
  1493. if (!initialized) {
  1494. throw new Error('You must initialize FacebookUtils before calling unlink.');
  1495. }
  1496. return user._unlinkFrom('facebook', options);
  1497. },
  1498. // Used for testing purposes
  1499. _getAuthProvider: function () {
  1500. return provider;
  1501. }
  1502. };
  1503. var _default = FacebookUtils;
  1504. exports.default = _default;
  1505. },{"./ParseUser":35,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],9:[function(_dereq_,module,exports){
  1506. "use strict";
  1507. var _keysInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys");
  1508. var _idbKeyval = _dereq_("idb-keyval");
  1509. /**
  1510. * @flow
  1511. */
  1512. /* global window */
  1513. if (typeof window !== 'undefined' && window.indexedDB) {
  1514. var ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
  1515. var IndexedDBStorageController = {
  1516. async: 1,
  1517. getItemAsync: function (path /*: string*/) {
  1518. return (0, _idbKeyval.get)(path, ParseStore);
  1519. },
  1520. setItemAsync: function (path /*: string*/, value /*: string*/) {
  1521. return (0, _idbKeyval.set)(path, value, ParseStore);
  1522. },
  1523. removeItemAsync: function (path /*: string*/) {
  1524. return (0, _idbKeyval.del)(path, ParseStore);
  1525. },
  1526. getAllKeysAsync: function () {
  1527. return (0, _keysInstanceProperty(_idbKeyval))(ParseStore);
  1528. },
  1529. clear: function () {
  1530. return (0, _idbKeyval.clear)(ParseStore);
  1531. }
  1532. };
  1533. module.exports = IndexedDBStorageController;
  1534. } else {
  1535. // IndexedDB not supported
  1536. module.exports = undefined;
  1537. }
  1538. },{"@babel/runtime-corejs3/core-js-stable/instance/keys":67,"idb-keyval":621}],10:[function(_dereq_,module,exports){
  1539. "use strict";
  1540. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1541. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  1542. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  1543. /**
  1544. * @flow
  1545. */
  1546. var uuidv4 = _dereq_('./uuid');
  1547. var iidCache = null;
  1548. var InstallationController = {
  1549. currentInstallationId: function () /*: Promise<string>*/{
  1550. if (typeof iidCache === 'string') {
  1551. return _promise.default.resolve(iidCache);
  1552. }
  1553. var path = _Storage.default.generatePath('installationId');
  1554. return _Storage.default.getItemAsync(path).then(function (iid) {
  1555. if (!iid) {
  1556. iid = uuidv4();
  1557. return _Storage.default.setItemAsync(path, iid).then(function () {
  1558. iidCache = iid;
  1559. return iid;
  1560. });
  1561. }
  1562. iidCache = iid;
  1563. return iid;
  1564. });
  1565. },
  1566. _clearCache: function () {
  1567. iidCache = null;
  1568. },
  1569. _setInstallationIdCache: function (iid /*: string*/) {
  1570. iidCache = iid;
  1571. }
  1572. };
  1573. module.exports = InstallationController;
  1574. },{"./Storage":39,"./uuid":54,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],11:[function(_dereq_,module,exports){
  1575. "use strict";
  1576. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  1577. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  1578. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  1579. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  1580. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  1581. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  1582. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  1583. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1584. _Object$defineProperty(exports, "__esModule", {
  1585. value: true
  1586. });
  1587. exports.default = void 0;
  1588. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  1589. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
  1590. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  1591. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  1592. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  1593. var _values = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/values"));
  1594. var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
  1595. var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
  1596. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  1597. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  1598. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  1599. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  1600. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  1601. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  1602. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  1603. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  1604. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  1605. var _EventEmitter2 = _interopRequireDefault(_dereq_("./EventEmitter"));
  1606. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  1607. var _LiveQuerySubscription = _interopRequireDefault(_dereq_("./LiveQuerySubscription"));
  1608. var _promiseUtils = _dereq_("./promiseUtils");
  1609. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  1610. function _createForOfIteratorHelper(o, allowArrayLike) {
  1611. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  1612. if (!it) {
  1613. if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  1614. if (it) o = it;
  1615. var i = 0;
  1616. var F = function () {};
  1617. return {
  1618. s: F,
  1619. n: function () {
  1620. if (i >= o.length) return {
  1621. done: true
  1622. };
  1623. return {
  1624. done: false,
  1625. value: o[i++]
  1626. };
  1627. },
  1628. e: function (_e) {
  1629. throw _e;
  1630. },
  1631. f: F
  1632. };
  1633. }
  1634. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1635. }
  1636. var normalCompletion = true,
  1637. didErr = false,
  1638. err;
  1639. return {
  1640. s: function () {
  1641. it = it.call(o);
  1642. },
  1643. n: function () {
  1644. var step = it.next();
  1645. normalCompletion = step.done;
  1646. return step;
  1647. },
  1648. e: function (_e2) {
  1649. didErr = true;
  1650. err = _e2;
  1651. },
  1652. f: function () {
  1653. try {
  1654. if (!normalCompletion && it.return != null) it.return();
  1655. } finally {
  1656. if (didErr) throw err;
  1657. }
  1658. }
  1659. };
  1660. }
  1661. function _unsupportedIterableToArray(o, minLen) {
  1662. var _context6;
  1663. if (!o) return;
  1664. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  1665. var n = _sliceInstanceProperty(_context6 = Object.prototype.toString.call(o)).call(_context6, 8, -1);
  1666. if (n === "Object" && o.constructor) n = o.constructor.name;
  1667. if (n === "Map" || n === "Set") return _Array$from(o);
  1668. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  1669. }
  1670. function _arrayLikeToArray(arr, len) {
  1671. if (len == null || len > arr.length) len = arr.length;
  1672. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  1673. return arr2;
  1674. }
  1675. function _createSuper(Derived) {
  1676. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  1677. return function () {
  1678. var Super = (0, _getPrototypeOf2.default)(Derived),
  1679. result;
  1680. if (hasNativeReflectConstruct) {
  1681. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  1682. result = _Reflect$construct(Super, arguments, NewTarget);
  1683. } else {
  1684. result = Super.apply(this, arguments);
  1685. }
  1686. return (0, _possibleConstructorReturn2.default)(this, result);
  1687. };
  1688. }
  1689. function _isNativeReflectConstruct() {
  1690. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  1691. if (_Reflect$construct.sham) return false;
  1692. if (typeof Proxy === "function") return true;
  1693. try {
  1694. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  1695. return true;
  1696. } catch (e) {
  1697. return false;
  1698. }
  1699. } /* global WebSocket */
  1700. // The LiveQuery client inner state
  1701. var CLIENT_STATE = {
  1702. INITIALIZED: 'initialized',
  1703. CONNECTING: 'connecting',
  1704. CONNECTED: 'connected',
  1705. CLOSED: 'closed',
  1706. RECONNECTING: 'reconnecting',
  1707. DISCONNECTED: 'disconnected'
  1708. };
  1709. // The event type the LiveQuery client should sent to server
  1710. var OP_TYPES = {
  1711. CONNECT: 'connect',
  1712. SUBSCRIBE: 'subscribe',
  1713. UNSUBSCRIBE: 'unsubscribe',
  1714. ERROR: 'error'
  1715. };
  1716. // The event we get back from LiveQuery server
  1717. var OP_EVENTS = {
  1718. CONNECTED: 'connected',
  1719. SUBSCRIBED: 'subscribed',
  1720. UNSUBSCRIBED: 'unsubscribed',
  1721. ERROR: 'error',
  1722. CREATE: 'create',
  1723. UPDATE: 'update',
  1724. ENTER: 'enter',
  1725. LEAVE: 'leave',
  1726. DELETE: 'delete'
  1727. };
  1728. // The event the LiveQuery client should emit
  1729. var CLIENT_EMMITER_TYPES = {
  1730. CLOSE: 'close',
  1731. ERROR: 'error',
  1732. OPEN: 'open'
  1733. };
  1734. // The event the LiveQuery subscription should emit
  1735. var SUBSCRIPTION_EMMITER_TYPES = {
  1736. OPEN: 'open',
  1737. CLOSE: 'close',
  1738. ERROR: 'error',
  1739. CREATE: 'create',
  1740. UPDATE: 'update',
  1741. ENTER: 'enter',
  1742. LEAVE: 'leave',
  1743. DELETE: 'delete'
  1744. };
  1745. var generateInterval = function (k) {
  1746. return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1000;
  1747. };
  1748. /**
  1749. * Creates a new LiveQueryClient.
  1750. * Extends events.EventEmitter
  1751. * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
  1752. *
  1753. * A wrapper of a standard WebSocket client. We add several useful methods to
  1754. * help you connect/disconnect to LiveQueryServer, subscribe/unsubscribe a ParseQuery easily.
  1755. *
  1756. * javascriptKey and masterKey are used for verifying the LiveQueryClient when it tries
  1757. * to connect to the LiveQuery server
  1758. *
  1759. * We expose three events to help you monitor the status of the LiveQueryClient.
  1760. *
  1761. * <pre>
  1762. * let Parse = require('parse/node');
  1763. * let LiveQueryClient = Parse.LiveQueryClient;
  1764. * let client = new LiveQueryClient({
  1765. * applicationId: '',
  1766. * serverURL: '',
  1767. * javascriptKey: '',
  1768. * masterKey: ''
  1769. * });
  1770. * </pre>
  1771. *
  1772. * Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
  1773. * <pre>
  1774. * client.on('open', () => {
  1775. *
  1776. * });</pre>
  1777. *
  1778. * Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
  1779. * <pre>
  1780. * client.on('close', () => {
  1781. *
  1782. * });</pre>
  1783. *
  1784. * Error - When some network error or LiveQuery server error happens, you'll get this event.
  1785. * <pre>
  1786. * client.on('error', (error) => {
  1787. *
  1788. * });</pre>
  1789. *
  1790. * @alias Parse.LiveQueryClient
  1791. */
  1792. var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
  1793. (0, _inherits2.default)(LiveQueryClient, _EventEmitter);
  1794. var _super = _createSuper(LiveQueryClient);
  1795. /**
  1796. * @param {object} options
  1797. * @param {string} options.applicationId - applicationId of your Parse app
  1798. * @param {string} options.serverURL - <b>the URL of your LiveQuery server</b>
  1799. * @param {string} options.javascriptKey (optional)
  1800. * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!)
  1801. * @param {string} options.sessionToken (optional)
  1802. * @param {string} options.installationId (optional)
  1803. */
  1804. function LiveQueryClient(_ref) {
  1805. var _this;
  1806. var applicationId = _ref.applicationId,
  1807. serverURL = _ref.serverURL,
  1808. javascriptKey = _ref.javascriptKey,
  1809. masterKey = _ref.masterKey,
  1810. sessionToken = _ref.sessionToken,
  1811. installationId = _ref.installationId;
  1812. (0, _classCallCheck2.default)(this, LiveQueryClient);
  1813. _this = _super.call(this);
  1814. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "attempts", void 0);
  1815. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "id", void 0);
  1816. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "requestId", void 0);
  1817. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "applicationId", void 0);
  1818. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "serverURL", void 0);
  1819. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "javascriptKey", void 0);
  1820. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "masterKey", void 0);
  1821. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sessionToken", void 0);
  1822. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "installationId", void 0);
  1823. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "additionalProperties", void 0);
  1824. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "connectPromise", void 0);
  1825. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "subscriptions", void 0);
  1826. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "socket", void 0);
  1827. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", void 0);
  1828. if (!serverURL || (0, _indexOf.default)(serverURL).call(serverURL, 'ws') !== 0) {
  1829. throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
  1830. }
  1831. _this.reconnectHandle = null;
  1832. _this.attempts = 1;
  1833. _this.id = 0;
  1834. _this.requestId = 1;
  1835. _this.serverURL = serverURL;
  1836. _this.applicationId = applicationId;
  1837. _this.javascriptKey = javascriptKey || undefined;
  1838. _this.masterKey = masterKey || undefined;
  1839. _this.sessionToken = sessionToken || undefined;
  1840. _this.installationId = installationId || undefined;
  1841. _this.additionalProperties = true;
  1842. _this.connectPromise = (0, _promiseUtils.resolvingPromise)();
  1843. _this.subscriptions = new _map.default();
  1844. _this.state = CLIENT_STATE.INITIALIZED;
  1845. // adding listener so process does not crash
  1846. // best practice is for developer to register their own listener
  1847. _this.on('error', function () {});
  1848. return _this;
  1849. }
  1850. (0, _createClass2.default)(LiveQueryClient, [{
  1851. key: "shouldOpen",
  1852. value: function () /*: any*/{
  1853. return this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED;
  1854. }
  1855. /**
  1856. * Subscribes to a ParseQuery
  1857. *
  1858. * If you provide the sessionToken, when the LiveQuery server gets ParseObject's
  1859. * updates from parse server, it'll try to check whether the sessionToken fulfills
  1860. * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose
  1861. * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol
  1862. * <a href="https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification">here</a> for more details. The subscription you get is the same subscription you get
  1863. * from our Standard API.
  1864. *
  1865. * @param {object} query - the ParseQuery you want to subscribe to
  1866. * @param {string} sessionToken (optional)
  1867. * @returns {LiveQuerySubscription | undefined}
  1868. */
  1869. }, {
  1870. key: "subscribe",
  1871. value: function (query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
  1872. var _queryJSON$keys,
  1873. _queryJSON$watch,
  1874. _this2 = this;
  1875. if (!query) {
  1876. return;
  1877. }
  1878. var className = query.className;
  1879. var queryJSON = query.toJSON();
  1880. var where = queryJSON.where;
  1881. var fields = (_queryJSON$keys = (0, _keys.default)(queryJSON)) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
  1882. var watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
  1883. var subscribeRequest = {
  1884. op: OP_TYPES.SUBSCRIBE,
  1885. requestId: this.requestId,
  1886. query: {
  1887. className: className,
  1888. where: where,
  1889. fields: fields,
  1890. watch: watch
  1891. }
  1892. };
  1893. if (sessionToken) {
  1894. subscribeRequest.sessionToken = sessionToken;
  1895. }
  1896. var subscription = new _LiveQuerySubscription.default(this.requestId, query, sessionToken);
  1897. this.subscriptions.set(this.requestId, subscription);
  1898. this.requestId += 1;
  1899. this.connectPromise.then(function () {
  1900. _this2.socket.send((0, _stringify.default)(subscribeRequest));
  1901. }).catch(function (error) {
  1902. subscription.subscribePromise.reject(error);
  1903. });
  1904. return subscription;
  1905. }
  1906. /**
  1907. * After calling unsubscribe you'll stop receiving events from the subscription object.
  1908. *
  1909. * @param {object} subscription - subscription you would like to unsubscribe from.
  1910. * @returns {Promise | undefined}
  1911. */
  1912. }, {
  1913. key: "unsubscribe",
  1914. value: function (subscription /*: Object*/) /*: ?Promise*/{
  1915. var _this3 = this;
  1916. if (!subscription) {
  1917. return;
  1918. }
  1919. var unsubscribeRequest = {
  1920. op: OP_TYPES.UNSUBSCRIBE,
  1921. requestId: subscription.id
  1922. };
  1923. return this.connectPromise.then(function () {
  1924. return _this3.socket.send((0, _stringify.default)(unsubscribeRequest));
  1925. }).then(function () {
  1926. return subscription.unsubscribePromise;
  1927. });
  1928. }
  1929. /**
  1930. * After open is called, the LiveQueryClient will try to send a connect request
  1931. * to the LiveQuery server.
  1932. *
  1933. */
  1934. }, {
  1935. key: "open",
  1936. value: function () {
  1937. var _this4 = this;
  1938. var WebSocketImplementation = _CoreManager.default.getWebSocketController();
  1939. if (!WebSocketImplementation) {
  1940. this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
  1941. return;
  1942. }
  1943. if (this.state !== CLIENT_STATE.RECONNECTING) {
  1944. this.state = CLIENT_STATE.CONNECTING;
  1945. }
  1946. this.socket = new WebSocketImplementation(this.serverURL);
  1947. this.socket.closingPromise = (0, _promiseUtils.resolvingPromise)();
  1948. // Bind WebSocket callbacks
  1949. this.socket.onopen = function () {
  1950. _this4._handleWebSocketOpen();
  1951. };
  1952. this.socket.onmessage = function (event) {
  1953. _this4._handleWebSocketMessage(event);
  1954. };
  1955. this.socket.onclose = function (event) {
  1956. _this4.socket.closingPromise.resolve(event);
  1957. _this4._handleWebSocketClose();
  1958. };
  1959. this.socket.onerror = function (error) {
  1960. _this4._handleWebSocketError(error);
  1961. };
  1962. }
  1963. }, {
  1964. key: "resubscribe",
  1965. value: function () {
  1966. var _context,
  1967. _this5 = this;
  1968. (0, _forEach.default)(_context = this.subscriptions).call(_context, function (subscription, requestId) {
  1969. var query = subscription.query;
  1970. var queryJSON = query.toJSON();
  1971. var where = queryJSON.where;
  1972. var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
  1973. var className = query.className;
  1974. var sessionToken = subscription.sessionToken;
  1975. var subscribeRequest = {
  1976. op: OP_TYPES.SUBSCRIBE,
  1977. requestId: requestId,
  1978. query: {
  1979. className: className,
  1980. where: where,
  1981. fields: fields
  1982. }
  1983. };
  1984. if (sessionToken) {
  1985. subscribeRequest.sessionToken = sessionToken;
  1986. }
  1987. _this5.connectPromise.then(function () {
  1988. _this5.socket.send((0, _stringify.default)(subscribeRequest));
  1989. });
  1990. });
  1991. }
  1992. /**
  1993. * This method will close the WebSocket connection to this LiveQueryClient,
  1994. * cancel the auto reconnect and unsubscribe all subscriptions based on it.
  1995. *
  1996. * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event}
  1997. */
  1998. }, {
  1999. key: "close",
  2000. value: function () /*: ?Promise*/{
  2001. var _this$socket, _this$socket2, _context2;
  2002. if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
  2003. return;
  2004. }
  2005. this.state = CLIENT_STATE.DISCONNECTED;
  2006. (_this$socket = this.socket) === null || _this$socket === void 0 ? void 0 : _this$socket.close();
  2007. // Notify each subscription about the close
  2008. var _iterator = _createForOfIteratorHelper((0, _values.default)(_context2 = this.subscriptions).call(_context2)),
  2009. _step;
  2010. try {
  2011. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  2012. var subscription = _step.value;
  2013. subscription.subscribed = false;
  2014. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
  2015. }
  2016. } catch (err) {
  2017. _iterator.e(err);
  2018. } finally {
  2019. _iterator.f();
  2020. }
  2021. this._handleReset();
  2022. this.emit(CLIENT_EMMITER_TYPES.CLOSE);
  2023. return (_this$socket2 = this.socket) === null || _this$socket2 === void 0 ? void 0 : _this$socket2.closingPromise;
  2024. }
  2025. // ensure we start with valid state if connect is called again after close
  2026. }, {
  2027. key: "_handleReset",
  2028. value: function () {
  2029. this.attempts = 1;
  2030. this.id = 0;
  2031. this.requestId = 1;
  2032. this.connectPromise = (0, _promiseUtils.resolvingPromise)();
  2033. this.subscriptions = new _map.default();
  2034. }
  2035. }, {
  2036. key: "_handleWebSocketOpen",
  2037. value: function () {
  2038. this.attempts = 1;
  2039. var connectRequest = {
  2040. op: OP_TYPES.CONNECT,
  2041. applicationId: this.applicationId,
  2042. javascriptKey: this.javascriptKey,
  2043. masterKey: this.masterKey,
  2044. sessionToken: this.sessionToken
  2045. };
  2046. if (this.additionalProperties) {
  2047. connectRequest.installationId = this.installationId;
  2048. }
  2049. this.socket.send((0, _stringify.default)(connectRequest));
  2050. }
  2051. }, {
  2052. key: "_handleWebSocketMessage",
  2053. value: function (event /*: any*/) {
  2054. var data = event.data;
  2055. if (typeof data === 'string') {
  2056. data = JSON.parse(data);
  2057. }
  2058. var subscription = null;
  2059. if (data.requestId) {
  2060. subscription = this.subscriptions.get(data.requestId);
  2061. }
  2062. var response = {
  2063. clientId: data.clientId,
  2064. installationId: data.installationId
  2065. };
  2066. switch (data.op) {
  2067. case OP_EVENTS.CONNECTED:
  2068. if (this.state === CLIENT_STATE.RECONNECTING) {
  2069. this.resubscribe();
  2070. }
  2071. this.emit(CLIENT_EMMITER_TYPES.OPEN);
  2072. this.id = data.clientId;
  2073. this.connectPromise.resolve();
  2074. this.state = CLIENT_STATE.CONNECTED;
  2075. break;
  2076. case OP_EVENTS.SUBSCRIBED:
  2077. if (subscription) {
  2078. subscription.subscribed = true;
  2079. subscription.subscribePromise.resolve();
  2080. (0, _setTimeout2.default)(function () {
  2081. return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response);
  2082. }, 200);
  2083. }
  2084. break;
  2085. case OP_EVENTS.ERROR:
  2086. {
  2087. var parseError = new _ParseError.default(data.code, data.error);
  2088. if (!this.id) {
  2089. this.connectPromise.reject(parseError);
  2090. this.state = CLIENT_STATE.DISCONNECTED;
  2091. }
  2092. if (data.requestId) {
  2093. if (subscription) {
  2094. subscription.subscribePromise.reject(parseError);
  2095. (0, _setTimeout2.default)(function () {
  2096. return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
  2097. }, 200);
  2098. }
  2099. } else {
  2100. this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
  2101. }
  2102. if (data.error === 'Additional properties not allowed') {
  2103. this.additionalProperties = false;
  2104. }
  2105. if (data.reconnect) {
  2106. this._handleReconnect();
  2107. }
  2108. break;
  2109. }
  2110. case OP_EVENTS.UNSUBSCRIBED:
  2111. {
  2112. if (subscription) {
  2113. this.subscriptions.delete(data.requestId);
  2114. subscription.subscribed = false;
  2115. subscription.unsubscribePromise.resolve();
  2116. }
  2117. break;
  2118. }
  2119. default:
  2120. {
  2121. // create, update, enter, leave, delete cases
  2122. if (!subscription) {
  2123. break;
  2124. }
  2125. var override = false;
  2126. if (data.original) {
  2127. override = true;
  2128. delete data.original.__type;
  2129. // Check for removed fields
  2130. for (var field in data.original) {
  2131. if (!(field in data.object)) {
  2132. data.object[field] = undefined;
  2133. }
  2134. }
  2135. data.original = _ParseObject.default.fromJSON(data.original, false);
  2136. }
  2137. delete data.object.__type;
  2138. var parseObject = _ParseObject.default.fromJSON(data.object, !(subscription.query && subscription.query._select) ? override : false);
  2139. if (data.original) {
  2140. subscription.emit(data.op, parseObject, data.original, response);
  2141. } else {
  2142. subscription.emit(data.op, parseObject, response);
  2143. }
  2144. var localDatastore = _CoreManager.default.getLocalDatastore();
  2145. if (override && localDatastore.isEnabled) {
  2146. localDatastore._updateObjectIfPinned(parseObject).then(function () {});
  2147. }
  2148. }
  2149. }
  2150. }
  2151. }, {
  2152. key: "_handleWebSocketClose",
  2153. value: function () {
  2154. var _context3;
  2155. if (this.state === CLIENT_STATE.DISCONNECTED) {
  2156. return;
  2157. }
  2158. this.state = CLIENT_STATE.CLOSED;
  2159. this.emit(CLIENT_EMMITER_TYPES.CLOSE);
  2160. // Notify each subscription about the close
  2161. var _iterator2 = _createForOfIteratorHelper((0, _values.default)(_context3 = this.subscriptions).call(_context3)),
  2162. _step2;
  2163. try {
  2164. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  2165. var subscription = _step2.value;
  2166. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
  2167. }
  2168. } catch (err) {
  2169. _iterator2.e(err);
  2170. } finally {
  2171. _iterator2.f();
  2172. }
  2173. this._handleReconnect();
  2174. }
  2175. }, {
  2176. key: "_handleWebSocketError",
  2177. value: function (error /*: any*/) {
  2178. var _context4;
  2179. this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
  2180. var _iterator3 = _createForOfIteratorHelper((0, _values.default)(_context4 = this.subscriptions).call(_context4)),
  2181. _step3;
  2182. try {
  2183. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  2184. var subscription = _step3.value;
  2185. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, error);
  2186. }
  2187. } catch (err) {
  2188. _iterator3.e(err);
  2189. } finally {
  2190. _iterator3.f();
  2191. }
  2192. this._handleReconnect();
  2193. }
  2194. }, {
  2195. key: "_handleReconnect",
  2196. value: function () {
  2197. var _context5,
  2198. _this6 = this;
  2199. // if closed or currently reconnecting we stop attempting to reconnect
  2200. if (this.state === CLIENT_STATE.DISCONNECTED) {
  2201. return;
  2202. }
  2203. this.state = CLIENT_STATE.RECONNECTING;
  2204. var time = generateInterval(this.attempts);
  2205. // handle case when both close/error occur at frequent rates we ensure we do not reconnect unnecessarily.
  2206. // we're unable to distinguish different between close/error when we're unable to reconnect therefore
  2207. // we try to reconnect in both cases
  2208. // server side ws and browser WebSocket behave differently in when close/error get triggered
  2209. if (this.reconnectHandle) {
  2210. clearTimeout(this.reconnectHandle);
  2211. }
  2212. this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context5 = function () {
  2213. _this6.attempts++;
  2214. _this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
  2215. _this6.open();
  2216. }).call(_context5, this), time);
  2217. }
  2218. }]);
  2219. return LiveQueryClient;
  2220. }(_EventEmitter2.default);
  2221. _CoreManager.default.setWebSocketController(typeof WebSocket === 'function' || (typeof WebSocket === "undefined" ? "undefined" : (0, _typeof2.default)(WebSocket)) === 'object' ? WebSocket : null);
  2222. var _default = LiveQueryClient;
  2223. exports.default = _default;
  2224. },{"./CoreManager":4,"./EventEmitter":6,"./LiveQuerySubscription":12,"./ParseError":22,"./ParseObject":27,"./promiseUtils":51,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/bind":57,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/keys":67,"@babel/runtime-corejs3/core-js-stable/instance/slice":70,"@babel/runtime-corejs3/core-js-stable/instance/values":74,"@babel/runtime-corejs3/core-js-stable/json/stringify":75,"@babel/runtime-corejs3/core-js-stable/map":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/reflect/construct":91,"@babel/runtime-corejs3/core-js-stable/set-timeout":93,"@babel/runtime-corejs3/core-js-stable/symbol":95,"@babel/runtime-corejs3/core-js/get-iterator-method":99,"@babel/runtime-corejs3/helpers/assertThisInitialized":120,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/getPrototypeOf":127,"@babel/runtime-corejs3/helpers/inherits":128,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":136,"@babel/runtime-corejs3/helpers/typeof":144}],12:[function(_dereq_,module,exports){
  2225. "use strict";
  2226. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  2227. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2228. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2229. _Object$defineProperty(exports, "__esModule", {
  2230. value: true
  2231. });
  2232. exports.default = void 0;
  2233. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  2234. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  2235. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  2236. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  2237. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  2238. var _EventEmitter2 = _interopRequireDefault(_dereq_("./EventEmitter"));
  2239. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  2240. var _promiseUtils = _dereq_("./promiseUtils");
  2241. function _createSuper(Derived) {
  2242. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  2243. return function () {
  2244. var Super = (0, _getPrototypeOf2.default)(Derived),
  2245. result;
  2246. if (hasNativeReflectConstruct) {
  2247. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  2248. result = _Reflect$construct(Super, arguments, NewTarget);
  2249. } else {
  2250. result = Super.apply(this, arguments);
  2251. }
  2252. return (0, _possibleConstructorReturn2.default)(this, result);
  2253. };
  2254. }
  2255. function _isNativeReflectConstruct() {
  2256. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  2257. if (_Reflect$construct.sham) return false;
  2258. if (typeof Proxy === "function") return true;
  2259. try {
  2260. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  2261. return true;
  2262. } catch (e) {
  2263. return false;
  2264. }
  2265. }
  2266. /**
  2267. * Creates a new LiveQuery Subscription.
  2268. * Extends events.EventEmitter
  2269. * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
  2270. *
  2271. * <p>Response Object - Contains data from the client that made the request
  2272. * <ul>
  2273. * <li>clientId</li>
  2274. * <li>installationId - requires Parse Server 4.0.0+</li>
  2275. * </ul>
  2276. * </p>
  2277. *
  2278. * <p>Open Event - When you call query.subscribe(), we send a subscribe request to
  2279. * the LiveQuery server, when we get the confirmation from the LiveQuery server,
  2280. * this event will be emitted. When the client loses WebSocket connection to the
  2281. * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we
  2282. * reconnect the LiveQuery server and successfully resubscribe the ParseQuery,
  2283. * you'll also get this event.
  2284. *
  2285. * <pre>
  2286. * subscription.on('open', (response) => {
  2287. *
  2288. * });</pre></p>
  2289. *
  2290. * <p>Create Event - When a new ParseObject is created and it fulfills the ParseQuery you subscribe,
  2291. * you'll get this event. The object is the ParseObject which is created.
  2292. *
  2293. * <pre>
  2294. * subscription.on('create', (object, response) => {
  2295. *
  2296. * });</pre></p>
  2297. *
  2298. * <p>Update Event - When an existing ParseObject (original) which fulfills the ParseQuery you subscribe
  2299. * is updated (The ParseObject fulfills the ParseQuery before and after changes),
  2300. * you'll get this event. The object is the ParseObject which is updated.
  2301. * Its content is the latest value of the ParseObject.
  2302. *
  2303. * Parse-Server 3.1.3+ Required for original object parameter
  2304. *
  2305. * <pre>
  2306. * subscription.on('update', (object, original, response) => {
  2307. *
  2308. * });</pre></p>
  2309. *
  2310. * <p>Enter Event - When an existing ParseObject's (original) old value doesn't fulfill the ParseQuery
  2311. * but its new value fulfills the ParseQuery, you'll get this event. The object is the
  2312. * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject.
  2313. *
  2314. * Parse-Server 3.1.3+ Required for original object parameter
  2315. *
  2316. * <pre>
  2317. * subscription.on('enter', (object, original, response) => {
  2318. *
  2319. * });</pre></p>
  2320. *
  2321. *
  2322. * <p>Update Event - When an existing ParseObject's old value fulfills the ParseQuery but its new value
  2323. * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject
  2324. * which leaves the ParseQuery. Its content is the latest value of the ParseObject.
  2325. *
  2326. * <pre>
  2327. * subscription.on('leave', (object, response) => {
  2328. *
  2329. * });</pre></p>
  2330. *
  2331. *
  2332. * <p>Delete Event - When an existing ParseObject which fulfills the ParseQuery is deleted, you'll
  2333. * get this event. The object is the ParseObject which is deleted.
  2334. *
  2335. * <pre>
  2336. * subscription.on('delete', (object, response) => {
  2337. *
  2338. * });</pre></p>
  2339. *
  2340. *
  2341. * <p>Close Event - When the client loses the WebSocket connection to the LiveQuery
  2342. * server and we stop receiving events, you'll get this event.
  2343. *
  2344. * <pre>
  2345. * subscription.on('close', () => {
  2346. *
  2347. * });</pre></p>
  2348. *
  2349. * @alias Parse.LiveQuerySubscription
  2350. */
  2351. var Subscription = /*#__PURE__*/function (_EventEmitter) {
  2352. (0, _inherits2.default)(Subscription, _EventEmitter);
  2353. var _super = _createSuper(Subscription);
  2354. /*
  2355. * @param {string} id - subscription id
  2356. * @param {string} query - query to subscribe to
  2357. * @param {string} sessionToken - optional session token
  2358. */
  2359. function Subscription(id, query, sessionToken) {
  2360. var _this;
  2361. (0, _classCallCheck2.default)(this, Subscription);
  2362. _this = _super.call(this);
  2363. _this.id = id;
  2364. _this.query = query;
  2365. _this.sessionToken = sessionToken;
  2366. _this.subscribePromise = (0, _promiseUtils.resolvingPromise)();
  2367. _this.unsubscribePromise = (0, _promiseUtils.resolvingPromise)();
  2368. _this.subscribed = false;
  2369. // adding listener so process does not crash
  2370. // best practice is for developer to register their own listener
  2371. _this.on('error', function () {});
  2372. return _this;
  2373. }
  2374. /**
  2375. * Close the subscription
  2376. *
  2377. * @returns {Promise}
  2378. */
  2379. (0, _createClass2.default)(Subscription, [{
  2380. key: "unsubscribe",
  2381. value: function () /*: Promise*/{
  2382. var _this2 = this;
  2383. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(function (liveQueryClient) {
  2384. _this2.emit('close');
  2385. return liveQueryClient.unsubscribe(_this2);
  2386. });
  2387. }
  2388. }]);
  2389. return Subscription;
  2390. }(_EventEmitter2.default);
  2391. var _default = Subscription;
  2392. exports.default = _default;
  2393. },{"./CoreManager":4,"./EventEmitter":6,"./promiseUtils":51,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/reflect/construct":91,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/getPrototypeOf":127,"@babel/runtime-corejs3/helpers/inherits":128,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":136}],13:[function(_dereq_,module,exports){
  2394. "use strict";
  2395. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  2396. var _Array$from2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  2397. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  2398. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  2399. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  2400. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2401. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  2402. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  2403. var _set = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set"));
  2404. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  2405. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  2406. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  2407. var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  2408. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  2409. var _keys3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  2410. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  2411. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  2412. var _from = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/from"));
  2413. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  2414. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  2415. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  2416. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  2417. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  2418. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  2419. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  2420. function _createForOfIteratorHelper(o, allowArrayLike) {
  2421. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  2422. if (!it) {
  2423. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  2424. if (it) o = it;
  2425. var i = 0;
  2426. var F = function () {};
  2427. return {
  2428. s: F,
  2429. n: function () {
  2430. if (i >= o.length) return {
  2431. done: true
  2432. };
  2433. return {
  2434. done: false,
  2435. value: o[i++]
  2436. };
  2437. },
  2438. e: function (_e) {
  2439. throw _e;
  2440. },
  2441. f: F
  2442. };
  2443. }
  2444. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2445. }
  2446. var normalCompletion = true,
  2447. didErr = false,
  2448. err;
  2449. return {
  2450. s: function () {
  2451. it = it.call(o);
  2452. },
  2453. n: function () {
  2454. var step = it.next();
  2455. normalCompletion = step.done;
  2456. return step;
  2457. },
  2458. e: function (_e2) {
  2459. didErr = true;
  2460. err = _e2;
  2461. },
  2462. f: function () {
  2463. try {
  2464. if (!normalCompletion && it.return != null) it.return();
  2465. } finally {
  2466. if (didErr) throw err;
  2467. }
  2468. }
  2469. };
  2470. }
  2471. function _unsupportedIterableToArray(o, minLen) {
  2472. var _context16;
  2473. if (!o) return;
  2474. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  2475. var n = _sliceInstanceProperty(_context16 = Object.prototype.toString.call(o)).call(_context16, 8, -1);
  2476. if (n === "Object" && o.constructor) n = o.constructor.name;
  2477. if (n === "Map" || n === "Set") return _Array$from2(o);
  2478. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  2479. }
  2480. function _arrayLikeToArray(arr, len) {
  2481. if (len == null || len > arr.length) len = arr.length;
  2482. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  2483. return arr2;
  2484. } /**
  2485. * @flow
  2486. */ /*:: import type ParseObject from './ParseObject';*/
  2487. /**
  2488. * Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
  2489. * To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
  2490. *
  2491. * Pin object to add to local datastore
  2492. *
  2493. * <pre>await object.pin();</pre>
  2494. * <pre>await object.pinWithName('pinName');</pre>
  2495. *
  2496. * Query pinned objects
  2497. *
  2498. * <pre>query.fromLocalDatastore();</pre>
  2499. * <pre>query.fromPin();</pre>
  2500. * <pre>query.fromPinWithName();</pre>
  2501. *
  2502. * <pre>const localObjects = await query.find();</pre>
  2503. *
  2504. * @class Parse.LocalDatastore
  2505. * @static
  2506. */
  2507. var LocalDatastore = {
  2508. isEnabled: false,
  2509. isSyncing: false,
  2510. fromPinWithName: function (name /*: string*/) /*: Promise<Array<Object>>*/{
  2511. var controller = _CoreManager.default.getLocalDatastoreController();
  2512. return controller.fromPinWithName(name);
  2513. },
  2514. pinWithName: function (name /*: string*/, value /*: any*/) /*: Promise<void>*/{
  2515. var controller = _CoreManager.default.getLocalDatastoreController();
  2516. return controller.pinWithName(name, value);
  2517. },
  2518. unPinWithName: function (name /*: string*/) /*: Promise<void>*/{
  2519. var controller = _CoreManager.default.getLocalDatastoreController();
  2520. return controller.unPinWithName(name);
  2521. },
  2522. _getAllContents: function () /*: Promise<Object>*/{
  2523. var controller = _CoreManager.default.getLocalDatastoreController();
  2524. return controller.getAllContents();
  2525. },
  2526. // Use for testing
  2527. _getRawStorage: function () /*: Promise<Object>*/{
  2528. var controller = _CoreManager.default.getLocalDatastoreController();
  2529. return controller.getRawStorage();
  2530. },
  2531. _clear: function () /*: Promise<void>*/{
  2532. var controller = _CoreManager.default.getLocalDatastoreController();
  2533. return controller.clear();
  2534. },
  2535. // Pin the object and children recursively
  2536. // Saves the object and children key to Pin Name
  2537. _handlePinAllWithName: function (name /*: string*/, objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
  2538. var _this = this;
  2539. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  2540. var _context;
  2541. var pinName, toPinPromises, objectKeys, _iterator, _step, parent, children, parentKey, json, objectKey, fromPinPromise, _yield$Promise$all, _yield$Promise$all2, pinned, toPin;
  2542. return _regenerator.default.wrap(function (_context2) {
  2543. while (1) switch (_context2.prev = _context2.next) {
  2544. case 0:
  2545. pinName = _this.getPinName(name);
  2546. toPinPromises = [];
  2547. objectKeys = [];
  2548. _iterator = _createForOfIteratorHelper(objects);
  2549. try {
  2550. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  2551. parent = _step.value;
  2552. children = _this._getChildren(parent);
  2553. parentKey = _this.getKeyForObject(parent);
  2554. json = parent._toFullJSON(undefined, true);
  2555. if (parent._localId) {
  2556. json._localId = parent._localId;
  2557. }
  2558. children[parentKey] = json;
  2559. for (objectKey in children) {
  2560. objectKeys.push(objectKey);
  2561. toPinPromises.push(_this.pinWithName(objectKey, [children[objectKey]]));
  2562. }
  2563. }
  2564. } catch (err) {
  2565. _iterator.e(err);
  2566. } finally {
  2567. _iterator.f();
  2568. }
  2569. fromPinPromise = _this.fromPinWithName(pinName);
  2570. _context2.next = 8;
  2571. return _promise.default.all([fromPinPromise, toPinPromises]);
  2572. case 8:
  2573. _yield$Promise$all = _context2.sent;
  2574. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1);
  2575. pinned = _yield$Promise$all2[0];
  2576. toPin = (0, _toConsumableArray2.default)(new _set.default((0, _concat.default)(_context = []).call(_context, (0, _toConsumableArray2.default)(pinned || []), objectKeys)));
  2577. return _context2.abrupt("return", _this.pinWithName(pinName, toPin));
  2578. case 13:
  2579. case "end":
  2580. return _context2.stop();
  2581. }
  2582. }, _callee);
  2583. }))();
  2584. },
  2585. // Removes object and children keys from pin name
  2586. // Keeps the object and children pinned
  2587. _handleUnPinAllWithName: function (name /*: string*/, objects /*: Array<ParseObject>*/) {
  2588. var _this2 = this;
  2589. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  2590. var localDatastore, pinName, promises, objectKeys, _iterator2, _step2, _objectKeys, _context3, parent, children, parentKey, pinned, _iterator3, _step3, objectKey, hasReference, key, pinnedObjects;
  2591. return _regenerator.default.wrap(function (_context4) {
  2592. while (1) switch (_context4.prev = _context4.next) {
  2593. case 0:
  2594. _context4.next = 2;
  2595. return _this2._getAllContents();
  2596. case 2:
  2597. localDatastore = _context4.sent;
  2598. pinName = _this2.getPinName(name);
  2599. promises = [];
  2600. objectKeys = [];
  2601. _iterator2 = _createForOfIteratorHelper(objects);
  2602. try {
  2603. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  2604. parent = _step2.value;
  2605. children = _this2._getChildren(parent);
  2606. parentKey = _this2.getKeyForObject(parent);
  2607. (_objectKeys = objectKeys).push.apply(_objectKeys, (0, _concat.default)(_context3 = [parentKey]).call(_context3, (0, _toConsumableArray2.default)((0, _keys2.default)(children))));
  2608. }
  2609. } catch (err) {
  2610. _iterator2.e(err);
  2611. } finally {
  2612. _iterator2.f();
  2613. }
  2614. objectKeys = (0, _toConsumableArray2.default)(new _set.default(objectKeys));
  2615. pinned = localDatastore[pinName] || [];
  2616. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  2617. return !(0, _includes.default)(objectKeys).call(objectKeys, item);
  2618. });
  2619. if (pinned.length == 0) {
  2620. promises.push(_this2.unPinWithName(pinName));
  2621. delete localDatastore[pinName];
  2622. } else {
  2623. promises.push(_this2.pinWithName(pinName, pinned));
  2624. localDatastore[pinName] = pinned;
  2625. }
  2626. _iterator3 = _createForOfIteratorHelper(objectKeys);
  2627. _context4.prev = 13;
  2628. _iterator3.s();
  2629. case 15:
  2630. if ((_step3 = _iterator3.n()).done) {
  2631. _context4.next = 31;
  2632. break;
  2633. }
  2634. objectKey = _step3.value;
  2635. hasReference = false;
  2636. _context4.t0 = (0, _keys3.default)(_regenerator.default).call(_regenerator.default, localDatastore);
  2637. case 19:
  2638. if ((_context4.t1 = _context4.t0()).done) {
  2639. _context4.next = 28;
  2640. break;
  2641. }
  2642. key = _context4.t1.value;
  2643. if (!(key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX))) {
  2644. _context4.next = 26;
  2645. break;
  2646. }
  2647. pinnedObjects = localDatastore[key] || [];
  2648. if (!(0, _includes.default)(pinnedObjects).call(pinnedObjects, objectKey)) {
  2649. _context4.next = 26;
  2650. break;
  2651. }
  2652. hasReference = true;
  2653. return _context4.abrupt("break", 28);
  2654. case 26:
  2655. _context4.next = 19;
  2656. break;
  2657. case 28:
  2658. if (!hasReference) {
  2659. promises.push(_this2.unPinWithName(objectKey));
  2660. }
  2661. case 29:
  2662. _context4.next = 15;
  2663. break;
  2664. case 31:
  2665. _context4.next = 36;
  2666. break;
  2667. case 33:
  2668. _context4.prev = 33;
  2669. _context4.t2 = _context4["catch"](13);
  2670. _iterator3.e(_context4.t2);
  2671. case 36:
  2672. _context4.prev = 36;
  2673. _iterator3.f();
  2674. return _context4.finish(36);
  2675. case 39:
  2676. return _context4.abrupt("return", _promise.default.all(promises));
  2677. case 40:
  2678. case "end":
  2679. return _context4.stop();
  2680. }
  2681. }, _callee2, null, [[13, 33, 36, 39]]);
  2682. }))();
  2683. },
  2684. // Retrieve all pointer fields from object recursively
  2685. _getChildren: function (object /*: ParseObject*/) {
  2686. var encountered = {};
  2687. var json = object._toFullJSON(undefined, true);
  2688. for (var key in json) {
  2689. if (json[key] && json[key].__type && json[key].__type === 'Object') {
  2690. this._traverse(json[key], encountered);
  2691. }
  2692. }
  2693. return encountered;
  2694. },
  2695. _traverse: function (object /*: any*/, encountered /*: any*/) {
  2696. if (!object.objectId) {
  2697. return;
  2698. } else {
  2699. var objectKey = this.getKeyForObject(object);
  2700. if (encountered[objectKey]) {
  2701. return;
  2702. }
  2703. encountered[objectKey] = object;
  2704. }
  2705. for (var key in object) {
  2706. var json = object[key];
  2707. if (!object[key]) {
  2708. json = object;
  2709. }
  2710. if (json.__type && json.__type === 'Object') {
  2711. this._traverse(json, encountered);
  2712. }
  2713. }
  2714. },
  2715. // Transform keys in pin name to objects
  2716. _serializeObjectsFromPinName: function (name /*: string*/) {
  2717. var _this3 = this;
  2718. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  2719. var _ref;
  2720. var localDatastore, allObjects, key, pinName, pinned, promises, objects;
  2721. return _regenerator.default.wrap(function (_context5) {
  2722. while (1) switch (_context5.prev = _context5.next) {
  2723. case 0:
  2724. _context5.next = 2;
  2725. return _this3._getAllContents();
  2726. case 2:
  2727. localDatastore = _context5.sent;
  2728. allObjects = [];
  2729. for (key in localDatastore) {
  2730. if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
  2731. allObjects.push(localDatastore[key][0]);
  2732. }
  2733. }
  2734. if (name) {
  2735. _context5.next = 7;
  2736. break;
  2737. }
  2738. return _context5.abrupt("return", allObjects);
  2739. case 7:
  2740. pinName = _this3.getPinName(name);
  2741. pinned = localDatastore[pinName];
  2742. if ((0, _isArray.default)(pinned)) {
  2743. _context5.next = 11;
  2744. break;
  2745. }
  2746. return _context5.abrupt("return", []);
  2747. case 11:
  2748. promises = (0, _map.default)(pinned).call(pinned, function (objectKey) {
  2749. return _this3.fromPinWithName(objectKey);
  2750. });
  2751. _context5.next = 14;
  2752. return _promise.default.all(promises);
  2753. case 14:
  2754. objects = _context5.sent;
  2755. objects = (0, _concat.default)(_ref = []).apply(_ref, (0, _toConsumableArray2.default)(objects));
  2756. return _context5.abrupt("return", (0, _filter.default)(objects).call(objects, function (object) {
  2757. return object != null;
  2758. }));
  2759. case 17:
  2760. case "end":
  2761. return _context5.stop();
  2762. }
  2763. }, _callee3);
  2764. }))();
  2765. },
  2766. // Replaces object pointers with pinned pointers
  2767. // The object pointers may contain old data
  2768. // Uses Breadth First Search Algorithm
  2769. _serializeObject: function (objectKey /*: string*/, localDatastore /*: any*/) {
  2770. var _this4 = this;
  2771. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
  2772. var LDS, root, queue, meta, uniqueId, nodeId, subTreeRoot, field, value, key, pointer;
  2773. return _regenerator.default.wrap(function (_context6) {
  2774. while (1) switch (_context6.prev = _context6.next) {
  2775. case 0:
  2776. LDS = localDatastore;
  2777. if (LDS) {
  2778. _context6.next = 5;
  2779. break;
  2780. }
  2781. _context6.next = 4;
  2782. return _this4._getAllContents();
  2783. case 4:
  2784. LDS = _context6.sent;
  2785. case 5:
  2786. if (!(!LDS[objectKey] || LDS[objectKey].length === 0)) {
  2787. _context6.next = 7;
  2788. break;
  2789. }
  2790. return _context6.abrupt("return", null);
  2791. case 7:
  2792. root = LDS[objectKey][0];
  2793. queue = [];
  2794. meta = {};
  2795. uniqueId = 0;
  2796. meta[uniqueId] = root;
  2797. queue.push(uniqueId);
  2798. while (queue.length !== 0) {
  2799. nodeId = queue.shift();
  2800. subTreeRoot = meta[nodeId];
  2801. for (field in subTreeRoot) {
  2802. value = subTreeRoot[field];
  2803. if (value.__type && value.__type === 'Object') {
  2804. key = _this4.getKeyForObject(value);
  2805. if (LDS[key] && LDS[key].length > 0) {
  2806. pointer = LDS[key][0];
  2807. uniqueId++;
  2808. meta[uniqueId] = pointer;
  2809. subTreeRoot[field] = pointer;
  2810. queue.push(uniqueId);
  2811. }
  2812. }
  2813. }
  2814. }
  2815. return _context6.abrupt("return", root);
  2816. case 15:
  2817. case "end":
  2818. return _context6.stop();
  2819. }
  2820. }, _callee4);
  2821. }))();
  2822. },
  2823. // Called when an object is save / fetched
  2824. // Update object pin value
  2825. _updateObjectIfPinned: function (object /*: ParseObject*/) /*: Promise<void>*/{
  2826. var _this5 = this;
  2827. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  2828. var objectKey, pinned;
  2829. return _regenerator.default.wrap(function (_context7) {
  2830. while (1) switch (_context7.prev = _context7.next) {
  2831. case 0:
  2832. if (_this5.isEnabled) {
  2833. _context7.next = 2;
  2834. break;
  2835. }
  2836. return _context7.abrupt("return");
  2837. case 2:
  2838. objectKey = _this5.getKeyForObject(object);
  2839. _context7.next = 5;
  2840. return _this5.fromPinWithName(objectKey);
  2841. case 5:
  2842. pinned = _context7.sent;
  2843. if (!(!pinned || pinned.length === 0)) {
  2844. _context7.next = 8;
  2845. break;
  2846. }
  2847. return _context7.abrupt("return");
  2848. case 8:
  2849. return _context7.abrupt("return", _this5.pinWithName(objectKey, [object._toFullJSON()]));
  2850. case 9:
  2851. case "end":
  2852. return _context7.stop();
  2853. }
  2854. }, _callee5);
  2855. }))();
  2856. },
  2857. // Called when object is destroyed
  2858. // Unpin object and remove all references from pin names
  2859. // TODO: Destroy children?
  2860. _destroyObjectIfPinned: function (object /*: ParseObject*/) {
  2861. var _this6 = this;
  2862. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  2863. var localDatastore, objectKey, pin, promises, key, pinned;
  2864. return _regenerator.default.wrap(function (_context8) {
  2865. while (1) switch (_context8.prev = _context8.next) {
  2866. case 0:
  2867. if (_this6.isEnabled) {
  2868. _context8.next = 2;
  2869. break;
  2870. }
  2871. return _context8.abrupt("return");
  2872. case 2:
  2873. _context8.next = 4;
  2874. return _this6._getAllContents();
  2875. case 4:
  2876. localDatastore = _context8.sent;
  2877. objectKey = _this6.getKeyForObject(object);
  2878. pin = localDatastore[objectKey];
  2879. if (pin) {
  2880. _context8.next = 9;
  2881. break;
  2882. }
  2883. return _context8.abrupt("return");
  2884. case 9:
  2885. promises = [_this6.unPinWithName(objectKey)];
  2886. delete localDatastore[objectKey];
  2887. for (key in localDatastore) {
  2888. if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
  2889. pinned = localDatastore[key] || [];
  2890. if ((0, _includes.default)(pinned).call(pinned, objectKey)) {
  2891. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  2892. return item !== objectKey;
  2893. });
  2894. if (pinned.length == 0) {
  2895. promises.push(_this6.unPinWithName(key));
  2896. delete localDatastore[key];
  2897. } else {
  2898. promises.push(_this6.pinWithName(key, pinned));
  2899. localDatastore[key] = pinned;
  2900. }
  2901. }
  2902. }
  2903. }
  2904. return _context8.abrupt("return", _promise.default.all(promises));
  2905. case 13:
  2906. case "end":
  2907. return _context8.stop();
  2908. }
  2909. }, _callee6);
  2910. }))();
  2911. },
  2912. // Update pin and references of the unsaved object
  2913. _updateLocalIdForObject: function (localId /*: string*/, object /*: ParseObject*/) {
  2914. var _this7 = this;
  2915. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
  2916. var _context9, _context10;
  2917. var localKey, objectKey, unsaved, promises, localDatastore, key, pinned;
  2918. return _regenerator.default.wrap(function (_context11) {
  2919. while (1) switch (_context11.prev = _context11.next) {
  2920. case 0:
  2921. if (_this7.isEnabled) {
  2922. _context11.next = 2;
  2923. break;
  2924. }
  2925. return _context11.abrupt("return");
  2926. case 2:
  2927. localKey = (0, _concat.default)(_context9 = (0, _concat.default)(_context10 = "".concat(_LocalDatastoreUtils.OBJECT_PREFIX)).call(_context10, object.className, "_")).call(_context9, localId);
  2928. objectKey = _this7.getKeyForObject(object);
  2929. _context11.next = 6;
  2930. return _this7.fromPinWithName(localKey);
  2931. case 6:
  2932. unsaved = _context11.sent;
  2933. if (!(!unsaved || unsaved.length === 0)) {
  2934. _context11.next = 9;
  2935. break;
  2936. }
  2937. return _context11.abrupt("return");
  2938. case 9:
  2939. promises = [_this7.unPinWithName(localKey), _this7.pinWithName(objectKey, unsaved)];
  2940. _context11.next = 12;
  2941. return _this7._getAllContents();
  2942. case 12:
  2943. localDatastore = _context11.sent;
  2944. for (key in localDatastore) {
  2945. if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
  2946. pinned = localDatastore[key] || [];
  2947. if ((0, _includes.default)(pinned).call(pinned, localKey)) {
  2948. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  2949. return item !== localKey;
  2950. });
  2951. pinned.push(objectKey);
  2952. promises.push(_this7.pinWithName(key, pinned));
  2953. localDatastore[key] = pinned;
  2954. }
  2955. }
  2956. }
  2957. return _context11.abrupt("return", _promise.default.all(promises));
  2958. case 15:
  2959. case "end":
  2960. return _context11.stop();
  2961. }
  2962. }, _callee7);
  2963. }))();
  2964. },
  2965. /**
  2966. * Updates Local Datastore from Server
  2967. *
  2968. * <pre>
  2969. * await Parse.LocalDatastore.updateFromServer();
  2970. * </pre>
  2971. *
  2972. * @function updateFromServer
  2973. * @name Parse.LocalDatastore.updateFromServer
  2974. * @static
  2975. */
  2976. updateFromServer: function () {
  2977. var _this8 = this;
  2978. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
  2979. var _context12;
  2980. var localDatastore, keys, key, pointersHash, _i, _keys, _key, _key$split, _key$split2, className, objectId, queryPromises, responses, objects, pinPromises;
  2981. return _regenerator.default.wrap(function (_context13) {
  2982. while (1) switch (_context13.prev = _context13.next) {
  2983. case 0:
  2984. if (!(!_this8.checkIfEnabled() || _this8.isSyncing)) {
  2985. _context13.next = 2;
  2986. break;
  2987. }
  2988. return _context13.abrupt("return");
  2989. case 2:
  2990. _context13.next = 4;
  2991. return _this8._getAllContents();
  2992. case 4:
  2993. localDatastore = _context13.sent;
  2994. keys = [];
  2995. for (key in localDatastore) {
  2996. if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
  2997. keys.push(key);
  2998. }
  2999. }
  3000. if (!(keys.length === 0)) {
  3001. _context13.next = 9;
  3002. break;
  3003. }
  3004. return _context13.abrupt("return");
  3005. case 9:
  3006. _this8.isSyncing = true;
  3007. pointersHash = {};
  3008. _i = 0, _keys = keys;
  3009. case 12:
  3010. if (!(_i < _keys.length)) {
  3011. _context13.next = 23;
  3012. break;
  3013. }
  3014. _key = _keys[_i];
  3015. // Ignore the OBJECT_PREFIX
  3016. _key$split = _key.split('_'), _key$split2 = (0, _slicedToArray2.default)(_key$split, 4), className = _key$split2[2], objectId = _key$split2[3]; // User key is split into [ 'Parse', 'LDS', '', 'User', 'objectId' ]
  3017. if (_key.split('_').length === 5 && _key.split('_')[3] === 'User') {
  3018. className = '_User';
  3019. objectId = _key.split('_')[4];
  3020. }
  3021. if (!(0, _startsWith.default)(objectId).call(objectId, 'local')) {
  3022. _context13.next = 18;
  3023. break;
  3024. }
  3025. return _context13.abrupt("continue", 20);
  3026. case 18:
  3027. if (!(className in pointersHash)) {
  3028. pointersHash[className] = new _set.default();
  3029. }
  3030. pointersHash[className].add(objectId);
  3031. case 20:
  3032. _i++;
  3033. _context13.next = 12;
  3034. break;
  3035. case 23:
  3036. queryPromises = (0, _map.default)(_context12 = (0, _keys2.default)(pointersHash)).call(_context12, function (className) {
  3037. var objectIds = (0, _from.default)(pointersHash[className]);
  3038. var query = new _ParseQuery.default(className);
  3039. query.limit(objectIds.length);
  3040. if (objectIds.length === 1) {
  3041. query.equalTo('objectId', objectIds[0]);
  3042. } else {
  3043. query.containedIn('objectId', objectIds);
  3044. }
  3045. return (0, _find.default)(query).call(query);
  3046. });
  3047. _context13.prev = 24;
  3048. _context13.next = 27;
  3049. return _promise.default.all(queryPromises);
  3050. case 27:
  3051. responses = _context13.sent;
  3052. objects = (0, _concat.default)([]).apply([], responses);
  3053. pinPromises = (0, _map.default)(objects).call(objects, function (object) {
  3054. var objectKey = _this8.getKeyForObject(object);
  3055. return _this8.pinWithName(objectKey, object._toFullJSON());
  3056. });
  3057. _context13.next = 32;
  3058. return _promise.default.all(pinPromises);
  3059. case 32:
  3060. _this8.isSyncing = false;
  3061. _context13.next = 39;
  3062. break;
  3063. case 35:
  3064. _context13.prev = 35;
  3065. _context13.t0 = _context13["catch"](24);
  3066. console.error('Error syncing LocalDatastore: ', _context13.t0);
  3067. _this8.isSyncing = false;
  3068. case 39:
  3069. case "end":
  3070. return _context13.stop();
  3071. }
  3072. }, _callee8, null, [[24, 35]]);
  3073. }))();
  3074. },
  3075. getKeyForObject: function (object /*: any*/) {
  3076. var _context14, _context15;
  3077. var objectId = object.objectId || object._getId();
  3078. return (0, _concat.default)(_context14 = (0, _concat.default)(_context15 = "".concat(_LocalDatastoreUtils.OBJECT_PREFIX)).call(_context15, object.className, "_")).call(_context14, objectId);
  3079. },
  3080. getPinName: function (pinName /*: ?string*/) {
  3081. if (!pinName || pinName === _LocalDatastoreUtils.DEFAULT_PIN) {
  3082. return _LocalDatastoreUtils.DEFAULT_PIN;
  3083. }
  3084. return _LocalDatastoreUtils.PIN_PREFIX + pinName;
  3085. },
  3086. checkIfEnabled: function () {
  3087. if (!this.isEnabled) {
  3088. console.error('Parse.enableLocalDatastore() must be called first');
  3089. }
  3090. return this.isEnabled;
  3091. }
  3092. };
  3093. module.exports = LocalDatastore;
  3094. _CoreManager.default.setLocalDatastoreController(_dereq_('./LocalDatastoreController'));
  3095. _CoreManager.default.setLocalDatastore(LocalDatastore);
  3096. },{"./CoreManager":4,"./LocalDatastoreController":14,"./LocalDatastoreUtils":15,"./ParseQuery":30,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/find":63,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/instance/keys":67,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/slice":70,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":73,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/core-js-stable/set":94,"@babel/runtime-corejs3/core-js-stable/symbol":95,"@babel/runtime-corejs3/core-js/get-iterator-method":99,"@babel/runtime-corejs3/helpers/asyncToGenerator":121,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/slicedToArray":139,"@babel/runtime-corejs3/helpers/toConsumableArray":141,"@babel/runtime-corejs3/regenerator":147}],14:[function(_dereq_,module,exports){
  3097. "use strict";
  3098. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  3099. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  3100. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  3101. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  3102. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  3103. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3104. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  3105. var _reduce = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
  3106. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  3107. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  3108. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  3109. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  3110. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  3111. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  3112. function _createForOfIteratorHelper(o, allowArrayLike) {
  3113. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  3114. if (!it) {
  3115. if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  3116. if (it) o = it;
  3117. var i = 0;
  3118. var F = function () {};
  3119. return {
  3120. s: F,
  3121. n: function () {
  3122. if (i >= o.length) return {
  3123. done: true
  3124. };
  3125. return {
  3126. done: false,
  3127. value: o[i++]
  3128. };
  3129. },
  3130. e: function (_e) {
  3131. throw _e;
  3132. },
  3133. f: F
  3134. };
  3135. }
  3136. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3137. }
  3138. var normalCompletion = true,
  3139. didErr = false,
  3140. err;
  3141. return {
  3142. s: function () {
  3143. it = it.call(o);
  3144. },
  3145. n: function () {
  3146. var step = it.next();
  3147. normalCompletion = step.done;
  3148. return step;
  3149. },
  3150. e: function (_e2) {
  3151. didErr = true;
  3152. err = _e2;
  3153. },
  3154. f: function () {
  3155. try {
  3156. if (!normalCompletion && it.return != null) it.return();
  3157. } finally {
  3158. if (didErr) throw err;
  3159. }
  3160. }
  3161. };
  3162. }
  3163. function _unsupportedIterableToArray(o, minLen) {
  3164. var _context7;
  3165. if (!o) return;
  3166. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  3167. var n = _sliceInstanceProperty(_context7 = Object.prototype.toString.call(o)).call(_context7, 8, -1);
  3168. if (n === "Object" && o.constructor) n = o.constructor.name;
  3169. if (n === "Map" || n === "Set") return _Array$from(o);
  3170. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  3171. }
  3172. function _arrayLikeToArray(arr, len) {
  3173. if (len == null || len > arr.length) len = arr.length;
  3174. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  3175. return arr2;
  3176. } /**
  3177. * @flow
  3178. */
  3179. var LocalDatastoreController = {
  3180. fromPinWithName: function (name /*: string*/) /*: Array<Object>*/{
  3181. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  3182. var values, objects;
  3183. return _regenerator.default.wrap(function (_context) {
  3184. while (1) switch (_context.prev = _context.next) {
  3185. case 0:
  3186. _context.next = 2;
  3187. return _Storage.default.getItemAsync(name);
  3188. case 2:
  3189. values = _context.sent;
  3190. if (values) {
  3191. _context.next = 5;
  3192. break;
  3193. }
  3194. return _context.abrupt("return", []);
  3195. case 5:
  3196. objects = JSON.parse(values);
  3197. return _context.abrupt("return", objects);
  3198. case 7:
  3199. case "end":
  3200. return _context.stop();
  3201. }
  3202. }, _callee);
  3203. }))();
  3204. },
  3205. pinWithName: function (name /*: string*/, value /*: any*/) {
  3206. var values = (0, _stringify.default)(value);
  3207. return _Storage.default.setItemAsync(name, values);
  3208. },
  3209. unPinWithName: function (name /*: string*/) {
  3210. return _Storage.default.removeItemAsync(name);
  3211. },
  3212. getAllContents: function () /*: Object*/{
  3213. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  3214. var keys;
  3215. return _regenerator.default.wrap(function (_context3) {
  3216. while (1) switch (_context3.prev = _context3.next) {
  3217. case 0:
  3218. _context3.next = 2;
  3219. return _Storage.default.getAllKeysAsync();
  3220. case 2:
  3221. keys = _context3.sent;
  3222. return _context3.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
  3223. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(previousPromise, key) {
  3224. var LDS, value;
  3225. return _regenerator.default.wrap(function (_context2) {
  3226. while (1) switch (_context2.prev = _context2.next) {
  3227. case 0:
  3228. _context2.next = 2;
  3229. return previousPromise;
  3230. case 2:
  3231. LDS = _context2.sent;
  3232. if (!(0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  3233. _context2.next = 8;
  3234. break;
  3235. }
  3236. _context2.next = 6;
  3237. return _Storage.default.getItemAsync(key);
  3238. case 6:
  3239. value = _context2.sent;
  3240. try {
  3241. LDS[key] = JSON.parse(value);
  3242. } catch (error) {
  3243. console.error('Error getAllContents: ', error);
  3244. }
  3245. case 8:
  3246. return _context2.abrupt("return", LDS);
  3247. case 9:
  3248. case "end":
  3249. return _context2.stop();
  3250. }
  3251. }, _callee2);
  3252. }));
  3253. return function () {
  3254. return _ref.apply(this, arguments);
  3255. };
  3256. }(), _promise.default.resolve({})));
  3257. case 4:
  3258. case "end":
  3259. return _context3.stop();
  3260. }
  3261. }, _callee3);
  3262. }))();
  3263. },
  3264. // Used for testing
  3265. getRawStorage: function () /*: Object*/{
  3266. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  3267. var keys;
  3268. return _regenerator.default.wrap(function (_context5) {
  3269. while (1) switch (_context5.prev = _context5.next) {
  3270. case 0:
  3271. _context5.next = 2;
  3272. return _Storage.default.getAllKeysAsync();
  3273. case 2:
  3274. keys = _context5.sent;
  3275. return _context5.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
  3276. var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(previousPromise, key) {
  3277. var LDS, value;
  3278. return _regenerator.default.wrap(function (_context4) {
  3279. while (1) switch (_context4.prev = _context4.next) {
  3280. case 0:
  3281. _context4.next = 2;
  3282. return previousPromise;
  3283. case 2:
  3284. LDS = _context4.sent;
  3285. _context4.next = 5;
  3286. return _Storage.default.getItemAsync(key);
  3287. case 5:
  3288. value = _context4.sent;
  3289. LDS[key] = value;
  3290. return _context4.abrupt("return", LDS);
  3291. case 8:
  3292. case "end":
  3293. return _context4.stop();
  3294. }
  3295. }, _callee4);
  3296. }));
  3297. return function () {
  3298. return _ref2.apply(this, arguments);
  3299. };
  3300. }(), _promise.default.resolve({})));
  3301. case 4:
  3302. case "end":
  3303. return _context5.stop();
  3304. }
  3305. }, _callee5);
  3306. }))();
  3307. },
  3308. clear: function () /*: Promise*/{
  3309. var _this = this;
  3310. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  3311. var keys, toRemove, _iterator, _step, key, promises;
  3312. return _regenerator.default.wrap(function (_context6) {
  3313. while (1) switch (_context6.prev = _context6.next) {
  3314. case 0:
  3315. _context6.next = 2;
  3316. return _Storage.default.getAllKeysAsync();
  3317. case 2:
  3318. keys = _context6.sent;
  3319. toRemove = [];
  3320. _iterator = _createForOfIteratorHelper(keys);
  3321. try {
  3322. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3323. key = _step.value;
  3324. if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  3325. toRemove.push(key);
  3326. }
  3327. }
  3328. } catch (err) {
  3329. _iterator.e(err);
  3330. } finally {
  3331. _iterator.f();
  3332. }
  3333. promises = (0, _map.default)(toRemove).call(toRemove, _this.unPinWithName);
  3334. return _context6.abrupt("return", _promise.default.all(promises));
  3335. case 8:
  3336. case "end":
  3337. return _context6.stop();
  3338. }
  3339. }, _callee6);
  3340. }))();
  3341. }
  3342. };
  3343. module.exports = LocalDatastoreController;
  3344. },{"./LocalDatastoreUtils":15,"./Storage":39,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/reduce":69,"@babel/runtime-corejs3/core-js-stable/instance/slice":70,"@babel/runtime-corejs3/core-js-stable/json/stringify":75,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/core-js-stable/symbol":95,"@babel/runtime-corejs3/core-js/get-iterator-method":99,"@babel/runtime-corejs3/helpers/asyncToGenerator":121,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/regenerator":147}],15:[function(_dereq_,module,exports){
  3345. "use strict";
  3346. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3347. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3348. _Object$defineProperty(exports, "__esModule", {
  3349. value: true
  3350. });
  3351. exports.PIN_PREFIX = exports.OBJECT_PREFIX = exports.DEFAULT_PIN = void 0;
  3352. exports.isLocalDatastoreKey = isLocalDatastoreKey;
  3353. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  3354. /**
  3355. * @flow
  3356. * @private
  3357. */
  3358. var DEFAULT_PIN = '_default';
  3359. exports.DEFAULT_PIN = DEFAULT_PIN;
  3360. var PIN_PREFIX = 'parsePin_';
  3361. exports.PIN_PREFIX = PIN_PREFIX;
  3362. var OBJECT_PREFIX = 'Parse_LDS_';
  3363. exports.OBJECT_PREFIX = OBJECT_PREFIX;
  3364. function isLocalDatastoreKey(key /*: string*/) /*: boolean*/{
  3365. return !!(key && (key === DEFAULT_PIN || (0, _startsWith.default)(key).call(key, PIN_PREFIX) || (0, _startsWith.default)(key).call(key, OBJECT_PREFIX)));
  3366. }
  3367. },{"@babel/runtime-corejs3/core-js-stable/instance/starts-with":73,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],16:[function(_dereq_,module,exports){
  3368. "use strict";
  3369. var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  3370. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  3371. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  3372. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  3373. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  3374. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  3375. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  3376. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3377. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3378. _Object$defineProperty(exports, "__esModule", {
  3379. value: true
  3380. });
  3381. exports.commitServerChanges = commitServerChanges;
  3382. exports.defaultState = defaultState;
  3383. exports.estimateAttribute = estimateAttribute;
  3384. exports.estimateAttributes = estimateAttributes;
  3385. exports.mergeFirstPendingState = mergeFirstPendingState;
  3386. exports.popPendingState = popPendingState;
  3387. exports.pushPendingState = pushPendingState;
  3388. exports.setPendingOp = setPendingOp;
  3389. exports.setServerData = setServerData;
  3390. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  3391. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  3392. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  3393. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  3394. var _encode = _interopRequireDefault(_dereq_("./encode"));
  3395. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  3396. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  3397. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  3398. var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
  3399. var _ParseOp = _dereq_("./ParseOp");
  3400. function ownKeys(object, enumerableOnly) {
  3401. var keys = _Object$keys(object);
  3402. if (_Object$getOwnPropertySymbols) {
  3403. var symbols = _Object$getOwnPropertySymbols(object);
  3404. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  3405. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  3406. })), keys.push.apply(keys, symbols);
  3407. }
  3408. return keys;
  3409. }
  3410. function _objectSpread(target) {
  3411. for (var i = 1; i < arguments.length; i++) {
  3412. var _context, _context2;
  3413. var source = null != arguments[i] ? arguments[i] : {};
  3414. i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) {
  3415. (0, _defineProperty2.default)(target, key, source[key]);
  3416. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) {
  3417. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  3418. });
  3419. }
  3420. return target;
  3421. } /**
  3422. * @flow
  3423. */
  3424. /*:: import type { Op } from './ParseOp';*/
  3425. /*:: export type AttributeMap = { [attr: string]: any };*/
  3426. /*:: export type OpsMap = { [attr: string]: Op };*/
  3427. /*:: export type ObjectCache = { [attr: string]: string };*/
  3428. /*:: export type State = {
  3429. serverData: AttributeMap,
  3430. pendingOps: Array<OpsMap>,
  3431. objectCache: ObjectCache,
  3432. tasks: TaskQueue,
  3433. existed: boolean,
  3434. };*/
  3435. function defaultState() /*: State*/{
  3436. return {
  3437. serverData: {},
  3438. pendingOps: [{}],
  3439. objectCache: {},
  3440. tasks: new _TaskQueue.default(),
  3441. existed: false
  3442. };
  3443. }
  3444. function setServerData(serverData /*: AttributeMap*/, attributes /*: AttributeMap*/) {
  3445. for (var _attr in attributes) {
  3446. if (typeof attributes[_attr] !== 'undefined') {
  3447. serverData[_attr] = attributes[_attr];
  3448. } else {
  3449. delete serverData[_attr];
  3450. }
  3451. }
  3452. }
  3453. function setPendingOp(pendingOps /*: Array<OpsMap>*/, attr /*: string*/, op /*: ?Op*/) {
  3454. var last = pendingOps.length - 1;
  3455. if (op) {
  3456. pendingOps[last][attr] = op;
  3457. } else {
  3458. delete pendingOps[last][attr];
  3459. }
  3460. }
  3461. function pushPendingState(pendingOps /*: Array<OpsMap>*/) {
  3462. pendingOps.push({});
  3463. }
  3464. function popPendingState(pendingOps /*: Array<OpsMap>*/) /*: OpsMap*/{
  3465. var first = pendingOps.shift();
  3466. if (!pendingOps.length) {
  3467. pendingOps[0] = {};
  3468. }
  3469. return first;
  3470. }
  3471. function mergeFirstPendingState(pendingOps /*: Array<OpsMap>*/) {
  3472. var first = popPendingState(pendingOps);
  3473. var next = pendingOps[0];
  3474. for (var _attr2 in first) {
  3475. if (next[_attr2] && first[_attr2]) {
  3476. var merged = next[_attr2].mergeWith(first[_attr2]);
  3477. if (merged) {
  3478. next[_attr2] = merged;
  3479. }
  3480. } else {
  3481. next[_attr2] = first[_attr2];
  3482. }
  3483. }
  3484. }
  3485. function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/, attr /*: string*/) /*: mixed*/{
  3486. var value = serverData[attr];
  3487. for (var i = 0; i < pendingOps.length; i++) {
  3488. if (pendingOps[i][attr]) {
  3489. if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
  3490. if (id) {
  3491. value = pendingOps[i][attr].applyTo(value, {
  3492. className: className,
  3493. id: id
  3494. }, attr);
  3495. }
  3496. } else {
  3497. value = pendingOps[i][attr].applyTo(value);
  3498. }
  3499. }
  3500. }
  3501. return value;
  3502. }
  3503. function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/) /*: AttributeMap*/{
  3504. var data = {};
  3505. for (var attr in serverData) {
  3506. data[attr] = serverData[attr];
  3507. }
  3508. for (var i = 0; i < pendingOps.length; i++) {
  3509. for (attr in pendingOps[i]) {
  3510. if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
  3511. if (id) {
  3512. data[attr] = pendingOps[i][attr].applyTo(data[attr], {
  3513. className: className,
  3514. id: id
  3515. }, attr);
  3516. }
  3517. } else {
  3518. if ((0, _includes.default)(attr).call(attr, '.')) {
  3519. // convert a.b.c into { a: { b: { c: value } } }
  3520. var fields = attr.split('.');
  3521. var first = fields[0];
  3522. var last = fields[fields.length - 1];
  3523. data[first] = _objectSpread({}, serverData[first]);
  3524. var object = _objectSpread({}, data);
  3525. for (var _i = 0; _i < fields.length - 1; _i++) {
  3526. var key = fields[_i];
  3527. if (!(key in object)) {
  3528. object[key] = {};
  3529. }
  3530. object = object[key];
  3531. }
  3532. object[last] = pendingOps[i][attr].applyTo(object[last]);
  3533. } else {
  3534. data[attr] = pendingOps[i][attr].applyTo(data[attr]);
  3535. }
  3536. }
  3537. }
  3538. }
  3539. return data;
  3540. }
  3541. function nestedSet(obj, key, value) {
  3542. var path = key.split('.');
  3543. for (var i = 0; i < path.length - 1; i++) {
  3544. if (!(path[i] in obj)) obj[path[i]] = {};
  3545. obj = obj[path[i]];
  3546. }
  3547. if (typeof value === 'undefined') {
  3548. delete obj[path[path.length - 1]];
  3549. } else {
  3550. obj[path[path.length - 1]] = value;
  3551. }
  3552. }
  3553. function commitServerChanges(serverData /*: AttributeMap*/, objectCache /*: ObjectCache*/, changes /*: AttributeMap*/) {
  3554. for (var _attr3 in changes) {
  3555. var val = changes[_attr3];
  3556. nestedSet(serverData, _attr3, val);
  3557. if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof _ParseObject.default) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
  3558. var json = (0, _encode.default)(val, false, true);
  3559. objectCache[_attr3] = (0, _stringify.default)(json);
  3560. }
  3561. }
  3562. }
  3563. },{"./ParseFile":23,"./ParseObject":27,"./ParseOp":28,"./ParseRelation":31,"./TaskQueue":41,"./encode":46,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/json/stringify":75,"@babel/runtime-corejs3/core-js-stable/object/define-properties":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":84,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":86,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],17:[function(_dereq_,module,exports){
  3564. "use strict";
  3565. var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  3566. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  3567. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  3568. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  3569. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  3570. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3571. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  3572. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  3573. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  3574. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  3575. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  3576. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  3577. var _isInteger = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/number/is-integer"));
  3578. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  3579. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  3580. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  3581. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  3582. function _createForOfIteratorHelper(o, allowArrayLike) {
  3583. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  3584. if (!it) {
  3585. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  3586. if (it) o = it;
  3587. var i = 0;
  3588. var F = function () {};
  3589. return {
  3590. s: F,
  3591. n: function () {
  3592. if (i >= o.length) return {
  3593. done: true
  3594. };
  3595. return {
  3596. done: false,
  3597. value: o[i++]
  3598. };
  3599. },
  3600. e: function (_e) {
  3601. throw _e;
  3602. },
  3603. f: F
  3604. };
  3605. }
  3606. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3607. }
  3608. var normalCompletion = true,
  3609. didErr = false,
  3610. err;
  3611. return {
  3612. s: function () {
  3613. it = it.call(o);
  3614. },
  3615. n: function () {
  3616. var step = it.next();
  3617. normalCompletion = step.done;
  3618. return step;
  3619. },
  3620. e: function (_e2) {
  3621. didErr = true;
  3622. err = _e2;
  3623. },
  3624. f: function () {
  3625. try {
  3626. if (!normalCompletion && it.return != null) it.return();
  3627. } finally {
  3628. if (didErr) throw err;
  3629. }
  3630. }
  3631. };
  3632. }
  3633. function _unsupportedIterableToArray(o, minLen) {
  3634. var _context6;
  3635. if (!o) return;
  3636. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  3637. var n = _sliceInstanceProperty2(_context6 = Object.prototype.toString.call(o)).call(_context6, 8, -1);
  3638. if (n === "Object" && o.constructor) n = o.constructor.name;
  3639. if (n === "Map" || n === "Set") return _Array$from(o);
  3640. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  3641. }
  3642. function _arrayLikeToArray(arr, len) {
  3643. if (len == null || len > arr.length) len = arr.length;
  3644. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  3645. return arr2;
  3646. }
  3647. var equalObjects = _dereq_('./equals').default;
  3648. var decode = _dereq_('./decode').default;
  3649. var ParseError = _dereq_('./ParseError').default;
  3650. var ParsePolygon = _dereq_('./ParsePolygon').default;
  3651. var ParseGeoPoint = _dereq_('./ParseGeoPoint').default;
  3652. /**
  3653. * contains -- Determines if an object is contained in a list with special handling for Parse pointers.
  3654. *
  3655. * @param haystack
  3656. * @param needle
  3657. * @private
  3658. * @returns {boolean}
  3659. */
  3660. function contains(haystack, needle) {
  3661. if (needle && needle.__type && (needle.__type === 'Pointer' || needle.__type === 'Object')) {
  3662. for (var i in haystack) {
  3663. var ptr = haystack[i];
  3664. if (typeof ptr === 'string' && ptr === needle.objectId) {
  3665. return true;
  3666. }
  3667. if (ptr.className === needle.className && ptr.objectId === needle.objectId) {
  3668. return true;
  3669. }
  3670. }
  3671. return false;
  3672. }
  3673. if ((0, _isArray.default)(needle)) {
  3674. var _iterator = _createForOfIteratorHelper(needle),
  3675. _step;
  3676. try {
  3677. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3678. var need = _step.value;
  3679. if (contains(haystack, need)) {
  3680. return true;
  3681. }
  3682. }
  3683. } catch (err) {
  3684. _iterator.e(err);
  3685. } finally {
  3686. _iterator.f();
  3687. }
  3688. }
  3689. return (0, _indexOf.default)(haystack).call(haystack, needle) > -1;
  3690. }
  3691. function transformObject(object) {
  3692. if (object._toFullJSON) {
  3693. return object._toFullJSON();
  3694. }
  3695. return object;
  3696. }
  3697. /**
  3698. * matchesQuery -- Determines if an object would be returned by a Parse Query
  3699. * It's a lightweight, where-clause only implementation of a full query engine.
  3700. * Since we find queries that match objects, rather than objects that match
  3701. * queries, we can avoid building a full-blown query tool.
  3702. *
  3703. * @param className
  3704. * @param object
  3705. * @param objects
  3706. * @param query
  3707. * @private
  3708. * @returns {boolean}
  3709. */
  3710. function matchesQuery(className, object, objects, query) {
  3711. if (object.className !== className) {
  3712. return false;
  3713. }
  3714. var obj = object;
  3715. var q = query;
  3716. if (object.toJSON) {
  3717. obj = object.toJSON();
  3718. }
  3719. if (query.toJSON) {
  3720. q = query.toJSON().where;
  3721. }
  3722. obj.className = className;
  3723. for (var field in q) {
  3724. if (!matchesKeyConstraints(className, obj, objects, field, q[field])) {
  3725. return false;
  3726. }
  3727. }
  3728. return true;
  3729. }
  3730. function equalObjectsGeneric(obj, compareTo, eqlFn) {
  3731. if ((0, _isArray.default)(obj)) {
  3732. for (var i = 0; i < obj.length; i++) {
  3733. if (eqlFn(obj[i], compareTo)) {
  3734. return true;
  3735. }
  3736. }
  3737. return false;
  3738. }
  3739. return eqlFn(obj, compareTo);
  3740. }
  3741. /**
  3742. * @typedef RelativeTimeToDateResult
  3743. * @property {string} status The conversion status, `error` if conversion failed or
  3744. * `success` if conversion succeeded.
  3745. * @property {string} info The error message if conversion failed, or the relative
  3746. * time indication (`past`, `present`, `future`) if conversion succeeded.
  3747. * @property {Date|undefined} result The converted date, or `undefined` if conversion
  3748. * failed.
  3749. */
  3750. /**
  3751. * Converts human readable relative date string, for example, 'in 10 days' to a date
  3752. * relative to now.
  3753. *
  3754. * @param {string} text The text to convert.
  3755. * @param {Date} [now=new Date()] The date from which add or subtract. Default is now.
  3756. * @returns {RelativeTimeToDateResult}
  3757. */
  3758. function relativeTimeToDate(text) {
  3759. var now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Date();
  3760. text = text.toLowerCase();
  3761. var parts = text.split(' ');
  3762. // Filter out whitespace
  3763. parts = (0, _filter.default)(parts).call(parts, function (part) {
  3764. return part !== '';
  3765. });
  3766. var future = parts[0] === 'in';
  3767. var past = parts[parts.length - 1] === 'ago';
  3768. if (!future && !past && text !== 'now') {
  3769. return {
  3770. status: 'error',
  3771. info: "Time should either start with 'in' or end with 'ago'"
  3772. };
  3773. }
  3774. if (future && past) {
  3775. return {
  3776. status: 'error',
  3777. info: "Time cannot have both 'in' and 'ago'"
  3778. };
  3779. }
  3780. // strip the 'ago' or 'in'
  3781. if (future) {
  3782. parts = (0, _slice.default)(parts).call(parts, 1);
  3783. } else {
  3784. // past
  3785. parts = (0, _slice.default)(parts).call(parts, 0, parts.length - 1);
  3786. }
  3787. if (parts.length % 2 !== 0 && text !== 'now') {
  3788. return {
  3789. status: 'error',
  3790. info: 'Invalid time string. Dangling unit or number.'
  3791. };
  3792. }
  3793. var pairs = [];
  3794. while (parts.length) {
  3795. pairs.push([parts.shift(), parts.shift()]);
  3796. }
  3797. var seconds = 0;
  3798. for (var _i = 0, _pairs = pairs; _i < _pairs.length; _i++) {
  3799. var _pairs$_i = (0, _slicedToArray2.default)(_pairs[_i], 2),
  3800. num = _pairs$_i[0],
  3801. interval = _pairs$_i[1];
  3802. var val = Number(num);
  3803. if (!(0, _isInteger.default)(val)) {
  3804. return {
  3805. status: 'error',
  3806. info: "'".concat(num, "' is not an integer.")
  3807. };
  3808. }
  3809. switch (interval) {
  3810. case 'yr':
  3811. case 'yrs':
  3812. case 'year':
  3813. case 'years':
  3814. seconds += val * 31536000; // 365 * 24 * 60 * 60
  3815. break;
  3816. case 'wk':
  3817. case 'wks':
  3818. case 'week':
  3819. case 'weeks':
  3820. seconds += val * 604800; // 7 * 24 * 60 * 60
  3821. break;
  3822. case 'd':
  3823. case 'day':
  3824. case 'days':
  3825. seconds += val * 86400; // 24 * 60 * 60
  3826. break;
  3827. case 'hr':
  3828. case 'hrs':
  3829. case 'hour':
  3830. case 'hours':
  3831. seconds += val * 3600; // 60 * 60
  3832. break;
  3833. case 'min':
  3834. case 'mins':
  3835. case 'minute':
  3836. case 'minutes':
  3837. seconds += val * 60;
  3838. break;
  3839. case 'sec':
  3840. case 'secs':
  3841. case 'second':
  3842. case 'seconds':
  3843. seconds += val;
  3844. break;
  3845. default:
  3846. return {
  3847. status: 'error',
  3848. info: "Invalid interval: '".concat(interval, "'")
  3849. };
  3850. }
  3851. }
  3852. var milliseconds = seconds * 1000;
  3853. if (future) {
  3854. return {
  3855. status: 'success',
  3856. info: 'future',
  3857. result: new Date(now.valueOf() + milliseconds)
  3858. };
  3859. } else if (past) {
  3860. return {
  3861. status: 'success',
  3862. info: 'past',
  3863. result: new Date(now.valueOf() - milliseconds)
  3864. };
  3865. } else {
  3866. return {
  3867. status: 'success',
  3868. info: 'present',
  3869. result: new Date(now.valueOf())
  3870. };
  3871. }
  3872. }
  3873. /**
  3874. * Determines whether an object matches a single key's constraints
  3875. *
  3876. * @param className
  3877. * @param object
  3878. * @param objects
  3879. * @param key
  3880. * @param constraints
  3881. * @private
  3882. * @returns {boolean}
  3883. */
  3884. function matchesKeyConstraints(className, object, objects, key, constraints) {
  3885. if (constraints === null) {
  3886. return false;
  3887. }
  3888. if ((0, _indexOf.default)(key).call(key, '.') >= 0) {
  3889. // Key references a subobject
  3890. var keyComponents = key.split('.');
  3891. var subObjectKey = keyComponents[0];
  3892. var keyRemainder = (0, _slice.default)(keyComponents).call(keyComponents, 1).join('.');
  3893. return matchesKeyConstraints(className, object[subObjectKey] || {}, objects, keyRemainder, constraints);
  3894. }
  3895. var i;
  3896. if (key === '$or') {
  3897. for (i = 0; i < constraints.length; i++) {
  3898. if (matchesQuery(className, object, objects, constraints[i])) {
  3899. return true;
  3900. }
  3901. }
  3902. return false;
  3903. }
  3904. if (key === '$and') {
  3905. for (i = 0; i < constraints.length; i++) {
  3906. if (!matchesQuery(className, object, objects, constraints[i])) {
  3907. return false;
  3908. }
  3909. }
  3910. return true;
  3911. }
  3912. if (key === '$nor') {
  3913. for (i = 0; i < constraints.length; i++) {
  3914. if (matchesQuery(className, object, objects, constraints[i])) {
  3915. return false;
  3916. }
  3917. }
  3918. return true;
  3919. }
  3920. if (key === '$relatedTo') {
  3921. // Bail! We can't handle relational queries locally
  3922. return false;
  3923. }
  3924. if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(key)) {
  3925. throw new ParseError(ParseError.INVALID_KEY_NAME, "Invalid Key: ".concat(key));
  3926. }
  3927. // Equality (or Array contains) cases
  3928. if ((0, _typeof2.default)(constraints) !== 'object') {
  3929. if ((0, _isArray.default)(object[key])) {
  3930. var _context;
  3931. return (0, _indexOf.default)(_context = object[key]).call(_context, constraints) > -1;
  3932. }
  3933. return object[key] === constraints;
  3934. }
  3935. var compareTo;
  3936. if (constraints.__type) {
  3937. if (constraints.__type === 'Pointer') {
  3938. return equalObjectsGeneric(object[key], constraints, function (obj, ptr) {
  3939. return typeof obj !== 'undefined' && ptr.className === obj.className && ptr.objectId === obj.objectId;
  3940. });
  3941. }
  3942. return equalObjectsGeneric(decode(object[key]), decode(constraints), equalObjects);
  3943. }
  3944. // More complex cases
  3945. for (var condition in constraints) {
  3946. compareTo = constraints[condition];
  3947. if (compareTo.__type) {
  3948. compareTo = decode(compareTo);
  3949. }
  3950. // is it a $relativeTime? convert to date
  3951. if (compareTo['$relativeTime']) {
  3952. var parserResult = relativeTimeToDate(compareTo['$relativeTime']);
  3953. if (parserResult.status !== 'success') {
  3954. var _context2;
  3955. throw new ParseError(ParseError.INVALID_JSON, (0, _concat.default)(_context2 = "bad $relativeTime (".concat(key, ") value. ")).call(_context2, parserResult.info));
  3956. }
  3957. compareTo = parserResult.result;
  3958. }
  3959. // Compare Date Object or Date String
  3960. if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' && new Date(compareTo) !== 'Invalid Date' && !isNaN(new Date(compareTo))) {
  3961. object[key] = new Date(object[key].iso ? object[key].iso : object[key]);
  3962. }
  3963. switch (condition) {
  3964. case '$lt':
  3965. if (object[key] >= compareTo) {
  3966. return false;
  3967. }
  3968. break;
  3969. case '$lte':
  3970. if (object[key] > compareTo) {
  3971. return false;
  3972. }
  3973. break;
  3974. case '$gt':
  3975. if (object[key] <= compareTo) {
  3976. return false;
  3977. }
  3978. break;
  3979. case '$gte':
  3980. if (object[key] < compareTo) {
  3981. return false;
  3982. }
  3983. break;
  3984. case '$ne':
  3985. if (equalObjects(object[key], compareTo)) {
  3986. return false;
  3987. }
  3988. break;
  3989. case '$in':
  3990. if (!contains(compareTo, object[key])) {
  3991. return false;
  3992. }
  3993. break;
  3994. case '$nin':
  3995. if (contains(compareTo, object[key])) {
  3996. return false;
  3997. }
  3998. break;
  3999. case '$all':
  4000. for (i = 0; i < compareTo.length; i++) {
  4001. var _context3;
  4002. if ((0, _indexOf.default)(_context3 = object[key]).call(_context3, compareTo[i]) < 0) {
  4003. return false;
  4004. }
  4005. }
  4006. break;
  4007. case '$exists':
  4008. {
  4009. var propertyExists = typeof object[key] !== 'undefined';
  4010. var existenceIsRequired = constraints['$exists'];
  4011. if (typeof constraints['$exists'] !== 'boolean') {
  4012. // The SDK will never submit a non-boolean for $exists, but if someone
  4013. // tries to submit a non-boolean for $exits outside the SDKs, just ignore it.
  4014. break;
  4015. }
  4016. if (!propertyExists && existenceIsRequired || propertyExists && !existenceIsRequired) {
  4017. return false;
  4018. }
  4019. break;
  4020. }
  4021. case '$regex':
  4022. {
  4023. if ((0, _typeof2.default)(compareTo) === 'object') {
  4024. return compareTo.test(object[key]);
  4025. }
  4026. // JS doesn't support perl-style escaping
  4027. var expString = '';
  4028. var escapeEnd = -2;
  4029. var escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q');
  4030. while (escapeStart > -1) {
  4031. // Add the unescaped portion
  4032. expString += compareTo.substring(escapeEnd + 2, escapeStart);
  4033. escapeEnd = (0, _indexOf.default)(compareTo).call(compareTo, '\\E', escapeStart);
  4034. if (escapeEnd > -1) {
  4035. expString += compareTo.substring(escapeStart + 2, escapeEnd).replace(/\\\\\\\\E/g, '\\E').replace(/\W/g, '\\$&');
  4036. }
  4037. escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q', escapeEnd);
  4038. }
  4039. expString += compareTo.substring(Math.max(escapeStart, escapeEnd + 2));
  4040. var modifiers = constraints.$options || '';
  4041. modifiers = modifiers.replace('x', '').replace('s', '');
  4042. // Parse Server / Mongo support x and s modifiers but JS RegExp doesn't
  4043. var exp = new RegExp(expString, modifiers);
  4044. if (!exp.test(object[key])) {
  4045. return false;
  4046. }
  4047. break;
  4048. }
  4049. case '$nearSphere':
  4050. {
  4051. if (!compareTo || !object[key]) {
  4052. return false;
  4053. }
  4054. var distance = compareTo.radiansTo(object[key]);
  4055. var max = constraints.$maxDistance || Infinity;
  4056. return distance <= max;
  4057. }
  4058. case '$within':
  4059. {
  4060. if (!compareTo || !object[key]) {
  4061. return false;
  4062. }
  4063. var southWest = compareTo.$box[0];
  4064. var northEast = compareTo.$box[1];
  4065. if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
  4066. // Invalid box, crosses the date line
  4067. return false;
  4068. }
  4069. return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
  4070. }
  4071. case '$options':
  4072. // Not a query type, but a way to add options to $regex. Ignore and
  4073. // avoid the default
  4074. break;
  4075. case '$maxDistance':
  4076. // Not a query type, but a way to add a cap to $nearSphere. Ignore and
  4077. // avoid the default
  4078. break;
  4079. case '$select':
  4080. {
  4081. var subQueryObjects = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  4082. return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
  4083. });
  4084. for (var _i2 = 0; _i2 < subQueryObjects.length; _i2 += 1) {
  4085. var subObject = transformObject(subQueryObjects[_i2]);
  4086. return equalObjects(object[key], subObject[compareTo.key]);
  4087. }
  4088. return false;
  4089. }
  4090. case '$dontSelect':
  4091. {
  4092. var _subQueryObjects = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  4093. return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
  4094. });
  4095. for (var _i3 = 0; _i3 < _subQueryObjects.length; _i3 += 1) {
  4096. var _subObject = transformObject(_subQueryObjects[_i3]);
  4097. return !equalObjects(object[key], _subObject[compareTo.key]);
  4098. }
  4099. return false;
  4100. }
  4101. case '$inQuery':
  4102. {
  4103. var _subQueryObjects2 = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  4104. return matchesQuery(compareTo.className, obj, arr, compareTo.where);
  4105. });
  4106. for (var _i4 = 0; _i4 < _subQueryObjects2.length; _i4 += 1) {
  4107. var _subObject2 = transformObject(_subQueryObjects2[_i4]);
  4108. if (object[key].className === _subObject2.className && object[key].objectId === _subObject2.objectId) {
  4109. return true;
  4110. }
  4111. }
  4112. return false;
  4113. }
  4114. case '$notInQuery':
  4115. {
  4116. var _subQueryObjects3 = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  4117. return matchesQuery(compareTo.className, obj, arr, compareTo.where);
  4118. });
  4119. for (var _i5 = 0; _i5 < _subQueryObjects3.length; _i5 += 1) {
  4120. var _subObject3 = transformObject(_subQueryObjects3[_i5]);
  4121. if (object[key].className === _subObject3.className && object[key].objectId === _subObject3.objectId) {
  4122. return false;
  4123. }
  4124. }
  4125. return true;
  4126. }
  4127. case '$containedBy':
  4128. {
  4129. var _iterator2 = _createForOfIteratorHelper(object[key]),
  4130. _step2;
  4131. try {
  4132. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  4133. var value = _step2.value;
  4134. if (!contains(compareTo, value)) {
  4135. return false;
  4136. }
  4137. }
  4138. } catch (err) {
  4139. _iterator2.e(err);
  4140. } finally {
  4141. _iterator2.f();
  4142. }
  4143. return true;
  4144. }
  4145. case '$geoWithin':
  4146. {
  4147. if (compareTo.$polygon) {
  4148. var _context4;
  4149. var points = (0, _map.default)(_context4 = compareTo.$polygon).call(_context4, function (geoPoint) {
  4150. return [geoPoint.latitude, geoPoint.longitude];
  4151. });
  4152. var polygon = new ParsePolygon(points);
  4153. return polygon.containsPoint(object[key]);
  4154. }
  4155. if (compareTo.$centerSphere) {
  4156. var _compareTo$$centerSph = (0, _slicedToArray2.default)(compareTo.$centerSphere, 2),
  4157. WGS84Point = _compareTo$$centerSph[0],
  4158. maxDistance = _compareTo$$centerSph[1];
  4159. var centerPoint = new ParseGeoPoint({
  4160. latitude: WGS84Point[1],
  4161. longitude: WGS84Point[0]
  4162. });
  4163. var point = new ParseGeoPoint(object[key]);
  4164. var _distance = point.radiansTo(centerPoint);
  4165. return _distance <= maxDistance;
  4166. }
  4167. break;
  4168. }
  4169. case '$geoIntersects':
  4170. {
  4171. var _polygon = new ParsePolygon(object[key].coordinates);
  4172. var _point = new ParseGeoPoint(compareTo.$point);
  4173. return _polygon.containsPoint(_point);
  4174. }
  4175. default:
  4176. return false;
  4177. }
  4178. }
  4179. return true;
  4180. }
  4181. function validateQuery(query /*: any*/) {
  4182. var _context5;
  4183. var q = query;
  4184. if (query.toJSON) {
  4185. q = query.toJSON().where;
  4186. }
  4187. var specialQuerykeys = ['$and', '$or', '$nor', '_rperm', '_wperm', '_perishable_token', '_email_verify_token', '_email_verify_token_expires_at', '_account_lockout_expires_at', '_failed_login_count'];
  4188. (0, _forEach.default)(_context5 = (0, _keys.default)(q)).call(_context5, function (key) {
  4189. if (q && q[key] && q[key].$regex) {
  4190. if (typeof q[key].$options === 'string') {
  4191. if (!q[key].$options.match(/^[imxs]+$/)) {
  4192. throw new ParseError(ParseError.INVALID_QUERY, "Bad $options value for query: ".concat(q[key].$options));
  4193. }
  4194. }
  4195. }
  4196. if ((0, _indexOf.default)(specialQuerykeys).call(specialQuerykeys, key) < 0 && !key.match(/^[a-zA-Z][a-zA-Z0-9_\.]*$/)) {
  4197. throw new ParseError(ParseError.INVALID_KEY_NAME, "Invalid key name: ".concat(key));
  4198. }
  4199. });
  4200. }
  4201. var OfflineQuery = {
  4202. matchesQuery: matchesQuery,
  4203. validateQuery: validateQuery
  4204. };
  4205. module.exports = OfflineQuery;
  4206. },{"./ParseError":22,"./ParseGeoPoint":24,"./ParsePolygon":29,"./decode":45,"./equals":47,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/slice":70,"@babel/runtime-corejs3/core-js-stable/number/is-integer":77,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/core-js-stable/symbol":95,"@babel/runtime-corejs3/core-js/get-iterator-method":99,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/slicedToArray":139,"@babel/runtime-corejs3/helpers/typeof":144}],18:[function(_dereq_,module,exports){
  4207. (function (process){(function (){
  4208. "use strict";
  4209. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  4210. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  4211. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4212. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  4213. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4214. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  4215. var _decode = _interopRequireDefault(_dereq_("./decode"));
  4216. var _encode = _interopRequireDefault(_dereq_("./encode"));
  4217. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  4218. var _CryptoController = _interopRequireDefault(_dereq_("./CryptoController"));
  4219. var _EventuallyQueue = _interopRequireDefault(_dereq_("./EventuallyQueue"));
  4220. var _InstallationController = _interopRequireDefault(_dereq_("./InstallationController"));
  4221. var ParseOp = _interopRequireWildcard(_dereq_("./ParseOp"));
  4222. var _RESTController = _interopRequireDefault(_dereq_("./RESTController"));
  4223. function _getRequireWildcardCache(nodeInterop) {
  4224. if (typeof _WeakMap !== "function") return null;
  4225. var cacheBabelInterop = new _WeakMap();
  4226. var cacheNodeInterop = new _WeakMap();
  4227. return (_getRequireWildcardCache = function (nodeInterop) {
  4228. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  4229. })(nodeInterop);
  4230. }
  4231. function _interopRequireWildcard(obj, nodeInterop) {
  4232. if (!nodeInterop && obj && obj.__esModule) {
  4233. return obj;
  4234. }
  4235. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  4236. return {
  4237. default: obj
  4238. };
  4239. }
  4240. var cache = _getRequireWildcardCache(nodeInterop);
  4241. if (cache && cache.has(obj)) {
  4242. return cache.get(obj);
  4243. }
  4244. var newObj = {};
  4245. for (var key in obj) {
  4246. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  4247. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  4248. if (desc && (desc.get || desc.set)) {
  4249. _Object$defineProperty(newObj, key, desc);
  4250. } else {
  4251. newObj[key] = obj[key];
  4252. }
  4253. }
  4254. }
  4255. newObj.default = obj;
  4256. if (cache) {
  4257. cache.set(obj, newObj);
  4258. }
  4259. return newObj;
  4260. }
  4261. /**
  4262. * Contains all Parse API classes and functions.
  4263. *
  4264. * @static
  4265. * @global
  4266. * @class
  4267. * @hideconstructor
  4268. */
  4269. var Parse = {
  4270. /**
  4271. * Call this method first to set up your authentication tokens for Parse.
  4272. *
  4273. * @param {string} applicationId Your Parse Application ID.
  4274. * @param {string} [javaScriptKey] Your Parse JavaScript Key (Not needed for parse-server)
  4275. * @param {string} [masterKey] Your Parse Master Key. (Node.js only!)
  4276. * @static
  4277. */
  4278. initialize: function (applicationId /*: string*/, javaScriptKey /*: string*/) {
  4279. if ("browser" === 'browser' && _CoreManager.default.get('IS_NODE') && !process.env.SERVER_RENDERING) {
  4280. /* eslint-disable no-console */
  4281. console.log("It looks like you're using the browser version of the SDK in a " + "node.js environment. You should require('parse/node') instead.");
  4282. /* eslint-enable no-console */
  4283. }
  4284. Parse._initialize(applicationId, javaScriptKey);
  4285. },
  4286. _initialize: function (applicationId /*: string*/, javaScriptKey /*: string*/, masterKey /*: string*/) {
  4287. _CoreManager.default.set('APPLICATION_ID', applicationId);
  4288. _CoreManager.default.set('JAVASCRIPT_KEY', javaScriptKey);
  4289. _CoreManager.default.set('MASTER_KEY', masterKey);
  4290. _CoreManager.default.set('USE_MASTER_KEY', false);
  4291. },
  4292. /**
  4293. * Call this method to set your AsyncStorage engine
  4294. * Starting Parse@1.11, the ParseSDK do not provide a React AsyncStorage as the ReactNative module
  4295. * is not provided at a stable path and changes over versions.
  4296. *
  4297. * @param {AsyncStorage} storage a react native async storage.
  4298. * @static
  4299. */
  4300. setAsyncStorage: function (storage /*: any*/) {
  4301. _CoreManager.default.setAsyncStorage(storage);
  4302. },
  4303. /**
  4304. * Call this method to set your LocalDatastoreStorage engine
  4305. * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()}
  4306. *
  4307. * @param {LocalDatastoreController} controller a data storage.
  4308. * @static
  4309. */
  4310. setLocalDatastoreController: function (controller /*: any*/) {
  4311. _CoreManager.default.setLocalDatastoreController(controller);
  4312. },
  4313. /**
  4314. * Returns information regarding the current server's health
  4315. *
  4316. * @returns {Promise}
  4317. * @static
  4318. */
  4319. getServerHealth: function () {
  4320. return _CoreManager.default.getRESTController().request('GET', 'health');
  4321. },
  4322. /**
  4323. * @member {string} Parse.applicationId
  4324. * @static
  4325. */
  4326. set applicationId(value) {
  4327. _CoreManager.default.set('APPLICATION_ID', value);
  4328. },
  4329. get applicationId() {
  4330. return _CoreManager.default.get('APPLICATION_ID');
  4331. },
  4332. /**
  4333. * @member {string} Parse.javaScriptKey
  4334. * @static
  4335. */
  4336. set javaScriptKey(value) {
  4337. _CoreManager.default.set('JAVASCRIPT_KEY', value);
  4338. },
  4339. get javaScriptKey() {
  4340. return _CoreManager.default.get('JAVASCRIPT_KEY');
  4341. },
  4342. /**
  4343. * @member {string} Parse.masterKey
  4344. * @static
  4345. */
  4346. set masterKey(value) {
  4347. _CoreManager.default.set('MASTER_KEY', value);
  4348. },
  4349. get masterKey() {
  4350. return _CoreManager.default.get('MASTER_KEY');
  4351. },
  4352. /**
  4353. * @member {string} Parse.serverURL
  4354. * @static
  4355. */
  4356. set serverURL(value) {
  4357. _CoreManager.default.set('SERVER_URL', value);
  4358. },
  4359. get serverURL() {
  4360. return _CoreManager.default.get('SERVER_URL');
  4361. },
  4362. /**
  4363. * @member {string} Parse.serverAuthToken
  4364. * @static
  4365. */
  4366. set serverAuthToken(value) {
  4367. _CoreManager.default.set('SERVER_AUTH_TOKEN', value);
  4368. },
  4369. get serverAuthToken() {
  4370. return _CoreManager.default.get('SERVER_AUTH_TOKEN');
  4371. },
  4372. /**
  4373. * @member {string} Parse.serverAuthType
  4374. * @static
  4375. */
  4376. set serverAuthType(value) {
  4377. _CoreManager.default.set('SERVER_AUTH_TYPE', value);
  4378. },
  4379. get serverAuthType() {
  4380. return _CoreManager.default.get('SERVER_AUTH_TYPE');
  4381. },
  4382. /**
  4383. * @member {string} Parse.liveQueryServerURL
  4384. * @static
  4385. */
  4386. set liveQueryServerURL(value) {
  4387. _CoreManager.default.set('LIVEQUERY_SERVER_URL', value);
  4388. },
  4389. get liveQueryServerURL() {
  4390. return _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  4391. },
  4392. /**
  4393. * @member {string} Parse.encryptedUser
  4394. * @static
  4395. */
  4396. set encryptedUser(value) {
  4397. _CoreManager.default.set('ENCRYPTED_USER', value);
  4398. },
  4399. get encryptedUser() {
  4400. return _CoreManager.default.get('ENCRYPTED_USER');
  4401. },
  4402. /**
  4403. * @member {string} Parse.secret
  4404. * @static
  4405. */
  4406. set secret(value) {
  4407. _CoreManager.default.set('ENCRYPTED_KEY', value);
  4408. },
  4409. get secret() {
  4410. return _CoreManager.default.get('ENCRYPTED_KEY');
  4411. },
  4412. /**
  4413. * @member {boolean} Parse.idempotency
  4414. * @static
  4415. */
  4416. set idempotency(value) {
  4417. _CoreManager.default.set('IDEMPOTENCY', value);
  4418. },
  4419. get idempotency() {
  4420. return _CoreManager.default.get('IDEMPOTENCY');
  4421. },
  4422. /**
  4423. * @member {boolean} Parse.allowCustomObjectId
  4424. * @static
  4425. */
  4426. set allowCustomObjectId(value) {
  4427. _CoreManager.default.set('ALLOW_CUSTOM_OBJECT_ID', value);
  4428. },
  4429. get allowCustomObjectId() {
  4430. return _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
  4431. }
  4432. };
  4433. Parse.ACL = _dereq_('./ParseACL').default;
  4434. Parse.Analytics = _dereq_('./Analytics');
  4435. Parse.AnonymousUtils = _dereq_('./AnonymousUtils').default;
  4436. Parse.Cloud = _dereq_('./Cloud');
  4437. Parse.CLP = _dereq_('./ParseCLP').default;
  4438. Parse.CoreManager = _dereq_('./CoreManager');
  4439. Parse.Config = _dereq_('./ParseConfig').default;
  4440. Parse.Error = _dereq_('./ParseError').default;
  4441. Parse.EventuallyQueue = _EventuallyQueue.default;
  4442. Parse.FacebookUtils = _dereq_('./FacebookUtils').default;
  4443. Parse.File = _dereq_('./ParseFile').default;
  4444. Parse.GeoPoint = _dereq_('./ParseGeoPoint').default;
  4445. Parse.Polygon = _dereq_('./ParsePolygon').default;
  4446. Parse.Installation = _dereq_('./ParseInstallation').default;
  4447. Parse.LocalDatastore = _dereq_('./LocalDatastore');
  4448. Parse.Object = _dereq_('./ParseObject').default;
  4449. Parse.Op = {
  4450. Set: ParseOp.SetOp,
  4451. Unset: ParseOp.UnsetOp,
  4452. Increment: ParseOp.IncrementOp,
  4453. Add: ParseOp.AddOp,
  4454. Remove: ParseOp.RemoveOp,
  4455. AddUnique: ParseOp.AddUniqueOp,
  4456. Relation: ParseOp.RelationOp
  4457. };
  4458. Parse.Push = _dereq_('./Push');
  4459. Parse.Query = _dereq_('./ParseQuery').default;
  4460. Parse.Relation = _dereq_('./ParseRelation').default;
  4461. Parse.Role = _dereq_('./ParseRole').default;
  4462. Parse.Schema = _dereq_('./ParseSchema').default;
  4463. Parse.Session = _dereq_('./ParseSession').default;
  4464. Parse.Storage = _dereq_('./Storage');
  4465. Parse.User = _dereq_('./ParseUser').default;
  4466. Parse.LiveQuery = _dereq_('./ParseLiveQuery').default;
  4467. Parse.LiveQueryClient = _dereq_('./LiveQueryClient').default;
  4468. Parse.IndexedDB = _dereq_('./IndexedDBStorageController');
  4469. Parse._request = function () {
  4470. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  4471. args[_key] = arguments[_key];
  4472. }
  4473. return _CoreManager.default.getRESTController().request.apply(null, args);
  4474. };
  4475. Parse._ajax = function () {
  4476. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  4477. args[_key2] = arguments[_key2];
  4478. }
  4479. return _CoreManager.default.getRESTController().ajax.apply(null, args);
  4480. };
  4481. // We attempt to match the signatures of the legacy versions of these methods
  4482. Parse._decode = function (_, value) {
  4483. return (0, _decode.default)(value);
  4484. };
  4485. Parse._encode = function (value, _, disallowObjects) {
  4486. return (0, _encode.default)(value, disallowObjects);
  4487. };
  4488. Parse._getInstallationId = function () {
  4489. return _CoreManager.default.getInstallationController().currentInstallationId();
  4490. };
  4491. /**
  4492. * Enable pinning in your application.
  4493. * This must be called after `Parse.initialize` in your application.
  4494. *
  4495. * @param [polling] Allow pinging the server /health endpoint. Default true
  4496. * @param [ms] Milliseconds to ping the server. Default 2000ms
  4497. * @static
  4498. */
  4499. Parse.enableLocalDatastore = function () {
  4500. var polling = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  4501. var ms /*: number*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
  4502. if (!Parse.applicationId) {
  4503. console.log("'enableLocalDataStore' must be called after 'initialize'");
  4504. return;
  4505. }
  4506. if (!Parse.LocalDatastore.isEnabled) {
  4507. Parse.LocalDatastore.isEnabled = true;
  4508. if (polling) {
  4509. _EventuallyQueue.default.poll(ms);
  4510. }
  4511. }
  4512. };
  4513. /**
  4514. * Flag that indicates whether Local Datastore is enabled.
  4515. *
  4516. * @static
  4517. * @returns {boolean}
  4518. */
  4519. Parse.isLocalDatastoreEnabled = function () {
  4520. return Parse.LocalDatastore.isEnabled;
  4521. };
  4522. /**
  4523. * Gets all contents from Local Datastore
  4524. *
  4525. * <pre>
  4526. * await Parse.dumpLocalDatastore();
  4527. * </pre>
  4528. *
  4529. * @static
  4530. * @returns {object}
  4531. */
  4532. Parse.dumpLocalDatastore = function () {
  4533. if (!Parse.LocalDatastore.isEnabled) {
  4534. console.log('Parse.enableLocalDatastore() must be called first'); // eslint-disable-line no-console
  4535. return _promise.default.resolve({});
  4536. } else {
  4537. return Parse.LocalDatastore._getAllContents();
  4538. }
  4539. };
  4540. /**
  4541. * Enable the current user encryption.
  4542. * This must be called before login any user.
  4543. *
  4544. * @static
  4545. */
  4546. Parse.enableEncryptedUser = function () {
  4547. Parse.encryptedUser = true;
  4548. };
  4549. /**
  4550. * Flag that indicates whether Encrypted User is enabled.
  4551. *
  4552. * @static
  4553. * @returns {boolean}
  4554. */
  4555. Parse.isEncryptedUserEnabled = function () {
  4556. return Parse.encryptedUser;
  4557. };
  4558. _CoreManager.default.setCryptoController(_CryptoController.default);
  4559. _CoreManager.default.setInstallationController(_InstallationController.default);
  4560. _CoreManager.default.setRESTController(_RESTController.default);
  4561. // For legacy requires, of the form `var Parse = require('parse').Parse`
  4562. Parse.Parse = Parse;
  4563. module.exports = Parse;
  4564. }).call(this)}).call(this,_dereq_('_process'))
  4565. },{"./Analytics":1,"./AnonymousUtils":2,"./Cloud":3,"./CoreManager":4,"./CryptoController":5,"./EventuallyQueue":7,"./FacebookUtils":8,"./IndexedDBStorageController":9,"./InstallationController":10,"./LiveQueryClient":11,"./LocalDatastore":13,"./ParseACL":19,"./ParseCLP":20,"./ParseConfig":21,"./ParseError":22,"./ParseFile":23,"./ParseGeoPoint":24,"./ParseInstallation":25,"./ParseLiveQuery":26,"./ParseObject":27,"./ParseOp":28,"./ParsePolygon":29,"./ParseQuery":30,"./ParseRelation":31,"./ParseRole":32,"./ParseSchema":33,"./ParseSession":34,"./ParseUser":35,"./Push":36,"./RESTController":37,"./Storage":39,"./decode":45,"./encode":46,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":84,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/core-js-stable/weak-map":96,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144,"_process":148}],19:[function(_dereq_,module,exports){
  4566. "use strict";
  4567. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4568. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4569. _Object$defineProperty(exports, "__esModule", {
  4570. value: true
  4571. });
  4572. exports.default = void 0;
  4573. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  4574. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  4575. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  4576. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  4577. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  4578. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  4579. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  4580. /**
  4581. * @flow
  4582. */
  4583. /*:: type PermissionsMap = { [permission: string]: boolean };*/
  4584. /*:: type ByIdMap = { [userId: string]: PermissionsMap };*/
  4585. var PUBLIC_KEY = '*';
  4586. /**
  4587. * Creates a new ACL.
  4588. * If no argument is given, the ACL has no permissions for anyone.
  4589. * If the argument is a Parse.User, the ACL will have read and write
  4590. * permission for only that user.
  4591. * If the argument is any other JSON object, that object will be interpretted
  4592. * as a serialized ACL created with toJSON().
  4593. *
  4594. * <p>An ACL, or Access Control List can be added to any
  4595. * <code>Parse.Object</code> to restrict access to only a subset of users
  4596. * of your application.</p>
  4597. *
  4598. * @alias Parse.ACL
  4599. */
  4600. var ParseACL = /*#__PURE__*/function () {
  4601. /**
  4602. * @param {(Parse.User | object)} arg1 The user to initialize the ACL for
  4603. */
  4604. function ParseACL(arg1 /*: ParseUser | ByIdMap*/) {
  4605. (0, _classCallCheck2.default)(this, ParseACL);
  4606. (0, _defineProperty2.default)(this, "permissionsById", void 0);
  4607. this.permissionsById = {};
  4608. if (arg1 && (0, _typeof2.default)(arg1) === 'object') {
  4609. if (arg1 instanceof _ParseUser.default) {
  4610. this.setReadAccess(arg1, true);
  4611. this.setWriteAccess(arg1, true);
  4612. } else {
  4613. for (var _userId in arg1) {
  4614. var accessList = arg1[_userId];
  4615. this.permissionsById[_userId] = {};
  4616. for (var _permission in accessList) {
  4617. var allowed = accessList[_permission];
  4618. if (_permission !== 'read' && _permission !== 'write') {
  4619. throw new TypeError('Tried to create an ACL with an invalid permission type.');
  4620. }
  4621. if (typeof allowed !== 'boolean') {
  4622. throw new TypeError('Tried to create an ACL with an invalid permission value.');
  4623. }
  4624. this.permissionsById[_userId][_permission] = allowed;
  4625. }
  4626. }
  4627. }
  4628. } else if (typeof arg1 === 'function') {
  4629. throw new TypeError('ParseACL constructed with a function. Did you forget ()?');
  4630. }
  4631. }
  4632. /**
  4633. * Returns a JSON-encoded version of the ACL.
  4634. *
  4635. * @returns {object}
  4636. */
  4637. (0, _createClass2.default)(ParseACL, [{
  4638. key: "toJSON",
  4639. value: function () /*: ByIdMap*/{
  4640. var permissions = {};
  4641. for (var p in this.permissionsById) {
  4642. permissions[p] = this.permissionsById[p];
  4643. }
  4644. return permissions;
  4645. }
  4646. /**
  4647. * Returns whether this ACL is equal to another object
  4648. *
  4649. * @param {ParseACL} other The other object's ACL to compare to
  4650. * @returns {boolean}
  4651. */
  4652. }, {
  4653. key: "equals",
  4654. value: function (other /*: ParseACL*/) /*: boolean*/{
  4655. if (!(other instanceof ParseACL)) {
  4656. return false;
  4657. }
  4658. var users = (0, _keys.default)(this.permissionsById);
  4659. var otherUsers = (0, _keys.default)(other.permissionsById);
  4660. if (users.length !== otherUsers.length) {
  4661. return false;
  4662. }
  4663. for (var u in this.permissionsById) {
  4664. if (!other.permissionsById[u]) {
  4665. return false;
  4666. }
  4667. if (this.permissionsById[u].read !== other.permissionsById[u].read) {
  4668. return false;
  4669. }
  4670. if (this.permissionsById[u].write !== other.permissionsById[u].write) {
  4671. return false;
  4672. }
  4673. }
  4674. return true;
  4675. }
  4676. }, {
  4677. key: "_setAccess",
  4678. value: function (accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
  4679. if (userId instanceof _ParseUser.default) {
  4680. userId = userId.id;
  4681. } else if (userId instanceof _ParseRole.default) {
  4682. var name = userId.getName();
  4683. if (!name) {
  4684. throw new TypeError('Role must have a name');
  4685. }
  4686. userId = 'role:' + name;
  4687. }
  4688. if (typeof userId !== 'string') {
  4689. throw new TypeError('userId must be a string.');
  4690. }
  4691. if (typeof allowed !== 'boolean') {
  4692. throw new TypeError('allowed must be either true or false.');
  4693. }
  4694. var permissions = this.permissionsById[userId];
  4695. if (!permissions) {
  4696. if (!allowed) {
  4697. // The user already doesn't have this permission, so no action is needed
  4698. return;
  4699. } else {
  4700. permissions = {};
  4701. this.permissionsById[userId] = permissions;
  4702. }
  4703. }
  4704. if (allowed) {
  4705. this.permissionsById[userId][accessType] = true;
  4706. } else {
  4707. delete permissions[accessType];
  4708. if ((0, _keys.default)(permissions).length === 0) {
  4709. delete this.permissionsById[userId];
  4710. }
  4711. }
  4712. }
  4713. }, {
  4714. key: "_getAccess",
  4715. value: function (accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
  4716. if (userId instanceof _ParseUser.default) {
  4717. userId = userId.id;
  4718. if (!userId) {
  4719. throw new Error('Cannot get access for a ParseUser without an ID');
  4720. }
  4721. } else if (userId instanceof _ParseRole.default) {
  4722. var name = userId.getName();
  4723. if (!name) {
  4724. throw new TypeError('Role must have a name');
  4725. }
  4726. userId = 'role:' + name;
  4727. }
  4728. var permissions = this.permissionsById[userId];
  4729. if (!permissions) {
  4730. return false;
  4731. }
  4732. return !!permissions[accessType];
  4733. }
  4734. /**
  4735. * Sets whether the given user is allowed to read this object.
  4736. *
  4737. * @param userId An instance of Parse.User or its objectId.
  4738. * @param {boolean} allowed Whether that user should have read access.
  4739. */
  4740. }, {
  4741. key: "setReadAccess",
  4742. value: function (userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
  4743. this._setAccess('read', userId, allowed);
  4744. }
  4745. /**
  4746. * Get whether the given user id is *explicitly* allowed to read this object.
  4747. * Even if this returns false, the user may still be able to access it if
  4748. * getPublicReadAccess returns true or a role that the user belongs to has
  4749. * write access.
  4750. *
  4751. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  4752. * @returns {boolean}
  4753. */
  4754. }, {
  4755. key: "getReadAccess",
  4756. value: function (userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
  4757. return this._getAccess('read', userId);
  4758. }
  4759. /**
  4760. * Sets whether the given user id is allowed to write this object.
  4761. *
  4762. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  4763. * @param {boolean} allowed Whether that user should have write access.
  4764. */
  4765. }, {
  4766. key: "setWriteAccess",
  4767. value: function (userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
  4768. this._setAccess('write', userId, allowed);
  4769. }
  4770. /**
  4771. * Gets whether the given user id is *explicitly* allowed to write this object.
  4772. * Even if this returns false, the user may still be able to write it if
  4773. * getPublicWriteAccess returns true or a role that the user belongs to has
  4774. * write access.
  4775. *
  4776. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  4777. * @returns {boolean}
  4778. */
  4779. }, {
  4780. key: "getWriteAccess",
  4781. value: function (userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
  4782. return this._getAccess('write', userId);
  4783. }
  4784. /**
  4785. * Sets whether the public is allowed to read this object.
  4786. *
  4787. * @param {boolean} allowed
  4788. */
  4789. }, {
  4790. key: "setPublicReadAccess",
  4791. value: function (allowed /*: boolean*/) {
  4792. this.setReadAccess(PUBLIC_KEY, allowed);
  4793. }
  4794. /**
  4795. * Gets whether the public is allowed to read this object.
  4796. *
  4797. * @returns {boolean}
  4798. */
  4799. }, {
  4800. key: "getPublicReadAccess",
  4801. value: function () /*: boolean*/{
  4802. return this.getReadAccess(PUBLIC_KEY);
  4803. }
  4804. /**
  4805. * Sets whether the public is allowed to write this object.
  4806. *
  4807. * @param {boolean} allowed
  4808. */
  4809. }, {
  4810. key: "setPublicWriteAccess",
  4811. value: function (allowed /*: boolean*/) {
  4812. this.setWriteAccess(PUBLIC_KEY, allowed);
  4813. }
  4814. /**
  4815. * Gets whether the public is allowed to write this object.
  4816. *
  4817. * @returns {boolean}
  4818. */
  4819. }, {
  4820. key: "getPublicWriteAccess",
  4821. value: function () /*: boolean*/{
  4822. return this.getWriteAccess(PUBLIC_KEY);
  4823. }
  4824. /**
  4825. * Gets whether users belonging to the given role are allowed
  4826. * to read this object. Even if this returns false, the role may
  4827. * still be able to write it if a parent role has read access.
  4828. *
  4829. * @param role The name of the role, or a Parse.Role object.
  4830. * @returns {boolean} true if the role has read access. false otherwise.
  4831. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4832. */
  4833. }, {
  4834. key: "getRoleReadAccess",
  4835. value: function (role /*: ParseRole | string*/) /*: boolean*/{
  4836. if (role instanceof _ParseRole.default) {
  4837. // Normalize to the String name
  4838. role = role.getName();
  4839. }
  4840. if (typeof role !== 'string') {
  4841. throw new TypeError('role must be a ParseRole or a String');
  4842. }
  4843. return this.getReadAccess('role:' + role);
  4844. }
  4845. /**
  4846. * Gets whether users belonging to the given role are allowed
  4847. * to write this object. Even if this returns false, the role may
  4848. * still be able to write it if a parent role has write access.
  4849. *
  4850. * @param role The name of the role, or a Parse.Role object.
  4851. * @returns {boolean} true if the role has write access. false otherwise.
  4852. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4853. */
  4854. }, {
  4855. key: "getRoleWriteAccess",
  4856. value: function (role /*: ParseRole | string*/) /*: boolean*/{
  4857. if (role instanceof _ParseRole.default) {
  4858. // Normalize to the String name
  4859. role = role.getName();
  4860. }
  4861. if (typeof role !== 'string') {
  4862. throw new TypeError('role must be a ParseRole or a String');
  4863. }
  4864. return this.getWriteAccess('role:' + role);
  4865. }
  4866. /**
  4867. * Sets whether users belonging to the given role are allowed
  4868. * to read this object.
  4869. *
  4870. * @param role The name of the role, or a Parse.Role object.
  4871. * @param {boolean} allowed Whether the given role can read this object.
  4872. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4873. */
  4874. }, {
  4875. key: "setRoleReadAccess",
  4876. value: function (role /*: ParseRole | string*/, allowed /*: boolean*/) {
  4877. if (role instanceof _ParseRole.default) {
  4878. // Normalize to the String name
  4879. role = role.getName();
  4880. }
  4881. if (typeof role !== 'string') {
  4882. throw new TypeError('role must be a ParseRole or a String');
  4883. }
  4884. this.setReadAccess('role:' + role, allowed);
  4885. }
  4886. /**
  4887. * Sets whether users belonging to the given role are allowed
  4888. * to write this object.
  4889. *
  4890. * @param role The name of the role, or a Parse.Role object.
  4891. * @param {boolean} allowed Whether the given role can write this object.
  4892. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4893. */
  4894. }, {
  4895. key: "setRoleWriteAccess",
  4896. value: function (role /*: ParseRole | string*/, allowed /*: boolean*/) {
  4897. if (role instanceof _ParseRole.default) {
  4898. // Normalize to the String name
  4899. role = role.getName();
  4900. }
  4901. if (typeof role !== 'string') {
  4902. throw new TypeError('role must be a ParseRole or a String');
  4903. }
  4904. this.setWriteAccess('role:' + role, allowed);
  4905. }
  4906. }]);
  4907. return ParseACL;
  4908. }();
  4909. var _default = ParseACL;
  4910. exports.default = _default;
  4911. },{"./ParseRole":32,"./ParseUser":35,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],20:[function(_dereq_,module,exports){
  4912. "use strict";
  4913. var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  4914. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  4915. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  4916. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  4917. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  4918. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  4919. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  4920. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  4921. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  4922. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  4923. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  4924. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  4925. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4926. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4927. _Object$defineProperty(exports, "__esModule", {
  4928. value: true
  4929. });
  4930. exports.default = void 0;
  4931. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  4932. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  4933. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  4934. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  4935. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  4936. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
  4937. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  4938. var _every = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/every"));
  4939. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/entries"));
  4940. var _assign = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/assign"));
  4941. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  4942. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  4943. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  4944. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  4945. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  4946. function ownKeys(object, enumerableOnly) {
  4947. var keys = _Object$keys2(object);
  4948. if (_Object$getOwnPropertySymbols) {
  4949. var symbols = _Object$getOwnPropertySymbols(object);
  4950. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  4951. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  4952. })), keys.push.apply(keys, symbols);
  4953. }
  4954. return keys;
  4955. }
  4956. function _objectSpread(target) {
  4957. for (var i = 1; i < arguments.length; i++) {
  4958. var _context3, _context4;
  4959. var source = null != arguments[i] ? arguments[i] : {};
  4960. i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) {
  4961. (0, _defineProperty2.default)(target, key, source[key]);
  4962. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) {
  4963. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  4964. });
  4965. }
  4966. return target;
  4967. }
  4968. function _createForOfIteratorHelper(o, allowArrayLike) {
  4969. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  4970. if (!it) {
  4971. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  4972. if (it) o = it;
  4973. var i = 0;
  4974. var F = function () {};
  4975. return {
  4976. s: F,
  4977. n: function () {
  4978. if (i >= o.length) return {
  4979. done: true
  4980. };
  4981. return {
  4982. done: false,
  4983. value: o[i++]
  4984. };
  4985. },
  4986. e: function (_e) {
  4987. throw _e;
  4988. },
  4989. f: F
  4990. };
  4991. }
  4992. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  4993. }
  4994. var normalCompletion = true,
  4995. didErr = false,
  4996. err;
  4997. return {
  4998. s: function () {
  4999. it = it.call(o);
  5000. },
  5001. n: function () {
  5002. var step = it.next();
  5003. normalCompletion = step.done;
  5004. return step;
  5005. },
  5006. e: function (_e2) {
  5007. didErr = true;
  5008. err = _e2;
  5009. },
  5010. f: function () {
  5011. try {
  5012. if (!normalCompletion && it.return != null) it.return();
  5013. } finally {
  5014. if (didErr) throw err;
  5015. }
  5016. }
  5017. };
  5018. }
  5019. function _unsupportedIterableToArray(o, minLen) {
  5020. var _context2;
  5021. if (!o) return;
  5022. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  5023. var n = _sliceInstanceProperty2(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1);
  5024. if (n === "Object" && o.constructor) n = o.constructor.name;
  5025. if (n === "Map" || n === "Set") return _Array$from(o);
  5026. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  5027. }
  5028. function _arrayLikeToArray(arr, len) {
  5029. if (len == null || len > arr.length) len = arr.length;
  5030. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  5031. return arr2;
  5032. } /**
  5033. * @flow
  5034. */
  5035. /*:: type Entity = Entity;*/
  5036. /*:: type UsersMap = { [userId: string]: boolean | any };*/
  5037. /*:: export type PermissionsMap = { [permission: string]: UsersMap };*/
  5038. var PUBLIC_KEY = '*';
  5039. var VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new _map.default(
  5040. /*:: <string, UsersMap>*/
  5041. );
  5042. VALID_PERMISSIONS.set('get', {});
  5043. VALID_PERMISSIONS.set('find', {});
  5044. VALID_PERMISSIONS.set('count', {});
  5045. VALID_PERMISSIONS.set('create', {});
  5046. VALID_PERMISSIONS.set('update', {});
  5047. VALID_PERMISSIONS.set('delete', {});
  5048. VALID_PERMISSIONS.set('addField', {});
  5049. var VALID_PERMISSIONS_EXTENDED /*: Map<string, UsersMap>*/ = new _map.default(
  5050. /*:: <string, UsersMap>*/
  5051. );
  5052. VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
  5053. /**
  5054. * Creates a new CLP.
  5055. * If no argument is given, the CLP has no permissions for anyone.
  5056. * If the argument is a Parse.User or Parse.Role, the CLP will have read and write
  5057. * permission for only that user or role.
  5058. * If the argument is any other JSON object, that object will be interpretted
  5059. * as a serialized CLP created with toJSON().
  5060. *
  5061. * <p>A CLP, or Class Level Permissions can be added to any
  5062. * <code>Parse.Schema</code> to restrict access to only a subset of users
  5063. * of your application.</p>
  5064. *
  5065. * <p>
  5066. * For get/count/find/create/update/delete/addField using the following functions:
  5067. *
  5068. * Entity is type Parse.User or Parse.Role or string
  5069. * Role is type Parse.Role or Name of Parse.Role
  5070. *
  5071. * getGetRequiresAuthentication()
  5072. * setGetRequiresAuthentication(allowed: boolean)
  5073. * getGetPointerFields()
  5074. * setGetPointerFields(pointerFields: string[])
  5075. * getGetAccess(entity: Entity)
  5076. * setGetAccess(entity: Entity, allowed: boolean)
  5077. * getPublicGetAccess()
  5078. * setPublicGetAccess(allowed: boolean)
  5079. * getRoleGetAccess(role: Role)
  5080. * setRoleGetAccess(role: Role, allowed: boolean)
  5081. * getFindRequiresAuthentication()
  5082. * setFindRequiresAuthentication(allowed: boolean)
  5083. * getFindPointerFields()
  5084. * setFindPointerFields(pointerFields: string[])
  5085. * getFindAccess(entity: Entity)
  5086. * setFindAccess(entity: Entity, allowed: boolean)
  5087. * getPublicFindAccess()
  5088. * setPublicFindAccess(allowed: boolean)
  5089. * getRoleFindAccess(role: Role)
  5090. * setRoleFindAccess(role: Role, allowed: boolean)
  5091. * getCountRequiresAuthentication()
  5092. * setCountRequiresAuthentication(allowed: boolean)
  5093. * getCountPointerFields()
  5094. * setCountPointerFields(pointerFields: string[])
  5095. * getCountAccess(entity: Entity)
  5096. * setCountAccess(entity: Entity, allowed: boolean)
  5097. * getPublicCountAccess()
  5098. * setPublicCountAccess(allowed: boolean)
  5099. * getRoleCountAccess(role: Role)
  5100. * setRoleCountAccess(role: Role, allowed: boolean)
  5101. * getCreateRequiresAuthentication()
  5102. * setCreateRequiresAuthentication(allowed: boolean)
  5103. * getCreatePointerFields()
  5104. * setCreatePointerFields(pointerFields: string[])
  5105. * getCreateAccess(entity: Entity)
  5106. * setCreateAccess(entity: Entity, allowed: boolean)
  5107. * getPublicCreateAccess()
  5108. * setPublicCreateAccess(allowed: Boolean)
  5109. * getRoleCreateAccess(role: Role)
  5110. * setRoleCreateAccess(role: Role, allowed: boolean)
  5111. * getUpdateRequiresAuthentication()
  5112. * setUpdateRequiresAuthentication(allowed: boolean)
  5113. * getUpdatePointerFields()
  5114. * setUpdatePointerFields(pointerFields: string[])
  5115. * getUpdateAccess(entity: Entity)
  5116. * setUpdateAccess(entity: Entity, allowed: boolean)
  5117. * getPublicUpdateAccess()
  5118. * setPublicUpdateAccess(allowed: boolean)
  5119. * getRoleUpdateAccess(role: Role)
  5120. * setRoleUpdateAccess(role: Role, allowed: boolean)
  5121. * getDeleteRequiresAuthentication()
  5122. * setDeleteRequiresAuthentication(allowed: boolean)
  5123. * getDeletePointerFields()
  5124. * setDeletePointerFields(pointerFields: string[])
  5125. * getDeleteAccess(entity: Entity)
  5126. * setDeleteAccess(entity: Entity, allowed: boolean)
  5127. * getPublicDeleteAccess()
  5128. * setPublicDeleteAccess(allowed: boolean)
  5129. * getRoleDeleteAccess(role: Role)
  5130. * setRoleDeleteAccess(role: Role, allowed: boolean)
  5131. * getAddFieldRequiresAuthentication()
  5132. * setAddFieldRequiresAuthentication(allowed: boolean)
  5133. * getAddFieldPointerFields()
  5134. * setAddFieldPointerFields(pointerFields: string[])
  5135. * getAddFieldAccess(entity: Entity)
  5136. * setAddFieldAccess(entity: Entity, allowed: boolean)
  5137. * getPublicAddFieldAccess()
  5138. * setPublicAddFieldAccess(allowed: boolean)
  5139. * getRoleAddFieldAccess(role: Role)
  5140. * setRoleAddFieldAccess(role: Role, allowed: boolean)
  5141. * </p>
  5142. *
  5143. * @alias Parse.CLP
  5144. */
  5145. var ParseCLP = /*#__PURE__*/function () {
  5146. /**
  5147. * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
  5148. */
  5149. function ParseCLP(userId /*: ParseUser | ParseRole | PermissionsMap*/) {
  5150. var _this = this;
  5151. (0, _classCallCheck2.default)(this, ParseCLP);
  5152. (0, _defineProperty2.default)(this, "permissionsMap", void 0);
  5153. this.permissionsMap = {};
  5154. // Initialize permissions Map with default permissions
  5155. var _iterator = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS).call(VALID_PERMISSIONS)),
  5156. _step;
  5157. try {
  5158. var _loop = function _loop() {
  5159. var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
  5160. operation = _step$value[0],
  5161. group = _step$value[1];
  5162. _this.permissionsMap[operation] = (0, _assign.default)({}, group);
  5163. var action = operation.charAt(0).toUpperCase() + (0, _slice.default)(operation).call(operation, 1);
  5164. _this["get".concat(action, "RequiresAuthentication")] = function () {
  5165. return this._getAccess(operation, 'requiresAuthentication');
  5166. };
  5167. _this["set".concat(action, "RequiresAuthentication")] = function (allowed) {
  5168. this._setAccess(operation, 'requiresAuthentication', allowed);
  5169. };
  5170. _this["get".concat(action, "PointerFields")] = function () {
  5171. return this._getAccess(operation, 'pointerFields', false);
  5172. };
  5173. _this["set".concat(action, "PointerFields")] = function (pointerFields) {
  5174. this._setArrayAccess(operation, 'pointerFields', pointerFields);
  5175. };
  5176. _this["get".concat(action, "Access")] = function (entity) {
  5177. return this._getAccess(operation, entity);
  5178. };
  5179. _this["set".concat(action, "Access")] = function (entity, allowed) {
  5180. this._setAccess(operation, entity, allowed);
  5181. };
  5182. _this["getPublic".concat(action, "Access")] = function () {
  5183. return this["get".concat(action, "Access")](PUBLIC_KEY);
  5184. };
  5185. _this["setPublic".concat(action, "Access")] = function (allowed) {
  5186. this["set".concat(action, "Access")](PUBLIC_KEY, allowed);
  5187. };
  5188. _this["getRole".concat(action, "Access")] = function (role) {
  5189. return this["get".concat(action, "Access")](this._getRoleName(role));
  5190. };
  5191. _this["setRole".concat(action, "Access")] = function (role, allowed) {
  5192. this["set".concat(action, "Access")](this._getRoleName(role), allowed);
  5193. };
  5194. };
  5195. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5196. _loop();
  5197. }
  5198. // Initialize permissions Map with default extended permissions
  5199. } catch (err) {
  5200. _iterator.e(err);
  5201. } finally {
  5202. _iterator.f();
  5203. }
  5204. var _iterator2 = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS_EXTENDED).call(VALID_PERMISSIONS_EXTENDED)),
  5205. _step2;
  5206. try {
  5207. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  5208. var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
  5209. operation = _step2$value[0],
  5210. group = _step2$value[1];
  5211. this.permissionsMap[operation] = (0, _assign.default)({}, group);
  5212. }
  5213. } catch (err) {
  5214. _iterator2.e(err);
  5215. } finally {
  5216. _iterator2.f();
  5217. }
  5218. if (userId && (0, _typeof2.default)(userId) === 'object') {
  5219. if (userId instanceof _ParseUser.default) {
  5220. this.setReadAccess(userId, true);
  5221. this.setWriteAccess(userId, true);
  5222. } else if (userId instanceof _ParseRole.default) {
  5223. this.setRoleReadAccess(userId, true);
  5224. this.setRoleWriteAccess(userId, true);
  5225. } else {
  5226. for (var _permission in userId) {
  5227. var _context;
  5228. var users = userId[_permission];
  5229. var isValidPermission = !!VALID_PERMISSIONS.get(_permission);
  5230. var isValidPermissionExtended = !!VALID_PERMISSIONS_EXTENDED.get(_permission);
  5231. var isValidGroupPermission = (0, _includes.default)(_context = ['readUserFields', 'writeUserFields']).call(_context, _permission);
  5232. if (typeof _permission !== 'string' || !(isValidPermission || isValidPermissionExtended || isValidGroupPermission)) {
  5233. throw new TypeError('Tried to create an CLP with an invalid permission type.');
  5234. }
  5235. if (isValidGroupPermission) {
  5236. if ((0, _every.default)(users).call(users, function (pointer) {
  5237. return typeof pointer === 'string';
  5238. })) {
  5239. this.permissionsMap[_permission] = users;
  5240. continue;
  5241. } else {
  5242. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  5243. }
  5244. }
  5245. for (var user in users) {
  5246. var allowed = users[user];
  5247. if (typeof allowed !== 'boolean' && !isValidPermissionExtended && user !== 'pointerFields') {
  5248. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  5249. }
  5250. this.permissionsMap[_permission][user] = allowed;
  5251. }
  5252. }
  5253. }
  5254. } else if (typeof userId === 'function') {
  5255. throw new TypeError('ParseCLP constructed with a function. Did you forget ()?');
  5256. }
  5257. }
  5258. /**
  5259. * Returns a JSON-encoded version of the CLP.
  5260. *
  5261. * @returns {object}
  5262. */
  5263. (0, _createClass2.default)(ParseCLP, [{
  5264. key: "toJSON",
  5265. value: function toJSON() /*: PermissionsMap*/{
  5266. return _objectSpread({}, this.permissionsMap);
  5267. }
  5268. /**
  5269. * Returns whether this CLP is equal to another object
  5270. *
  5271. * @param other The other object to compare to
  5272. * @returns {boolean}
  5273. */
  5274. }, {
  5275. key: "equals",
  5276. value: function equals(other /*: ParseCLP*/) /*: boolean*/{
  5277. if (!(other instanceof ParseCLP)) {
  5278. return false;
  5279. }
  5280. var permissions = (0, _keys.default)(this.permissionsMap);
  5281. var otherPermissions = (0, _keys.default)(other.permissionsMap);
  5282. if (permissions.length !== otherPermissions.length) {
  5283. return false;
  5284. }
  5285. for (var _permission2 in this.permissionsMap) {
  5286. if (!other.permissionsMap[_permission2]) {
  5287. return false;
  5288. }
  5289. var users = (0, _keys.default)(this.permissionsMap[_permission2]);
  5290. var otherUsers = (0, _keys.default)(other.permissionsMap[_permission2]);
  5291. if (users.length !== otherUsers.length) {
  5292. return false;
  5293. }
  5294. for (var user in this.permissionsMap[_permission2]) {
  5295. if (!other.permissionsMap[_permission2][user]) {
  5296. return false;
  5297. }
  5298. if (this.permissionsMap[_permission2][user] !== other.permissionsMap[_permission2][user]) {
  5299. return false;
  5300. }
  5301. }
  5302. }
  5303. return true;
  5304. }
  5305. }, {
  5306. key: "_getRoleName",
  5307. value: function _getRoleName(role /*: ParseRole | string*/) /*: string*/{
  5308. var name = role;
  5309. if (role instanceof _ParseRole.default) {
  5310. // Normalize to the String name
  5311. name = role.getName();
  5312. }
  5313. if (typeof name !== 'string') {
  5314. throw new TypeError('role must be a Parse.Role or a String');
  5315. }
  5316. return "role:".concat(name);
  5317. }
  5318. }, {
  5319. key: "_parseEntity",
  5320. value: function _parseEntity(entity /*: Entity*/) {
  5321. var userId = entity;
  5322. if (userId instanceof _ParseUser.default) {
  5323. userId = userId.id;
  5324. if (!userId) {
  5325. throw new Error('Cannot get access for a Parse.User without an id.');
  5326. }
  5327. } else if (userId instanceof _ParseRole.default) {
  5328. userId = this._getRoleName(userId);
  5329. }
  5330. if (typeof userId !== 'string') {
  5331. throw new TypeError('userId must be a string.');
  5332. }
  5333. return userId;
  5334. }
  5335. }, {
  5336. key: "_setAccess",
  5337. value: function _setAccess(permission /*: string*/, userId /*: Entity*/, allowed /*: boolean*/) {
  5338. userId = this._parseEntity(userId);
  5339. if (typeof allowed !== 'boolean') {
  5340. throw new TypeError('allowed must be either true or false.');
  5341. }
  5342. var permissions = this.permissionsMap[permission][userId];
  5343. if (!permissions) {
  5344. if (!allowed) {
  5345. // The user already doesn't have this permission, so no action is needed
  5346. return;
  5347. } else {
  5348. this.permissionsMap[permission][userId] = {};
  5349. }
  5350. }
  5351. if (allowed) {
  5352. this.permissionsMap[permission][userId] = true;
  5353. } else {
  5354. delete this.permissionsMap[permission][userId];
  5355. }
  5356. }
  5357. }, {
  5358. key: "_getAccess",
  5359. value: function _getAccess(permission /*: string*/, userId /*: Entity*/) /*: boolean | string[]*/{
  5360. var returnBoolean = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  5361. userId = this._parseEntity(userId);
  5362. var permissions = this.permissionsMap[permission][userId];
  5363. if (returnBoolean) {
  5364. if (!permissions) {
  5365. return false;
  5366. }
  5367. return !!this.permissionsMap[permission][userId];
  5368. }
  5369. return permissions;
  5370. }
  5371. }, {
  5372. key: "_setArrayAccess",
  5373. value: function _setArrayAccess(permission /*: string*/, userId /*: Entity*/, fields /*: string*/) {
  5374. userId = this._parseEntity(userId);
  5375. var permissions = this.permissionsMap[permission][userId];
  5376. if (!permissions) {
  5377. this.permissionsMap[permission][userId] = [];
  5378. }
  5379. if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
  5380. delete this.permissionsMap[permission][userId];
  5381. } else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, function (field) {
  5382. return typeof field === 'string';
  5383. })) {
  5384. this.permissionsMap[permission][userId] = fields;
  5385. } else {
  5386. throw new TypeError('fields must be an array of strings or undefined.');
  5387. }
  5388. }
  5389. }, {
  5390. key: "_setGroupPointerPermission",
  5391. value: function _setGroupPointerPermission(operation /*: string*/, pointerFields /*: string[]*/) {
  5392. var fields = this.permissionsMap[operation];
  5393. if (!fields) {
  5394. this.permissionsMap[operation] = [];
  5395. }
  5396. if (!pointerFields || (0, _isArray.default)(pointerFields) && pointerFields.length === 0) {
  5397. delete this.permissionsMap[operation];
  5398. } else if ((0, _isArray.default)(pointerFields) && (0, _every.default)(pointerFields).call(pointerFields, function (field) {
  5399. return typeof field === 'string';
  5400. })) {
  5401. this.permissionsMap[operation] = pointerFields;
  5402. } else {
  5403. throw new TypeError("".concat(operation, ".pointerFields must be an array of strings or undefined."));
  5404. }
  5405. }
  5406. }, {
  5407. key: "_getGroupPointerPermissions",
  5408. value: function _getGroupPointerPermissions(operation /*: string*/) /*: string[]*/{
  5409. return this.permissionsMap[operation];
  5410. }
  5411. /**
  5412. * Sets user pointer fields to allow permission for get/count/find operations.
  5413. *
  5414. * @param {string[]} pointerFields User pointer fields
  5415. */
  5416. }, {
  5417. key: "setReadUserFields",
  5418. value: function setReadUserFields(pointerFields /*: string[]*/) {
  5419. this._setGroupPointerPermission('readUserFields', pointerFields);
  5420. }
  5421. /**
  5422. * @returns {string[]} User pointer fields
  5423. */
  5424. }, {
  5425. key: "getReadUserFields",
  5426. value: function getReadUserFields() /*: string[]*/{
  5427. return this._getGroupPointerPermissions('readUserFields');
  5428. }
  5429. /**
  5430. * Sets user pointer fields to allow permission for create/delete/update/addField operations
  5431. *
  5432. * @param {string[]} pointerFields User pointer fields
  5433. */
  5434. }, {
  5435. key: "setWriteUserFields",
  5436. value: function setWriteUserFields(pointerFields /*: string[]*/) {
  5437. this._setGroupPointerPermission('writeUserFields', pointerFields);
  5438. }
  5439. /**
  5440. * @returns {string[]} User pointer fields
  5441. */
  5442. }, {
  5443. key: "getWriteUserFields",
  5444. value: function getWriteUserFields() /*: string[]*/{
  5445. return this._getGroupPointerPermissions('writeUserFields');
  5446. }
  5447. /**
  5448. * Sets whether the given user is allowed to retrieve fields from this class.
  5449. *
  5450. * @param userId An instance of Parse.User or its objectId.
  5451. * @param {string[]} fields fields to be protected
  5452. */
  5453. }, {
  5454. key: "setProtectedFields",
  5455. value: function setProtectedFields(userId /*: Entity*/, fields /*: string[]*/) {
  5456. this._setArrayAccess('protectedFields', userId, fields);
  5457. }
  5458. /**
  5459. * Returns array of fields are accessable to this user.
  5460. *
  5461. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  5462. * @returns {string[]}
  5463. */
  5464. }, {
  5465. key: "getProtectedFields",
  5466. value: function getProtectedFields(userId /*: Entity*/) /*: string[]*/{
  5467. return this._getAccess('protectedFields', userId, false);
  5468. }
  5469. /**
  5470. * Sets whether the given user is allowed to read from this class.
  5471. *
  5472. * @param userId An instance of Parse.User or its objectId.
  5473. * @param {boolean} allowed whether that user should have read access.
  5474. */
  5475. }, {
  5476. key: "setReadAccess",
  5477. value: function setReadAccess(userId /*: Entity*/, allowed /*: boolean*/) {
  5478. this._setAccess('find', userId, allowed);
  5479. this._setAccess('get', userId, allowed);
  5480. this._setAccess('count', userId, allowed);
  5481. }
  5482. /**
  5483. * Get whether the given user id is *explicitly* allowed to read from this class.
  5484. * Even if this returns false, the user may still be able to access it if
  5485. * getPublicReadAccess returns true or a role that the user belongs to has
  5486. * write access.
  5487. *
  5488. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  5489. * @returns {boolean}
  5490. */
  5491. }, {
  5492. key: "getReadAccess",
  5493. value: function getReadAccess(userId /*: Entity*/) /*: boolean*/{
  5494. return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
  5495. }
  5496. /**
  5497. * Sets whether the given user id is allowed to write to this class.
  5498. *
  5499. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  5500. * @param {boolean} allowed Whether that user should have write access.
  5501. */
  5502. }, {
  5503. key: "setWriteAccess",
  5504. value: function setWriteAccess(userId /*: Entity*/, allowed /*: boolean*/) {
  5505. this._setAccess('create', userId, allowed);
  5506. this._setAccess('update', userId, allowed);
  5507. this._setAccess('delete', userId, allowed);
  5508. this._setAccess('addField', userId, allowed);
  5509. }
  5510. /**
  5511. * Gets whether the given user id is *explicitly* allowed to write to this class.
  5512. * Even if this returns false, the user may still be able to write it if
  5513. * getPublicWriteAccess returns true or a role that the user belongs to has
  5514. * write access.
  5515. *
  5516. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  5517. * @returns {boolean}
  5518. */
  5519. }, {
  5520. key: "getWriteAccess",
  5521. value: function getWriteAccess(userId /*: Entity*/) /*: boolean*/{
  5522. return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
  5523. }
  5524. /**
  5525. * Sets whether the public is allowed to read from this class.
  5526. *
  5527. * @param {boolean} allowed
  5528. */
  5529. }, {
  5530. key: "setPublicReadAccess",
  5531. value: function setPublicReadAccess(allowed /*: boolean*/) {
  5532. this.setReadAccess(PUBLIC_KEY, allowed);
  5533. }
  5534. /**
  5535. * Gets whether the public is allowed to read from this class.
  5536. *
  5537. * @returns {boolean}
  5538. */
  5539. }, {
  5540. key: "getPublicReadAccess",
  5541. value: function getPublicReadAccess() /*: boolean*/{
  5542. return this.getReadAccess(PUBLIC_KEY);
  5543. }
  5544. /**
  5545. * Sets whether the public is allowed to write to this class.
  5546. *
  5547. * @param {boolean} allowed
  5548. */
  5549. }, {
  5550. key: "setPublicWriteAccess",
  5551. value: function setPublicWriteAccess(allowed /*: boolean*/) {
  5552. this.setWriteAccess(PUBLIC_KEY, allowed);
  5553. }
  5554. /**
  5555. * Gets whether the public is allowed to write to this class.
  5556. *
  5557. * @returns {boolean}
  5558. */
  5559. }, {
  5560. key: "getPublicWriteAccess",
  5561. value: function getPublicWriteAccess() /*: boolean*/{
  5562. return this.getWriteAccess(PUBLIC_KEY);
  5563. }
  5564. /**
  5565. * Sets whether the public is allowed to protect fields in this class.
  5566. *
  5567. * @param {string[]} fields
  5568. */
  5569. }, {
  5570. key: "setPublicProtectedFields",
  5571. value: function setPublicProtectedFields(fields /*: string[]*/) {
  5572. this.setProtectedFields(PUBLIC_KEY, fields);
  5573. }
  5574. /**
  5575. * Gets whether the public is allowed to read fields from this class.
  5576. *
  5577. * @returns {string[]}
  5578. */
  5579. }, {
  5580. key: "getPublicProtectedFields",
  5581. value: function getPublicProtectedFields() /*: string[]*/{
  5582. return this.getProtectedFields(PUBLIC_KEY);
  5583. }
  5584. /**
  5585. * Gets whether users belonging to the given role are allowed
  5586. * to read from this class. Even if this returns false, the role may
  5587. * still be able to write it if a parent role has read access.
  5588. *
  5589. * @param role The name of the role, or a Parse.Role object.
  5590. * @returns {boolean} true if the role has read access. false otherwise.
  5591. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5592. */
  5593. }, {
  5594. key: "getRoleReadAccess",
  5595. value: function getRoleReadAccess(role /*: ParseRole | string*/) /*: boolean*/{
  5596. return this.getReadAccess(this._getRoleName(role));
  5597. }
  5598. /**
  5599. * Gets whether users belonging to the given role are allowed
  5600. * to write to this user. Even if this returns false, the role may
  5601. * still be able to write it if a parent role has write access.
  5602. *
  5603. * @param role The name of the role, or a Parse.Role object.
  5604. * @returns {boolean} true if the role has write access. false otherwise.
  5605. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5606. */
  5607. }, {
  5608. key: "getRoleWriteAccess",
  5609. value: function getRoleWriteAccess(role /*: ParseRole | string*/) /*: boolean*/{
  5610. return this.getWriteAccess(this._getRoleName(role));
  5611. }
  5612. /**
  5613. * Sets whether users belonging to the given role are allowed
  5614. * to read from this class.
  5615. *
  5616. * @param role The name of the role, or a Parse.Role object.
  5617. * @param {boolean} allowed Whether the given role can read this object.
  5618. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5619. */
  5620. }, {
  5621. key: "setRoleReadAccess",
  5622. value: function setRoleReadAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
  5623. this.setReadAccess(this._getRoleName(role), allowed);
  5624. }
  5625. /**
  5626. * Sets whether users belonging to the given role are allowed
  5627. * to write to this class.
  5628. *
  5629. * @param role The name of the role, or a Parse.Role object.
  5630. * @param {boolean} allowed Whether the given role can write this object.
  5631. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5632. */
  5633. }, {
  5634. key: "setRoleWriteAccess",
  5635. value: function setRoleWriteAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
  5636. this.setWriteAccess(this._getRoleName(role), allowed);
  5637. }
  5638. /**
  5639. * Gets whether users belonging to the given role are allowed
  5640. * to count to this user. Even if this returns false, the role may
  5641. * still be able to count it if a parent role has count access.
  5642. *
  5643. * @param role The name of the role, or a Parse.Role object.
  5644. * @returns {string[]}
  5645. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5646. */
  5647. }, {
  5648. key: "getRoleProtectedFields",
  5649. value: function getRoleProtectedFields(role /*: ParseRole | string*/) /*: string[]*/{
  5650. return this.getProtectedFields(this._getRoleName(role));
  5651. }
  5652. /**
  5653. * Sets whether users belonging to the given role are allowed
  5654. * to set access field in this class.
  5655. *
  5656. * @param role The name of the role, or a Parse.Role object.
  5657. * @param {string[]} fields Fields to be protected by Role.
  5658. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5659. */
  5660. }, {
  5661. key: "setRoleProtectedFields",
  5662. value: function setRoleProtectedFields(role /*: ParseRole | string*/, fields /*: string[]*/) {
  5663. this.setProtectedFields(this._getRoleName(role), fields);
  5664. }
  5665. }]);
  5666. return ParseCLP;
  5667. }();
  5668. var _default = ParseCLP;
  5669. exports.default = _default;
  5670. },{"./ParseRole":32,"./ParseUser":35,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/entries":59,"@babel/runtime-corejs3/core-js-stable/instance/every":60,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/instance/slice":70,"@babel/runtime-corejs3/core-js-stable/map":76,"@babel/runtime-corejs3/core-js-stable/object/assign":78,"@babel/runtime-corejs3/core-js-stable/object/define-properties":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":84,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":86,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/core-js-stable/symbol":95,"@babel/runtime-corejs3/core-js/get-iterator-method":99,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/slicedToArray":139,"@babel/runtime-corejs3/helpers/typeof":144}],21:[function(_dereq_,module,exports){
  5671. "use strict";
  5672. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5673. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5674. _Object$defineProperty(exports, "__esModule", {
  5675. value: true
  5676. });
  5677. exports.default = void 0;
  5678. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  5679. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  5680. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  5681. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  5682. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  5683. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  5684. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  5685. var _decode = _interopRequireDefault(_dereq_("./decode"));
  5686. var _encode = _interopRequireDefault(_dereq_("./encode"));
  5687. var _escape2 = _interopRequireDefault(_dereq_("./escape"));
  5688. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  5689. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  5690. /**
  5691. * @flow
  5692. */
  5693. /*:: import type { RequestOptions } from './RESTController';*/
  5694. /**
  5695. * Parse.Config is a local representation of configuration data that
  5696. * can be set from the Parse dashboard.
  5697. *
  5698. * @alias Parse.Config
  5699. */
  5700. var ParseConfig = /*#__PURE__*/function () {
  5701. function ParseConfig() {
  5702. (0, _classCallCheck2.default)(this, ParseConfig);
  5703. (0, _defineProperty2.default)(this, "attributes", void 0);
  5704. (0, _defineProperty2.default)(this, "_escapedAttributes", void 0);
  5705. this.attributes = {};
  5706. this._escapedAttributes = {};
  5707. }
  5708. /**
  5709. * Gets the value of an attribute.
  5710. *
  5711. * @param {string} attr The name of an attribute.
  5712. * @returns {*}
  5713. */
  5714. (0, _createClass2.default)(ParseConfig, [{
  5715. key: "get",
  5716. value: function (attr /*: string*/) /*: any*/{
  5717. return this.attributes[attr];
  5718. }
  5719. /**
  5720. * Gets the HTML-escaped value of an attribute.
  5721. *
  5722. * @param {string} attr The name of an attribute.
  5723. * @returns {string}
  5724. */
  5725. }, {
  5726. key: "escape",
  5727. value: function (attr /*: string*/) /*: string*/{
  5728. var html = this._escapedAttributes[attr];
  5729. if (html) {
  5730. return html;
  5731. }
  5732. var val = this.attributes[attr];
  5733. var escaped = '';
  5734. if (val != null) {
  5735. escaped = (0, _escape2.default)(val.toString());
  5736. }
  5737. this._escapedAttributes[attr] = escaped;
  5738. return escaped;
  5739. }
  5740. /**
  5741. * Retrieves the most recently-fetched configuration object, either from
  5742. * memory or from local storage if necessary.
  5743. *
  5744. * @static
  5745. * @returns {Parse.Config} The most recently-fetched Parse.Config if it
  5746. * exists, else an empty Parse.Config.
  5747. */
  5748. }], [{
  5749. key: "current",
  5750. value: function () {
  5751. var controller = _CoreManager.default.getConfigController();
  5752. return controller.current();
  5753. }
  5754. /**
  5755. * Gets a new configuration object from the server.
  5756. *
  5757. * @static
  5758. * @param {object} options
  5759. * Valid options are:<ul>
  5760. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  5761. * be used for this request.
  5762. * </ul>
  5763. * @returns {Promise} A promise that is resolved with a newly-created
  5764. * configuration object when the get completes.
  5765. */
  5766. }, {
  5767. key: "get",
  5768. value: function () {
  5769. var options /*: RequestOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5770. var controller = _CoreManager.default.getConfigController();
  5771. return controller.get(options);
  5772. }
  5773. /**
  5774. * Save value keys to the server.
  5775. *
  5776. * @static
  5777. * @param {object} attrs The config parameters and values.
  5778. * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed
  5779. * in `attrs` should be retrievable only by using the master key.
  5780. * For example: `param1: true` makes `param1` only retrievable by using the master key.
  5781. * If a parameter is not provided or set to `false`, it can be retrieved without
  5782. * using the master key.
  5783. * @returns {Promise} A promise that is resolved with a newly-created
  5784. * configuration object or with the current with the update.
  5785. */
  5786. }, {
  5787. key: "save",
  5788. value: function (attrs /*: { [key: string]: any }*/, masterKeyOnlyFlags /*: { [key: string]: any }*/) {
  5789. var controller = _CoreManager.default.getConfigController();
  5790. //To avoid a mismatch with the local and the cloud config we get a new version
  5791. return controller.save(attrs, masterKeyOnlyFlags).then(function () {
  5792. return controller.get({
  5793. useMasterKey: true
  5794. });
  5795. }, function (error) {
  5796. return _promise.default.reject(error);
  5797. });
  5798. }
  5799. /**
  5800. * Used for testing
  5801. *
  5802. * @private
  5803. */
  5804. }, {
  5805. key: "_clearCache",
  5806. value: function () {
  5807. currentConfig = null;
  5808. }
  5809. }]);
  5810. return ParseConfig;
  5811. }();
  5812. var currentConfig = null;
  5813. var CURRENT_CONFIG_KEY = 'currentConfig';
  5814. function decodePayload(data) {
  5815. try {
  5816. var json = JSON.parse(data);
  5817. if (json && (0, _typeof2.default)(json) === 'object') {
  5818. return (0, _decode.default)(json);
  5819. }
  5820. } catch (e) {
  5821. return null;
  5822. }
  5823. }
  5824. var DefaultController = {
  5825. current: function () {
  5826. if (currentConfig) {
  5827. return currentConfig;
  5828. }
  5829. var config = new ParseConfig();
  5830. var storagePath = _Storage.default.generatePath(CURRENT_CONFIG_KEY);
  5831. if (!_Storage.default.async()) {
  5832. var configData = _Storage.default.getItem(storagePath);
  5833. if (configData) {
  5834. var attributes = decodePayload(configData);
  5835. if (attributes) {
  5836. config.attributes = attributes;
  5837. currentConfig = config;
  5838. }
  5839. }
  5840. return config;
  5841. }
  5842. // Return a promise for async storage controllers
  5843. return _Storage.default.getItemAsync(storagePath).then(function (configData) {
  5844. if (configData) {
  5845. var _attributes = decodePayload(configData);
  5846. if (_attributes) {
  5847. config.attributes = _attributes;
  5848. currentConfig = config;
  5849. }
  5850. }
  5851. return config;
  5852. });
  5853. },
  5854. get: function () {
  5855. var options /*: RequestOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5856. var RESTController = _CoreManager.default.getRESTController();
  5857. return RESTController.request('GET', 'config', {}, options).then(function (response) {
  5858. if (!response || !response.params) {
  5859. var error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Config JSON response invalid.');
  5860. return _promise.default.reject(error);
  5861. }
  5862. var config = new ParseConfig();
  5863. config.attributes = {};
  5864. for (var attr in response.params) {
  5865. config.attributes[attr] = (0, _decode.default)(response.params[attr]);
  5866. }
  5867. currentConfig = config;
  5868. return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(function () {
  5869. return config;
  5870. });
  5871. });
  5872. },
  5873. save: function (attrs /*: { [key: string]: any }*/, masterKeyOnlyFlags /*: { [key: string]: any }*/) {
  5874. var RESTController = _CoreManager.default.getRESTController();
  5875. var encodedAttrs = {};
  5876. for (var _key in attrs) {
  5877. encodedAttrs[_key] = (0, _encode.default)(attrs[_key]);
  5878. }
  5879. return RESTController.request('PUT', 'config', {
  5880. params: encodedAttrs,
  5881. masterKeyOnly: masterKeyOnlyFlags
  5882. }, {
  5883. useMasterKey: true
  5884. }).then(function (response) {
  5885. if (response && response.result) {
  5886. return _promise.default.resolve();
  5887. } else {
  5888. var error = new _ParseError.default(_ParseError.default.INTERNAL_SERVER_ERROR, 'Error occured updating Config.');
  5889. return _promise.default.reject(error);
  5890. }
  5891. });
  5892. }
  5893. };
  5894. _CoreManager.default.setConfigController(DefaultController);
  5895. var _default = ParseConfig;
  5896. exports.default = _default;
  5897. },{"./CoreManager":4,"./ParseError":22,"./Storage":39,"./decode":45,"./encode":46,"./escape":48,"@babel/runtime-corejs3/core-js-stable/json/stringify":75,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],22:[function(_dereq_,module,exports){
  5898. "use strict";
  5899. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  5900. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5901. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5902. _Object$defineProperty2(exports, "__esModule", {
  5903. value: true
  5904. });
  5905. exports.default = void 0;
  5906. var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  5907. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  5908. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  5909. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  5910. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  5911. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  5912. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  5913. var _wrapNativeSuper2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
  5914. function _createSuper(Derived) {
  5915. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  5916. return function () {
  5917. var Super = (0, _getPrototypeOf2.default)(Derived),
  5918. result;
  5919. if (hasNativeReflectConstruct) {
  5920. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  5921. result = _Reflect$construct(Super, arguments, NewTarget);
  5922. } else {
  5923. result = Super.apply(this, arguments);
  5924. }
  5925. return (0, _possibleConstructorReturn2.default)(this, result);
  5926. };
  5927. }
  5928. function _isNativeReflectConstruct() {
  5929. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  5930. if (_Reflect$construct.sham) return false;
  5931. if (typeof Proxy === "function") return true;
  5932. try {
  5933. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  5934. return true;
  5935. } catch (e) {
  5936. return false;
  5937. }
  5938. }
  5939. /**
  5940. * Constructs a new Parse.Error object with the given code and message.
  5941. *
  5942. * @alias Parse.Error
  5943. */
  5944. var ParseError = /*#__PURE__*/function (_Error) {
  5945. (0, _inherits2.default)(ParseError, _Error);
  5946. var _super = _createSuper(ParseError);
  5947. /**
  5948. * @param {number} code An error code constant from <code>Parse.Error</code>.
  5949. * @param {string} message A detailed description of the error.
  5950. */
  5951. function ParseError(code, message) {
  5952. var _this;
  5953. (0, _classCallCheck2.default)(this, ParseError);
  5954. _this = _super.call(this, message);
  5955. _this.code = code;
  5956. (0, _defineProperty.default)((0, _assertThisInitialized2.default)(_this), 'message', {
  5957. enumerable: true,
  5958. value: message
  5959. });
  5960. return _this;
  5961. }
  5962. (0, _createClass2.default)(ParseError, [{
  5963. key: "toString",
  5964. value: function () {
  5965. return 'ParseError: ' + this.code + ' ' + this.message;
  5966. }
  5967. }]);
  5968. return ParseError;
  5969. }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
  5970. /**
  5971. * Error code indicating some error other than those enumerated here.
  5972. *
  5973. * @property {number} OTHER_CAUSE
  5974. * @static
  5975. */
  5976. ParseError.OTHER_CAUSE = -1;
  5977. /**
  5978. * Error code indicating that something has gone wrong with the server.
  5979. *
  5980. * @property {number} INTERNAL_SERVER_ERROR
  5981. * @static
  5982. */
  5983. ParseError.INTERNAL_SERVER_ERROR = 1;
  5984. /**
  5985. * Error code indicating the connection to the Parse servers failed.
  5986. *
  5987. * @property {number} CONNECTION_FAILED
  5988. * @static
  5989. */
  5990. ParseError.CONNECTION_FAILED = 100;
  5991. /**
  5992. * Error code indicating the specified object doesn't exist.
  5993. *
  5994. * @property {number} OBJECT_NOT_FOUND
  5995. * @static
  5996. */
  5997. ParseError.OBJECT_NOT_FOUND = 101;
  5998. /**
  5999. * Error code indicating you tried to query with a datatype that doesn't
  6000. * support it, like exact matching an array or object.
  6001. *
  6002. * @property {number} INVALID_QUERY
  6003. * @static
  6004. */
  6005. ParseError.INVALID_QUERY = 102;
  6006. /**
  6007. * Error code indicating a missing or invalid classname. Classnames are
  6008. * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
  6009. * only valid characters.
  6010. *
  6011. * @property {number} INVALID_CLASS_NAME
  6012. * @static
  6013. */
  6014. ParseError.INVALID_CLASS_NAME = 103;
  6015. /**
  6016. * Error code indicating an unspecified object id.
  6017. *
  6018. * @property {number} MISSING_OBJECT_ID
  6019. * @static
  6020. */
  6021. ParseError.MISSING_OBJECT_ID = 104;
  6022. /**
  6023. * Error code indicating an invalid key name. Keys are case-sensitive. They
  6024. * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
  6025. *
  6026. * @property {number} INVALID_KEY_NAME
  6027. * @static
  6028. */
  6029. ParseError.INVALID_KEY_NAME = 105;
  6030. /**
  6031. * Error code indicating a malformed pointer. You should not see this unless
  6032. * you have been mucking about changing internal Parse code.
  6033. *
  6034. * @property {number} INVALID_POINTER
  6035. * @static
  6036. */
  6037. ParseError.INVALID_POINTER = 106;
  6038. /**
  6039. * Error code indicating that badly formed JSON was received upstream. This
  6040. * either indicates you have done something unusual with modifying how
  6041. * things encode to JSON, or the network is failing badly.
  6042. *
  6043. * @property {number} INVALID_JSON
  6044. * @static
  6045. */
  6046. ParseError.INVALID_JSON = 107;
  6047. /**
  6048. * Error code indicating that the feature you tried to access is only
  6049. * available internally for testing purposes.
  6050. *
  6051. * @property {number} COMMAND_UNAVAILABLE
  6052. * @static
  6053. */
  6054. ParseError.COMMAND_UNAVAILABLE = 108;
  6055. /**
  6056. * You must call Parse.initialize before using the Parse library.
  6057. *
  6058. * @property {number} NOT_INITIALIZED
  6059. * @static
  6060. */
  6061. ParseError.NOT_INITIALIZED = 109;
  6062. /**
  6063. * Error code indicating that a field was set to an inconsistent type.
  6064. *
  6065. * @property {number} INCORRECT_TYPE
  6066. * @static
  6067. */
  6068. ParseError.INCORRECT_TYPE = 111;
  6069. /**
  6070. * Error code indicating an invalid channel name. A channel name is either
  6071. * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
  6072. * characters and starts with a letter.
  6073. *
  6074. * @property {number} INVALID_CHANNEL_NAME
  6075. * @static
  6076. */
  6077. ParseError.INVALID_CHANNEL_NAME = 112;
  6078. /**
  6079. * Error code indicating that push is misconfigured.
  6080. *
  6081. * @property {number} PUSH_MISCONFIGURED
  6082. * @static
  6083. */
  6084. ParseError.PUSH_MISCONFIGURED = 115;
  6085. /**
  6086. * Error code indicating that the object is too large.
  6087. *
  6088. * @property {number} OBJECT_TOO_LARGE
  6089. * @static
  6090. */
  6091. ParseError.OBJECT_TOO_LARGE = 116;
  6092. /**
  6093. * Error code indicating that the operation isn't allowed for clients.
  6094. *
  6095. * @property {number} OPERATION_FORBIDDEN
  6096. * @static
  6097. */
  6098. ParseError.OPERATION_FORBIDDEN = 119;
  6099. /**
  6100. * Error code indicating the result was not found in the cache.
  6101. *
  6102. * @property {number} CACHE_MISS
  6103. * @static
  6104. */
  6105. ParseError.CACHE_MISS = 120;
  6106. /**
  6107. * Error code indicating that an invalid key was used in a nested
  6108. * JSONObject.
  6109. *
  6110. * @property {number} INVALID_NESTED_KEY
  6111. * @static
  6112. */
  6113. ParseError.INVALID_NESTED_KEY = 121;
  6114. /**
  6115. * Error code indicating that an invalid filename was used for ParseFile.
  6116. * A valid file name contains only a-zA-Z0-9_. characters and is between 1
  6117. * and 128 characters.
  6118. *
  6119. * @property {number} INVALID_FILE_NAME
  6120. * @static
  6121. */
  6122. ParseError.INVALID_FILE_NAME = 122;
  6123. /**
  6124. * Error code indicating an invalid ACL was provided.
  6125. *
  6126. * @property {number} INVALID_ACL
  6127. * @static
  6128. */
  6129. ParseError.INVALID_ACL = 123;
  6130. /**
  6131. * Error code indicating that the request timed out on the server. Typically
  6132. * this indicates that the request is too expensive to run.
  6133. *
  6134. * @property {number} TIMEOUT
  6135. * @static
  6136. */
  6137. ParseError.TIMEOUT = 124;
  6138. /**
  6139. * Error code indicating that the email address was invalid.
  6140. *
  6141. * @property {number} INVALID_EMAIL_ADDRESS
  6142. * @static
  6143. */
  6144. ParseError.INVALID_EMAIL_ADDRESS = 125;
  6145. /**
  6146. * Error code indicating a missing content type.
  6147. *
  6148. * @property {number} MISSING_CONTENT_TYPE
  6149. * @static
  6150. */
  6151. ParseError.MISSING_CONTENT_TYPE = 126;
  6152. /**
  6153. * Error code indicating a missing content length.
  6154. *
  6155. * @property {number} MISSING_CONTENT_LENGTH
  6156. * @static
  6157. */
  6158. ParseError.MISSING_CONTENT_LENGTH = 127;
  6159. /**
  6160. * Error code indicating an invalid content length.
  6161. *
  6162. * @property {number} INVALID_CONTENT_LENGTH
  6163. * @static
  6164. */
  6165. ParseError.INVALID_CONTENT_LENGTH = 128;
  6166. /**
  6167. * Error code indicating a file that was too large.
  6168. *
  6169. * @property {number} FILE_TOO_LARGE
  6170. * @static
  6171. */
  6172. ParseError.FILE_TOO_LARGE = 129;
  6173. /**
  6174. * Error code indicating an error saving a file.
  6175. *
  6176. * @property {number} FILE_SAVE_ERROR
  6177. * @static
  6178. */
  6179. ParseError.FILE_SAVE_ERROR = 130;
  6180. /**
  6181. * Error code indicating that a unique field was given a value that is
  6182. * already taken.
  6183. *
  6184. * @property {number} DUPLICATE_VALUE
  6185. * @static
  6186. */
  6187. ParseError.DUPLICATE_VALUE = 137;
  6188. /**
  6189. * Error code indicating that a role's name is invalid.
  6190. *
  6191. * @property {number} INVALID_ROLE_NAME
  6192. * @static
  6193. */
  6194. ParseError.INVALID_ROLE_NAME = 139;
  6195. /**
  6196. * Error code indicating that an application quota was exceeded. Upgrade to
  6197. * resolve.
  6198. *
  6199. * @property {number} EXCEEDED_QUOTA
  6200. * @static
  6201. */
  6202. ParseError.EXCEEDED_QUOTA = 140;
  6203. /**
  6204. * Error code indicating that a Cloud Code script failed.
  6205. *
  6206. * @property {number} SCRIPT_FAILED
  6207. * @static
  6208. */
  6209. ParseError.SCRIPT_FAILED = 141;
  6210. /**
  6211. * Error code indicating that a Cloud Code validation failed.
  6212. *
  6213. * @property {number} VALIDATION_ERROR
  6214. * @static
  6215. */
  6216. ParseError.VALIDATION_ERROR = 142;
  6217. /**
  6218. * Error code indicating that invalid image data was provided.
  6219. *
  6220. * @property {number} INVALID_IMAGE_DATA
  6221. * @static
  6222. */
  6223. ParseError.INVALID_IMAGE_DATA = 143;
  6224. /**
  6225. * Error code indicating an unsaved file.
  6226. *
  6227. * @property {number} UNSAVED_FILE_ERROR
  6228. * @static
  6229. */
  6230. ParseError.UNSAVED_FILE_ERROR = 151;
  6231. /**
  6232. * Error code indicating an invalid push time.
  6233. *
  6234. * @property {number} INVALID_PUSH_TIME_ERROR
  6235. * @static
  6236. */
  6237. ParseError.INVALID_PUSH_TIME_ERROR = 152;
  6238. /**
  6239. * Error code indicating an error deleting a file.
  6240. *
  6241. * @property {number} FILE_DELETE_ERROR
  6242. * @static
  6243. */
  6244. ParseError.FILE_DELETE_ERROR = 153;
  6245. /**
  6246. * Error code indicating an error deleting an unnamed file.
  6247. *
  6248. * @property {number} FILE_DELETE_UNNAMED_ERROR
  6249. * @static
  6250. */
  6251. ParseError.FILE_DELETE_UNNAMED_ERROR = 161;
  6252. /**
  6253. * Error code indicating that the application has exceeded its request
  6254. * limit.
  6255. *
  6256. * @property {number} REQUEST_LIMIT_EXCEEDED
  6257. * @static
  6258. */
  6259. ParseError.REQUEST_LIMIT_EXCEEDED = 155;
  6260. /**
  6261. * Error code indicating that the request was a duplicate and has been discarded due to
  6262. * idempotency rules.
  6263. *
  6264. * @property {number} DUPLICATE_REQUEST
  6265. * @static
  6266. */
  6267. ParseError.DUPLICATE_REQUEST = 159;
  6268. /**
  6269. * Error code indicating an invalid event name.
  6270. *
  6271. * @property {number} INVALID_EVENT_NAME
  6272. * @static
  6273. */
  6274. ParseError.INVALID_EVENT_NAME = 160;
  6275. /**
  6276. * Error code indicating that a field had an invalid value.
  6277. *
  6278. * @property {number} INVALID_VALUE
  6279. * @static
  6280. */
  6281. ParseError.INVALID_VALUE = 162;
  6282. /**
  6283. * Error code indicating that the username is missing or empty.
  6284. *
  6285. * @property {number} USERNAME_MISSING
  6286. * @static
  6287. */
  6288. ParseError.USERNAME_MISSING = 200;
  6289. /**
  6290. * Error code indicating that the password is missing or empty.
  6291. *
  6292. * @property {number} PASSWORD_MISSING
  6293. * @static
  6294. */
  6295. ParseError.PASSWORD_MISSING = 201;
  6296. /**
  6297. * Error code indicating that the username has already been taken.
  6298. *
  6299. * @property {number} USERNAME_TAKEN
  6300. * @static
  6301. */
  6302. ParseError.USERNAME_TAKEN = 202;
  6303. /**
  6304. * Error code indicating that the email has already been taken.
  6305. *
  6306. * @property {number} EMAIL_TAKEN
  6307. * @static
  6308. */
  6309. ParseError.EMAIL_TAKEN = 203;
  6310. /**
  6311. * Error code indicating that the email is missing, but must be specified.
  6312. *
  6313. * @property {number} EMAIL_MISSING
  6314. * @static
  6315. */
  6316. ParseError.EMAIL_MISSING = 204;
  6317. /**
  6318. * Error code indicating that a user with the specified email was not found.
  6319. *
  6320. * @property {number} EMAIL_NOT_FOUND
  6321. * @static
  6322. */
  6323. ParseError.EMAIL_NOT_FOUND = 205;
  6324. /**
  6325. * Error code indicating that a user object without a valid session could
  6326. * not be altered.
  6327. *
  6328. * @property {number} SESSION_MISSING
  6329. * @static
  6330. */
  6331. ParseError.SESSION_MISSING = 206;
  6332. /**
  6333. * Error code indicating that a user can only be created through signup.
  6334. *
  6335. * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP
  6336. * @static
  6337. */
  6338. ParseError.MUST_CREATE_USER_THROUGH_SIGNUP = 207;
  6339. /**
  6340. * Error code indicating that an an account being linked is already linked
  6341. * to another user.
  6342. *
  6343. * @property {number} ACCOUNT_ALREADY_LINKED
  6344. * @static
  6345. */
  6346. ParseError.ACCOUNT_ALREADY_LINKED = 208;
  6347. /**
  6348. * Error code indicating that the current session token is invalid.
  6349. *
  6350. * @property {number} INVALID_SESSION_TOKEN
  6351. * @static
  6352. */
  6353. ParseError.INVALID_SESSION_TOKEN = 209;
  6354. /**
  6355. * Error code indicating an error enabling or verifying MFA
  6356. *
  6357. * @property {number} MFA_ERROR
  6358. * @static
  6359. */
  6360. ParseError.MFA_ERROR = 210;
  6361. /**
  6362. * Error code indicating that a valid MFA token must be provided
  6363. *
  6364. * @property {number} MFA_TOKEN_REQUIRED
  6365. * @static
  6366. */
  6367. ParseError.MFA_TOKEN_REQUIRED = 211;
  6368. /**
  6369. * Error code indicating that a user cannot be linked to an account because
  6370. * that account's id could not be found.
  6371. *
  6372. * @property {number} LINKED_ID_MISSING
  6373. * @static
  6374. */
  6375. ParseError.LINKED_ID_MISSING = 250;
  6376. /**
  6377. * Error code indicating that a user with a linked (e.g. Facebook) account
  6378. * has an invalid session.
  6379. *
  6380. * @property {number} INVALID_LINKED_SESSION
  6381. * @static
  6382. */
  6383. ParseError.INVALID_LINKED_SESSION = 251;
  6384. /**
  6385. * Error code indicating that a service being linked (e.g. Facebook or
  6386. * Twitter) is unsupported.
  6387. *
  6388. * @property {number} UNSUPPORTED_SERVICE
  6389. * @static
  6390. */
  6391. ParseError.UNSUPPORTED_SERVICE = 252;
  6392. /**
  6393. * Error code indicating an invalid operation occured on schema
  6394. *
  6395. * @property {number} INVALID_SCHEMA_OPERATION
  6396. * @static
  6397. */
  6398. ParseError.INVALID_SCHEMA_OPERATION = 255;
  6399. /**
  6400. * Error code indicating that there were multiple errors. Aggregate errors
  6401. * have an "errors" property, which is an array of error objects with more
  6402. * detail about each error that occurred.
  6403. *
  6404. * @property {number} AGGREGATE_ERROR
  6405. * @static
  6406. */
  6407. ParseError.AGGREGATE_ERROR = 600;
  6408. /**
  6409. * Error code indicating the client was unable to read an input file.
  6410. *
  6411. * @property {number} FILE_READ_ERROR
  6412. * @static
  6413. */
  6414. ParseError.FILE_READ_ERROR = 601;
  6415. /**
  6416. * Error code indicating a real error code is unavailable because
  6417. * we had to use an XDomainRequest object to allow CORS requests in
  6418. * Internet Explorer, which strips the body from HTTP responses that have
  6419. * a non-2XX status code.
  6420. *
  6421. * @property {number} X_DOMAIN_REQUEST
  6422. * @static
  6423. */
  6424. ParseError.X_DOMAIN_REQUEST = 602;
  6425. var _default = ParseError;
  6426. exports.default = _default;
  6427. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/reflect/construct":91,"@babel/runtime-corejs3/helpers/assertThisInitialized":120,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/getPrototypeOf":127,"@babel/runtime-corejs3/helpers/inherits":128,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":136,"@babel/runtime-corejs3/helpers/wrapNativeSuper":146}],23:[function(_dereq_,module,exports){
  6428. "use strict";
  6429. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  6430. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  6431. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  6432. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  6433. var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  6434. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  6435. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  6436. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  6437. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  6438. _Object$defineProperty(exports, "__esModule", {
  6439. value: true
  6440. });
  6441. exports.default = void 0;
  6442. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  6443. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  6444. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  6445. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  6446. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  6447. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  6448. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  6449. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  6450. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  6451. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  6452. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  6453. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  6454. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  6455. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  6456. function ownKeys(object, enumerableOnly) {
  6457. var keys = _Object$keys2(object);
  6458. if (_Object$getOwnPropertySymbols) {
  6459. var symbols = _Object$getOwnPropertySymbols(object);
  6460. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  6461. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  6462. })), keys.push.apply(keys, symbols);
  6463. }
  6464. return keys;
  6465. }
  6466. function _objectSpread(target) {
  6467. for (var i = 1; i < arguments.length; i++) {
  6468. var _context8, _context9;
  6469. var source = null != arguments[i] ? arguments[i] : {};
  6470. i % 2 ? _forEachInstanceProperty2(_context8 = ownKeys(Object(source), !0)).call(_context8, function (key) {
  6471. (0, _defineProperty2.default)(target, key, source[key]);
  6472. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context9 = ownKeys(Object(source))).call(_context9, function (key) {
  6473. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  6474. });
  6475. }
  6476. return target;
  6477. } /**
  6478. * @flow
  6479. */ /* global XMLHttpRequest, Blob */
  6480. /*:: import type { FullOptions } from './RESTController';*/
  6481. var ParseError = _dereq_('./ParseError').default;
  6482. var XHR = null;
  6483. if (typeof XMLHttpRequest !== 'undefined') {
  6484. XHR = XMLHttpRequest;
  6485. }
  6486. /*:: type Base64 = { base64: string };*/
  6487. /*:: type Uri = { uri: string };*/
  6488. /*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
  6489. /*:: export type FileSource =
  6490. | {
  6491. format: 'file',
  6492. file: Blob,
  6493. type: string,
  6494. }
  6495. | {
  6496. format: 'base64',
  6497. base64: string,
  6498. type: string,
  6499. }
  6500. | {
  6501. format: 'uri',
  6502. uri: string,
  6503. type: string,
  6504. };*/
  6505. function b64Digit(number /*: number*/) /*: string*/{
  6506. if (number < 26) {
  6507. return String.fromCharCode(65 + number);
  6508. }
  6509. if (number < 52) {
  6510. return String.fromCharCode(97 + (number - 26));
  6511. }
  6512. if (number < 62) {
  6513. return String.fromCharCode(48 + (number - 52));
  6514. }
  6515. if (number === 62) {
  6516. return '+';
  6517. }
  6518. if (number === 63) {
  6519. return '/';
  6520. }
  6521. throw new TypeError('Tried to encode large digit ' + number + ' in base64.');
  6522. }
  6523. /**
  6524. * A Parse.File is a local representation of a file that is saved to the Parse
  6525. * cloud.
  6526. *
  6527. * @alias Parse.File
  6528. */
  6529. var ParseFile = /*#__PURE__*/function () {
  6530. /**
  6531. * @param name {String} The file's name. This will be prefixed by a unique
  6532. * value once the file has finished saving. The file name must begin with
  6533. * an alphanumeric character, and consist of alphanumeric characters,
  6534. * periods, spaces, underscores, or dashes.
  6535. * @param data {Array} The data for the file, as either:
  6536. * 1. an Array of byte value Numbers, or
  6537. * 2. an Object like { base64: "..." } with a base64-encoded String.
  6538. * 3. an Object like { uri: "..." } with a uri String.
  6539. * 4. a File object selected with a file upload control. (3) only works
  6540. * in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+.
  6541. * For example:
  6542. * <pre>
  6543. * var fileUploadControl = $("#profilePhotoFileUpload")[0];
  6544. * if (fileUploadControl.files.length > 0) {
  6545. * var file = fileUploadControl.files[0];
  6546. * var name = "photo.jpg";
  6547. * var parseFile = new Parse.File(name, file);
  6548. * parseFile.save().then(function() {
  6549. * // The file has been saved to Parse.
  6550. * }, function(error) {
  6551. * // The file either could not be read, or could not be saved to Parse.
  6552. * });
  6553. * }</pre>
  6554. * @param type {String} Optional Content-Type header to use for the file. If
  6555. * this is omitted, the content type will be inferred from the name's
  6556. * extension.
  6557. * @param metadata {Object} Optional key value pairs to be stored with file object
  6558. * @param tags {Object} Optional key value pairs to be stored with file object
  6559. */
  6560. function ParseFile(name /*: string*/, data /*:: ?: FileData*/, type /*:: ?: string*/, metadata /*:: ?: Object*/, tags /*:: ?: Object*/) {
  6561. (0, _classCallCheck2.default)(this, ParseFile);
  6562. (0, _defineProperty2.default)(this, "_name", void 0);
  6563. (0, _defineProperty2.default)(this, "_url", void 0);
  6564. (0, _defineProperty2.default)(this, "_source", void 0);
  6565. (0, _defineProperty2.default)(this, "_previousSave", void 0);
  6566. (0, _defineProperty2.default)(this, "_data", void 0);
  6567. (0, _defineProperty2.default)(this, "_requestTask", void 0);
  6568. (0, _defineProperty2.default)(this, "_metadata", void 0);
  6569. (0, _defineProperty2.default)(this, "_tags", void 0);
  6570. var specifiedType = type || '';
  6571. this._name = name;
  6572. this._metadata = metadata || {};
  6573. this._tags = tags || {};
  6574. if (data !== undefined) {
  6575. if ((0, _isArray.default)(data)) {
  6576. this._data = ParseFile.encodeBase64(data);
  6577. this._source = {
  6578. format: 'base64',
  6579. base64: this._data,
  6580. type: specifiedType
  6581. };
  6582. } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
  6583. this._source = {
  6584. format: 'file',
  6585. file: data,
  6586. type: specifiedType
  6587. };
  6588. } else if (data && typeof data.uri === 'string' && data.uri !== undefined) {
  6589. this._source = {
  6590. format: 'uri',
  6591. uri: data.uri,
  6592. type: specifiedType
  6593. };
  6594. } else if (data && typeof data.base64 === 'string') {
  6595. var _context, _context2, _context3;
  6596. var base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
  6597. var dataType = specifiedType || (0, _slice.default)(_context2 = (0, _slice.default)(_context3 = data.base64.split(';')).call(_context3, 0, 1)[0].split(':')).call(_context2, 1, 2)[0] || 'text/plain';
  6598. this._data = base64;
  6599. this._source = {
  6600. format: 'base64',
  6601. base64: base64,
  6602. type: dataType
  6603. };
  6604. } else {
  6605. throw new TypeError('Cannot create a Parse.File with that data.');
  6606. }
  6607. }
  6608. }
  6609. /**
  6610. * Return the data for the file, downloading it if not already present.
  6611. * Data is present if initialized with Byte Array, Base64 or Saved with Uri.
  6612. * Data is cleared if saved with File object selected with a file upload control
  6613. *
  6614. * @returns {Promise} Promise that is resolve with base64 data
  6615. */
  6616. (0, _createClass2.default)(ParseFile, [{
  6617. key: "getData",
  6618. value: function () {
  6619. var _getData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  6620. var _this = this;
  6621. var options, controller, result;
  6622. return _regenerator.default.wrap(function (_context4) {
  6623. while (1) switch (_context4.prev = _context4.next) {
  6624. case 0:
  6625. if (!this._data) {
  6626. _context4.next = 2;
  6627. break;
  6628. }
  6629. return _context4.abrupt("return", this._data);
  6630. case 2:
  6631. if (this._url) {
  6632. _context4.next = 4;
  6633. break;
  6634. }
  6635. throw new Error('Cannot retrieve data for unsaved ParseFile.');
  6636. case 4:
  6637. options = {
  6638. requestTask: function (task) {
  6639. return _this._requestTask = task;
  6640. }
  6641. };
  6642. controller = _CoreManager.default.getFileController();
  6643. _context4.next = 8;
  6644. return controller.download(this._url, options);
  6645. case 8:
  6646. result = _context4.sent;
  6647. this._data = result.base64;
  6648. return _context4.abrupt("return", this._data);
  6649. case 11:
  6650. case "end":
  6651. return _context4.stop();
  6652. }
  6653. }, _callee, this);
  6654. }));
  6655. function getData() {
  6656. return _getData.apply(this, arguments);
  6657. }
  6658. return getData;
  6659. }()
  6660. /**
  6661. * Gets the name of the file. Before save is called, this is the filename
  6662. * given by the user. After save is called, that name gets prefixed with a
  6663. * unique identifier.
  6664. *
  6665. * @returns {string}
  6666. */
  6667. }, {
  6668. key: "name",
  6669. value: function () /*: string*/{
  6670. return this._name;
  6671. }
  6672. /**
  6673. * Gets the url of the file. It is only available after you save the file or
  6674. * after you get the file from a Parse.Object.
  6675. *
  6676. * @param {object} options An object to specify url options
  6677. * @returns {string | undefined}
  6678. */
  6679. }, {
  6680. key: "url",
  6681. value: function (options /*:: ?: { forceSecure?: boolean }*/) /*: ?string*/{
  6682. options = options || {};
  6683. if (!this._url) {
  6684. return;
  6685. }
  6686. if (options.forceSecure) {
  6687. return this._url.replace(/^http:\/\//i, 'https://');
  6688. } else {
  6689. return this._url;
  6690. }
  6691. }
  6692. /**
  6693. * Gets the metadata of the file.
  6694. *
  6695. * @returns {object}
  6696. */
  6697. }, {
  6698. key: "metadata",
  6699. value: function () /*: Object*/{
  6700. return this._metadata;
  6701. }
  6702. /**
  6703. * Gets the tags of the file.
  6704. *
  6705. * @returns {object}
  6706. */
  6707. }, {
  6708. key: "tags",
  6709. value: function () /*: Object*/{
  6710. return this._tags;
  6711. }
  6712. /**
  6713. * Saves the file to the Parse cloud.
  6714. *
  6715. * @param {object} options
  6716. * Valid options are:<ul>
  6717. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  6718. * be used for this request.
  6719. * <li>sessionToken: A valid session token, used for making a request on
  6720. * behalf of a specific user.
  6721. * <li>progress: In Browser only, callback for upload progress. For example:
  6722. * <pre>
  6723. * let parseFile = new Parse.File(name, file);
  6724. * parseFile.save({
  6725. * progress: (progressValue, loaded, total, { type }) => {
  6726. * if (type === "upload" && progressValue !== null) {
  6727. * // Update the UI using progressValue
  6728. * }
  6729. * }
  6730. * });
  6731. * </pre>
  6732. * </ul>
  6733. * @returns {Promise | undefined} Promise that is resolved when the save finishes.
  6734. */
  6735. }, {
  6736. key: "save",
  6737. value: function (options /*:: ?: FullOptions*/) /*: ?Promise*/{
  6738. var _this2 = this;
  6739. options = options || {};
  6740. options.requestTask = function (task) {
  6741. return _this2._requestTask = task;
  6742. };
  6743. options.metadata = this._metadata;
  6744. options.tags = this._tags;
  6745. var controller = _CoreManager.default.getFileController();
  6746. if (!this._previousSave) {
  6747. if (this._source.format === 'file') {
  6748. this._previousSave = controller.saveFile(this._name, this._source, options).then(function (res) {
  6749. _this2._name = res.name;
  6750. _this2._url = res.url;
  6751. _this2._data = null;
  6752. _this2._requestTask = null;
  6753. return _this2;
  6754. });
  6755. } else if (this._source.format === 'uri') {
  6756. this._previousSave = controller.download(this._source.uri, options).then(function (result) {
  6757. if (!(result && result.base64)) {
  6758. return {};
  6759. }
  6760. var newSource = {
  6761. format: 'base64',
  6762. base64: result.base64,
  6763. type: result.contentType
  6764. };
  6765. _this2._data = result.base64;
  6766. _this2._requestTask = null;
  6767. return controller.saveBase64(_this2._name, newSource, options);
  6768. }).then(function (res) {
  6769. _this2._name = res.name;
  6770. _this2._url = res.url;
  6771. _this2._requestTask = null;
  6772. return _this2;
  6773. });
  6774. } else {
  6775. this._previousSave = controller.saveBase64(this._name, this._source, options).then(function (res) {
  6776. _this2._name = res.name;
  6777. _this2._url = res.url;
  6778. _this2._requestTask = null;
  6779. return _this2;
  6780. });
  6781. }
  6782. }
  6783. if (this._previousSave) {
  6784. return this._previousSave;
  6785. }
  6786. }
  6787. /**
  6788. * Aborts the request if it has already been sent.
  6789. */
  6790. }, {
  6791. key: "cancel",
  6792. value: function () {
  6793. if (this._requestTask && typeof this._requestTask.abort === 'function') {
  6794. this._requestTask._aborted = true;
  6795. this._requestTask.abort();
  6796. }
  6797. this._requestTask = null;
  6798. }
  6799. /**
  6800. * Deletes the file from the Parse cloud.
  6801. * In Cloud Code and Node only with Master Key.
  6802. *
  6803. * @param {object} options
  6804. * Valid options are:<ul>
  6805. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  6806. * be used for this request.
  6807. * <pre>
  6808. * @returns {Promise} Promise that is resolved when the delete finishes.
  6809. */
  6810. }, {
  6811. key: "destroy",
  6812. value: function () {
  6813. var _this3 = this;
  6814. var options /*:: ?: FullOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  6815. if (!this._name) {
  6816. throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
  6817. }
  6818. var destroyOptions = {
  6819. useMasterKey: true
  6820. };
  6821. if (options.hasOwnProperty('useMasterKey')) {
  6822. destroyOptions.useMasterKey = options.useMasterKey;
  6823. }
  6824. var controller = _CoreManager.default.getFileController();
  6825. return controller.deleteFile(this._name, destroyOptions).then(function () {
  6826. _this3._data = null;
  6827. _this3._requestTask = null;
  6828. return _this3;
  6829. });
  6830. }
  6831. }, {
  6832. key: "toJSON",
  6833. value: function () /*: { name: ?string, url: ?string }*/{
  6834. return {
  6835. __type: 'File',
  6836. name: this._name,
  6837. url: this._url
  6838. };
  6839. }
  6840. }, {
  6841. key: "equals",
  6842. value: function (other /*: mixed*/) /*: boolean*/{
  6843. if (this === other) {
  6844. return true;
  6845. }
  6846. // Unsaved Files are never equal, since they will be saved to different URLs
  6847. return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
  6848. }
  6849. /**
  6850. * Sets metadata to be saved with file object. Overwrites existing metadata
  6851. *
  6852. * @param {object} metadata Key value pairs to be stored with file object
  6853. */
  6854. }, {
  6855. key: "setMetadata",
  6856. value: function (metadata /*: any*/) {
  6857. var _this4 = this;
  6858. if (metadata && (0, _typeof2.default)(metadata) === 'object') {
  6859. var _context5;
  6860. (0, _forEach.default)(_context5 = (0, _keys.default)(metadata)).call(_context5, function (key) {
  6861. _this4.addMetadata(key, metadata[key]);
  6862. });
  6863. }
  6864. }
  6865. /**
  6866. * Sets metadata to be saved with file object. Adds to existing metadata.
  6867. *
  6868. * @param {string} key key to store the metadata
  6869. * @param {*} value metadata
  6870. */
  6871. }, {
  6872. key: "addMetadata",
  6873. value: function (key /*: string*/, value /*: any*/) {
  6874. if (typeof key === 'string') {
  6875. this._metadata[key] = value;
  6876. }
  6877. }
  6878. /**
  6879. * Sets tags to be saved with file object. Overwrites existing tags
  6880. *
  6881. * @param {object} tags Key value pairs to be stored with file object
  6882. */
  6883. }, {
  6884. key: "setTags",
  6885. value: function (tags /*: any*/) {
  6886. var _this5 = this;
  6887. if (tags && (0, _typeof2.default)(tags) === 'object') {
  6888. var _context6;
  6889. (0, _forEach.default)(_context6 = (0, _keys.default)(tags)).call(_context6, function (key) {
  6890. _this5.addTag(key, tags[key]);
  6891. });
  6892. }
  6893. }
  6894. /**
  6895. * Sets tags to be saved with file object. Adds to existing tags.
  6896. *
  6897. * @param {string} key key to store tags
  6898. * @param {*} value tag
  6899. */
  6900. }, {
  6901. key: "addTag",
  6902. value: function (key /*: string*/, value /*: string*/) {
  6903. if (typeof key === 'string') {
  6904. this._tags[key] = value;
  6905. }
  6906. }
  6907. }], [{
  6908. key: "fromJSON",
  6909. value: function (obj) /*: ParseFile*/{
  6910. if (obj.__type !== 'File') {
  6911. throw new TypeError('JSON object does not represent a ParseFile');
  6912. }
  6913. var file = new ParseFile(obj.name);
  6914. file._url = obj.url;
  6915. return file;
  6916. }
  6917. }, {
  6918. key: "encodeBase64",
  6919. value: function (bytes /*: Array<number>*/) /*: string*/{
  6920. var chunks = [];
  6921. chunks.length = Math.ceil(bytes.length / 3);
  6922. for (var i = 0; i < chunks.length; i++) {
  6923. var b1 = bytes[i * 3];
  6924. var b2 = bytes[i * 3 + 1] || 0;
  6925. var b3 = bytes[i * 3 + 2] || 0;
  6926. var has2 = i * 3 + 1 < bytes.length;
  6927. var has3 = i * 3 + 2 < bytes.length;
  6928. chunks[i] = [b64Digit(b1 >> 2 & 0x3f), b64Digit(b1 << 4 & 0x30 | b2 >> 4 & 0x0f), has2 ? b64Digit(b2 << 2 & 0x3c | b3 >> 6 & 0x03) : '=', has3 ? b64Digit(b3 & 0x3f) : '='].join('');
  6929. }
  6930. return chunks.join('');
  6931. }
  6932. }]);
  6933. return ParseFile;
  6934. }();
  6935. var DefaultController = {
  6936. saveFile: function () {
  6937. var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
  6938. var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
  6939. return _regenerator.default.wrap(function (_context7) {
  6940. while (1) switch (_context7.prev = _context7.next) {
  6941. case 0:
  6942. if (!(source.format !== 'file')) {
  6943. _context7.next = 2;
  6944. break;
  6945. }
  6946. throw new Error('saveFile can only be used with File-type sources.');
  6947. case 2:
  6948. _context7.next = 4;
  6949. return new _promise.default(function (res, rej) {
  6950. // eslint-disable-next-line no-undef
  6951. var reader = new FileReader();
  6952. reader.onload = function () {
  6953. return res(reader.result);
  6954. };
  6955. reader.onerror = function (error) {
  6956. return rej(error);
  6957. };
  6958. reader.readAsDataURL(source.file);
  6959. });
  6960. case 4:
  6961. base64Data = _context7.sent;
  6962. // we only want the data after the comma
  6963. // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
  6964. _base64Data$split = base64Data.split(','), _base64Data$split2 = (0, _slicedToArray2.default)(_base64Data$split, 2), first = _base64Data$split2[0], second = _base64Data$split2[1]; // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
  6965. // use the entire string instead
  6966. data = second ? second : first;
  6967. newSource = {
  6968. format: 'base64',
  6969. base64: data,
  6970. type: source.type || (source.file ? source.file.type : null)
  6971. };
  6972. _context7.next = 10;
  6973. return DefaultController.saveBase64(name, newSource, options);
  6974. case 10:
  6975. return _context7.abrupt("return", _context7.sent);
  6976. case 11:
  6977. case "end":
  6978. return _context7.stop();
  6979. }
  6980. }, _callee2);
  6981. }));
  6982. function saveFile() {
  6983. return _saveFile.apply(this, arguments);
  6984. }
  6985. return saveFile;
  6986. }(),
  6987. saveBase64: function (name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
  6988. if (source.format !== 'base64') {
  6989. throw new Error('saveBase64 can only be used with Base64-type sources.');
  6990. }
  6991. var data /*: { base64: any, _ContentType?: any, fileData: Object }*/ = {
  6992. base64: source.base64,
  6993. fileData: {
  6994. metadata: _objectSpread({}, options.metadata),
  6995. tags: _objectSpread({}, options.tags)
  6996. }
  6997. };
  6998. delete options.metadata;
  6999. delete options.tags;
  7000. if (source.type) {
  7001. data._ContentType = source.type;
  7002. }
  7003. return _CoreManager.default.getRESTController().request('POST', 'files/' + name, data, options);
  7004. },
  7005. download: function (uri, options) {
  7006. if (XHR) {
  7007. return this.downloadAjax(uri, options);
  7008. } else {
  7009. return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
  7010. }
  7011. },
  7012. downloadAjax: function (uri, options) {
  7013. return new _promise.default(function (resolve, reject) {
  7014. var xhr = new XHR();
  7015. xhr.open('GET', uri, true);
  7016. xhr.responseType = 'arraybuffer';
  7017. xhr.onerror = function (e) {
  7018. reject(e);
  7019. };
  7020. xhr.onreadystatechange = function () {
  7021. if (xhr.readyState !== xhr.DONE) {
  7022. return;
  7023. }
  7024. if (!this.response) {
  7025. return resolve({});
  7026. }
  7027. var bytes = new Uint8Array(this.response);
  7028. resolve({
  7029. base64: ParseFile.encodeBase64(bytes),
  7030. contentType: xhr.getResponseHeader('content-type')
  7031. });
  7032. };
  7033. options.requestTask(xhr);
  7034. xhr.send();
  7035. });
  7036. },
  7037. deleteFile: function (name /*: string*/, options /*:: ?: FullOptions*/) {
  7038. var headers = {
  7039. 'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
  7040. };
  7041. if (options.useMasterKey) {
  7042. headers['X-Parse-Master-Key'] = _CoreManager.default.get('MASTER_KEY');
  7043. }
  7044. var url = _CoreManager.default.get('SERVER_URL');
  7045. if (url[url.length - 1] !== '/') {
  7046. url += '/';
  7047. }
  7048. url += 'files/' + name;
  7049. return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(function (response) {
  7050. // TODO: return JSON object in server
  7051. if (!response || response === 'SyntaxError: Unexpected end of JSON input') {
  7052. return _promise.default.resolve();
  7053. } else {
  7054. return _CoreManager.default.getRESTController().handleError(response);
  7055. }
  7056. });
  7057. },
  7058. _setXHR: function (xhr /*: any*/) {
  7059. XHR = xhr;
  7060. },
  7061. _getXHR: function () {
  7062. return XHR;
  7063. }
  7064. };
  7065. _CoreManager.default.setFileController(DefaultController);
  7066. var _default = ParseFile;
  7067. exports.default = _default;
  7068. exports.b64Digit = b64Digit;
  7069. },{"./CoreManager":4,"./ParseError":22,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/slice":70,"@babel/runtime-corejs3/core-js-stable/object/define-properties":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":84,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":86,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/helpers/asyncToGenerator":121,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/slicedToArray":139,"@babel/runtime-corejs3/helpers/typeof":144,"@babel/runtime-corejs3/regenerator":147}],24:[function(_dereq_,module,exports){
  7070. "use strict";
  7071. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7072. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7073. _Object$defineProperty(exports, "__esModule", {
  7074. value: true
  7075. });
  7076. exports.default = void 0;
  7077. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  7078. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  7079. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  7080. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  7081. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  7082. /**
  7083. * @flow
  7084. */
  7085. /**
  7086. * Creates a new GeoPoint with any of the following forms:<br>
  7087. * <pre>
  7088. * new GeoPoint(otherGeoPoint)
  7089. * new GeoPoint(30, 30)
  7090. * new GeoPoint([30, 30])
  7091. * new GeoPoint({latitude: 30, longitude: 30})
  7092. * new GeoPoint() // defaults to (0, 0)
  7093. * </pre>
  7094. * <p>Represents a latitude / longitude point that may be associated
  7095. * with a key in a ParseObject or used as a reference point for geo queries.
  7096. * This allows proximity-based queries on the key.</p>
  7097. *
  7098. * <p>Only one key in a class may contain a GeoPoint.</p>
  7099. *
  7100. * <p>Example:<pre>
  7101. * var point = new Parse.GeoPoint(30.0, -20.0);
  7102. * var object = new Parse.Object("PlaceObject");
  7103. * object.set("location", point);
  7104. * object.save();</pre></p>
  7105. *
  7106. * @alias Parse.GeoPoint
  7107. */
  7108. /* global navigator */
  7109. var ParseGeoPoint = /*#__PURE__*/function () {
  7110. /**
  7111. * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
  7112. * @param {number} arg2 The longitude of the GeoPoint
  7113. */
  7114. function ParseGeoPoint(arg1 /*: Array<number> | { latitude: number, longitude: number } | number*/, arg2 /*:: ?: number*/) {
  7115. (0, _classCallCheck2.default)(this, ParseGeoPoint);
  7116. (0, _defineProperty2.default)(this, "_latitude", void 0);
  7117. (0, _defineProperty2.default)(this, "_longitude", void 0);
  7118. if ((0, _isArray.default)(arg1)) {
  7119. ParseGeoPoint._validate(arg1[0], arg1[1]);
  7120. this._latitude = arg1[0];
  7121. this._longitude = arg1[1];
  7122. } else if ((0, _typeof2.default)(arg1) === 'object') {
  7123. ParseGeoPoint._validate(arg1.latitude, arg1.longitude);
  7124. this._latitude = arg1.latitude;
  7125. this._longitude = arg1.longitude;
  7126. } else if (arg1 !== undefined && arg2 !== undefined) {
  7127. ParseGeoPoint._validate(arg1, arg2);
  7128. this._latitude = arg1;
  7129. this._longitude = arg2;
  7130. } else {
  7131. this._latitude = 0;
  7132. this._longitude = 0;
  7133. }
  7134. }
  7135. /**
  7136. * North-south portion of the coordinate, in range [-90, 90].
  7137. * Throws an exception if set out of range in a modern browser.
  7138. *
  7139. * @property {number} latitude
  7140. * @returns {number}
  7141. */
  7142. (0, _createClass2.default)(ParseGeoPoint, [{
  7143. key: "latitude",
  7144. get: function () /*: number*/{
  7145. return this._latitude;
  7146. },
  7147. set: function (val /*: number*/) {
  7148. ParseGeoPoint._validate(val, this.longitude);
  7149. this._latitude = val;
  7150. }
  7151. /**
  7152. * East-west portion of the coordinate, in range [-180, 180].
  7153. * Throws if set out of range in a modern browser.
  7154. *
  7155. * @property {number} longitude
  7156. * @returns {number}
  7157. */
  7158. }, {
  7159. key: "longitude",
  7160. get: function () /*: number*/{
  7161. return this._longitude;
  7162. },
  7163. set: function (val /*: number*/) {
  7164. ParseGeoPoint._validate(this.latitude, val);
  7165. this._longitude = val;
  7166. }
  7167. /**
  7168. * Returns a JSON representation of the GeoPoint, suitable for Parse.
  7169. *
  7170. * @returns {object}
  7171. */
  7172. }, {
  7173. key: "toJSON",
  7174. value: function () /*: { __type: string, latitude: number, longitude: number }*/{
  7175. ParseGeoPoint._validate(this._latitude, this._longitude);
  7176. return {
  7177. __type: 'GeoPoint',
  7178. latitude: this._latitude,
  7179. longitude: this._longitude
  7180. };
  7181. }
  7182. }, {
  7183. key: "equals",
  7184. value: function (other /*: mixed*/) /*: boolean*/{
  7185. return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
  7186. }
  7187. /**
  7188. * Returns the distance from this GeoPoint to another in radians.
  7189. *
  7190. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  7191. * @returns {number}
  7192. */
  7193. }, {
  7194. key: "radiansTo",
  7195. value: function (point /*: ParseGeoPoint*/) /*: number*/{
  7196. var d2r = Math.PI / 180.0;
  7197. var lat1rad = this.latitude * d2r;
  7198. var long1rad = this.longitude * d2r;
  7199. var lat2rad = point.latitude * d2r;
  7200. var long2rad = point.longitude * d2r;
  7201. var sinDeltaLatDiv2 = Math.sin((lat1rad - lat2rad) / 2);
  7202. var sinDeltaLongDiv2 = Math.sin((long1rad - long2rad) / 2);
  7203. // Square of half the straight line chord distance between both points.
  7204. var a = sinDeltaLatDiv2 * sinDeltaLatDiv2 + Math.cos(lat1rad) * Math.cos(lat2rad) * sinDeltaLongDiv2 * sinDeltaLongDiv2;
  7205. a = Math.min(1.0, a);
  7206. return 2 * Math.asin(Math.sqrt(a));
  7207. }
  7208. /**
  7209. * Returns the distance from this GeoPoint to another in kilometers.
  7210. *
  7211. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  7212. * @returns {number}
  7213. */
  7214. }, {
  7215. key: "kilometersTo",
  7216. value: function (point /*: ParseGeoPoint*/) /*: number*/{
  7217. return this.radiansTo(point) * 6371.0;
  7218. }
  7219. /**
  7220. * Returns the distance from this GeoPoint to another in miles.
  7221. *
  7222. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  7223. * @returns {number}
  7224. */
  7225. }, {
  7226. key: "milesTo",
  7227. value: function (point /*: ParseGeoPoint*/) /*: number*/{
  7228. return this.radiansTo(point) * 3958.8;
  7229. }
  7230. /*
  7231. * Throws an exception if the given lat-long is out of bounds.
  7232. */
  7233. }], [{
  7234. key: "_validate",
  7235. value: function (latitude /*: number*/, longitude /*: number*/) {
  7236. if (isNaN(latitude) || isNaN(longitude) || typeof latitude !== 'number' || typeof longitude !== 'number') {
  7237. throw new TypeError('GeoPoint latitude and longitude must be valid numbers');
  7238. }
  7239. if (latitude < -90.0) {
  7240. throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' < -90.0.');
  7241. }
  7242. if (latitude > 90.0) {
  7243. throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' > 90.0.');
  7244. }
  7245. if (longitude < -180.0) {
  7246. throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' < -180.0.');
  7247. }
  7248. if (longitude > 180.0) {
  7249. throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' > 180.0.');
  7250. }
  7251. }
  7252. /**
  7253. * Creates a GeoPoint with the user's current location, if available.
  7254. *
  7255. * @static
  7256. * @returns {Parse.GeoPoint} User's current location
  7257. */
  7258. }, {
  7259. key: "current",
  7260. value: function () {
  7261. return navigator.geolocation.getCurrentPosition(function (location) {
  7262. return new ParseGeoPoint(location.coords.latitude, location.coords.longitude);
  7263. });
  7264. }
  7265. }]);
  7266. return ParseGeoPoint;
  7267. }();
  7268. var _default = ParseGeoPoint;
  7269. exports.default = _default;
  7270. },{"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],25:[function(_dereq_,module,exports){
  7271. "use strict";
  7272. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  7273. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7274. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7275. _Object$defineProperty(exports, "__esModule", {
  7276. value: true
  7277. });
  7278. exports.default = void 0;
  7279. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  7280. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  7281. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  7282. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  7283. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  7284. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  7285. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  7286. function _createSuper(Derived) {
  7287. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  7288. return function () {
  7289. var Super = (0, _getPrototypeOf2.default)(Derived),
  7290. result;
  7291. if (hasNativeReflectConstruct) {
  7292. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  7293. result = _Reflect$construct(Super, arguments, NewTarget);
  7294. } else {
  7295. result = Super.apply(this, arguments);
  7296. }
  7297. return (0, _possibleConstructorReturn2.default)(this, result);
  7298. };
  7299. }
  7300. function _isNativeReflectConstruct() {
  7301. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  7302. if (_Reflect$construct.sham) return false;
  7303. if (typeof Proxy === "function") return true;
  7304. try {
  7305. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  7306. return true;
  7307. } catch (e) {
  7308. return false;
  7309. }
  7310. } /**
  7311. * @flow
  7312. */
  7313. /*:: import type { AttributeMap } from './ObjectStateMutations';*/
  7314. var Installation = /*#__PURE__*/function (_ParseObject) {
  7315. (0, _inherits2.default)(Installation, _ParseObject);
  7316. var _super = _createSuper(Installation);
  7317. function Installation(attributes /*: ?AttributeMap*/) {
  7318. var _this;
  7319. (0, _classCallCheck2.default)(this, Installation);
  7320. _this = _super.call(this, '_Installation');
  7321. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  7322. if (!_this.set(attributes || {})) {
  7323. throw new Error("Can't create an invalid Installation");
  7324. }
  7325. }
  7326. return _this;
  7327. }
  7328. return (0, _createClass2.default)(Installation);
  7329. }(_ParseObject2.default);
  7330. exports.default = Installation;
  7331. _ParseObject2.default.registerSubclass('_Installation', Installation);
  7332. },{"./ParseObject":27,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/reflect/construct":91,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/getPrototypeOf":127,"@babel/runtime-corejs3/helpers/inherits":128,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":136,"@babel/runtime-corejs3/helpers/typeof":144}],26:[function(_dereq_,module,exports){
  7333. "use strict";
  7334. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7335. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7336. _Object$defineProperty(exports, "__esModule", {
  7337. value: true
  7338. });
  7339. exports.default = void 0;
  7340. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  7341. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  7342. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  7343. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  7344. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  7345. var _EventEmitter = _interopRequireDefault(_dereq_("./EventEmitter"));
  7346. var _LiveQueryClient = _interopRequireDefault(_dereq_("./LiveQueryClient"));
  7347. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  7348. /**
  7349. * @flow
  7350. */
  7351. function getLiveQueryClient() /*: LiveQueryClient*/{
  7352. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  7353. }
  7354. /**
  7355. * We expose three events to help you monitor the status of the WebSocket connection:
  7356. *
  7357. * <p>Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
  7358. *
  7359. * <pre>
  7360. * Parse.LiveQuery.on('open', () => {
  7361. *
  7362. * });</pre></p>
  7363. *
  7364. * <p>Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
  7365. *
  7366. * <pre>
  7367. * Parse.LiveQuery.on('close', () => {
  7368. *
  7369. * });</pre></p>
  7370. *
  7371. * <p>Error - When some network error or LiveQuery server error happens, you'll get this event.
  7372. *
  7373. * <pre>
  7374. * Parse.LiveQuery.on('error', (error) => {
  7375. *
  7376. * });</pre></p>
  7377. *
  7378. * @class Parse.LiveQuery
  7379. * @static
  7380. */
  7381. var LiveQuery = new _EventEmitter.default();
  7382. /**
  7383. * After open is called, the LiveQuery will try to send a connect request
  7384. * to the LiveQuery server.
  7385. */
  7386. LiveQuery.open = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  7387. var liveQueryClient;
  7388. return _regenerator.default.wrap(function (_context) {
  7389. while (1) switch (_context.prev = _context.next) {
  7390. case 0:
  7391. _context.next = 2;
  7392. return getLiveQueryClient();
  7393. case 2:
  7394. liveQueryClient = _context.sent;
  7395. liveQueryClient.open();
  7396. case 4:
  7397. case "end":
  7398. return _context.stop();
  7399. }
  7400. }, _callee);
  7401. }));
  7402. /**
  7403. * When you're done using LiveQuery, you can call Parse.LiveQuery.close().
  7404. * This function will close the WebSocket connection to the LiveQuery server,
  7405. * cancel the auto reconnect, and unsubscribe all subscriptions based on it.
  7406. * If you call query.subscribe() after this, we'll create a new WebSocket
  7407. * connection to the LiveQuery server.
  7408. */
  7409. LiveQuery.close = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  7410. var liveQueryClient;
  7411. return _regenerator.default.wrap(function (_context2) {
  7412. while (1) switch (_context2.prev = _context2.next) {
  7413. case 0:
  7414. _context2.next = 2;
  7415. return getLiveQueryClient();
  7416. case 2:
  7417. liveQueryClient = _context2.sent;
  7418. liveQueryClient.close();
  7419. case 4:
  7420. case "end":
  7421. return _context2.stop();
  7422. }
  7423. }, _callee2);
  7424. }));
  7425. // Register a default onError callback to make sure we do not crash on error
  7426. LiveQuery.on('error', function () {});
  7427. var _default = LiveQuery;
  7428. exports.default = _default;
  7429. var defaultLiveQueryClient;
  7430. var DefaultLiveQueryController = {
  7431. setDefaultLiveQueryClient: function (liveQueryClient /*: LiveQueryClient*/) {
  7432. defaultLiveQueryClient = liveQueryClient;
  7433. },
  7434. getDefaultLiveQueryClient: function () /*: Promise<LiveQueryClient>*/{
  7435. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  7436. var _yield$Promise$all, _yield$Promise$all2, currentUser, installationId, sessionToken, liveQueryServerURL, serverURL, protocol, host, applicationId, javascriptKey, masterKey;
  7437. return _regenerator.default.wrap(function (_context3) {
  7438. while (1) switch (_context3.prev = _context3.next) {
  7439. case 0:
  7440. if (!defaultLiveQueryClient) {
  7441. _context3.next = 2;
  7442. break;
  7443. }
  7444. return _context3.abrupt("return", defaultLiveQueryClient);
  7445. case 2:
  7446. _context3.next = 4;
  7447. return _promise.default.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);
  7448. case 4:
  7449. _yield$Promise$all = _context3.sent;
  7450. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
  7451. currentUser = _yield$Promise$all2[0];
  7452. installationId = _yield$Promise$all2[1];
  7453. sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
  7454. liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  7455. if (!(liveQueryServerURL && (0, _indexOf.default)(liveQueryServerURL).call(liveQueryServerURL, 'ws') !== 0)) {
  7456. _context3.next = 12;
  7457. break;
  7458. }
  7459. throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
  7460. case 12:
  7461. // If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
  7462. if (!liveQueryServerURL) {
  7463. serverURL = _CoreManager.default.get('SERVER_URL');
  7464. protocol = (0, _indexOf.default)(serverURL).call(serverURL, 'https') === 0 ? 'wss://' : 'ws://';
  7465. host = serverURL.replace(/^https?:\/\//, '');
  7466. liveQueryServerURL = protocol + host;
  7467. _CoreManager.default.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);
  7468. }
  7469. applicationId = _CoreManager.default.get('APPLICATION_ID');
  7470. javascriptKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  7471. masterKey = _CoreManager.default.get('MASTER_KEY');
  7472. defaultLiveQueryClient = new _LiveQueryClient.default({
  7473. applicationId: applicationId,
  7474. serverURL: liveQueryServerURL,
  7475. javascriptKey: javascriptKey,
  7476. masterKey: masterKey,
  7477. sessionToken: sessionToken,
  7478. installationId: installationId
  7479. });
  7480. defaultLiveQueryClient.on('error', function (error) {
  7481. LiveQuery.emit('error', error);
  7482. });
  7483. defaultLiveQueryClient.on('open', function () {
  7484. LiveQuery.emit('open');
  7485. });
  7486. defaultLiveQueryClient.on('close', function () {
  7487. LiveQuery.emit('close');
  7488. });
  7489. return _context3.abrupt("return", defaultLiveQueryClient);
  7490. case 21:
  7491. case "end":
  7492. return _context3.stop();
  7493. }
  7494. }, _callee3);
  7495. }))();
  7496. },
  7497. _clearCachedDefaultClient: function () {
  7498. defaultLiveQueryClient = null;
  7499. }
  7500. };
  7501. _CoreManager.default.setLiveQueryController(DefaultLiveQueryController);
  7502. },{"./CoreManager":4,"./EventEmitter":6,"./LiveQueryClient":11,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/helpers/asyncToGenerator":121,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/slicedToArray":139,"@babel/runtime-corejs3/regenerator":147}],27:[function(_dereq_,module,exports){
  7503. "use strict";
  7504. var _typeof3 = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  7505. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  7506. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  7507. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  7508. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  7509. var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  7510. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  7511. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  7512. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7513. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  7514. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  7515. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  7516. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  7517. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  7518. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  7519. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7520. _Object$defineProperty2(exports, "__esModule", {
  7521. value: true
  7522. });
  7523. exports.default = void 0;
  7524. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  7525. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  7526. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  7527. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  7528. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  7529. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  7530. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  7531. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  7532. var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
  7533. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  7534. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  7535. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  7536. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  7537. var _getPrototypeOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
  7538. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  7539. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  7540. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  7541. var _create = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/create"));
  7542. var _defineProperty3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  7543. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  7544. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  7545. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  7546. var _canBeSerialized = _interopRequireDefault(_dereq_("./canBeSerialized"));
  7547. var _decode = _interopRequireDefault(_dereq_("./decode"));
  7548. var _encode = _interopRequireDefault(_dereq_("./encode"));
  7549. var _escape2 = _interopRequireDefault(_dereq_("./escape"));
  7550. var _EventuallyQueue = _interopRequireDefault(_dereq_("./EventuallyQueue"));
  7551. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  7552. var _parseDate = _interopRequireDefault(_dereq_("./parseDate"));
  7553. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  7554. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  7555. var _promiseUtils = _dereq_("./promiseUtils");
  7556. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  7557. var _ParseOp = _dereq_("./ParseOp");
  7558. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  7559. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  7560. var SingleInstanceStateController = _interopRequireWildcard(_dereq_("./SingleInstanceStateController"));
  7561. var _unique = _interopRequireDefault(_dereq_("./unique"));
  7562. var UniqueInstanceStateController = _interopRequireWildcard(_dereq_("./UniqueInstanceStateController"));
  7563. var _unsavedChildren = _interopRequireDefault(_dereq_("./unsavedChildren"));
  7564. function _getRequireWildcardCache(nodeInterop) {
  7565. if (typeof _WeakMap !== "function") return null;
  7566. var cacheBabelInterop = new _WeakMap();
  7567. var cacheNodeInterop = new _WeakMap();
  7568. return (_getRequireWildcardCache = function (nodeInterop) {
  7569. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  7570. })(nodeInterop);
  7571. }
  7572. function _interopRequireWildcard(obj, nodeInterop) {
  7573. if (!nodeInterop && obj && obj.__esModule) {
  7574. return obj;
  7575. }
  7576. if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") {
  7577. return {
  7578. default: obj
  7579. };
  7580. }
  7581. var cache = _getRequireWildcardCache(nodeInterop);
  7582. if (cache && cache.has(obj)) {
  7583. return cache.get(obj);
  7584. }
  7585. var newObj = {};
  7586. for (var key in obj) {
  7587. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  7588. var desc = _Object$defineProperty2 && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  7589. if (desc && (desc.get || desc.set)) {
  7590. _Object$defineProperty2(newObj, key, desc);
  7591. } else {
  7592. newObj[key] = obj[key];
  7593. }
  7594. }
  7595. }
  7596. newObj.default = obj;
  7597. if (cache) {
  7598. cache.set(obj, newObj);
  7599. }
  7600. return newObj;
  7601. }
  7602. function _createForOfIteratorHelper(o, allowArrayLike) {
  7603. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  7604. if (!it) {
  7605. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  7606. if (it) o = it;
  7607. var i = 0;
  7608. var F = function () {};
  7609. return {
  7610. s: F,
  7611. n: function () {
  7612. if (i >= o.length) return {
  7613. done: true
  7614. };
  7615. return {
  7616. done: false,
  7617. value: o[i++]
  7618. };
  7619. },
  7620. e: function (_e) {
  7621. throw _e;
  7622. },
  7623. f: F
  7624. };
  7625. }
  7626. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  7627. }
  7628. var normalCompletion = true,
  7629. didErr = false,
  7630. err;
  7631. return {
  7632. s: function () {
  7633. it = it.call(o);
  7634. },
  7635. n: function () {
  7636. var step = it.next();
  7637. normalCompletion = step.done;
  7638. return step;
  7639. },
  7640. e: function (_e2) {
  7641. didErr = true;
  7642. err = _e2;
  7643. },
  7644. f: function () {
  7645. try {
  7646. if (!normalCompletion && it.return != null) it.return();
  7647. } finally {
  7648. if (didErr) throw err;
  7649. }
  7650. }
  7651. };
  7652. }
  7653. function _unsupportedIterableToArray(o, minLen) {
  7654. var _context19;
  7655. if (!o) return;
  7656. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  7657. var n = _sliceInstanceProperty(_context19 = Object.prototype.toString.call(o)).call(_context19, 8, -1);
  7658. if (n === "Object" && o.constructor) n = o.constructor.name;
  7659. if (n === "Map" || n === "Set") return _Array$from(o);
  7660. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  7661. }
  7662. function _arrayLikeToArray(arr, len) {
  7663. if (len == null || len > arr.length) len = arr.length;
  7664. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  7665. return arr2;
  7666. }
  7667. function ownKeys(object, enumerableOnly) {
  7668. var keys = _Object$keys2(object);
  7669. if (_Object$getOwnPropertySymbols) {
  7670. var symbols = _Object$getOwnPropertySymbols(object);
  7671. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  7672. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  7673. })), keys.push.apply(keys, symbols);
  7674. }
  7675. return keys;
  7676. }
  7677. function _objectSpread(target) {
  7678. for (var i = 1; i < arguments.length; i++) {
  7679. var _context17, _context18;
  7680. var source = null != arguments[i] ? arguments[i] : {};
  7681. i % 2 ? _forEachInstanceProperty2(_context17 = ownKeys(Object(source), !0)).call(_context17, function (key) {
  7682. (0, _defineProperty2.default)(target, key, source[key]);
  7683. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context18 = ownKeys(Object(source))).call(_context18, function (key) {
  7684. _Object$defineProperty2(target, key, _Object$getOwnPropertyDescriptor(source, key));
  7685. });
  7686. }
  7687. return target;
  7688. } /**
  7689. * @flow
  7690. */
  7691. /*:: import type { AttributeMap, OpsMap } from './ObjectStateMutations';*/
  7692. /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
  7693. var uuidv4 = _dereq_('./uuid');
  7694. /*:: export type Pointer = {
  7695. __type: string,
  7696. className: string,
  7697. objectId: string,
  7698. };*/
  7699. /*:: type SaveParams = {
  7700. method: string,
  7701. path: string,
  7702. body: AttributeMap,
  7703. };*/
  7704. /*:: export type SaveOptions = FullOptions & {
  7705. cascadeSave?: boolean,
  7706. context?: AttributeMap,
  7707. };*/
  7708. // Mapping of class names to constructors, so we can populate objects from the
  7709. // server with appropriate subclasses of ParseObject
  7710. var classMap = {};
  7711. // Global counter for generating unique Ids for non-single-instance objects
  7712. var objectCount = 0;
  7713. // On web clients, objects are single-instance: any two objects with the same Id
  7714. // will have the same attributes. However, this may be dangerous default
  7715. // behavior in a server scenario
  7716. var singleInstance = !_CoreManager.default.get('IS_NODE');
  7717. if (singleInstance) {
  7718. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  7719. } else {
  7720. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  7721. }
  7722. function getServerUrlPath() {
  7723. var serverUrl = _CoreManager.default.get('SERVER_URL');
  7724. if (serverUrl[serverUrl.length - 1] !== '/') {
  7725. serverUrl += '/';
  7726. }
  7727. var url = serverUrl.replace(/https?:\/\//, '');
  7728. return url.substr((0, _indexOf.default)(url).call(url, '/'));
  7729. }
  7730. /**
  7731. * Creates a new model with defined attributes.
  7732. *
  7733. * <p>You won't normally call this method directly. It is recommended that
  7734. * you use a subclass of <code>Parse.Object</code> instead, created by calling
  7735. * <code>extend</code>.</p>
  7736. *
  7737. * <p>However, if you don't want to use a subclass, or aren't sure which
  7738. * subclass is appropriate, you can use this form:<pre>
  7739. * var object = new Parse.Object("ClassName");
  7740. * </pre>
  7741. * That is basically equivalent to:<pre>
  7742. * var MyClass = Parse.Object.extend("ClassName");
  7743. * var object = new MyClass();
  7744. * </pre></p>
  7745. *
  7746. * @alias Parse.Object
  7747. */
  7748. var ParseObject = /*#__PURE__*/function () {
  7749. /**
  7750. * @param {string} className The class name for the object
  7751. * @param {object} attributes The initial set of data to store in the object.
  7752. * @param {object} options The options for this object instance.
  7753. */
  7754. function ParseObject(className /*: ?string | { className: string, [attr: string]: mixed }*/, attributes /*:: ?: { [attr: string]: mixed }*/, options /*:: ?: { ignoreValidation: boolean }*/) {
  7755. (0, _classCallCheck2.default)(this, ParseObject);
  7756. /**
  7757. * The ID of this object, unique within its class.
  7758. *
  7759. * @property {string} id
  7760. */
  7761. (0, _defineProperty2.default)(this, "id", void 0);
  7762. (0, _defineProperty2.default)(this, "_localId", void 0);
  7763. (0, _defineProperty2.default)(this, "_objCount", void 0);
  7764. (0, _defineProperty2.default)(this, "className", void 0);
  7765. // Enable legacy initializers
  7766. if (typeof this.initialize === 'function') {
  7767. this.initialize.apply(this, arguments);
  7768. }
  7769. var toSet = null;
  7770. this._objCount = objectCount++;
  7771. if (typeof className === 'string') {
  7772. this.className = className;
  7773. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  7774. toSet = attributes;
  7775. }
  7776. } else if (className && (0, _typeof2.default)(className) === 'object') {
  7777. this.className = className.className;
  7778. toSet = {};
  7779. for (var _attr in className) {
  7780. if (_attr !== 'className') {
  7781. toSet[_attr] = className[_attr];
  7782. }
  7783. }
  7784. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  7785. options = attributes;
  7786. }
  7787. }
  7788. if (toSet && !this.set(toSet, options)) {
  7789. throw new Error("Can't create an invalid Parse Object");
  7790. }
  7791. }
  7792. (0, _createClass2.default)(ParseObject, [{
  7793. key: "attributes",
  7794. get: /* Prototype getters / setters */
  7795. function () /*: AttributeMap*/{
  7796. var stateController = _CoreManager.default.getObjectStateController();
  7797. return (0, _freeze.default)(stateController.estimateAttributes(this._getStateIdentifier()));
  7798. }
  7799. /**
  7800. * The first time this object was saved on the server.
  7801. *
  7802. * @property {Date} createdAt
  7803. * @returns {Date}
  7804. */
  7805. }, {
  7806. key: "createdAt",
  7807. get: function () /*: ?Date*/{
  7808. return this._getServerData().createdAt;
  7809. }
  7810. /**
  7811. * The last time this object was updated on the server.
  7812. *
  7813. * @property {Date} updatedAt
  7814. * @returns {Date}
  7815. */
  7816. }, {
  7817. key: "updatedAt",
  7818. get: function () /*: ?Date*/{
  7819. return this._getServerData().updatedAt;
  7820. }
  7821. /* Private methods */
  7822. /**
  7823. * Returns a local or server Id used uniquely identify this object
  7824. *
  7825. * @returns {string}
  7826. */
  7827. }, {
  7828. key: "_getId",
  7829. value: function () /*: string*/{
  7830. if (typeof this.id === 'string') {
  7831. return this.id;
  7832. }
  7833. if (typeof this._localId === 'string') {
  7834. return this._localId;
  7835. }
  7836. var localId = 'local' + uuidv4();
  7837. this._localId = localId;
  7838. return localId;
  7839. }
  7840. /**
  7841. * Returns a unique identifier used to pull data from the State Controller.
  7842. *
  7843. * @returns {Parse.Object|object}
  7844. */
  7845. }, {
  7846. key: "_getStateIdentifier",
  7847. value: function () /*: ParseObject | { id: string, className: string }*/{
  7848. if (singleInstance) {
  7849. var id = this.id;
  7850. if (!id) {
  7851. id = this._getId();
  7852. }
  7853. return {
  7854. id: id,
  7855. className: this.className
  7856. };
  7857. } else {
  7858. return this;
  7859. }
  7860. }
  7861. }, {
  7862. key: "_getServerData",
  7863. value: function () /*: AttributeMap*/{
  7864. var stateController = _CoreManager.default.getObjectStateController();
  7865. return stateController.getServerData(this._getStateIdentifier());
  7866. }
  7867. }, {
  7868. key: "_clearServerData",
  7869. value: function () {
  7870. var serverData = this._getServerData();
  7871. var unset = {};
  7872. for (var _attr2 in serverData) {
  7873. unset[_attr2] = undefined;
  7874. }
  7875. var stateController = _CoreManager.default.getObjectStateController();
  7876. stateController.setServerData(this._getStateIdentifier(), unset);
  7877. }
  7878. }, {
  7879. key: "_getPendingOps",
  7880. value: function () /*: Array<OpsMap>*/{
  7881. var stateController = _CoreManager.default.getObjectStateController();
  7882. return stateController.getPendingOps(this._getStateIdentifier());
  7883. }
  7884. /**
  7885. * @param {Array<string>} [keysToClear] - if specified, only ops matching
  7886. * these fields will be cleared
  7887. */
  7888. }, {
  7889. key: "_clearPendingOps",
  7890. value: function (keysToClear /*:: ?: Array<string>*/) {
  7891. var pending = this._getPendingOps();
  7892. var latest = pending[pending.length - 1];
  7893. var keys = keysToClear || (0, _keys.default)(latest);
  7894. (0, _forEach.default)(keys).call(keys, function (key) {
  7895. delete latest[key];
  7896. });
  7897. }
  7898. }, {
  7899. key: "_getDirtyObjectAttributes",
  7900. value: function () /*: AttributeMap*/{
  7901. var attributes = this.attributes;
  7902. var stateController = _CoreManager.default.getObjectStateController();
  7903. var objectCache = stateController.getObjectCache(this._getStateIdentifier());
  7904. var dirty = {};
  7905. for (var _attr3 in attributes) {
  7906. var val = attributes[_attr3];
  7907. if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
  7908. // Due to the way browsers construct maps, the key order will not change
  7909. // unless the object is changed
  7910. try {
  7911. var json = (0, _encode.default)(val, false, true);
  7912. var stringified = (0, _stringify.default)(json);
  7913. if (objectCache[_attr3] !== stringified) {
  7914. dirty[_attr3] = val;
  7915. }
  7916. } catch (e) {
  7917. // Error occurred, possibly by a nested unsaved pointer in a mutable container
  7918. // No matter how it happened, it indicates a change in the attribute
  7919. dirty[_attr3] = val;
  7920. }
  7921. }
  7922. }
  7923. return dirty;
  7924. }
  7925. }, {
  7926. key: "_toFullJSON",
  7927. value: function (seen /*:: ?: Array<any>*/, offline /*:: ?: boolean*/) /*: AttributeMap*/{
  7928. var json /*: { [key: string]: mixed }*/ = this.toJSON(seen, offline);
  7929. json.__type = 'Object';
  7930. json.className = this.className;
  7931. return json;
  7932. }
  7933. }, {
  7934. key: "_getSaveJSON",
  7935. value: function () /*: AttributeMap*/{
  7936. var pending = this._getPendingOps();
  7937. var dirtyObjects = this._getDirtyObjectAttributes();
  7938. var json = {};
  7939. for (var attr in dirtyObjects) {
  7940. var isDotNotation = false;
  7941. for (var i = 0; i < pending.length; i += 1) {
  7942. for (var field in pending[i]) {
  7943. // Dot notation operations are handled later
  7944. if ((0, _includes.default)(field).call(field, '.')) {
  7945. var fieldName = field.split('.')[0];
  7946. if (fieldName === attr) {
  7947. isDotNotation = true;
  7948. break;
  7949. }
  7950. }
  7951. }
  7952. }
  7953. if (!isDotNotation) {
  7954. json[attr] = new _ParseOp.SetOp(dirtyObjects[attr]).toJSON();
  7955. }
  7956. }
  7957. for (attr in pending[0]) {
  7958. json[attr] = pending[0][attr].toJSON();
  7959. }
  7960. return json;
  7961. }
  7962. }, {
  7963. key: "_getSaveParams",
  7964. value: function () /*: SaveParams*/{
  7965. var method = this.id ? 'PUT' : 'POST';
  7966. var body = this._getSaveJSON();
  7967. var path = 'classes/' + this.className;
  7968. if (_CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID')) {
  7969. if (!this.createdAt) {
  7970. method = 'POST';
  7971. body.objectId = this.id;
  7972. } else {
  7973. method = 'PUT';
  7974. path += '/' + this.id;
  7975. }
  7976. } else if (this.id) {
  7977. path += '/' + this.id;
  7978. } else if (this.className === '_User') {
  7979. path = 'users';
  7980. }
  7981. return {
  7982. method: method,
  7983. body: body,
  7984. path: path
  7985. };
  7986. }
  7987. }, {
  7988. key: "_finishFetch",
  7989. value: function (serverData /*: AttributeMap*/) {
  7990. if (!this.id && serverData.objectId) {
  7991. this.id = serverData.objectId;
  7992. }
  7993. var stateController = _CoreManager.default.getObjectStateController();
  7994. stateController.initializeState(this._getStateIdentifier());
  7995. var decoded = {};
  7996. for (var _attr4 in serverData) {
  7997. if (_attr4 === 'ACL') {
  7998. decoded[_attr4] = new _ParseACL.default(serverData[_attr4]);
  7999. } else if (_attr4 !== 'objectId') {
  8000. decoded[_attr4] = (0, _decode.default)(serverData[_attr4]);
  8001. if (decoded[_attr4] instanceof _ParseRelation.default) {
  8002. decoded[_attr4]._ensureParentAndKey(this, _attr4);
  8003. }
  8004. }
  8005. }
  8006. if (decoded.createdAt && typeof decoded.createdAt === 'string') {
  8007. decoded.createdAt = (0, _parseDate.default)(decoded.createdAt);
  8008. }
  8009. if (decoded.updatedAt && typeof decoded.updatedAt === 'string') {
  8010. decoded.updatedAt = (0, _parseDate.default)(decoded.updatedAt);
  8011. }
  8012. if (!decoded.updatedAt && decoded.createdAt) {
  8013. decoded.updatedAt = decoded.createdAt;
  8014. }
  8015. stateController.commitServerChanges(this._getStateIdentifier(), decoded);
  8016. }
  8017. }, {
  8018. key: "_setExisted",
  8019. value: function (existed /*: boolean*/) {
  8020. var stateController = _CoreManager.default.getObjectStateController();
  8021. var state = stateController.getState(this._getStateIdentifier());
  8022. if (state) {
  8023. state.existed = existed;
  8024. }
  8025. }
  8026. }, {
  8027. key: "_migrateId",
  8028. value: function (serverId /*: string*/) {
  8029. if (this._localId && serverId) {
  8030. if (singleInstance) {
  8031. var stateController = _CoreManager.default.getObjectStateController();
  8032. var oldState = stateController.removeState(this._getStateIdentifier());
  8033. this.id = serverId;
  8034. delete this._localId;
  8035. if (oldState) {
  8036. stateController.initializeState(this._getStateIdentifier(), oldState);
  8037. }
  8038. } else {
  8039. this.id = serverId;
  8040. delete this._localId;
  8041. }
  8042. }
  8043. }
  8044. }, {
  8045. key: "_handleSaveResponse",
  8046. value: function (response /*: AttributeMap*/, status /*: number*/) {
  8047. var changes = {};
  8048. var stateController = _CoreManager.default.getObjectStateController();
  8049. var pending = stateController.popPendingState(this._getStateIdentifier());
  8050. for (var attr in pending) {
  8051. if (pending[attr] instanceof _ParseOp.RelationOp) {
  8052. changes[attr] = pending[attr].applyTo(undefined, this, attr);
  8053. } else if (!(attr in response)) {
  8054. // Only SetOps and UnsetOps should not come back with results
  8055. changes[attr] = pending[attr].applyTo(undefined);
  8056. }
  8057. }
  8058. for (attr in response) {
  8059. if ((attr === 'createdAt' || attr === 'updatedAt') && typeof response[attr] === 'string') {
  8060. changes[attr] = (0, _parseDate.default)(response[attr]);
  8061. } else if (attr === 'ACL') {
  8062. changes[attr] = new _ParseACL.default(response[attr]);
  8063. } else if (attr !== 'objectId') {
  8064. var val = (0, _decode.default)(response[attr]);
  8065. if (val && (0, _getPrototypeOf.default)(val) === Object.prototype) {
  8066. changes[attr] = _objectSpread(_objectSpread({}, this.attributes[attr]), val);
  8067. } else {
  8068. changes[attr] = val;
  8069. }
  8070. if (changes[attr] instanceof _ParseOp.UnsetOp) {
  8071. changes[attr] = undefined;
  8072. }
  8073. }
  8074. }
  8075. if (changes.createdAt && !changes.updatedAt) {
  8076. changes.updatedAt = changes.createdAt;
  8077. }
  8078. this._migrateId(response.objectId);
  8079. if (status !== 201) {
  8080. this._setExisted(true);
  8081. }
  8082. stateController.commitServerChanges(this._getStateIdentifier(), changes);
  8083. }
  8084. }, {
  8085. key: "_handleSaveError",
  8086. value: function () {
  8087. var stateController = _CoreManager.default.getObjectStateController();
  8088. stateController.mergeFirstPendingState(this._getStateIdentifier());
  8089. }
  8090. }, {
  8091. key: "initialize",
  8092. value: /* Public methods */
  8093. function () {
  8094. // NOOP
  8095. }
  8096. /**
  8097. * Returns a JSON version of the object suitable for saving to Parse.
  8098. *
  8099. * @param seen
  8100. * @param offline
  8101. * @returns {object}
  8102. */
  8103. }, {
  8104. key: "toJSON",
  8105. value: function (seen /*: Array<any> | void*/, offline /*:: ?: boolean*/) /*: AttributeMap*/{
  8106. var seenEntry = this.id ? this.className + ':' + this.id : this;
  8107. seen = seen || [seenEntry];
  8108. var json = {};
  8109. var attrs = this.attributes;
  8110. for (var _attr5 in attrs) {
  8111. if ((_attr5 === 'createdAt' || _attr5 === 'updatedAt') && attrs[_attr5].toJSON) {
  8112. json[_attr5] = attrs[_attr5].toJSON();
  8113. } else {
  8114. json[_attr5] = (0, _encode.default)(attrs[_attr5], false, false, seen, offline);
  8115. }
  8116. }
  8117. var pending = this._getPendingOps();
  8118. for (var _attr6 in pending[0]) {
  8119. json[_attr6] = pending[0][_attr6].toJSON(offline);
  8120. }
  8121. if (this.id) {
  8122. json.objectId = this.id;
  8123. }
  8124. return json;
  8125. }
  8126. /**
  8127. * Determines whether this ParseObject is equal to another ParseObject
  8128. *
  8129. * @param {object} other - An other object ot compare
  8130. * @returns {boolean}
  8131. */
  8132. }, {
  8133. key: "equals",
  8134. value: function (other /*: mixed*/) /*: boolean*/{
  8135. if (this === other) {
  8136. return true;
  8137. }
  8138. return other instanceof ParseObject && this.className === other.className && this.id === other.id && typeof this.id !== 'undefined';
  8139. }
  8140. /**
  8141. * Returns true if this object has been modified since its last
  8142. * save/refresh. If an attribute is specified, it returns true only if that
  8143. * particular attribute has been modified since the last save/refresh.
  8144. *
  8145. * @param {string} attr An attribute name (optional).
  8146. * @returns {boolean}
  8147. */
  8148. }, {
  8149. key: "dirty",
  8150. value: function (attr /*:: ?: string*/) /*: boolean*/{
  8151. if (!this.id) {
  8152. return true;
  8153. }
  8154. var pendingOps = this._getPendingOps();
  8155. var dirtyObjects = this._getDirtyObjectAttributes();
  8156. if (attr) {
  8157. if (dirtyObjects.hasOwnProperty(attr)) {
  8158. return true;
  8159. }
  8160. for (var i = 0; i < pendingOps.length; i++) {
  8161. if (pendingOps[i].hasOwnProperty(attr)) {
  8162. return true;
  8163. }
  8164. }
  8165. return false;
  8166. }
  8167. if ((0, _keys.default)(pendingOps[0]).length !== 0) {
  8168. return true;
  8169. }
  8170. if ((0, _keys.default)(dirtyObjects).length !== 0) {
  8171. return true;
  8172. }
  8173. return false;
  8174. }
  8175. /**
  8176. * Returns an array of keys that have been modified since last save/refresh
  8177. *
  8178. * @returns {string[]}
  8179. */
  8180. }, {
  8181. key: "dirtyKeys",
  8182. value: function () /*: Array<string>*/{
  8183. var pendingOps = this._getPendingOps();
  8184. var keys = {};
  8185. for (var i = 0; i < pendingOps.length; i++) {
  8186. for (var _attr7 in pendingOps[i]) {
  8187. keys[_attr7] = true;
  8188. }
  8189. }
  8190. var dirtyObjects = this._getDirtyObjectAttributes();
  8191. for (var _attr8 in dirtyObjects) {
  8192. keys[_attr8] = true;
  8193. }
  8194. return (0, _keys.default)(keys);
  8195. }
  8196. /**
  8197. * Returns true if the object has been fetched.
  8198. *
  8199. * @returns {boolean}
  8200. */
  8201. }, {
  8202. key: "isDataAvailable",
  8203. value: function () /*: boolean*/{
  8204. var serverData = this._getServerData();
  8205. return !!(0, _keys.default)(serverData).length;
  8206. }
  8207. /**
  8208. * Gets a Pointer referencing this Object.
  8209. *
  8210. * @returns {Pointer}
  8211. */
  8212. }, {
  8213. key: "toPointer",
  8214. value: function () /*: Pointer*/{
  8215. if (!this.id) {
  8216. throw new Error('Cannot create a pointer to an unsaved ParseObject');
  8217. }
  8218. return {
  8219. __type: 'Pointer',
  8220. className: this.className,
  8221. objectId: this.id
  8222. };
  8223. }
  8224. /**
  8225. * Gets a Pointer referencing this Object.
  8226. *
  8227. * @returns {Pointer}
  8228. */
  8229. }, {
  8230. key: "toOfflinePointer",
  8231. value: function () /*: Pointer*/{
  8232. if (!this._localId) {
  8233. throw new Error('Cannot create a offline pointer to a saved ParseObject');
  8234. }
  8235. return {
  8236. __type: 'Object',
  8237. className: this.className,
  8238. _localId: this._localId
  8239. };
  8240. }
  8241. /**
  8242. * Gets the value of an attribute.
  8243. *
  8244. * @param {string} attr The string name of an attribute.
  8245. * @returns {*}
  8246. */
  8247. }, {
  8248. key: "get",
  8249. value: function (attr /*: string*/) /*: mixed*/{
  8250. return this.attributes[attr];
  8251. }
  8252. /**
  8253. * Gets a relation on the given class for the attribute.
  8254. *
  8255. * @param {string} attr The attribute to get the relation for.
  8256. * @returns {Parse.Relation}
  8257. */
  8258. }, {
  8259. key: "relation",
  8260. value: function (attr /*: string*/) /*: ParseRelation*/{
  8261. var value = this.get(attr);
  8262. if (value) {
  8263. if (!(value instanceof _ParseRelation.default)) {
  8264. throw new Error('Called relation() on non-relation field ' + attr);
  8265. }
  8266. value._ensureParentAndKey(this, attr);
  8267. return value;
  8268. }
  8269. return new _ParseRelation.default(this, attr);
  8270. }
  8271. /**
  8272. * Gets the HTML-escaped value of an attribute.
  8273. *
  8274. * @param {string} attr The string name of an attribute.
  8275. * @returns {string}
  8276. */
  8277. }, {
  8278. key: "escape",
  8279. value: function (attr /*: string*/) /*: string*/{
  8280. var val = this.attributes[attr];
  8281. if (val == null) {
  8282. return '';
  8283. }
  8284. if (typeof val !== 'string') {
  8285. if (typeof val.toString !== 'function') {
  8286. return '';
  8287. }
  8288. val = val.toString();
  8289. }
  8290. return (0, _escape2.default)(val);
  8291. }
  8292. /**
  8293. * Returns <code>true</code> if the attribute contains a value that is not
  8294. * null or undefined.
  8295. *
  8296. * @param {string} attr The string name of the attribute.
  8297. * @returns {boolean}
  8298. */
  8299. }, {
  8300. key: "has",
  8301. value: function (attr /*: string*/) /*: boolean*/{
  8302. var attributes = this.attributes;
  8303. if (attributes.hasOwnProperty(attr)) {
  8304. return attributes[attr] != null;
  8305. }
  8306. return false;
  8307. }
  8308. /**
  8309. * Sets a hash of model attributes on the object.
  8310. *
  8311. * <p>You can call it with an object containing keys and values, with one
  8312. * key and value, or dot notation. For example:<pre>
  8313. * gameTurn.set({
  8314. * player: player1,
  8315. * diceRoll: 2
  8316. * }, {
  8317. * error: function(gameTurnAgain, error) {
  8318. * // The set failed validation.
  8319. * }
  8320. * });
  8321. *
  8322. * game.set("currentPlayer", player2, {
  8323. * error: function(gameTurnAgain, error) {
  8324. * // The set failed validation.
  8325. * }
  8326. * });
  8327. *
  8328. * game.set("finished", true);</pre></p>
  8329. *
  8330. * game.set("player.score", 10);</pre></p>
  8331. *
  8332. * @param {(string|object)} key The key to set.
  8333. * @param {(string|object)} value The value to give it.
  8334. * @param {object} options A set of options for the set.
  8335. * The only supported option is <code>error</code>.
  8336. * @returns {(ParseObject|boolean)} true if the set succeeded.
  8337. */
  8338. }, {
  8339. key: "set",
  8340. value: function (key /*: mixed*/, value /*: mixed*/, options /*:: ?: mixed*/) /*: ParseObject | boolean*/{
  8341. var changes = {};
  8342. var newOps = {};
  8343. if (key && (0, _typeof2.default)(key) === 'object') {
  8344. changes = key;
  8345. options = value;
  8346. } else if (typeof key === 'string') {
  8347. changes[key] = value;
  8348. } else {
  8349. return this;
  8350. }
  8351. options = options || {};
  8352. var readonly = [];
  8353. if (typeof this.constructor.readOnlyAttributes === 'function') {
  8354. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  8355. }
  8356. for (var k in changes) {
  8357. if (k === 'createdAt' || k === 'updatedAt') {
  8358. // This property is read-only, but for legacy reasons we silently
  8359. // ignore it
  8360. continue;
  8361. }
  8362. if ((0, _indexOf.default)(readonly).call(readonly, k) > -1) {
  8363. throw new Error('Cannot modify readonly attribute: ' + k);
  8364. }
  8365. if (options.unset) {
  8366. newOps[k] = new _ParseOp.UnsetOp();
  8367. } else if (changes[k] instanceof _ParseOp.Op) {
  8368. newOps[k] = changes[k];
  8369. } else if (changes[k] && (0, _typeof2.default)(changes[k]) === 'object' && typeof changes[k].__op === 'string') {
  8370. newOps[k] = (0, _ParseOp.opFromJSON)(changes[k]);
  8371. } else if (k === 'objectId' || k === 'id') {
  8372. if (typeof changes[k] === 'string') {
  8373. this.id = changes[k];
  8374. }
  8375. } else if (k === 'ACL' && (0, _typeof2.default)(changes[k]) === 'object' && !(changes[k] instanceof _ParseACL.default)) {
  8376. newOps[k] = new _ParseOp.SetOp(new _ParseACL.default(changes[k]));
  8377. } else if (changes[k] instanceof _ParseRelation.default) {
  8378. var relation = new _ParseRelation.default(this, k);
  8379. relation.targetClassName = changes[k].targetClassName;
  8380. newOps[k] = new _ParseOp.SetOp(relation);
  8381. } else {
  8382. newOps[k] = new _ParseOp.SetOp(changes[k]);
  8383. }
  8384. }
  8385. var currentAttributes = this.attributes;
  8386. // Calculate new values
  8387. var newValues = {};
  8388. for (var _attr9 in newOps) {
  8389. if (newOps[_attr9] instanceof _ParseOp.RelationOp) {
  8390. newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9], this, _attr9);
  8391. } else if (!(newOps[_attr9] instanceof _ParseOp.UnsetOp)) {
  8392. newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9]);
  8393. }
  8394. }
  8395. // Validate changes
  8396. if (!options.ignoreValidation) {
  8397. var validation = this.validate(newValues);
  8398. if (validation) {
  8399. if (typeof options.error === 'function') {
  8400. options.error(this, validation);
  8401. }
  8402. return false;
  8403. }
  8404. }
  8405. // Consolidate Ops
  8406. var pendingOps = this._getPendingOps();
  8407. var last = pendingOps.length - 1;
  8408. var stateController = _CoreManager.default.getObjectStateController();
  8409. for (var _attr10 in newOps) {
  8410. var nextOp = newOps[_attr10].mergeWith(pendingOps[last][_attr10]);
  8411. stateController.setPendingOp(this._getStateIdentifier(), _attr10, nextOp);
  8412. }
  8413. return this;
  8414. }
  8415. /**
  8416. * Remove an attribute from the model. This is a noop if the attribute doesn't
  8417. * exist.
  8418. *
  8419. * @param {string} attr The string name of an attribute.
  8420. * @param options
  8421. * @returns {(ParseObject | boolean)}
  8422. */
  8423. }, {
  8424. key: "unset",
  8425. value: function (attr /*: string*/, options /*:: ?: { [opt: string]: mixed }*/) /*: ParseObject | boolean*/{
  8426. options = options || {};
  8427. options.unset = true;
  8428. return this.set(attr, null, options);
  8429. }
  8430. /**
  8431. * Atomically increments the value of the given attribute the next time the
  8432. * object is saved. If no amount is specified, 1 is used by default.
  8433. *
  8434. * @param attr {String} The key.
  8435. * @param amount {Number} The amount to increment by (optional).
  8436. * @returns {(ParseObject|boolean)}
  8437. */
  8438. }, {
  8439. key: "increment",
  8440. value: function (attr /*: string*/, amount /*:: ?: number*/) /*: ParseObject | boolean*/{
  8441. if (typeof amount === 'undefined') {
  8442. amount = 1;
  8443. }
  8444. if (typeof amount !== 'number') {
  8445. throw new Error('Cannot increment by a non-numeric amount.');
  8446. }
  8447. return this.set(attr, new _ParseOp.IncrementOp(amount));
  8448. }
  8449. /**
  8450. * Atomically decrements the value of the given attribute the next time the
  8451. * object is saved. If no amount is specified, 1 is used by default.
  8452. *
  8453. * @param attr {String} The key.
  8454. * @param amount {Number} The amount to decrement by (optional).
  8455. * @returns {(ParseObject | boolean)}
  8456. */
  8457. }, {
  8458. key: "decrement",
  8459. value: function (attr /*: string*/, amount /*:: ?: number*/) /*: ParseObject | boolean*/{
  8460. if (typeof amount === 'undefined') {
  8461. amount = 1;
  8462. }
  8463. if (typeof amount !== 'number') {
  8464. throw new Error('Cannot decrement by a non-numeric amount.');
  8465. }
  8466. return this.set(attr, new _ParseOp.IncrementOp(amount * -1));
  8467. }
  8468. /**
  8469. * Atomically add an object to the end of the array associated with a given
  8470. * key.
  8471. *
  8472. * @param attr {String} The key.
  8473. * @param item {} The item to add.
  8474. * @returns {(ParseObject | boolean)}
  8475. */
  8476. }, {
  8477. key: "add",
  8478. value: function (attr /*: string*/, item /*: mixed*/) /*: ParseObject | boolean*/{
  8479. return this.set(attr, new _ParseOp.AddOp([item]));
  8480. }
  8481. /**
  8482. * Atomically add the objects to the end of the array associated with a given
  8483. * key.
  8484. *
  8485. * @param attr {String} The key.
  8486. * @param items {Object[]} The items to add.
  8487. * @returns {(ParseObject | boolean)}
  8488. */
  8489. }, {
  8490. key: "addAll",
  8491. value: function (attr /*: string*/, items /*: Array<mixed>*/) /*: ParseObject | boolean*/{
  8492. return this.set(attr, new _ParseOp.AddOp(items));
  8493. }
  8494. /**
  8495. * Atomically add an object to the array associated with a given key, only
  8496. * if it is not already present in the array. The position of the insert is
  8497. * not guaranteed.
  8498. *
  8499. * @param attr {String} The key.
  8500. * @param item {} The object to add.
  8501. * @returns {(ParseObject | boolean)}
  8502. */
  8503. }, {
  8504. key: "addUnique",
  8505. value: function (attr /*: string*/, item /*: mixed*/) /*: ParseObject | boolean*/{
  8506. return this.set(attr, new _ParseOp.AddUniqueOp([item]));
  8507. }
  8508. /**
  8509. * Atomically add the objects to the array associated with a given key, only
  8510. * if it is not already present in the array. The position of the insert is
  8511. * not guaranteed.
  8512. *
  8513. * @param attr {String} The key.
  8514. * @param items {Object[]} The objects to add.
  8515. * @returns {(ParseObject | boolean)}
  8516. */
  8517. }, {
  8518. key: "addAllUnique",
  8519. value: function (attr /*: string*/, items /*: Array<mixed>*/) /*: ParseObject | boolean*/{
  8520. return this.set(attr, new _ParseOp.AddUniqueOp(items));
  8521. }
  8522. /**
  8523. * Atomically remove all instances of an object from the array associated
  8524. * with a given key.
  8525. *
  8526. * @param attr {String} The key.
  8527. * @param item {} The object to remove.
  8528. * @returns {(ParseObject | boolean)}
  8529. */
  8530. }, {
  8531. key: "remove",
  8532. value: function (attr /*: string*/, item /*: mixed*/) /*: ParseObject | boolean*/{
  8533. return this.set(attr, new _ParseOp.RemoveOp([item]));
  8534. }
  8535. /**
  8536. * Atomically remove all instances of the objects from the array associated
  8537. * with a given key.
  8538. *
  8539. * @param attr {String} The key.
  8540. * @param items {Object[]} The object to remove.
  8541. * @returns {(ParseObject | boolean)}
  8542. */
  8543. }, {
  8544. key: "removeAll",
  8545. value: function (attr /*: string*/, items /*: Array<mixed>*/) /*: ParseObject | boolean*/{
  8546. return this.set(attr, new _ParseOp.RemoveOp(items));
  8547. }
  8548. /**
  8549. * Returns an instance of a subclass of Parse.Op describing what kind of
  8550. * modification has been performed on this field since the last time it was
  8551. * saved. For example, after calling object.increment("x"), calling
  8552. * object.op("x") would return an instance of Parse.Op.Increment.
  8553. *
  8554. * @param attr {String} The key.
  8555. * @returns {Parse.Op | undefined} The operation, or undefined if none.
  8556. */
  8557. }, {
  8558. key: "op",
  8559. value: function (attr /*: string*/) /*: ?Op*/{
  8560. var pending = this._getPendingOps();
  8561. for (var i = pending.length; i--;) {
  8562. if (pending[i][attr]) {
  8563. return pending[i][attr];
  8564. }
  8565. }
  8566. }
  8567. /**
  8568. * Creates a new model with identical attributes to this one.
  8569. *
  8570. * @returns {Parse.Object}
  8571. */
  8572. }, {
  8573. key: "clone",
  8574. value: function clone() /*: any*/{
  8575. var clone = new this.constructor(this.className);
  8576. var attributes = this.attributes;
  8577. if (typeof this.constructor.readOnlyAttributes === 'function') {
  8578. var readonly = this.constructor.readOnlyAttributes() || [];
  8579. // Attributes are frozen, so we have to rebuild an object,
  8580. // rather than delete readonly keys
  8581. var copy = {};
  8582. for (var a in attributes) {
  8583. if ((0, _indexOf.default)(readonly).call(readonly, a) < 0) {
  8584. copy[a] = attributes[a];
  8585. }
  8586. }
  8587. attributes = copy;
  8588. }
  8589. if (clone.set) {
  8590. clone.set(attributes);
  8591. }
  8592. return clone;
  8593. }
  8594. /**
  8595. * Creates a new instance of this object. Not to be confused with clone()
  8596. *
  8597. * @returns {Parse.Object}
  8598. */
  8599. }, {
  8600. key: "newInstance",
  8601. value: function () /*: any*/{
  8602. var clone = new this.constructor(this.className);
  8603. clone.id = this.id;
  8604. if (singleInstance) {
  8605. // Just return an object with the right id
  8606. return clone;
  8607. }
  8608. var stateController = _CoreManager.default.getObjectStateController();
  8609. if (stateController) {
  8610. stateController.duplicateState(this._getStateIdentifier(), clone._getStateIdentifier());
  8611. }
  8612. return clone;
  8613. }
  8614. /**
  8615. * Returns true if this object has never been saved to Parse.
  8616. *
  8617. * @returns {boolean}
  8618. */
  8619. }, {
  8620. key: "isNew",
  8621. value: function () /*: boolean*/{
  8622. return !this.id;
  8623. }
  8624. /**
  8625. * Returns true if this object was created by the Parse server when the
  8626. * object might have already been there (e.g. in the case of a Facebook
  8627. * login)
  8628. *
  8629. * @returns {boolean}
  8630. */
  8631. }, {
  8632. key: "existed",
  8633. value: function () /*: boolean*/{
  8634. if (!this.id) {
  8635. return false;
  8636. }
  8637. var stateController = _CoreManager.default.getObjectStateController();
  8638. var state = stateController.getState(this._getStateIdentifier());
  8639. if (state) {
  8640. return state.existed;
  8641. }
  8642. return false;
  8643. }
  8644. /**
  8645. * Returns true if this object exists on the Server
  8646. *
  8647. * @param {object} options
  8648. * Valid options are:<ul>
  8649. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8650. * be used for this request.
  8651. * <li>sessionToken: A valid session token, used for making a request on
  8652. * behalf of a specific user.
  8653. * </ul>
  8654. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object exists.
  8655. */
  8656. }, {
  8657. key: "exists",
  8658. value: function () {
  8659. var _exists = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options /*:: ?: RequestOptions*/) {
  8660. var query;
  8661. return _regenerator.default.wrap(function (_context) {
  8662. while (1) switch (_context.prev = _context.next) {
  8663. case 0:
  8664. if (this.id) {
  8665. _context.next = 2;
  8666. break;
  8667. }
  8668. return _context.abrupt("return", false);
  8669. case 2:
  8670. _context.prev = 2;
  8671. query = new _ParseQuery.default(this.className);
  8672. _context.next = 6;
  8673. return query.get(this.id, options);
  8674. case 6:
  8675. return _context.abrupt("return", true);
  8676. case 9:
  8677. _context.prev = 9;
  8678. _context.t0 = _context["catch"](2);
  8679. if (!(_context.t0.code === _ParseError.default.OBJECT_NOT_FOUND)) {
  8680. _context.next = 13;
  8681. break;
  8682. }
  8683. return _context.abrupt("return", false);
  8684. case 13:
  8685. throw _context.t0;
  8686. case 14:
  8687. case "end":
  8688. return _context.stop();
  8689. }
  8690. }, _callee, this, [[2, 9]]);
  8691. }));
  8692. function exists() {
  8693. return _exists.apply(this, arguments);
  8694. }
  8695. return exists;
  8696. }()
  8697. /**
  8698. * Checks if the model is currently in a valid state.
  8699. *
  8700. * @returns {boolean}
  8701. */
  8702. }, {
  8703. key: "isValid",
  8704. value: function () /*: boolean*/{
  8705. return !this.validate(this.attributes);
  8706. }
  8707. /**
  8708. * You should not call this function directly unless you subclass
  8709. * <code>Parse.Object</code>, in which case you can override this method
  8710. * to provide additional validation on <code>set</code> and
  8711. * <code>save</code>. Your implementation should return
  8712. *
  8713. * @param {object} attrs The current data to validate.
  8714. * @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise.
  8715. * @see Parse.Object#set
  8716. */
  8717. }, {
  8718. key: "validate",
  8719. value: function (attrs /*: AttributeMap*/) /*: ParseError | boolean*/{
  8720. if (attrs.hasOwnProperty('ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
  8721. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'ACL must be a Parse ACL.');
  8722. }
  8723. for (var _key in attrs) {
  8724. if (!/^[A-Za-z][0-9A-Za-z_.]*$/.test(_key)) {
  8725. return new _ParseError.default(_ParseError.default.INVALID_KEY_NAME);
  8726. }
  8727. }
  8728. return false;
  8729. }
  8730. /**
  8731. * Returns the ACL for this object.
  8732. *
  8733. * @returns {Parse.ACL} An instance of Parse.ACL.
  8734. * @see Parse.Object#get
  8735. */
  8736. }, {
  8737. key: "getACL",
  8738. value: function () /*: ?ParseACL*/{
  8739. var acl = this.get('ACL');
  8740. if (acl instanceof _ParseACL.default) {
  8741. return acl;
  8742. }
  8743. return null;
  8744. }
  8745. /**
  8746. * Sets the ACL to be used for this object.
  8747. *
  8748. * @param {Parse.ACL} acl An instance of Parse.ACL.
  8749. * @param {object} options
  8750. * @returns {(ParseObject | boolean)} Whether the set passed validation.
  8751. * @see Parse.Object#set
  8752. */
  8753. }, {
  8754. key: "setACL",
  8755. value: function (acl /*: ParseACL*/, options /*:: ?: mixed*/) /*: ParseObject | boolean*/{
  8756. return this.set('ACL', acl, options);
  8757. }
  8758. /**
  8759. * Clears any (or specific) changes to this object made since the last call to save()
  8760. *
  8761. * @param {string} [keys] - specify which fields to revert
  8762. */
  8763. }, {
  8764. key: "revert",
  8765. value: function () /*: void*/{
  8766. var keysToRevert;
  8767. for (var _len = arguments.length, keys = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
  8768. keys[_key2] = arguments[_key2];
  8769. }
  8770. if (keys.length) {
  8771. keysToRevert = [];
  8772. var _iterator = _createForOfIteratorHelper(keys),
  8773. _step;
  8774. try {
  8775. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8776. var _key3 = _step.value;
  8777. if (typeof _key3 === 'string') {
  8778. keysToRevert.push(_key3);
  8779. } else {
  8780. throw new Error('Parse.Object#revert expects either no, or a list of string, arguments.');
  8781. }
  8782. }
  8783. } catch (err) {
  8784. _iterator.e(err);
  8785. } finally {
  8786. _iterator.f();
  8787. }
  8788. }
  8789. this._clearPendingOps(keysToRevert);
  8790. }
  8791. /**
  8792. * Clears all attributes on a model
  8793. *
  8794. * @returns {(ParseObject | boolean)}
  8795. */
  8796. }, {
  8797. key: "clear",
  8798. value: function () /*: ParseObject | boolean*/{
  8799. var attributes = this.attributes;
  8800. var erasable = {};
  8801. var readonly = ['createdAt', 'updatedAt'];
  8802. if (typeof this.constructor.readOnlyAttributes === 'function') {
  8803. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  8804. }
  8805. for (var _attr11 in attributes) {
  8806. if ((0, _indexOf.default)(readonly).call(readonly, _attr11) < 0) {
  8807. erasable[_attr11] = true;
  8808. }
  8809. }
  8810. return this.set(erasable, {
  8811. unset: true
  8812. });
  8813. }
  8814. /**
  8815. * Fetch the model from the server. If the server's representation of the
  8816. * model differs from its current attributes, they will be overriden.
  8817. *
  8818. * @param {object} options
  8819. * Valid options are:<ul>
  8820. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8821. * be used for this request.
  8822. * <li>sessionToken: A valid session token, used for making a request on
  8823. * behalf of a specific user.
  8824. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  8825. * or an array of array of strings.
  8826. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  8827. * </ul>
  8828. * @returns {Promise} A promise that is fulfilled when the fetch
  8829. * completes.
  8830. */
  8831. }, {
  8832. key: "fetch",
  8833. value: function (options /*: RequestOptions*/) /*: Promise*/{
  8834. options = options || {};
  8835. var fetchOptions = {};
  8836. if (options.hasOwnProperty('useMasterKey')) {
  8837. fetchOptions.useMasterKey = options.useMasterKey;
  8838. }
  8839. if (options.hasOwnProperty('sessionToken')) {
  8840. fetchOptions.sessionToken = options.sessionToken;
  8841. }
  8842. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  8843. fetchOptions.context = options.context;
  8844. }
  8845. if (options.hasOwnProperty('include')) {
  8846. fetchOptions.include = [];
  8847. if ((0, _isArray.default)(options.include)) {
  8848. var _context2;
  8849. (0, _forEach.default)(_context2 = options.include).call(_context2, function (key) {
  8850. if ((0, _isArray.default)(key)) {
  8851. var _context3;
  8852. fetchOptions.include = (0, _concat.default)(_context3 = fetchOptions.include).call(_context3, key);
  8853. } else {
  8854. fetchOptions.include.push(key);
  8855. }
  8856. });
  8857. } else {
  8858. fetchOptions.include.push(options.include);
  8859. }
  8860. }
  8861. var controller = _CoreManager.default.getObjectController();
  8862. return controller.fetch(this, true, fetchOptions);
  8863. }
  8864. /**
  8865. * Fetch the model from the server. If the server's representation of the
  8866. * model differs from its current attributes, they will be overriden.
  8867. *
  8868. * Includes nested Parse.Objects for the provided key. You can use dot
  8869. * notation to specify which fields in the included object are also fetched.
  8870. *
  8871. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  8872. * @param {object} options
  8873. * Valid options are:<ul>
  8874. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8875. * be used for this request.
  8876. * <li>sessionToken: A valid session token, used for making a request on
  8877. * behalf of a specific user.
  8878. * </ul>
  8879. * @returns {Promise} A promise that is fulfilled when the fetch
  8880. * completes.
  8881. */
  8882. }, {
  8883. key: "fetchWithInclude",
  8884. value: function (keys /*: String | Array<string | Array<string>>*/, options /*: RequestOptions*/) /*: Promise*/{
  8885. options = options || {};
  8886. options.include = keys;
  8887. return this.fetch(options);
  8888. }
  8889. /**
  8890. * Saves this object to the server at some unspecified time in the future,
  8891. * even if Parse is currently inaccessible.
  8892. *
  8893. * Use this when you may not have a solid network connection, and don't need to know when the save completes.
  8894. * If there is some problem with the object such that it can't be saved, it will be silently discarded.
  8895. *
  8896. * Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse.
  8897. * They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is
  8898. * available. Objects saved this way will persist even after the app is closed, in which case they will be sent the
  8899. * next time the app is opened.
  8900. *
  8901. * @param {object} [options]
  8902. * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
  8903. * Valid options are:
  8904. * <ul>
  8905. * <li>sessionToken: A valid session token, used for making a request on
  8906. * behalf of a specific user.
  8907. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  8908. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  8909. * </ul>
  8910. * @returns {Promise} A promise that is fulfilled when the save
  8911. * completes.
  8912. */
  8913. }, {
  8914. key: "saveEventually",
  8915. value: function () {
  8916. var _saveEventually = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(options /*: SaveOptions*/) {
  8917. return _regenerator.default.wrap(function (_context4) {
  8918. while (1) switch (_context4.prev = _context4.next) {
  8919. case 0:
  8920. _context4.prev = 0;
  8921. _context4.next = 3;
  8922. return this.save(null, options);
  8923. case 3:
  8924. _context4.next = 11;
  8925. break;
  8926. case 5:
  8927. _context4.prev = 5;
  8928. _context4.t0 = _context4["catch"](0);
  8929. if (!(_context4.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
  8930. _context4.next = 11;
  8931. break;
  8932. }
  8933. _context4.next = 10;
  8934. return _EventuallyQueue.default.save(this, options);
  8935. case 10:
  8936. _EventuallyQueue.default.poll();
  8937. case 11:
  8938. return _context4.abrupt("return", this);
  8939. case 12:
  8940. case "end":
  8941. return _context4.stop();
  8942. }
  8943. }, _callee2, this, [[0, 5]]);
  8944. }));
  8945. function saveEventually() {
  8946. return _saveEventually.apply(this, arguments);
  8947. }
  8948. return saveEventually;
  8949. }()
  8950. /**
  8951. * Set a hash of model attributes, and save the model to the server.
  8952. * updatedAt will be updated when the request returns.
  8953. * You can either call it as:<pre>
  8954. * object.save();</pre>
  8955. * or<pre>
  8956. * object.save(attrs);</pre>
  8957. * or<pre>
  8958. * object.save(null, options);</pre>
  8959. * or<pre>
  8960. * object.save(attrs, options);</pre>
  8961. * or<pre>
  8962. * object.save(key, value);</pre>
  8963. * or<pre>
  8964. * object.save(key, value, options);</pre>
  8965. *
  8966. * Example 1: <pre>
  8967. * gameTurn.save({
  8968. * player: "Jake Cutter",
  8969. * diceRoll: 2
  8970. * }).then(function(gameTurnAgain) {
  8971. * // The save was successful.
  8972. * }, function(error) {
  8973. * // The save failed. Error is an instance of Parse.Error.
  8974. * });</pre>
  8975. *
  8976. * Example 2: <pre>
  8977. * gameTurn.save("player", "Jake Cutter");</pre>
  8978. *
  8979. * @param {string | object | null} [arg1]
  8980. * Valid options are:<ul>
  8981. * <li>`Object` - Key/value pairs to update on the object.</li>
  8982. * <li>`String` Key - Key of attribute to update (requires arg2 to also be string)</li>
  8983. * <li>`null` - Passing null for arg1 allows you to save the object with options passed in arg2.</li>
  8984. * </ul>
  8985. * @param {string | object} [arg2]
  8986. * <ul>
  8987. * <li>`String` Value - If arg1 was passed as a key, arg2 is the value that should be set on that key.</li>
  8988. * <li>`Object` Options - Valid options are:
  8989. * <ul>
  8990. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8991. * be used for this request.
  8992. * <li>sessionToken: A valid session token, used for making a request on
  8993. * behalf of a specific user.
  8994. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  8995. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  8996. * </ul>
  8997. * </li>
  8998. * </ul>
  8999. * @param {object} [arg3]
  9000. * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
  9001. * Valid options are:
  9002. * <ul>
  9003. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  9004. * be used for this request.
  9005. * <li>sessionToken: A valid session token, used for making a request on
  9006. * behalf of a specific user.
  9007. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  9008. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  9009. * </ul>
  9010. * @returns {Promise} A promise that is fulfilled when the save
  9011. * completes.
  9012. */
  9013. }, {
  9014. key: "save",
  9015. value: function (arg1 /*: ?string | { [attr: string]: mixed }*/, arg2 /*: SaveOptions | mixed*/, arg3 /*:: ?: SaveOptions*/) /*: Promise*/{
  9016. var _this = this;
  9017. var attrs;
  9018. var options;
  9019. if ((0, _typeof2.default)(arg1) === 'object' || typeof arg1 === 'undefined') {
  9020. attrs = arg1;
  9021. if ((0, _typeof2.default)(arg2) === 'object') {
  9022. options = arg2;
  9023. }
  9024. } else {
  9025. attrs = {};
  9026. attrs[arg1] = arg2;
  9027. options = arg3;
  9028. }
  9029. if (attrs) {
  9030. var validation = this.validate(attrs);
  9031. if (validation) {
  9032. return _promise.default.reject(validation);
  9033. }
  9034. this.set(attrs, options);
  9035. }
  9036. options = options || {};
  9037. var saveOptions = {};
  9038. if (options.hasOwnProperty('useMasterKey')) {
  9039. saveOptions.useMasterKey = !!options.useMasterKey;
  9040. }
  9041. if (options.hasOwnProperty('sessionToken') && typeof options.sessionToken === 'string') {
  9042. saveOptions.sessionToken = options.sessionToken;
  9043. }
  9044. if (options.hasOwnProperty('installationId') && typeof options.installationId === 'string') {
  9045. saveOptions.installationId = options.installationId;
  9046. }
  9047. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  9048. saveOptions.context = options.context;
  9049. }
  9050. var controller = _CoreManager.default.getObjectController();
  9051. var unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
  9052. return controller.save(unsaved, saveOptions).then(function () {
  9053. return controller.save(_this, saveOptions);
  9054. });
  9055. }
  9056. /**
  9057. * Deletes this object from the server at some unspecified time in the future,
  9058. * even if Parse is currently inaccessible.
  9059. *
  9060. * Use this when you may not have a solid network connection,
  9061. * and don't need to know when the delete completes. If there is some problem with the object
  9062. * such that it can't be deleted, the request will be silently discarded.
  9063. *
  9064. * Delete instructions made with this method will be stored locally in an on-disk cache until they can be transmitted
  9065. * to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection
  9066. * is available. Delete requests will persist even after the app is closed, in which case they will be sent the
  9067. * next time the app is opened.
  9068. *
  9069. * @param {object} [options]
  9070. * Valid options are:<ul>
  9071. * <li>sessionToken: A valid session token, used for making a request on
  9072. * behalf of a specific user.
  9073. * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
  9074. * </ul>
  9075. * @returns {Promise} A promise that is fulfilled when the destroy
  9076. * completes.
  9077. */
  9078. }, {
  9079. key: "destroyEventually",
  9080. value: function () {
  9081. var _destroyEventually = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(options /*: RequestOptions*/) {
  9082. return _regenerator.default.wrap(function (_context5) {
  9083. while (1) switch (_context5.prev = _context5.next) {
  9084. case 0:
  9085. _context5.prev = 0;
  9086. _context5.next = 3;
  9087. return this.destroy(options);
  9088. case 3:
  9089. _context5.next = 11;
  9090. break;
  9091. case 5:
  9092. _context5.prev = 5;
  9093. _context5.t0 = _context5["catch"](0);
  9094. if (!(_context5.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
  9095. _context5.next = 11;
  9096. break;
  9097. }
  9098. _context5.next = 10;
  9099. return _EventuallyQueue.default.destroy(this, options);
  9100. case 10:
  9101. _EventuallyQueue.default.poll();
  9102. case 11:
  9103. return _context5.abrupt("return", this);
  9104. case 12:
  9105. case "end":
  9106. return _context5.stop();
  9107. }
  9108. }, _callee3, this, [[0, 5]]);
  9109. }));
  9110. function destroyEventually() {
  9111. return _destroyEventually.apply(this, arguments);
  9112. }
  9113. return destroyEventually;
  9114. }()
  9115. /**
  9116. * Destroy this model on the server if it was already persisted.
  9117. *
  9118. * @param {object} options
  9119. * Valid options are:<ul>
  9120. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  9121. * be used for this request.
  9122. * <li>sessionToken: A valid session token, used for making a request on
  9123. * behalf of a specific user.
  9124. * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
  9125. * </ul>
  9126. * @returns {Promise} A promise that is fulfilled when the destroy
  9127. * completes.
  9128. */
  9129. }, {
  9130. key: "destroy",
  9131. value: function (options /*: RequestOptions*/) /*: Promise*/{
  9132. options = options || {};
  9133. var destroyOptions = {};
  9134. if (options.hasOwnProperty('useMasterKey')) {
  9135. destroyOptions.useMasterKey = options.useMasterKey;
  9136. }
  9137. if (options.hasOwnProperty('sessionToken')) {
  9138. destroyOptions.sessionToken = options.sessionToken;
  9139. }
  9140. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  9141. destroyOptions.context = options.context;
  9142. }
  9143. if (!this.id) {
  9144. return _promise.default.resolve();
  9145. }
  9146. return _CoreManager.default.getObjectController().destroy(this, destroyOptions);
  9147. }
  9148. /**
  9149. * Asynchronously stores the object and every object it points to in the local datastore,
  9150. * recursively, using a default pin name: _default.
  9151. *
  9152. * If those other objects have not been fetched from Parse, they will not be stored.
  9153. * However, if they have changed data, all the changes will be retained.
  9154. *
  9155. * <pre>
  9156. * await object.pin();
  9157. * </pre>
  9158. *
  9159. * To retrieve object:
  9160. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  9161. *
  9162. * @returns {Promise} A promise that is fulfilled when the pin completes.
  9163. */
  9164. }, {
  9165. key: "pin",
  9166. value: function () /*: Promise<void>*/{
  9167. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  9168. }
  9169. /**
  9170. * Asynchronously removes the object and every object it points to in the local datastore,
  9171. * recursively, using a default pin name: _default.
  9172. *
  9173. * <pre>
  9174. * await object.unPin();
  9175. * </pre>
  9176. *
  9177. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9178. */
  9179. }, {
  9180. key: "unPin",
  9181. value: function () /*: Promise<void>*/{
  9182. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  9183. }
  9184. /**
  9185. * Asynchronously returns if the object is pinned
  9186. *
  9187. * <pre>
  9188. * const isPinned = await object.isPinned();
  9189. * </pre>
  9190. *
  9191. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object is pinned.
  9192. */
  9193. }, {
  9194. key: "isPinned",
  9195. value: function () {
  9196. var _isPinned = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
  9197. var localDatastore, objectKey, pin;
  9198. return _regenerator.default.wrap(function (_context6) {
  9199. while (1) switch (_context6.prev = _context6.next) {
  9200. case 0:
  9201. localDatastore = _CoreManager.default.getLocalDatastore();
  9202. if (localDatastore.isEnabled) {
  9203. _context6.next = 3;
  9204. break;
  9205. }
  9206. return _context6.abrupt("return", _promise.default.reject('Parse.enableLocalDatastore() must be called first'));
  9207. case 3:
  9208. objectKey = localDatastore.getKeyForObject(this);
  9209. _context6.next = 6;
  9210. return localDatastore.fromPinWithName(objectKey);
  9211. case 6:
  9212. pin = _context6.sent;
  9213. return _context6.abrupt("return", pin.length > 0);
  9214. case 8:
  9215. case "end":
  9216. return _context6.stop();
  9217. }
  9218. }, _callee4, this);
  9219. }));
  9220. function isPinned() {
  9221. return _isPinned.apply(this, arguments);
  9222. }
  9223. return isPinned;
  9224. }()
  9225. /**
  9226. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  9227. *
  9228. * If those other objects have not been fetched from Parse, they will not be stored.
  9229. * However, if they have changed data, all the changes will be retained.
  9230. *
  9231. * <pre>
  9232. * await object.pinWithName(name);
  9233. * </pre>
  9234. *
  9235. * To retrieve object:
  9236. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  9237. *
  9238. * @param {string} name Name of Pin.
  9239. * @returns {Promise} A promise that is fulfilled when the pin completes.
  9240. */
  9241. }, {
  9242. key: "pinWithName",
  9243. value: function (name /*: string*/) /*: Promise<void>*/{
  9244. return ParseObject.pinAllWithName(name, [this]);
  9245. }
  9246. /**
  9247. * Asynchronously removes the object and every object it points to in the local datastore, recursively.
  9248. *
  9249. * <pre>
  9250. * await object.unPinWithName(name);
  9251. * </pre>
  9252. *
  9253. * @param {string} name Name of Pin.
  9254. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9255. */
  9256. }, {
  9257. key: "unPinWithName",
  9258. value: function (name /*: string*/) /*: Promise<void>*/{
  9259. return ParseObject.unPinAllWithName(name, [this]);
  9260. }
  9261. /**
  9262. * Asynchronously loads data from the local datastore into this object.
  9263. *
  9264. * <pre>
  9265. * await object.fetchFromLocalDatastore();
  9266. * </pre>
  9267. *
  9268. * You can create an unfetched pointer with <code>Parse.Object.createWithoutData()</code>
  9269. * and then call <code>fetchFromLocalDatastore()</code> on it.
  9270. *
  9271. * @returns {Promise} A promise that is fulfilled when the fetch completes.
  9272. */
  9273. }, {
  9274. key: "fetchFromLocalDatastore",
  9275. value: function () {
  9276. var _fetchFromLocalDatastore = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  9277. var localDatastore, objectKey, pinned, result;
  9278. return _regenerator.default.wrap(function (_context7) {
  9279. while (1) switch (_context7.prev = _context7.next) {
  9280. case 0:
  9281. localDatastore = _CoreManager.default.getLocalDatastore();
  9282. if (localDatastore.isEnabled) {
  9283. _context7.next = 3;
  9284. break;
  9285. }
  9286. throw new Error('Parse.enableLocalDatastore() must be called first');
  9287. case 3:
  9288. objectKey = localDatastore.getKeyForObject(this);
  9289. _context7.next = 6;
  9290. return localDatastore._serializeObject(objectKey);
  9291. case 6:
  9292. pinned = _context7.sent;
  9293. if (pinned) {
  9294. _context7.next = 9;
  9295. break;
  9296. }
  9297. throw new Error('Cannot fetch an unsaved ParseObject');
  9298. case 9:
  9299. result = ParseObject.fromJSON(pinned);
  9300. this._finishFetch(result.toJSON());
  9301. return _context7.abrupt("return", this);
  9302. case 12:
  9303. case "end":
  9304. return _context7.stop();
  9305. }
  9306. }, _callee5, this);
  9307. }));
  9308. function fetchFromLocalDatastore() {
  9309. return _fetchFromLocalDatastore.apply(this, arguments);
  9310. }
  9311. return fetchFromLocalDatastore;
  9312. }() /* Static methods */
  9313. }], [{
  9314. key: "_getClassMap",
  9315. value: function () {
  9316. return classMap;
  9317. }
  9318. }, {
  9319. key: "_clearAllState",
  9320. value: function () {
  9321. var stateController = _CoreManager.default.getObjectStateController();
  9322. stateController.clearAllState();
  9323. }
  9324. /**
  9325. * Fetches the given list of Parse.Object.
  9326. * If any error is encountered, stops and calls the error handler.
  9327. *
  9328. * <pre>
  9329. * Parse.Object.fetchAll([object1, object2, ...])
  9330. * .then((list) => {
  9331. * // All the objects were fetched.
  9332. * }, (error) => {
  9333. * // An error occurred while fetching one of the objects.
  9334. * });
  9335. * </pre>
  9336. *
  9337. * @param {Array} list A list of <code>Parse.Object</code>.
  9338. * @param {object} options
  9339. * Valid options are:<ul>
  9340. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  9341. * be used for this request.
  9342. * <li>sessionToken: A valid session token, used for making a request on
  9343. * behalf of a specific user.
  9344. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  9345. * or an array of array of strings.
  9346. * </ul>
  9347. * @static
  9348. * @returns {Parse.Object[]}
  9349. */
  9350. }, {
  9351. key: "fetchAll",
  9352. value: function (list /*: Array<ParseObject>*/) {
  9353. var options /*: RequestOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  9354. var queryOptions = {};
  9355. if (options.hasOwnProperty('useMasterKey')) {
  9356. queryOptions.useMasterKey = options.useMasterKey;
  9357. }
  9358. if (options.hasOwnProperty('sessionToken')) {
  9359. queryOptions.sessionToken = options.sessionToken;
  9360. }
  9361. if (options.hasOwnProperty('include')) {
  9362. queryOptions.include = ParseObject.handleIncludeOptions(options);
  9363. }
  9364. return _CoreManager.default.getObjectController().fetch(list, true, queryOptions);
  9365. }
  9366. /**
  9367. * Fetches the given list of Parse.Object.
  9368. *
  9369. * Includes nested Parse.Objects for the provided key. You can use dot
  9370. * notation to specify which fields in the included object are also fetched.
  9371. *
  9372. * If any error is encountered, stops and calls the error handler.
  9373. *
  9374. * <pre>
  9375. * Parse.Object.fetchAllWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  9376. * .then((list) => {
  9377. * // All the objects were fetched.
  9378. * }, (error) => {
  9379. * // An error occurred while fetching one of the objects.
  9380. * });
  9381. * </pre>
  9382. *
  9383. * @param {Array} list A list of <code>Parse.Object</code>.
  9384. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  9385. * @param {object} options
  9386. * Valid options are:<ul>
  9387. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  9388. * be used for this request.
  9389. * <li>sessionToken: A valid session token, used for making a request on
  9390. * behalf of a specific user.
  9391. * </ul>
  9392. * @static
  9393. * @returns {Parse.Object[]}
  9394. */
  9395. }, {
  9396. key: "fetchAllWithInclude",
  9397. value: function (list /*: Array<ParseObject>*/, keys /*: String | Array<string | Array<string>>*/, options /*: RequestOptions*/) {
  9398. options = options || {};
  9399. options.include = keys;
  9400. return ParseObject.fetchAll(list, options);
  9401. }
  9402. /**
  9403. * Fetches the given list of Parse.Object if needed.
  9404. * If any error is encountered, stops and calls the error handler.
  9405. *
  9406. * Includes nested Parse.Objects for the provided key. You can use dot
  9407. * notation to specify which fields in the included object are also fetched.
  9408. *
  9409. * If any error is encountered, stops and calls the error handler.
  9410. *
  9411. * <pre>
  9412. * Parse.Object.fetchAllIfNeededWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  9413. * .then((list) => {
  9414. * // All the objects were fetched.
  9415. * }, (error) => {
  9416. * // An error occurred while fetching one of the objects.
  9417. * });
  9418. * </pre>
  9419. *
  9420. * @param {Array} list A list of <code>Parse.Object</code>.
  9421. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  9422. * @param {object} options
  9423. * Valid options are:<ul>
  9424. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  9425. * be used for this request.
  9426. * <li>sessionToken: A valid session token, used for making a request on
  9427. * behalf of a specific user.
  9428. * </ul>
  9429. * @static
  9430. * @returns {Parse.Object[]}
  9431. */
  9432. }, {
  9433. key: "fetchAllIfNeededWithInclude",
  9434. value: function (list /*: Array<ParseObject>*/, keys /*: String | Array<string | Array<string>>*/, options /*: RequestOptions*/) {
  9435. options = options || {};
  9436. options.include = keys;
  9437. return ParseObject.fetchAllIfNeeded(list, options);
  9438. }
  9439. /**
  9440. * Fetches the given list of Parse.Object if needed.
  9441. * If any error is encountered, stops and calls the error handler.
  9442. *
  9443. * <pre>
  9444. * Parse.Object.fetchAllIfNeeded([object1, ...])
  9445. * .then((list) => {
  9446. * // Objects were fetched and updated.
  9447. * }, (error) => {
  9448. * // An error occurred while fetching one of the objects.
  9449. * });
  9450. * </pre>
  9451. *
  9452. * @param {Array} list A list of <code>Parse.Object</code>.
  9453. * @param {object} options
  9454. * @static
  9455. * @returns {Parse.Object[]}
  9456. */
  9457. }, {
  9458. key: "fetchAllIfNeeded",
  9459. value: function (list /*: Array<ParseObject>*/, options) {
  9460. options = options || {};
  9461. var queryOptions = {};
  9462. if (options.hasOwnProperty('useMasterKey')) {
  9463. queryOptions.useMasterKey = options.useMasterKey;
  9464. }
  9465. if (options.hasOwnProperty('sessionToken')) {
  9466. queryOptions.sessionToken = options.sessionToken;
  9467. }
  9468. if (options.hasOwnProperty('include')) {
  9469. queryOptions.include = ParseObject.handleIncludeOptions(options);
  9470. }
  9471. return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
  9472. }
  9473. }, {
  9474. key: "handleIncludeOptions",
  9475. value: function (options) {
  9476. var include = [];
  9477. if ((0, _isArray.default)(options.include)) {
  9478. var _context8;
  9479. (0, _forEach.default)(_context8 = options.include).call(_context8, function (key) {
  9480. if ((0, _isArray.default)(key)) {
  9481. include = (0, _concat.default)(include).call(include, key);
  9482. } else {
  9483. include.push(key);
  9484. }
  9485. });
  9486. } else {
  9487. include.push(options.include);
  9488. }
  9489. return include;
  9490. }
  9491. /**
  9492. * Destroy the given list of models on the server if it was already persisted.
  9493. *
  9494. * <p>Unlike saveAll, if an error occurs while deleting an individual model,
  9495. * this method will continue trying to delete the rest of the models if
  9496. * possible, except in the case of a fatal error like a connection error.
  9497. *
  9498. * <p>In particular, the Parse.Error object returned in the case of error may
  9499. * be one of two types:
  9500. *
  9501. * <ul>
  9502. * <li>A Parse.Error.AGGREGATE_ERROR. This object's "errors" property is an
  9503. * array of other Parse.Error objects. Each error object in this array
  9504. * has an "object" property that references the object that could not be
  9505. * deleted (for instance, because that object could not be found).</li>
  9506. * <li>A non-aggregate Parse.Error. This indicates a serious error that
  9507. * caused the delete operation to be aborted partway through (for
  9508. * instance, a connection failure in the middle of the delete).</li>
  9509. * </ul>
  9510. *
  9511. * <pre>
  9512. * Parse.Object.destroyAll([object1, object2, ...])
  9513. * .then((list) => {
  9514. * // All the objects were deleted.
  9515. * }, (error) => {
  9516. * // An error occurred while deleting one or more of the objects.
  9517. * // If this is an aggregate error, then we can inspect each error
  9518. * // object individually to determine the reason why a particular
  9519. * // object was not deleted.
  9520. * if (error.code === Parse.Error.AGGREGATE_ERROR) {
  9521. * for (var i = 0; i < error.errors.length; i++) {
  9522. * console.log("Couldn't delete " + error.errors[i].object.id +
  9523. * "due to " + error.errors[i].message);
  9524. * }
  9525. * } else {
  9526. * console.log("Delete aborted because of " + error.message);
  9527. * }
  9528. * });
  9529. * </pre>
  9530. *
  9531. * @param {Array} list A list of <code>Parse.Object</code>.
  9532. * @param {object} options
  9533. * @static
  9534. * @returns {Promise} A promise that is fulfilled when the destroyAll
  9535. * completes.
  9536. */
  9537. }, {
  9538. key: "destroyAll",
  9539. value: function (list /*: Array<ParseObject>*/) {
  9540. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  9541. var destroyOptions = {};
  9542. if (options.hasOwnProperty('useMasterKey')) {
  9543. destroyOptions.useMasterKey = options.useMasterKey;
  9544. }
  9545. if (options.hasOwnProperty('sessionToken')) {
  9546. destroyOptions.sessionToken = options.sessionToken;
  9547. }
  9548. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  9549. destroyOptions.batchSize = options.batchSize;
  9550. }
  9551. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  9552. destroyOptions.context = options.context;
  9553. }
  9554. return _CoreManager.default.getObjectController().destroy(list, destroyOptions);
  9555. }
  9556. /**
  9557. * Saves the given list of Parse.Object.
  9558. * If any error is encountered, stops and calls the error handler.
  9559. *
  9560. * <pre>
  9561. * Parse.Object.saveAll([object1, object2, ...])
  9562. * .then((list) => {
  9563. * // All the objects were saved.
  9564. * }, (error) => {
  9565. * // An error occurred while saving one of the objects.
  9566. * });
  9567. * </pre>
  9568. *
  9569. * @param {Array} list A list of <code>Parse.Object</code>.
  9570. * @param {object} options
  9571. * @static
  9572. * @returns {Parse.Object[]}
  9573. */
  9574. }, {
  9575. key: "saveAll",
  9576. value: function (list /*: Array<ParseObject>*/) {
  9577. var options /*: RequestOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  9578. var saveOptions = {};
  9579. if (options.hasOwnProperty('useMasterKey')) {
  9580. saveOptions.useMasterKey = options.useMasterKey;
  9581. }
  9582. if (options.hasOwnProperty('sessionToken')) {
  9583. saveOptions.sessionToken = options.sessionToken;
  9584. }
  9585. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  9586. saveOptions.batchSize = options.batchSize;
  9587. }
  9588. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  9589. saveOptions.context = options.context;
  9590. }
  9591. return _CoreManager.default.getObjectController().save(list, saveOptions);
  9592. }
  9593. /**
  9594. * Creates a reference to a subclass of Parse.Object with the given id. This
  9595. * does not exist on Parse.Object, only on subclasses.
  9596. *
  9597. * <p>A shortcut for: <pre>
  9598. * var Foo = Parse.Object.extend("Foo");
  9599. * var pointerToFoo = new Foo();
  9600. * pointerToFoo.id = "myObjectId";
  9601. * </pre>
  9602. *
  9603. * @param {string} id The ID of the object to create a reference to.
  9604. * @static
  9605. * @returns {Parse.Object} A Parse.Object reference.
  9606. */
  9607. }, {
  9608. key: "createWithoutData",
  9609. value: function (id /*: string*/) {
  9610. var obj = new this();
  9611. obj.id = id;
  9612. return obj;
  9613. }
  9614. /**
  9615. * Creates a new instance of a Parse Object from a JSON representation.
  9616. *
  9617. * @param {object} json The JSON map of the Object's data
  9618. * @param {boolean} override In single instance mode, all old server data
  9619. * is overwritten if this is set to true
  9620. * @param {boolean} dirty Whether the Parse.Object should set JSON keys to dirty
  9621. * @static
  9622. * @returns {Parse.Object} A Parse.Object reference
  9623. */
  9624. }, {
  9625. key: "fromJSON",
  9626. value: function (json /*: any*/, override /*:: ?: boolean*/, dirty /*:: ?: boolean*/) {
  9627. if (!json.className) {
  9628. throw new Error('Cannot create an object without a className');
  9629. }
  9630. var constructor = classMap[json.className];
  9631. var o = constructor ? new constructor(json.className) : new ParseObject(json.className);
  9632. var otherAttributes = {};
  9633. for (var _attr12 in json) {
  9634. if (_attr12 !== 'className' && _attr12 !== '__type') {
  9635. otherAttributes[_attr12] = json[_attr12];
  9636. if (dirty) {
  9637. o.set(_attr12, json[_attr12]);
  9638. }
  9639. }
  9640. }
  9641. if (override) {
  9642. // id needs to be set before clearServerData can work
  9643. if (otherAttributes.objectId) {
  9644. o.id = otherAttributes.objectId;
  9645. }
  9646. var preserved = null;
  9647. if (typeof o._preserveFieldsOnFetch === 'function') {
  9648. preserved = o._preserveFieldsOnFetch();
  9649. }
  9650. o._clearServerData();
  9651. if (preserved) {
  9652. o._finishFetch(preserved);
  9653. }
  9654. }
  9655. o._finishFetch(otherAttributes);
  9656. if (json.objectId) {
  9657. o._setExisted(true);
  9658. }
  9659. return o;
  9660. }
  9661. /**
  9662. * Registers a subclass of Parse.Object with a specific class name.
  9663. * When objects of that class are retrieved from a query, they will be
  9664. * instantiated with this subclass.
  9665. * This is only necessary when using ES6 subclassing.
  9666. *
  9667. * @param {string} className The class name of the subclass
  9668. * @param {Function} constructor The subclass
  9669. */
  9670. }, {
  9671. key: "registerSubclass",
  9672. value: function (className /*: string*/, constructor /*: any*/) {
  9673. if (typeof className !== 'string') {
  9674. throw new TypeError('The first argument must be a valid class name.');
  9675. }
  9676. if (typeof constructor === 'undefined') {
  9677. throw new TypeError('You must supply a subclass constructor.');
  9678. }
  9679. if (typeof constructor !== 'function') {
  9680. throw new TypeError('You must register the subclass constructor. ' + 'Did you attempt to register an instance of the subclass?');
  9681. }
  9682. classMap[className] = constructor;
  9683. if (!constructor.className) {
  9684. constructor.className = className;
  9685. }
  9686. }
  9687. /**
  9688. * Unegisters a subclass of Parse.Object with a specific class name.
  9689. *
  9690. * @param {string} className The class name of the subclass
  9691. */
  9692. }, {
  9693. key: "unregisterSubclass",
  9694. value: function (className /*: string*/) {
  9695. if (typeof className !== 'string') {
  9696. throw new TypeError('The first argument must be a valid class name.');
  9697. }
  9698. delete classMap[className];
  9699. }
  9700. /**
  9701. * Creates a new subclass of Parse.Object for the given Parse class name.
  9702. *
  9703. * <p>Every extension of a Parse class will inherit from the most recent
  9704. * previous extension of that class. When a Parse.Object is automatically
  9705. * created by parsing JSON, it will use the most recent extension of that
  9706. * class.</p>
  9707. *
  9708. * <p>You should call either:<pre>
  9709. * var MyClass = Parse.Object.extend("MyClass", {
  9710. * <i>Instance methods</i>,
  9711. * initialize: function(attrs, options) {
  9712. * this.someInstanceProperty = [],
  9713. * <i>Other instance properties</i>
  9714. * }
  9715. * }, {
  9716. * <i>Class properties</i>
  9717. * });</pre>
  9718. * or, for Backbone compatibility:<pre>
  9719. * var MyClass = Parse.Object.extend({
  9720. * className: "MyClass",
  9721. * <i>Instance methods</i>,
  9722. * initialize: function(attrs, options) {
  9723. * this.someInstanceProperty = [],
  9724. * <i>Other instance properties</i>
  9725. * }
  9726. * }, {
  9727. * <i>Class properties</i>
  9728. * });</pre></p>
  9729. *
  9730. * @param {string} className The name of the Parse class backing this model.
  9731. * @param {object} protoProps Instance properties to add to instances of the
  9732. * class returned from this method.
  9733. * @param {object} classProps Class properties to add the class returned from
  9734. * this method.
  9735. * @returns {Parse.Object} A new subclass of Parse.Object.
  9736. */
  9737. }, {
  9738. key: "extend",
  9739. value: function (className /*: any*/, protoProps /*: any*/, classProps /*: any*/) {
  9740. if (typeof className !== 'string') {
  9741. if (className && typeof className.className === 'string') {
  9742. return ParseObject.extend(className.className, className, protoProps);
  9743. } else {
  9744. throw new Error("Parse.Object.extend's first argument should be the className.");
  9745. }
  9746. }
  9747. var adjustedClassName = className;
  9748. if (adjustedClassName === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  9749. adjustedClassName = '_User';
  9750. }
  9751. var parentProto = ParseObject.prototype;
  9752. if (this.hasOwnProperty('__super__') && this.__super__) {
  9753. parentProto = this.prototype;
  9754. }
  9755. var ParseObjectSubclass = function (attributes, options) {
  9756. this.className = adjustedClassName;
  9757. this._objCount = objectCount++;
  9758. // Enable legacy initializers
  9759. if (typeof this.initialize === 'function') {
  9760. this.initialize.apply(this, arguments);
  9761. }
  9762. if (this._initializers) {
  9763. var _iterator2 = _createForOfIteratorHelper(this._initializers),
  9764. _step2;
  9765. try {
  9766. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  9767. var initializer = _step2.value;
  9768. initializer.apply(this, arguments);
  9769. }
  9770. } catch (err) {
  9771. _iterator2.e(err);
  9772. } finally {
  9773. _iterator2.f();
  9774. }
  9775. }
  9776. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  9777. if (!this.set(attributes || {}, options)) {
  9778. throw new Error("Can't create an invalid Parse Object");
  9779. }
  9780. }
  9781. };
  9782. if (classMap[adjustedClassName]) {
  9783. ParseObjectSubclass = classMap[adjustedClassName];
  9784. } else {
  9785. ParseObjectSubclass.extend = function (name, protoProps, classProps) {
  9786. if (typeof name === 'string') {
  9787. return ParseObject.extend.call(ParseObjectSubclass, name, protoProps, classProps);
  9788. }
  9789. return ParseObject.extend.call(ParseObjectSubclass, adjustedClassName, name, protoProps);
  9790. };
  9791. ParseObjectSubclass.createWithoutData = ParseObject.createWithoutData;
  9792. ParseObjectSubclass.className = adjustedClassName;
  9793. ParseObjectSubclass.__super__ = parentProto;
  9794. ParseObjectSubclass.prototype = (0, _create.default)(parentProto, {
  9795. constructor: {
  9796. value: ParseObjectSubclass,
  9797. enumerable: false,
  9798. writable: true,
  9799. configurable: true
  9800. }
  9801. });
  9802. }
  9803. if (protoProps) {
  9804. for (var prop in protoProps) {
  9805. if (prop === 'initialize') {
  9806. var _context9;
  9807. (0, _defineProperty3.default)(ParseObjectSubclass.prototype, '_initializers', {
  9808. value: (0, _concat.default)(_context9 = []).call(_context9, (0, _toConsumableArray2.default)(ParseObjectSubclass.prototype._initializers || []), [protoProps[prop]]),
  9809. enumerable: false,
  9810. writable: true,
  9811. configurable: true
  9812. });
  9813. continue;
  9814. }
  9815. if (prop !== 'className') {
  9816. (0, _defineProperty3.default)(ParseObjectSubclass.prototype, prop, {
  9817. value: protoProps[prop],
  9818. enumerable: false,
  9819. writable: true,
  9820. configurable: true
  9821. });
  9822. }
  9823. }
  9824. }
  9825. if (classProps) {
  9826. for (var _prop in classProps) {
  9827. if (_prop !== 'className') {
  9828. (0, _defineProperty3.default)(ParseObjectSubclass, _prop, {
  9829. value: classProps[_prop],
  9830. enumerable: false,
  9831. writable: true,
  9832. configurable: true
  9833. });
  9834. }
  9835. }
  9836. }
  9837. classMap[adjustedClassName] = ParseObjectSubclass;
  9838. return ParseObjectSubclass;
  9839. }
  9840. /**
  9841. * Enable single instance objects, where any local objects with the same Id
  9842. * share the same attributes, and stay synchronized with each other.
  9843. * This is disabled by default in server environments, since it can lead to
  9844. * security issues.
  9845. *
  9846. * @static
  9847. */
  9848. }, {
  9849. key: "enableSingleInstance",
  9850. value: function () {
  9851. singleInstance = true;
  9852. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  9853. }
  9854. /**
  9855. * Disable single instance objects, where any local objects with the same Id
  9856. * share the same attributes, and stay synchronized with each other.
  9857. * When disabled, you can have two instances of the same object in memory
  9858. * without them sharing attributes.
  9859. *
  9860. * @static
  9861. */
  9862. }, {
  9863. key: "disableSingleInstance",
  9864. value: function () {
  9865. singleInstance = false;
  9866. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  9867. }
  9868. /**
  9869. * Asynchronously stores the objects and every object they point to in the local datastore,
  9870. * recursively, using a default pin name: _default.
  9871. *
  9872. * If those other objects have not been fetched from Parse, they will not be stored.
  9873. * However, if they have changed data, all the changes will be retained.
  9874. *
  9875. * <pre>
  9876. * await Parse.Object.pinAll([...]);
  9877. * </pre>
  9878. *
  9879. * To retrieve object:
  9880. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  9881. *
  9882. * @param {Array} objects A list of <code>Parse.Object</code>.
  9883. * @returns {Promise} A promise that is fulfilled when the pin completes.
  9884. * @static
  9885. */
  9886. }, {
  9887. key: "pinAll",
  9888. value: function (objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
  9889. var localDatastore = _CoreManager.default.getLocalDatastore();
  9890. if (!localDatastore.isEnabled) {
  9891. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  9892. }
  9893. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  9894. }
  9895. /**
  9896. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  9897. *
  9898. * If those other objects have not been fetched from Parse, they will not be stored.
  9899. * However, if they have changed data, all the changes will be retained.
  9900. *
  9901. * <pre>
  9902. * await Parse.Object.pinAllWithName(name, [obj1, obj2, ...]);
  9903. * </pre>
  9904. *
  9905. * To retrieve object:
  9906. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  9907. *
  9908. * @param {string} name Name of Pin.
  9909. * @param {Array} objects A list of <code>Parse.Object</code>.
  9910. * @returns {Promise} A promise that is fulfilled when the pin completes.
  9911. * @static
  9912. */
  9913. }, {
  9914. key: "pinAllWithName",
  9915. value: function (name /*: string*/, objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
  9916. var localDatastore = _CoreManager.default.getLocalDatastore();
  9917. if (!localDatastore.isEnabled) {
  9918. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  9919. }
  9920. return localDatastore._handlePinAllWithName(name, objects);
  9921. }
  9922. /**
  9923. * Asynchronously removes the objects and every object they point to in the local datastore,
  9924. * recursively, using a default pin name: _default.
  9925. *
  9926. * <pre>
  9927. * await Parse.Object.unPinAll([...]);
  9928. * </pre>
  9929. *
  9930. * @param {Array} objects A list of <code>Parse.Object</code>.
  9931. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9932. * @static
  9933. */
  9934. }, {
  9935. key: "unPinAll",
  9936. value: function (objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
  9937. var localDatastore = _CoreManager.default.getLocalDatastore();
  9938. if (!localDatastore.isEnabled) {
  9939. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  9940. }
  9941. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  9942. }
  9943. /**
  9944. * Asynchronously removes the objects and every object they point to in the local datastore, recursively.
  9945. *
  9946. * <pre>
  9947. * await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
  9948. * </pre>
  9949. *
  9950. * @param {string} name Name of Pin.
  9951. * @param {Array} objects A list of <code>Parse.Object</code>.
  9952. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9953. * @static
  9954. */
  9955. }, {
  9956. key: "unPinAllWithName",
  9957. value: function (name /*: string*/, objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
  9958. var localDatastore = _CoreManager.default.getLocalDatastore();
  9959. if (!localDatastore.isEnabled) {
  9960. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  9961. }
  9962. return localDatastore._handleUnPinAllWithName(name, objects);
  9963. }
  9964. /**
  9965. * Asynchronously removes all objects in the local datastore using a default pin name: _default.
  9966. *
  9967. * <pre>
  9968. * await Parse.Object.unPinAllObjects();
  9969. * </pre>
  9970. *
  9971. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9972. * @static
  9973. */
  9974. }, {
  9975. key: "unPinAllObjects",
  9976. value: function () /*: Promise<void>*/{
  9977. var localDatastore = _CoreManager.default.getLocalDatastore();
  9978. if (!localDatastore.isEnabled) {
  9979. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  9980. }
  9981. return localDatastore.unPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  9982. }
  9983. /**
  9984. * Asynchronously removes all objects with the specified pin name.
  9985. * Deletes the pin name also.
  9986. *
  9987. * <pre>
  9988. * await Parse.Object.unPinAllObjectsWithName(name);
  9989. * </pre>
  9990. *
  9991. * @param {string} name Name of Pin.
  9992. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9993. * @static
  9994. */
  9995. }, {
  9996. key: "unPinAllObjectsWithName",
  9997. value: function (name /*: string*/) /*: Promise<void>*/{
  9998. var localDatastore = _CoreManager.default.getLocalDatastore();
  9999. if (!localDatastore.isEnabled) {
  10000. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  10001. }
  10002. return localDatastore.unPinWithName(_LocalDatastoreUtils.PIN_PREFIX + name);
  10003. }
  10004. }]);
  10005. return ParseObject;
  10006. }();
  10007. var DefaultController = {
  10008. fetch: function (target /*: ParseObject | Array<ParseObject>*/, forceFetch /*: boolean*/, options /*: RequestOptions*/) /*: Promise<Array<void> | ParseObject>*/{
  10009. var localDatastore = _CoreManager.default.getLocalDatastore();
  10010. if ((0, _isArray.default)(target)) {
  10011. if (target.length < 1) {
  10012. return _promise.default.resolve([]);
  10013. }
  10014. var objs = [];
  10015. var ids = [];
  10016. var className = null;
  10017. var results = [];
  10018. var error = null;
  10019. (0, _forEach.default)(target).call(target, function (el) {
  10020. if (error) {
  10021. return;
  10022. }
  10023. if (!className) {
  10024. className = el.className;
  10025. }
  10026. if (className !== el.className) {
  10027. error = new _ParseError.default(_ParseError.default.INVALID_CLASS_NAME, 'All objects should be of the same class');
  10028. }
  10029. if (!el.id) {
  10030. error = new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'All objects must have an ID');
  10031. }
  10032. if (forceFetch || !el.isDataAvailable()) {
  10033. ids.push(el.id);
  10034. objs.push(el);
  10035. }
  10036. results.push(el);
  10037. });
  10038. if (error) {
  10039. return _promise.default.reject(error);
  10040. }
  10041. var query = new _ParseQuery.default(className);
  10042. query.containedIn('objectId', ids);
  10043. if (options && options.include) {
  10044. query.include(options.include);
  10045. }
  10046. query._limit = ids.length;
  10047. return (0, _find.default)(query).call(query, options).then( /*#__PURE__*/function () {
  10048. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(objects) {
  10049. var idMap, i, obj, _i, _obj, id, _i2, _results, object;
  10050. return _regenerator.default.wrap(function (_context10) {
  10051. while (1) switch (_context10.prev = _context10.next) {
  10052. case 0:
  10053. idMap = {};
  10054. (0, _forEach.default)(objects).call(objects, function (o) {
  10055. idMap[o.id] = o;
  10056. });
  10057. i = 0;
  10058. case 3:
  10059. if (!(i < objs.length)) {
  10060. _context10.next = 11;
  10061. break;
  10062. }
  10063. obj = objs[i];
  10064. if (!(!obj || !obj.id || !idMap[obj.id])) {
  10065. _context10.next = 8;
  10066. break;
  10067. }
  10068. if (!forceFetch) {
  10069. _context10.next = 8;
  10070. break;
  10071. }
  10072. return _context10.abrupt("return", _promise.default.reject(new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'All objects must exist on the server.')));
  10073. case 8:
  10074. i++;
  10075. _context10.next = 3;
  10076. break;
  10077. case 11:
  10078. if (!singleInstance) {
  10079. // If single instance objects are disabled, we need to replace the
  10080. for (_i = 0; _i < results.length; _i++) {
  10081. _obj = results[_i];
  10082. if (_obj && _obj.id && idMap[_obj.id]) {
  10083. id = _obj.id;
  10084. _obj._finishFetch(idMap[id].toJSON());
  10085. results[_i] = idMap[id];
  10086. }
  10087. }
  10088. }
  10089. _i2 = 0, _results = results;
  10090. case 13:
  10091. if (!(_i2 < _results.length)) {
  10092. _context10.next = 20;
  10093. break;
  10094. }
  10095. object = _results[_i2];
  10096. _context10.next = 17;
  10097. return localDatastore._updateObjectIfPinned(object);
  10098. case 17:
  10099. _i2++;
  10100. _context10.next = 13;
  10101. break;
  10102. case 20:
  10103. return _context10.abrupt("return", _promise.default.resolve(results));
  10104. case 21:
  10105. case "end":
  10106. return _context10.stop();
  10107. }
  10108. }, _callee6);
  10109. }));
  10110. return function () {
  10111. return _ref.apply(this, arguments);
  10112. };
  10113. }());
  10114. } else if (target instanceof ParseObject) {
  10115. if (!target.id) {
  10116. return _promise.default.reject(new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'Object does not have an ID'));
  10117. }
  10118. var RESTController = _CoreManager.default.getRESTController();
  10119. var params = {};
  10120. if (options && options.include) {
  10121. params.include = options.include.join();
  10122. }
  10123. return RESTController.request('GET', 'classes/' + target.className + '/' + target._getId(), params, options).then( /*#__PURE__*/function () {
  10124. var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(response) {
  10125. return _regenerator.default.wrap(function (_context11) {
  10126. while (1) switch (_context11.prev = _context11.next) {
  10127. case 0:
  10128. target._clearPendingOps();
  10129. target._clearServerData();
  10130. target._finishFetch(response);
  10131. _context11.next = 5;
  10132. return localDatastore._updateObjectIfPinned(target);
  10133. case 5:
  10134. return _context11.abrupt("return", target);
  10135. case 6:
  10136. case "end":
  10137. return _context11.stop();
  10138. }
  10139. }, _callee7);
  10140. }));
  10141. return function () {
  10142. return _ref2.apply(this, arguments);
  10143. };
  10144. }());
  10145. }
  10146. return _promise.default.resolve();
  10147. },
  10148. destroy: function (target /*: ParseObject | Array<ParseObject>*/, options /*: RequestOptions*/) /*: Promise<Array<void> | ParseObject>*/{
  10149. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
  10150. var batchSize, localDatastore, RESTController, batches, deleteCompleted, errors;
  10151. return _regenerator.default.wrap(function (_context14) {
  10152. while (1) switch (_context14.prev = _context14.next) {
  10153. case 0:
  10154. batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  10155. localDatastore = _CoreManager.default.getLocalDatastore();
  10156. RESTController = _CoreManager.default.getRESTController();
  10157. if (!(0, _isArray.default)(target)) {
  10158. _context14.next = 15;
  10159. break;
  10160. }
  10161. if (!(target.length < 1)) {
  10162. _context14.next = 6;
  10163. break;
  10164. }
  10165. return _context14.abrupt("return", _promise.default.resolve([]));
  10166. case 6:
  10167. batches = [[]];
  10168. (0, _forEach.default)(target).call(target, function (obj) {
  10169. if (!obj.id) {
  10170. return;
  10171. }
  10172. batches[batches.length - 1].push(obj);
  10173. if (batches[batches.length - 1].length >= batchSize) {
  10174. batches.push([]);
  10175. }
  10176. });
  10177. if (batches[batches.length - 1].length === 0) {
  10178. // If the last batch is empty, remove it
  10179. batches.pop();
  10180. }
  10181. deleteCompleted = _promise.default.resolve();
  10182. errors = [];
  10183. (0, _forEach.default)(batches).call(batches, function (batch) {
  10184. deleteCompleted = deleteCompleted.then(function () {
  10185. return RESTController.request('POST', 'batch', {
  10186. requests: (0, _map.default)(batch).call(batch, function (obj) {
  10187. return {
  10188. method: 'DELETE',
  10189. path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
  10190. body: {}
  10191. };
  10192. })
  10193. }, options).then(function (results) {
  10194. for (var i = 0; i < results.length; i++) {
  10195. if (results[i] && results[i].hasOwnProperty('error')) {
  10196. var err = new _ParseError.default(results[i].error.code, results[i].error.error);
  10197. err.object = batch[i];
  10198. errors.push(err);
  10199. }
  10200. }
  10201. });
  10202. });
  10203. });
  10204. return _context14.abrupt("return", deleteCompleted.then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
  10205. var aggregate, _iterator3, _step3, object;
  10206. return _regenerator.default.wrap(function (_context12) {
  10207. while (1) switch (_context12.prev = _context12.next) {
  10208. case 0:
  10209. if (!errors.length) {
  10210. _context12.next = 4;
  10211. break;
  10212. }
  10213. aggregate = new _ParseError.default(_ParseError.default.AGGREGATE_ERROR);
  10214. aggregate.errors = errors;
  10215. return _context12.abrupt("return", _promise.default.reject(aggregate));
  10216. case 4:
  10217. _iterator3 = _createForOfIteratorHelper(target);
  10218. _context12.prev = 5;
  10219. _iterator3.s();
  10220. case 7:
  10221. if ((_step3 = _iterator3.n()).done) {
  10222. _context12.next = 13;
  10223. break;
  10224. }
  10225. object = _step3.value;
  10226. _context12.next = 11;
  10227. return localDatastore._destroyObjectIfPinned(object);
  10228. case 11:
  10229. _context12.next = 7;
  10230. break;
  10231. case 13:
  10232. _context12.next = 18;
  10233. break;
  10234. case 15:
  10235. _context12.prev = 15;
  10236. _context12.t0 = _context12["catch"](5);
  10237. _iterator3.e(_context12.t0);
  10238. case 18:
  10239. _context12.prev = 18;
  10240. _iterator3.f();
  10241. return _context12.finish(18);
  10242. case 21:
  10243. return _context12.abrupt("return", _promise.default.resolve(target));
  10244. case 22:
  10245. case "end":
  10246. return _context12.stop();
  10247. }
  10248. }, _callee8, null, [[5, 15, 18, 21]]);
  10249. }))));
  10250. case 15:
  10251. if (!(target instanceof ParseObject)) {
  10252. _context14.next = 17;
  10253. break;
  10254. }
  10255. return _context14.abrupt("return", RESTController.request('DELETE', 'classes/' + target.className + '/' + target._getId(), {}, options).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
  10256. return _regenerator.default.wrap(function (_context13) {
  10257. while (1) switch (_context13.prev = _context13.next) {
  10258. case 0:
  10259. _context13.next = 2;
  10260. return localDatastore._destroyObjectIfPinned(target);
  10261. case 2:
  10262. return _context13.abrupt("return", _promise.default.resolve(target));
  10263. case 3:
  10264. case "end":
  10265. return _context13.stop();
  10266. }
  10267. }, _callee9);
  10268. }))));
  10269. case 17:
  10270. return _context14.abrupt("return", _promise.default.resolve(target));
  10271. case 18:
  10272. case "end":
  10273. return _context14.stop();
  10274. }
  10275. }, _callee10);
  10276. }))();
  10277. },
  10278. save: function (target /*: ParseObject | Array<ParseObject | ParseFile>*/, options /*: RequestOptions*/) {
  10279. var batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  10280. var localDatastore = _CoreManager.default.getLocalDatastore();
  10281. var mapIdForPin = {};
  10282. var RESTController = _CoreManager.default.getRESTController();
  10283. var stateController = _CoreManager.default.getObjectStateController();
  10284. var allowCustomObjectId = _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
  10285. options = options || {};
  10286. options.returnStatus = options.returnStatus || true;
  10287. if ((0, _isArray.default)(target)) {
  10288. if (target.length < 1) {
  10289. return _promise.default.resolve([]);
  10290. }
  10291. var unsaved = (0, _concat.default)(target).call(target);
  10292. for (var i = 0; i < target.length; i++) {
  10293. if (target[i] instanceof ParseObject) {
  10294. unsaved = (0, _concat.default)(unsaved).call(unsaved, (0, _unsavedChildren.default)(target[i], true));
  10295. }
  10296. }
  10297. unsaved = (0, _unique.default)(unsaved);
  10298. var filesSaved /*: Array<ParseFile>*/ = [];
  10299. var pending /*: Array<ParseObject>*/ = [];
  10300. (0, _forEach.default)(unsaved).call(unsaved, function (el) {
  10301. if (el instanceof _ParseFile.default) {
  10302. filesSaved.push(el.save(options));
  10303. } else if (el instanceof ParseObject) {
  10304. pending.push(el);
  10305. }
  10306. });
  10307. return _promise.default.all(filesSaved).then(function () {
  10308. var objectError = null;
  10309. return (0, _promiseUtils.continueWhile)(function () {
  10310. return pending.length > 0;
  10311. }, function () {
  10312. var batch = [];
  10313. var nextPending = [];
  10314. (0, _forEach.default)(pending).call(pending, function (el) {
  10315. if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(el, 'id') && !el.id) {
  10316. throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
  10317. }
  10318. if (batch.length < batchSize && (0, _canBeSerialized.default)(el)) {
  10319. batch.push(el);
  10320. } else {
  10321. nextPending.push(el);
  10322. }
  10323. });
  10324. pending = nextPending;
  10325. if (batch.length < 1) {
  10326. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a batch with a cycle.'));
  10327. }
  10328. // Queue up tasks for each object in the batch.
  10329. // When every task is ready, the API request will execute
  10330. var batchReturned = new _promiseUtils.resolvingPromise();
  10331. var batchReady = [];
  10332. var batchTasks = [];
  10333. (0, _forEach.default)(batch).call(batch, function (obj, index) {
  10334. var ready = new _promiseUtils.resolvingPromise();
  10335. batchReady.push(ready);
  10336. var task = function task() {
  10337. ready.resolve();
  10338. return batchReturned.then(function (responses) {
  10339. if (responses[index].hasOwnProperty('success')) {
  10340. var objectId = responses[index].success.objectId;
  10341. var status = responses[index]._status;
  10342. delete responses[index]._status;
  10343. mapIdForPin[objectId] = obj._localId;
  10344. obj._handleSaveResponse(responses[index].success, status);
  10345. } else {
  10346. if (!objectError && responses[index].hasOwnProperty('error')) {
  10347. var serverError = responses[index].error;
  10348. objectError = new _ParseError.default(serverError.code, serverError.error);
  10349. // Cancel the rest of the save
  10350. pending = [];
  10351. }
  10352. obj._handleSaveError();
  10353. }
  10354. });
  10355. };
  10356. stateController.pushPendingState(obj._getStateIdentifier());
  10357. batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), task));
  10358. });
  10359. (0, _promiseUtils.when)(batchReady).then(function () {
  10360. // Kick off the batch request
  10361. return RESTController.request('POST', 'batch', {
  10362. requests: (0, _map.default)(batch).call(batch, function (obj) {
  10363. var params = obj._getSaveParams();
  10364. params.path = getServerUrlPath() + params.path;
  10365. return params;
  10366. })
  10367. }, options);
  10368. }).then(batchReturned.resolve, function (error) {
  10369. batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
  10370. });
  10371. return (0, _promiseUtils.when)(batchTasks);
  10372. }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
  10373. var _iterator4, _step4, object;
  10374. return _regenerator.default.wrap(function _callee11$(_context15) {
  10375. while (1) switch (_context15.prev = _context15.next) {
  10376. case 0:
  10377. if (!objectError) {
  10378. _context15.next = 2;
  10379. break;
  10380. }
  10381. return _context15.abrupt("return", _promise.default.reject(objectError));
  10382. case 2:
  10383. _iterator4 = _createForOfIteratorHelper(target);
  10384. _context15.prev = 3;
  10385. _iterator4.s();
  10386. case 5:
  10387. if ((_step4 = _iterator4.n()).done) {
  10388. _context15.next = 14;
  10389. break;
  10390. }
  10391. object = _step4.value;
  10392. if (!(object instanceof ParseObject)) {
  10393. _context15.next = 12;
  10394. break;
  10395. }
  10396. _context15.next = 10;
  10397. return localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object);
  10398. case 10:
  10399. _context15.next = 12;
  10400. return localDatastore._updateObjectIfPinned(object);
  10401. case 12:
  10402. _context15.next = 5;
  10403. break;
  10404. case 14:
  10405. _context15.next = 19;
  10406. break;
  10407. case 16:
  10408. _context15.prev = 16;
  10409. _context15.t0 = _context15["catch"](3);
  10410. _iterator4.e(_context15.t0);
  10411. case 19:
  10412. _context15.prev = 19;
  10413. _iterator4.f();
  10414. return _context15.finish(19);
  10415. case 22:
  10416. return _context15.abrupt("return", _promise.default.resolve(target));
  10417. case 23:
  10418. case "end":
  10419. return _context15.stop();
  10420. }
  10421. }, _callee11, null, [[3, 16, 19, 22]]);
  10422. })));
  10423. });
  10424. } else if (target instanceof ParseObject) {
  10425. if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(target, 'id') && !target.id) {
  10426. throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
  10427. }
  10428. // generate _localId in case if cascadeSave=false
  10429. target._getId();
  10430. var localId = target._localId;
  10431. // copying target lets Flow guarantee the pointer isn't modified elsewhere
  10432. var targetCopy = target;
  10433. var task = function task() {
  10434. var params = targetCopy._getSaveParams();
  10435. return RESTController.request(params.method, params.path, params.body, options).then(function (response) {
  10436. var status = response._status;
  10437. delete response._status;
  10438. targetCopy._handleSaveResponse(response, status);
  10439. }, function (error) {
  10440. targetCopy._handleSaveError();
  10441. return _promise.default.reject(error);
  10442. });
  10443. };
  10444. stateController.pushPendingState(target._getStateIdentifier());
  10445. return stateController.enqueueTask(target._getStateIdentifier(), task).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
  10446. return _regenerator.default.wrap(function _callee12$(_context16) {
  10447. while (1) switch (_context16.prev = _context16.next) {
  10448. case 0:
  10449. _context16.next = 2;
  10450. return localDatastore._updateLocalIdForObject(localId, target);
  10451. case 2:
  10452. _context16.next = 4;
  10453. return localDatastore._updateObjectIfPinned(target);
  10454. case 4:
  10455. return _context16.abrupt("return", target);
  10456. case 5:
  10457. case "end":
  10458. return _context16.stop();
  10459. }
  10460. }, _callee12);
  10461. })), function (error) {
  10462. return _promise.default.reject(error);
  10463. });
  10464. }
  10465. return _promise.default.resolve();
  10466. }
  10467. };
  10468. _CoreManager.default.setObjectController(DefaultController);
  10469. var _default = ParseObject;
  10470. exports.default = _default;
  10471. },{"./CoreManager":4,"./EventuallyQueue":7,"./LocalDatastoreUtils":15,"./ParseACL":19,"./ParseError":22,"./ParseFile":23,"./ParseOp":28,"./ParseQuery":30,"./ParseRelation":31,"./SingleInstanceStateController":38,"./UniqueInstanceStateController":42,"./canBeSerialized":44,"./decode":45,"./encode":46,"./escape":48,"./parseDate":50,"./promiseUtils":51,"./unique":52,"./unsavedChildren":53,"./uuid":54,"@babel/runtime-corejs3/core-js-stable/array/from":55,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/find":63,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/slice":70,"@babel/runtime-corejs3/core-js-stable/json/stringify":75,"@babel/runtime-corejs3/core-js-stable/object/create":79,"@babel/runtime-corejs3/core-js-stable/object/define-properties":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/freeze":83,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":84,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":86,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":87,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/core-js-stable/symbol":95,"@babel/runtime-corejs3/core-js-stable/weak-map":96,"@babel/runtime-corejs3/core-js/get-iterator-method":99,"@babel/runtime-corejs3/helpers/asyncToGenerator":121,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/toConsumableArray":141,"@babel/runtime-corejs3/helpers/typeof":144,"@babel/runtime-corejs3/regenerator":147}],28:[function(_dereq_,module,exports){
  10472. "use strict";
  10473. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  10474. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  10475. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  10476. _Object$defineProperty(exports, "__esModule", {
  10477. value: true
  10478. });
  10479. exports.UnsetOp = exports.SetOp = exports.RemoveOp = exports.RelationOp = exports.Op = exports.IncrementOp = exports.AddUniqueOp = exports.AddOp = void 0;
  10480. exports.opFromJSON = opFromJSON;
  10481. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  10482. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  10483. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  10484. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  10485. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  10486. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  10487. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  10488. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  10489. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  10490. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  10491. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  10492. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  10493. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  10494. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  10495. var _decode = _interopRequireDefault(_dereq_("./decode"));
  10496. var _encode = _interopRequireDefault(_dereq_("./encode"));
  10497. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  10498. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  10499. var _unique = _interopRequireDefault(_dereq_("./unique"));
  10500. function _createSuper(Derived) {
  10501. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  10502. return function () {
  10503. var Super = (0, _getPrototypeOf2.default)(Derived),
  10504. result;
  10505. if (hasNativeReflectConstruct) {
  10506. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  10507. result = _Reflect$construct(Super, arguments, NewTarget);
  10508. } else {
  10509. result = Super.apply(this, arguments);
  10510. }
  10511. return (0, _possibleConstructorReturn2.default)(this, result);
  10512. };
  10513. }
  10514. function _isNativeReflectConstruct() {
  10515. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  10516. if (_Reflect$construct.sham) return false;
  10517. if (typeof Proxy === "function") return true;
  10518. try {
  10519. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  10520. return true;
  10521. } catch (e) {
  10522. return false;
  10523. }
  10524. } /**
  10525. * @flow
  10526. */
  10527. function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
  10528. if (!json || !json.__op) {
  10529. return null;
  10530. }
  10531. switch (json.__op) {
  10532. case 'Delete':
  10533. return new UnsetOp();
  10534. case 'Increment':
  10535. return new IncrementOp(json.amount);
  10536. case 'Add':
  10537. return new AddOp((0, _decode.default)(json.objects));
  10538. case 'AddUnique':
  10539. return new AddUniqueOp((0, _decode.default)(json.objects));
  10540. case 'Remove':
  10541. return new RemoveOp((0, _decode.default)(json.objects));
  10542. case 'AddRelation':
  10543. {
  10544. var toAdd = (0, _decode.default)(json.objects);
  10545. if (!(0, _isArray.default)(toAdd)) {
  10546. return new RelationOp([], []);
  10547. }
  10548. return new RelationOp(toAdd, []);
  10549. }
  10550. case 'RemoveRelation':
  10551. {
  10552. var toRemove = (0, _decode.default)(json.objects);
  10553. if (!(0, _isArray.default)(toRemove)) {
  10554. return new RelationOp([], []);
  10555. }
  10556. return new RelationOp([], toRemove);
  10557. }
  10558. case 'Batch':
  10559. {
  10560. var _toAdd = [];
  10561. var _toRemove = [];
  10562. for (var i = 0; i < json.ops.length; i++) {
  10563. if (json.ops[i].__op === 'AddRelation') {
  10564. _toAdd = (0, _concat.default)(_toAdd).call(_toAdd, (0, _decode.default)(json.ops[i].objects));
  10565. } else if (json.ops[i].__op === 'RemoveRelation') {
  10566. _toRemove = (0, _concat.default)(_toRemove).call(_toRemove, (0, _decode.default)(json.ops[i].objects));
  10567. }
  10568. }
  10569. return new RelationOp(_toAdd, _toRemove);
  10570. }
  10571. }
  10572. return null;
  10573. }
  10574. var Op = /*#__PURE__*/function () {
  10575. function Op() {
  10576. (0, _classCallCheck2.default)(this, Op);
  10577. }
  10578. (0, _createClass2.default)(Op, [{
  10579. key: "applyTo",
  10580. value:
  10581. // Empty parent class
  10582. function () /*: mixed*/{} /* eslint-disable-line no-unused-vars */
  10583. }, {
  10584. key: "mergeWith",
  10585. value: function () /*: ?Op*/{} /* eslint-disable-line no-unused-vars */
  10586. }, {
  10587. key: "toJSON",
  10588. value: function () /*: mixed*/{}
  10589. }]);
  10590. return Op;
  10591. }();
  10592. exports.Op = Op;
  10593. var SetOp = /*#__PURE__*/function (_Op) {
  10594. (0, _inherits2.default)(SetOp, _Op);
  10595. var _super = _createSuper(SetOp);
  10596. function SetOp(value /*: mixed*/) {
  10597. var _this;
  10598. (0, _classCallCheck2.default)(this, SetOp);
  10599. _this = _super.call(this);
  10600. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_value", void 0);
  10601. _this._value = value;
  10602. return _this;
  10603. }
  10604. (0, _createClass2.default)(SetOp, [{
  10605. key: "applyTo",
  10606. value: function () /*: mixed*/{
  10607. return this._value;
  10608. }
  10609. }, {
  10610. key: "mergeWith",
  10611. value: function () /*: SetOp*/{
  10612. return new SetOp(this._value);
  10613. }
  10614. }, {
  10615. key: "toJSON",
  10616. value: function (offline /*:: ?: boolean*/) {
  10617. return (0, _encode.default)(this._value, false, true, undefined, offline);
  10618. }
  10619. }]);
  10620. return SetOp;
  10621. }(Op);
  10622. exports.SetOp = SetOp;
  10623. var UnsetOp = /*#__PURE__*/function (_Op2) {
  10624. (0, _inherits2.default)(UnsetOp, _Op2);
  10625. var _super2 = _createSuper(UnsetOp);
  10626. function UnsetOp() {
  10627. (0, _classCallCheck2.default)(this, UnsetOp);
  10628. return _super2.apply(this, arguments);
  10629. }
  10630. (0, _createClass2.default)(UnsetOp, [{
  10631. key: "applyTo",
  10632. value: function () {
  10633. return undefined;
  10634. }
  10635. }, {
  10636. key: "mergeWith",
  10637. value: function () /*: UnsetOp*/{
  10638. return new UnsetOp();
  10639. }
  10640. }, {
  10641. key: "toJSON",
  10642. value: function () /*: { __op: string }*/{
  10643. return {
  10644. __op: 'Delete'
  10645. };
  10646. }
  10647. }]);
  10648. return UnsetOp;
  10649. }(Op);
  10650. exports.UnsetOp = UnsetOp;
  10651. var IncrementOp = /*#__PURE__*/function (_Op3) {
  10652. (0, _inherits2.default)(IncrementOp, _Op3);
  10653. var _super3 = _createSuper(IncrementOp);
  10654. function IncrementOp(amount /*: number*/) {
  10655. var _this2;
  10656. (0, _classCallCheck2.default)(this, IncrementOp);
  10657. _this2 = _super3.call(this);
  10658. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "_amount", void 0);
  10659. if (typeof amount !== 'number') {
  10660. throw new TypeError('Increment Op must be initialized with a numeric amount.');
  10661. }
  10662. _this2._amount = amount;
  10663. return _this2;
  10664. }
  10665. (0, _createClass2.default)(IncrementOp, [{
  10666. key: "applyTo",
  10667. value: function (value /*: ?mixed*/) /*: number*/{
  10668. if (typeof value === 'undefined') {
  10669. return this._amount;
  10670. }
  10671. if (typeof value !== 'number') {
  10672. throw new TypeError('Cannot increment a non-numeric value.');
  10673. }
  10674. return this._amount + value;
  10675. }
  10676. }, {
  10677. key: "mergeWith",
  10678. value: function (previous /*: Op*/) /*: Op*/{
  10679. if (!previous) {
  10680. return this;
  10681. }
  10682. if (previous instanceof SetOp) {
  10683. return new SetOp(this.applyTo(previous._value));
  10684. }
  10685. if (previous instanceof UnsetOp) {
  10686. return new SetOp(this._amount);
  10687. }
  10688. if (previous instanceof IncrementOp) {
  10689. return new IncrementOp(this.applyTo(previous._amount));
  10690. }
  10691. throw new Error('Cannot merge Increment Op with the previous Op');
  10692. }
  10693. }, {
  10694. key: "toJSON",
  10695. value: function () /*: { __op: string, amount: number }*/{
  10696. return {
  10697. __op: 'Increment',
  10698. amount: this._amount
  10699. };
  10700. }
  10701. }]);
  10702. return IncrementOp;
  10703. }(Op);
  10704. exports.IncrementOp = IncrementOp;
  10705. var AddOp = /*#__PURE__*/function (_Op4) {
  10706. (0, _inherits2.default)(AddOp, _Op4);
  10707. var _super4 = _createSuper(AddOp);
  10708. function AddOp(value /*: mixed | Array<mixed>*/) {
  10709. var _this3;
  10710. (0, _classCallCheck2.default)(this, AddOp);
  10711. _this3 = _super4.call(this);
  10712. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this3), "_value", void 0);
  10713. _this3._value = (0, _isArray.default)(value) ? value : [value];
  10714. return _this3;
  10715. }
  10716. (0, _createClass2.default)(AddOp, [{
  10717. key: "applyTo",
  10718. value: function (value /*: mixed*/) /*: Array<mixed>*/{
  10719. if (value == null) {
  10720. return this._value;
  10721. }
  10722. if ((0, _isArray.default)(value)) {
  10723. return (0, _concat.default)(value).call(value, this._value);
  10724. }
  10725. throw new Error('Cannot add elements to a non-array value');
  10726. }
  10727. }, {
  10728. key: "mergeWith",
  10729. value: function (previous /*: Op*/) /*: Op*/{
  10730. if (!previous) {
  10731. return this;
  10732. }
  10733. if (previous instanceof SetOp) {
  10734. return new SetOp(this.applyTo(previous._value));
  10735. }
  10736. if (previous instanceof UnsetOp) {
  10737. return new SetOp(this._value);
  10738. }
  10739. if (previous instanceof AddOp) {
  10740. return new AddOp(this.applyTo(previous._value));
  10741. }
  10742. throw new Error('Cannot merge Add Op with the previous Op');
  10743. }
  10744. }, {
  10745. key: "toJSON",
  10746. value: function () /*: { __op: string, objects: mixed }*/{
  10747. return {
  10748. __op: 'Add',
  10749. objects: (0, _encode.default)(this._value, false, true)
  10750. };
  10751. }
  10752. }]);
  10753. return AddOp;
  10754. }(Op);
  10755. exports.AddOp = AddOp;
  10756. var AddUniqueOp = /*#__PURE__*/function (_Op5) {
  10757. (0, _inherits2.default)(AddUniqueOp, _Op5);
  10758. var _super5 = _createSuper(AddUniqueOp);
  10759. function AddUniqueOp(value /*: mixed | Array<mixed>*/) {
  10760. var _this4;
  10761. (0, _classCallCheck2.default)(this, AddUniqueOp);
  10762. _this4 = _super5.call(this);
  10763. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this4), "_value", void 0);
  10764. _this4._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  10765. return _this4;
  10766. }
  10767. (0, _createClass2.default)(AddUniqueOp, [{
  10768. key: "applyTo",
  10769. value: function (value /*: mixed | Array<mixed>*/) /*: Array<mixed>*/{
  10770. if (value == null) {
  10771. return this._value || [];
  10772. }
  10773. if ((0, _isArray.default)(value)) {
  10774. var _context;
  10775. var toAdd = [];
  10776. (0, _forEach.default)(_context = this._value).call(_context, function (v) {
  10777. if (v instanceof _ParseObject.default) {
  10778. if (!(0, _arrayContainsObject.default)(value, v)) {
  10779. toAdd.push(v);
  10780. }
  10781. } else {
  10782. if ((0, _indexOf.default)(value).call(value, v) < 0) {
  10783. toAdd.push(v);
  10784. }
  10785. }
  10786. });
  10787. return (0, _concat.default)(value).call(value, toAdd);
  10788. }
  10789. throw new Error('Cannot add elements to a non-array value');
  10790. }
  10791. }, {
  10792. key: "mergeWith",
  10793. value: function (previous /*: Op*/) /*: Op*/{
  10794. if (!previous) {
  10795. return this;
  10796. }
  10797. if (previous instanceof SetOp) {
  10798. return new SetOp(this.applyTo(previous._value));
  10799. }
  10800. if (previous instanceof UnsetOp) {
  10801. return new SetOp(this._value);
  10802. }
  10803. if (previous instanceof AddUniqueOp) {
  10804. return new AddUniqueOp(this.applyTo(previous._value));
  10805. }
  10806. throw new Error('Cannot merge AddUnique Op with the previous Op');
  10807. }
  10808. }, {
  10809. key: "toJSON",
  10810. value: function () /*: { __op: string, objects: mixed }*/{
  10811. return {
  10812. __op: 'AddUnique',
  10813. objects: (0, _encode.default)(this._value, false, true)
  10814. };
  10815. }
  10816. }]);
  10817. return AddUniqueOp;
  10818. }(Op);
  10819. exports.AddUniqueOp = AddUniqueOp;
  10820. var RemoveOp = /*#__PURE__*/function (_Op6) {
  10821. (0, _inherits2.default)(RemoveOp, _Op6);
  10822. var _super6 = _createSuper(RemoveOp);
  10823. function RemoveOp(value /*: mixed | Array<mixed>*/) {
  10824. var _this5;
  10825. (0, _classCallCheck2.default)(this, RemoveOp);
  10826. _this5 = _super6.call(this);
  10827. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this5), "_value", void 0);
  10828. _this5._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  10829. return _this5;
  10830. }
  10831. (0, _createClass2.default)(RemoveOp, [{
  10832. key: "applyTo",
  10833. value: function (value /*: mixed | Array<mixed>*/) /*: Array<mixed>*/{
  10834. if (value == null) {
  10835. return [];
  10836. }
  10837. if ((0, _isArray.default)(value)) {
  10838. // var i = value.indexOf(this._value);
  10839. var removed = (0, _concat.default)(value).call(value, []);
  10840. for (var i = 0; i < this._value.length; i++) {
  10841. var index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  10842. while (index > -1) {
  10843. (0, _splice.default)(removed).call(removed, index, 1);
  10844. index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  10845. }
  10846. if (this._value[i] instanceof _ParseObject.default && this._value[i].id) {
  10847. for (var j = 0; j < removed.length; j++) {
  10848. if (removed[j] instanceof _ParseObject.default && this._value[i].id === removed[j].id) {
  10849. (0, _splice.default)(removed).call(removed, j, 1);
  10850. j--;
  10851. }
  10852. }
  10853. }
  10854. }
  10855. return removed;
  10856. }
  10857. throw new Error('Cannot remove elements from a non-array value');
  10858. }
  10859. }, {
  10860. key: "mergeWith",
  10861. value: function (previous /*: Op*/) /*: Op*/{
  10862. if (!previous) {
  10863. return this;
  10864. }
  10865. if (previous instanceof SetOp) {
  10866. return new SetOp(this.applyTo(previous._value));
  10867. }
  10868. if (previous instanceof UnsetOp) {
  10869. return new UnsetOp();
  10870. }
  10871. if (previous instanceof RemoveOp) {
  10872. var _context2;
  10873. var uniques = (0, _concat.default)(_context2 = previous._value).call(_context2, []);
  10874. for (var i = 0; i < this._value.length; i++) {
  10875. if (this._value[i] instanceof _ParseObject.default) {
  10876. if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
  10877. uniques.push(this._value[i]);
  10878. }
  10879. } else {
  10880. if ((0, _indexOf.default)(uniques).call(uniques, this._value[i]) < 0) {
  10881. uniques.push(this._value[i]);
  10882. }
  10883. }
  10884. }
  10885. return new RemoveOp(uniques);
  10886. }
  10887. throw new Error('Cannot merge Remove Op with the previous Op');
  10888. }
  10889. }, {
  10890. key: "toJSON",
  10891. value: function () /*: { __op: string, objects: mixed }*/{
  10892. return {
  10893. __op: 'Remove',
  10894. objects: (0, _encode.default)(this._value, false, true)
  10895. };
  10896. }
  10897. }]);
  10898. return RemoveOp;
  10899. }(Op);
  10900. exports.RemoveOp = RemoveOp;
  10901. var RelationOp = /*#__PURE__*/function (_Op7) {
  10902. (0, _inherits2.default)(RelationOp, _Op7);
  10903. var _super7 = _createSuper(RelationOp);
  10904. function RelationOp(adds /*: Array<ParseObject | string>*/, removes /*: Array<ParseObject | string>*/) {
  10905. var _this6;
  10906. (0, _classCallCheck2.default)(this, RelationOp);
  10907. _this6 = _super7.call(this);
  10908. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "_targetClassName", void 0);
  10909. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToAdd", void 0);
  10910. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToRemove", void 0);
  10911. _this6._targetClassName = null;
  10912. if ((0, _isArray.default)(adds)) {
  10913. _this6.relationsToAdd = (0, _unique.default)((0, _map.default)(adds).call(adds, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
  10914. }
  10915. if ((0, _isArray.default)(removes)) {
  10916. _this6.relationsToRemove = (0, _unique.default)((0, _map.default)(removes).call(removes, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
  10917. }
  10918. return _this6;
  10919. }
  10920. (0, _createClass2.default)(RelationOp, [{
  10921. key: "_extractId",
  10922. value: function (obj /*: string | ParseObject*/) /*: string*/{
  10923. if (typeof obj === 'string') {
  10924. return obj;
  10925. }
  10926. if (!obj.id) {
  10927. throw new Error('You cannot add or remove an unsaved Parse Object from a relation');
  10928. }
  10929. if (!this._targetClassName) {
  10930. this._targetClassName = obj.className;
  10931. }
  10932. if (this._targetClassName !== obj.className) {
  10933. throw new Error('Tried to create a Relation with 2 different object types: ' + this._targetClassName + ' and ' + obj.className + '.');
  10934. }
  10935. return obj.id;
  10936. }
  10937. }, {
  10938. key: "applyTo",
  10939. value: function (value /*: mixed*/, object /*:: ?: { className: string, id: ?string }*/, key /*:: ?: string*/) /*: ?ParseRelation*/{
  10940. if (!value) {
  10941. var _context3;
  10942. if (!object || !key) {
  10943. throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
  10944. }
  10945. var parent = new _ParseObject.default(object.className);
  10946. if (object.id && (0, _indexOf.default)(_context3 = object.id).call(_context3, 'local') === 0) {
  10947. parent._localId = object.id;
  10948. } else if (object.id) {
  10949. parent.id = object.id;
  10950. }
  10951. var relation = new _ParseRelation.default(parent, key);
  10952. relation.targetClassName = this._targetClassName;
  10953. return relation;
  10954. }
  10955. if (value instanceof _ParseRelation.default) {
  10956. if (this._targetClassName) {
  10957. if (value.targetClassName) {
  10958. if (this._targetClassName !== value.targetClassName) {
  10959. throw new Error('Related object must be a ' + value.targetClassName + ', but a ' + this._targetClassName + ' was passed in.');
  10960. }
  10961. } else {
  10962. value.targetClassName = this._targetClassName;
  10963. }
  10964. }
  10965. return value;
  10966. } else {
  10967. throw new Error('Relation cannot be applied to a non-relation field');
  10968. }
  10969. }
  10970. }, {
  10971. key: "mergeWith",
  10972. value: function (previous /*: Op*/) /*: Op*/{
  10973. if (!previous) {
  10974. return this;
  10975. } else if (previous instanceof UnsetOp) {
  10976. throw new Error('You cannot modify a relation after deleting it.');
  10977. } else if (previous instanceof SetOp && previous._value instanceof _ParseRelation.default) {
  10978. return this;
  10979. } else if (previous instanceof RelationOp) {
  10980. var _context4, _context5, _context6, _context7, _context8, _context9;
  10981. if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
  10982. throw new Error('Related object must be of class ' + previous._targetClassName + ', but ' + (this._targetClassName || 'null') + ' was passed in.');
  10983. }
  10984. var newAdd = (0, _concat.default)(_context4 = previous.relationsToAdd).call(_context4, []);
  10985. (0, _forEach.default)(_context5 = this.relationsToRemove).call(_context5, function (r) {
  10986. var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  10987. if (index > -1) {
  10988. (0, _splice.default)(newAdd).call(newAdd, index, 1);
  10989. }
  10990. });
  10991. (0, _forEach.default)(_context6 = this.relationsToAdd).call(_context6, function (r) {
  10992. var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  10993. if (index < 0) {
  10994. newAdd.push(r);
  10995. }
  10996. });
  10997. var newRemove = (0, _concat.default)(_context7 = previous.relationsToRemove).call(_context7, []);
  10998. (0, _forEach.default)(_context8 = this.relationsToAdd).call(_context8, function (r) {
  10999. var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  11000. if (index > -1) {
  11001. (0, _splice.default)(newRemove).call(newRemove, index, 1);
  11002. }
  11003. });
  11004. (0, _forEach.default)(_context9 = this.relationsToRemove).call(_context9, function (r) {
  11005. var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  11006. if (index < 0) {
  11007. newRemove.push(r);
  11008. }
  11009. });
  11010. var newRelation = new RelationOp(newAdd, newRemove);
  11011. newRelation._targetClassName = this._targetClassName;
  11012. return newRelation;
  11013. }
  11014. throw new Error('Cannot merge Relation Op with the previous Op');
  11015. }
  11016. }, {
  11017. key: "toJSON",
  11018. value: function () /*: { __op?: string, objects?: mixed, ops?: mixed }*/{
  11019. var _this7 = this;
  11020. var idToPointer = function (id) {
  11021. return {
  11022. __type: 'Pointer',
  11023. className: _this7._targetClassName,
  11024. objectId: id
  11025. };
  11026. };
  11027. var adds = null;
  11028. var removes = null;
  11029. var pointers = null;
  11030. if (this.relationsToAdd.length > 0) {
  11031. var _context10;
  11032. pointers = (0, _map.default)(_context10 = this.relationsToAdd).call(_context10, idToPointer);
  11033. adds = {
  11034. __op: 'AddRelation',
  11035. objects: pointers
  11036. };
  11037. }
  11038. if (this.relationsToRemove.length > 0) {
  11039. var _context11;
  11040. pointers = (0, _map.default)(_context11 = this.relationsToRemove).call(_context11, idToPointer);
  11041. removes = {
  11042. __op: 'RemoveRelation',
  11043. objects: pointers
  11044. };
  11045. }
  11046. if (adds && removes) {
  11047. return {
  11048. __op: 'Batch',
  11049. ops: [adds, removes]
  11050. };
  11051. }
  11052. return adds || removes || {};
  11053. }
  11054. }]);
  11055. return RelationOp;
  11056. }(Op);
  11057. exports.RelationOp = RelationOp;
  11058. },{"./ParseObject":27,"./ParseRelation":31,"./arrayContainsObject":43,"./decode":45,"./encode":46,"./unique":52,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/splice":72,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/reflect/construct":91,"@babel/runtime-corejs3/helpers/assertThisInitialized":120,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/getPrototypeOf":127,"@babel/runtime-corejs3/helpers/inherits":128,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":136}],29:[function(_dereq_,module,exports){
  11059. "use strict";
  11060. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11061. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11062. _Object$defineProperty(exports, "__esModule", {
  11063. value: true
  11064. });
  11065. exports.default = void 0;
  11066. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  11067. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  11068. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  11069. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  11070. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  11071. /**
  11072. * @flow
  11073. */
  11074. /**
  11075. * Creates a new Polygon with any of the following forms:<br>
  11076. * <pre>
  11077. * new Polygon([[0,0],[0,1],[1,1],[1,0]])
  11078. * new Polygon([GeoPoint, GeoPoint, GeoPoint])
  11079. * </pre>
  11080. *
  11081. * <p>Represents a coordinates that may be associated
  11082. * with a key in a ParseObject or used as a reference point for geo queries.
  11083. * This allows proximity-based queries on the key.</p>
  11084. *
  11085. * <p>Example:<pre>
  11086. * var polygon = new Parse.Polygon([[0,0],[0,1],[1,1],[1,0]]);
  11087. * var object = new Parse.Object("PlaceObject");
  11088. * object.set("area", polygon);
  11089. * object.save();</pre></p>
  11090. *
  11091. * @alias Parse.Polygon
  11092. */
  11093. var ParsePolygon = /*#__PURE__*/function () {
  11094. /**
  11095. * @param {(number[][] | Parse.GeoPoint[])} coordinates An Array of coordinate pairs
  11096. */
  11097. function ParsePolygon(coordinates /*: Array<Array<number>> | Array<ParseGeoPoint>*/) {
  11098. (0, _classCallCheck2.default)(this, ParsePolygon);
  11099. (0, _defineProperty2.default)(this, "_coordinates", void 0);
  11100. this._coordinates = ParsePolygon._validate(coordinates);
  11101. }
  11102. /**
  11103. * Coordinates value for this Polygon.
  11104. * Throws an exception if not valid type.
  11105. *
  11106. * @property {(number[][] | Parse.GeoPoint[])} coordinates list of coordinates
  11107. * @returns {number[][]}
  11108. */
  11109. (0, _createClass2.default)(ParsePolygon, [{
  11110. key: "coordinates",
  11111. get: function () /*: Array<Array<number>>*/{
  11112. return this._coordinates;
  11113. },
  11114. set: function (coords /*: Array<Array<number>> | Array<ParseGeoPoint>*/) {
  11115. this._coordinates = ParsePolygon._validate(coords);
  11116. }
  11117. /**
  11118. * Returns a JSON representation of the Polygon, suitable for Parse.
  11119. *
  11120. * @returns {object}
  11121. */
  11122. }, {
  11123. key: "toJSON",
  11124. value: function () /*: { __type: string, coordinates: Array<Array<number>> }*/{
  11125. ParsePolygon._validate(this._coordinates);
  11126. return {
  11127. __type: 'Polygon',
  11128. coordinates: this._coordinates
  11129. };
  11130. }
  11131. /**
  11132. * Checks if two polygons are equal
  11133. *
  11134. * @param {(Parse.Polygon | object)} other
  11135. * @returns {boolean}
  11136. */
  11137. }, {
  11138. key: "equals",
  11139. value: function (other /*: mixed*/) /*: boolean*/{
  11140. if (!(other instanceof ParsePolygon) || this.coordinates.length !== other.coordinates.length) {
  11141. return false;
  11142. }
  11143. var isEqual = true;
  11144. for (var i = 1; i < this._coordinates.length; i += 1) {
  11145. if (this._coordinates[i][0] != other.coordinates[i][0] || this._coordinates[i][1] != other.coordinates[i][1]) {
  11146. isEqual = false;
  11147. break;
  11148. }
  11149. }
  11150. return isEqual;
  11151. }
  11152. /**
  11153. *
  11154. * @param {Parse.GeoPoint} point
  11155. * @returns {boolean} Returns if the point is contained in the polygon
  11156. */
  11157. }, {
  11158. key: "containsPoint",
  11159. value: function (point /*: ParseGeoPoint*/) /*: boolean*/{
  11160. var minX = this._coordinates[0][0];
  11161. var maxX = this._coordinates[0][0];
  11162. var minY = this._coordinates[0][1];
  11163. var maxY = this._coordinates[0][1];
  11164. for (var i = 1; i < this._coordinates.length; i += 1) {
  11165. var p = this._coordinates[i];
  11166. minX = Math.min(p[0], minX);
  11167. maxX = Math.max(p[0], maxX);
  11168. minY = Math.min(p[1], minY);
  11169. maxY = Math.max(p[1], maxY);
  11170. }
  11171. var outside = point.latitude < minX || point.latitude > maxX || point.longitude < minY || point.longitude > maxY;
  11172. if (outside) {
  11173. return false;
  11174. }
  11175. var inside = false;
  11176. for (var _i = 0, j = this._coordinates.length - 1; _i < this._coordinates.length; j = _i++) {
  11177. var startX = this._coordinates[_i][0];
  11178. var startY = this._coordinates[_i][1];
  11179. var endX = this._coordinates[j][0];
  11180. var endY = this._coordinates[j][1];
  11181. var intersect = startY > point.longitude != endY > point.longitude && point.latitude < (endX - startX) * (point.longitude - startY) / (endY - startY) + startX;
  11182. if (intersect) {
  11183. inside = !inside;
  11184. }
  11185. }
  11186. return inside;
  11187. }
  11188. /**
  11189. * Validates that the list of coordinates can form a valid polygon
  11190. *
  11191. * @param {Array} coords the list of coordinates to validate as a polygon
  11192. * @throws {TypeError}
  11193. * @returns {number[][]} Array of coordinates if validated.
  11194. */
  11195. }], [{
  11196. key: "_validate",
  11197. value: function (coords /*: Array<Array<number>> | Array<ParseGeoPoint>*/) /*: Array<Array<number>>*/{
  11198. if (!(0, _isArray.default)(coords)) {
  11199. throw new TypeError('Coordinates must be an Array');
  11200. }
  11201. if (coords.length < 3) {
  11202. throw new TypeError('Polygon must have at least 3 GeoPoints or Points');
  11203. }
  11204. var points = [];
  11205. for (var i = 0; i < coords.length; i += 1) {
  11206. var coord = coords[i];
  11207. var geoPoint = void 0;
  11208. if (coord instanceof _ParseGeoPoint.default) {
  11209. geoPoint = coord;
  11210. } else if ((0, _isArray.default)(coord) && coord.length === 2) {
  11211. geoPoint = new _ParseGeoPoint.default(coord[0], coord[1]);
  11212. } else {
  11213. throw new TypeError('Coordinates must be an Array of GeoPoints or Points');
  11214. }
  11215. points.push([geoPoint.latitude, geoPoint.longitude]);
  11216. }
  11217. return points;
  11218. }
  11219. }]);
  11220. return ParsePolygon;
  11221. }();
  11222. var _default = ParsePolygon;
  11223. exports.default = _default;
  11224. },{"./ParseGeoPoint":24,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],30:[function(_dereq_,module,exports){
  11225. "use strict";
  11226. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11227. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11228. _Object$defineProperty(exports, "__esModule", {
  11229. value: true
  11230. });
  11231. exports.default = void 0;
  11232. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  11233. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  11234. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  11235. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  11236. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  11237. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  11238. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  11239. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  11240. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  11241. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  11242. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  11243. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  11244. var _map2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  11245. var _filter2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  11246. var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  11247. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  11248. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  11249. var _sort = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/sort"));
  11250. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  11251. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  11252. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  11253. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  11254. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/entries"));
  11255. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  11256. var _encode = _interopRequireDefault(_dereq_("./encode"));
  11257. var _promiseUtils = _dereq_("./promiseUtils");
  11258. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  11259. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  11260. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  11261. var _OfflineQuery = _interopRequireDefault(_dereq_("./OfflineQuery"));
  11262. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  11263. /*
  11264. * @flow
  11265. */
  11266. /*:: import type LiveQuerySubscription from './LiveQuerySubscription';*/
  11267. /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
  11268. /*:: type BatchOptions = FullOptions & { batchSize?: number };*/
  11269. /*:: export type WhereClause = {
  11270. [attr: string]: mixed,
  11271. };*/
  11272. /*:: export type QueryJSON = {
  11273. where: WhereClause,
  11274. watch?: string,
  11275. include?: string,
  11276. excludeKeys?: string,
  11277. keys?: string,
  11278. limit?: number,
  11279. skip?: number,
  11280. order?: string,
  11281. className?: string,
  11282. count?: number,
  11283. hint?: mixed,
  11284. explain?: boolean,
  11285. readPreference?: string,
  11286. includeReadPreference?: string,
  11287. subqueryReadPreference?: string,
  11288. };*/
  11289. /**
  11290. * Converts a string into a regex that matches it.
  11291. * Surrounding with \Q .. \E does this, we just need to escape any \E's in
  11292. * the text separately.
  11293. *
  11294. * @param s
  11295. * @private
  11296. * @returns {string}
  11297. */
  11298. function quote(s /*: string*/) /*: string*/{
  11299. return '\\Q' + s.replace('\\E', '\\E\\\\E\\Q') + '\\E';
  11300. }
  11301. /**
  11302. * Extracts the class name from queries. If not all queries have the same
  11303. * class name an error will be thrown.
  11304. *
  11305. * @param queries
  11306. * @private
  11307. * @returns {string}
  11308. */
  11309. function _getClassNameFromQueries(queries /*: Array<ParseQuery>*/) /*: ?string*/{
  11310. var className = null;
  11311. (0, _forEach.default)(queries).call(queries, function (q) {
  11312. if (!className) {
  11313. className = q.className;
  11314. }
  11315. if (className !== q.className) {
  11316. throw new Error('All queries must be for the same class.');
  11317. }
  11318. });
  11319. return className;
  11320. }
  11321. /*
  11322. * Handles pre-populating the result data of a query with select fields,
  11323. * making sure that the data object contains keys for all objects that have
  11324. * been requested with a select, so that our cached state updates correctly.
  11325. */
  11326. function handleSelectResult(data /*: any*/, select /*: Array<string>*/) {
  11327. var serverDataMask = {};
  11328. (0, _forEach.default)(select).call(select, function (field) {
  11329. var hasSubObjectSelect = (0, _indexOf.default)(field).call(field, '.') !== -1;
  11330. if (!hasSubObjectSelect && !data.hasOwnProperty(field)) {
  11331. // this field was selected, but is missing from the retrieved data
  11332. data[field] = undefined;
  11333. } else if (hasSubObjectSelect) {
  11334. // this field references a sub-object,
  11335. // so we need to walk down the path components
  11336. var pathComponents = field.split('.');
  11337. var _obj = data;
  11338. var serverMask = serverDataMask;
  11339. (0, _forEach.default)(pathComponents).call(pathComponents, function (component, index, arr) {
  11340. // add keys if the expected data is missing
  11341. if (_obj && !_obj.hasOwnProperty(component)) {
  11342. _obj[component] = undefined;
  11343. }
  11344. if (_obj && (0, _typeof2.default)(_obj) === 'object') {
  11345. _obj = _obj[component];
  11346. }
  11347. //add this path component to the server mask so we can fill it in later if needed
  11348. if (index < arr.length - 1) {
  11349. if (!serverMask[component]) {
  11350. serverMask[component] = {};
  11351. }
  11352. serverMask = serverMask[component];
  11353. }
  11354. });
  11355. }
  11356. });
  11357. if ((0, _keys.default)(serverDataMask).length > 0) {
  11358. // When selecting from sub-objects, we don't want to blow away the missing
  11359. // information that we may have retrieved before. We've already added any
  11360. // missing selected keys to sub-objects, but we still need to add in the
  11361. // data for any previously retrieved sub-objects that were not selected.
  11362. var serverData = _CoreManager.default.getObjectStateController().getServerData({
  11363. id: data.objectId,
  11364. className: data.className
  11365. });
  11366. copyMissingDataWithMask(serverData, data, serverDataMask, false);
  11367. }
  11368. }
  11369. function copyMissingDataWithMask(src, dest, mask, copyThisLevel) {
  11370. //copy missing elements at this level
  11371. if (copyThisLevel) {
  11372. for (var _key in src) {
  11373. if (src.hasOwnProperty(_key) && !dest.hasOwnProperty(_key)) {
  11374. dest[_key] = src[_key];
  11375. }
  11376. }
  11377. }
  11378. for (var _key2 in mask) {
  11379. if (dest[_key2] !== undefined && dest[_key2] !== null && src !== undefined && src !== null) {
  11380. //traverse into objects as needed
  11381. copyMissingDataWithMask(src[_key2], dest[_key2], mask[_key2], true);
  11382. }
  11383. }
  11384. }
  11385. function handleOfflineSort(a, b, sorts) {
  11386. var order = sorts[0];
  11387. var operator = (0, _slice.default)(order).call(order, 0, 1);
  11388. var isDescending = operator === '-';
  11389. if (isDescending) {
  11390. order = order.substring(1);
  11391. }
  11392. if (order === '_created_at') {
  11393. order = 'createdAt';
  11394. }
  11395. if (order === '_updated_at') {
  11396. order = 'updatedAt';
  11397. }
  11398. if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(order) || order === 'password') {
  11399. throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, "Invalid Key: ".concat(order));
  11400. }
  11401. var field1 = a.get(order);
  11402. var field2 = b.get(order);
  11403. if (field1 < field2) {
  11404. return isDescending ? 1 : -1;
  11405. }
  11406. if (field1 > field2) {
  11407. return isDescending ? -1 : 1;
  11408. }
  11409. if (sorts.length > 1) {
  11410. var remainingSorts = (0, _slice.default)(sorts).call(sorts, 1);
  11411. return handleOfflineSort(a, b, remainingSorts);
  11412. }
  11413. return 0;
  11414. }
  11415. /**
  11416. * Creates a new parse Parse.Query for the given Parse.Object subclass.
  11417. *
  11418. * <p>Parse.Query defines a query that is used to fetch Parse.Objects. The
  11419. * most common use case is finding all objects that match a query through the
  11420. * <code>find</code> method. for example, this sample code fetches all objects
  11421. * of class <code>myclass</code>. it calls a different function depending on
  11422. * whether the fetch succeeded or not.
  11423. *
  11424. * <pre>
  11425. * var query = new Parse.Query(myclass);
  11426. * query.find().then((results) => {
  11427. * // results is an array of parse.object.
  11428. * }).catch((error) => {
  11429. * // error is an instance of parse.error.
  11430. * });</pre></p>
  11431. *
  11432. * <p>a Parse.Query can also be used to retrieve a single object whose id is
  11433. * known, through the get method. for example, this sample code fetches an
  11434. * object of class <code>myclass</code> and id <code>myid</code>. it calls a
  11435. * different function depending on whether the fetch succeeded or not.
  11436. *
  11437. * <pre>
  11438. * var query = new Parse.Query(myclass);
  11439. * query.get(myid).then((object) => {
  11440. * // object is an instance of parse.object.
  11441. * }).catch((error) => {
  11442. * // error is an instance of parse.error.
  11443. * });</pre></p>
  11444. *
  11445. * <p>a Parse.Query can also be used to count the number of objects that match
  11446. * the query without retrieving all of those objects. for example, this
  11447. * sample code counts the number of objects of the class <code>myclass</code>
  11448. * <pre>
  11449. * var query = new Parse.Query(myclass);
  11450. * query.count().then((number) => {
  11451. * // there are number instances of myclass.
  11452. * }).catch((error) => {
  11453. * // error is an instance of Parse.Error.
  11454. * });</pre></p>
  11455. *
  11456. * @alias Parse.Query
  11457. */
  11458. var ParseQuery = /*#__PURE__*/function () {
  11459. /**
  11460. * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
  11461. */
  11462. function ParseQuery(objectClass /*: string | ParseObject*/) {
  11463. (0, _classCallCheck2.default)(this, ParseQuery);
  11464. /**
  11465. * @property {string} className
  11466. */
  11467. (0, _defineProperty2.default)(this, "className", void 0);
  11468. (0, _defineProperty2.default)(this, "_where", void 0);
  11469. (0, _defineProperty2.default)(this, "_watch", void 0);
  11470. (0, _defineProperty2.default)(this, "_include", void 0);
  11471. (0, _defineProperty2.default)(this, "_exclude", void 0);
  11472. (0, _defineProperty2.default)(this, "_select", void 0);
  11473. (0, _defineProperty2.default)(this, "_limit", void 0);
  11474. (0, _defineProperty2.default)(this, "_skip", void 0);
  11475. (0, _defineProperty2.default)(this, "_count", void 0);
  11476. (0, _defineProperty2.default)(this, "_order", void 0);
  11477. (0, _defineProperty2.default)(this, "_readPreference", void 0);
  11478. (0, _defineProperty2.default)(this, "_includeReadPreference", void 0);
  11479. (0, _defineProperty2.default)(this, "_subqueryReadPreference", void 0);
  11480. (0, _defineProperty2.default)(this, "_queriesLocalDatastore", void 0);
  11481. (0, _defineProperty2.default)(this, "_localDatastorePinName", void 0);
  11482. (0, _defineProperty2.default)(this, "_extraOptions", void 0);
  11483. (0, _defineProperty2.default)(this, "_hint", void 0);
  11484. (0, _defineProperty2.default)(this, "_explain", void 0);
  11485. (0, _defineProperty2.default)(this, "_xhrRequest", void 0);
  11486. if (typeof objectClass === 'string') {
  11487. if (objectClass === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  11488. this.className = '_User';
  11489. } else {
  11490. this.className = objectClass;
  11491. }
  11492. } else if (objectClass instanceof _ParseObject.default) {
  11493. this.className = objectClass.className;
  11494. } else if (typeof objectClass === 'function') {
  11495. if (typeof objectClass.className === 'string') {
  11496. this.className = objectClass.className;
  11497. } else {
  11498. var _obj2 = new objectClass();
  11499. this.className = _obj2.className;
  11500. }
  11501. } else {
  11502. throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
  11503. }
  11504. this._where = {};
  11505. this._watch = [];
  11506. this._include = [];
  11507. this._exclude = [];
  11508. this._count = false;
  11509. this._limit = -1; // negative limit is not sent in the server request
  11510. this._skip = 0;
  11511. this._readPreference = null;
  11512. this._includeReadPreference = null;
  11513. this._subqueryReadPreference = null;
  11514. this._queriesLocalDatastore = false;
  11515. this._localDatastorePinName = null;
  11516. this._extraOptions = {};
  11517. this._xhrRequest = {
  11518. task: null,
  11519. onchange: function () {}
  11520. };
  11521. }
  11522. /**
  11523. * Adds constraint that at least one of the passed in queries matches.
  11524. *
  11525. * @param {Array} queries
  11526. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11527. */
  11528. (0, _createClass2.default)(ParseQuery, [{
  11529. key: "_orQuery",
  11530. value: function (queries /*: Array<ParseQuery>*/) /*: ParseQuery*/{
  11531. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  11532. return q.toJSON().where;
  11533. });
  11534. this._where.$or = queryJSON;
  11535. return this;
  11536. }
  11537. /**
  11538. * Adds constraint that all of the passed in queries match.
  11539. *
  11540. * @param {Array} queries
  11541. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11542. */
  11543. }, {
  11544. key: "_andQuery",
  11545. value: function (queries /*: Array<ParseQuery>*/) /*: ParseQuery*/{
  11546. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  11547. return q.toJSON().where;
  11548. });
  11549. this._where.$and = queryJSON;
  11550. return this;
  11551. }
  11552. /**
  11553. * Adds constraint that none of the passed in queries match.
  11554. *
  11555. * @param {Array} queries
  11556. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11557. */
  11558. }, {
  11559. key: "_norQuery",
  11560. value: function (queries /*: Array<ParseQuery>*/) /*: ParseQuery*/{
  11561. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  11562. return q.toJSON().where;
  11563. });
  11564. this._where.$nor = queryJSON;
  11565. return this;
  11566. }
  11567. /**
  11568. * Helper for condition queries
  11569. *
  11570. * @param key
  11571. * @param condition
  11572. * @param value
  11573. * @returns {Parse.Query}
  11574. */
  11575. }, {
  11576. key: "_addCondition",
  11577. value: function (key /*: string*/, condition /*: string*/, value /*: mixed*/) /*: ParseQuery*/{
  11578. if (!this._where[key] || typeof this._where[key] === 'string') {
  11579. this._where[key] = {};
  11580. }
  11581. this._where[key][condition] = (0, _encode.default)(value, false, true);
  11582. return this;
  11583. }
  11584. /**
  11585. * Converts string for regular expression at the beginning
  11586. *
  11587. * @param string
  11588. * @returns {string}
  11589. */
  11590. }, {
  11591. key: "_regexStartWith",
  11592. value: function (string /*: string*/) /*: string*/{
  11593. return '^' + quote(string);
  11594. }
  11595. }, {
  11596. key: "_handleOfflineQuery",
  11597. value: function () {
  11598. var _handleOfflineQuery2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(params /*: any*/) {
  11599. var _context,
  11600. _this2 = this;
  11601. var localDatastore, objects, results, keys, alwaysSelectedKeys, sorts, count, limit;
  11602. return _regenerator.default.wrap(function (_context3) {
  11603. while (1) switch (_context3.prev = _context3.next) {
  11604. case 0:
  11605. _OfflineQuery.default.validateQuery(this);
  11606. localDatastore = _CoreManager.default.getLocalDatastore();
  11607. _context3.next = 4;
  11608. return localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
  11609. case 4:
  11610. objects = _context3.sent;
  11611. results = (0, _filter2.default)(_context = (0, _map2.default)(objects).call(objects, function (json, index, arr) {
  11612. var object = _ParseObject.default.fromJSON(json, false);
  11613. if (json._localId && !json.objectId) {
  11614. object._localId = json._localId;
  11615. }
  11616. if (!_OfflineQuery.default.matchesQuery(_this2.className, object, arr, _this2)) {
  11617. return null;
  11618. }
  11619. return object;
  11620. })).call(_context, function (object) {
  11621. return object !== null;
  11622. });
  11623. if ((0, _keys2.default)(params)) {
  11624. keys = (0, _keys2.default)(params).split(',');
  11625. alwaysSelectedKeys = ['className', 'objectId', 'createdAt', 'updatedAt', 'ACL'];
  11626. keys = (0, _concat.default)(keys).call(keys, alwaysSelectedKeys);
  11627. results = (0, _map2.default)(results).call(results, function (object) {
  11628. var _context2;
  11629. var json = object._toFullJSON();
  11630. (0, _forEach.default)(_context2 = (0, _keys.default)(json)).call(_context2, function (key) {
  11631. if (!(0, _includes.default)(keys).call(keys, key)) {
  11632. delete json[key];
  11633. }
  11634. });
  11635. return _ParseObject.default.fromJSON(json, false);
  11636. });
  11637. }
  11638. if (params.order) {
  11639. sorts = params.order.split(',');
  11640. (0, _sort.default)(results).call(results, function (a, b) {
  11641. return handleOfflineSort(a, b, sorts);
  11642. });
  11643. }
  11644. // count total before applying limit/skip
  11645. if (params.count) {
  11646. count = results.length; // total count from response
  11647. }
  11648. if (params.skip) {
  11649. if (params.skip >= results.length) {
  11650. results = [];
  11651. } else {
  11652. results = (0, _splice.default)(results).call(results, params.skip, results.length);
  11653. }
  11654. }
  11655. limit = results.length;
  11656. if (params.limit !== 0 && params.limit < results.length) {
  11657. limit = params.limit;
  11658. }
  11659. results = (0, _splice.default)(results).call(results, 0, limit);
  11660. if (!(typeof count === 'number')) {
  11661. _context3.next = 15;
  11662. break;
  11663. }
  11664. return _context3.abrupt("return", {
  11665. results: results,
  11666. count: count
  11667. });
  11668. case 15:
  11669. return _context3.abrupt("return", results);
  11670. case 16:
  11671. case "end":
  11672. return _context3.stop();
  11673. }
  11674. }, _callee, this);
  11675. }));
  11676. function _handleOfflineQuery() {
  11677. return _handleOfflineQuery2.apply(this, arguments);
  11678. }
  11679. return _handleOfflineQuery;
  11680. }()
  11681. /**
  11682. * Returns a JSON representation of this query.
  11683. *
  11684. * @returns {object} The JSON representation of the query.
  11685. */
  11686. }, {
  11687. key: "toJSON",
  11688. value: function () /*: QueryJSON*/{
  11689. var params /*: QueryJSON*/ = {
  11690. where: this._where
  11691. };
  11692. if (this._watch.length) {
  11693. params.watch = this._watch.join(',');
  11694. }
  11695. if (this._include.length) {
  11696. params.include = this._include.join(',');
  11697. }
  11698. if (this._exclude.length) {
  11699. params.excludeKeys = this._exclude.join(',');
  11700. }
  11701. if (this._select) {
  11702. params.keys = this._select.join(',');
  11703. }
  11704. if (this._count) {
  11705. params.count = 1;
  11706. }
  11707. if (this._limit >= 0) {
  11708. params.limit = this._limit;
  11709. }
  11710. if (this._skip > 0) {
  11711. params.skip = this._skip;
  11712. }
  11713. if (this._order) {
  11714. params.order = this._order.join(',');
  11715. }
  11716. if (this._readPreference) {
  11717. params.readPreference = this._readPreference;
  11718. }
  11719. if (this._includeReadPreference) {
  11720. params.includeReadPreference = this._includeReadPreference;
  11721. }
  11722. if (this._subqueryReadPreference) {
  11723. params.subqueryReadPreference = this._subqueryReadPreference;
  11724. }
  11725. if (this._hint) {
  11726. params.hint = this._hint;
  11727. }
  11728. if (this._explain) {
  11729. params.explain = true;
  11730. }
  11731. for (var _key3 in this._extraOptions) {
  11732. params[_key3] = this._extraOptions[_key3];
  11733. }
  11734. return params;
  11735. }
  11736. /**
  11737. * Return a query with conditions from json, can be useful to send query from server side to client
  11738. * Not static, all query conditions was set before calling this method will be deleted.
  11739. * For example on the server side we have
  11740. * var query = new Parse.Query("className");
  11741. * query.equalTo(key: value);
  11742. * query.limit(100);
  11743. * ... (others queries)
  11744. * Create JSON representation of Query Object
  11745. * var jsonFromServer = query.fromJSON();
  11746. *
  11747. * On client side getting query:
  11748. * var query = new Parse.Query("className");
  11749. * query.fromJSON(jsonFromServer);
  11750. *
  11751. * and continue to query...
  11752. * query.skip(100).find().then(...);
  11753. *
  11754. * @param {QueryJSON} json from Parse.Query.toJSON() method
  11755. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11756. */
  11757. }, {
  11758. key: "withJSON",
  11759. value: function (json /*: QueryJSON*/) /*: ParseQuery*/{
  11760. if (json.where) {
  11761. this._where = json.where;
  11762. }
  11763. if (json.watch) {
  11764. this._watch = json.watch.split(',');
  11765. }
  11766. if (json.include) {
  11767. this._include = json.include.split(',');
  11768. }
  11769. if ((0, _keys2.default)(json)) {
  11770. this._select = (0, _keys2.default)(json).split(',');
  11771. }
  11772. if (json.excludeKeys) {
  11773. this._exclude = json.excludeKeys.split(',');
  11774. }
  11775. if (json.count) {
  11776. this._count = json.count === 1;
  11777. }
  11778. if (json.limit) {
  11779. this._limit = json.limit;
  11780. }
  11781. if (json.skip) {
  11782. this._skip = json.skip;
  11783. }
  11784. if (json.order) {
  11785. this._order = json.order.split(',');
  11786. }
  11787. if (json.readPreference) {
  11788. this._readPreference = json.readPreference;
  11789. }
  11790. if (json.includeReadPreference) {
  11791. this._includeReadPreference = json.includeReadPreference;
  11792. }
  11793. if (json.subqueryReadPreference) {
  11794. this._subqueryReadPreference = json.subqueryReadPreference;
  11795. }
  11796. if (json.hint) {
  11797. this._hint = json.hint;
  11798. }
  11799. if (json.explain) {
  11800. this._explain = !!json.explain;
  11801. }
  11802. for (var _key4 in json) {
  11803. if (json.hasOwnProperty(_key4)) {
  11804. var _context4;
  11805. if ((0, _indexOf.default)(_context4 = ['where', 'include', 'keys', 'count', 'limit', 'skip', 'order', 'readPreference', 'includeReadPreference', 'subqueryReadPreference', 'hint', 'explain']).call(_context4, _key4) === -1) {
  11806. this._extraOptions[_key4] = json[_key4];
  11807. }
  11808. }
  11809. }
  11810. return this;
  11811. }
  11812. /**
  11813. * Static method to restore Parse.Query by json representation
  11814. * Internally calling Parse.Query.withJSON
  11815. *
  11816. * @param {string} className
  11817. * @param {QueryJSON} json from Parse.Query.toJSON() method
  11818. * @returns {Parse.Query} new created query
  11819. */
  11820. }, {
  11821. key: "get",
  11822. value:
  11823. /**
  11824. * Constructs a Parse.Object whose id is already known by fetching data from
  11825. * the server. Unlike the <code>first</code> method, it never returns undefined.
  11826. *
  11827. * @param {string} objectId The id of the object to be fetched.
  11828. * @param {object} options
  11829. * Valid options are:<ul>
  11830. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11831. * be used for this request.
  11832. * <li>sessionToken: A valid session token, used for making a request on
  11833. * behalf of a specific user.
  11834. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  11835. * <li>json: Return raw json without converting to Parse.Object
  11836. * </ul>
  11837. * @returns {Promise} A promise that is resolved with the result when
  11838. * the query completes.
  11839. */
  11840. function (objectId /*: string*/, options /*:: ?: FullOptions*/) /*: Promise<ParseObject>*/{
  11841. this.equalTo('objectId', objectId);
  11842. var firstOptions = {};
  11843. if (options && options.hasOwnProperty('useMasterKey')) {
  11844. firstOptions.useMasterKey = options.useMasterKey;
  11845. }
  11846. if (options && options.hasOwnProperty('sessionToken')) {
  11847. firstOptions.sessionToken = options.sessionToken;
  11848. }
  11849. if (options && options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  11850. firstOptions.context = options.context;
  11851. }
  11852. if (options && options.hasOwnProperty('json')) {
  11853. firstOptions.json = options.json;
  11854. }
  11855. return this.first(firstOptions).then(function (response) {
  11856. if (response) {
  11857. return response;
  11858. }
  11859. var errorObject = new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'Object not found.');
  11860. return _promise.default.reject(errorObject);
  11861. });
  11862. }
  11863. /**
  11864. * Retrieves a list of ParseObjects that satisfy this query.
  11865. *
  11866. * @param {object} options Valid options
  11867. * are:<ul>
  11868. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11869. * be used for this request.
  11870. * <li>sessionToken: A valid session token, used for making a request on
  11871. * behalf of a specific user.
  11872. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  11873. * <li>json: Return raw json without converting to Parse.Object
  11874. * </ul>
  11875. * @returns {Promise} A promise that is resolved with the results when
  11876. * the query completes.
  11877. */
  11878. }, {
  11879. key: "find",
  11880. value: function (options /*:: ?: FullOptions*/) /*: Promise<Array<ParseObject>>*/{
  11881. var _this3 = this;
  11882. options = options || {};
  11883. var findOptions = {};
  11884. if (options.hasOwnProperty('useMasterKey')) {
  11885. findOptions.useMasterKey = options.useMasterKey;
  11886. }
  11887. if (options.hasOwnProperty('sessionToken')) {
  11888. findOptions.sessionToken = options.sessionToken;
  11889. }
  11890. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  11891. findOptions.context = options.context;
  11892. }
  11893. this._setRequestTask(findOptions);
  11894. var controller = _CoreManager.default.getQueryController();
  11895. var select = this._select;
  11896. if (this._queriesLocalDatastore) {
  11897. return this._handleOfflineQuery(this.toJSON());
  11898. }
  11899. return (0, _find.default)(controller).call(controller, this.className, this.toJSON(), findOptions).then(function (response) {
  11900. var _context5;
  11901. // Return generic object when explain is used
  11902. if (_this3._explain) {
  11903. return response.results;
  11904. }
  11905. var results = (0, _map2.default)(_context5 = response.results).call(_context5, function (data) {
  11906. // In cases of relations, the server may send back a className
  11907. // on the top level of the payload
  11908. var override = response.className || _this3.className;
  11909. if (!data.className) {
  11910. data.className = override;
  11911. }
  11912. // Make sure the data object contains keys for all objects that
  11913. // have been requested with a select, so that our cached state
  11914. // updates correctly.
  11915. if (select) {
  11916. handleSelectResult(data, select);
  11917. }
  11918. if (options.json) {
  11919. return data;
  11920. } else {
  11921. return _ParseObject.default.fromJSON(data, !select);
  11922. }
  11923. });
  11924. var count = response.count;
  11925. if (typeof count === 'number') {
  11926. return {
  11927. results: results,
  11928. count: count
  11929. };
  11930. } else {
  11931. return results;
  11932. }
  11933. });
  11934. }
  11935. /**
  11936. * Retrieves a complete list of ParseObjects that satisfy this query.
  11937. * Using `eachBatch` under the hood to fetch all the valid objects.
  11938. *
  11939. * @param {object} options Valid options are:<ul>
  11940. * <li>batchSize: How many objects to yield in each batch (default: 100)
  11941. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11942. * be used for this request.
  11943. * <li>sessionToken: A valid session token, used for making a request on
  11944. * behalf of a specific user.
  11945. * </ul>
  11946. * @returns {Promise} A promise that is resolved with the results when
  11947. * the query completes.
  11948. */
  11949. }, {
  11950. key: "findAll",
  11951. value: function () {
  11952. var _findAll = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(options /*:: ?: BatchOptions*/) {
  11953. var result;
  11954. return _regenerator.default.wrap(function (_context7) {
  11955. while (1) switch (_context7.prev = _context7.next) {
  11956. case 0:
  11957. result /*: ParseObject[]*/ = [];
  11958. _context7.next = 3;
  11959. return this.eachBatch(function (objects /*: ParseObject[]*/) {
  11960. var _context6;
  11961. result = (0, _concat.default)(_context6 = []).call(_context6, (0, _toConsumableArray2.default)(result), (0, _toConsumableArray2.default)(objects));
  11962. }, options);
  11963. case 3:
  11964. return _context7.abrupt("return", result);
  11965. case 4:
  11966. case "end":
  11967. return _context7.stop();
  11968. }
  11969. }, _callee2, this);
  11970. }));
  11971. function findAll() {
  11972. return _findAll.apply(this, arguments);
  11973. }
  11974. return findAll;
  11975. }()
  11976. /**
  11977. * Counts the number of objects that match this query.
  11978. *
  11979. * @param {object} options
  11980. * Valid options are:<ul>
  11981. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11982. * be used for this request.
  11983. * <li>sessionToken: A valid session token, used for making a request on
  11984. * behalf of a specific user.
  11985. * </ul>
  11986. * @returns {Promise} A promise that is resolved with the count when
  11987. * the query completes.
  11988. */
  11989. }, {
  11990. key: "count",
  11991. value: function (options /*:: ?: FullOptions*/) /*: Promise<number>*/{
  11992. options = options || {};
  11993. var findOptions = {};
  11994. if (options.hasOwnProperty('useMasterKey')) {
  11995. findOptions.useMasterKey = options.useMasterKey;
  11996. }
  11997. if (options.hasOwnProperty('sessionToken')) {
  11998. findOptions.sessionToken = options.sessionToken;
  11999. }
  12000. this._setRequestTask(findOptions);
  12001. var controller = _CoreManager.default.getQueryController();
  12002. var params = this.toJSON();
  12003. params.limit = 0;
  12004. params.count = 1;
  12005. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(function (result) {
  12006. return result.count;
  12007. });
  12008. }
  12009. /**
  12010. * Executes a distinct query and returns unique values
  12011. *
  12012. * @param {string} key A field to find distinct values
  12013. * @param {object} options
  12014. * Valid options are:<ul>
  12015. * <li>sessionToken: A valid session token, used for making a request on
  12016. * behalf of a specific user.
  12017. * </ul>
  12018. * @returns {Promise} A promise that is resolved with the query completes.
  12019. */
  12020. }, {
  12021. key: "distinct",
  12022. value: function (key /*: string*/, options /*:: ?: FullOptions*/) /*: Promise<Array<mixed>>*/{
  12023. options = options || {};
  12024. var distinctOptions = {};
  12025. distinctOptions.useMasterKey = true;
  12026. if (options.hasOwnProperty('sessionToken')) {
  12027. distinctOptions.sessionToken = options.sessionToken;
  12028. }
  12029. this._setRequestTask(distinctOptions);
  12030. var controller = _CoreManager.default.getQueryController();
  12031. var params = {
  12032. distinct: key,
  12033. where: this._where,
  12034. hint: this._hint
  12035. };
  12036. return controller.aggregate(this.className, params, distinctOptions).then(function (results) {
  12037. return results.results;
  12038. });
  12039. }
  12040. /**
  12041. * Executes an aggregate query and returns aggregate results
  12042. *
  12043. * @param {(Array|object)} pipeline Array or Object of stages to process query
  12044. * @param {object} options Valid options are:<ul>
  12045. * <li>sessionToken: A valid session token, used for making a request on
  12046. * behalf of a specific user.
  12047. * </ul>
  12048. * @returns {Promise} A promise that is resolved with the query completes.
  12049. */
  12050. }, {
  12051. key: "aggregate",
  12052. value: function (pipeline /*: mixed*/, options /*:: ?: FullOptions*/) /*: Promise<Array<mixed>>*/{
  12053. options = options || {};
  12054. var aggregateOptions = {};
  12055. aggregateOptions.useMasterKey = true;
  12056. if (options.hasOwnProperty('sessionToken')) {
  12057. aggregateOptions.sessionToken = options.sessionToken;
  12058. }
  12059. this._setRequestTask(aggregateOptions);
  12060. var controller = _CoreManager.default.getQueryController();
  12061. if (!(0, _isArray.default)(pipeline) && (0, _typeof2.default)(pipeline) !== 'object') {
  12062. throw new Error('Invalid pipeline must be Array or Object');
  12063. }
  12064. if ((0, _keys.default)(this._where || {}).length) {
  12065. if (!(0, _isArray.default)(pipeline)) {
  12066. pipeline = [pipeline];
  12067. }
  12068. pipeline.unshift({
  12069. $match: this._where
  12070. });
  12071. }
  12072. var params = {
  12073. pipeline: pipeline,
  12074. hint: this._hint,
  12075. explain: this._explain,
  12076. readPreference: this._readPreference
  12077. };
  12078. return controller.aggregate(this.className, params, aggregateOptions).then(function (results) {
  12079. return results.results;
  12080. });
  12081. }
  12082. /**
  12083. * Retrieves at most one Parse.Object that satisfies this query.
  12084. *
  12085. * Returns the object if there is one, otherwise undefined.
  12086. *
  12087. * @param {object} options Valid options are:<ul>
  12088. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12089. * be used for this request.
  12090. * <li>sessionToken: A valid session token, used for making a request on
  12091. * behalf of a specific user.
  12092. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  12093. * <li>json: Return raw json without converting to Parse.Object
  12094. * </ul>
  12095. * @returns {Promise} A promise that is resolved with the object when
  12096. * the query completes.
  12097. */
  12098. }, {
  12099. key: "first",
  12100. value: function (options /*:: ?: FullOptions*/) /*: Promise<ParseObject | void>*/{
  12101. var _this4 = this;
  12102. options = options || {};
  12103. var findOptions = {};
  12104. if (options.hasOwnProperty('useMasterKey')) {
  12105. findOptions.useMasterKey = options.useMasterKey;
  12106. }
  12107. if (options.hasOwnProperty('sessionToken')) {
  12108. findOptions.sessionToken = options.sessionToken;
  12109. }
  12110. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  12111. findOptions.context = options.context;
  12112. }
  12113. this._setRequestTask(findOptions);
  12114. var controller = _CoreManager.default.getQueryController();
  12115. var params = this.toJSON();
  12116. params.limit = 1;
  12117. var select = this._select;
  12118. if (this._queriesLocalDatastore) {
  12119. return this._handleOfflineQuery(params).then(function (objects) {
  12120. if (!objects[0]) {
  12121. return undefined;
  12122. }
  12123. return objects[0];
  12124. });
  12125. }
  12126. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(function (response) {
  12127. var objects = response.results;
  12128. if (!objects[0]) {
  12129. return undefined;
  12130. }
  12131. if (!objects[0].className) {
  12132. objects[0].className = _this4.className;
  12133. }
  12134. // Make sure the data object contains keys for all objects that
  12135. // have been requested with a select, so that our cached state
  12136. // updates correctly.
  12137. if (select) {
  12138. handleSelectResult(objects[0], select);
  12139. }
  12140. if (options.json) {
  12141. return objects[0];
  12142. } else {
  12143. return _ParseObject.default.fromJSON(objects[0], !select);
  12144. }
  12145. });
  12146. }
  12147. /**
  12148. * Iterates over objects matching a query, calling a callback for each batch.
  12149. * If the callback returns a promise, the iteration will not continue until
  12150. * that promise has been fulfilled. If the callback returns a rejected
  12151. * promise, then iteration will stop with that error. The items are processed
  12152. * in an unspecified order. The query may not have any sort order, and may
  12153. * not use limit or skip.
  12154. *
  12155. * @param {Function} callback Callback that will be called with each result
  12156. * of the query.
  12157. * @param {object} options Valid options are:<ul>
  12158. * <li>batchSize: How many objects to yield in each batch (default: 100)
  12159. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12160. * be used for this request.
  12161. * <li>sessionToken: A valid session token, used for making a request on
  12162. * behalf of a specific user.
  12163. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  12164. * </ul>
  12165. * @returns {Promise} A promise that will be fulfilled once the
  12166. * iteration has completed.
  12167. */
  12168. }, {
  12169. key: "eachBatch",
  12170. value: function (callback /*: (objs: Array<ParseObject>) => Promise<*>*/, options /*:: ?: BatchOptions*/) /*: Promise<void>*/{
  12171. var _context8;
  12172. options = options || {};
  12173. if (this._order || this._skip || this._limit >= 0) {
  12174. return _promise.default.reject('Cannot iterate on a query with sort, skip, or limit.');
  12175. }
  12176. var query = new ParseQuery(this.className);
  12177. query._limit = options.batchSize || 100;
  12178. query._include = (0, _map2.default)(_context8 = this._include).call(_context8, function (i) {
  12179. return i;
  12180. });
  12181. if (this._select) {
  12182. var _context9;
  12183. query._select = (0, _map2.default)(_context9 = this._select).call(_context9, function (s) {
  12184. return s;
  12185. });
  12186. }
  12187. query._hint = this._hint;
  12188. query._where = {};
  12189. for (var _attr in this._where) {
  12190. var val = this._where[_attr];
  12191. if ((0, _isArray.default)(val)) {
  12192. query._where[_attr] = (0, _map2.default)(val).call(val, function (v) {
  12193. return v;
  12194. });
  12195. } else if (val && (0, _typeof2.default)(val) === 'object') {
  12196. var conditionMap = {};
  12197. query._where[_attr] = conditionMap;
  12198. for (var cond in val) {
  12199. conditionMap[cond] = val[cond];
  12200. }
  12201. } else {
  12202. query._where[_attr] = val;
  12203. }
  12204. }
  12205. query.ascending('objectId');
  12206. var findOptions = {};
  12207. if (options.hasOwnProperty('useMasterKey')) {
  12208. findOptions.useMasterKey = options.useMasterKey;
  12209. }
  12210. if (options.hasOwnProperty('sessionToken')) {
  12211. findOptions.sessionToken = options.sessionToken;
  12212. }
  12213. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  12214. findOptions.context = options.context;
  12215. }
  12216. if (options.hasOwnProperty('json')) {
  12217. findOptions.json = options.json;
  12218. }
  12219. var finished = false;
  12220. var previousResults = [];
  12221. return (0, _promiseUtils.continueWhile)(function () {
  12222. return !finished;
  12223. }, /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  12224. var _yield$Promise$all, _yield$Promise$all2, results;
  12225. return _regenerator.default.wrap(function (_context10) {
  12226. while (1) switch (_context10.prev = _context10.next) {
  12227. case 0:
  12228. _context10.next = 2;
  12229. return _promise.default.all([(0, _find.default)(query).call(query, findOptions), _promise.default.resolve(previousResults.length > 0 && callback(previousResults))]);
  12230. case 2:
  12231. _yield$Promise$all = _context10.sent;
  12232. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1);
  12233. results = _yield$Promise$all2[0];
  12234. if (!(results.length >= query._limit)) {
  12235. _context10.next = 10;
  12236. break;
  12237. }
  12238. query.greaterThan('objectId', results[results.length - 1].id);
  12239. previousResults = results;
  12240. _context10.next = 17;
  12241. break;
  12242. case 10:
  12243. if (!(results.length > 0)) {
  12244. _context10.next = 16;
  12245. break;
  12246. }
  12247. _context10.next = 13;
  12248. return _promise.default.resolve(callback(results));
  12249. case 13:
  12250. finished = true;
  12251. _context10.next = 17;
  12252. break;
  12253. case 16:
  12254. finished = true;
  12255. case 17:
  12256. case "end":
  12257. return _context10.stop();
  12258. }
  12259. }, _callee3);
  12260. })));
  12261. }
  12262. /**
  12263. * Iterates over each result of a query, calling a callback for each one. If
  12264. * the callback returns a promise, the iteration will not continue until
  12265. * that promise has been fulfilled. If the callback returns a rejected
  12266. * promise, then iteration will stop with that error. The items are
  12267. * processed in an unspecified order. The query may not have any sort order,
  12268. * and may not use limit or skip.
  12269. *
  12270. * @param {Function} callback Callback that will be called with each result
  12271. * of the query.
  12272. * @param {object} options Valid options are:<ul>
  12273. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12274. * be used for this request.
  12275. * <li>sessionToken: A valid session token, used for making a request on
  12276. * behalf of a specific user.
  12277. * <li>json: Return raw json without converting to Parse.Object
  12278. * </ul>
  12279. * @returns {Promise} A promise that will be fulfilled once the
  12280. * iteration has completed.
  12281. */
  12282. }, {
  12283. key: "each",
  12284. value: function (callback /*: (obj: ParseObject) => any*/, options /*:: ?: BatchOptions*/) /*: Promise<void>*/{
  12285. return this.eachBatch(function (results) {
  12286. var callbacksDone = _promise.default.resolve();
  12287. (0, _forEach.default)(results).call(results, function (result) {
  12288. callbacksDone = callbacksDone.then(function () {
  12289. return callback(result);
  12290. });
  12291. });
  12292. return callbacksDone;
  12293. }, options);
  12294. }
  12295. /**
  12296. * Adds a hint to force index selection. (https://docs.mongodb.com/manual/reference/operator/meta/hint/)
  12297. *
  12298. * @param {(string|object)} value String or Object of index that should be used when executing query
  12299. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12300. */
  12301. }, {
  12302. key: "hint",
  12303. value: function (value /*: mixed*/) /*: ParseQuery*/{
  12304. if (typeof value === 'undefined') {
  12305. delete this._hint;
  12306. }
  12307. this._hint = value;
  12308. return this;
  12309. }
  12310. /**
  12311. * Investigates the query execution plan. Useful for optimizing queries. (https://docs.mongodb.com/manual/reference/operator/meta/explain/)
  12312. *
  12313. * @param {boolean} explain Used to toggle the information on the query plan.
  12314. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12315. */
  12316. }, {
  12317. key: "explain",
  12318. value: function () /*: ParseQuery*/{
  12319. var _explain /*: boolean*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  12320. if (typeof _explain !== 'boolean') {
  12321. throw new Error('You can only set explain to a boolean value');
  12322. }
  12323. this._explain = _explain;
  12324. return this;
  12325. }
  12326. /**
  12327. * Iterates over each result of a query, calling a callback for each one. If
  12328. * the callback returns a promise, the iteration will not continue until
  12329. * that promise has been fulfilled. If the callback returns a rejected
  12330. * promise, then iteration will stop with that error. The items are
  12331. * processed in an unspecified order. The query may not have any sort order,
  12332. * and may not use limit or skip.
  12333. *
  12334. * @param {Function} callback Callback <ul>
  12335. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  12336. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  12337. * <li>query: The query map was called upon.</li>
  12338. * </ul>
  12339. * @param {object} options Valid options are:<ul>
  12340. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12341. * be used for this request.
  12342. * <li>sessionToken: A valid session token, used for making a request on
  12343. * behalf of a specific user.
  12344. * </ul>
  12345. * @returns {Promise} A promise that will be fulfilled once the
  12346. * iteration has completed.
  12347. */
  12348. }, {
  12349. key: "map",
  12350. value: function () {
  12351. var _map = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(callback /*: (currentObject: ParseObject, index: number, query: ParseQuery) => any*/, options /*:: ?: BatchOptions*/) {
  12352. var _this5 = this;
  12353. var array, index;
  12354. return _regenerator.default.wrap(function (_context11) {
  12355. while (1) switch (_context11.prev = _context11.next) {
  12356. case 0:
  12357. array = [];
  12358. index = 0;
  12359. _context11.next = 4;
  12360. return this.each(function (object) {
  12361. return _promise.default.resolve(callback(object, index, _this5)).then(function (result) {
  12362. array.push(result);
  12363. index += 1;
  12364. });
  12365. }, options);
  12366. case 4:
  12367. return _context11.abrupt("return", array);
  12368. case 5:
  12369. case "end":
  12370. return _context11.stop();
  12371. }
  12372. }, _callee4, this);
  12373. }));
  12374. function map() {
  12375. return _map.apply(this, arguments);
  12376. }
  12377. return map;
  12378. }()
  12379. /**
  12380. * Iterates over each result of a query, calling a callback for each one. If
  12381. * the callback returns a promise, the iteration will not continue until
  12382. * that promise has been fulfilled. If the callback returns a rejected
  12383. * promise, then iteration will stop with that error. The items are
  12384. * processed in an unspecified order. The query may not have any sort order,
  12385. * and may not use limit or skip.
  12386. *
  12387. * @param {Function} callback Callback <ul>
  12388. * <li>accumulator: The accumulator accumulates the callback's return values. It is the accumulated value previously returned in the last invocation of the callback.</li>
  12389. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  12390. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  12391. * </ul>
  12392. * @param {*} initialValue A value to use as the first argument to the first call of the callback. If no initialValue is supplied, the first object in the query will be used and skipped.
  12393. * @param {object} options Valid options are:<ul>
  12394. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12395. * be used for this request.
  12396. * <li>sessionToken: A valid session token, used for making a request on
  12397. * behalf of a specific user.
  12398. * </ul>
  12399. * @returns {Promise} A promise that will be fulfilled once the
  12400. * iteration has completed.
  12401. */
  12402. }, {
  12403. key: "reduce",
  12404. value: function () {
  12405. var _reduce = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(callback /*: (accumulator: any, currentObject: ParseObject, index: number) => any*/, initialValue /*: any*/, options /*:: ?: BatchOptions*/) {
  12406. var accumulator, index;
  12407. return _regenerator.default.wrap(function (_context12) {
  12408. while (1) switch (_context12.prev = _context12.next) {
  12409. case 0:
  12410. accumulator = initialValue;
  12411. index = 0;
  12412. _context12.next = 4;
  12413. return this.each(function (object) {
  12414. // If no initial value was given, we take the first object from the query
  12415. // as the initial value and don't call the callback with it.
  12416. if (index === 0 && initialValue === undefined) {
  12417. accumulator = object;
  12418. index += 1;
  12419. return;
  12420. }
  12421. return _promise.default.resolve(callback(accumulator, object, index)).then(function (result) {
  12422. accumulator = result;
  12423. index += 1;
  12424. });
  12425. }, options);
  12426. case 4:
  12427. if (!(index === 0 && initialValue === undefined)) {
  12428. _context12.next = 6;
  12429. break;
  12430. }
  12431. throw new TypeError('Reducing empty query result set with no initial value');
  12432. case 6:
  12433. return _context12.abrupt("return", accumulator);
  12434. case 7:
  12435. case "end":
  12436. return _context12.stop();
  12437. }
  12438. }, _callee5, this);
  12439. }));
  12440. function reduce() {
  12441. return _reduce.apply(this, arguments);
  12442. }
  12443. return reduce;
  12444. }()
  12445. /**
  12446. * Iterates over each result of a query, calling a callback for each one. If
  12447. * the callback returns a promise, the iteration will not continue until
  12448. * that promise has been fulfilled. If the callback returns a rejected
  12449. * promise, then iteration will stop with that error. The items are
  12450. * processed in an unspecified order. The query may not have any sort order,
  12451. * and may not use limit or skip.
  12452. *
  12453. * @param {Function} callback Callback <ul>
  12454. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  12455. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  12456. * <li>query: The query filter was called upon.</li>
  12457. * </ul>
  12458. * @param {object} options Valid options are:<ul>
  12459. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12460. * be used for this request.
  12461. * <li>sessionToken: A valid session token, used for making a request on
  12462. * behalf of a specific user.
  12463. * </ul>
  12464. * @returns {Promise} A promise that will be fulfilled once the
  12465. * iteration has completed.
  12466. */
  12467. }, {
  12468. key: "filter",
  12469. value: function () {
  12470. var _filter = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(callback /*: (currentObject: ParseObject, index: number, query: ParseQuery) => boolean*/, options /*:: ?: BatchOptions*/) {
  12471. var _this6 = this;
  12472. var array, index;
  12473. return _regenerator.default.wrap(function (_context13) {
  12474. while (1) switch (_context13.prev = _context13.next) {
  12475. case 0:
  12476. array = [];
  12477. index = 0;
  12478. _context13.next = 4;
  12479. return this.each(function (object) {
  12480. return _promise.default.resolve(callback(object, index, _this6)).then(function (flag) {
  12481. if (flag) {
  12482. array.push(object);
  12483. }
  12484. index += 1;
  12485. });
  12486. }, options);
  12487. case 4:
  12488. return _context13.abrupt("return", array);
  12489. case 5:
  12490. case "end":
  12491. return _context13.stop();
  12492. }
  12493. }, _callee6, this);
  12494. }));
  12495. function filter() {
  12496. return _filter.apply(this, arguments);
  12497. }
  12498. return filter;
  12499. }()
  12500. /* Query Conditions */
  12501. /**
  12502. * Adds a constraint to the query that requires a particular key's value to
  12503. * be equal to the provided value.
  12504. *
  12505. * @param {string} key The key to check.
  12506. * @param value The value that the Parse.Object must contain.
  12507. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12508. */
  12509. }, {
  12510. key: "equalTo",
  12511. value: function (key /*: string | { [key: string]: any }*/, value /*: ?mixed*/) /*: ParseQuery*/{
  12512. var _this7 = this;
  12513. if (key && (0, _typeof2.default)(key) === 'object') {
  12514. var _context14;
  12515. (0, _forEach.default)(_context14 = (0, _entries.default)(key)).call(_context14, function (_ref2) {
  12516. var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
  12517. k = _ref3[0],
  12518. val = _ref3[1];
  12519. return _this7.equalTo(k, val);
  12520. });
  12521. return this;
  12522. }
  12523. if (typeof value === 'undefined') {
  12524. return this.doesNotExist(key);
  12525. }
  12526. this._where[key] = (0, _encode.default)(value, false, true);
  12527. return this;
  12528. }
  12529. /**
  12530. * Adds a constraint to the query that requires a particular key's value to
  12531. * be not equal to the provided value.
  12532. *
  12533. * @param {string} key The key to check.
  12534. * @param value The value that must not be equalled.
  12535. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12536. */
  12537. }, {
  12538. key: "notEqualTo",
  12539. value: function (key /*: string | { [key: string]: any }*/, value /*: ?mixed*/) /*: ParseQuery*/{
  12540. var _this8 = this;
  12541. if (key && (0, _typeof2.default)(key) === 'object') {
  12542. var _context15;
  12543. (0, _forEach.default)(_context15 = (0, _entries.default)(key)).call(_context15, function (_ref4) {
  12544. var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
  12545. k = _ref5[0],
  12546. val = _ref5[1];
  12547. return _this8.notEqualTo(k, val);
  12548. });
  12549. return this;
  12550. }
  12551. return this._addCondition(key, '$ne', value);
  12552. }
  12553. /**
  12554. * Adds a constraint to the query that requires a particular key's value to
  12555. * be less than the provided value.
  12556. *
  12557. * @param {string} key The key to check.
  12558. * @param value The value that provides an upper bound.
  12559. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12560. */
  12561. }, {
  12562. key: "lessThan",
  12563. value: function (key /*: string*/, value /*: mixed*/) /*: ParseQuery*/{
  12564. return this._addCondition(key, '$lt', value);
  12565. }
  12566. /**
  12567. * Adds a constraint to the query that requires a particular key's value to
  12568. * be greater than the provided value.
  12569. *
  12570. * @param {string} key The key to check.
  12571. * @param value The value that provides an lower bound.
  12572. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12573. */
  12574. }, {
  12575. key: "greaterThan",
  12576. value: function (key /*: string*/, value /*: mixed*/) /*: ParseQuery*/{
  12577. return this._addCondition(key, '$gt', value);
  12578. }
  12579. /**
  12580. * Adds a constraint to the query that requires a particular key's value to
  12581. * be less than or equal to the provided value.
  12582. *
  12583. * @param {string} key The key to check.
  12584. * @param value The value that provides an upper bound.
  12585. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12586. */
  12587. }, {
  12588. key: "lessThanOrEqualTo",
  12589. value: function (key /*: string*/, value /*: mixed*/) /*: ParseQuery*/{
  12590. return this._addCondition(key, '$lte', value);
  12591. }
  12592. /**
  12593. * Adds a constraint to the query that requires a particular key's value to
  12594. * be greater than or equal to the provided value.
  12595. *
  12596. * @param {string} key The key to check.
  12597. * @param {*} value The value that provides an lower bound.
  12598. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12599. */
  12600. }, {
  12601. key: "greaterThanOrEqualTo",
  12602. value: function (key /*: string*/, value /*: mixed*/) /*: ParseQuery*/{
  12603. return this._addCondition(key, '$gte', value);
  12604. }
  12605. /**
  12606. * Adds a constraint to the query that requires a particular key's value to
  12607. * be contained in the provided list of values.
  12608. *
  12609. * @param {string} key The key to check.
  12610. * @param {Array<*>} value The values that will match.
  12611. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12612. */
  12613. }, {
  12614. key: "containedIn",
  12615. value: function (key /*: string*/, value /*: Array<mixed>*/) /*: ParseQuery*/{
  12616. return this._addCondition(key, '$in', value);
  12617. }
  12618. /**
  12619. * Adds a constraint to the query that requires a particular key's value to
  12620. * not be contained in the provided list of values.
  12621. *
  12622. * @param {string} key The key to check.
  12623. * @param {Array<*>} value The values that will not match.
  12624. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12625. */
  12626. }, {
  12627. key: "notContainedIn",
  12628. value: function (key /*: string*/, value /*: Array<mixed>*/) /*: ParseQuery*/{
  12629. return this._addCondition(key, '$nin', value);
  12630. }
  12631. /**
  12632. * Adds a constraint to the query that requires a particular key's value to
  12633. * be contained by the provided list of values. Get objects where all array elements match.
  12634. *
  12635. * @param {string} key The key to check.
  12636. * @param {Array} values The values that will match.
  12637. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12638. */
  12639. }, {
  12640. key: "containedBy",
  12641. value: function (key /*: string*/, values /*: Array<mixed>*/) /*: ParseQuery*/{
  12642. return this._addCondition(key, '$containedBy', values);
  12643. }
  12644. /**
  12645. * Adds a constraint to the query that requires a particular key's value to
  12646. * contain each one of the provided list of values.
  12647. *
  12648. * @param {string} key The key to check. This key's value must be an array.
  12649. * @param {Array} values The values that will match.
  12650. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12651. */
  12652. }, {
  12653. key: "containsAll",
  12654. value: function (key /*: string*/, values /*: Array<mixed>*/) /*: ParseQuery*/{
  12655. return this._addCondition(key, '$all', values);
  12656. }
  12657. /**
  12658. * Adds a constraint to the query that requires a particular key's value to
  12659. * contain each one of the provided list of values starting with given strings.
  12660. *
  12661. * @param {string} key The key to check. This key's value must be an array.
  12662. * @param {Array<string>} values The string values that will match as starting string.
  12663. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12664. */
  12665. }, {
  12666. key: "containsAllStartingWith",
  12667. value: function (key /*: string*/, values /*: Array<string>*/) /*: ParseQuery*/{
  12668. var _this = this;
  12669. if (!(0, _isArray.default)(values)) {
  12670. values = [values];
  12671. }
  12672. var regexObject = (0, _map2.default)(values).call(values, function (value) {
  12673. return {
  12674. $regex: _this._regexStartWith(value)
  12675. };
  12676. });
  12677. return this.containsAll(key, regexObject);
  12678. }
  12679. /**
  12680. * Adds a constraint for finding objects that contain the given key.
  12681. *
  12682. * @param {string} key The key that should exist.
  12683. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12684. */
  12685. }, {
  12686. key: "exists",
  12687. value: function (key /*: string*/) /*: ParseQuery*/{
  12688. return this._addCondition(key, '$exists', true);
  12689. }
  12690. /**
  12691. * Adds a constraint for finding objects that do not contain a given key.
  12692. *
  12693. * @param {string} key The key that should not exist
  12694. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12695. */
  12696. }, {
  12697. key: "doesNotExist",
  12698. value: function (key /*: string*/) /*: ParseQuery*/{
  12699. return this._addCondition(key, '$exists', false);
  12700. }
  12701. /**
  12702. * Adds a regular expression constraint for finding string values that match
  12703. * the provided regular expression.
  12704. * This may be slow for large datasets.
  12705. *
  12706. * @param {string} key The key that the string to match is stored in.
  12707. * @param {RegExp} regex The regular expression pattern to match.
  12708. * @param {string} modifiers The regular expression mode.
  12709. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12710. */
  12711. }, {
  12712. key: "matches",
  12713. value: function (key /*: string*/, regex /*: RegExp*/, modifiers /*: string*/) /*: ParseQuery*/{
  12714. this._addCondition(key, '$regex', regex);
  12715. if (!modifiers) {
  12716. modifiers = '';
  12717. }
  12718. if (regex.ignoreCase) {
  12719. modifiers += 'i';
  12720. }
  12721. if (regex.multiline) {
  12722. modifiers += 'm';
  12723. }
  12724. if (modifiers.length) {
  12725. this._addCondition(key, '$options', modifiers);
  12726. }
  12727. return this;
  12728. }
  12729. /**
  12730. * Adds a constraint that requires that a key's value matches a Parse.Query
  12731. * constraint.
  12732. *
  12733. * @param {string} key The key that the contains the object to match the
  12734. * query.
  12735. * @param {Parse.Query} query The query that should match.
  12736. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12737. */
  12738. }, {
  12739. key: "matchesQuery",
  12740. value: function (key /*: string*/, query /*: ParseQuery*/) /*: ParseQuery*/{
  12741. var queryJSON = query.toJSON();
  12742. queryJSON.className = query.className;
  12743. return this._addCondition(key, '$inQuery', queryJSON);
  12744. }
  12745. /**
  12746. * Adds a constraint that requires that a key's value not matches a
  12747. * Parse.Query constraint.
  12748. *
  12749. * @param {string} key The key that the contains the object to match the
  12750. * query.
  12751. * @param {Parse.Query} query The query that should not match.
  12752. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12753. */
  12754. }, {
  12755. key: "doesNotMatchQuery",
  12756. value: function (key /*: string*/, query /*: ParseQuery*/) /*: ParseQuery*/{
  12757. var queryJSON = query.toJSON();
  12758. queryJSON.className = query.className;
  12759. return this._addCondition(key, '$notInQuery', queryJSON);
  12760. }
  12761. /**
  12762. * Adds a constraint that requires that a key's value matches a value in
  12763. * an object returned by a different Parse.Query.
  12764. *
  12765. * @param {string} key The key that contains the value that is being
  12766. * matched.
  12767. * @param {string} queryKey The key in the objects returned by the query to
  12768. * match against.
  12769. * @param {Parse.Query} query The query to run.
  12770. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12771. */
  12772. }, {
  12773. key: "matchesKeyInQuery",
  12774. value: function (key /*: string*/, queryKey /*: string*/, query /*: ParseQuery*/) /*: ParseQuery*/{
  12775. var queryJSON = query.toJSON();
  12776. queryJSON.className = query.className;
  12777. return this._addCondition(key, '$select', {
  12778. key: queryKey,
  12779. query: queryJSON
  12780. });
  12781. }
  12782. /**
  12783. * Adds a constraint that requires that a key's value not match a value in
  12784. * an object returned by a different Parse.Query.
  12785. *
  12786. * @param {string} key The key that contains the value that is being
  12787. * excluded.
  12788. * @param {string} queryKey The key in the objects returned by the query to
  12789. * match against.
  12790. * @param {Parse.Query} query The query to run.
  12791. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12792. */
  12793. }, {
  12794. key: "doesNotMatchKeyInQuery",
  12795. value: function (key /*: string*/, queryKey /*: string*/, query /*: ParseQuery*/) /*: ParseQuery*/{
  12796. var queryJSON = query.toJSON();
  12797. queryJSON.className = query.className;
  12798. return this._addCondition(key, '$dontSelect', {
  12799. key: queryKey,
  12800. query: queryJSON
  12801. });
  12802. }
  12803. /**
  12804. * Adds a constraint for finding string values that contain a provided
  12805. * string. This may be slow for large datasets.
  12806. *
  12807. * @param {string} key The key that the string to match is stored in.
  12808. * @param {string} substring The substring that the value must contain.
  12809. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12810. */
  12811. }, {
  12812. key: "contains",
  12813. value: function (key /*: string*/, substring /*: string*/) /*: ParseQuery*/{
  12814. if (typeof substring !== 'string') {
  12815. throw new Error('The value being searched for must be a string.');
  12816. }
  12817. return this._addCondition(key, '$regex', quote(substring));
  12818. }
  12819. /**
  12820. * Adds a constraint for finding string values that contain a provided
  12821. * string. This may be slow for large datasets. Requires Parse-Server > 2.5.0
  12822. *
  12823. * In order to sort you must use select and ascending ($score is required)
  12824. * <pre>
  12825. * query.fullText('field', 'term');
  12826. * query.ascending('$score');
  12827. * query.select('$score');
  12828. * </pre>
  12829. *
  12830. * To retrieve the weight / rank
  12831. * <pre>
  12832. * object->get('score');
  12833. * </pre>
  12834. *
  12835. * You can define optionals by providing an object as a third parameter
  12836. * <pre>
  12837. * query.fullText('field', 'term', { language: 'es', diacriticSensitive: true });
  12838. * </pre>
  12839. *
  12840. * @param {string} key The key that the string to match is stored in.
  12841. * @param {string} value The string to search
  12842. * @param {object} options (Optional)
  12843. * @param {string} options.language The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer.
  12844. * @param {boolean} options.caseSensitive A boolean flag to enable or disable case sensitive search.
  12845. * @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search.
  12846. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12847. */
  12848. }, {
  12849. key: "fullText",
  12850. value: function (key /*: string*/, value /*: string*/, options /*: ?Object*/) /*: ParseQuery*/{
  12851. options = options || {};
  12852. if (!key) {
  12853. throw new Error('A key is required.');
  12854. }
  12855. if (!value) {
  12856. throw new Error('A search term is required');
  12857. }
  12858. if (typeof value !== 'string') {
  12859. throw new Error('The value being searched for must be a string.');
  12860. }
  12861. var fullOptions = {};
  12862. fullOptions.$term = value;
  12863. for (var option in options) {
  12864. switch (option) {
  12865. case 'language':
  12866. fullOptions.$language = options[option];
  12867. break;
  12868. case 'caseSensitive':
  12869. fullOptions.$caseSensitive = options[option];
  12870. break;
  12871. case 'diacriticSensitive':
  12872. fullOptions.$diacriticSensitive = options[option];
  12873. break;
  12874. default:
  12875. throw new Error("Unknown option: ".concat(option));
  12876. }
  12877. }
  12878. return this._addCondition(key, '$text', {
  12879. $search: fullOptions
  12880. });
  12881. }
  12882. /**
  12883. * Method to sort the full text search by text score
  12884. *
  12885. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12886. */
  12887. }, {
  12888. key: "sortByTextScore",
  12889. value: function () {
  12890. this.ascending('$score');
  12891. this.select(['$score']);
  12892. return this;
  12893. }
  12894. /**
  12895. * Adds a constraint for finding string values that start with a provided
  12896. * string. This query will use the backend index, so it will be fast even
  12897. * for large datasets.
  12898. *
  12899. * @param {string} key The key that the string to match is stored in.
  12900. * @param {string} prefix The substring that the value must start with.
  12901. * @param {string} modifiers The regular expression mode.
  12902. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12903. */
  12904. }, {
  12905. key: "startsWith",
  12906. value: function (key /*: string*/, prefix /*: string*/, modifiers /*: string*/) /*: ParseQuery*/{
  12907. if (typeof prefix !== 'string') {
  12908. throw new Error('The value being searched for must be a string.');
  12909. }
  12910. return this.matches(key, this._regexStartWith(prefix), modifiers);
  12911. }
  12912. /**
  12913. * Adds a constraint for finding string values that end with a provided
  12914. * string. This will be slow for large datasets.
  12915. *
  12916. * @param {string} key The key that the string to match is stored in.
  12917. * @param {string} suffix The substring that the value must end with.
  12918. * @param {string} modifiers The regular expression mode.
  12919. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12920. */
  12921. }, {
  12922. key: "endsWith",
  12923. value: function (key /*: string*/, suffix /*: string*/, modifiers /*: string*/) /*: ParseQuery*/{
  12924. if (typeof suffix !== 'string') {
  12925. throw new Error('The value being searched for must be a string.');
  12926. }
  12927. return this.matches(key, quote(suffix) + '$', modifiers);
  12928. }
  12929. /**
  12930. * Adds a proximity based constraint for finding objects with key point
  12931. * values near the point given.
  12932. *
  12933. * @param {string} key The key that the Parse.GeoPoint is stored in.
  12934. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  12935. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12936. */
  12937. }, {
  12938. key: "near",
  12939. value: function (key /*: string*/, point /*: ParseGeoPoint*/) /*: ParseQuery*/{
  12940. if (!(point instanceof _ParseGeoPoint.default)) {
  12941. // Try to cast it as a GeoPoint
  12942. point = new _ParseGeoPoint.default(point);
  12943. }
  12944. return this._addCondition(key, '$nearSphere', point);
  12945. }
  12946. /**
  12947. * Adds a proximity based constraint for finding objects with key point
  12948. * values near the point given and within the maximum distance given.
  12949. *
  12950. * @param {string} key The key that the Parse.GeoPoint is stored in.
  12951. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  12952. * @param {number} maxDistance Maximum distance (in radians) of results to return.
  12953. * @param {boolean} sorted A Bool value that is true if results should be
  12954. * sorted by distance ascending, false is no sorting is required,
  12955. * defaults to true.
  12956. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12957. */
  12958. }, {
  12959. key: "withinRadians",
  12960. value: function (key /*: string*/, point /*: ParseGeoPoint*/, maxDistance /*: number*/, sorted /*: boolean*/) /*: ParseQuery*/{
  12961. if (sorted || sorted === undefined) {
  12962. this.near(key, point);
  12963. return this._addCondition(key, '$maxDistance', maxDistance);
  12964. } else {
  12965. return this._addCondition(key, '$geoWithin', {
  12966. $centerSphere: [[point.longitude, point.latitude], maxDistance]
  12967. });
  12968. }
  12969. }
  12970. /**
  12971. * Adds a proximity based constraint for finding objects with key point
  12972. * values near the point given and within the maximum distance given.
  12973. * Radius of earth used is 3958.8 miles.
  12974. *
  12975. * @param {string} key The key that the Parse.GeoPoint is stored in.
  12976. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  12977. * @param {number} maxDistance Maximum distance (in miles) of results to return.
  12978. * @param {boolean} sorted A Bool value that is true if results should be
  12979. * sorted by distance ascending, false is no sorting is required,
  12980. * defaults to true.
  12981. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12982. */
  12983. }, {
  12984. key: "withinMiles",
  12985. value: function (key /*: string*/, point /*: ParseGeoPoint*/, maxDistance /*: number*/, sorted /*: boolean*/) /*: ParseQuery*/{
  12986. return this.withinRadians(key, point, maxDistance / 3958.8, sorted);
  12987. }
  12988. /**
  12989. * Adds a proximity based constraint for finding objects with key point
  12990. * values near the point given and within the maximum distance given.
  12991. * Radius of earth used is 6371.0 kilometers.
  12992. *
  12993. * @param {string} key The key that the Parse.GeoPoint is stored in.
  12994. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  12995. * @param {number} maxDistance Maximum distance (in kilometers) of results to return.
  12996. * @param {boolean} sorted A Bool value that is true if results should be
  12997. * sorted by distance ascending, false is no sorting is required,
  12998. * defaults to true.
  12999. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13000. */
  13001. }, {
  13002. key: "withinKilometers",
  13003. value: function (key /*: string*/, point /*: ParseGeoPoint*/, maxDistance /*: number*/, sorted /*: boolean*/) /*: ParseQuery*/{
  13004. return this.withinRadians(key, point, maxDistance / 6371.0, sorted);
  13005. }
  13006. /**
  13007. * Adds a constraint to the query that requires a particular key's
  13008. * coordinates be contained within a given rectangular geographic bounding
  13009. * box.
  13010. *
  13011. * @param {string} key The key to be constrained.
  13012. * @param {Parse.GeoPoint} southwest
  13013. * The lower-left inclusive corner of the box.
  13014. * @param {Parse.GeoPoint} northeast
  13015. * The upper-right inclusive corner of the box.
  13016. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13017. */
  13018. }, {
  13019. key: "withinGeoBox",
  13020. value: function (key /*: string*/, southwest /*: ParseGeoPoint*/, northeast /*: ParseGeoPoint*/) /*: ParseQuery*/{
  13021. if (!(southwest instanceof _ParseGeoPoint.default)) {
  13022. southwest = new _ParseGeoPoint.default(southwest);
  13023. }
  13024. if (!(northeast instanceof _ParseGeoPoint.default)) {
  13025. northeast = new _ParseGeoPoint.default(northeast);
  13026. }
  13027. this._addCondition(key, '$within', {
  13028. $box: [southwest, northeast]
  13029. });
  13030. return this;
  13031. }
  13032. /**
  13033. * Adds a constraint to the query that requires a particular key's
  13034. * coordinates be contained within and on the bounds of a given polygon.
  13035. * Supports closed and open (last point is connected to first) paths
  13036. *
  13037. * Polygon must have at least 3 points
  13038. *
  13039. * @param {string} key The key to be constrained.
  13040. * @param {Array} points Array of Coordinates / GeoPoints
  13041. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13042. */
  13043. }, {
  13044. key: "withinPolygon",
  13045. value: function (key /*: string*/, points /*: Array<Array<number>>*/) /*: ParseQuery*/{
  13046. return this._addCondition(key, '$geoWithin', {
  13047. $polygon: points
  13048. });
  13049. }
  13050. /**
  13051. * Add a constraint to the query that requires a particular key's
  13052. * coordinates that contains a ParseGeoPoint
  13053. *
  13054. * @param {string} key The key to be constrained.
  13055. * @param {Parse.GeoPoint} point
  13056. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13057. */
  13058. }, {
  13059. key: "polygonContains",
  13060. value: function (key /*: string*/, point /*: ParseGeoPoint*/) /*: ParseQuery*/{
  13061. return this._addCondition(key, '$geoIntersects', {
  13062. $point: point
  13063. });
  13064. }
  13065. /* Query Orderings */
  13066. /**
  13067. * Sorts the results in ascending order by the given key.
  13068. *
  13069. * @param {(string|string[])} keys The key to order by, which is a
  13070. * string of comma separated values, or an Array of keys, or multiple keys.
  13071. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13072. */
  13073. }, {
  13074. key: "ascending",
  13075. value: function () /*: ParseQuery*/{
  13076. this._order = [];
  13077. for (var _len = arguments.length, keys = new Array(_len), _key5 = 0; _key5 < _len; _key5++) {
  13078. keys[_key5] = arguments[_key5];
  13079. }
  13080. return this.addAscending.apply(this, keys);
  13081. }
  13082. /**
  13083. * Sorts the results in ascending order by the given key,
  13084. * but can also add secondary sort descriptors without overwriting _order.
  13085. *
  13086. * @param {(string|string[])} keys The key to order by, which is a
  13087. * string of comma separated values, or an Array of keys, or multiple keys.
  13088. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13089. */
  13090. }, {
  13091. key: "addAscending",
  13092. value: function () /*: ParseQuery*/{
  13093. var _this9 = this;
  13094. if (!this._order) {
  13095. this._order = [];
  13096. }
  13097. for (var _len2 = arguments.length, keys = new Array(_len2), _key6 = 0; _key6 < _len2; _key6++) {
  13098. keys[_key6] = arguments[_key6];
  13099. }
  13100. (0, _forEach.default)(keys).call(keys, function (key) {
  13101. var _context16;
  13102. if ((0, _isArray.default)(key)) {
  13103. key = key.join();
  13104. }
  13105. _this9._order = (0, _concat.default)(_context16 = _this9._order).call(_context16, key.replace(/\s/g, '').split(','));
  13106. });
  13107. return this;
  13108. }
  13109. /**
  13110. * Sorts the results in descending order by the given key.
  13111. *
  13112. * @param {(string|string[])} keys The key to order by, which is a
  13113. * string of comma separated values, or an Array of keys, or multiple keys.
  13114. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13115. */
  13116. }, {
  13117. key: "descending",
  13118. value: function () /*: ParseQuery*/{
  13119. this._order = [];
  13120. for (var _len3 = arguments.length, keys = new Array(_len3), _key7 = 0; _key7 < _len3; _key7++) {
  13121. keys[_key7] = arguments[_key7];
  13122. }
  13123. return this.addDescending.apply(this, keys);
  13124. }
  13125. /**
  13126. * Sorts the results in descending order by the given key,
  13127. * but can also add secondary sort descriptors without overwriting _order.
  13128. *
  13129. * @param {(string|string[])} keys The key to order by, which is a
  13130. * string of comma separated values, or an Array of keys, or multiple keys.
  13131. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13132. */
  13133. }, {
  13134. key: "addDescending",
  13135. value: function () /*: ParseQuery*/{
  13136. var _this10 = this;
  13137. if (!this._order) {
  13138. this._order = [];
  13139. }
  13140. for (var _len4 = arguments.length, keys = new Array(_len4), _key8 = 0; _key8 < _len4; _key8++) {
  13141. keys[_key8] = arguments[_key8];
  13142. }
  13143. (0, _forEach.default)(keys).call(keys, function (key) {
  13144. var _context17, _context18;
  13145. if ((0, _isArray.default)(key)) {
  13146. key = key.join();
  13147. }
  13148. _this10._order = (0, _concat.default)(_context17 = _this10._order).call(_context17, (0, _map2.default)(_context18 = key.replace(/\s/g, '').split(',')).call(_context18, function (k) {
  13149. return '-' + k;
  13150. }));
  13151. });
  13152. return this;
  13153. }
  13154. /* Query Options */
  13155. /**
  13156. * Sets the number of results to skip before returning any results.
  13157. * This is useful for pagination.
  13158. * Default is to skip zero results.
  13159. *
  13160. * @param {number} n the number of results to skip.
  13161. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13162. */
  13163. }, {
  13164. key: "skip",
  13165. value: function (n /*: number*/) /*: ParseQuery*/{
  13166. if (typeof n !== 'number' || n < 0) {
  13167. throw new Error('You can only skip by a positive number');
  13168. }
  13169. this._skip = n;
  13170. return this;
  13171. }
  13172. /**
  13173. * Sets the limit of the number of results to return. The default limit is 100.
  13174. *
  13175. * @param {number} n the number of results to limit to.
  13176. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13177. */
  13178. }, {
  13179. key: "limit",
  13180. value: function (n /*: number*/) /*: ParseQuery*/{
  13181. if (typeof n !== 'number') {
  13182. throw new Error('You can only set the limit to a numeric value');
  13183. }
  13184. this._limit = n;
  13185. return this;
  13186. }
  13187. /**
  13188. * Sets the flag to include with response the total number of objects satisfying this query,
  13189. * despite limits/skip. Might be useful for pagination.
  13190. * Note that result of this query will be wrapped as an object with
  13191. * `results`: holding {ParseObject} array and `count`: integer holding total number
  13192. *
  13193. * @param {boolean} includeCount false - disable, true - enable.
  13194. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13195. */
  13196. }, {
  13197. key: "withCount",
  13198. value: function () /*: ParseQuery*/{
  13199. var includeCount /*: boolean*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  13200. if (typeof includeCount !== 'boolean') {
  13201. throw new Error('You can only set withCount to a boolean value');
  13202. }
  13203. this._count = includeCount;
  13204. return this;
  13205. }
  13206. /**
  13207. * Includes nested Parse.Objects for the provided key. You can use dot
  13208. * notation to specify which fields in the included object are also fetched.
  13209. *
  13210. * You can include all nested Parse.Objects by passing in '*'.
  13211. * Requires Parse Server 3.0.0+
  13212. * <pre>query.include('*');</pre>
  13213. *
  13214. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  13215. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13216. */
  13217. }, {
  13218. key: "include",
  13219. value: function () /*: ParseQuery*/{
  13220. var _this11 = this;
  13221. for (var _len5 = arguments.length, keys = new Array(_len5), _key9 = 0; _key9 < _len5; _key9++) {
  13222. keys[_key9] = arguments[_key9];
  13223. }
  13224. (0, _forEach.default)(keys).call(keys, function (key) {
  13225. if ((0, _isArray.default)(key)) {
  13226. var _context19;
  13227. _this11._include = (0, _concat.default)(_context19 = _this11._include).call(_context19, key);
  13228. } else {
  13229. _this11._include.push(key);
  13230. }
  13231. });
  13232. return this;
  13233. }
  13234. /**
  13235. * Includes all nested Parse.Objects one level deep.
  13236. *
  13237. * Requires Parse Server 3.0.0+
  13238. *
  13239. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13240. */
  13241. }, {
  13242. key: "includeAll",
  13243. value: function () /*: ParseQuery*/{
  13244. return this.include('*');
  13245. }
  13246. /**
  13247. * Restricts the fields of the returned Parse.Objects to include only the
  13248. * provided keys. If this is called multiple times, then all of the keys
  13249. * specified in each of the calls will be included.
  13250. *
  13251. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  13252. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13253. */
  13254. }, {
  13255. key: "select",
  13256. value: function () /*: ParseQuery*/{
  13257. var _this12 = this;
  13258. if (!this._select) {
  13259. this._select = [];
  13260. }
  13261. for (var _len6 = arguments.length, keys = new Array(_len6), _key10 = 0; _key10 < _len6; _key10++) {
  13262. keys[_key10] = arguments[_key10];
  13263. }
  13264. (0, _forEach.default)(keys).call(keys, function (key) {
  13265. if ((0, _isArray.default)(key)) {
  13266. var _context20;
  13267. _this12._select = (0, _concat.default)(_context20 = _this12._select).call(_context20, key);
  13268. } else {
  13269. _this12._select.push(key);
  13270. }
  13271. });
  13272. return this;
  13273. }
  13274. /**
  13275. * Restricts the fields of the returned Parse.Objects to all keys except the
  13276. * provided keys. Exclude takes precedence over select and include.
  13277. *
  13278. * Requires Parse Server 3.6.0+
  13279. *
  13280. * @param {...string|Array<string>} keys The name(s) of the key(s) to exclude.
  13281. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13282. */
  13283. }, {
  13284. key: "exclude",
  13285. value: function () /*: ParseQuery*/{
  13286. var _this13 = this;
  13287. for (var _len7 = arguments.length, keys = new Array(_len7), _key11 = 0; _key11 < _len7; _key11++) {
  13288. keys[_key11] = arguments[_key11];
  13289. }
  13290. (0, _forEach.default)(keys).call(keys, function (key) {
  13291. if ((0, _isArray.default)(key)) {
  13292. var _context21;
  13293. _this13._exclude = (0, _concat.default)(_context21 = _this13._exclude).call(_context21, key);
  13294. } else {
  13295. _this13._exclude.push(key);
  13296. }
  13297. });
  13298. return this;
  13299. }
  13300. /**
  13301. * Restricts live query to trigger only for watched fields.
  13302. *
  13303. * Requires Parse Server 6.0.0+
  13304. *
  13305. * @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
  13306. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13307. */
  13308. }, {
  13309. key: "watch",
  13310. value: function () /*: ParseQuery*/{
  13311. var _this14 = this;
  13312. for (var _len8 = arguments.length, keys = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
  13313. keys[_key12] = arguments[_key12];
  13314. }
  13315. (0, _forEach.default)(keys).call(keys, function (key) {
  13316. if ((0, _isArray.default)(key)) {
  13317. var _context22;
  13318. _this14._watch = (0, _concat.default)(_context22 = _this14._watch).call(_context22, key);
  13319. } else {
  13320. _this14._watch.push(key);
  13321. }
  13322. });
  13323. return this;
  13324. }
  13325. /**
  13326. * Changes the read preference that the backend will use when performing the query to the database.
  13327. *
  13328. * @param {string} readPreference The read preference for the main query.
  13329. * @param {string} includeReadPreference The read preference for the queries to include pointers.
  13330. * @param {string} subqueryReadPreference The read preference for the sub queries.
  13331. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13332. */
  13333. }, {
  13334. key: "readPreference",
  13335. value: function (_readPreference /*: string*/, includeReadPreference /*:: ?: string*/, subqueryReadPreference /*:: ?: string*/) /*: ParseQuery*/{
  13336. this._readPreference = _readPreference;
  13337. this._includeReadPreference = includeReadPreference;
  13338. this._subqueryReadPreference = subqueryReadPreference;
  13339. return this;
  13340. }
  13341. /**
  13342. * Subscribe this query to get liveQuery updates
  13343. *
  13344. * @param {string} sessionToken (optional) Defaults to the currentUser
  13345. * @returns {Promise<LiveQuerySubscription>} Returns the liveQuerySubscription, it's an event emitter
  13346. * which can be used to get liveQuery updates.
  13347. */
  13348. }, {
  13349. key: "subscribe",
  13350. value: function () {
  13351. var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(sessionToken /*:: ?: string*/) {
  13352. var currentUser, liveQueryClient, subscription;
  13353. return _regenerator.default.wrap(function (_context23) {
  13354. while (1) switch (_context23.prev = _context23.next) {
  13355. case 0:
  13356. _context23.next = 2;
  13357. return _CoreManager.default.getUserController().currentUserAsync();
  13358. case 2:
  13359. currentUser = _context23.sent;
  13360. if (!sessionToken) {
  13361. sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
  13362. }
  13363. _context23.next = 6;
  13364. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  13365. case 6:
  13366. liveQueryClient = _context23.sent;
  13367. if (liveQueryClient.shouldOpen()) {
  13368. liveQueryClient.open();
  13369. }
  13370. subscription = liveQueryClient.subscribe(this, sessionToken);
  13371. return _context23.abrupt("return", subscription.subscribePromise.then(function () {
  13372. return subscription;
  13373. }));
  13374. case 10:
  13375. case "end":
  13376. return _context23.stop();
  13377. }
  13378. }, _callee7, this);
  13379. }));
  13380. function subscribe() {
  13381. return _subscribe.apply(this, arguments);
  13382. }
  13383. return subscribe;
  13384. }()
  13385. /**
  13386. * Constructs a Parse.Query that is the OR of the passed in queries. For
  13387. * example:
  13388. * <pre>var compoundQuery = Parse.Query.or(query1, query2, query3);</pre>
  13389. *
  13390. * will create a compoundQuery that is an or of the query1, query2, and
  13391. * query3.
  13392. *
  13393. * @param {...Parse.Query} queries The list of queries to OR.
  13394. * @static
  13395. * @returns {Parse.Query} The query that is the OR of the passed in queries.
  13396. */
  13397. }, {
  13398. key: "fromNetwork",
  13399. value:
  13400. /**
  13401. * Change the source of this query to the server.
  13402. *
  13403. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13404. */
  13405. function () /*: ParseQuery*/{
  13406. this._queriesLocalDatastore = false;
  13407. this._localDatastorePinName = null;
  13408. return this;
  13409. }
  13410. /**
  13411. * Changes the source of this query to all pinned objects.
  13412. *
  13413. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13414. */
  13415. }, {
  13416. key: "fromLocalDatastore",
  13417. value: function () /*: ParseQuery*/{
  13418. return this.fromPinWithName(null);
  13419. }
  13420. /**
  13421. * Changes the source of this query to the default group of pinned objects.
  13422. *
  13423. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13424. */
  13425. }, {
  13426. key: "fromPin",
  13427. value: function () /*: ParseQuery*/{
  13428. return this.fromPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  13429. }
  13430. /**
  13431. * Changes the source of this query to a specific group of pinned objects.
  13432. *
  13433. * @param {string} name The name of query source.
  13434. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13435. */
  13436. }, {
  13437. key: "fromPinWithName",
  13438. value: function (name /*:: ?: string*/) /*: ParseQuery*/{
  13439. var localDatastore = _CoreManager.default.getLocalDatastore();
  13440. if (localDatastore.checkIfEnabled()) {
  13441. this._queriesLocalDatastore = true;
  13442. this._localDatastorePinName = name;
  13443. }
  13444. return this;
  13445. }
  13446. /**
  13447. * Cancels the current network request (if any is running).
  13448. *
  13449. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13450. */
  13451. }, {
  13452. key: "cancel",
  13453. value: function () /*: ParseQuery*/{
  13454. var _this15 = this;
  13455. if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
  13456. this._xhrRequest.task._aborted = true;
  13457. this._xhrRequest.task.abort();
  13458. this._xhrRequest.task = null;
  13459. this._xhrRequest.onchange = function () {};
  13460. return this;
  13461. }
  13462. return this._xhrRequest.onchange = function () {
  13463. return _this15.cancel();
  13464. };
  13465. }
  13466. }, {
  13467. key: "_setRequestTask",
  13468. value: function (options) {
  13469. var _this16 = this;
  13470. options.requestTask = function (task) {
  13471. _this16._xhrRequest.task = task;
  13472. _this16._xhrRequest.onchange();
  13473. };
  13474. }
  13475. }], [{
  13476. key: "fromJSON",
  13477. value: function (className /*: string*/, json /*: QueryJSON*/) /*: ParseQuery*/{
  13478. var query = new ParseQuery(className);
  13479. return query.withJSON(json);
  13480. }
  13481. }, {
  13482. key: "or",
  13483. value: function () /*: ParseQuery*/{
  13484. for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
  13485. queries[_key13] = arguments[_key13];
  13486. }
  13487. var className = _getClassNameFromQueries(queries);
  13488. var query = new ParseQuery(className);
  13489. query._orQuery(queries);
  13490. return query;
  13491. }
  13492. /**
  13493. * Constructs a Parse.Query that is the AND of the passed in queries. For
  13494. * example:
  13495. * <pre>var compoundQuery = Parse.Query.and(query1, query2, query3);</pre>
  13496. *
  13497. * will create a compoundQuery that is an and of the query1, query2, and
  13498. * query3.
  13499. *
  13500. * @param {...Parse.Query} queries The list of queries to AND.
  13501. * @static
  13502. * @returns {Parse.Query} The query that is the AND of the passed in queries.
  13503. */
  13504. }, {
  13505. key: "and",
  13506. value: function () /*: ParseQuery*/{
  13507. for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
  13508. queries[_key14] = arguments[_key14];
  13509. }
  13510. var className = _getClassNameFromQueries(queries);
  13511. var query = new ParseQuery(className);
  13512. query._andQuery(queries);
  13513. return query;
  13514. }
  13515. /**
  13516. * Constructs a Parse.Query that is the NOR of the passed in queries. For
  13517. * example:
  13518. * <pre>const compoundQuery = Parse.Query.nor(query1, query2, query3);</pre>
  13519. *
  13520. * will create a compoundQuery that is a nor of the query1, query2, and
  13521. * query3.
  13522. *
  13523. * @param {...Parse.Query} queries The list of queries to NOR.
  13524. * @static
  13525. * @returns {Parse.Query} The query that is the NOR of the passed in queries.
  13526. */
  13527. }, {
  13528. key: "nor",
  13529. value: function () /*: ParseQuery*/{
  13530. for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
  13531. queries[_key15] = arguments[_key15];
  13532. }
  13533. var className = _getClassNameFromQueries(queries);
  13534. var query = new ParseQuery(className);
  13535. query._norQuery(queries);
  13536. return query;
  13537. }
  13538. }]);
  13539. return ParseQuery;
  13540. }();
  13541. var DefaultController = {
  13542. find: function (className /*: string*/, params /*: QueryJSON*/, options /*: RequestOptions*/) /*: Promise<Array<ParseObject>>*/{
  13543. var RESTController = _CoreManager.default.getRESTController();
  13544. return RESTController.request('GET', 'classes/' + className, params, options);
  13545. },
  13546. aggregate: function (className /*: string*/, params /*: any*/, options /*: RequestOptions*/) /*: Promise<Array<mixed>>*/{
  13547. var RESTController = _CoreManager.default.getRESTController();
  13548. return RESTController.request('GET', 'aggregate/' + className, params, options);
  13549. }
  13550. };
  13551. _CoreManager.default.setQueryController(DefaultController);
  13552. var _default = ParseQuery;
  13553. exports.default = _default;
  13554. },{"./CoreManager":4,"./LocalDatastoreUtils":15,"./OfflineQuery":17,"./ParseError":22,"./ParseGeoPoint":24,"./ParseObject":27,"./encode":46,"./promiseUtils":51,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/find":63,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/keys":67,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/slice":70,"@babel/runtime-corejs3/core-js-stable/instance/sort":71,"@babel/runtime-corejs3/core-js-stable/instance/splice":72,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/entries":82,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/helpers/asyncToGenerator":121,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/slicedToArray":139,"@babel/runtime-corejs3/helpers/toConsumableArray":141,"@babel/runtime-corejs3/helpers/typeof":144,"@babel/runtime-corejs3/regenerator":147}],31:[function(_dereq_,module,exports){
  13555. "use strict";
  13556. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13557. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  13558. _Object$defineProperty(exports, "__esModule", {
  13559. value: true
  13560. });
  13561. exports.default = void 0;
  13562. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  13563. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  13564. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  13565. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  13566. var _ParseOp = _dereq_("./ParseOp");
  13567. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  13568. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  13569. /**
  13570. * @flow
  13571. */
  13572. /**
  13573. * Creates a new Relation for the given parent object and key. This
  13574. * constructor should rarely be used directly, but rather created by
  13575. * Parse.Object.relation.
  13576. *
  13577. * <p>
  13578. * A class that is used to access all of the children of a many-to-many
  13579. * relationship. Each instance of Parse.Relation is associated with a
  13580. * particular parent object and key.
  13581. * </p>
  13582. *
  13583. * @alias Parse.Relation
  13584. */
  13585. var ParseRelation = /*#__PURE__*/function () {
  13586. /**
  13587. * @param {Parse.Object} parent The parent of this relation.
  13588. * @param {string} key The key for this relation on the parent.
  13589. */
  13590. function ParseRelation(parent /*: ?ParseObject*/, key /*: ?string*/) {
  13591. (0, _classCallCheck2.default)(this, ParseRelation);
  13592. (0, _defineProperty2.default)(this, "parent", void 0);
  13593. (0, _defineProperty2.default)(this, "key", void 0);
  13594. (0, _defineProperty2.default)(this, "targetClassName", void 0);
  13595. this.parent = parent;
  13596. this.key = key;
  13597. this.targetClassName = null;
  13598. }
  13599. /*
  13600. * Makes sure that this relation has the right parent and key.
  13601. */
  13602. (0, _createClass2.default)(ParseRelation, [{
  13603. key: "_ensureParentAndKey",
  13604. value: function (parent /*: ParseObject*/, key /*: string*/) {
  13605. this.key = this.key || key;
  13606. if (this.key !== key) {
  13607. throw new Error('Internal Error. Relation retrieved from two different keys.');
  13608. }
  13609. if (this.parent) {
  13610. if (this.parent.className !== parent.className) {
  13611. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  13612. }
  13613. if (this.parent.id) {
  13614. if (this.parent.id !== parent.id) {
  13615. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  13616. }
  13617. } else if (parent.id) {
  13618. this.parent = parent;
  13619. }
  13620. } else {
  13621. this.parent = parent;
  13622. }
  13623. }
  13624. /**
  13625. * Adds a Parse.Object or an array of Parse.Objects to the relation.
  13626. *
  13627. * @param {(Parse.Object|Array)} objects The item or items to add.
  13628. * @returns {Parse.Object} The parent of the relation.
  13629. */
  13630. }, {
  13631. key: "add",
  13632. value: function (objects /*: ParseObject | Array<ParseObject | string>*/) /*: ParseObject*/{
  13633. if (!(0, _isArray.default)(objects)) {
  13634. objects = [objects];
  13635. }
  13636. var change = new _ParseOp.RelationOp(objects, []);
  13637. var parent = this.parent;
  13638. if (!parent) {
  13639. throw new Error('Cannot add to a Relation without a parent');
  13640. }
  13641. if (objects.length === 0) {
  13642. return parent;
  13643. }
  13644. parent.set(this.key, change);
  13645. this.targetClassName = change._targetClassName;
  13646. return parent;
  13647. }
  13648. /**
  13649. * Removes a Parse.Object or an array of Parse.Objects from this relation.
  13650. *
  13651. * @param {(Parse.Object|Array)} objects The item or items to remove.
  13652. */
  13653. }, {
  13654. key: "remove",
  13655. value: function (objects /*: ParseObject | Array<ParseObject | string>*/) {
  13656. if (!(0, _isArray.default)(objects)) {
  13657. objects = [objects];
  13658. }
  13659. var change = new _ParseOp.RelationOp([], objects);
  13660. if (!this.parent) {
  13661. throw new Error('Cannot remove from a Relation without a parent');
  13662. }
  13663. if (objects.length === 0) {
  13664. return;
  13665. }
  13666. this.parent.set(this.key, change);
  13667. this.targetClassName = change._targetClassName;
  13668. }
  13669. /**
  13670. * Returns a JSON version of the object suitable for saving to disk.
  13671. *
  13672. * @returns {object} JSON representation of Relation
  13673. */
  13674. }, {
  13675. key: "toJSON",
  13676. value: function () /*: { __type: 'Relation', className: ?string }*/{
  13677. return {
  13678. __type: 'Relation',
  13679. className: this.targetClassName
  13680. };
  13681. }
  13682. /**
  13683. * Returns a Parse.Query that is limited to objects in this
  13684. * relation.
  13685. *
  13686. * @returns {Parse.Query} Relation Query
  13687. */
  13688. }, {
  13689. key: "query",
  13690. value: function query() /*: ParseQuery*/{
  13691. var query;
  13692. var parent = this.parent;
  13693. if (!parent) {
  13694. throw new Error('Cannot construct a query for a Relation without a parent');
  13695. }
  13696. if (!this.targetClassName) {
  13697. query = new _ParseQuery.default(parent.className);
  13698. query._extraOptions.redirectClassNameForKey = this.key;
  13699. } else {
  13700. query = new _ParseQuery.default(this.targetClassName);
  13701. }
  13702. query._addCondition('$relatedTo', 'object', {
  13703. __type: 'Pointer',
  13704. className: parent.className,
  13705. objectId: parent.id
  13706. });
  13707. query._addCondition('$relatedTo', 'key', this.key);
  13708. return query;
  13709. }
  13710. }]);
  13711. return ParseRelation;
  13712. }();
  13713. var _default = ParseRelation;
  13714. exports.default = _default;
  13715. },{"./ParseObject":27,"./ParseOp":28,"./ParseQuery":30,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],32:[function(_dereq_,module,exports){
  13716. "use strict";
  13717. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  13718. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13719. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  13720. _Object$defineProperty(exports, "__esModule", {
  13721. value: true
  13722. });
  13723. exports.default = void 0;
  13724. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  13725. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  13726. var _get2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/get"));
  13727. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  13728. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  13729. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  13730. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  13731. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  13732. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  13733. function _createSuper(Derived) {
  13734. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  13735. return function () {
  13736. var Super = (0, _getPrototypeOf2.default)(Derived),
  13737. result;
  13738. if (hasNativeReflectConstruct) {
  13739. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  13740. result = _Reflect$construct(Super, arguments, NewTarget);
  13741. } else {
  13742. result = Super.apply(this, arguments);
  13743. }
  13744. return (0, _possibleConstructorReturn2.default)(this, result);
  13745. };
  13746. }
  13747. function _isNativeReflectConstruct() {
  13748. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  13749. if (_Reflect$construct.sham) return false;
  13750. if (typeof Proxy === "function") return true;
  13751. try {
  13752. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  13753. return true;
  13754. } catch (e) {
  13755. return false;
  13756. }
  13757. } /**
  13758. * @flow
  13759. */
  13760. /*:: import type { AttributeMap } from './ObjectStateMutations';*/
  13761. /*:: import type ParseRelation from './ParseRelation';*/
  13762. /**
  13763. * Represents a Role on the Parse server. Roles represent groupings of
  13764. * Users for the purposes of granting permissions (e.g. specifying an ACL
  13765. * for an Object). Roles are specified by their sets of child users and
  13766. * child roles, all of which are granted any permissions that the parent
  13767. * role has.
  13768. *
  13769. * <p>Roles must have a name (which cannot be changed after creation of the
  13770. * role), and must specify an ACL.</p>
  13771. *
  13772. * @alias Parse.Role
  13773. * @augments Parse.Object
  13774. */
  13775. var ParseRole = /*#__PURE__*/function (_ParseObject) {
  13776. (0, _inherits2.default)(ParseRole, _ParseObject);
  13777. var _super = _createSuper(ParseRole);
  13778. /**
  13779. * @param {string} name The name of the Role to create.
  13780. * @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL.
  13781. * A Parse.Role is a local representation of a role persisted to the Parse
  13782. * cloud.
  13783. */
  13784. function ParseRole(name /*: string*/, acl /*: ParseACL*/) {
  13785. var _this;
  13786. (0, _classCallCheck2.default)(this, ParseRole);
  13787. _this = _super.call(this, '_Role');
  13788. if (typeof name === 'string' && acl instanceof _ParseACL.default) {
  13789. _this.setName(name);
  13790. _this.setACL(acl);
  13791. }
  13792. return _this;
  13793. }
  13794. /**
  13795. * Gets the name of the role. You can alternatively call role.get("name")
  13796. *
  13797. * @returns {string} the name of the role.
  13798. */
  13799. (0, _createClass2.default)(ParseRole, [{
  13800. key: "getName",
  13801. value: function () /*: ?string*/{
  13802. var name = this.get('name');
  13803. if (name == null || typeof name === 'string') {
  13804. return name;
  13805. }
  13806. return '';
  13807. }
  13808. /**
  13809. * Sets the name for a role. This value must be set before the role has
  13810. * been saved to the server, and cannot be set once the role has been
  13811. * saved.
  13812. *
  13813. * <p>
  13814. * A role's name can only contain alphanumeric characters, _, -, and
  13815. * spaces.
  13816. * </p>
  13817. *
  13818. * <p>This is equivalent to calling role.set("name", name)</p>
  13819. *
  13820. * @param {string} name The name of the role.
  13821. * @param {object} options Standard options object with success and error
  13822. * callbacks.
  13823. * @returns {(ParseObject|boolean)} true if the set succeeded.
  13824. */
  13825. }, {
  13826. key: "setName",
  13827. value: function (name /*: string*/, options /*:: ?: mixed*/) /*: ParseObject | boolean*/{
  13828. this._validateName(name);
  13829. return this.set('name', name, options);
  13830. }
  13831. /**
  13832. * Gets the Parse.Relation for the Parse.Users that are direct
  13833. * children of this role. These users are granted any privileges that this
  13834. * role has been granted (e.g. read or write access through ACLs). You can
  13835. * add or remove users from the role through this relation.
  13836. *
  13837. * <p>This is equivalent to calling role.relation("users")</p>
  13838. *
  13839. * @returns {Parse.Relation} the relation for the users belonging to this
  13840. * role.
  13841. */
  13842. }, {
  13843. key: "getUsers",
  13844. value: function () /*: ParseRelation*/{
  13845. return this.relation('users');
  13846. }
  13847. /**
  13848. * Gets the Parse.Relation for the Parse.Roles that are direct
  13849. * children of this role. These roles' users are granted any privileges that
  13850. * this role has been granted (e.g. read or write access through ACLs). You
  13851. * can add or remove child roles from this role through this relation.
  13852. *
  13853. * <p>This is equivalent to calling role.relation("roles")</p>
  13854. *
  13855. * @returns {Parse.Relation} the relation for the roles belonging to this
  13856. * role.
  13857. */
  13858. }, {
  13859. key: "getRoles",
  13860. value: function () /*: ParseRelation*/{
  13861. return this.relation('roles');
  13862. }
  13863. }, {
  13864. key: "_validateName",
  13865. value: function (newName) {
  13866. if (typeof newName !== 'string') {
  13867. throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
  13868. }
  13869. if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
  13870. throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
  13871. }
  13872. }
  13873. }, {
  13874. key: "validate",
  13875. value: function (attrs /*: AttributeMap*/, options /*:: ?: mixed*/) /*: ParseError | boolean*/{
  13876. var isInvalid = (0, _get2.default)((0, _getPrototypeOf2.default)(ParseRole.prototype), "validate", this).call(this, attrs, options);
  13877. if (isInvalid) {
  13878. return isInvalid;
  13879. }
  13880. if ('name' in attrs && attrs.name !== this.getName()) {
  13881. var newName = attrs.name;
  13882. if (this.id && this.id !== attrs.objectId) {
  13883. // Check to see if the objectId being set matches this.id
  13884. // This happens during a fetch -- the id is set before calling fetch
  13885. // Let the name be set in this case
  13886. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
  13887. }
  13888. try {
  13889. this._validateName(newName);
  13890. } catch (e) {
  13891. return e;
  13892. }
  13893. }
  13894. return false;
  13895. }
  13896. }]);
  13897. return ParseRole;
  13898. }(_ParseObject2.default);
  13899. _ParseObject2.default.registerSubclass('_Role', ParseRole);
  13900. var _default = ParseRole;
  13901. exports.default = _default;
  13902. },{"./ParseACL":19,"./ParseError":22,"./ParseObject":27,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/reflect/construct":91,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/get":126,"@babel/runtime-corejs3/helpers/getPrototypeOf":127,"@babel/runtime-corejs3/helpers/inherits":128,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":136}],33:[function(_dereq_,module,exports){
  13903. "use strict";
  13904. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13905. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  13906. _Object$defineProperty(exports, "__esModule", {
  13907. value: true
  13908. });
  13909. exports.default = void 0;
  13910. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  13911. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  13912. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  13913. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  13914. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  13915. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  13916. var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
  13917. /**
  13918. * @flow
  13919. */
  13920. /*:: import type { PermissionsMap } from './ParseCLP';*/
  13921. var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
  13922. /*:: type FieldOptions = {
  13923. required: boolean,
  13924. defaultValue: mixed,
  13925. };*/
  13926. /**
  13927. * A Parse.Schema object is for handling schema data from Parse.
  13928. * <p>All the schemas methods require MasterKey.
  13929. *
  13930. * When adding fields, you may set required and default values. (Requires Parse Server 3.7.0+)
  13931. *
  13932. * <pre>
  13933. * const options = { required: true, defaultValue: 'hello world' };
  13934. * const schema = new Parse.Schema('MyClass');
  13935. * schema.addString('field', options);
  13936. * schema.addIndex('index_name', { 'field': 1 });
  13937. * schema.save();
  13938. * </pre>
  13939. * </p>
  13940. *
  13941. * @alias Parse.Schema
  13942. */
  13943. var ParseSchema = /*#__PURE__*/function () {
  13944. /**
  13945. * @param {string} className Parse Class string.
  13946. */
  13947. function ParseSchema(className /*: string*/) {
  13948. (0, _classCallCheck2.default)(this, ParseSchema);
  13949. (0, _defineProperty2.default)(this, "className", void 0);
  13950. (0, _defineProperty2.default)(this, "_fields", void 0);
  13951. (0, _defineProperty2.default)(this, "_indexes", void 0);
  13952. (0, _defineProperty2.default)(this, "_clp", void 0);
  13953. if (typeof className === 'string') {
  13954. if (className === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  13955. this.className = '_User';
  13956. } else {
  13957. this.className = className;
  13958. }
  13959. }
  13960. this._fields = {};
  13961. this._indexes = {};
  13962. }
  13963. /**
  13964. * Static method to get all schemas
  13965. *
  13966. * @returns {Promise} A promise that is resolved with the result when
  13967. * the query completes.
  13968. */
  13969. (0, _createClass2.default)(ParseSchema, [{
  13970. key: "get",
  13971. value:
  13972. /**
  13973. * Get the Schema from Parse
  13974. *
  13975. * @returns {Promise} A promise that is resolved with the result when
  13976. * the query completes.
  13977. */
  13978. function () {
  13979. this.assertClassName();
  13980. var controller = _CoreManager.default.getSchemaController();
  13981. return controller.get(this.className).then(function (response) {
  13982. if (!response) {
  13983. throw new Error('Schema not found.');
  13984. }
  13985. return response;
  13986. });
  13987. }
  13988. /**
  13989. * Create a new Schema on Parse
  13990. *
  13991. * @returns {Promise} A promise that is resolved with the result when
  13992. * the query completes.
  13993. */
  13994. }, {
  13995. key: "save",
  13996. value: function () {
  13997. this.assertClassName();
  13998. var controller = _CoreManager.default.getSchemaController();
  13999. var params = {
  14000. className: this.className,
  14001. fields: this._fields,
  14002. indexes: this._indexes,
  14003. classLevelPermissions: this._clp
  14004. };
  14005. return controller.create(this.className, params);
  14006. }
  14007. /**
  14008. * Update a Schema on Parse
  14009. *
  14010. * @returns {Promise} A promise that is resolved with the result when
  14011. * the query completes.
  14012. */
  14013. }, {
  14014. key: "update",
  14015. value: function () {
  14016. this.assertClassName();
  14017. var controller = _CoreManager.default.getSchemaController();
  14018. var params = {
  14019. className: this.className,
  14020. fields: this._fields,
  14021. indexes: this._indexes,
  14022. classLevelPermissions: this._clp
  14023. };
  14024. this._fields = {};
  14025. this._indexes = {};
  14026. return controller.update(this.className, params);
  14027. }
  14028. /**
  14029. * Removing a Schema from Parse
  14030. * Can only be used on Schema without objects
  14031. *
  14032. * @returns {Promise} A promise that is resolved with the result when
  14033. * the query completes.
  14034. */
  14035. }, {
  14036. key: "delete",
  14037. value: function () {
  14038. this.assertClassName();
  14039. var controller = _CoreManager.default.getSchemaController();
  14040. return controller.delete(this.className);
  14041. }
  14042. /**
  14043. * Removes all objects from a Schema (class) in Parse.
  14044. * EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
  14045. *
  14046. * @returns {Promise} A promise that is resolved with the result when
  14047. * the query completes.
  14048. */
  14049. }, {
  14050. key: "purge",
  14051. value: function () {
  14052. this.assertClassName();
  14053. var controller = _CoreManager.default.getSchemaController();
  14054. return controller.purge(this.className);
  14055. }
  14056. /**
  14057. * Assert if ClassName has been filled
  14058. *
  14059. * @private
  14060. */
  14061. }, {
  14062. key: "assertClassName",
  14063. value: function () {
  14064. if (!this.className) {
  14065. throw new Error('You must set a Class Name before making any request.');
  14066. }
  14067. }
  14068. /**
  14069. * Sets Class Level Permissions when creating / updating a Schema.
  14070. * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed
  14071. *
  14072. * @param {object | Parse.CLP} clp Class Level Permissions
  14073. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14074. */
  14075. }, {
  14076. key: "setCLP",
  14077. value: function (clp /*: PermissionsMap | ParseCLP*/) {
  14078. if (clp instanceof _ParseCLP.default) {
  14079. this._clp = clp.toJSON();
  14080. } else {
  14081. this._clp = clp;
  14082. }
  14083. return this;
  14084. }
  14085. /**
  14086. * Adding a Field to Create / Update a Schema
  14087. *
  14088. * @param {string} name Name of the field that will be created on Parse
  14089. * @param {string} type Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation)
  14090. * @param {object} options
  14091. * Valid options are:<ul>
  14092. * <li>required: If field is not set, save operation fails (Requires Parse Server 3.7.0+)
  14093. * <li>defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+)
  14094. * <li>targetClass: Required if type is Pointer or Parse.Relation
  14095. * </ul>
  14096. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14097. */
  14098. }, {
  14099. key: "addField",
  14100. value: function (name /*: string*/, type /*: string*/) {
  14101. var options /*: FieldOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  14102. type = type || 'String';
  14103. if (!name) {
  14104. throw new Error('field name may not be null.');
  14105. }
  14106. if ((0, _indexOf.default)(FIELD_TYPES).call(FIELD_TYPES, type) === -1) {
  14107. throw new Error("".concat(type, " is not a valid type."));
  14108. }
  14109. if (type === 'Pointer') {
  14110. return this.addPointer(name, options.targetClass, options);
  14111. }
  14112. if (type === 'Relation') {
  14113. return this.addRelation(name, options.targetClass, options);
  14114. }
  14115. var fieldOptions = {
  14116. type: type
  14117. };
  14118. if (typeof options.required === 'boolean') {
  14119. fieldOptions.required = options.required;
  14120. }
  14121. if (options.defaultValue !== undefined) {
  14122. fieldOptions.defaultValue = options.defaultValue;
  14123. }
  14124. if (type === 'Date') {
  14125. if (options && options.defaultValue) {
  14126. fieldOptions.defaultValue = {
  14127. __type: 'Date',
  14128. iso: new Date(options.defaultValue)
  14129. };
  14130. }
  14131. }
  14132. this._fields[name] = fieldOptions;
  14133. return this;
  14134. }
  14135. /**
  14136. * Adding an Index to Create / Update a Schema
  14137. *
  14138. * @param {string} name Name of the index
  14139. * @param {object} index { field: value }
  14140. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14141. *
  14142. * <pre>
  14143. * schema.addIndex('index_name', { 'field': 1 });
  14144. * </pre>
  14145. */
  14146. }, {
  14147. key: "addIndex",
  14148. value: function (name /*: string*/, index /*: any*/) {
  14149. if (!name) {
  14150. throw new Error('index name may not be null.');
  14151. }
  14152. if (!index) {
  14153. throw new Error('index may not be null.');
  14154. }
  14155. this._indexes[name] = index;
  14156. return this;
  14157. }
  14158. /**
  14159. * Adding String Field
  14160. *
  14161. * @param {string} name Name of the field that will be created on Parse
  14162. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14163. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14164. */
  14165. }, {
  14166. key: "addString",
  14167. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14168. return this.addField(name, 'String', options);
  14169. }
  14170. /**
  14171. * Adding Number Field
  14172. *
  14173. * @param {string} name Name of the field that will be created on Parse
  14174. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14175. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14176. */
  14177. }, {
  14178. key: "addNumber",
  14179. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14180. return this.addField(name, 'Number', options);
  14181. }
  14182. /**
  14183. * Adding Boolean Field
  14184. *
  14185. * @param {string} name Name of the field that will be created on Parse
  14186. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14187. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14188. */
  14189. }, {
  14190. key: "addBoolean",
  14191. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14192. return this.addField(name, 'Boolean', options);
  14193. }
  14194. /**
  14195. * Adding Date Field
  14196. *
  14197. * @param {string} name Name of the field that will be created on Parse
  14198. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14199. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14200. */
  14201. }, {
  14202. key: "addDate",
  14203. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14204. return this.addField(name, 'Date', options);
  14205. }
  14206. /**
  14207. * Adding File Field
  14208. *
  14209. * @param {string} name Name of the field that will be created on Parse
  14210. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14211. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14212. */
  14213. }, {
  14214. key: "addFile",
  14215. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14216. return this.addField(name, 'File', options);
  14217. }
  14218. /**
  14219. * Adding GeoPoint Field
  14220. *
  14221. * @param {string} name Name of the field that will be created on Parse
  14222. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14223. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14224. */
  14225. }, {
  14226. key: "addGeoPoint",
  14227. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14228. return this.addField(name, 'GeoPoint', options);
  14229. }
  14230. /**
  14231. * Adding Polygon Field
  14232. *
  14233. * @param {string} name Name of the field that will be created on Parse
  14234. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14235. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14236. */
  14237. }, {
  14238. key: "addPolygon",
  14239. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14240. return this.addField(name, 'Polygon', options);
  14241. }
  14242. /**
  14243. * Adding Array Field
  14244. *
  14245. * @param {string} name Name of the field that will be created on Parse
  14246. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14247. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14248. */
  14249. }, {
  14250. key: "addArray",
  14251. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14252. return this.addField(name, 'Array', options);
  14253. }
  14254. /**
  14255. * Adding Object Field
  14256. *
  14257. * @param {string} name Name of the field that will be created on Parse
  14258. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14259. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14260. */
  14261. }, {
  14262. key: "addObject",
  14263. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14264. return this.addField(name, 'Object', options);
  14265. }
  14266. /**
  14267. * Adding Pointer Field
  14268. *
  14269. * @param {string} name Name of the field that will be created on Parse
  14270. * @param {string} targetClass Name of the target Pointer Class
  14271. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14272. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14273. */
  14274. }, {
  14275. key: "addPointer",
  14276. value: function (name /*: string*/, targetClass /*: string*/) {
  14277. var options /*: FieldOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  14278. if (!name) {
  14279. throw new Error('field name may not be null.');
  14280. }
  14281. if (!targetClass) {
  14282. throw new Error('You need to set the targetClass of the Pointer.');
  14283. }
  14284. var fieldOptions = {
  14285. type: 'Pointer',
  14286. targetClass: targetClass
  14287. };
  14288. if (typeof options.required === 'boolean') {
  14289. fieldOptions.required = options.required;
  14290. }
  14291. if (options.defaultValue !== undefined) {
  14292. fieldOptions.defaultValue = options.defaultValue;
  14293. if (options.defaultValue instanceof _ParseObject.default) {
  14294. fieldOptions.defaultValue = options.defaultValue.toPointer();
  14295. }
  14296. }
  14297. this._fields[name] = fieldOptions;
  14298. return this;
  14299. }
  14300. /**
  14301. * Adding Relation Field
  14302. *
  14303. * @param {string} name Name of the field that will be created on Parse
  14304. * @param {string} targetClass Name of the target Pointer Class
  14305. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14306. */
  14307. }, {
  14308. key: "addRelation",
  14309. value: function (name /*: string*/, targetClass /*: string*/) {
  14310. if (!name) {
  14311. throw new Error('field name may not be null.');
  14312. }
  14313. if (!targetClass) {
  14314. throw new Error('You need to set the targetClass of the Relation.');
  14315. }
  14316. this._fields[name] = {
  14317. type: 'Relation',
  14318. targetClass: targetClass
  14319. };
  14320. return this;
  14321. }
  14322. /**
  14323. * Deleting a Field to Update on a Schema
  14324. *
  14325. * @param {string} name Name of the field
  14326. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14327. */
  14328. }, {
  14329. key: "deleteField",
  14330. value: function (name /*: string*/) {
  14331. this._fields[name] = {
  14332. __op: 'Delete'
  14333. };
  14334. return this;
  14335. }
  14336. /**
  14337. * Deleting an Index to Update on a Schema
  14338. *
  14339. * @param {string} name Name of the field
  14340. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14341. */
  14342. }, {
  14343. key: "deleteIndex",
  14344. value: function (name /*: string*/) {
  14345. this._indexes[name] = {
  14346. __op: 'Delete'
  14347. };
  14348. return this;
  14349. }
  14350. }], [{
  14351. key: "all",
  14352. value: function () {
  14353. var controller = _CoreManager.default.getSchemaController();
  14354. return controller.get('').then(function (response) {
  14355. if (response.results.length === 0) {
  14356. throw new Error('Schema not found.');
  14357. }
  14358. return response.results;
  14359. });
  14360. }
  14361. }]);
  14362. return ParseSchema;
  14363. }();
  14364. var DefaultController = {
  14365. send: function (className /*: string*/, method /*: string*/) /*: Promise*/{
  14366. var params /*: any*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  14367. var RESTController = _CoreManager.default.getRESTController();
  14368. return RESTController.request(method, "schemas/".concat(className), params, {
  14369. useMasterKey: true
  14370. });
  14371. },
  14372. get: function (className /*: string*/) /*: Promise*/{
  14373. return this.send(className, 'GET');
  14374. },
  14375. create: function (className /*: string*/, params /*: any*/) /*: Promise*/{
  14376. return this.send(className, 'POST', params);
  14377. },
  14378. update: function (className /*: string*/, params /*: any*/) /*: Promise*/{
  14379. return this.send(className, 'PUT', params);
  14380. },
  14381. delete: function (className /*: string*/) /*: Promise*/{
  14382. return this.send(className, 'DELETE');
  14383. },
  14384. purge: function (className /*: string*/) /*: Promise*/{
  14385. var RESTController = _CoreManager.default.getRESTController();
  14386. return RESTController.request('DELETE', "purge/".concat(className), {}, {
  14387. useMasterKey: true
  14388. });
  14389. }
  14390. };
  14391. _CoreManager.default.setSchemaController(DefaultController);
  14392. var _default = ParseSchema;
  14393. exports.default = _default;
  14394. },{"./CoreManager":4,"./ParseCLP":20,"./ParseObject":27,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],34:[function(_dereq_,module,exports){
  14395. "use strict";
  14396. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  14397. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14398. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14399. _Object$defineProperty(exports, "__esModule", {
  14400. value: true
  14401. });
  14402. exports.default = void 0;
  14403. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  14404. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  14405. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  14406. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  14407. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  14408. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  14409. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  14410. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14411. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  14412. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  14413. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  14414. function _createSuper(Derived) {
  14415. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  14416. return function () {
  14417. var Super = (0, _getPrototypeOf2.default)(Derived),
  14418. result;
  14419. if (hasNativeReflectConstruct) {
  14420. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  14421. result = _Reflect$construct(Super, arguments, NewTarget);
  14422. } else {
  14423. result = Super.apply(this, arguments);
  14424. }
  14425. return (0, _possibleConstructorReturn2.default)(this, result);
  14426. };
  14427. }
  14428. function _isNativeReflectConstruct() {
  14429. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  14430. if (_Reflect$construct.sham) return false;
  14431. if (typeof Proxy === "function") return true;
  14432. try {
  14433. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  14434. return true;
  14435. } catch (e) {
  14436. return false;
  14437. }
  14438. } /**
  14439. * @flow
  14440. */
  14441. /*:: import type { AttributeMap } from './ObjectStateMutations';*/
  14442. /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
  14443. /**
  14444. * <p>A Parse.Session object is a local representation of a revocable session.
  14445. * This class is a subclass of a Parse.Object, and retains the same
  14446. * functionality of a Parse.Object.</p>
  14447. *
  14448. * @alias Parse.Session
  14449. * @augments Parse.Object
  14450. */
  14451. var ParseSession = /*#__PURE__*/function (_ParseObject) {
  14452. (0, _inherits2.default)(ParseSession, _ParseObject);
  14453. var _super = _createSuper(ParseSession);
  14454. /**
  14455. * @param {object} attributes The initial set of data to store in the user.
  14456. */
  14457. function ParseSession(attributes /*: ?AttributeMap*/) {
  14458. var _this;
  14459. (0, _classCallCheck2.default)(this, ParseSession);
  14460. _this = _super.call(this, '_Session');
  14461. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  14462. if (!_this.set(attributes || {})) {
  14463. throw new Error("Can't create an invalid Session");
  14464. }
  14465. }
  14466. return _this;
  14467. }
  14468. /**
  14469. * Returns the session token string.
  14470. *
  14471. * @returns {string}
  14472. */
  14473. (0, _createClass2.default)(ParseSession, [{
  14474. key: "getSessionToken",
  14475. value: function () /*: string*/{
  14476. var token = this.get('sessionToken');
  14477. if (typeof token === 'string') {
  14478. return token;
  14479. }
  14480. return '';
  14481. }
  14482. }], [{
  14483. key: "readOnlyAttributes",
  14484. value: function () {
  14485. return ['createdWith', 'expiresAt', 'installationId', 'restricted', 'sessionToken', 'user'];
  14486. }
  14487. /**
  14488. * Retrieves the Session object for the currently logged in session.
  14489. *
  14490. * @param {object} options useMasterKey
  14491. * @static
  14492. * @returns {Promise} A promise that is resolved with the Parse.Session
  14493. * object after it has been fetched. If there is no current user, the
  14494. * promise will be rejected.
  14495. */
  14496. }, {
  14497. key: "current",
  14498. value: function (options /*: FullOptions*/) {
  14499. options = options || {};
  14500. var controller = _CoreManager.default.getSessionController();
  14501. var sessionOptions = {};
  14502. if (options.hasOwnProperty('useMasterKey')) {
  14503. sessionOptions.useMasterKey = options.useMasterKey;
  14504. }
  14505. return _ParseUser.default.currentAsync().then(function (user) {
  14506. if (!user) {
  14507. return _promise.default.reject('There is no current user.');
  14508. }
  14509. sessionOptions.sessionToken = user.getSessionToken();
  14510. return controller.getSession(sessionOptions);
  14511. });
  14512. }
  14513. /**
  14514. * Determines whether the current session token is revocable.
  14515. * This method is useful for migrating Express.js or Node.js web apps to
  14516. * use revocable sessions. If you are migrating an app that uses the Parse
  14517. * SDK in the browser only, please use Parse.User.enableRevocableSession()
  14518. * instead, so that sessions can be automatically upgraded.
  14519. *
  14520. * @static
  14521. * @returns {boolean}
  14522. */
  14523. }, {
  14524. key: "isCurrentSessionRevocable",
  14525. value: function () /*: boolean*/{
  14526. var currentUser = _ParseUser.default.current();
  14527. if (currentUser) {
  14528. return (0, _isRevocableSession.default)(currentUser.getSessionToken() || '');
  14529. }
  14530. return false;
  14531. }
  14532. }]);
  14533. return ParseSession;
  14534. }(_ParseObject2.default);
  14535. _ParseObject2.default.registerSubclass('_Session', ParseSession);
  14536. var DefaultController = {
  14537. getSession: function (options /*: RequestOptions*/) /*: Promise<ParseSession>*/{
  14538. var RESTController = _CoreManager.default.getRESTController();
  14539. var session = new ParseSession();
  14540. return RESTController.request('GET', 'sessions/me', {}, options).then(function (sessionData) {
  14541. session._finishFetch(sessionData);
  14542. session._setExisted(true);
  14543. return session;
  14544. });
  14545. }
  14546. };
  14547. _CoreManager.default.setSessionController(DefaultController);
  14548. var _default = ParseSession;
  14549. exports.default = _default;
  14550. },{"./CoreManager":4,"./ParseObject":27,"./ParseUser":35,"./isRevocableSession":49,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/core-js-stable/reflect/construct":91,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/getPrototypeOf":127,"@babel/runtime-corejs3/helpers/inherits":128,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":136,"@babel/runtime-corejs3/helpers/typeof":144}],35:[function(_dereq_,module,exports){
  14551. "use strict";
  14552. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  14553. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14554. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14555. _Object$defineProperty2(exports, "__esModule", {
  14556. value: true
  14557. });
  14558. exports.default = void 0;
  14559. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  14560. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  14561. var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  14562. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  14563. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  14564. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  14565. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  14566. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  14567. var _get2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/get"));
  14568. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  14569. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  14570. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  14571. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14572. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  14573. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  14574. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  14575. var _ParseSession = _interopRequireDefault(_dereq_("./ParseSession"));
  14576. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  14577. function _createSuper(Derived) {
  14578. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  14579. return function () {
  14580. var Super = (0, _getPrototypeOf2.default)(Derived),
  14581. result;
  14582. if (hasNativeReflectConstruct) {
  14583. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  14584. result = _Reflect$construct(Super, arguments, NewTarget);
  14585. } else {
  14586. result = Super.apply(this, arguments);
  14587. }
  14588. return (0, _possibleConstructorReturn2.default)(this, result);
  14589. };
  14590. }
  14591. function _isNativeReflectConstruct() {
  14592. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  14593. if (_Reflect$construct.sham) return false;
  14594. if (typeof Proxy === "function") return true;
  14595. try {
  14596. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  14597. return true;
  14598. } catch (e) {
  14599. return false;
  14600. }
  14601. } /**
  14602. * @flow
  14603. */
  14604. /*:: import type { AttributeMap } from './ObjectStateMutations';*/
  14605. /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
  14606. /*:: export type AuthData = ?{ [key: string]: mixed };*/
  14607. var CURRENT_USER_KEY = 'currentUser';
  14608. var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
  14609. var currentUserCacheMatchesDisk = false;
  14610. var currentUserCache = null;
  14611. var authProviders = {};
  14612. /**
  14613. * <p>A Parse.User object is a local representation of a user persisted to the
  14614. * Parse cloud. This class is a subclass of a Parse.Object, and retains the
  14615. * same functionality of a Parse.Object, but also extends it with various
  14616. * user specific methods, like authentication, signing up, and validation of
  14617. * uniqueness.</p>
  14618. *
  14619. * @alias Parse.User
  14620. * @augments Parse.Object
  14621. */
  14622. var ParseUser = /*#__PURE__*/function (_ParseObject) {
  14623. (0, _inherits2.default)(ParseUser, _ParseObject);
  14624. var _super = _createSuper(ParseUser);
  14625. /**
  14626. * @param {object} attributes The initial set of data to store in the user.
  14627. */
  14628. function ParseUser(attributes /*: ?AttributeMap*/) {
  14629. var _this;
  14630. (0, _classCallCheck2.default)(this, ParseUser);
  14631. _this = _super.call(this, '_User');
  14632. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  14633. if (!_this.set(attributes || {})) {
  14634. throw new Error("Can't create an invalid Parse User");
  14635. }
  14636. }
  14637. return _this;
  14638. }
  14639. /**
  14640. * Request a revocable session token to replace the older style of token.
  14641. *
  14642. * @param {object} options
  14643. * @returns {Promise} A promise that is resolved when the replacement
  14644. * token has been fetched.
  14645. */
  14646. (0, _createClass2.default)(ParseUser, [{
  14647. key: "_upgradeToRevocableSession",
  14648. value: function (options /*: RequestOptions*/) /*: Promise<void>*/{
  14649. options = options || {};
  14650. var upgradeOptions = {};
  14651. if (options.hasOwnProperty('useMasterKey')) {
  14652. upgradeOptions.useMasterKey = options.useMasterKey;
  14653. }
  14654. var controller = _CoreManager.default.getUserController();
  14655. return controller.upgradeToRevocableSession(this, upgradeOptions);
  14656. }
  14657. /**
  14658. * Parse allows you to link your users with {@link https://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication 3rd party authentication}, enabling
  14659. * your users to sign up or log into your application using their existing identities.
  14660. * Since 2.9.0
  14661. *
  14662. * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users}
  14663. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  14664. * @param {object} options
  14665. * <ul>
  14666. * <li>If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData}
  14667. * <li>If provider is AuthProvider, options is saveOpts
  14668. * </ul>
  14669. * @param {object} saveOpts useMasterKey / sessionToken
  14670. * @returns {Promise} A promise that is fulfilled with the user is linked
  14671. */
  14672. }, {
  14673. key: "linkWith",
  14674. value: function (provider /*: any*/, options /*: { authData?: AuthData }*/) /*: Promise<ParseUser>*/{
  14675. var _this2 = this;
  14676. var saveOpts /*:: ?: FullOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  14677. saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
  14678. var authType;
  14679. if (typeof provider === 'string') {
  14680. authType = provider;
  14681. if (authProviders[provider]) {
  14682. provider = authProviders[provider];
  14683. } else {
  14684. var authProvider = {
  14685. restoreAuthentication: function () {
  14686. return true;
  14687. },
  14688. getAuthType: function () {
  14689. return authType;
  14690. }
  14691. };
  14692. authProviders[authProvider.getAuthType()] = authProvider;
  14693. provider = authProvider;
  14694. }
  14695. } else {
  14696. authType = provider.getAuthType();
  14697. }
  14698. if (options && options.hasOwnProperty('authData')) {
  14699. var authData = this.get('authData') || {};
  14700. if ((0, _typeof2.default)(authData) !== 'object') {
  14701. throw new Error('Invalid type: authData field should be an object');
  14702. }
  14703. authData[authType] = options.authData;
  14704. var controller = _CoreManager.default.getUserController();
  14705. return controller.linkWith(this, authData, saveOpts);
  14706. } else {
  14707. return new _promise.default(function (resolve, reject) {
  14708. provider.authenticate({
  14709. success: function (provider, result) {
  14710. var opts = {};
  14711. opts.authData = result;
  14712. _this2.linkWith(provider, opts, saveOpts).then(function () {
  14713. resolve(_this2);
  14714. }, function (error) {
  14715. reject(error);
  14716. });
  14717. },
  14718. error: function (provider, _error) {
  14719. reject(_error);
  14720. }
  14721. });
  14722. });
  14723. }
  14724. }
  14725. /**
  14726. * @param provider
  14727. * @param options
  14728. * @param saveOpts
  14729. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  14730. * @returns {Promise}
  14731. */
  14732. }, {
  14733. key: "_linkWith",
  14734. value: function (provider /*: any*/, options /*: { authData?: AuthData }*/) /*: Promise<ParseUser>*/{
  14735. var saveOpts /*:: ?: FullOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  14736. return this.linkWith(provider, options, saveOpts);
  14737. }
  14738. /**
  14739. * Synchronizes auth data for a provider (e.g. puts the access token in the
  14740. * right place to be used by the Facebook SDK).
  14741. *
  14742. * @param provider
  14743. */
  14744. }, {
  14745. key: "_synchronizeAuthData",
  14746. value: function (provider /*: string*/) {
  14747. if (!this.isCurrent() || !provider) {
  14748. return;
  14749. }
  14750. var authType;
  14751. if (typeof provider === 'string') {
  14752. authType = provider;
  14753. provider = authProviders[authType];
  14754. } else {
  14755. authType = provider.getAuthType();
  14756. }
  14757. var authData = this.get('authData');
  14758. if (!provider || !authData || (0, _typeof2.default)(authData) !== 'object') {
  14759. return;
  14760. }
  14761. var success = provider.restoreAuthentication(authData[authType]);
  14762. if (!success) {
  14763. this._unlinkFrom(provider);
  14764. }
  14765. }
  14766. /**
  14767. * Synchronizes authData for all providers.
  14768. */
  14769. }, {
  14770. key: "_synchronizeAllAuthData",
  14771. value: function () {
  14772. var authData = this.get('authData');
  14773. if ((0, _typeof2.default)(authData) !== 'object') {
  14774. return;
  14775. }
  14776. for (var _key in authData) {
  14777. this._synchronizeAuthData(_key);
  14778. }
  14779. }
  14780. /**
  14781. * Removes null values from authData (which exist temporarily for unlinking)
  14782. */
  14783. }, {
  14784. key: "_cleanupAuthData",
  14785. value: function () {
  14786. if (!this.isCurrent()) {
  14787. return;
  14788. }
  14789. var authData = this.get('authData');
  14790. if ((0, _typeof2.default)(authData) !== 'object') {
  14791. return;
  14792. }
  14793. for (var _key2 in authData) {
  14794. if (!authData[_key2]) {
  14795. delete authData[_key2];
  14796. }
  14797. }
  14798. }
  14799. /**
  14800. * Unlinks a user from a service.
  14801. *
  14802. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  14803. * @param {object} options MasterKey / SessionToken
  14804. * @returns {Promise} A promise that is fulfilled when the unlinking
  14805. * finishes.
  14806. */
  14807. }, {
  14808. key: "_unlinkFrom",
  14809. value: function (provider /*: any*/, options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
  14810. var _this3 = this;
  14811. return this.linkWith(provider, {
  14812. authData: null
  14813. }, options).then(function () {
  14814. _this3._synchronizeAuthData(provider);
  14815. return _promise.default.resolve(_this3);
  14816. });
  14817. }
  14818. /**
  14819. * Checks whether a user is linked to a service.
  14820. *
  14821. * @param {object} provider service to link to
  14822. * @returns {boolean} true if link was successful
  14823. */
  14824. }, {
  14825. key: "_isLinked",
  14826. value: function (provider /*: any*/) /*: boolean*/{
  14827. var authType;
  14828. if (typeof provider === 'string') {
  14829. authType = provider;
  14830. } else {
  14831. authType = provider.getAuthType();
  14832. }
  14833. var authData = this.get('authData') || {};
  14834. if ((0, _typeof2.default)(authData) !== 'object') {
  14835. return false;
  14836. }
  14837. return !!authData[authType];
  14838. }
  14839. /**
  14840. * Deauthenticates all providers.
  14841. */
  14842. }, {
  14843. key: "_logOutWithAll",
  14844. value: function () {
  14845. var authData = this.get('authData');
  14846. if ((0, _typeof2.default)(authData) !== 'object') {
  14847. return;
  14848. }
  14849. for (var _key3 in authData) {
  14850. this._logOutWith(_key3);
  14851. }
  14852. }
  14853. /**
  14854. * Deauthenticates a single provider (e.g. removing access tokens from the
  14855. * Facebook SDK).
  14856. *
  14857. * @param {object} provider service to logout of
  14858. */
  14859. }, {
  14860. key: "_logOutWith",
  14861. value: function (provider /*: any*/) {
  14862. if (!this.isCurrent()) {
  14863. return;
  14864. }
  14865. if (typeof provider === 'string') {
  14866. provider = authProviders[provider];
  14867. }
  14868. if (provider && provider.deauthenticate) {
  14869. provider.deauthenticate();
  14870. }
  14871. }
  14872. /**
  14873. * Class instance method used to maintain specific keys when a fetch occurs.
  14874. * Used to ensure that the session token is not lost.
  14875. *
  14876. * @returns {object} sessionToken
  14877. */
  14878. }, {
  14879. key: "_preserveFieldsOnFetch",
  14880. value: function () /*: AttributeMap*/{
  14881. return {
  14882. sessionToken: this.get('sessionToken')
  14883. };
  14884. }
  14885. /**
  14886. * Returns true if <code>current</code> would return this user.
  14887. *
  14888. * @returns {boolean} true if user is cached on disk
  14889. */
  14890. }, {
  14891. key: "isCurrent",
  14892. value: function () /*: boolean*/{
  14893. var current = ParseUser.current();
  14894. return !!current && current.id === this.id;
  14895. }
  14896. /**
  14897. * Returns true if <code>current</code> would return this user.
  14898. *
  14899. * @returns {Promise<boolean>} true if user is cached on disk
  14900. */
  14901. }, {
  14902. key: "isCurrentAsync",
  14903. value: function () {
  14904. var _isCurrentAsync = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  14905. var current;
  14906. return _regenerator.default.wrap(function (_context) {
  14907. while (1) switch (_context.prev = _context.next) {
  14908. case 0:
  14909. _context.next = 2;
  14910. return ParseUser.currentAsync();
  14911. case 2:
  14912. current = _context.sent;
  14913. return _context.abrupt("return", !!current && current.id === this.id);
  14914. case 4:
  14915. case "end":
  14916. return _context.stop();
  14917. }
  14918. }, _callee, this);
  14919. }));
  14920. function isCurrentAsync() {
  14921. return _isCurrentAsync.apply(this, arguments);
  14922. }
  14923. return isCurrentAsync;
  14924. }()
  14925. /**
  14926. * Returns get("username").
  14927. *
  14928. * @returns {string}
  14929. */
  14930. }, {
  14931. key: "getUsername",
  14932. value: function () /*: ?string*/{
  14933. var username = this.get('username');
  14934. if (username == null || typeof username === 'string') {
  14935. return username;
  14936. }
  14937. return '';
  14938. }
  14939. /**
  14940. * Calls set("username", username, options) and returns the result.
  14941. *
  14942. * @param {string} username
  14943. */
  14944. }, {
  14945. key: "setUsername",
  14946. value: function (username /*: string*/) {
  14947. // Strip anonymity
  14948. var authData = this.get('authData');
  14949. if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
  14950. // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
  14951. authData.anonymous = null;
  14952. }
  14953. this.set('username', username);
  14954. }
  14955. /**
  14956. * Calls set("password", password, options) and returns the result.
  14957. *
  14958. * @param {string} password User's Password
  14959. */
  14960. }, {
  14961. key: "setPassword",
  14962. value: function (password /*: string*/) {
  14963. this.set('password', password);
  14964. }
  14965. /**
  14966. * Returns get("email").
  14967. *
  14968. * @returns {string} User's Email
  14969. */
  14970. }, {
  14971. key: "getEmail",
  14972. value: function () /*: ?string*/{
  14973. var email = this.get('email');
  14974. if (email == null || typeof email === 'string') {
  14975. return email;
  14976. }
  14977. return '';
  14978. }
  14979. /**
  14980. * Calls set("email", email) and returns the result.
  14981. *
  14982. * @param {string} email
  14983. * @returns {boolean}
  14984. */
  14985. }, {
  14986. key: "setEmail",
  14987. value: function (email /*: string*/) {
  14988. return this.set('email', email);
  14989. }
  14990. /**
  14991. * Returns the session token for this user, if the user has been logged in,
  14992. * or if it is the result of a query with the master key. Otherwise, returns
  14993. * undefined.
  14994. *
  14995. * @returns {string} the session token, or undefined
  14996. */
  14997. }, {
  14998. key: "getSessionToken",
  14999. value: function () /*: ?string*/{
  15000. var token = this.get('sessionToken');
  15001. if (token == null || typeof token === 'string') {
  15002. return token;
  15003. }
  15004. return '';
  15005. }
  15006. /**
  15007. * Checks whether this user is the current user and has been authenticated.
  15008. *
  15009. * @returns {boolean} whether this user is the current user and is logged in.
  15010. */
  15011. }, {
  15012. key: "authenticated",
  15013. value: function () /*: boolean*/{
  15014. var current = ParseUser.current();
  15015. return !!this.get('sessionToken') && !!current && current.id === this.id;
  15016. }
  15017. /**
  15018. * Signs up a new user. You should call this instead of save for
  15019. * new Parse.Users. This will create a new Parse.User on the server, and
  15020. * also persist the session on disk so that you can access the user using
  15021. * <code>current</code>.
  15022. *
  15023. * <p>A username and password must be set before calling signUp.</p>
  15024. *
  15025. * @param {object} attrs Extra fields to set on the new user, or null.
  15026. * @param {object} options
  15027. * @returns {Promise} A promise that is fulfilled when the signup
  15028. * finishes.
  15029. */
  15030. }, {
  15031. key: "signUp",
  15032. value: function (attrs /*: AttributeMap*/, options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
  15033. options = options || {};
  15034. var signupOptions = {};
  15035. if (options.hasOwnProperty('useMasterKey')) {
  15036. signupOptions.useMasterKey = options.useMasterKey;
  15037. }
  15038. if (options.hasOwnProperty('installationId')) {
  15039. signupOptions.installationId = options.installationId;
  15040. }
  15041. if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
  15042. signupOptions.context = options.context;
  15043. }
  15044. var controller = _CoreManager.default.getUserController();
  15045. return controller.signUp(this, attrs, signupOptions);
  15046. }
  15047. /**
  15048. * Logs in a Parse.User. On success, this saves the session to disk,
  15049. * so you can retrieve the currently logged in user using
  15050. * <code>current</code>.
  15051. *
  15052. * <p>A username and password must be set before calling logIn.</p>
  15053. *
  15054. * @param {object} options
  15055. * @returns {Promise} A promise that is fulfilled with the user when
  15056. * the login is complete.
  15057. */
  15058. }, {
  15059. key: "logIn",
  15060. value: function (options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
  15061. options = options || {};
  15062. var loginOptions = {
  15063. usePost: true
  15064. };
  15065. if (options.hasOwnProperty('useMasterKey')) {
  15066. loginOptions.useMasterKey = options.useMasterKey;
  15067. }
  15068. if (options.hasOwnProperty('installationId')) {
  15069. loginOptions.installationId = options.installationId;
  15070. }
  15071. if (options.hasOwnProperty('usePost')) {
  15072. loginOptions.usePost = options.usePost;
  15073. }
  15074. var controller = _CoreManager.default.getUserController();
  15075. return controller.logIn(this, loginOptions);
  15076. }
  15077. /**
  15078. * Wrap the default save behavior with functionality to save to local
  15079. * storage if this is current user.
  15080. *
  15081. * @param {...any} args
  15082. * @returns {Promise}
  15083. */
  15084. }, {
  15085. key: "save",
  15086. value: function () {
  15087. var _save = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  15088. var _len,
  15089. args,
  15090. _key4,
  15091. current,
  15092. _args2 = arguments;
  15093. return _regenerator.default.wrap(function (_context2) {
  15094. while (1) switch (_context2.prev = _context2.next) {
  15095. case 0:
  15096. for (_len = _args2.length, args = new Array(_len), _key4 = 0; _key4 < _len; _key4++) {
  15097. args[_key4] = _args2[_key4];
  15098. }
  15099. _context2.next = 3;
  15100. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "save", this).apply(this, args);
  15101. case 3:
  15102. _context2.next = 5;
  15103. return this.isCurrentAsync();
  15104. case 5:
  15105. current = _context2.sent;
  15106. if (!current) {
  15107. _context2.next = 8;
  15108. break;
  15109. }
  15110. return _context2.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
  15111. case 8:
  15112. return _context2.abrupt("return", this);
  15113. case 9:
  15114. case "end":
  15115. return _context2.stop();
  15116. }
  15117. }, _callee2, this);
  15118. }));
  15119. function save() {
  15120. return _save.apply(this, arguments);
  15121. }
  15122. return save;
  15123. }()
  15124. /**
  15125. * Wrap the default destroy behavior with functionality that logs out
  15126. * the current user when it is destroyed
  15127. *
  15128. * @param {...any} args
  15129. * @returns {Parse.User}
  15130. */
  15131. }, {
  15132. key: "destroy",
  15133. value: function () {
  15134. var _destroy = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  15135. var _len2,
  15136. args,
  15137. _key5,
  15138. current,
  15139. _args3 = arguments;
  15140. return _regenerator.default.wrap(function (_context3) {
  15141. while (1) switch (_context3.prev = _context3.next) {
  15142. case 0:
  15143. for (_len2 = _args3.length, args = new Array(_len2), _key5 = 0; _key5 < _len2; _key5++) {
  15144. args[_key5] = _args3[_key5];
  15145. }
  15146. _context3.next = 3;
  15147. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "destroy", this).apply(this, args);
  15148. case 3:
  15149. _context3.next = 5;
  15150. return this.isCurrentAsync();
  15151. case 5:
  15152. current = _context3.sent;
  15153. if (!current) {
  15154. _context3.next = 8;
  15155. break;
  15156. }
  15157. return _context3.abrupt("return", _CoreManager.default.getUserController().removeUserFromDisk());
  15158. case 8:
  15159. return _context3.abrupt("return", this);
  15160. case 9:
  15161. case "end":
  15162. return _context3.stop();
  15163. }
  15164. }, _callee3, this);
  15165. }));
  15166. function destroy() {
  15167. return _destroy.apply(this, arguments);
  15168. }
  15169. return destroy;
  15170. }()
  15171. /**
  15172. * Wrap the default fetch behavior with functionality to save to local
  15173. * storage if this is current user.
  15174. *
  15175. * @param {...any} args
  15176. * @returns {Parse.User}
  15177. */
  15178. }, {
  15179. key: "fetch",
  15180. value: function () {
  15181. var _fetch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
  15182. var _len3,
  15183. args,
  15184. _key6,
  15185. current,
  15186. _args4 = arguments;
  15187. return _regenerator.default.wrap(function (_context4) {
  15188. while (1) switch (_context4.prev = _context4.next) {
  15189. case 0:
  15190. for (_len3 = _args4.length, args = new Array(_len3), _key6 = 0; _key6 < _len3; _key6++) {
  15191. args[_key6] = _args4[_key6];
  15192. }
  15193. _context4.next = 3;
  15194. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetch", this).apply(this, args);
  15195. case 3:
  15196. _context4.next = 5;
  15197. return this.isCurrentAsync();
  15198. case 5:
  15199. current = _context4.sent;
  15200. if (!current) {
  15201. _context4.next = 8;
  15202. break;
  15203. }
  15204. return _context4.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
  15205. case 8:
  15206. return _context4.abrupt("return", this);
  15207. case 9:
  15208. case "end":
  15209. return _context4.stop();
  15210. }
  15211. }, _callee4, this);
  15212. }));
  15213. function fetch() {
  15214. return _fetch.apply(this, arguments);
  15215. }
  15216. return fetch;
  15217. }()
  15218. /**
  15219. * Wrap the default fetchWithInclude behavior with functionality to save to local
  15220. * storage if this is current user.
  15221. *
  15222. * @param {...any} args
  15223. * @returns {Parse.User}
  15224. */
  15225. }, {
  15226. key: "fetchWithInclude",
  15227. value: function () {
  15228. var _fetchWithInclude = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  15229. var _len4,
  15230. args,
  15231. _key7,
  15232. current,
  15233. _args5 = arguments;
  15234. return _regenerator.default.wrap(function (_context5) {
  15235. while (1) switch (_context5.prev = _context5.next) {
  15236. case 0:
  15237. for (_len4 = _args5.length, args = new Array(_len4), _key7 = 0; _key7 < _len4; _key7++) {
  15238. args[_key7] = _args5[_key7];
  15239. }
  15240. _context5.next = 3;
  15241. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetchWithInclude", this).apply(this, args);
  15242. case 3:
  15243. _context5.next = 5;
  15244. return this.isCurrentAsync();
  15245. case 5:
  15246. current = _context5.sent;
  15247. if (!current) {
  15248. _context5.next = 8;
  15249. break;
  15250. }
  15251. return _context5.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
  15252. case 8:
  15253. return _context5.abrupt("return", this);
  15254. case 9:
  15255. case "end":
  15256. return _context5.stop();
  15257. }
  15258. }, _callee5, this);
  15259. }));
  15260. function fetchWithInclude() {
  15261. return _fetchWithInclude.apply(this, arguments);
  15262. }
  15263. return fetchWithInclude;
  15264. }()
  15265. /**
  15266. * Verify whether a given password is the password of the current user.
  15267. *
  15268. * @param {string} password A password to be verified
  15269. * @param {object} options
  15270. * @returns {Promise} A promise that is fulfilled with a user
  15271. * when the password is correct.
  15272. */
  15273. }, {
  15274. key: "verifyPassword",
  15275. value: function (password /*: string*/, options /*:: ?: RequestOptions*/) /*: Promise<ParseUser>*/{
  15276. var username = this.getUsername() || '';
  15277. return ParseUser.verifyPassword(username, password, options);
  15278. }
  15279. }], [{
  15280. key: "readOnlyAttributes",
  15281. value: function () {
  15282. return ['sessionToken'];
  15283. }
  15284. /**
  15285. * Adds functionality to the existing Parse.User class.
  15286. *
  15287. * @param {object} protoProps A set of properties to add to the prototype
  15288. * @param {object} classProps A set of static properties to add to the class
  15289. * @static
  15290. * @returns {Parse.User} The newly extended Parse.User class
  15291. */
  15292. }, {
  15293. key: "extend",
  15294. value: function (protoProps /*: { [prop: string]: any }*/, classProps /*: { [prop: string]: any }*/) {
  15295. if (protoProps) {
  15296. for (var _prop in protoProps) {
  15297. if (_prop !== 'className') {
  15298. (0, _defineProperty.default)(ParseUser.prototype, _prop, {
  15299. value: protoProps[_prop],
  15300. enumerable: false,
  15301. writable: true,
  15302. configurable: true
  15303. });
  15304. }
  15305. }
  15306. }
  15307. if (classProps) {
  15308. for (var _prop2 in classProps) {
  15309. if (_prop2 !== 'className') {
  15310. (0, _defineProperty.default)(ParseUser, _prop2, {
  15311. value: classProps[_prop2],
  15312. enumerable: false,
  15313. writable: true,
  15314. configurable: true
  15315. });
  15316. }
  15317. }
  15318. }
  15319. return ParseUser;
  15320. }
  15321. /**
  15322. * Retrieves the currently logged in ParseUser with a valid session,
  15323. * either from memory or localStorage, if necessary.
  15324. *
  15325. * @static
  15326. * @returns {Parse.Object} The currently logged in Parse.User.
  15327. */
  15328. }, {
  15329. key: "current",
  15330. value: function () /*: ?ParseUser*/{
  15331. if (!canUseCurrentUser) {
  15332. return null;
  15333. }
  15334. var controller = _CoreManager.default.getUserController();
  15335. return controller.currentUser();
  15336. }
  15337. /**
  15338. * Retrieves the currently logged in ParseUser from asynchronous Storage.
  15339. *
  15340. * @static
  15341. * @returns {Promise} A Promise that is resolved with the currently
  15342. * logged in Parse User
  15343. */
  15344. }, {
  15345. key: "currentAsync",
  15346. value: function () /*: Promise<?ParseUser>*/{
  15347. if (!canUseCurrentUser) {
  15348. return _promise.default.resolve(null);
  15349. }
  15350. var controller = _CoreManager.default.getUserController();
  15351. return controller.currentUserAsync();
  15352. }
  15353. /**
  15354. * Signs up a new user with a username (or email) and password.
  15355. * This will create a new Parse.User on the server, and also persist the
  15356. * session in localStorage so that you can access the user using
  15357. * {@link #current}.
  15358. *
  15359. * @param {string} username The username (or email) to sign up with.
  15360. * @param {string} password The password to sign up with.
  15361. * @param {object} attrs Extra fields to set on the new user.
  15362. * @param {object} options
  15363. * @static
  15364. * @returns {Promise} A promise that is fulfilled with the user when
  15365. * the signup completes.
  15366. */
  15367. }, {
  15368. key: "signUp",
  15369. value: function (username /*: string*/, password /*: string*/, attrs /*: AttributeMap*/, options /*:: ?: FullOptions*/) {
  15370. attrs = attrs || {};
  15371. attrs.username = username;
  15372. attrs.password = password;
  15373. var user = new this(attrs);
  15374. return user.signUp({}, options);
  15375. }
  15376. /**
  15377. * Logs in a user with a username (or email) and password. On success, this
  15378. * saves the session to disk, so you can retrieve the currently logged in
  15379. * user using <code>current</code>.
  15380. *
  15381. * @param {string} username The username (or email) to log in with.
  15382. * @param {string} password The password to log in with.
  15383. * @param {object} options
  15384. * @static
  15385. * @returns {Promise} A promise that is fulfilled with the user when
  15386. * the login completes.
  15387. */
  15388. }, {
  15389. key: "logIn",
  15390. value: function (username /*: string*/, password /*: string*/, options /*:: ?: FullOptions*/) {
  15391. if (typeof username !== 'string') {
  15392. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  15393. } else if (typeof password !== 'string') {
  15394. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  15395. }
  15396. var user = new this();
  15397. user._finishFetch({
  15398. username: username,
  15399. password: password
  15400. });
  15401. return user.logIn(options);
  15402. }
  15403. /**
  15404. * Logs in a user with an objectId. On success, this saves the session
  15405. * to disk, so you can retrieve the currently logged in user using
  15406. * <code>current</code>.
  15407. *
  15408. * @param {string} userId The objectId for the user.
  15409. * @static
  15410. * @returns {Promise} A promise that is fulfilled with the user when
  15411. * the login completes.
  15412. */
  15413. }, {
  15414. key: "loginAs",
  15415. value: function (userId /*: string*/) {
  15416. if (!userId) {
  15417. throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
  15418. }
  15419. var controller = _CoreManager.default.getUserController();
  15420. var user = new this();
  15421. return controller.loginAs(user, userId);
  15422. }
  15423. /**
  15424. * Logs in a user with a session token. On success, this saves the session
  15425. * to disk, so you can retrieve the currently logged in user using
  15426. * <code>current</code>.
  15427. *
  15428. * @param {string} sessionToken The sessionToken to log in with.
  15429. * @param {object} options
  15430. * @static
  15431. * @returns {Promise} A promise that is fulfilled with the user when
  15432. * the login completes.
  15433. */
  15434. }, {
  15435. key: "become",
  15436. value: function (sessionToken /*: string*/, options /*:: ?: RequestOptions*/) {
  15437. if (!canUseCurrentUser) {
  15438. throw new Error('It is not memory-safe to become a user in a server environment');
  15439. }
  15440. options = options || {};
  15441. var becomeOptions /*: RequestOptions*/ = {
  15442. sessionToken: sessionToken
  15443. };
  15444. if (options.hasOwnProperty('useMasterKey')) {
  15445. becomeOptions.useMasterKey = options.useMasterKey;
  15446. }
  15447. var controller = _CoreManager.default.getUserController();
  15448. var user = new this();
  15449. return controller.become(user, becomeOptions);
  15450. }
  15451. /**
  15452. * Retrieves a user with a session token.
  15453. *
  15454. * @param {string} sessionToken The sessionToken to get user with.
  15455. * @param {object} options
  15456. * @static
  15457. * @returns {Promise} A promise that is fulfilled with the user is fetched.
  15458. */
  15459. }, {
  15460. key: "me",
  15461. value: function (sessionToken /*: string*/) {
  15462. var options /*:: ?: RequestOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  15463. var controller = _CoreManager.default.getUserController();
  15464. var meOptions /*: RequestOptions*/ = {
  15465. sessionToken: sessionToken
  15466. };
  15467. if (options.useMasterKey) {
  15468. meOptions.useMasterKey = options.useMasterKey;
  15469. }
  15470. var user = new this();
  15471. return controller.me(user, meOptions);
  15472. }
  15473. /**
  15474. * Logs in a user with a session token. On success, this saves the session
  15475. * to disk, so you can retrieve the currently logged in user using
  15476. * <code>current</code>. If there is no session token the user will not logged in.
  15477. *
  15478. * @param {object} userJSON The JSON map of the User's data
  15479. * @static
  15480. * @returns {Promise} A promise that is fulfilled with the user when
  15481. * the login completes.
  15482. */
  15483. }, {
  15484. key: "hydrate",
  15485. value: function (userJSON /*: AttributeMap*/) {
  15486. var controller = _CoreManager.default.getUserController();
  15487. var user = new this();
  15488. return controller.hydrate(user, userJSON);
  15489. }
  15490. /**
  15491. * Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  15492. *
  15493. * @param provider
  15494. * @param options
  15495. * @param saveOpts
  15496. * @static
  15497. * @returns {Promise}
  15498. */
  15499. }, {
  15500. key: "logInWith",
  15501. value: function (provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
  15502. var user = new this();
  15503. return user.linkWith(provider, options, saveOpts);
  15504. }
  15505. /**
  15506. * Logs out the currently logged in user session. This will remove the
  15507. * session from disk, log out of linked services, and future calls to
  15508. * <code>current</code> will return <code>null</code>.
  15509. *
  15510. * @param {object} options
  15511. * @static
  15512. * @returns {Promise} A promise that is resolved when the session is
  15513. * destroyed on the server.
  15514. */
  15515. }, {
  15516. key: "logOut",
  15517. value: function () {
  15518. var options /*: RequestOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  15519. var controller = _CoreManager.default.getUserController();
  15520. return controller.logOut(options);
  15521. }
  15522. /**
  15523. * Requests a password reset email to be sent to the specified email address
  15524. * associated with the user account. This email allows the user to securely
  15525. * reset their password on the Parse site.
  15526. *
  15527. * @param {string} email The email address associated with the user that
  15528. * forgot their password.
  15529. * @param {object} options
  15530. * @static
  15531. * @returns {Promise}
  15532. */
  15533. }, {
  15534. key: "requestPasswordReset",
  15535. value: function (email /*: string*/, options /*:: ?: RequestOptions*/) {
  15536. options = options || {};
  15537. var requestOptions = {};
  15538. if (options.hasOwnProperty('useMasterKey')) {
  15539. requestOptions.useMasterKey = options.useMasterKey;
  15540. }
  15541. var controller = _CoreManager.default.getUserController();
  15542. return controller.requestPasswordReset(email, requestOptions);
  15543. }
  15544. /**
  15545. * Request an email verification.
  15546. *
  15547. * @param {string} email The email address associated with the user that
  15548. * needs to verify their email.
  15549. * @param {object} options
  15550. * @static
  15551. * @returns {Promise}
  15552. */
  15553. }, {
  15554. key: "requestEmailVerification",
  15555. value: function (email /*: string*/, options /*:: ?: RequestOptions*/) {
  15556. options = options || {};
  15557. var requestOptions = {};
  15558. if (options.hasOwnProperty('useMasterKey')) {
  15559. requestOptions.useMasterKey = options.useMasterKey;
  15560. }
  15561. var controller = _CoreManager.default.getUserController();
  15562. return controller.requestEmailVerification(email, requestOptions);
  15563. }
  15564. /**
  15565. * Verify whether a given password is the password of the current user.
  15566. *
  15567. * @param {string} username A username to be used for identificaiton
  15568. * @param {string} password A password to be verified
  15569. * @param {object} options
  15570. * @static
  15571. * @returns {Promise} A promise that is fulfilled with a user
  15572. * when the password is correct.
  15573. */
  15574. }, {
  15575. key: "verifyPassword",
  15576. value: function (username /*: string*/, password /*: string*/, options /*:: ?: RequestOptions*/) {
  15577. if (typeof username !== 'string') {
  15578. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  15579. }
  15580. if (typeof password !== 'string') {
  15581. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  15582. }
  15583. options = options || {};
  15584. var verificationOption = {};
  15585. if (options.hasOwnProperty('useMasterKey')) {
  15586. verificationOption.useMasterKey = options.useMasterKey;
  15587. }
  15588. var controller = _CoreManager.default.getUserController();
  15589. return controller.verifyPassword(username, password, verificationOption);
  15590. }
  15591. /**
  15592. * Allow someone to define a custom User class without className
  15593. * being rewritten to _User. The default behavior is to rewrite
  15594. * User to _User for legacy reasons. This allows developers to
  15595. * override that behavior.
  15596. *
  15597. * @param {boolean} isAllowed Whether or not to allow custom User class
  15598. * @static
  15599. */
  15600. }, {
  15601. key: "allowCustomUserClass",
  15602. value: function (isAllowed /*: boolean*/) {
  15603. _CoreManager.default.set('PERFORM_USER_REWRITE', !isAllowed);
  15604. }
  15605. /**
  15606. * Allows a legacy application to start using revocable sessions. If the
  15607. * current session token is not revocable, a request will be made for a new,
  15608. * revocable session.
  15609. * It is not necessary to call this method from cloud code unless you are
  15610. * handling user signup or login from the server side. In a cloud code call,
  15611. * this function will not attempt to upgrade the current token.
  15612. *
  15613. * @param {object} options
  15614. * @static
  15615. * @returns {Promise} A promise that is resolved when the process has
  15616. * completed. If a replacement session token is requested, the promise
  15617. * will be resolved after a new token has been fetched.
  15618. */
  15619. }, {
  15620. key: "enableRevocableSession",
  15621. value: function (options /*:: ?: RequestOptions*/) {
  15622. options = options || {};
  15623. _CoreManager.default.set('FORCE_REVOCABLE_SESSION', true);
  15624. if (canUseCurrentUser) {
  15625. var current = ParseUser.current();
  15626. if (current) {
  15627. return current._upgradeToRevocableSession(options);
  15628. }
  15629. }
  15630. return _promise.default.resolve();
  15631. }
  15632. /**
  15633. * Enables the use of become or the current user in a server
  15634. * environment. These features are disabled by default, since they depend on
  15635. * global objects that are not memory-safe for most servers.
  15636. *
  15637. * @static
  15638. */
  15639. }, {
  15640. key: "enableUnsafeCurrentUser",
  15641. value: function () {
  15642. canUseCurrentUser = true;
  15643. }
  15644. /**
  15645. * Disables the use of become or the current user in any environment.
  15646. * These features are disabled on servers by default, since they depend on
  15647. * global objects that are not memory-safe for most servers.
  15648. *
  15649. * @static
  15650. */
  15651. }, {
  15652. key: "disableUnsafeCurrentUser",
  15653. value: function () {
  15654. canUseCurrentUser = false;
  15655. }
  15656. /**
  15657. * When registering users with {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} a basic auth provider
  15658. * is automatically created for you.
  15659. *
  15660. * For advanced authentication, you can register an Auth provider to
  15661. * implement custom authentication, deauthentication.
  15662. *
  15663. * @param provider
  15664. * @see {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  15665. * @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module}
  15666. * @static
  15667. */
  15668. }, {
  15669. key: "_registerAuthenticationProvider",
  15670. value: function (provider /*: any*/) {
  15671. authProviders[provider.getAuthType()] = provider;
  15672. // Synchronize the current user with the auth provider.
  15673. ParseUser.currentAsync().then(function (current) {
  15674. if (current) {
  15675. current._synchronizeAuthData(provider.getAuthType());
  15676. }
  15677. });
  15678. }
  15679. /**
  15680. * @param provider
  15681. * @param options
  15682. * @param saveOpts
  15683. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith}
  15684. * @static
  15685. * @returns {Promise}
  15686. */
  15687. }, {
  15688. key: "_logInWith",
  15689. value: function (provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*:: ?: FullOptions*/) {
  15690. var user = new this();
  15691. return user.linkWith(provider, options, saveOpts);
  15692. }
  15693. }, {
  15694. key: "_clearCache",
  15695. value: function () {
  15696. currentUserCache = null;
  15697. currentUserCacheMatchesDisk = false;
  15698. }
  15699. }, {
  15700. key: "_setCurrentUserCache",
  15701. value: function (user /*: ParseUser*/) {
  15702. currentUserCache = user;
  15703. }
  15704. }]);
  15705. return ParseUser;
  15706. }(_ParseObject2.default);
  15707. _ParseObject2.default.registerSubclass('_User', ParseUser);
  15708. var DefaultController = {
  15709. updateUserOnDisk: function (user) {
  15710. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  15711. var json = user.toJSON();
  15712. delete json.password;
  15713. json.className = '_User';
  15714. var userData = (0, _stringify.default)(json);
  15715. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  15716. var crypto = _CoreManager.default.getCryptoController();
  15717. userData = crypto.encrypt(json, _CoreManager.default.get('ENCRYPTED_KEY'));
  15718. }
  15719. return _Storage.default.setItemAsync(path, userData).then(function () {
  15720. return user;
  15721. });
  15722. },
  15723. removeUserFromDisk: function () {
  15724. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  15725. currentUserCacheMatchesDisk = true;
  15726. currentUserCache = null;
  15727. return _Storage.default.removeItemAsync(path);
  15728. },
  15729. setCurrentUser: function (user) {
  15730. currentUserCache = user;
  15731. user._cleanupAuthData();
  15732. user._synchronizeAllAuthData();
  15733. return DefaultController.updateUserOnDisk(user);
  15734. },
  15735. currentUser: function () /*: ?ParseUser*/{
  15736. if (currentUserCache) {
  15737. return currentUserCache;
  15738. }
  15739. if (currentUserCacheMatchesDisk) {
  15740. return null;
  15741. }
  15742. if (_Storage.default.async()) {
  15743. throw new Error('Cannot call currentUser() when using a platform with an async ' + 'storage system. Call currentUserAsync() instead.');
  15744. }
  15745. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  15746. var userData = _Storage.default.getItem(path);
  15747. currentUserCacheMatchesDisk = true;
  15748. if (!userData) {
  15749. currentUserCache = null;
  15750. return null;
  15751. }
  15752. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  15753. var crypto = _CoreManager.default.getCryptoController();
  15754. userData = crypto.decrypt(userData, _CoreManager.default.get('ENCRYPTED_KEY'));
  15755. }
  15756. userData = JSON.parse(userData);
  15757. if (!userData.className) {
  15758. userData.className = '_User';
  15759. }
  15760. if (userData._id) {
  15761. if (userData.objectId !== userData._id) {
  15762. userData.objectId = userData._id;
  15763. }
  15764. delete userData._id;
  15765. }
  15766. if (userData._sessionToken) {
  15767. userData.sessionToken = userData._sessionToken;
  15768. delete userData._sessionToken;
  15769. }
  15770. var current = _ParseObject2.default.fromJSON(userData);
  15771. currentUserCache = current;
  15772. current._synchronizeAllAuthData();
  15773. return current;
  15774. },
  15775. currentUserAsync: function () /*: Promise<?ParseUser>*/{
  15776. if (currentUserCache) {
  15777. return _promise.default.resolve(currentUserCache);
  15778. }
  15779. if (currentUserCacheMatchesDisk) {
  15780. return _promise.default.resolve(null);
  15781. }
  15782. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  15783. return _Storage.default.getItemAsync(path).then(function (userData) {
  15784. currentUserCacheMatchesDisk = true;
  15785. if (!userData) {
  15786. currentUserCache = null;
  15787. return _promise.default.resolve(null);
  15788. }
  15789. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  15790. var crypto = _CoreManager.default.getCryptoController();
  15791. userData = crypto.decrypt(userData.toString(), _CoreManager.default.get('ENCRYPTED_KEY'));
  15792. }
  15793. userData = JSON.parse(userData);
  15794. if (!userData.className) {
  15795. userData.className = '_User';
  15796. }
  15797. if (userData._id) {
  15798. if (userData.objectId !== userData._id) {
  15799. userData.objectId = userData._id;
  15800. }
  15801. delete userData._id;
  15802. }
  15803. if (userData._sessionToken) {
  15804. userData.sessionToken = userData._sessionToken;
  15805. delete userData._sessionToken;
  15806. }
  15807. var current = _ParseObject2.default.fromJSON(userData);
  15808. currentUserCache = current;
  15809. current._synchronizeAllAuthData();
  15810. return _promise.default.resolve(current);
  15811. });
  15812. },
  15813. signUp: function (user /*: ParseUser*/, attrs /*: AttributeMap*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
  15814. var username = attrs && attrs.username || user.get('username');
  15815. var password = attrs && attrs.password || user.get('password');
  15816. if (!username || !username.length) {
  15817. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty username.'));
  15818. }
  15819. if (!password || !password.length) {
  15820. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty password.'));
  15821. }
  15822. return user.save(attrs, options).then(function () {
  15823. // Clear the password field
  15824. user._finishFetch({
  15825. password: undefined
  15826. });
  15827. if (canUseCurrentUser) {
  15828. return DefaultController.setCurrentUser(user);
  15829. }
  15830. return user;
  15831. });
  15832. },
  15833. logIn: function (user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
  15834. var RESTController = _CoreManager.default.getRESTController();
  15835. var stateController = _CoreManager.default.getObjectStateController();
  15836. var auth = {
  15837. username: user.get('username'),
  15838. password: user.get('password')
  15839. };
  15840. return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(function (response) {
  15841. user._migrateId(response.objectId);
  15842. user._setExisted(true);
  15843. stateController.setPendingOp(user._getStateIdentifier(), 'username', undefined);
  15844. stateController.setPendingOp(user._getStateIdentifier(), 'password', undefined);
  15845. response.password = undefined;
  15846. user._finishFetch(response);
  15847. if (!canUseCurrentUser) {
  15848. // We can't set the current user, so just return the one we logged in
  15849. return _promise.default.resolve(user);
  15850. }
  15851. return DefaultController.setCurrentUser(user);
  15852. });
  15853. },
  15854. loginAs: function (user /*: ParseUser*/, userId /*: string*/) /*: Promise<ParseUser>*/{
  15855. var RESTController = _CoreManager.default.getRESTController();
  15856. return RESTController.request('POST', 'loginAs', {
  15857. userId: userId
  15858. }, {
  15859. useMasterKey: true
  15860. }).then(function (response) {
  15861. user._finishFetch(response);
  15862. user._setExisted(true);
  15863. if (!canUseCurrentUser) {
  15864. return _promise.default.resolve(user);
  15865. }
  15866. return DefaultController.setCurrentUser(user);
  15867. });
  15868. },
  15869. become: function (user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
  15870. var RESTController = _CoreManager.default.getRESTController();
  15871. return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
  15872. user._finishFetch(response);
  15873. user._setExisted(true);
  15874. return DefaultController.setCurrentUser(user);
  15875. });
  15876. },
  15877. hydrate: function (user /*: ParseUser*/, userJSON /*: AttributeMap*/) /*: Promise<ParseUser>*/{
  15878. user._finishFetch(userJSON);
  15879. user._setExisted(true);
  15880. if (userJSON.sessionToken && canUseCurrentUser) {
  15881. return DefaultController.setCurrentUser(user);
  15882. } else {
  15883. return _promise.default.resolve(user);
  15884. }
  15885. },
  15886. me: function (user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
  15887. var RESTController = _CoreManager.default.getRESTController();
  15888. return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
  15889. user._finishFetch(response);
  15890. user._setExisted(true);
  15891. return user;
  15892. });
  15893. },
  15894. logOut: function (options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
  15895. var RESTController = _CoreManager.default.getRESTController();
  15896. if (options.sessionToken) {
  15897. return RESTController.request('POST', 'logout', {}, options);
  15898. }
  15899. return DefaultController.currentUserAsync().then(function (currentUser) {
  15900. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  15901. var promise = _Storage.default.removeItemAsync(path);
  15902. if (currentUser !== null) {
  15903. var currentSession = currentUser.getSessionToken();
  15904. if (currentSession && (0, _isRevocableSession.default)(currentSession)) {
  15905. promise = promise.then(function () {
  15906. return RESTController.request('POST', 'logout', {}, {
  15907. sessionToken: currentSession
  15908. });
  15909. });
  15910. }
  15911. currentUser._logOutWithAll();
  15912. currentUser._finishFetch({
  15913. sessionToken: undefined
  15914. });
  15915. }
  15916. currentUserCacheMatchesDisk = true;
  15917. currentUserCache = null;
  15918. return promise;
  15919. });
  15920. },
  15921. requestPasswordReset: function (email /*: string*/, options /*: RequestOptions*/) {
  15922. var RESTController = _CoreManager.default.getRESTController();
  15923. return RESTController.request('POST', 'requestPasswordReset', {
  15924. email: email
  15925. }, options);
  15926. },
  15927. upgradeToRevocableSession: function (user /*: ParseUser*/, options /*: RequestOptions*/) {
  15928. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  15929. var token, RESTController, result, session, current;
  15930. return _regenerator.default.wrap(function (_context6) {
  15931. while (1) switch (_context6.prev = _context6.next) {
  15932. case 0:
  15933. token = user.getSessionToken();
  15934. if (token) {
  15935. _context6.next = 3;
  15936. break;
  15937. }
  15938. return _context6.abrupt("return", _promise.default.reject(new _ParseError.default(_ParseError.default.SESSION_MISSING, 'Cannot upgrade a user with no session token')));
  15939. case 3:
  15940. options.sessionToken = token;
  15941. RESTController = _CoreManager.default.getRESTController();
  15942. _context6.next = 7;
  15943. return RESTController.request('POST', 'upgradeToRevocableSession', {}, options);
  15944. case 7:
  15945. result = _context6.sent;
  15946. session = new _ParseSession.default();
  15947. session._finishFetch(result);
  15948. user._finishFetch({
  15949. sessionToken: session.getSessionToken()
  15950. });
  15951. _context6.next = 13;
  15952. return user.isCurrentAsync();
  15953. case 13:
  15954. current = _context6.sent;
  15955. if (!current) {
  15956. _context6.next = 16;
  15957. break;
  15958. }
  15959. return _context6.abrupt("return", DefaultController.setCurrentUser(user));
  15960. case 16:
  15961. return _context6.abrupt("return", _promise.default.resolve(user));
  15962. case 17:
  15963. case "end":
  15964. return _context6.stop();
  15965. }
  15966. }, _callee6);
  15967. }))();
  15968. },
  15969. linkWith: function (user /*: ParseUser*/, authData /*: AuthData*/, options /*: FullOptions*/) {
  15970. return user.save({
  15971. authData: authData
  15972. }, options).then(function () {
  15973. if (canUseCurrentUser) {
  15974. return DefaultController.setCurrentUser(user);
  15975. }
  15976. return user;
  15977. });
  15978. },
  15979. verifyPassword: function (username /*: string*/, password /*: string*/, options /*: RequestOptions*/) {
  15980. var RESTController = _CoreManager.default.getRESTController();
  15981. return RESTController.request('GET', 'verifyPassword', {
  15982. username: username,
  15983. password: password
  15984. }, options);
  15985. },
  15986. requestEmailVerification: function (email /*: string*/, options /*: RequestOptions*/) {
  15987. var RESTController = _CoreManager.default.getRESTController();
  15988. return RESTController.request('POST', 'verificationEmailRequest', {
  15989. email: email
  15990. }, options);
  15991. }
  15992. };
  15993. _CoreManager.default.setUserController(DefaultController);
  15994. var _default = ParseUser;
  15995. exports.default = _default;
  15996. },{"./CoreManager":4,"./ParseError":22,"./ParseObject":27,"./ParseSession":34,"./Storage":39,"./isRevocableSession":49,"@babel/runtime-corejs3/core-js-stable/json/stringify":75,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/core-js-stable/reflect/construct":91,"@babel/runtime-corejs3/helpers/asyncToGenerator":121,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/get":126,"@babel/runtime-corejs3/helpers/getPrototypeOf":127,"@babel/runtime-corejs3/helpers/inherits":128,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":136,"@babel/runtime-corejs3/helpers/typeof":144,"@babel/runtime-corejs3/regenerator":147}],36:[function(_dereq_,module,exports){
  15997. "use strict";
  15998. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15999. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16000. _Object$defineProperty(exports, "__esModule", {
  16001. value: true
  16002. });
  16003. exports.getPushStatus = getPushStatus;
  16004. exports.send = send;
  16005. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  16006. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  16007. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  16008. /**
  16009. * @flow
  16010. */
  16011. /*:: import type { WhereClause } from './ParseQuery';*/
  16012. /*:: import type { FullOptions } from './RESTController';*/
  16013. /*:: export type PushData = {
  16014. where?: WhereClause | ParseQuery,
  16015. push_time?: Date | string,
  16016. expiration_time?: Date | string,
  16017. expiration_interval?: number,
  16018. };*/
  16019. /**
  16020. * Contains functions to deal with Push in Parse.
  16021. *
  16022. * @class Parse.Push
  16023. * @static
  16024. * @hideconstructor
  16025. */
  16026. /**
  16027. * Sends a push notification.
  16028. * **Available in Cloud Code only.**
  16029. *
  16030. * See {@link https://docs.parseplatform.org/js/guide/#push-notifications Push Notification Guide}
  16031. *
  16032. * @function send
  16033. * @name Parse.Push.send
  16034. * @param {object} data - The data of the push notification. Valid fields
  16035. * are:
  16036. * <ol>
  16037. * <li>channels - An Array of channels to push to.</li>
  16038. * <li>push_time - A Date object for when to send the push.</li>
  16039. * <li>expiration_time - A Date object for when to expire
  16040. * the push.</li>
  16041. * <li>expiration_interval - The seconds from now to expire the push.</li>
  16042. * <li>where - A Parse.Query over Parse.Installation that is used to match
  16043. * a set of installations to push to.</li>
  16044. * <li>data - The data to send as part of the push.</li>
  16045. * <ol>
  16046. * @param {object} options Valid options
  16047. * are:<ul>
  16048. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  16049. * be used for this request.
  16050. * </ul>
  16051. * @returns {Promise} A promise that is fulfilled when the push request
  16052. * completes.
  16053. */
  16054. function send(data /*: PushData*/) /*: Promise*/{
  16055. var options /*:: ?: FullOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  16056. if (data.where && data.where instanceof _ParseQuery.default) {
  16057. data.where = data.where.toJSON().where;
  16058. }
  16059. if (data.push_time && (0, _typeof2.default)(data.push_time) === 'object') {
  16060. data.push_time = data.push_time.toJSON();
  16061. }
  16062. if (data.expiration_time && (0, _typeof2.default)(data.expiration_time) === 'object') {
  16063. data.expiration_time = data.expiration_time.toJSON();
  16064. }
  16065. if (data.expiration_time && data.expiration_interval) {
  16066. throw new Error('expiration_time and expiration_interval cannot both be set.');
  16067. }
  16068. var pushOptions = {
  16069. useMasterKey: true
  16070. };
  16071. if (options.hasOwnProperty('useMasterKey')) {
  16072. pushOptions.useMasterKey = options.useMasterKey;
  16073. }
  16074. return _CoreManager.default.getPushController().send(data, pushOptions);
  16075. }
  16076. /**
  16077. * Gets push status by Id
  16078. *
  16079. * @function getPushStatus
  16080. * @name Parse.Push.getPushStatus
  16081. * @param {string} pushStatusId The Id of Push Status.
  16082. * @param {object} options Valid options
  16083. * are:<ul>
  16084. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  16085. * be used for this request.
  16086. * </ul>
  16087. * @returns {Parse.Object} Status of Push.
  16088. */
  16089. function getPushStatus(pushStatusId /*: string*/) /*: Promise<string>*/{
  16090. var options /*:: ?: FullOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  16091. var pushOptions = {
  16092. useMasterKey: true
  16093. };
  16094. if (options.hasOwnProperty('useMasterKey')) {
  16095. pushOptions.useMasterKey = options.useMasterKey;
  16096. }
  16097. var query = new _ParseQuery.default('_PushStatus');
  16098. return query.get(pushStatusId, pushOptions);
  16099. }
  16100. var DefaultController = {
  16101. send: function (data /*: PushData*/, options /*:: ?: FullOptions*/) {
  16102. return _CoreManager.default.getRESTController().request('POST', 'push', data, options);
  16103. }
  16104. };
  16105. _CoreManager.default.setPushController(DefaultController);
  16106. },{"./CoreManager":4,"./ParseQuery":30,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],37:[function(_dereq_,module,exports){
  16107. (function (process){(function (){
  16108. "use strict";
  16109. var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  16110. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  16111. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  16112. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  16113. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  16114. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  16115. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  16116. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  16117. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16118. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  16119. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  16120. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  16121. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  16122. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  16123. var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
  16124. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  16125. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  16126. var _promiseUtils = _dereq_("./promiseUtils");
  16127. function ownKeys(object, enumerableOnly) {
  16128. var keys = _Object$keys(object);
  16129. if (_Object$getOwnPropertySymbols) {
  16130. var symbols = _Object$getOwnPropertySymbols(object);
  16131. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  16132. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  16133. })), keys.push.apply(keys, symbols);
  16134. }
  16135. return keys;
  16136. }
  16137. function _objectSpread(target) {
  16138. for (var i = 1; i < arguments.length; i++) {
  16139. var _context4, _context5;
  16140. var source = null != arguments[i] ? arguments[i] : {};
  16141. i % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(source), !0)).call(_context4, function (key) {
  16142. (0, _defineProperty2.default)(target, key, source[key]);
  16143. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context5 = ownKeys(Object(source))).call(_context5, function (key) {
  16144. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  16145. });
  16146. }
  16147. return target;
  16148. }
  16149. /**
  16150. * @flow
  16151. */
  16152. /* global XMLHttpRequest, XDomainRequest */
  16153. var uuidv4 = _dereq_('./uuid');
  16154. /*:: export type RequestOptions = {
  16155. useMasterKey?: boolean,
  16156. sessionToken?: string,
  16157. installationId?: string,
  16158. returnStatus?: boolean,
  16159. batchSize?: number,
  16160. include?: any,
  16161. progress?: any,
  16162. context?: any,
  16163. usePost?: boolean,
  16164. };*/
  16165. /*:: export type FullOptions = {
  16166. success?: any,
  16167. error?: any,
  16168. useMasterKey?: boolean,
  16169. sessionToken?: string,
  16170. installationId?: string,
  16171. progress?: any,
  16172. usePost?: boolean,
  16173. };*/
  16174. var XHR = null;
  16175. if (typeof XMLHttpRequest !== 'undefined') {
  16176. XHR = XMLHttpRequest;
  16177. }
  16178. var useXDomainRequest = false;
  16179. if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
  16180. useXDomainRequest = true;
  16181. }
  16182. function ajaxIE9(method /*: string*/, url /*: string*/, data /*: any*/, headers /*:: ?: any*/, options /*:: ?: FullOptions*/) {
  16183. return new _promise.default(function (resolve, reject) {
  16184. var xdr = new XDomainRequest();
  16185. xdr.onload = function () {
  16186. var response;
  16187. try {
  16188. response = JSON.parse(xdr.responseText);
  16189. } catch (e) {
  16190. reject(e);
  16191. }
  16192. if (response) {
  16193. resolve({
  16194. response: response
  16195. });
  16196. }
  16197. };
  16198. xdr.onerror = xdr.ontimeout = function () {
  16199. // Let's fake a real error message.
  16200. var fakeResponse = {
  16201. responseText: (0, _stringify.default)({
  16202. code: _ParseError.default.X_DOMAIN_REQUEST,
  16203. error: "IE's XDomainRequest does not supply error info."
  16204. })
  16205. };
  16206. reject(fakeResponse);
  16207. };
  16208. xdr.onprogress = function () {
  16209. if (options && typeof options.progress === 'function') {
  16210. options.progress(xdr.responseText);
  16211. }
  16212. };
  16213. xdr.open(method, url);
  16214. xdr.send(data);
  16215. if (options && typeof options.requestTask === 'function') {
  16216. options.requestTask(xdr);
  16217. }
  16218. });
  16219. }
  16220. var RESTController = {
  16221. ajax: function (method /*: string*/, url /*: string*/, data /*: any*/, headers /*:: ?: any*/, options /*:: ?: FullOptions*/) {
  16222. var _context;
  16223. if (useXDomainRequest) {
  16224. return ajaxIE9(method, url, data, headers, options);
  16225. }
  16226. var promise = (0, _promiseUtils.resolvingPromise)();
  16227. var isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && (0, _includes.default)(_context = ['POST', 'PUT']).call(_context, method);
  16228. var requestId = isIdempotent ? uuidv4() : '';
  16229. var attempts = 0;
  16230. (function dispatch() {
  16231. if (XHR == null) {
  16232. throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
  16233. }
  16234. var handled = false;
  16235. var xhr = new XHR();
  16236. xhr.onreadystatechange = function () {
  16237. if (xhr.readyState !== 4 || handled || xhr._aborted) {
  16238. return;
  16239. }
  16240. handled = true;
  16241. if (xhr.status >= 200 && xhr.status < 300) {
  16242. var response;
  16243. try {
  16244. response = JSON.parse(xhr.responseText);
  16245. if (typeof xhr.getResponseHeader === 'function') {
  16246. var _context2, _context3;
  16247. if ((0, _includes.default)(_context2 = xhr.getAllResponseHeaders() || '').call(_context2, 'x-parse-job-status-id: ')) {
  16248. response = xhr.getResponseHeader('x-parse-job-status-id');
  16249. }
  16250. if ((0, _includes.default)(_context3 = xhr.getAllResponseHeaders() || '').call(_context3, 'x-parse-push-status-id: ')) {
  16251. response = xhr.getResponseHeader('x-parse-push-status-id');
  16252. }
  16253. }
  16254. } catch (e) {
  16255. promise.reject(e.toString());
  16256. }
  16257. if (response) {
  16258. promise.resolve({
  16259. response: response,
  16260. status: xhr.status,
  16261. xhr: xhr
  16262. });
  16263. }
  16264. } else if (xhr.status >= 500 || xhr.status === 0) {
  16265. // retry on 5XX or node-xmlhttprequest error
  16266. if (++attempts < _CoreManager.default.get('REQUEST_ATTEMPT_LIMIT')) {
  16267. // Exponentially-growing random delay
  16268. var delay = Math.round(Math.random() * 125 * Math.pow(2, attempts));
  16269. (0, _setTimeout2.default)(dispatch, delay);
  16270. } else if (xhr.status === 0) {
  16271. promise.reject('Unable to connect to the Parse API');
  16272. } else {
  16273. // After the retry limit is reached, fail
  16274. promise.reject(xhr);
  16275. }
  16276. } else {
  16277. promise.reject(xhr);
  16278. }
  16279. };
  16280. headers = headers || {};
  16281. if (typeof headers['Content-Type'] !== 'string') {
  16282. headers['Content-Type'] = 'text/plain'; // Avoid pre-flight
  16283. }
  16284. if (_CoreManager.default.get('IS_NODE')) {
  16285. headers['User-Agent'] = 'Parse/' + _CoreManager.default.get('VERSION') + ' (NodeJS ' + process.versions.node + ')';
  16286. }
  16287. if (isIdempotent) {
  16288. headers['X-Parse-Request-Id'] = requestId;
  16289. }
  16290. if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
  16291. headers['Authorization'] = _CoreManager.default.get('SERVER_AUTH_TYPE') + ' ' + _CoreManager.default.get('SERVER_AUTH_TOKEN');
  16292. }
  16293. var customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
  16294. for (var key in customHeaders) {
  16295. headers[key] = customHeaders[key];
  16296. }
  16297. if (options && typeof options.progress === 'function') {
  16298. var handleProgress = function handleProgress(type, event) {
  16299. if (event.lengthComputable) {
  16300. options.progress(event.loaded / event.total, event.loaded, event.total, {
  16301. type: type
  16302. });
  16303. } else {
  16304. options.progress(null, null, null, {
  16305. type: type
  16306. });
  16307. }
  16308. };
  16309. xhr.onprogress = function (event) {
  16310. handleProgress('download', event);
  16311. };
  16312. if (xhr.upload) {
  16313. xhr.upload.onprogress = function (event) {
  16314. handleProgress('upload', event);
  16315. };
  16316. }
  16317. }
  16318. xhr.open(method, url, true);
  16319. for (var h in headers) {
  16320. xhr.setRequestHeader(h, headers[h]);
  16321. }
  16322. xhr.onabort = function () {
  16323. promise.resolve({
  16324. response: {
  16325. results: []
  16326. },
  16327. status: 0,
  16328. xhr: xhr
  16329. });
  16330. };
  16331. xhr.send(data);
  16332. if (options && typeof options.requestTask === 'function') {
  16333. options.requestTask(xhr);
  16334. }
  16335. })();
  16336. return promise;
  16337. },
  16338. request: function request(method /*: string*/, path /*: string*/, data /*: mixed*/, options /*:: ?: RequestOptions*/) {
  16339. options = options || {};
  16340. var url = _CoreManager.default.get('SERVER_URL');
  16341. if (url[url.length - 1] !== '/') {
  16342. url += '/';
  16343. }
  16344. url += path;
  16345. var payload = {};
  16346. if (data && (0, _typeof2.default)(data) === 'object') {
  16347. for (var k in data) {
  16348. payload[k] = data[k];
  16349. }
  16350. }
  16351. // Add context
  16352. var context = options.context;
  16353. if (context !== undefined) {
  16354. payload._context = context;
  16355. }
  16356. if (method !== 'POST') {
  16357. payload._method = method;
  16358. method = 'POST';
  16359. }
  16360. payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
  16361. var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  16362. if (jsKey) {
  16363. payload._JavaScriptKey = jsKey;
  16364. }
  16365. payload._ClientVersion = _CoreManager.default.get('VERSION');
  16366. var useMasterKey = options.useMasterKey;
  16367. if (typeof useMasterKey === 'undefined') {
  16368. useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
  16369. }
  16370. if (useMasterKey) {
  16371. if (_CoreManager.default.get('MASTER_KEY')) {
  16372. delete payload._JavaScriptKey;
  16373. payload._MasterKey = _CoreManager.default.get('MASTER_KEY');
  16374. } else {
  16375. throw new Error('Cannot use the Master Key, it has not been provided.');
  16376. }
  16377. }
  16378. if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
  16379. payload._RevocableSession = '1';
  16380. }
  16381. var installationId = options.installationId;
  16382. var installationIdPromise;
  16383. if (installationId && typeof installationId === 'string') {
  16384. installationIdPromise = _promise.default.resolve(installationId);
  16385. } else {
  16386. var installationController = _CoreManager.default.getInstallationController();
  16387. installationIdPromise = installationController.currentInstallationId();
  16388. }
  16389. return installationIdPromise.then(function (iid) {
  16390. payload._InstallationId = iid;
  16391. var userController = _CoreManager.default.getUserController();
  16392. if (options && typeof options.sessionToken === 'string') {
  16393. return _promise.default.resolve(options.sessionToken);
  16394. } else if (userController) {
  16395. return userController.currentUserAsync().then(function (user) {
  16396. if (user) {
  16397. return _promise.default.resolve(user.getSessionToken());
  16398. }
  16399. return _promise.default.resolve(null);
  16400. });
  16401. }
  16402. return _promise.default.resolve(null);
  16403. }).then(function (token) {
  16404. if (token) {
  16405. payload._SessionToken = token;
  16406. }
  16407. var payloadString = (0, _stringify.default)(payload);
  16408. return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
  16409. var response = _ref.response,
  16410. status = _ref.status;
  16411. if (options.returnStatus) {
  16412. return _objectSpread(_objectSpread({}, response), {}, {
  16413. _status: status
  16414. });
  16415. } else {
  16416. return response;
  16417. }
  16418. });
  16419. }).catch(RESTController.handleError);
  16420. },
  16421. handleError: function handleError(response) {
  16422. // Transform the error into an instance of ParseError by trying to parse
  16423. // the error string as JSON
  16424. var error;
  16425. if (response && response.responseText) {
  16426. try {
  16427. var errorJSON = JSON.parse(response.responseText);
  16428. error = new _ParseError.default(errorJSON.code, errorJSON.error);
  16429. } catch (e) {
  16430. // If we fail to parse the error text, that's okay.
  16431. error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Received an error with invalid JSON from Parse: ' + response.responseText);
  16432. }
  16433. } else {
  16434. var message = response.message ? response.message : response;
  16435. error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, 'XMLHttpRequest failed: ' + (0, _stringify.default)(message));
  16436. }
  16437. return _promise.default.reject(error);
  16438. },
  16439. _setXHR: function _setXHR(xhr /*: any*/) {
  16440. XHR = xhr;
  16441. },
  16442. _getXHR: function _getXHR() {
  16443. return XHR;
  16444. }
  16445. };
  16446. module.exports = RESTController;
  16447. }).call(this)}).call(this,_dereq_('_process'))
  16448. },{"./CoreManager":4,"./ParseError":22,"./promiseUtils":51,"./uuid":54,"@babel/runtime-corejs3/core-js-stable/instance/filter":61,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":65,"@babel/runtime-corejs3/core-js-stable/json/stringify":75,"@babel/runtime-corejs3/core-js-stable/object/define-properties":80,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":84,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":86,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/core-js-stable/set-timeout":93,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144,"_process":148}],38:[function(_dereq_,module,exports){
  16449. "use strict";
  16450. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  16451. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  16452. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  16453. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  16454. _Object$defineProperty(exports, "__esModule", {
  16455. value: true
  16456. });
  16457. exports.clearAllState = clearAllState;
  16458. exports.commitServerChanges = commitServerChanges;
  16459. exports.duplicateState = duplicateState;
  16460. exports.enqueueTask = enqueueTask;
  16461. exports.estimateAttribute = estimateAttribute;
  16462. exports.estimateAttributes = estimateAttributes;
  16463. exports.getObjectCache = getObjectCache;
  16464. exports.getPendingOps = getPendingOps;
  16465. exports.getServerData = getServerData;
  16466. exports.getState = getState;
  16467. exports.initializeState = initializeState;
  16468. exports.mergeFirstPendingState = mergeFirstPendingState;
  16469. exports.popPendingState = popPendingState;
  16470. exports.pushPendingState = pushPendingState;
  16471. exports.removeState = removeState;
  16472. exports.setPendingOp = setPendingOp;
  16473. exports.setServerData = setServerData;
  16474. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  16475. function _getRequireWildcardCache(nodeInterop) {
  16476. if (typeof _WeakMap !== "function") return null;
  16477. var cacheBabelInterop = new _WeakMap();
  16478. var cacheNodeInterop = new _WeakMap();
  16479. return (_getRequireWildcardCache = function (nodeInterop) {
  16480. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  16481. })(nodeInterop);
  16482. }
  16483. function _interopRequireWildcard(obj, nodeInterop) {
  16484. if (!nodeInterop && obj && obj.__esModule) {
  16485. return obj;
  16486. }
  16487. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  16488. return {
  16489. default: obj
  16490. };
  16491. }
  16492. var cache = _getRequireWildcardCache(nodeInterop);
  16493. if (cache && cache.has(obj)) {
  16494. return cache.get(obj);
  16495. }
  16496. var newObj = {};
  16497. for (var key in obj) {
  16498. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  16499. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  16500. if (desc && (desc.get || desc.set)) {
  16501. _Object$defineProperty(newObj, key, desc);
  16502. } else {
  16503. newObj[key] = obj[key];
  16504. }
  16505. }
  16506. }
  16507. newObj.default = obj;
  16508. if (cache) {
  16509. cache.set(obj, newObj);
  16510. }
  16511. return newObj;
  16512. }
  16513. /**
  16514. * @flow
  16515. */
  16516. /*:: import type { Op } from './ParseOp';*/
  16517. /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
  16518. /*:: type ObjectIdentifier = {
  16519. className: string,
  16520. id: string,
  16521. };*/
  16522. var objectState
  16523. /*: {
  16524. [className: string]: {
  16525. [id: string]: State,
  16526. },
  16527. }*/ = {};
  16528. function getState(obj /*: ObjectIdentifier*/) /*: ?State*/{
  16529. var classData = objectState[obj.className];
  16530. if (classData) {
  16531. return classData[obj.id] || null;
  16532. }
  16533. return null;
  16534. }
  16535. function initializeState(obj /*: ObjectIdentifier*/, initial /*:: ?: State*/) /*: State*/{
  16536. var state = getState(obj);
  16537. if (state) {
  16538. return state;
  16539. }
  16540. if (!objectState[obj.className]) {
  16541. objectState[obj.className] = {};
  16542. }
  16543. if (!initial) {
  16544. initial = ObjectStateMutations.defaultState();
  16545. }
  16546. state = objectState[obj.className][obj.id] = initial;
  16547. return state;
  16548. }
  16549. function removeState(obj /*: ObjectIdentifier*/) /*: ?State*/{
  16550. var state = getState(obj);
  16551. if (state === null) {
  16552. return null;
  16553. }
  16554. delete objectState[obj.className][obj.id];
  16555. return state;
  16556. }
  16557. function getServerData(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
  16558. var state = getState(obj);
  16559. if (state) {
  16560. return state.serverData;
  16561. }
  16562. return {};
  16563. }
  16564. function setServerData(obj /*: ObjectIdentifier*/, attributes /*: AttributeMap*/) {
  16565. var serverData = initializeState(obj).serverData;
  16566. ObjectStateMutations.setServerData(serverData, attributes);
  16567. }
  16568. function getPendingOps(obj /*: ObjectIdentifier*/) /*: Array<OpsMap>*/{
  16569. var state = getState(obj);
  16570. if (state) {
  16571. return state.pendingOps;
  16572. }
  16573. return [{}];
  16574. }
  16575. function setPendingOp(obj /*: ObjectIdentifier*/, attr /*: string*/, op /*: ?Op*/) {
  16576. var pendingOps = initializeState(obj).pendingOps;
  16577. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  16578. }
  16579. function pushPendingState(obj /*: ObjectIdentifier*/) {
  16580. var pendingOps = initializeState(obj).pendingOps;
  16581. ObjectStateMutations.pushPendingState(pendingOps);
  16582. }
  16583. function popPendingState(obj /*: ObjectIdentifier*/) /*: OpsMap*/{
  16584. var pendingOps = initializeState(obj).pendingOps;
  16585. return ObjectStateMutations.popPendingState(pendingOps);
  16586. }
  16587. function mergeFirstPendingState(obj /*: ObjectIdentifier*/) {
  16588. var pendingOps = getPendingOps(obj);
  16589. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  16590. }
  16591. function getObjectCache(obj /*: ObjectIdentifier*/) /*: ObjectCache*/{
  16592. var state = getState(obj);
  16593. if (state) {
  16594. return state.objectCache;
  16595. }
  16596. return {};
  16597. }
  16598. function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*: mixed*/{
  16599. var serverData = getServerData(obj);
  16600. var pendingOps = getPendingOps(obj);
  16601. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
  16602. }
  16603. function estimateAttributes(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
  16604. var serverData = getServerData(obj);
  16605. var pendingOps = getPendingOps(obj);
  16606. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
  16607. }
  16608. function commitServerChanges(obj /*: ObjectIdentifier*/, changes /*: AttributeMap*/) {
  16609. var state = initializeState(obj);
  16610. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  16611. }
  16612. function enqueueTask(obj /*: ObjectIdentifier*/, task /*: () => Promise*/) /*: Promise*/{
  16613. var state = initializeState(obj);
  16614. return state.tasks.enqueue(task);
  16615. }
  16616. function clearAllState() {
  16617. objectState = {};
  16618. }
  16619. function duplicateState(source /*: { id: string }*/, dest /*: { id: string }*/) {
  16620. dest.id = source.id;
  16621. }
  16622. },{"./ObjectStateMutations":16,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":84,"@babel/runtime-corejs3/core-js-stable/weak-map":96,"@babel/runtime-corejs3/helpers/typeof":144}],39:[function(_dereq_,module,exports){
  16623. "use strict";
  16624. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16625. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  16626. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  16627. /**
  16628. * @flow
  16629. */
  16630. var Storage = {
  16631. async: function () /*: boolean*/{
  16632. var controller = _CoreManager.default.getStorageController();
  16633. return !!controller.async;
  16634. },
  16635. getItem: function (path /*: string*/) /*: ?string*/{
  16636. var controller = _CoreManager.default.getStorageController();
  16637. if (controller.async === 1) {
  16638. throw new Error('Synchronous storage is not supported by the current storage controller');
  16639. }
  16640. return controller.getItem(path);
  16641. },
  16642. getItemAsync: function (path /*: string*/) /*: Promise<string>*/{
  16643. var controller = _CoreManager.default.getStorageController();
  16644. if (controller.async === 1) {
  16645. return controller.getItemAsync(path);
  16646. }
  16647. return _promise.default.resolve(controller.getItem(path));
  16648. },
  16649. setItem: function (path /*: string*/, value /*: string*/) /*: void*/{
  16650. var controller = _CoreManager.default.getStorageController();
  16651. if (controller.async === 1) {
  16652. throw new Error('Synchronous storage is not supported by the current storage controller');
  16653. }
  16654. return controller.setItem(path, value);
  16655. },
  16656. setItemAsync: function (path /*: string*/, value /*: string*/) /*: Promise<void>*/{
  16657. var controller = _CoreManager.default.getStorageController();
  16658. if (controller.async === 1) {
  16659. return controller.setItemAsync(path, value);
  16660. }
  16661. return _promise.default.resolve(controller.setItem(path, value));
  16662. },
  16663. removeItem: function (path /*: string*/) /*: void*/{
  16664. var controller = _CoreManager.default.getStorageController();
  16665. if (controller.async === 1) {
  16666. throw new Error('Synchronous storage is not supported by the current storage controller');
  16667. }
  16668. return controller.removeItem(path);
  16669. },
  16670. removeItemAsync: function (path /*: string*/) /*: Promise<void>*/{
  16671. var controller = _CoreManager.default.getStorageController();
  16672. if (controller.async === 1) {
  16673. return controller.removeItemAsync(path);
  16674. }
  16675. return _promise.default.resolve(controller.removeItem(path));
  16676. },
  16677. getAllKeys: function () /*: Array<string>*/{
  16678. var controller = _CoreManager.default.getStorageController();
  16679. if (controller.async === 1) {
  16680. throw new Error('Synchronous storage is not supported by the current storage controller');
  16681. }
  16682. return controller.getAllKeys();
  16683. },
  16684. getAllKeysAsync: function () /*: Promise<Array<string>>*/{
  16685. var controller = _CoreManager.default.getStorageController();
  16686. if (controller.async === 1) {
  16687. return controller.getAllKeysAsync();
  16688. }
  16689. return _promise.default.resolve(controller.getAllKeys());
  16690. },
  16691. generatePath: function (path /*: string*/) /*: string*/{
  16692. if (!_CoreManager.default.get('APPLICATION_ID')) {
  16693. throw new Error('You need to call Parse.initialize before using Parse.');
  16694. }
  16695. if (typeof path !== 'string') {
  16696. throw new Error('Tried to get a Storage path that was not a String.');
  16697. }
  16698. if (path[0] === '/') {
  16699. path = path.substr(1);
  16700. }
  16701. return 'Parse/' + _CoreManager.default.get('APPLICATION_ID') + '/' + path;
  16702. },
  16703. _clear: function () {
  16704. var controller = _CoreManager.default.getStorageController();
  16705. if (controller.hasOwnProperty('clear')) {
  16706. controller.clear();
  16707. }
  16708. }
  16709. };
  16710. module.exports = Storage;
  16711. _CoreManager.default.setStorageController(_dereq_('./StorageController.browser'));
  16712. },{"./CoreManager":4,"./StorageController.browser":40,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],40:[function(_dereq_,module,exports){
  16713. "use strict";
  16714. /**
  16715. * @flow
  16716. * @private
  16717. */
  16718. /* global localStorage */
  16719. var StorageController = {
  16720. async: 0,
  16721. getItem: function (path /*: string*/) /*: ?string*/{
  16722. return localStorage.getItem(path);
  16723. },
  16724. setItem: function (path /*: string*/, value /*: string*/) {
  16725. try {
  16726. localStorage.setItem(path, value);
  16727. } catch (e) {
  16728. // Quota exceeded, possibly due to Safari Private Browsing mode
  16729. console.log(e.message);
  16730. }
  16731. },
  16732. removeItem: function (path /*: string*/) {
  16733. localStorage.removeItem(path);
  16734. },
  16735. getAllKeys: function () {
  16736. var keys = [];
  16737. for (var i = 0; i < localStorage.length; i += 1) {
  16738. keys.push(localStorage.key(i));
  16739. }
  16740. return keys;
  16741. },
  16742. clear: function () {
  16743. localStorage.clear();
  16744. }
  16745. };
  16746. module.exports = StorageController;
  16747. },{}],41:[function(_dereq_,module,exports){
  16748. "use strict";
  16749. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16750. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  16751. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  16752. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  16753. var _promiseUtils = _dereq_("./promiseUtils");
  16754. /**
  16755. * @flow
  16756. */
  16757. /*:: type Task = {
  16758. task: () => Promise,
  16759. _completion: Promise,
  16760. };*/
  16761. var TaskQueue = /*#__PURE__*/function () {
  16762. function TaskQueue() {
  16763. (0, _classCallCheck2.default)(this, TaskQueue);
  16764. (0, _defineProperty2.default)(this, "queue", void 0);
  16765. this.queue = [];
  16766. }
  16767. (0, _createClass2.default)(TaskQueue, [{
  16768. key: "enqueue",
  16769. value: function (task /*: () => Promise*/) /*: Promise*/{
  16770. var _this = this;
  16771. var taskComplete = new _promiseUtils.resolvingPromise();
  16772. this.queue.push({
  16773. task: task,
  16774. _completion: taskComplete
  16775. });
  16776. if (this.queue.length === 1) {
  16777. task().then(function () {
  16778. _this._dequeue();
  16779. taskComplete.resolve();
  16780. }, function (error) {
  16781. _this._dequeue();
  16782. taskComplete.reject(error);
  16783. });
  16784. }
  16785. return taskComplete;
  16786. }
  16787. }, {
  16788. key: "_dequeue",
  16789. value: function () {
  16790. var _this2 = this;
  16791. this.queue.shift();
  16792. if (this.queue.length) {
  16793. var next = this.queue[0];
  16794. next.task().then(function () {
  16795. _this2._dequeue();
  16796. next._completion.resolve();
  16797. }, function (error) {
  16798. _this2._dequeue();
  16799. next._completion.reject(error);
  16800. });
  16801. }
  16802. }
  16803. }]);
  16804. return TaskQueue;
  16805. }();
  16806. module.exports = TaskQueue;
  16807. },{"./promiseUtils":51,"@babel/runtime-corejs3/helpers/classCallCheck":122,"@babel/runtime-corejs3/helpers/createClass":124,"@babel/runtime-corejs3/helpers/defineProperty":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],42:[function(_dereq_,module,exports){
  16808. "use strict";
  16809. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  16810. var _WeakMap2 = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  16811. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  16812. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  16813. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16814. _Object$defineProperty(exports, "__esModule", {
  16815. value: true
  16816. });
  16817. exports.clearAllState = clearAllState;
  16818. exports.commitServerChanges = commitServerChanges;
  16819. exports.duplicateState = duplicateState;
  16820. exports.enqueueTask = enqueueTask;
  16821. exports.estimateAttribute = estimateAttribute;
  16822. exports.estimateAttributes = estimateAttributes;
  16823. exports.getObjectCache = getObjectCache;
  16824. exports.getPendingOps = getPendingOps;
  16825. exports.getServerData = getServerData;
  16826. exports.getState = getState;
  16827. exports.initializeState = initializeState;
  16828. exports.mergeFirstPendingState = mergeFirstPendingState;
  16829. exports.popPendingState = popPendingState;
  16830. exports.pushPendingState = pushPendingState;
  16831. exports.removeState = removeState;
  16832. exports.setPendingOp = setPendingOp;
  16833. exports.setServerData = setServerData;
  16834. var _weakMap = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/weak-map"));
  16835. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  16836. var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
  16837. function _getRequireWildcardCache(nodeInterop) {
  16838. if (typeof _WeakMap2 !== "function") return null;
  16839. var cacheBabelInterop = new _WeakMap2();
  16840. var cacheNodeInterop = new _WeakMap2();
  16841. return (_getRequireWildcardCache = function (nodeInterop) {
  16842. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  16843. })(nodeInterop);
  16844. }
  16845. function _interopRequireWildcard(obj, nodeInterop) {
  16846. if (!nodeInterop && obj && obj.__esModule) {
  16847. return obj;
  16848. }
  16849. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  16850. return {
  16851. default: obj
  16852. };
  16853. }
  16854. var cache = _getRequireWildcardCache(nodeInterop);
  16855. if (cache && cache.has(obj)) {
  16856. return cache.get(obj);
  16857. }
  16858. var newObj = {};
  16859. for (var key in obj) {
  16860. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  16861. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  16862. if (desc && (desc.get || desc.set)) {
  16863. _Object$defineProperty(newObj, key, desc);
  16864. } else {
  16865. newObj[key] = obj[key];
  16866. }
  16867. }
  16868. }
  16869. newObj.default = obj;
  16870. if (cache) {
  16871. cache.set(obj, newObj);
  16872. }
  16873. return newObj;
  16874. }
  16875. /**
  16876. * @flow
  16877. */
  16878. /*:: import type { Op } from './ParseOp';*/
  16879. /*:: import type ParseObject from './ParseObject';*/
  16880. /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
  16881. var objectState = new _weakMap.default();
  16882. function getState(obj /*: ParseObject*/) /*: ?State*/{
  16883. var classData = objectState.get(obj);
  16884. return classData || null;
  16885. }
  16886. function initializeState(obj /*: ParseObject*/, initial /*:: ?: State*/) /*: State*/{
  16887. var state = getState(obj);
  16888. if (state) {
  16889. return state;
  16890. }
  16891. if (!initial) {
  16892. initial = {
  16893. serverData: {},
  16894. pendingOps: [{}],
  16895. objectCache: {},
  16896. tasks: new _TaskQueue.default(),
  16897. existed: false
  16898. };
  16899. }
  16900. state = initial;
  16901. objectState.set(obj, state);
  16902. return state;
  16903. }
  16904. function removeState(obj /*: ParseObject*/) /*: ?State*/{
  16905. var state = getState(obj);
  16906. if (state === null) {
  16907. return null;
  16908. }
  16909. objectState.delete(obj);
  16910. return state;
  16911. }
  16912. function getServerData(obj /*: ParseObject*/) /*: AttributeMap*/{
  16913. var state = getState(obj);
  16914. if (state) {
  16915. return state.serverData;
  16916. }
  16917. return {};
  16918. }
  16919. function setServerData(obj /*: ParseObject*/, attributes /*: AttributeMap*/) {
  16920. var serverData = initializeState(obj).serverData;
  16921. ObjectStateMutations.setServerData(serverData, attributes);
  16922. }
  16923. function getPendingOps(obj /*: ParseObject*/) /*: Array<OpsMap>*/{
  16924. var state = getState(obj);
  16925. if (state) {
  16926. return state.pendingOps;
  16927. }
  16928. return [{}];
  16929. }
  16930. function setPendingOp(obj /*: ParseObject*/, attr /*: string*/, op /*: ?Op*/) {
  16931. var pendingOps = initializeState(obj).pendingOps;
  16932. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  16933. }
  16934. function pushPendingState(obj /*: ParseObject*/) {
  16935. var pendingOps = initializeState(obj).pendingOps;
  16936. ObjectStateMutations.pushPendingState(pendingOps);
  16937. }
  16938. function popPendingState(obj /*: ParseObject*/) /*: OpsMap*/{
  16939. var pendingOps = initializeState(obj).pendingOps;
  16940. return ObjectStateMutations.popPendingState(pendingOps);
  16941. }
  16942. function mergeFirstPendingState(obj /*: ParseObject*/) {
  16943. var pendingOps = getPendingOps(obj);
  16944. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  16945. }
  16946. function getObjectCache(obj /*: ParseObject*/) /*: ObjectCache*/{
  16947. var state = getState(obj);
  16948. if (state) {
  16949. return state.objectCache;
  16950. }
  16951. return {};
  16952. }
  16953. function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
  16954. var serverData = getServerData(obj);
  16955. var pendingOps = getPendingOps(obj);
  16956. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
  16957. }
  16958. function estimateAttributes(obj /*: ParseObject*/) /*: AttributeMap*/{
  16959. var serverData = getServerData(obj);
  16960. var pendingOps = getPendingOps(obj);
  16961. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
  16962. }
  16963. function commitServerChanges(obj /*: ParseObject*/, changes /*: AttributeMap*/) {
  16964. var state = initializeState(obj);
  16965. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  16966. }
  16967. function enqueueTask(obj /*: ParseObject*/, task /*: () => Promise*/) /*: Promise*/{
  16968. var state = initializeState(obj);
  16969. return state.tasks.enqueue(task);
  16970. }
  16971. function duplicateState(source /*: ParseObject*/, dest /*: ParseObject*/) /*: void*/{
  16972. var oldState = initializeState(source);
  16973. var newState = initializeState(dest);
  16974. for (var key in oldState.serverData) {
  16975. newState.serverData[key] = oldState.serverData[key];
  16976. }
  16977. for (var index = 0; index < oldState.pendingOps.length; index++) {
  16978. for (var _key in oldState.pendingOps[index]) {
  16979. newState.pendingOps[index][_key] = oldState.pendingOps[index][_key];
  16980. }
  16981. }
  16982. for (var _key2 in oldState.objectCache) {
  16983. newState.objectCache[_key2] = oldState.objectCache[_key2];
  16984. }
  16985. newState.existed = oldState.existed;
  16986. }
  16987. function clearAllState() {
  16988. objectState = new _weakMap.default();
  16989. }
  16990. },{"./ObjectStateMutations":16,"./TaskQueue":41,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":84,"@babel/runtime-corejs3/core-js-stable/weak-map":96,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],43:[function(_dereq_,module,exports){
  16991. "use strict";
  16992. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  16993. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16994. _Object$defineProperty(exports, "__esModule", {
  16995. value: true
  16996. });
  16997. exports.default = arrayContainsObject;
  16998. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  16999. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17000. /**
  17001. * @flow
  17002. */
  17003. function arrayContainsObject(array /*: Array<any>*/, object /*: ParseObject*/) /*: boolean*/{
  17004. if ((0, _indexOf.default)(array).call(array, object) > -1) {
  17005. return true;
  17006. }
  17007. for (var i = 0; i < array.length; i++) {
  17008. if (array[i] instanceof _ParseObject.default && array[i].className === object.className && array[i]._getId() === object._getId()) {
  17009. return true;
  17010. }
  17011. }
  17012. return false;
  17013. }
  17014. },{"./ParseObject":27,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],44:[function(_dereq_,module,exports){
  17015. "use strict";
  17016. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17017. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17018. _Object$defineProperty(exports, "__esModule", {
  17019. value: true
  17020. });
  17021. exports.default = canBeSerialized;
  17022. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17023. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  17024. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  17025. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17026. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  17027. /**
  17028. * @flow
  17029. */
  17030. function canBeSerialized(obj /*: ParseObject*/) /*: boolean*/{
  17031. if (!(obj instanceof _ParseObject.default)) {
  17032. return true;
  17033. }
  17034. var attributes = obj.attributes;
  17035. for (var attr in attributes) {
  17036. var val = attributes[attr];
  17037. if (!canBeSerializedHelper(val)) {
  17038. return false;
  17039. }
  17040. }
  17041. return true;
  17042. }
  17043. function canBeSerializedHelper(value /*: any*/) /*: boolean*/{
  17044. if ((0, _typeof2.default)(value) !== 'object') {
  17045. return true;
  17046. }
  17047. if (value instanceof _ParseRelation.default) {
  17048. return true;
  17049. }
  17050. if (value instanceof _ParseObject.default) {
  17051. return !!value.id;
  17052. }
  17053. if (value instanceof _ParseFile.default) {
  17054. if (value.url()) {
  17055. return true;
  17056. }
  17057. return false;
  17058. }
  17059. if ((0, _isArray.default)(value)) {
  17060. for (var i = 0; i < value.length; i++) {
  17061. if (!canBeSerializedHelper(value[i])) {
  17062. return false;
  17063. }
  17064. }
  17065. return true;
  17066. }
  17067. for (var k in value) {
  17068. if (!canBeSerializedHelper(value[k])) {
  17069. return false;
  17070. }
  17071. }
  17072. return true;
  17073. }
  17074. },{"./ParseFile":23,"./ParseObject":27,"./ParseRelation":31,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],45:[function(_dereq_,module,exports){
  17075. "use strict";
  17076. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17077. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17078. _Object$defineProperty(exports, "__esModule", {
  17079. value: true
  17080. });
  17081. exports.default = decode;
  17082. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17083. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  17084. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  17085. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  17086. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  17087. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  17088. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  17089. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17090. var _ParseOp = _dereq_("./ParseOp");
  17091. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  17092. /**
  17093. * @flow
  17094. */
  17095. // eslint-disable-line no-unused-vars
  17096. function decode(value /*: any*/) /*: any*/{
  17097. if (value === null || (0, _typeof2.default)(value) !== 'object' || value instanceof Date) {
  17098. return value;
  17099. }
  17100. if ((0, _isArray.default)(value)) {
  17101. var dup = [];
  17102. (0, _forEach.default)(value).call(value, function (v, i) {
  17103. dup[i] = decode(v);
  17104. });
  17105. return dup;
  17106. }
  17107. if (typeof value.__op === 'string') {
  17108. return (0, _ParseOp.opFromJSON)(value);
  17109. }
  17110. if (value.__type === 'Pointer' && value.className) {
  17111. return _ParseObject.default.fromJSON(value);
  17112. }
  17113. if (value.__type === 'Object' && value.className) {
  17114. return _ParseObject.default.fromJSON(value);
  17115. }
  17116. if (value.__type === 'Relation') {
  17117. // The parent and key fields will be populated by the parent
  17118. var relation = new _ParseRelation.default(null, null);
  17119. relation.targetClassName = value.className;
  17120. return relation;
  17121. }
  17122. if (value.__type === 'Date') {
  17123. return new Date(value.iso);
  17124. }
  17125. if (value.__type === 'File') {
  17126. return _ParseFile.default.fromJSON(value);
  17127. }
  17128. if (value.__type === 'GeoPoint') {
  17129. return new _ParseGeoPoint.default({
  17130. latitude: value.latitude,
  17131. longitude: value.longitude
  17132. });
  17133. }
  17134. if (value.__type === 'Polygon') {
  17135. return new _ParsePolygon.default(value.coordinates);
  17136. }
  17137. var copy = {};
  17138. for (var k in value) {
  17139. copy[k] = decode(value[k]);
  17140. }
  17141. return copy;
  17142. }
  17143. },{"./ParseACL":19,"./ParseFile":23,"./ParseGeoPoint":24,"./ParseObject":27,"./ParseOp":28,"./ParsePolygon":29,"./ParseRelation":31,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],46:[function(_dereq_,module,exports){
  17144. "use strict";
  17145. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17146. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17147. _Object$defineProperty(exports, "__esModule", {
  17148. value: true
  17149. });
  17150. exports.default = _default;
  17151. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  17152. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  17153. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  17154. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  17155. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  17156. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17157. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  17158. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  17159. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  17160. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  17161. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  17162. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17163. var _ParseOp = _dereq_("./ParseOp");
  17164. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  17165. /**
  17166. * @flow
  17167. */
  17168. function encode(value /*: mixed*/, disallowObjects /*: boolean*/, forcePointers /*: boolean*/, seen /*: Array<mixed>*/, offline /*: boolean*/) /*: any*/{
  17169. if (value instanceof _ParseObject.default) {
  17170. if (disallowObjects) {
  17171. throw new Error('Parse Objects not allowed here');
  17172. }
  17173. var seenEntry = value.id ? value.className + ':' + value.id : value;
  17174. if (forcePointers || !seen || (0, _indexOf.default)(seen).call(seen, seenEntry) > -1 || value.dirty() || (0, _keys.default)(value._getServerData()).length < 1) {
  17175. var _context;
  17176. if (offline && (0, _startsWith.default)(_context = value._getId()).call(_context, 'local')) {
  17177. return value.toOfflinePointer();
  17178. }
  17179. return value.toPointer();
  17180. }
  17181. seen = (0, _concat.default)(seen).call(seen, seenEntry);
  17182. return value._toFullJSON(seen, offline);
  17183. }
  17184. if (value instanceof _ParseOp.Op || value instanceof _ParseACL.default || value instanceof _ParseGeoPoint.default || value instanceof _ParsePolygon.default || value instanceof _ParseRelation.default) {
  17185. return value.toJSON();
  17186. }
  17187. if (value instanceof _ParseFile.default) {
  17188. if (!value.url()) {
  17189. throw new Error('Tried to encode an unsaved file.');
  17190. }
  17191. return value.toJSON();
  17192. }
  17193. if (Object.prototype.toString.call(value) === '[object Date]') {
  17194. if (isNaN(value)) {
  17195. throw new Error('Tried to encode an invalid date.');
  17196. }
  17197. return {
  17198. __type: 'Date',
  17199. iso: value /*: any*/.toJSON()
  17200. };
  17201. }
  17202. if (Object.prototype.toString.call(value) === '[object RegExp]' && typeof value.source === 'string') {
  17203. return value.source;
  17204. }
  17205. if ((0, _isArray.default)(value)) {
  17206. return (0, _map.default)(value).call(value, function (v) {
  17207. return encode(v, disallowObjects, forcePointers, seen, offline);
  17208. });
  17209. }
  17210. if (value && (0, _typeof2.default)(value) === 'object') {
  17211. var output = {};
  17212. for (var k in value) {
  17213. output[k] = encode(value[k], disallowObjects, forcePointers, seen, offline);
  17214. }
  17215. return output;
  17216. }
  17217. return value;
  17218. }
  17219. function _default(value /*: mixed*/, disallowObjects /*:: ?: boolean*/, forcePointers /*:: ?: boolean*/, seen /*:: ?: Array<mixed>*/, offline /*:: ?: boolean*/) /*: any*/{
  17220. return encode(value, !!disallowObjects, !!forcePointers, seen || [], offline);
  17221. }
  17222. },{"./ParseACL":19,"./ParseFile":23,"./ParseGeoPoint":24,"./ParseObject":27,"./ParseOp":28,"./ParsePolygon":29,"./ParseRelation":31,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/instance/map":68,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":73,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],47:[function(_dereq_,module,exports){
  17223. "use strict";
  17224. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17225. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17226. _Object$defineProperty(exports, "__esModule", {
  17227. value: true
  17228. });
  17229. exports.default = equals;
  17230. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17231. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  17232. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  17233. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  17234. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  17235. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  17236. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17237. function equals(a, b) {
  17238. var toString = Object.prototype.toString;
  17239. if (toString.call(a) === '[object Date]' || toString.call(b) === '[object Date]') {
  17240. var dateA = new Date(a);
  17241. var dateB = new Date(b);
  17242. return +dateA === +dateB;
  17243. }
  17244. if ((0, _typeof2.default)(a) !== (0, _typeof2.default)(b)) {
  17245. return false;
  17246. }
  17247. if (!a || (0, _typeof2.default)(a) !== 'object') {
  17248. // a is a primitive
  17249. return a === b;
  17250. }
  17251. if ((0, _isArray.default)(a) || (0, _isArray.default)(b)) {
  17252. if (!(0, _isArray.default)(a) || !(0, _isArray.default)(b)) {
  17253. return false;
  17254. }
  17255. if (a.length !== b.length) {
  17256. return false;
  17257. }
  17258. for (var i = a.length; i--;) {
  17259. if (!equals(a[i], b[i])) {
  17260. return false;
  17261. }
  17262. }
  17263. return true;
  17264. }
  17265. if (a instanceof _ParseACL.default || a instanceof _ParseFile.default || a instanceof _ParseGeoPoint.default || a instanceof _ParseObject.default) {
  17266. return a.equals(b);
  17267. }
  17268. if (b instanceof _ParseObject.default) {
  17269. if (a.__type === 'Object' || a.__type === 'Pointer') {
  17270. return a.objectId === b.id && a.className === b.className;
  17271. }
  17272. }
  17273. if ((0, _keys.default)(a).length !== (0, _keys.default)(b).length) {
  17274. return false;
  17275. }
  17276. for (var k in a) {
  17277. if (!equals(a[k], b[k])) {
  17278. return false;
  17279. }
  17280. }
  17281. return true;
  17282. }
  17283. },{"./ParseACL":19,"./ParseFile":23,"./ParseGeoPoint":24,"./ParseObject":27,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/object/keys":88,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],48:[function(_dereq_,module,exports){
  17284. "use strict";
  17285. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17286. _Object$defineProperty(exports, "__esModule", {
  17287. value: true
  17288. });
  17289. exports.default = escape;
  17290. /*
  17291. * @flow
  17292. */
  17293. var encoded = {
  17294. '&': '&amp;',
  17295. '<': '&lt;',
  17296. '>': '&gt;',
  17297. '/': '&#x2F;',
  17298. "'": '&#x27;',
  17299. '"': '&quot;'
  17300. };
  17301. function escape(str /*: string*/) /*: string*/{
  17302. return str.replace(/[&<>\/'"]/g, function (char) {
  17303. return encoded[char];
  17304. });
  17305. }
  17306. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":81}],49:[function(_dereq_,module,exports){
  17307. "use strict";
  17308. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17309. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17310. _Object$defineProperty(exports, "__esModule", {
  17311. value: true
  17312. });
  17313. exports.default = isRevocableSession;
  17314. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  17315. /**
  17316. * @flow
  17317. */
  17318. function isRevocableSession(token /*: string*/) /*: boolean*/{
  17319. return (0, _indexOf.default)(token).call(token, 'r:') > -1;
  17320. }
  17321. },{"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],50:[function(_dereq_,module,exports){
  17322. "use strict";
  17323. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17324. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17325. _Object$defineProperty(exports, "__esModule", {
  17326. value: true
  17327. });
  17328. exports.default = parseDate;
  17329. var _parseInt2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/parse-int"));
  17330. /**
  17331. * @flow
  17332. */
  17333. function parseDate(iso8601 /*: string*/) /*: ?Date*/{
  17334. var regexp = new RegExp('^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})' + 'T' + '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})' + '(.([0-9]+))?' + 'Z$');
  17335. var match = regexp.exec(iso8601);
  17336. if (!match) {
  17337. return null;
  17338. }
  17339. var year = (0, _parseInt2.default)(match[1]) || 0;
  17340. var month = ((0, _parseInt2.default)(match[2]) || 1) - 1;
  17341. var day = (0, _parseInt2.default)(match[3]) || 0;
  17342. var hour = (0, _parseInt2.default)(match[4]) || 0;
  17343. var minute = (0, _parseInt2.default)(match[5]) || 0;
  17344. var second = (0, _parseInt2.default)(match[6]) || 0;
  17345. var milli = (0, _parseInt2.default)(match[8]) || 0;
  17346. return new Date(Date.UTC(year, month, day, hour, minute, second, milli));
  17347. }
  17348. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/parse-int":89,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],51:[function(_dereq_,module,exports){
  17349. "use strict";
  17350. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17351. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17352. _Object$defineProperty(exports, "__esModule", {
  17353. value: true
  17354. });
  17355. exports.continueWhile = continueWhile;
  17356. exports.resolvingPromise = resolvingPromise;
  17357. exports.when = when;
  17358. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  17359. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17360. // Create Deferred Promise
  17361. function resolvingPromise() {
  17362. var res;
  17363. var rej;
  17364. var promise = new _promise.default(function (resolve, reject) {
  17365. res = resolve;
  17366. rej = reject;
  17367. });
  17368. promise.resolve = res;
  17369. promise.reject = rej;
  17370. return promise;
  17371. }
  17372. function when(promises) {
  17373. var objects;
  17374. var arrayArgument = (0, _isArray.default)(promises);
  17375. if (arrayArgument) {
  17376. objects = promises;
  17377. } else {
  17378. objects = arguments;
  17379. }
  17380. var total = objects.length;
  17381. var hadError = false;
  17382. var results = [];
  17383. var returnValue = arrayArgument ? [results] : results;
  17384. var errors = [];
  17385. results.length = objects.length;
  17386. errors.length = objects.length;
  17387. if (total === 0) {
  17388. return _promise.default.resolve(returnValue);
  17389. }
  17390. var promise = new resolvingPromise();
  17391. var resolveOne = function () {
  17392. total--;
  17393. if (total <= 0) {
  17394. if (hadError) {
  17395. promise.reject(errors);
  17396. } else {
  17397. promise.resolve(returnValue);
  17398. }
  17399. }
  17400. };
  17401. var chain = function (object, index) {
  17402. if (object && typeof object.then === 'function') {
  17403. object.then(function (result) {
  17404. results[index] = result;
  17405. resolveOne();
  17406. }, function (error) {
  17407. errors[index] = error;
  17408. hadError = true;
  17409. resolveOne();
  17410. });
  17411. } else {
  17412. results[index] = object;
  17413. resolveOne();
  17414. }
  17415. };
  17416. for (var i = 0; i < objects.length; i++) {
  17417. chain(objects[i], i);
  17418. }
  17419. return promise;
  17420. }
  17421. function continueWhile(test, emitter) {
  17422. if (test()) {
  17423. return emitter().then(function () {
  17424. return continueWhile(test, emitter);
  17425. });
  17426. }
  17427. return _promise.default.resolve();
  17428. }
  17429. },{"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/core-js-stable/promise":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],52:[function(_dereq_,module,exports){
  17430. "use strict";
  17431. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17432. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17433. _Object$defineProperty(exports, "__esModule", {
  17434. value: true
  17435. });
  17436. exports.default = unique;
  17437. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  17438. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  17439. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  17440. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17441. /**
  17442. * @flow
  17443. */
  17444. function unique /*:: <T>*/(arr /*: Array<T>*/) /*: Array<T>*/{
  17445. var uniques = [];
  17446. (0, _forEach.default)(arr).call(arr, function (value) {
  17447. if (value instanceof _ParseObject.default) {
  17448. if (!(0, _arrayContainsObject.default)(uniques, value)) {
  17449. uniques.push(value);
  17450. }
  17451. } else {
  17452. if ((0, _indexOf.default)(uniques).call(uniques, value) < 0) {
  17453. uniques.push(value);
  17454. }
  17455. }
  17456. });
  17457. return uniques;
  17458. }
  17459. },{"./ParseObject":27,"./arrayContainsObject":43,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/interopRequireDefault":129}],53:[function(_dereq_,module,exports){
  17460. "use strict";
  17461. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17462. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17463. _Object$defineProperty(exports, "__esModule", {
  17464. value: true
  17465. });
  17466. exports.default = unsavedChildren;
  17467. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  17468. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  17469. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17470. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  17471. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  17472. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  17473. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17474. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  17475. /**
  17476. * @flow
  17477. */
  17478. /*:: type EncounterMap = {
  17479. objects: { [identifier: string]: ParseObject | boolean },
  17480. files: Array<ParseFile>,
  17481. };*/
  17482. /**
  17483. * Return an array of unsaved children, which are either Parse Objects or Files.
  17484. * If it encounters any dirty Objects without Ids, it will throw an exception.
  17485. *
  17486. * @param {Parse.Object} obj
  17487. * @param {boolean} allowDeepUnsaved
  17488. * @returns {Array}
  17489. */
  17490. function unsavedChildren(obj /*: ParseObject*/, allowDeepUnsaved /*:: ?: boolean*/) /*: Array<ParseFile | ParseObject>*/{
  17491. var encountered = {
  17492. objects: {},
  17493. files: []
  17494. };
  17495. var identifier = obj.className + ':' + obj._getId();
  17496. encountered.objects[identifier] = obj.dirty() ? obj : true;
  17497. var attributes = obj.attributes;
  17498. for (var attr in attributes) {
  17499. if ((0, _typeof2.default)(attributes[attr]) === 'object') {
  17500. traverse(attributes[attr], encountered, false, !!allowDeepUnsaved);
  17501. }
  17502. }
  17503. var unsaved = [];
  17504. for (var id in encountered.objects) {
  17505. if (id !== identifier && encountered.objects[id] !== true) {
  17506. unsaved.push(encountered.objects[id]);
  17507. }
  17508. }
  17509. return (0, _concat.default)(unsaved).call(unsaved, encountered.files);
  17510. }
  17511. function traverse(obj /*: ParseObject*/, encountered /*: EncounterMap*/, shouldThrow /*: boolean*/, allowDeepUnsaved /*: boolean*/) {
  17512. if (obj instanceof _ParseObject.default) {
  17513. if (!obj.id && shouldThrow) {
  17514. throw new Error('Cannot create a pointer to an unsaved Object.');
  17515. }
  17516. var _identifier = obj.className + ':' + obj._getId();
  17517. if (!encountered.objects[_identifier]) {
  17518. encountered.objects[_identifier] = obj.dirty() ? obj : true;
  17519. var attributes = obj.attributes;
  17520. for (var attr in attributes) {
  17521. if ((0, _typeof2.default)(attributes[attr]) === 'object') {
  17522. traverse(attributes[attr], encountered, !allowDeepUnsaved, allowDeepUnsaved);
  17523. }
  17524. }
  17525. }
  17526. return;
  17527. }
  17528. if (obj instanceof _ParseFile.default) {
  17529. var _context;
  17530. if (!obj.url() && (0, _indexOf.default)(_context = encountered.files).call(_context, obj) < 0) {
  17531. encountered.files.push(obj);
  17532. }
  17533. return;
  17534. }
  17535. if (obj instanceof _ParseRelation.default) {
  17536. return;
  17537. }
  17538. if ((0, _isArray.default)(obj)) {
  17539. (0, _forEach.default)(obj).call(obj, function (el) {
  17540. if ((0, _typeof2.default)(el) === 'object') {
  17541. traverse(el, encountered, shouldThrow, allowDeepUnsaved);
  17542. }
  17543. });
  17544. }
  17545. for (var k in obj) {
  17546. if ((0, _typeof2.default)(obj[k]) === 'object') {
  17547. traverse(obj[k], encountered, shouldThrow, allowDeepUnsaved);
  17548. }
  17549. }
  17550. }
  17551. },{"./ParseFile":23,"./ParseObject":27,"./ParseRelation":31,"@babel/runtime-corejs3/core-js-stable/array/is-array":56,"@babel/runtime-corejs3/core-js-stable/instance/concat":58,"@babel/runtime-corejs3/core-js-stable/instance/for-each":64,"@babel/runtime-corejs3/core-js-stable/instance/index-of":66,"@babel/runtime-corejs3/core-js-stable/object/define-property":81,"@babel/runtime-corejs3/helpers/interopRequireDefault":129,"@babel/runtime-corejs3/helpers/typeof":144}],54:[function(_dereq_,module,exports){
  17552. "use strict";
  17553. var uuid = null;
  17554. var _require = _dereq_('uuid'),
  17555. v4 = _require.v4;
  17556. uuid = v4;
  17557. module.exports = uuid;
  17558. },{"uuid":622}],55:[function(_dereq_,module,exports){
  17559. module.exports = _dereq_("core-js-pure/stable/array/from");
  17560. },{"core-js-pure/stable/array/from":559}],56:[function(_dereq_,module,exports){
  17561. module.exports = _dereq_("core-js-pure/stable/array/is-array");
  17562. },{"core-js-pure/stable/array/is-array":560}],57:[function(_dereq_,module,exports){
  17563. module.exports = _dereq_("core-js-pure/stable/instance/bind");
  17564. },{"core-js-pure/stable/instance/bind":566}],58:[function(_dereq_,module,exports){
  17565. module.exports = _dereq_("core-js-pure/stable/instance/concat");
  17566. },{"core-js-pure/stable/instance/concat":567}],59:[function(_dereq_,module,exports){
  17567. module.exports = _dereq_("core-js-pure/stable/instance/entries");
  17568. },{"core-js-pure/stable/instance/entries":568}],60:[function(_dereq_,module,exports){
  17569. module.exports = _dereq_("core-js-pure/stable/instance/every");
  17570. },{"core-js-pure/stable/instance/every":569}],61:[function(_dereq_,module,exports){
  17571. module.exports = _dereq_("core-js-pure/stable/instance/filter");
  17572. },{"core-js-pure/stable/instance/filter":570}],62:[function(_dereq_,module,exports){
  17573. module.exports = _dereq_("core-js-pure/stable/instance/find-index");
  17574. },{"core-js-pure/stable/instance/find-index":571}],63:[function(_dereq_,module,exports){
  17575. module.exports = _dereq_("core-js-pure/stable/instance/find");
  17576. },{"core-js-pure/stable/instance/find":572}],64:[function(_dereq_,module,exports){
  17577. module.exports = _dereq_("core-js-pure/stable/instance/for-each");
  17578. },{"core-js-pure/stable/instance/for-each":573}],65:[function(_dereq_,module,exports){
  17579. module.exports = _dereq_("core-js-pure/stable/instance/includes");
  17580. },{"core-js-pure/stable/instance/includes":574}],66:[function(_dereq_,module,exports){
  17581. module.exports = _dereq_("core-js-pure/stable/instance/index-of");
  17582. },{"core-js-pure/stable/instance/index-of":575}],67:[function(_dereq_,module,exports){
  17583. module.exports = _dereq_("core-js-pure/stable/instance/keys");
  17584. },{"core-js-pure/stable/instance/keys":576}],68:[function(_dereq_,module,exports){
  17585. module.exports = _dereq_("core-js-pure/stable/instance/map");
  17586. },{"core-js-pure/stable/instance/map":577}],69:[function(_dereq_,module,exports){
  17587. module.exports = _dereq_("core-js-pure/stable/instance/reduce");
  17588. },{"core-js-pure/stable/instance/reduce":578}],70:[function(_dereq_,module,exports){
  17589. module.exports = _dereq_("core-js-pure/stable/instance/slice");
  17590. },{"core-js-pure/stable/instance/slice":580}],71:[function(_dereq_,module,exports){
  17591. module.exports = _dereq_("core-js-pure/stable/instance/sort");
  17592. },{"core-js-pure/stable/instance/sort":581}],72:[function(_dereq_,module,exports){
  17593. module.exports = _dereq_("core-js-pure/stable/instance/splice");
  17594. },{"core-js-pure/stable/instance/splice":582}],73:[function(_dereq_,module,exports){
  17595. module.exports = _dereq_("core-js-pure/stable/instance/starts-with");
  17596. },{"core-js-pure/stable/instance/starts-with":583}],74:[function(_dereq_,module,exports){
  17597. module.exports = _dereq_("core-js-pure/stable/instance/values");
  17598. },{"core-js-pure/stable/instance/values":584}],75:[function(_dereq_,module,exports){
  17599. module.exports = _dereq_("core-js-pure/stable/json/stringify");
  17600. },{"core-js-pure/stable/json/stringify":585}],76:[function(_dereq_,module,exports){
  17601. module.exports = _dereq_("core-js-pure/stable/map");
  17602. },{"core-js-pure/stable/map":586}],77:[function(_dereq_,module,exports){
  17603. module.exports = _dereq_("core-js-pure/stable/number/is-integer");
  17604. },{"core-js-pure/stable/number/is-integer":587}],78:[function(_dereq_,module,exports){
  17605. module.exports = _dereq_("core-js-pure/stable/object/assign");
  17606. },{"core-js-pure/stable/object/assign":588}],79:[function(_dereq_,module,exports){
  17607. module.exports = _dereq_("core-js-pure/stable/object/create");
  17608. },{"core-js-pure/stable/object/create":589}],80:[function(_dereq_,module,exports){
  17609. module.exports = _dereq_("core-js-pure/stable/object/define-properties");
  17610. },{"core-js-pure/stable/object/define-properties":590}],81:[function(_dereq_,module,exports){
  17611. module.exports = _dereq_("core-js-pure/stable/object/define-property");
  17612. },{"core-js-pure/stable/object/define-property":591}],82:[function(_dereq_,module,exports){
  17613. module.exports = _dereq_("core-js-pure/stable/object/entries");
  17614. },{"core-js-pure/stable/object/entries":592}],83:[function(_dereq_,module,exports){
  17615. module.exports = _dereq_("core-js-pure/stable/object/freeze");
  17616. },{"core-js-pure/stable/object/freeze":593}],84:[function(_dereq_,module,exports){
  17617. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptor");
  17618. },{"core-js-pure/stable/object/get-own-property-descriptor":594}],85:[function(_dereq_,module,exports){
  17619. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptors");
  17620. },{"core-js-pure/stable/object/get-own-property-descriptors":595}],86:[function(_dereq_,module,exports){
  17621. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-symbols");
  17622. },{"core-js-pure/stable/object/get-own-property-symbols":596}],87:[function(_dereq_,module,exports){
  17623. module.exports = _dereq_("core-js-pure/stable/object/get-prototype-of");
  17624. },{"core-js-pure/stable/object/get-prototype-of":597}],88:[function(_dereq_,module,exports){
  17625. module.exports = _dereq_("core-js-pure/stable/object/keys");
  17626. },{"core-js-pure/stable/object/keys":598}],89:[function(_dereq_,module,exports){
  17627. module.exports = _dereq_("core-js-pure/stable/parse-int");
  17628. },{"core-js-pure/stable/parse-int":600}],90:[function(_dereq_,module,exports){
  17629. module.exports = _dereq_("core-js-pure/stable/promise");
  17630. },{"core-js-pure/stable/promise":601}],91:[function(_dereq_,module,exports){
  17631. module.exports = _dereq_("core-js-pure/stable/reflect/construct");
  17632. },{"core-js-pure/stable/reflect/construct":602}],92:[function(_dereq_,module,exports){
  17633. module.exports = _dereq_("core-js-pure/stable/set-interval");
  17634. },{"core-js-pure/stable/set-interval":604}],93:[function(_dereq_,module,exports){
  17635. module.exports = _dereq_("core-js-pure/stable/set-timeout");
  17636. },{"core-js-pure/stable/set-timeout":605}],94:[function(_dereq_,module,exports){
  17637. module.exports = _dereq_("core-js-pure/stable/set");
  17638. },{"core-js-pure/stable/set":606}],95:[function(_dereq_,module,exports){
  17639. module.exports = _dereq_("core-js-pure/stable/symbol");
  17640. },{"core-js-pure/stable/symbol":607}],96:[function(_dereq_,module,exports){
  17641. module.exports = _dereq_("core-js-pure/stable/weak-map");
  17642. },{"core-js-pure/stable/weak-map":610}],97:[function(_dereq_,module,exports){
  17643. module.exports = _dereq_("core-js-pure/features/array/from");
  17644. },{"core-js-pure/features/array/from":231}],98:[function(_dereq_,module,exports){
  17645. module.exports = _dereq_("core-js-pure/features/array/is-array");
  17646. },{"core-js-pure/features/array/is-array":232}],99:[function(_dereq_,module,exports){
  17647. module.exports = _dereq_("core-js-pure/features/get-iterator-method");
  17648. },{"core-js-pure/features/get-iterator-method":233}],100:[function(_dereq_,module,exports){
  17649. module.exports = _dereq_("core-js-pure/features/instance/bind");
  17650. },{"core-js-pure/features/instance/bind":234}],101:[function(_dereq_,module,exports){
  17651. module.exports = _dereq_("core-js-pure/features/instance/for-each");
  17652. },{"core-js-pure/features/instance/for-each":235}],102:[function(_dereq_,module,exports){
  17653. module.exports = _dereq_("core-js-pure/features/instance/index-of");
  17654. },{"core-js-pure/features/instance/index-of":236}],103:[function(_dereq_,module,exports){
  17655. module.exports = _dereq_("core-js-pure/features/instance/reverse");
  17656. },{"core-js-pure/features/instance/reverse":237}],104:[function(_dereq_,module,exports){
  17657. module.exports = _dereq_("core-js-pure/features/instance/slice");
  17658. },{"core-js-pure/features/instance/slice":238}],105:[function(_dereq_,module,exports){
  17659. module.exports = _dereq_("core-js-pure/features/map");
  17660. },{"core-js-pure/features/map":239}],106:[function(_dereq_,module,exports){
  17661. module.exports = _dereq_("core-js-pure/features/object/create");
  17662. },{"core-js-pure/features/object/create":240}],107:[function(_dereq_,module,exports){
  17663. module.exports = _dereq_("core-js-pure/features/object/define-property");
  17664. },{"core-js-pure/features/object/define-property":241}],108:[function(_dereq_,module,exports){
  17665. module.exports = _dereq_("core-js-pure/features/object/get-own-property-descriptor");
  17666. },{"core-js-pure/features/object/get-own-property-descriptor":242}],109:[function(_dereq_,module,exports){
  17667. module.exports = _dereq_("core-js-pure/features/object/get-prototype-of");
  17668. },{"core-js-pure/features/object/get-prototype-of":243}],110:[function(_dereq_,module,exports){
  17669. module.exports = _dereq_("core-js-pure/features/object/set-prototype-of");
  17670. },{"core-js-pure/features/object/set-prototype-of":244}],111:[function(_dereq_,module,exports){
  17671. module.exports = _dereq_("core-js-pure/features/promise");
  17672. },{"core-js-pure/features/promise":245}],112:[function(_dereq_,module,exports){
  17673. module.exports = _dereq_("core-js-pure/features/reflect/construct");
  17674. },{"core-js-pure/features/reflect/construct":246}],113:[function(_dereq_,module,exports){
  17675. module.exports = _dereq_("core-js-pure/features/reflect/get");
  17676. },{"core-js-pure/features/reflect/get":247}],114:[function(_dereq_,module,exports){
  17677. module.exports = _dereq_("core-js-pure/features/symbol");
  17678. },{"core-js-pure/features/symbol":248}],115:[function(_dereq_,module,exports){
  17679. module.exports = _dereq_("core-js-pure/features/symbol/iterator");
  17680. },{"core-js-pure/features/symbol/iterator":249}],116:[function(_dereq_,module,exports){
  17681. module.exports = _dereq_("core-js-pure/features/symbol/to-primitive");
  17682. },{"core-js-pure/features/symbol/to-primitive":250}],117:[function(_dereq_,module,exports){
  17683. function _arrayLikeToArray(arr, len) {
  17684. if (len == null || len > arr.length) len = arr.length;
  17685. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  17686. return arr2;
  17687. }
  17688. module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17689. },{}],118:[function(_dereq_,module,exports){
  17690. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js/array/is-array");
  17691. function _arrayWithHoles(arr) {
  17692. if (_Array$isArray(arr)) return arr;
  17693. }
  17694. module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17695. },{"@babel/runtime-corejs3/core-js/array/is-array":98}],119:[function(_dereq_,module,exports){
  17696. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js/array/is-array");
  17697. var arrayLikeToArray = _dereq_("./arrayLikeToArray.js");
  17698. function _arrayWithoutHoles(arr) {
  17699. if (_Array$isArray(arr)) return arrayLikeToArray(arr);
  17700. }
  17701. module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17702. },{"./arrayLikeToArray.js":117,"@babel/runtime-corejs3/core-js/array/is-array":98}],120:[function(_dereq_,module,exports){
  17703. function _assertThisInitialized(self) {
  17704. if (self === void 0) {
  17705. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  17706. }
  17707. return self;
  17708. }
  17709. module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17710. },{}],121:[function(_dereq_,module,exports){
  17711. var _Promise = _dereq_("@babel/runtime-corejs3/core-js/promise");
  17712. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  17713. try {
  17714. var info = gen[key](arg);
  17715. var value = info.value;
  17716. } catch (error) {
  17717. reject(error);
  17718. return;
  17719. }
  17720. if (info.done) {
  17721. resolve(value);
  17722. } else {
  17723. _Promise.resolve(value).then(_next, _throw);
  17724. }
  17725. }
  17726. function _asyncToGenerator(fn) {
  17727. return function () {
  17728. var self = this,
  17729. args = arguments;
  17730. return new _Promise(function (resolve, reject) {
  17731. var gen = fn.apply(self, args);
  17732. function _next(value) {
  17733. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  17734. }
  17735. function _throw(err) {
  17736. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  17737. }
  17738. _next(undefined);
  17739. });
  17740. };
  17741. }
  17742. module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17743. },{"@babel/runtime-corejs3/core-js/promise":111}],122:[function(_dereq_,module,exports){
  17744. function _classCallCheck(instance, Constructor) {
  17745. if (!(instance instanceof Constructor)) {
  17746. throw new TypeError("Cannot call a class as a function");
  17747. }
  17748. }
  17749. module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17750. },{}],123:[function(_dereq_,module,exports){
  17751. var _bindInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/bind");
  17752. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js/reflect/construct");
  17753. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  17754. var isNativeReflectConstruct = _dereq_("./isNativeReflectConstruct.js");
  17755. function _construct(Parent, args, Class) {
  17756. if (isNativeReflectConstruct()) {
  17757. var _context;
  17758. module.exports = _construct = _bindInstanceProperty(_context = _Reflect$construct).call(_context), module.exports.__esModule = true, module.exports["default"] = module.exports;
  17759. } else {
  17760. module.exports = _construct = function _construct(Parent, args, Class) {
  17761. var a = [null];
  17762. a.push.apply(a, args);
  17763. var Constructor = _bindInstanceProperty(Function).apply(Parent, a);
  17764. var instance = new Constructor();
  17765. if (Class) setPrototypeOf(instance, Class.prototype);
  17766. return instance;
  17767. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17768. }
  17769. return _construct.apply(null, arguments);
  17770. }
  17771. module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17772. },{"./isNativeReflectConstruct.js":131,"./setPrototypeOf.js":138,"@babel/runtime-corejs3/core-js/instance/bind":100,"@babel/runtime-corejs3/core-js/reflect/construct":112}],124:[function(_dereq_,module,exports){
  17773. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  17774. var toPropertyKey = _dereq_("./toPropertyKey.js");
  17775. function _defineProperties(target, props) {
  17776. for (var i = 0; i < props.length; i++) {
  17777. var descriptor = props[i];
  17778. descriptor.enumerable = descriptor.enumerable || false;
  17779. descriptor.configurable = true;
  17780. if ("value" in descriptor) descriptor.writable = true;
  17781. _Object$defineProperty(target, toPropertyKey(descriptor.key), descriptor);
  17782. }
  17783. }
  17784. function _createClass(Constructor, protoProps, staticProps) {
  17785. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  17786. if (staticProps) _defineProperties(Constructor, staticProps);
  17787. _Object$defineProperty(Constructor, "prototype", {
  17788. writable: false
  17789. });
  17790. return Constructor;
  17791. }
  17792. module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17793. },{"./toPropertyKey.js":143,"@babel/runtime-corejs3/core-js/object/define-property":107}],125:[function(_dereq_,module,exports){
  17794. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  17795. var toPropertyKey = _dereq_("./toPropertyKey.js");
  17796. function _defineProperty(obj, key, value) {
  17797. key = toPropertyKey(key);
  17798. if (key in obj) {
  17799. _Object$defineProperty(obj, key, {
  17800. value: value,
  17801. enumerable: true,
  17802. configurable: true,
  17803. writable: true
  17804. });
  17805. } else {
  17806. obj[key] = value;
  17807. }
  17808. return obj;
  17809. }
  17810. module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17811. },{"./toPropertyKey.js":143,"@babel/runtime-corejs3/core-js/object/define-property":107}],126:[function(_dereq_,module,exports){
  17812. var _Reflect$get = _dereq_("@babel/runtime-corejs3/core-js/reflect/get");
  17813. var _bindInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/bind");
  17814. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor");
  17815. var superPropBase = _dereq_("./superPropBase.js");
  17816. function _get() {
  17817. if (typeof Reflect !== "undefined" && _Reflect$get) {
  17818. var _context;
  17819. module.exports = _get = _bindInstanceProperty(_context = _Reflect$get).call(_context), module.exports.__esModule = true, module.exports["default"] = module.exports;
  17820. } else {
  17821. module.exports = _get = function _get(target, property, receiver) {
  17822. var base = superPropBase(target, property);
  17823. if (!base) return;
  17824. var desc = _Object$getOwnPropertyDescriptor(base, property);
  17825. if (desc.get) {
  17826. return desc.get.call(arguments.length < 3 ? target : receiver);
  17827. }
  17828. return desc.value;
  17829. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17830. }
  17831. return _get.apply(this, arguments);
  17832. }
  17833. module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17834. },{"./superPropBase.js":140,"@babel/runtime-corejs3/core-js/instance/bind":100,"@babel/runtime-corejs3/core-js/object/get-own-property-descriptor":108,"@babel/runtime-corejs3/core-js/reflect/get":113}],127:[function(_dereq_,module,exports){
  17835. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
  17836. var _bindInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/bind");
  17837. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/get-prototype-of");
  17838. function _getPrototypeOf(o) {
  17839. var _context;
  17840. module.exports = _getPrototypeOf = _Object$setPrototypeOf ? _bindInstanceProperty(_context = _Object$getPrototypeOf).call(_context) : function _getPrototypeOf(o) {
  17841. return o.__proto__ || _Object$getPrototypeOf(o);
  17842. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17843. return _getPrototypeOf(o);
  17844. }
  17845. module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17846. },{"@babel/runtime-corejs3/core-js/instance/bind":100,"@babel/runtime-corejs3/core-js/object/get-prototype-of":109,"@babel/runtime-corejs3/core-js/object/set-prototype-of":110}],128:[function(_dereq_,module,exports){
  17847. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
  17848. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  17849. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  17850. function _inherits(subClass, superClass) {
  17851. if (typeof superClass !== "function" && superClass !== null) {
  17852. throw new TypeError("Super expression must either be null or a function");
  17853. }
  17854. subClass.prototype = _Object$create(superClass && superClass.prototype, {
  17855. constructor: {
  17856. value: subClass,
  17857. writable: true,
  17858. configurable: true
  17859. }
  17860. });
  17861. _Object$defineProperty(subClass, "prototype", {
  17862. writable: false
  17863. });
  17864. if (superClass) setPrototypeOf(subClass, superClass);
  17865. }
  17866. module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17867. },{"./setPrototypeOf.js":138,"@babel/runtime-corejs3/core-js/object/create":106,"@babel/runtime-corejs3/core-js/object/define-property":107}],129:[function(_dereq_,module,exports){
  17868. function _interopRequireDefault(obj) {
  17869. return obj && obj.__esModule ? obj : {
  17870. "default": obj
  17871. };
  17872. }
  17873. module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17874. },{}],130:[function(_dereq_,module,exports){
  17875. var _indexOfInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/index-of");
  17876. function _isNativeFunction(fn) {
  17877. var _context;
  17878. return _indexOfInstanceProperty(_context = Function.toString.call(fn)).call(_context, "[native code]") !== -1;
  17879. }
  17880. module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17881. },{"@babel/runtime-corejs3/core-js/instance/index-of":102}],131:[function(_dereq_,module,exports){
  17882. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js/reflect/construct");
  17883. function _isNativeReflectConstruct() {
  17884. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  17885. if (_Reflect$construct.sham) return false;
  17886. if (typeof Proxy === "function") return true;
  17887. try {
  17888. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  17889. return true;
  17890. } catch (e) {
  17891. return false;
  17892. }
  17893. }
  17894. module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17895. },{"@babel/runtime-corejs3/core-js/reflect/construct":112}],132:[function(_dereq_,module,exports){
  17896. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  17897. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  17898. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js/array/from");
  17899. function _iterableToArray(iter) {
  17900. if (typeof _Symbol !== "undefined" && _getIteratorMethod(iter) != null || iter["@@iterator"] != null) return _Array$from(iter);
  17901. }
  17902. module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17903. },{"@babel/runtime-corejs3/core-js/array/from":97,"@babel/runtime-corejs3/core-js/get-iterator-method":99,"@babel/runtime-corejs3/core-js/symbol":114}],133:[function(_dereq_,module,exports){
  17904. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  17905. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  17906. function _iterableToArrayLimit(arr, i) {
  17907. var _i = null == arr ? null : "undefined" != typeof _Symbol && _getIteratorMethod(arr) || arr["@@iterator"];
  17908. if (null != _i) {
  17909. var _s,
  17910. _e,
  17911. _x,
  17912. _r,
  17913. _arr = [],
  17914. _n = !0,
  17915. _d = !1;
  17916. try {
  17917. if (_x = (_i = _i.call(arr)).next, 0 === i) {
  17918. if (Object(_i) !== _i) return;
  17919. _n = !1;
  17920. } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
  17921. } catch (err) {
  17922. _d = !0, _e = err;
  17923. } finally {
  17924. try {
  17925. if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
  17926. } finally {
  17927. if (_d) throw _e;
  17928. }
  17929. }
  17930. return _arr;
  17931. }
  17932. }
  17933. module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17934. },{"@babel/runtime-corejs3/core-js/get-iterator-method":99,"@babel/runtime-corejs3/core-js/symbol":114}],134:[function(_dereq_,module,exports){
  17935. function _nonIterableRest() {
  17936. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  17937. }
  17938. module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17939. },{}],135:[function(_dereq_,module,exports){
  17940. function _nonIterableSpread() {
  17941. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  17942. }
  17943. module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17944. },{}],136:[function(_dereq_,module,exports){
  17945. var _typeof = _dereq_("./typeof.js")["default"];
  17946. var assertThisInitialized = _dereq_("./assertThisInitialized.js");
  17947. function _possibleConstructorReturn(self, call) {
  17948. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  17949. return call;
  17950. } else if (call !== void 0) {
  17951. throw new TypeError("Derived constructors may only return object or undefined");
  17952. }
  17953. return assertThisInitialized(self);
  17954. }
  17955. module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17956. },{"./assertThisInitialized.js":120,"./typeof.js":144}],137:[function(_dereq_,module,exports){
  17957. var _typeof = _dereq_("./typeof.js")["default"];
  17958. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  17959. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  17960. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
  17961. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/get-prototype-of");
  17962. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/for-each");
  17963. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
  17964. var _Promise = _dereq_("@babel/runtime-corejs3/core-js/promise");
  17965. var _reverseInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/reverse");
  17966. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/slice");
  17967. function _regeneratorRuntime() {
  17968. "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  17969. module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
  17970. return exports;
  17971. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17972. var exports = {},
  17973. Op = Object.prototype,
  17974. hasOwn = Op.hasOwnProperty,
  17975. defineProperty = _Object$defineProperty || function (obj, key, desc) {
  17976. obj[key] = desc.value;
  17977. },
  17978. $Symbol = "function" == typeof _Symbol ? _Symbol : {},
  17979. iteratorSymbol = $Symbol.iterator || "@@iterator",
  17980. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  17981. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  17982. function define(obj, key, value) {
  17983. return _Object$defineProperty(obj, key, {
  17984. value: value,
  17985. enumerable: !0,
  17986. configurable: !0,
  17987. writable: !0
  17988. }), obj[key];
  17989. }
  17990. try {
  17991. define({}, "");
  17992. } catch (err) {
  17993. define = function define(obj, key, value) {
  17994. return obj[key] = value;
  17995. };
  17996. }
  17997. function wrap(innerFn, outerFn, self, tryLocsList) {
  17998. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  17999. generator = _Object$create(protoGenerator.prototype),
  18000. context = new Context(tryLocsList || []);
  18001. return defineProperty(generator, "_invoke", {
  18002. value: makeInvokeMethod(innerFn, self, context)
  18003. }), generator;
  18004. }
  18005. function tryCatch(fn, obj, arg) {
  18006. try {
  18007. return {
  18008. type: "normal",
  18009. arg: fn.call(obj, arg)
  18010. };
  18011. } catch (err) {
  18012. return {
  18013. type: "throw",
  18014. arg: err
  18015. };
  18016. }
  18017. }
  18018. exports.wrap = wrap;
  18019. var ContinueSentinel = {};
  18020. function Generator() {}
  18021. function GeneratorFunction() {}
  18022. function GeneratorFunctionPrototype() {}
  18023. var IteratorPrototype = {};
  18024. define(IteratorPrototype, iteratorSymbol, function () {
  18025. return this;
  18026. });
  18027. var getProto = _Object$getPrototypeOf,
  18028. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  18029. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  18030. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype);
  18031. function defineIteratorMethods(prototype) {
  18032. var _context;
  18033. _forEachInstanceProperty(_context = ["next", "throw", "return"]).call(_context, function (method) {
  18034. define(prototype, method, function (arg) {
  18035. return this._invoke(method, arg);
  18036. });
  18037. });
  18038. }
  18039. function AsyncIterator(generator, PromiseImpl) {
  18040. function invoke(method, arg, resolve, reject) {
  18041. var record = tryCatch(generator[method], generator, arg);
  18042. if ("throw" !== record.type) {
  18043. var result = record.arg,
  18044. value = result.value;
  18045. return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  18046. invoke("next", value, resolve, reject);
  18047. }, function (err) {
  18048. invoke("throw", err, resolve, reject);
  18049. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  18050. result.value = unwrapped, resolve(result);
  18051. }, function (error) {
  18052. return invoke("throw", error, resolve, reject);
  18053. });
  18054. }
  18055. reject(record.arg);
  18056. }
  18057. var previousPromise;
  18058. defineProperty(this, "_invoke", {
  18059. value: function value(method, arg) {
  18060. function callInvokeWithMethodAndArg() {
  18061. return new PromiseImpl(function (resolve, reject) {
  18062. invoke(method, arg, resolve, reject);
  18063. });
  18064. }
  18065. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  18066. }
  18067. });
  18068. }
  18069. function makeInvokeMethod(innerFn, self, context) {
  18070. var state = "suspendedStart";
  18071. return function (method, arg) {
  18072. if ("executing" === state) throw new Error("Generator is already running");
  18073. if ("completed" === state) {
  18074. if ("throw" === method) throw arg;
  18075. return doneResult();
  18076. }
  18077. for (context.method = method, context.arg = arg;;) {
  18078. var delegate = context.delegate;
  18079. if (delegate) {
  18080. var delegateResult = maybeInvokeDelegate(delegate, context);
  18081. if (delegateResult) {
  18082. if (delegateResult === ContinueSentinel) continue;
  18083. return delegateResult;
  18084. }
  18085. }
  18086. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  18087. if ("suspendedStart" === state) throw state = "completed", context.arg;
  18088. context.dispatchException(context.arg);
  18089. } else "return" === context.method && context.abrupt("return", context.arg);
  18090. state = "executing";
  18091. var record = tryCatch(innerFn, self, context);
  18092. if ("normal" === record.type) {
  18093. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  18094. return {
  18095. value: record.arg,
  18096. done: context.done
  18097. };
  18098. }
  18099. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  18100. }
  18101. };
  18102. }
  18103. function maybeInvokeDelegate(delegate, context) {
  18104. var methodName = context.method,
  18105. method = delegate.iterator[methodName];
  18106. if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
  18107. var record = tryCatch(method, delegate.iterator, context.arg);
  18108. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  18109. var info = record.arg;
  18110. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  18111. }
  18112. function pushTryEntry(locs) {
  18113. var entry = {
  18114. tryLoc: locs[0]
  18115. };
  18116. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  18117. }
  18118. function resetTryEntry(entry) {
  18119. var record = entry.completion || {};
  18120. record.type = "normal", delete record.arg, entry.completion = record;
  18121. }
  18122. function Context(tryLocsList) {
  18123. this.tryEntries = [{
  18124. tryLoc: "root"
  18125. }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
  18126. }
  18127. function values(iterable) {
  18128. if (iterable) {
  18129. var iteratorMethod = iterable[iteratorSymbol];
  18130. if (iteratorMethod) return iteratorMethod.call(iterable);
  18131. if ("function" == typeof iterable.next) return iterable;
  18132. if (!isNaN(iterable.length)) {
  18133. var i = -1,
  18134. next = function next() {
  18135. for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  18136. return next.value = undefined, next.done = !0, next;
  18137. };
  18138. return next.next = next;
  18139. }
  18140. }
  18141. return {
  18142. next: doneResult
  18143. };
  18144. }
  18145. function doneResult() {
  18146. return {
  18147. value: undefined,
  18148. done: !0
  18149. };
  18150. }
  18151. return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
  18152. value: GeneratorFunctionPrototype,
  18153. configurable: !0
  18154. }), defineProperty(GeneratorFunctionPrototype, "constructor", {
  18155. value: GeneratorFunction,
  18156. configurable: !0
  18157. }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  18158. var ctor = "function" == typeof genFun && genFun.constructor;
  18159. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  18160. }, exports.mark = function (genFun) {
  18161. return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun;
  18162. }, exports.awrap = function (arg) {
  18163. return {
  18164. __await: arg
  18165. };
  18166. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  18167. return this;
  18168. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  18169. void 0 === PromiseImpl && (PromiseImpl = _Promise);
  18170. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  18171. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  18172. return result.done ? result.value : iter.next();
  18173. });
  18174. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  18175. return this;
  18176. }), define(Gp, "toString", function () {
  18177. return "[object Generator]";
  18178. }), exports.keys = function (val) {
  18179. var object = Object(val),
  18180. keys = [];
  18181. for (var key in object) keys.push(key);
  18182. return _reverseInstanceProperty(keys).call(keys), function next() {
  18183. for (; keys.length;) {
  18184. var key = keys.pop();
  18185. if (key in object) return next.value = key, next.done = !1, next;
  18186. }
  18187. return next.done = !0, next;
  18188. };
  18189. }, exports.values = values, Context.prototype = {
  18190. constructor: Context,
  18191. reset: function reset(skipTempReset) {
  18192. var _context2;
  18193. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context2 = this.tryEntries).call(_context2, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined);
  18194. },
  18195. stop: function stop() {
  18196. this.done = !0;
  18197. var rootRecord = this.tryEntries[0].completion;
  18198. if ("throw" === rootRecord.type) throw rootRecord.arg;
  18199. return this.rval;
  18200. },
  18201. dispatchException: function dispatchException(exception) {
  18202. if (this.done) throw exception;
  18203. var context = this;
  18204. function handle(loc, caught) {
  18205. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  18206. }
  18207. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18208. var entry = this.tryEntries[i],
  18209. record = entry.completion;
  18210. if ("root" === entry.tryLoc) return handle("end");
  18211. if (entry.tryLoc <= this.prev) {
  18212. var hasCatch = hasOwn.call(entry, "catchLoc"),
  18213. hasFinally = hasOwn.call(entry, "finallyLoc");
  18214. if (hasCatch && hasFinally) {
  18215. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  18216. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  18217. } else if (hasCatch) {
  18218. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  18219. } else {
  18220. if (!hasFinally) throw new Error("try statement without catch or finally");
  18221. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  18222. }
  18223. }
  18224. }
  18225. },
  18226. abrupt: function abrupt(type, arg) {
  18227. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18228. var entry = this.tryEntries[i];
  18229. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  18230. var finallyEntry = entry;
  18231. break;
  18232. }
  18233. }
  18234. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  18235. var record = finallyEntry ? finallyEntry.completion : {};
  18236. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  18237. },
  18238. complete: function complete(record, afterLoc) {
  18239. if ("throw" === record.type) throw record.arg;
  18240. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  18241. },
  18242. finish: function finish(finallyLoc) {
  18243. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18244. var entry = this.tryEntries[i];
  18245. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  18246. }
  18247. },
  18248. "catch": function _catch(tryLoc) {
  18249. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18250. var entry = this.tryEntries[i];
  18251. if (entry.tryLoc === tryLoc) {
  18252. var record = entry.completion;
  18253. if ("throw" === record.type) {
  18254. var thrown = record.arg;
  18255. resetTryEntry(entry);
  18256. }
  18257. return thrown;
  18258. }
  18259. }
  18260. throw new Error("illegal catch attempt");
  18261. },
  18262. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  18263. return this.delegate = {
  18264. iterator: values(iterable),
  18265. resultName: resultName,
  18266. nextLoc: nextLoc
  18267. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  18268. }
  18269. }, exports;
  18270. }
  18271. module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18272. },{"./typeof.js":144,"@babel/runtime-corejs3/core-js/instance/for-each":101,"@babel/runtime-corejs3/core-js/instance/reverse":103,"@babel/runtime-corejs3/core-js/instance/slice":104,"@babel/runtime-corejs3/core-js/object/create":106,"@babel/runtime-corejs3/core-js/object/define-property":107,"@babel/runtime-corejs3/core-js/object/get-prototype-of":109,"@babel/runtime-corejs3/core-js/object/set-prototype-of":110,"@babel/runtime-corejs3/core-js/promise":111,"@babel/runtime-corejs3/core-js/symbol":114}],138:[function(_dereq_,module,exports){
  18273. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
  18274. var _bindInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/bind");
  18275. function _setPrototypeOf(o, p) {
  18276. var _context;
  18277. module.exports = _setPrototypeOf = _Object$setPrototypeOf ? _bindInstanceProperty(_context = _Object$setPrototypeOf).call(_context) : function _setPrototypeOf(o, p) {
  18278. o.__proto__ = p;
  18279. return o;
  18280. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18281. return _setPrototypeOf(o, p);
  18282. }
  18283. module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18284. },{"@babel/runtime-corejs3/core-js/instance/bind":100,"@babel/runtime-corejs3/core-js/object/set-prototype-of":110}],139:[function(_dereq_,module,exports){
  18285. var arrayWithHoles = _dereq_("./arrayWithHoles.js");
  18286. var iterableToArrayLimit = _dereq_("./iterableToArrayLimit.js");
  18287. var unsupportedIterableToArray = _dereq_("./unsupportedIterableToArray.js");
  18288. var nonIterableRest = _dereq_("./nonIterableRest.js");
  18289. function _slicedToArray(arr, i) {
  18290. return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
  18291. }
  18292. module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18293. },{"./arrayWithHoles.js":118,"./iterableToArrayLimit.js":133,"./nonIterableRest.js":134,"./unsupportedIterableToArray.js":145}],140:[function(_dereq_,module,exports){
  18294. var getPrototypeOf = _dereq_("./getPrototypeOf.js");
  18295. function _superPropBase(object, property) {
  18296. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  18297. object = getPrototypeOf(object);
  18298. if (object === null) break;
  18299. }
  18300. return object;
  18301. }
  18302. module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18303. },{"./getPrototypeOf.js":127}],141:[function(_dereq_,module,exports){
  18304. var arrayWithoutHoles = _dereq_("./arrayWithoutHoles.js");
  18305. var iterableToArray = _dereq_("./iterableToArray.js");
  18306. var unsupportedIterableToArray = _dereq_("./unsupportedIterableToArray.js");
  18307. var nonIterableSpread = _dereq_("./nonIterableSpread.js");
  18308. function _toConsumableArray(arr) {
  18309. return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
  18310. }
  18311. module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18312. },{"./arrayWithoutHoles.js":119,"./iterableToArray.js":132,"./nonIterableSpread.js":135,"./unsupportedIterableToArray.js":145}],142:[function(_dereq_,module,exports){
  18313. var _Symbol$toPrimitive = _dereq_("@babel/runtime-corejs3/core-js/symbol/to-primitive");
  18314. var _typeof = _dereq_("./typeof.js")["default"];
  18315. function _toPrimitive(input, hint) {
  18316. if (_typeof(input) !== "object" || input === null) return input;
  18317. var prim = input[_Symbol$toPrimitive];
  18318. if (prim !== undefined) {
  18319. var res = prim.call(input, hint || "default");
  18320. if (_typeof(res) !== "object") return res;
  18321. throw new TypeError("@@toPrimitive must return a primitive value.");
  18322. }
  18323. return (hint === "string" ? String : Number)(input);
  18324. }
  18325. module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18326. },{"./typeof.js":144,"@babel/runtime-corejs3/core-js/symbol/to-primitive":116}],143:[function(_dereq_,module,exports){
  18327. var _typeof = _dereq_("./typeof.js")["default"];
  18328. var toPrimitive = _dereq_("./toPrimitive.js");
  18329. function _toPropertyKey(arg) {
  18330. var key = toPrimitive(arg, "string");
  18331. return _typeof(key) === "symbol" ? key : String(key);
  18332. }
  18333. module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18334. },{"./toPrimitive.js":142,"./typeof.js":144}],144:[function(_dereq_,module,exports){
  18335. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  18336. var _Symbol$iterator = _dereq_("@babel/runtime-corejs3/core-js/symbol/iterator");
  18337. function _typeof(obj) {
  18338. "@babel/helpers - typeof";
  18339. return (module.exports = _typeof = "function" == typeof _Symbol && "symbol" == typeof _Symbol$iterator ? function (obj) {
  18340. return typeof obj;
  18341. } : function (obj) {
  18342. return obj && "function" == typeof _Symbol && obj.constructor === _Symbol && obj !== _Symbol.prototype ? "symbol" : typeof obj;
  18343. }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
  18344. }
  18345. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18346. },{"@babel/runtime-corejs3/core-js/symbol":114,"@babel/runtime-corejs3/core-js/symbol/iterator":115}],145:[function(_dereq_,module,exports){
  18347. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/slice");
  18348. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js/array/from");
  18349. var arrayLikeToArray = _dereq_("./arrayLikeToArray.js");
  18350. function _unsupportedIterableToArray(o, minLen) {
  18351. var _context;
  18352. if (!o) return;
  18353. if (typeof o === "string") return arrayLikeToArray(o, minLen);
  18354. var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1);
  18355. if (n === "Object" && o.constructor) n = o.constructor.name;
  18356. if (n === "Map" || n === "Set") return _Array$from(o);
  18357. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
  18358. }
  18359. module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18360. },{"./arrayLikeToArray.js":117,"@babel/runtime-corejs3/core-js/array/from":97,"@babel/runtime-corejs3/core-js/instance/slice":104}],146:[function(_dereq_,module,exports){
  18361. var _Map = _dereq_("@babel/runtime-corejs3/core-js/map");
  18362. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
  18363. var getPrototypeOf = _dereq_("./getPrototypeOf.js");
  18364. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  18365. var isNativeFunction = _dereq_("./isNativeFunction.js");
  18366. var construct = _dereq_("./construct.js");
  18367. function _wrapNativeSuper(Class) {
  18368. var _cache = typeof _Map === "function" ? new _Map() : undefined;
  18369. module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) {
  18370. if (Class === null || !isNativeFunction(Class)) return Class;
  18371. if (typeof Class !== "function") {
  18372. throw new TypeError("Super expression must either be null or a function");
  18373. }
  18374. if (typeof _cache !== "undefined") {
  18375. if (_cache.has(Class)) return _cache.get(Class);
  18376. _cache.set(Class, Wrapper);
  18377. }
  18378. function Wrapper() {
  18379. return construct(Class, arguments, getPrototypeOf(this).constructor);
  18380. }
  18381. Wrapper.prototype = _Object$create(Class.prototype, {
  18382. constructor: {
  18383. value: Wrapper,
  18384. enumerable: false,
  18385. writable: true,
  18386. configurable: true
  18387. }
  18388. });
  18389. return setPrototypeOf(Wrapper, Class);
  18390. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18391. return _wrapNativeSuper(Class);
  18392. }
  18393. module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18394. },{"./construct.js":123,"./getPrototypeOf.js":127,"./isNativeFunction.js":130,"./setPrototypeOf.js":138,"@babel/runtime-corejs3/core-js/map":105,"@babel/runtime-corejs3/core-js/object/create":106}],147:[function(_dereq_,module,exports){
  18395. // TODO(Babel 8): Remove this file.
  18396. var runtime = _dereq_("../helpers/regeneratorRuntime")();
  18397. module.exports = runtime;
  18398. // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
  18399. try {
  18400. regeneratorRuntime = runtime;
  18401. } catch (accidentalStrictMode) {
  18402. if (typeof globalThis === "object") {
  18403. globalThis.regeneratorRuntime = runtime;
  18404. } else {
  18405. Function("r", "regeneratorRuntime = r")(runtime);
  18406. }
  18407. }
  18408. },{"../helpers/regeneratorRuntime":137}],148:[function(_dereq_,module,exports){
  18409. },{}],149:[function(_dereq_,module,exports){
  18410. var parent = _dereq_('../../stable/array/from');
  18411. module.exports = parent;
  18412. },{"../../stable/array/from":559}],150:[function(_dereq_,module,exports){
  18413. var parent = _dereq_('../../stable/array/is-array');
  18414. module.exports = parent;
  18415. },{"../../stable/array/is-array":560}],151:[function(_dereq_,module,exports){
  18416. var parent = _dereq_('../stable/get-iterator-method');
  18417. module.exports = parent;
  18418. },{"../stable/get-iterator-method":565}],152:[function(_dereq_,module,exports){
  18419. var parent = _dereq_('../../stable/instance/bind');
  18420. module.exports = parent;
  18421. },{"../../stable/instance/bind":566}],153:[function(_dereq_,module,exports){
  18422. var parent = _dereq_('../../stable/instance/for-each');
  18423. module.exports = parent;
  18424. },{"../../stable/instance/for-each":573}],154:[function(_dereq_,module,exports){
  18425. var parent = _dereq_('../../stable/instance/index-of');
  18426. module.exports = parent;
  18427. },{"../../stable/instance/index-of":575}],155:[function(_dereq_,module,exports){
  18428. var parent = _dereq_('../../stable/instance/reverse');
  18429. module.exports = parent;
  18430. },{"../../stable/instance/reverse":579}],156:[function(_dereq_,module,exports){
  18431. var parent = _dereq_('../../stable/instance/slice');
  18432. module.exports = parent;
  18433. },{"../../stable/instance/slice":580}],157:[function(_dereq_,module,exports){
  18434. var parent = _dereq_('../../stable/map');
  18435. module.exports = parent;
  18436. },{"../../stable/map":586}],158:[function(_dereq_,module,exports){
  18437. var parent = _dereq_('../../stable/object/create');
  18438. module.exports = parent;
  18439. },{"../../stable/object/create":589}],159:[function(_dereq_,module,exports){
  18440. var parent = _dereq_('../../stable/object/define-property');
  18441. module.exports = parent;
  18442. },{"../../stable/object/define-property":591}],160:[function(_dereq_,module,exports){
  18443. var parent = _dereq_('../../stable/object/get-own-property-descriptor');
  18444. module.exports = parent;
  18445. },{"../../stable/object/get-own-property-descriptor":594}],161:[function(_dereq_,module,exports){
  18446. var parent = _dereq_('../../stable/object/get-prototype-of');
  18447. module.exports = parent;
  18448. },{"../../stable/object/get-prototype-of":597}],162:[function(_dereq_,module,exports){
  18449. var parent = _dereq_('../../stable/object/set-prototype-of');
  18450. module.exports = parent;
  18451. },{"../../stable/object/set-prototype-of":599}],163:[function(_dereq_,module,exports){
  18452. var parent = _dereq_('../../stable/promise');
  18453. module.exports = parent;
  18454. },{"../../stable/promise":601}],164:[function(_dereq_,module,exports){
  18455. var parent = _dereq_('../../stable/reflect/construct');
  18456. module.exports = parent;
  18457. },{"../../stable/reflect/construct":602}],165:[function(_dereq_,module,exports){
  18458. var parent = _dereq_('../../stable/reflect/get');
  18459. module.exports = parent;
  18460. },{"../../stable/reflect/get":603}],166:[function(_dereq_,module,exports){
  18461. var parent = _dereq_('../../stable/symbol');
  18462. module.exports = parent;
  18463. },{"../../stable/symbol":607}],167:[function(_dereq_,module,exports){
  18464. var parent = _dereq_('../../stable/symbol/iterator');
  18465. module.exports = parent;
  18466. },{"../../stable/symbol/iterator":608}],168:[function(_dereq_,module,exports){
  18467. var parent = _dereq_('../../stable/symbol/to-primitive');
  18468. module.exports = parent;
  18469. },{"../../stable/symbol/to-primitive":609}],169:[function(_dereq_,module,exports){
  18470. _dereq_('../../modules/es.string.iterator');
  18471. _dereq_('../../modules/es.array.from');
  18472. var path = _dereq_('../../internals/path');
  18473. module.exports = path.Array.from;
  18474. },{"../../internals/path":403,"../../modules/es.array.from":452,"../../modules/es.string.iterator":501}],170:[function(_dereq_,module,exports){
  18475. _dereq_('../../modules/es.array.is-array');
  18476. var path = _dereq_('../../internals/path');
  18477. module.exports = path.Array.isArray;
  18478. },{"../../internals/path":403,"../../modules/es.array.is-array":455}],171:[function(_dereq_,module,exports){
  18479. _dereq_('../../../modules/es.array.concat');
  18480. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18481. module.exports = entryVirtual('Array').concat;
  18482. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.concat":446}],172:[function(_dereq_,module,exports){
  18483. _dereq_('../../../modules/es.array.iterator');
  18484. _dereq_('../../../modules/es.object.to-string');
  18485. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18486. module.exports = entryVirtual('Array').entries;
  18487. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.iterator":456,"../../../modules/es.object.to-string":483}],173:[function(_dereq_,module,exports){
  18488. _dereq_('../../../modules/es.array.every');
  18489. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18490. module.exports = entryVirtual('Array').every;
  18491. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.every":447}],174:[function(_dereq_,module,exports){
  18492. _dereq_('../../../modules/es.array.filter');
  18493. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18494. module.exports = entryVirtual('Array').filter;
  18495. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.filter":448}],175:[function(_dereq_,module,exports){
  18496. _dereq_('../../../modules/es.array.find-index');
  18497. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18498. module.exports = entryVirtual('Array').findIndex;
  18499. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.find-index":449}],176:[function(_dereq_,module,exports){
  18500. _dereq_('../../../modules/es.array.find');
  18501. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18502. module.exports = entryVirtual('Array').find;
  18503. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.find":450}],177:[function(_dereq_,module,exports){
  18504. _dereq_('../../../modules/es.array.for-each');
  18505. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18506. module.exports = entryVirtual('Array').forEach;
  18507. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.for-each":451}],178:[function(_dereq_,module,exports){
  18508. _dereq_('../../../modules/es.array.includes');
  18509. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18510. module.exports = entryVirtual('Array').includes;
  18511. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.includes":453}],179:[function(_dereq_,module,exports){
  18512. _dereq_('../../../modules/es.array.index-of');
  18513. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18514. module.exports = entryVirtual('Array').indexOf;
  18515. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.index-of":454}],180:[function(_dereq_,module,exports){
  18516. _dereq_('../../../modules/es.array.iterator');
  18517. _dereq_('../../../modules/es.object.to-string');
  18518. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18519. module.exports = entryVirtual('Array').keys;
  18520. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.iterator":456,"../../../modules/es.object.to-string":483}],181:[function(_dereq_,module,exports){
  18521. _dereq_('../../../modules/es.array.map');
  18522. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18523. module.exports = entryVirtual('Array').map;
  18524. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.map":457}],182:[function(_dereq_,module,exports){
  18525. _dereq_('../../../modules/es.array.reduce');
  18526. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18527. module.exports = entryVirtual('Array').reduce;
  18528. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.reduce":458}],183:[function(_dereq_,module,exports){
  18529. _dereq_('../../../modules/es.array.reverse');
  18530. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18531. module.exports = entryVirtual('Array').reverse;
  18532. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.reverse":459}],184:[function(_dereq_,module,exports){
  18533. _dereq_('../../../modules/es.array.slice');
  18534. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18535. module.exports = entryVirtual('Array').slice;
  18536. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.slice":460}],185:[function(_dereq_,module,exports){
  18537. _dereq_('../../../modules/es.array.sort');
  18538. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18539. module.exports = entryVirtual('Array').sort;
  18540. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.sort":461}],186:[function(_dereq_,module,exports){
  18541. _dereq_('../../../modules/es.array.splice');
  18542. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18543. module.exports = entryVirtual('Array').splice;
  18544. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.splice":462}],187:[function(_dereq_,module,exports){
  18545. _dereq_('../../../modules/es.array.iterator');
  18546. _dereq_('../../../modules/es.object.to-string');
  18547. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18548. module.exports = entryVirtual('Array').values;
  18549. },{"../../../internals/entry-virtual":327,"../../../modules/es.array.iterator":456,"../../../modules/es.object.to-string":483}],188:[function(_dereq_,module,exports){
  18550. _dereq_('../../../modules/es.function.bind');
  18551. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18552. module.exports = entryVirtual('Function').bind;
  18553. },{"../../../internals/entry-virtual":327,"../../../modules/es.function.bind":464}],189:[function(_dereq_,module,exports){
  18554. _dereq_('../modules/es.array.iterator');
  18555. _dereq_('../modules/es.string.iterator');
  18556. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  18557. module.exports = getIteratorMethod;
  18558. },{"../internals/get-iterator-method":342,"../modules/es.array.iterator":456,"../modules/es.string.iterator":501}],190:[function(_dereq_,module,exports){
  18559. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18560. var method = _dereq_('../function/virtual/bind');
  18561. var FunctionPrototype = Function.prototype;
  18562. module.exports = function (it) {
  18563. var own = it.bind;
  18564. return it === FunctionPrototype || (isPrototypeOf(FunctionPrototype, it) && own === FunctionPrototype.bind) ? method : own;
  18565. };
  18566. },{"../../internals/object-is-prototype-of":394,"../function/virtual/bind":188}],191:[function(_dereq_,module,exports){
  18567. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18568. var method = _dereq_('../array/virtual/concat');
  18569. var ArrayPrototype = Array.prototype;
  18570. module.exports = function (it) {
  18571. var own = it.concat;
  18572. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.concat) ? method : own;
  18573. };
  18574. },{"../../internals/object-is-prototype-of":394,"../array/virtual/concat":171}],192:[function(_dereq_,module,exports){
  18575. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18576. var method = _dereq_('../array/virtual/every');
  18577. var ArrayPrototype = Array.prototype;
  18578. module.exports = function (it) {
  18579. var own = it.every;
  18580. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.every) ? method : own;
  18581. };
  18582. },{"../../internals/object-is-prototype-of":394,"../array/virtual/every":173}],193:[function(_dereq_,module,exports){
  18583. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18584. var method = _dereq_('../array/virtual/filter');
  18585. var ArrayPrototype = Array.prototype;
  18586. module.exports = function (it) {
  18587. var own = it.filter;
  18588. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.filter) ? method : own;
  18589. };
  18590. },{"../../internals/object-is-prototype-of":394,"../array/virtual/filter":174}],194:[function(_dereq_,module,exports){
  18591. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18592. var method = _dereq_('../array/virtual/find-index');
  18593. var ArrayPrototype = Array.prototype;
  18594. module.exports = function (it) {
  18595. var own = it.findIndex;
  18596. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.findIndex) ? method : own;
  18597. };
  18598. },{"../../internals/object-is-prototype-of":394,"../array/virtual/find-index":175}],195:[function(_dereq_,module,exports){
  18599. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18600. var method = _dereq_('../array/virtual/find');
  18601. var ArrayPrototype = Array.prototype;
  18602. module.exports = function (it) {
  18603. var own = it.find;
  18604. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.find) ? method : own;
  18605. };
  18606. },{"../../internals/object-is-prototype-of":394,"../array/virtual/find":176}],196:[function(_dereq_,module,exports){
  18607. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18608. var arrayMethod = _dereq_('../array/virtual/includes');
  18609. var stringMethod = _dereq_('../string/virtual/includes');
  18610. var ArrayPrototype = Array.prototype;
  18611. var StringPrototype = String.prototype;
  18612. module.exports = function (it) {
  18613. var own = it.includes;
  18614. if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.includes)) return arrayMethod;
  18615. if (typeof it == 'string' || it === StringPrototype || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.includes)) {
  18616. return stringMethod;
  18617. } return own;
  18618. };
  18619. },{"../../internals/object-is-prototype-of":394,"../array/virtual/includes":178,"../string/virtual/includes":225}],197:[function(_dereq_,module,exports){
  18620. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18621. var method = _dereq_('../array/virtual/index-of');
  18622. var ArrayPrototype = Array.prototype;
  18623. module.exports = function (it) {
  18624. var own = it.indexOf;
  18625. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.indexOf) ? method : own;
  18626. };
  18627. },{"../../internals/object-is-prototype-of":394,"../array/virtual/index-of":179}],198:[function(_dereq_,module,exports){
  18628. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18629. var method = _dereq_('../array/virtual/map');
  18630. var ArrayPrototype = Array.prototype;
  18631. module.exports = function (it) {
  18632. var own = it.map;
  18633. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.map) ? method : own;
  18634. };
  18635. },{"../../internals/object-is-prototype-of":394,"../array/virtual/map":181}],199:[function(_dereq_,module,exports){
  18636. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18637. var method = _dereq_('../array/virtual/reduce');
  18638. var ArrayPrototype = Array.prototype;
  18639. module.exports = function (it) {
  18640. var own = it.reduce;
  18641. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reduce) ? method : own;
  18642. };
  18643. },{"../../internals/object-is-prototype-of":394,"../array/virtual/reduce":182}],200:[function(_dereq_,module,exports){
  18644. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18645. var method = _dereq_('../array/virtual/reverse');
  18646. var ArrayPrototype = Array.prototype;
  18647. module.exports = function (it) {
  18648. var own = it.reverse;
  18649. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reverse) ? method : own;
  18650. };
  18651. },{"../../internals/object-is-prototype-of":394,"../array/virtual/reverse":183}],201:[function(_dereq_,module,exports){
  18652. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18653. var method = _dereq_('../array/virtual/slice');
  18654. var ArrayPrototype = Array.prototype;
  18655. module.exports = function (it) {
  18656. var own = it.slice;
  18657. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.slice) ? method : own;
  18658. };
  18659. },{"../../internals/object-is-prototype-of":394,"../array/virtual/slice":184}],202:[function(_dereq_,module,exports){
  18660. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18661. var method = _dereq_('../array/virtual/sort');
  18662. var ArrayPrototype = Array.prototype;
  18663. module.exports = function (it) {
  18664. var own = it.sort;
  18665. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.sort) ? method : own;
  18666. };
  18667. },{"../../internals/object-is-prototype-of":394,"../array/virtual/sort":185}],203:[function(_dereq_,module,exports){
  18668. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18669. var method = _dereq_('../array/virtual/splice');
  18670. var ArrayPrototype = Array.prototype;
  18671. module.exports = function (it) {
  18672. var own = it.splice;
  18673. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.splice) ? method : own;
  18674. };
  18675. },{"../../internals/object-is-prototype-of":394,"../array/virtual/splice":186}],204:[function(_dereq_,module,exports){
  18676. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18677. var method = _dereq_('../string/virtual/starts-with');
  18678. var StringPrototype = String.prototype;
  18679. module.exports = function (it) {
  18680. var own = it.startsWith;
  18681. return typeof it == 'string' || it === StringPrototype
  18682. || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.startsWith) ? method : own;
  18683. };
  18684. },{"../../internals/object-is-prototype-of":394,"../string/virtual/starts-with":226}],205:[function(_dereq_,module,exports){
  18685. _dereq_('../../modules/es.json.stringify');
  18686. var path = _dereq_('../../internals/path');
  18687. var apply = _dereq_('../../internals/function-apply');
  18688. // eslint-disable-next-line es-x/no-json -- safe
  18689. if (!path.JSON) path.JSON = { stringify: JSON.stringify };
  18690. // eslint-disable-next-line no-unused-vars -- required for `.length`
  18691. module.exports = function stringify(it, replacer, space) {
  18692. return apply(path.JSON.stringify, null, arguments);
  18693. };
  18694. },{"../../internals/function-apply":334,"../../internals/path":403,"../../modules/es.json.stringify":465}],206:[function(_dereq_,module,exports){
  18695. _dereq_('../../modules/es.array.iterator');
  18696. _dereq_('../../modules/es.map');
  18697. _dereq_('../../modules/es.object.to-string');
  18698. _dereq_('../../modules/es.string.iterator');
  18699. var path = _dereq_('../../internals/path');
  18700. module.exports = path.Map;
  18701. },{"../../internals/path":403,"../../modules/es.array.iterator":456,"../../modules/es.map":468,"../../modules/es.object.to-string":483,"../../modules/es.string.iterator":501}],207:[function(_dereq_,module,exports){
  18702. _dereq_('../../modules/es.number.is-integer');
  18703. var path = _dereq_('../../internals/path');
  18704. module.exports = path.Number.isInteger;
  18705. },{"../../internals/path":403,"../../modules/es.number.is-integer":470}],208:[function(_dereq_,module,exports){
  18706. _dereq_('../../modules/es.object.assign');
  18707. var path = _dereq_('../../internals/path');
  18708. module.exports = path.Object.assign;
  18709. },{"../../internals/path":403,"../../modules/es.object.assign":471}],209:[function(_dereq_,module,exports){
  18710. _dereq_('../../modules/es.object.create');
  18711. var path = _dereq_('../../internals/path');
  18712. var Object = path.Object;
  18713. module.exports = function create(P, D) {
  18714. return Object.create(P, D);
  18715. };
  18716. },{"../../internals/path":403,"../../modules/es.object.create":472}],210:[function(_dereq_,module,exports){
  18717. _dereq_('../../modules/es.object.define-properties');
  18718. var path = _dereq_('../../internals/path');
  18719. var Object = path.Object;
  18720. var defineProperties = module.exports = function defineProperties(T, D) {
  18721. return Object.defineProperties(T, D);
  18722. };
  18723. if (Object.defineProperties.sham) defineProperties.sham = true;
  18724. },{"../../internals/path":403,"../../modules/es.object.define-properties":473}],211:[function(_dereq_,module,exports){
  18725. _dereq_('../../modules/es.object.define-property');
  18726. var path = _dereq_('../../internals/path');
  18727. var Object = path.Object;
  18728. var defineProperty = module.exports = function defineProperty(it, key, desc) {
  18729. return Object.defineProperty(it, key, desc);
  18730. };
  18731. if (Object.defineProperty.sham) defineProperty.sham = true;
  18732. },{"../../internals/path":403,"../../modules/es.object.define-property":474}],212:[function(_dereq_,module,exports){
  18733. _dereq_('../../modules/es.object.entries');
  18734. var path = _dereq_('../../internals/path');
  18735. module.exports = path.Object.entries;
  18736. },{"../../internals/path":403,"../../modules/es.object.entries":475}],213:[function(_dereq_,module,exports){
  18737. _dereq_('../../modules/es.object.freeze');
  18738. var path = _dereq_('../../internals/path');
  18739. module.exports = path.Object.freeze;
  18740. },{"../../internals/path":403,"../../modules/es.object.freeze":476}],214:[function(_dereq_,module,exports){
  18741. _dereq_('../../modules/es.object.get-own-property-descriptor');
  18742. var path = _dereq_('../../internals/path');
  18743. var Object = path.Object;
  18744. var getOwnPropertyDescriptor = module.exports = function getOwnPropertyDescriptor(it, key) {
  18745. return Object.getOwnPropertyDescriptor(it, key);
  18746. };
  18747. if (Object.getOwnPropertyDescriptor.sham) getOwnPropertyDescriptor.sham = true;
  18748. },{"../../internals/path":403,"../../modules/es.object.get-own-property-descriptor":477}],215:[function(_dereq_,module,exports){
  18749. _dereq_('../../modules/es.object.get-own-property-descriptors');
  18750. var path = _dereq_('../../internals/path');
  18751. module.exports = path.Object.getOwnPropertyDescriptors;
  18752. },{"../../internals/path":403,"../../modules/es.object.get-own-property-descriptors":478}],216:[function(_dereq_,module,exports){
  18753. _dereq_('../../modules/es.symbol');
  18754. var path = _dereq_('../../internals/path');
  18755. module.exports = path.Object.getOwnPropertySymbols;
  18756. },{"../../internals/path":403,"../../modules/es.symbol":510}],217:[function(_dereq_,module,exports){
  18757. _dereq_('../../modules/es.object.get-prototype-of');
  18758. var path = _dereq_('../../internals/path');
  18759. module.exports = path.Object.getPrototypeOf;
  18760. },{"../../internals/path":403,"../../modules/es.object.get-prototype-of":480}],218:[function(_dereq_,module,exports){
  18761. _dereq_('../../modules/es.object.keys');
  18762. var path = _dereq_('../../internals/path');
  18763. module.exports = path.Object.keys;
  18764. },{"../../internals/path":403,"../../modules/es.object.keys":481}],219:[function(_dereq_,module,exports){
  18765. _dereq_('../../modules/es.object.set-prototype-of');
  18766. var path = _dereq_('../../internals/path');
  18767. module.exports = path.Object.setPrototypeOf;
  18768. },{"../../internals/path":403,"../../modules/es.object.set-prototype-of":482}],220:[function(_dereq_,module,exports){
  18769. _dereq_('../modules/es.parse-int');
  18770. var path = _dereq_('../internals/path');
  18771. module.exports = path.parseInt;
  18772. },{"../internals/path":403,"../modules/es.parse-int":484}],221:[function(_dereq_,module,exports){
  18773. _dereq_('../../modules/es.aggregate-error');
  18774. _dereq_('../../modules/es.array.iterator');
  18775. _dereq_('../../modules/es.object.to-string');
  18776. _dereq_('../../modules/es.promise');
  18777. _dereq_('../../modules/es.promise.all-settled');
  18778. _dereq_('../../modules/es.promise.any');
  18779. _dereq_('../../modules/es.promise.finally');
  18780. _dereq_('../../modules/es.string.iterator');
  18781. var path = _dereq_('../../internals/path');
  18782. module.exports = path.Promise;
  18783. },{"../../internals/path":403,"../../modules/es.aggregate-error":445,"../../modules/es.array.iterator":456,"../../modules/es.object.to-string":483,"../../modules/es.promise":491,"../../modules/es.promise.all-settled":485,"../../modules/es.promise.any":487,"../../modules/es.promise.finally":490,"../../modules/es.string.iterator":501}],222:[function(_dereq_,module,exports){
  18784. _dereq_('../../modules/es.reflect.construct');
  18785. var path = _dereq_('../../internals/path');
  18786. module.exports = path.Reflect.construct;
  18787. },{"../../internals/path":403,"../../modules/es.reflect.construct":495}],223:[function(_dereq_,module,exports){
  18788. _dereq_('../../modules/es.reflect.get');
  18789. var path = _dereq_('../../internals/path');
  18790. module.exports = path.Reflect.get;
  18791. },{"../../internals/path":403,"../../modules/es.reflect.get":496}],224:[function(_dereq_,module,exports){
  18792. _dereq_('../../modules/es.array.iterator');
  18793. _dereq_('../../modules/es.object.to-string');
  18794. _dereq_('../../modules/es.set');
  18795. _dereq_('../../modules/es.string.iterator');
  18796. var path = _dereq_('../../internals/path');
  18797. module.exports = path.Set;
  18798. },{"../../internals/path":403,"../../modules/es.array.iterator":456,"../../modules/es.object.to-string":483,"../../modules/es.set":499,"../../modules/es.string.iterator":501}],225:[function(_dereq_,module,exports){
  18799. _dereq_('../../../modules/es.string.includes');
  18800. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18801. module.exports = entryVirtual('String').includes;
  18802. },{"../../../internals/entry-virtual":327,"../../../modules/es.string.includes":500}],226:[function(_dereq_,module,exports){
  18803. _dereq_('../../../modules/es.string.starts-with');
  18804. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18805. module.exports = entryVirtual('String').startsWith;
  18806. },{"../../../internals/entry-virtual":327,"../../../modules/es.string.starts-with":502}],227:[function(_dereq_,module,exports){
  18807. _dereq_('../../modules/es.array.concat');
  18808. _dereq_('../../modules/es.object.to-string');
  18809. _dereq_('../../modules/es.symbol');
  18810. _dereq_('../../modules/es.symbol.async-iterator');
  18811. _dereq_('../../modules/es.symbol.description');
  18812. _dereq_('../../modules/es.symbol.has-instance');
  18813. _dereq_('../../modules/es.symbol.is-concat-spreadable');
  18814. _dereq_('../../modules/es.symbol.iterator');
  18815. _dereq_('../../modules/es.symbol.match');
  18816. _dereq_('../../modules/es.symbol.match-all');
  18817. _dereq_('../../modules/es.symbol.replace');
  18818. _dereq_('../../modules/es.symbol.search');
  18819. _dereq_('../../modules/es.symbol.species');
  18820. _dereq_('../../modules/es.symbol.split');
  18821. _dereq_('../../modules/es.symbol.to-primitive');
  18822. _dereq_('../../modules/es.symbol.to-string-tag');
  18823. _dereq_('../../modules/es.symbol.unscopables');
  18824. _dereq_('../../modules/es.json.to-string-tag');
  18825. _dereq_('../../modules/es.math.to-string-tag');
  18826. _dereq_('../../modules/es.reflect.to-string-tag');
  18827. var path = _dereq_('../../internals/path');
  18828. module.exports = path.Symbol;
  18829. },{"../../internals/path":403,"../../modules/es.array.concat":446,"../../modules/es.json.to-string-tag":466,"../../modules/es.math.to-string-tag":469,"../../modules/es.object.to-string":483,"../../modules/es.reflect.to-string-tag":497,"../../modules/es.symbol":510,"../../modules/es.symbol.async-iterator":503,"../../modules/es.symbol.description":505,"../../modules/es.symbol.has-instance":507,"../../modules/es.symbol.is-concat-spreadable":508,"../../modules/es.symbol.iterator":509,"../../modules/es.symbol.match":513,"../../modules/es.symbol.match-all":512,"../../modules/es.symbol.replace":514,"../../modules/es.symbol.search":515,"../../modules/es.symbol.species":516,"../../modules/es.symbol.split":517,"../../modules/es.symbol.to-primitive":518,"../../modules/es.symbol.to-string-tag":519,"../../modules/es.symbol.unscopables":520}],228:[function(_dereq_,module,exports){
  18830. _dereq_('../../modules/es.array.iterator');
  18831. _dereq_('../../modules/es.object.to-string');
  18832. _dereq_('../../modules/es.string.iterator');
  18833. _dereq_('../../modules/es.symbol.iterator');
  18834. var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
  18835. module.exports = WrappedWellKnownSymbolModule.f('iterator');
  18836. },{"../../internals/well-known-symbol-wrapped":441,"../../modules/es.array.iterator":456,"../../modules/es.object.to-string":483,"../../modules/es.string.iterator":501,"../../modules/es.symbol.iterator":509}],229:[function(_dereq_,module,exports){
  18837. _dereq_('../../modules/es.date.to-primitive');
  18838. _dereq_('../../modules/es.symbol.to-primitive');
  18839. var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
  18840. module.exports = WrappedWellKnownSymbolModule.f('toPrimitive');
  18841. },{"../../internals/well-known-symbol-wrapped":441,"../../modules/es.date.to-primitive":463,"../../modules/es.symbol.to-primitive":518}],230:[function(_dereq_,module,exports){
  18842. _dereq_('../../modules/es.array.iterator');
  18843. _dereq_('../../modules/es.object.to-string');
  18844. _dereq_('../../modules/es.weak-map');
  18845. var path = _dereq_('../../internals/path');
  18846. module.exports = path.WeakMap;
  18847. },{"../../internals/path":403,"../../modules/es.array.iterator":456,"../../modules/es.object.to-string":483,"../../modules/es.weak-map":522}],231:[function(_dereq_,module,exports){
  18848. module.exports = _dereq_('../../full/array/from');
  18849. },{"../../full/array/from":251}],232:[function(_dereq_,module,exports){
  18850. module.exports = _dereq_('../../full/array/is-array');
  18851. },{"../../full/array/is-array":252}],233:[function(_dereq_,module,exports){
  18852. module.exports = _dereq_('../full/get-iterator-method');
  18853. },{"../full/get-iterator-method":253}],234:[function(_dereq_,module,exports){
  18854. module.exports = _dereq_('../../full/instance/bind');
  18855. },{"../../full/instance/bind":254}],235:[function(_dereq_,module,exports){
  18856. module.exports = _dereq_('../../full/instance/for-each');
  18857. },{"../../full/instance/for-each":255}],236:[function(_dereq_,module,exports){
  18858. module.exports = _dereq_('../../full/instance/index-of');
  18859. },{"../../full/instance/index-of":256}],237:[function(_dereq_,module,exports){
  18860. module.exports = _dereq_('../../full/instance/reverse');
  18861. },{"../../full/instance/reverse":257}],238:[function(_dereq_,module,exports){
  18862. module.exports = _dereq_('../../full/instance/slice');
  18863. },{"../../full/instance/slice":258}],239:[function(_dereq_,module,exports){
  18864. module.exports = _dereq_('../../full/map');
  18865. },{"../../full/map":259}],240:[function(_dereq_,module,exports){
  18866. module.exports = _dereq_('../../full/object/create');
  18867. },{"../../full/object/create":260}],241:[function(_dereq_,module,exports){
  18868. module.exports = _dereq_('../../full/object/define-property');
  18869. },{"../../full/object/define-property":261}],242:[function(_dereq_,module,exports){
  18870. module.exports = _dereq_('../../full/object/get-own-property-descriptor');
  18871. },{"../../full/object/get-own-property-descriptor":262}],243:[function(_dereq_,module,exports){
  18872. module.exports = _dereq_('../../full/object/get-prototype-of');
  18873. },{"../../full/object/get-prototype-of":263}],244:[function(_dereq_,module,exports){
  18874. module.exports = _dereq_('../../full/object/set-prototype-of');
  18875. },{"../../full/object/set-prototype-of":264}],245:[function(_dereq_,module,exports){
  18876. module.exports = _dereq_('../../full/promise');
  18877. },{"../../full/promise":265}],246:[function(_dereq_,module,exports){
  18878. module.exports = _dereq_('../../full/reflect/construct');
  18879. },{"../../full/reflect/construct":266}],247:[function(_dereq_,module,exports){
  18880. module.exports = _dereq_('../../full/reflect/get');
  18881. },{"../../full/reflect/get":267}],248:[function(_dereq_,module,exports){
  18882. module.exports = _dereq_('../../full/symbol');
  18883. },{"../../full/symbol":268}],249:[function(_dereq_,module,exports){
  18884. module.exports = _dereq_('../../full/symbol/iterator');
  18885. },{"../../full/symbol/iterator":269}],250:[function(_dereq_,module,exports){
  18886. module.exports = _dereq_('../../full/symbol/to-primitive');
  18887. },{"../../full/symbol/to-primitive":270}],251:[function(_dereq_,module,exports){
  18888. var parent = _dereq_('../../actual/array/from');
  18889. module.exports = parent;
  18890. },{"../../actual/array/from":149}],252:[function(_dereq_,module,exports){
  18891. var parent = _dereq_('../../actual/array/is-array');
  18892. module.exports = parent;
  18893. },{"../../actual/array/is-array":150}],253:[function(_dereq_,module,exports){
  18894. var parent = _dereq_('../actual/get-iterator-method');
  18895. module.exports = parent;
  18896. },{"../actual/get-iterator-method":151}],254:[function(_dereq_,module,exports){
  18897. var parent = _dereq_('../../actual/instance/bind');
  18898. module.exports = parent;
  18899. },{"../../actual/instance/bind":152}],255:[function(_dereq_,module,exports){
  18900. var parent = _dereq_('../../actual/instance/for-each');
  18901. module.exports = parent;
  18902. },{"../../actual/instance/for-each":153}],256:[function(_dereq_,module,exports){
  18903. var parent = _dereq_('../../actual/instance/index-of');
  18904. module.exports = parent;
  18905. },{"../../actual/instance/index-of":154}],257:[function(_dereq_,module,exports){
  18906. var parent = _dereq_('../../actual/instance/reverse');
  18907. module.exports = parent;
  18908. },{"../../actual/instance/reverse":155}],258:[function(_dereq_,module,exports){
  18909. var parent = _dereq_('../../actual/instance/slice');
  18910. module.exports = parent;
  18911. },{"../../actual/instance/slice":156}],259:[function(_dereq_,module,exports){
  18912. var parent = _dereq_('../../actual/map');
  18913. _dereq_('../../modules/esnext.map.from');
  18914. _dereq_('../../modules/esnext.map.of');
  18915. _dereq_('../../modules/esnext.map.delete-all');
  18916. _dereq_('../../modules/esnext.map.emplace');
  18917. _dereq_('../../modules/esnext.map.every');
  18918. _dereq_('../../modules/esnext.map.filter');
  18919. _dereq_('../../modules/esnext.map.find');
  18920. _dereq_('../../modules/esnext.map.find-key');
  18921. _dereq_('../../modules/esnext.map.group-by');
  18922. _dereq_('../../modules/esnext.map.includes');
  18923. _dereq_('../../modules/esnext.map.key-by');
  18924. _dereq_('../../modules/esnext.map.key-of');
  18925. _dereq_('../../modules/esnext.map.map-keys');
  18926. _dereq_('../../modules/esnext.map.map-values');
  18927. _dereq_('../../modules/esnext.map.merge');
  18928. _dereq_('../../modules/esnext.map.reduce');
  18929. _dereq_('../../modules/esnext.map.some');
  18930. _dereq_('../../modules/esnext.map.update');
  18931. // TODO: remove from `core-js@4`
  18932. _dereq_('../../modules/esnext.map.upsert');
  18933. // TODO: remove from `core-js@4`
  18934. _dereq_('../../modules/esnext.map.update-or-insert');
  18935. module.exports = parent;
  18936. },{"../../actual/map":157,"../../modules/esnext.map.delete-all":524,"../../modules/esnext.map.emplace":525,"../../modules/esnext.map.every":526,"../../modules/esnext.map.filter":527,"../../modules/esnext.map.find":529,"../../modules/esnext.map.find-key":528,"../../modules/esnext.map.from":530,"../../modules/esnext.map.group-by":531,"../../modules/esnext.map.includes":532,"../../modules/esnext.map.key-by":533,"../../modules/esnext.map.key-of":534,"../../modules/esnext.map.map-keys":535,"../../modules/esnext.map.map-values":536,"../../modules/esnext.map.merge":537,"../../modules/esnext.map.of":538,"../../modules/esnext.map.reduce":539,"../../modules/esnext.map.some":540,"../../modules/esnext.map.update":542,"../../modules/esnext.map.update-or-insert":541,"../../modules/esnext.map.upsert":543}],260:[function(_dereq_,module,exports){
  18937. var parent = _dereq_('../../actual/object/create');
  18938. module.exports = parent;
  18939. },{"../../actual/object/create":158}],261:[function(_dereq_,module,exports){
  18940. var parent = _dereq_('../../actual/object/define-property');
  18941. module.exports = parent;
  18942. },{"../../actual/object/define-property":159}],262:[function(_dereq_,module,exports){
  18943. var parent = _dereq_('../../actual/object/get-own-property-descriptor');
  18944. module.exports = parent;
  18945. },{"../../actual/object/get-own-property-descriptor":160}],263:[function(_dereq_,module,exports){
  18946. var parent = _dereq_('../../actual/object/get-prototype-of');
  18947. module.exports = parent;
  18948. },{"../../actual/object/get-prototype-of":161}],264:[function(_dereq_,module,exports){
  18949. var parent = _dereq_('../../actual/object/set-prototype-of');
  18950. module.exports = parent;
  18951. },{"../../actual/object/set-prototype-of":162}],265:[function(_dereq_,module,exports){
  18952. var parent = _dereq_('../../actual/promise');
  18953. _dereq_('../../modules/esnext.aggregate-error');
  18954. // TODO: Remove from `core-js@4`
  18955. _dereq_('../../modules/esnext.promise.all-settled');
  18956. _dereq_('../../modules/esnext.promise.try');
  18957. _dereq_('../../modules/esnext.promise.any');
  18958. module.exports = parent;
  18959. },{"../../actual/promise":163,"../../modules/esnext.aggregate-error":523,"../../modules/esnext.promise.all-settled":544,"../../modules/esnext.promise.any":545,"../../modules/esnext.promise.try":546}],266:[function(_dereq_,module,exports){
  18960. var parent = _dereq_('../../actual/reflect/construct');
  18961. module.exports = parent;
  18962. },{"../../actual/reflect/construct":164}],267:[function(_dereq_,module,exports){
  18963. var parent = _dereq_('../../actual/reflect/get');
  18964. module.exports = parent;
  18965. },{"../../actual/reflect/get":165}],268:[function(_dereq_,module,exports){
  18966. var parent = _dereq_('../../actual/symbol');
  18967. _dereq_('../../modules/esnext.symbol.async-dispose');
  18968. _dereq_('../../modules/esnext.symbol.dispose');
  18969. _dereq_('../../modules/esnext.symbol.matcher');
  18970. _dereq_('../../modules/esnext.symbol.metadata-key');
  18971. _dereq_('../../modules/esnext.symbol.observable');
  18972. // TODO: Remove from `core-js@4`
  18973. _dereq_('../../modules/esnext.symbol.metadata');
  18974. _dereq_('../../modules/esnext.symbol.pattern-match');
  18975. _dereq_('../../modules/esnext.symbol.replace-all');
  18976. module.exports = parent;
  18977. },{"../../actual/symbol":166,"../../modules/esnext.symbol.async-dispose":547,"../../modules/esnext.symbol.dispose":548,"../../modules/esnext.symbol.matcher":549,"../../modules/esnext.symbol.metadata":551,"../../modules/esnext.symbol.metadata-key":550,"../../modules/esnext.symbol.observable":552,"../../modules/esnext.symbol.pattern-match":553,"../../modules/esnext.symbol.replace-all":554}],269:[function(_dereq_,module,exports){
  18978. var parent = _dereq_('../../actual/symbol/iterator');
  18979. module.exports = parent;
  18980. },{"../../actual/symbol/iterator":167}],270:[function(_dereq_,module,exports){
  18981. var parent = _dereq_('../../actual/symbol/to-primitive');
  18982. module.exports = parent;
  18983. },{"../../actual/symbol/to-primitive":168}],271:[function(_dereq_,module,exports){
  18984. var isCallable = _dereq_('../internals/is-callable');
  18985. var tryToString = _dereq_('../internals/try-to-string');
  18986. var $TypeError = TypeError;
  18987. // `Assert: IsCallable(argument) is true`
  18988. module.exports = function (argument) {
  18989. if (isCallable(argument)) return argument;
  18990. throw $TypeError(tryToString(argument) + ' is not a function');
  18991. };
  18992. },{"../internals/is-callable":359,"../internals/try-to-string":434}],272:[function(_dereq_,module,exports){
  18993. var isConstructor = _dereq_('../internals/is-constructor');
  18994. var tryToString = _dereq_('../internals/try-to-string');
  18995. var $TypeError = TypeError;
  18996. // `Assert: IsConstructor(argument) is true`
  18997. module.exports = function (argument) {
  18998. if (isConstructor(argument)) return argument;
  18999. throw $TypeError(tryToString(argument) + ' is not a constructor');
  19000. };
  19001. },{"../internals/is-constructor":360,"../internals/try-to-string":434}],273:[function(_dereq_,module,exports){
  19002. var isCallable = _dereq_('../internals/is-callable');
  19003. var $String = String;
  19004. var $TypeError = TypeError;
  19005. module.exports = function (argument) {
  19006. if (typeof argument == 'object' || isCallable(argument)) return argument;
  19007. throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
  19008. };
  19009. },{"../internals/is-callable":359}],274:[function(_dereq_,module,exports){
  19010. module.exports = function () { /* empty */ };
  19011. },{}],275:[function(_dereq_,module,exports){
  19012. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  19013. var $TypeError = TypeError;
  19014. module.exports = function (it, Prototype) {
  19015. if (isPrototypeOf(Prototype, it)) return it;
  19016. throw $TypeError('Incorrect invocation');
  19017. };
  19018. },{"../internals/object-is-prototype-of":394}],276:[function(_dereq_,module,exports){
  19019. var isObject = _dereq_('../internals/is-object');
  19020. var $String = String;
  19021. var $TypeError = TypeError;
  19022. // `Assert: Type(argument) is Object`
  19023. module.exports = function (argument) {
  19024. if (isObject(argument)) return argument;
  19025. throw $TypeError($String(argument) + ' is not an object');
  19026. };
  19027. },{"../internals/is-object":365}],277:[function(_dereq_,module,exports){
  19028. // FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it
  19029. var fails = _dereq_('../internals/fails');
  19030. module.exports = fails(function () {
  19031. if (typeof ArrayBuffer == 'function') {
  19032. var buffer = new ArrayBuffer(8);
  19033. // eslint-disable-next-line es-x/no-object-isextensible, es-x/no-object-defineproperty -- safe
  19034. if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', { value: 8 });
  19035. }
  19036. });
  19037. },{"../internals/fails":332}],278:[function(_dereq_,module,exports){
  19038. 'use strict';
  19039. var $forEach = _dereq_('../internals/array-iteration').forEach;
  19040. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  19041. var STRICT_METHOD = arrayMethodIsStrict('forEach');
  19042. // `Array.prototype.forEach` method implementation
  19043. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  19044. module.exports = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {
  19045. return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19046. // eslint-disable-next-line es-x/no-array-prototype-foreach -- safe
  19047. } : [].forEach;
  19048. },{"../internals/array-iteration":281,"../internals/array-method-is-strict":283}],279:[function(_dereq_,module,exports){
  19049. 'use strict';
  19050. var bind = _dereq_('../internals/function-bind-context');
  19051. var call = _dereq_('../internals/function-call');
  19052. var toObject = _dereq_('../internals/to-object');
  19053. var callWithSafeIterationClosing = _dereq_('../internals/call-with-safe-iteration-closing');
  19054. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  19055. var isConstructor = _dereq_('../internals/is-constructor');
  19056. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19057. var createProperty = _dereq_('../internals/create-property');
  19058. var getIterator = _dereq_('../internals/get-iterator');
  19059. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  19060. var $Array = Array;
  19061. // `Array.from` method implementation
  19062. // https://tc39.es/ecma262/#sec-array.from
  19063. module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  19064. var O = toObject(arrayLike);
  19065. var IS_CONSTRUCTOR = isConstructor(this);
  19066. var argumentsLength = arguments.length;
  19067. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  19068. var mapping = mapfn !== undefined;
  19069. if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
  19070. var iteratorMethod = getIteratorMethod(O);
  19071. var index = 0;
  19072. var length, result, step, iterator, next, value;
  19073. // if the target is not iterable or it's an array with the default iterator - use a simple case
  19074. if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) {
  19075. iterator = getIterator(O, iteratorMethod);
  19076. next = iterator.next;
  19077. result = IS_CONSTRUCTOR ? new this() : [];
  19078. for (;!(step = call(next, iterator)).done; index++) {
  19079. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
  19080. createProperty(result, index, value);
  19081. }
  19082. } else {
  19083. length = lengthOfArrayLike(O);
  19084. result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
  19085. for (;length > index; index++) {
  19086. value = mapping ? mapfn(O[index], index) : O[index];
  19087. createProperty(result, index, value);
  19088. }
  19089. }
  19090. result.length = index;
  19091. return result;
  19092. };
  19093. },{"../internals/call-with-safe-iteration-closing":291,"../internals/create-property":307,"../internals/function-bind-context":335,"../internals/function-call":338,"../internals/get-iterator":343,"../internals/get-iterator-method":342,"../internals/is-array-iterator-method":357,"../internals/is-constructor":360,"../internals/length-of-array-like":375,"../internals/to-object":429}],280:[function(_dereq_,module,exports){
  19094. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  19095. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  19096. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19097. // `Array.prototype.{ indexOf, includes }` methods implementation
  19098. var createMethod = function (IS_INCLUDES) {
  19099. return function ($this, el, fromIndex) {
  19100. var O = toIndexedObject($this);
  19101. var length = lengthOfArrayLike(O);
  19102. var index = toAbsoluteIndex(fromIndex, length);
  19103. var value;
  19104. // Array#includes uses SameValueZero equality algorithm
  19105. // eslint-disable-next-line no-self-compare -- NaN check
  19106. if (IS_INCLUDES && el != el) while (length > index) {
  19107. value = O[index++];
  19108. // eslint-disable-next-line no-self-compare -- NaN check
  19109. if (value != value) return true;
  19110. // Array#indexOf ignores holes, Array#includes - not
  19111. } else for (;length > index; index++) {
  19112. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  19113. } return !IS_INCLUDES && -1;
  19114. };
  19115. };
  19116. module.exports = {
  19117. // `Array.prototype.includes` method
  19118. // https://tc39.es/ecma262/#sec-array.prototype.includes
  19119. includes: createMethod(true),
  19120. // `Array.prototype.indexOf` method
  19121. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  19122. indexOf: createMethod(false)
  19123. };
  19124. },{"../internals/length-of-array-like":375,"../internals/to-absolute-index":425,"../internals/to-indexed-object":426}],281:[function(_dereq_,module,exports){
  19125. var bind = _dereq_('../internals/function-bind-context');
  19126. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19127. var IndexedObject = _dereq_('../internals/indexed-object');
  19128. var toObject = _dereq_('../internals/to-object');
  19129. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19130. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  19131. var push = uncurryThis([].push);
  19132. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
  19133. var createMethod = function (TYPE) {
  19134. var IS_MAP = TYPE == 1;
  19135. var IS_FILTER = TYPE == 2;
  19136. var IS_SOME = TYPE == 3;
  19137. var IS_EVERY = TYPE == 4;
  19138. var IS_FIND_INDEX = TYPE == 6;
  19139. var IS_FILTER_REJECT = TYPE == 7;
  19140. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  19141. return function ($this, callbackfn, that, specificCreate) {
  19142. var O = toObject($this);
  19143. var self = IndexedObject(O);
  19144. var boundFunction = bind(callbackfn, that);
  19145. var length = lengthOfArrayLike(self);
  19146. var index = 0;
  19147. var create = specificCreate || arraySpeciesCreate;
  19148. var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
  19149. var value, result;
  19150. for (;length > index; index++) if (NO_HOLES || index in self) {
  19151. value = self[index];
  19152. result = boundFunction(value, index, O);
  19153. if (TYPE) {
  19154. if (IS_MAP) target[index] = result; // map
  19155. else if (result) switch (TYPE) {
  19156. case 3: return true; // some
  19157. case 5: return value; // find
  19158. case 6: return index; // findIndex
  19159. case 2: push(target, value); // filter
  19160. } else switch (TYPE) {
  19161. case 4: return false; // every
  19162. case 7: push(target, value); // filterReject
  19163. }
  19164. }
  19165. }
  19166. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  19167. };
  19168. };
  19169. module.exports = {
  19170. // `Array.prototype.forEach` method
  19171. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  19172. forEach: createMethod(0),
  19173. // `Array.prototype.map` method
  19174. // https://tc39.es/ecma262/#sec-array.prototype.map
  19175. map: createMethod(1),
  19176. // `Array.prototype.filter` method
  19177. // https://tc39.es/ecma262/#sec-array.prototype.filter
  19178. filter: createMethod(2),
  19179. // `Array.prototype.some` method
  19180. // https://tc39.es/ecma262/#sec-array.prototype.some
  19181. some: createMethod(3),
  19182. // `Array.prototype.every` method
  19183. // https://tc39.es/ecma262/#sec-array.prototype.every
  19184. every: createMethod(4),
  19185. // `Array.prototype.find` method
  19186. // https://tc39.es/ecma262/#sec-array.prototype.find
  19187. find: createMethod(5),
  19188. // `Array.prototype.findIndex` method
  19189. // https://tc39.es/ecma262/#sec-array.prototype.findIndex
  19190. findIndex: createMethod(6),
  19191. // `Array.prototype.filterReject` method
  19192. // https://github.com/tc39/proposal-array-filtering
  19193. filterReject: createMethod(7)
  19194. };
  19195. },{"../internals/array-species-create":290,"../internals/function-bind-context":335,"../internals/function-uncurry-this":340,"../internals/indexed-object":352,"../internals/length-of-array-like":375,"../internals/to-object":429}],282:[function(_dereq_,module,exports){
  19196. var fails = _dereq_('../internals/fails');
  19197. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19198. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  19199. var SPECIES = wellKnownSymbol('species');
  19200. module.exports = function (METHOD_NAME) {
  19201. // We can't use this feature detection in V8 since it causes
  19202. // deoptimization and serious performance degradation
  19203. // https://github.com/zloirock/core-js/issues/677
  19204. return V8_VERSION >= 51 || !fails(function () {
  19205. var array = [];
  19206. var constructor = array.constructor = {};
  19207. constructor[SPECIES] = function () {
  19208. return { foo: 1 };
  19209. };
  19210. return array[METHOD_NAME](Boolean).foo !== 1;
  19211. });
  19212. };
  19213. },{"../internals/engine-v8-version":325,"../internals/fails":332,"../internals/well-known-symbol":442}],283:[function(_dereq_,module,exports){
  19214. 'use strict';
  19215. var fails = _dereq_('../internals/fails');
  19216. module.exports = function (METHOD_NAME, argument) {
  19217. var method = [][METHOD_NAME];
  19218. return !!method && fails(function () {
  19219. // eslint-disable-next-line no-useless-call -- required for testing
  19220. method.call(null, argument || function () { return 1; }, 1);
  19221. });
  19222. };
  19223. },{"../internals/fails":332}],284:[function(_dereq_,module,exports){
  19224. var aCallable = _dereq_('../internals/a-callable');
  19225. var toObject = _dereq_('../internals/to-object');
  19226. var IndexedObject = _dereq_('../internals/indexed-object');
  19227. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19228. var $TypeError = TypeError;
  19229. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  19230. var createMethod = function (IS_RIGHT) {
  19231. return function (that, callbackfn, argumentsLength, memo) {
  19232. aCallable(callbackfn);
  19233. var O = toObject(that);
  19234. var self = IndexedObject(O);
  19235. var length = lengthOfArrayLike(O);
  19236. var index = IS_RIGHT ? length - 1 : 0;
  19237. var i = IS_RIGHT ? -1 : 1;
  19238. if (argumentsLength < 2) while (true) {
  19239. if (index in self) {
  19240. memo = self[index];
  19241. index += i;
  19242. break;
  19243. }
  19244. index += i;
  19245. if (IS_RIGHT ? index < 0 : length <= index) {
  19246. throw $TypeError('Reduce of empty array with no initial value');
  19247. }
  19248. }
  19249. for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
  19250. memo = callbackfn(memo, self[index], index, O);
  19251. }
  19252. return memo;
  19253. };
  19254. };
  19255. module.exports = {
  19256. // `Array.prototype.reduce` method
  19257. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  19258. left: createMethod(false),
  19259. // `Array.prototype.reduceRight` method
  19260. // https://tc39.es/ecma262/#sec-array.prototype.reduceright
  19261. right: createMethod(true)
  19262. };
  19263. },{"../internals/a-callable":271,"../internals/indexed-object":352,"../internals/length-of-array-like":375,"../internals/to-object":429}],285:[function(_dereq_,module,exports){
  19264. 'use strict';
  19265. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19266. var isArray = _dereq_('../internals/is-array');
  19267. var $TypeError = TypeError;
  19268. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  19269. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  19270. // Safari < 13 does not throw an error in this case
  19271. var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () {
  19272. // makes no sense without proper strict mode support
  19273. if (this !== undefined) return true;
  19274. try {
  19275. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  19276. Object.defineProperty([], 'length', { writable: false }).length = 1;
  19277. } catch (error) {
  19278. return error instanceof TypeError;
  19279. }
  19280. }();
  19281. module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
  19282. if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
  19283. throw $TypeError('Cannot set read only .length');
  19284. } return O.length = length;
  19285. } : function (O, length) {
  19286. return O.length = length;
  19287. };
  19288. },{"../internals/descriptors":312,"../internals/is-array":358}],286:[function(_dereq_,module,exports){
  19289. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  19290. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19291. var createProperty = _dereq_('../internals/create-property');
  19292. var $Array = Array;
  19293. var max = Math.max;
  19294. module.exports = function (O, start, end) {
  19295. var length = lengthOfArrayLike(O);
  19296. var k = toAbsoluteIndex(start, length);
  19297. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  19298. var result = $Array(max(fin - k, 0));
  19299. for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
  19300. result.length = n;
  19301. return result;
  19302. };
  19303. },{"../internals/create-property":307,"../internals/length-of-array-like":375,"../internals/to-absolute-index":425}],287:[function(_dereq_,module,exports){
  19304. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19305. module.exports = uncurryThis([].slice);
  19306. },{"../internals/function-uncurry-this":340}],288:[function(_dereq_,module,exports){
  19307. var arraySlice = _dereq_('../internals/array-slice-simple');
  19308. var floor = Math.floor;
  19309. var mergeSort = function (array, comparefn) {
  19310. var length = array.length;
  19311. var middle = floor(length / 2);
  19312. return length < 8 ? insertionSort(array, comparefn) : merge(
  19313. array,
  19314. mergeSort(arraySlice(array, 0, middle), comparefn),
  19315. mergeSort(arraySlice(array, middle), comparefn),
  19316. comparefn
  19317. );
  19318. };
  19319. var insertionSort = function (array, comparefn) {
  19320. var length = array.length;
  19321. var i = 1;
  19322. var element, j;
  19323. while (i < length) {
  19324. j = i;
  19325. element = array[i];
  19326. while (j && comparefn(array[j - 1], element) > 0) {
  19327. array[j] = array[--j];
  19328. }
  19329. if (j !== i++) array[j] = element;
  19330. } return array;
  19331. };
  19332. var merge = function (array, left, right, comparefn) {
  19333. var llength = left.length;
  19334. var rlength = right.length;
  19335. var lindex = 0;
  19336. var rindex = 0;
  19337. while (lindex < llength || rindex < rlength) {
  19338. array[lindex + rindex] = (lindex < llength && rindex < rlength)
  19339. ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
  19340. : lindex < llength ? left[lindex++] : right[rindex++];
  19341. } return array;
  19342. };
  19343. module.exports = mergeSort;
  19344. },{"../internals/array-slice-simple":286}],289:[function(_dereq_,module,exports){
  19345. var isArray = _dereq_('../internals/is-array');
  19346. var isConstructor = _dereq_('../internals/is-constructor');
  19347. var isObject = _dereq_('../internals/is-object');
  19348. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19349. var SPECIES = wellKnownSymbol('species');
  19350. var $Array = Array;
  19351. // a part of `ArraySpeciesCreate` abstract operation
  19352. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  19353. module.exports = function (originalArray) {
  19354. var C;
  19355. if (isArray(originalArray)) {
  19356. C = originalArray.constructor;
  19357. // cross-realm fallback
  19358. if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined;
  19359. else if (isObject(C)) {
  19360. C = C[SPECIES];
  19361. if (C === null) C = undefined;
  19362. }
  19363. } return C === undefined ? $Array : C;
  19364. };
  19365. },{"../internals/is-array":358,"../internals/is-constructor":360,"../internals/is-object":365,"../internals/well-known-symbol":442}],290:[function(_dereq_,module,exports){
  19366. var arraySpeciesConstructor = _dereq_('../internals/array-species-constructor');
  19367. // `ArraySpeciesCreate` abstract operation
  19368. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  19369. module.exports = function (originalArray, length) {
  19370. return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
  19371. };
  19372. },{"../internals/array-species-constructor":289}],291:[function(_dereq_,module,exports){
  19373. var anObject = _dereq_('../internals/an-object');
  19374. var iteratorClose = _dereq_('../internals/iterator-close');
  19375. // call something on iterator step with safe closing on error
  19376. module.exports = function (iterator, fn, value, ENTRIES) {
  19377. try {
  19378. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  19379. } catch (error) {
  19380. iteratorClose(iterator, 'throw', error);
  19381. }
  19382. };
  19383. },{"../internals/an-object":276,"../internals/iterator-close":370}],292:[function(_dereq_,module,exports){
  19384. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19385. var ITERATOR = wellKnownSymbol('iterator');
  19386. var SAFE_CLOSING = false;
  19387. try {
  19388. var called = 0;
  19389. var iteratorWithReturn = {
  19390. next: function () {
  19391. return { done: !!called++ };
  19392. },
  19393. 'return': function () {
  19394. SAFE_CLOSING = true;
  19395. }
  19396. };
  19397. iteratorWithReturn[ITERATOR] = function () {
  19398. return this;
  19399. };
  19400. // eslint-disable-next-line es-x/no-array-from, no-throw-literal -- required for testing
  19401. Array.from(iteratorWithReturn, function () { throw 2; });
  19402. } catch (error) { /* empty */ }
  19403. module.exports = function (exec, SKIP_CLOSING) {
  19404. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  19405. var ITERATION_SUPPORT = false;
  19406. try {
  19407. var object = {};
  19408. object[ITERATOR] = function () {
  19409. return {
  19410. next: function () {
  19411. return { done: ITERATION_SUPPORT = true };
  19412. }
  19413. };
  19414. };
  19415. exec(object);
  19416. } catch (error) { /* empty */ }
  19417. return ITERATION_SUPPORT;
  19418. };
  19419. },{"../internals/well-known-symbol":442}],293:[function(_dereq_,module,exports){
  19420. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19421. var toString = uncurryThis({}.toString);
  19422. var stringSlice = uncurryThis(''.slice);
  19423. module.exports = function (it) {
  19424. return stringSlice(toString(it), 8, -1);
  19425. };
  19426. },{"../internals/function-uncurry-this":340}],294:[function(_dereq_,module,exports){
  19427. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  19428. var isCallable = _dereq_('../internals/is-callable');
  19429. var classofRaw = _dereq_('../internals/classof-raw');
  19430. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19431. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  19432. var $Object = Object;
  19433. // ES3 wrong here
  19434. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  19435. // fallback for IE11 Script Access Denied error
  19436. var tryGet = function (it, key) {
  19437. try {
  19438. return it[key];
  19439. } catch (error) { /* empty */ }
  19440. };
  19441. // getting tag from ES6+ `Object.prototype.toString`
  19442. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  19443. var O, tag, result;
  19444. return it === undefined ? 'Undefined' : it === null ? 'Null'
  19445. // @@toStringTag case
  19446. : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
  19447. // builtinTag case
  19448. : CORRECT_ARGUMENTS ? classofRaw(O)
  19449. // ES3 arguments fallback
  19450. : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  19451. };
  19452. },{"../internals/classof-raw":293,"../internals/is-callable":359,"../internals/to-string-tag-support":432,"../internals/well-known-symbol":442}],295:[function(_dereq_,module,exports){
  19453. 'use strict';
  19454. var call = _dereq_('../internals/function-call');
  19455. var aCallable = _dereq_('../internals/a-callable');
  19456. var anObject = _dereq_('../internals/an-object');
  19457. // https://github.com/tc39/collection-methods
  19458. module.exports = function deleteAll(/* ...elements */) {
  19459. var collection = anObject(this);
  19460. var remover = aCallable(collection['delete']);
  19461. var allDeleted = true;
  19462. var wasDeleted;
  19463. for (var k = 0, len = arguments.length; k < len; k++) {
  19464. wasDeleted = call(remover, collection, arguments[k]);
  19465. allDeleted = allDeleted && wasDeleted;
  19466. }
  19467. return !!allDeleted;
  19468. };
  19469. },{"../internals/a-callable":271,"../internals/an-object":276,"../internals/function-call":338}],296:[function(_dereq_,module,exports){
  19470. 'use strict';
  19471. // https://tc39.github.io/proposal-setmap-offrom/
  19472. var bind = _dereq_('../internals/function-bind-context');
  19473. var call = _dereq_('../internals/function-call');
  19474. var aCallable = _dereq_('../internals/a-callable');
  19475. var aConstructor = _dereq_('../internals/a-constructor');
  19476. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  19477. var iterate = _dereq_('../internals/iterate');
  19478. var push = [].push;
  19479. module.exports = function from(source /* , mapFn, thisArg */) {
  19480. var length = arguments.length;
  19481. var mapFn = length > 1 ? arguments[1] : undefined;
  19482. var mapping, array, n, boundFunction;
  19483. aConstructor(this);
  19484. mapping = mapFn !== undefined;
  19485. if (mapping) aCallable(mapFn);
  19486. if (isNullOrUndefined(source)) return new this();
  19487. array = [];
  19488. if (mapping) {
  19489. n = 0;
  19490. boundFunction = bind(mapFn, length > 2 ? arguments[2] : undefined);
  19491. iterate(source, function (nextItem) {
  19492. call(push, array, boundFunction(nextItem, n++));
  19493. });
  19494. } else {
  19495. iterate(source, push, { that: array });
  19496. }
  19497. return new this(array);
  19498. };
  19499. },{"../internals/a-callable":271,"../internals/a-constructor":272,"../internals/function-bind-context":335,"../internals/function-call":338,"../internals/is-null-or-undefined":364,"../internals/iterate":369}],297:[function(_dereq_,module,exports){
  19500. 'use strict';
  19501. var arraySlice = _dereq_('../internals/array-slice');
  19502. // https://tc39.github.io/proposal-setmap-offrom/
  19503. module.exports = function of() {
  19504. return new this(arraySlice(arguments));
  19505. };
  19506. },{"../internals/array-slice":287}],298:[function(_dereq_,module,exports){
  19507. 'use strict';
  19508. var defineProperty = _dereq_('../internals/object-define-property').f;
  19509. var create = _dereq_('../internals/object-create');
  19510. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  19511. var bind = _dereq_('../internals/function-bind-context');
  19512. var anInstance = _dereq_('../internals/an-instance');
  19513. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  19514. var iterate = _dereq_('../internals/iterate');
  19515. var defineIterator = _dereq_('../internals/iterator-define');
  19516. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  19517. var setSpecies = _dereq_('../internals/set-species');
  19518. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19519. var fastKey = _dereq_('../internals/internal-metadata').fastKey;
  19520. var InternalStateModule = _dereq_('../internals/internal-state');
  19521. var setInternalState = InternalStateModule.set;
  19522. var internalStateGetterFor = InternalStateModule.getterFor;
  19523. module.exports = {
  19524. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  19525. var Constructor = wrapper(function (that, iterable) {
  19526. anInstance(that, Prototype);
  19527. setInternalState(that, {
  19528. type: CONSTRUCTOR_NAME,
  19529. index: create(null),
  19530. first: undefined,
  19531. last: undefined,
  19532. size: 0
  19533. });
  19534. if (!DESCRIPTORS) that.size = 0;
  19535. if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  19536. });
  19537. var Prototype = Constructor.prototype;
  19538. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  19539. var define = function (that, key, value) {
  19540. var state = getInternalState(that);
  19541. var entry = getEntry(that, key);
  19542. var previous, index;
  19543. // change existing entry
  19544. if (entry) {
  19545. entry.value = value;
  19546. // create new entry
  19547. } else {
  19548. state.last = entry = {
  19549. index: index = fastKey(key, true),
  19550. key: key,
  19551. value: value,
  19552. previous: previous = state.last,
  19553. next: undefined,
  19554. removed: false
  19555. };
  19556. if (!state.first) state.first = entry;
  19557. if (previous) previous.next = entry;
  19558. if (DESCRIPTORS) state.size++;
  19559. else that.size++;
  19560. // add to index
  19561. if (index !== 'F') state.index[index] = entry;
  19562. } return that;
  19563. };
  19564. var getEntry = function (that, key) {
  19565. var state = getInternalState(that);
  19566. // fast case
  19567. var index = fastKey(key);
  19568. var entry;
  19569. if (index !== 'F') return state.index[index];
  19570. // frozen object case
  19571. for (entry = state.first; entry; entry = entry.next) {
  19572. if (entry.key == key) return entry;
  19573. }
  19574. };
  19575. defineBuiltIns(Prototype, {
  19576. // `{ Map, Set }.prototype.clear()` methods
  19577. // https://tc39.es/ecma262/#sec-map.prototype.clear
  19578. // https://tc39.es/ecma262/#sec-set.prototype.clear
  19579. clear: function clear() {
  19580. var that = this;
  19581. var state = getInternalState(that);
  19582. var data = state.index;
  19583. var entry = state.first;
  19584. while (entry) {
  19585. entry.removed = true;
  19586. if (entry.previous) entry.previous = entry.previous.next = undefined;
  19587. delete data[entry.index];
  19588. entry = entry.next;
  19589. }
  19590. state.first = state.last = undefined;
  19591. if (DESCRIPTORS) state.size = 0;
  19592. else that.size = 0;
  19593. },
  19594. // `{ Map, Set }.prototype.delete(key)` methods
  19595. // https://tc39.es/ecma262/#sec-map.prototype.delete
  19596. // https://tc39.es/ecma262/#sec-set.prototype.delete
  19597. 'delete': function (key) {
  19598. var that = this;
  19599. var state = getInternalState(that);
  19600. var entry = getEntry(that, key);
  19601. if (entry) {
  19602. var next = entry.next;
  19603. var prev = entry.previous;
  19604. delete state.index[entry.index];
  19605. entry.removed = true;
  19606. if (prev) prev.next = next;
  19607. if (next) next.previous = prev;
  19608. if (state.first == entry) state.first = next;
  19609. if (state.last == entry) state.last = prev;
  19610. if (DESCRIPTORS) state.size--;
  19611. else that.size--;
  19612. } return !!entry;
  19613. },
  19614. // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods
  19615. // https://tc39.es/ecma262/#sec-map.prototype.foreach
  19616. // https://tc39.es/ecma262/#sec-set.prototype.foreach
  19617. forEach: function forEach(callbackfn /* , that = undefined */) {
  19618. var state = getInternalState(this);
  19619. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19620. var entry;
  19621. while (entry = entry ? entry.next : state.first) {
  19622. boundFunction(entry.value, entry.key, this);
  19623. // revert to the last existing entry
  19624. while (entry && entry.removed) entry = entry.previous;
  19625. }
  19626. },
  19627. // `{ Map, Set}.prototype.has(key)` methods
  19628. // https://tc39.es/ecma262/#sec-map.prototype.has
  19629. // https://tc39.es/ecma262/#sec-set.prototype.has
  19630. has: function has(key) {
  19631. return !!getEntry(this, key);
  19632. }
  19633. });
  19634. defineBuiltIns(Prototype, IS_MAP ? {
  19635. // `Map.prototype.get(key)` method
  19636. // https://tc39.es/ecma262/#sec-map.prototype.get
  19637. get: function get(key) {
  19638. var entry = getEntry(this, key);
  19639. return entry && entry.value;
  19640. },
  19641. // `Map.prototype.set(key, value)` method
  19642. // https://tc39.es/ecma262/#sec-map.prototype.set
  19643. set: function set(key, value) {
  19644. return define(this, key === 0 ? 0 : key, value);
  19645. }
  19646. } : {
  19647. // `Set.prototype.add(value)` method
  19648. // https://tc39.es/ecma262/#sec-set.prototype.add
  19649. add: function add(value) {
  19650. return define(this, value = value === 0 ? 0 : value, value);
  19651. }
  19652. });
  19653. if (DESCRIPTORS) defineProperty(Prototype, 'size', {
  19654. get: function () {
  19655. return getInternalState(this).size;
  19656. }
  19657. });
  19658. return Constructor;
  19659. },
  19660. setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
  19661. var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
  19662. var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
  19663. var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);
  19664. // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods
  19665. // https://tc39.es/ecma262/#sec-map.prototype.entries
  19666. // https://tc39.es/ecma262/#sec-map.prototype.keys
  19667. // https://tc39.es/ecma262/#sec-map.prototype.values
  19668. // https://tc39.es/ecma262/#sec-map.prototype-@@iterator
  19669. // https://tc39.es/ecma262/#sec-set.prototype.entries
  19670. // https://tc39.es/ecma262/#sec-set.prototype.keys
  19671. // https://tc39.es/ecma262/#sec-set.prototype.values
  19672. // https://tc39.es/ecma262/#sec-set.prototype-@@iterator
  19673. defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
  19674. setInternalState(this, {
  19675. type: ITERATOR_NAME,
  19676. target: iterated,
  19677. state: getInternalCollectionState(iterated),
  19678. kind: kind,
  19679. last: undefined
  19680. });
  19681. }, function () {
  19682. var state = getInternalIteratorState(this);
  19683. var kind = state.kind;
  19684. var entry = state.last;
  19685. // revert to the last existing entry
  19686. while (entry && entry.removed) entry = entry.previous;
  19687. // get next entry
  19688. if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
  19689. // or finish the iteration
  19690. state.target = undefined;
  19691. return createIterResultObject(undefined, true);
  19692. }
  19693. // return step by kind
  19694. if (kind == 'keys') return createIterResultObject(entry.key, false);
  19695. if (kind == 'values') return createIterResultObject(entry.value, false);
  19696. return createIterResultObject([entry.key, entry.value], false);
  19697. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  19698. // `{ Map, Set }.prototype[@@species]` accessors
  19699. // https://tc39.es/ecma262/#sec-get-map-@@species
  19700. // https://tc39.es/ecma262/#sec-get-set-@@species
  19701. setSpecies(CONSTRUCTOR_NAME);
  19702. }
  19703. };
  19704. },{"../internals/an-instance":275,"../internals/create-iter-result-object":304,"../internals/define-built-ins":309,"../internals/descriptors":312,"../internals/function-bind-context":335,"../internals/internal-metadata":355,"../internals/internal-state":356,"../internals/is-null-or-undefined":364,"../internals/iterate":369,"../internals/iterator-define":372,"../internals/object-create":385,"../internals/object-define-property":387,"../internals/set-species":413}],299:[function(_dereq_,module,exports){
  19705. 'use strict';
  19706. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19707. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  19708. var getWeakData = _dereq_('../internals/internal-metadata').getWeakData;
  19709. var anInstance = _dereq_('../internals/an-instance');
  19710. var anObject = _dereq_('../internals/an-object');
  19711. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  19712. var isObject = _dereq_('../internals/is-object');
  19713. var iterate = _dereq_('../internals/iterate');
  19714. var ArrayIterationModule = _dereq_('../internals/array-iteration');
  19715. var hasOwn = _dereq_('../internals/has-own-property');
  19716. var InternalStateModule = _dereq_('../internals/internal-state');
  19717. var setInternalState = InternalStateModule.set;
  19718. var internalStateGetterFor = InternalStateModule.getterFor;
  19719. var find = ArrayIterationModule.find;
  19720. var findIndex = ArrayIterationModule.findIndex;
  19721. var splice = uncurryThis([].splice);
  19722. var id = 0;
  19723. // fallback for uncaught frozen keys
  19724. var uncaughtFrozenStore = function (store) {
  19725. return store.frozen || (store.frozen = new UncaughtFrozenStore());
  19726. };
  19727. var UncaughtFrozenStore = function () {
  19728. this.entries = [];
  19729. };
  19730. var findUncaughtFrozen = function (store, key) {
  19731. return find(store.entries, function (it) {
  19732. return it[0] === key;
  19733. });
  19734. };
  19735. UncaughtFrozenStore.prototype = {
  19736. get: function (key) {
  19737. var entry = findUncaughtFrozen(this, key);
  19738. if (entry) return entry[1];
  19739. },
  19740. has: function (key) {
  19741. return !!findUncaughtFrozen(this, key);
  19742. },
  19743. set: function (key, value) {
  19744. var entry = findUncaughtFrozen(this, key);
  19745. if (entry) entry[1] = value;
  19746. else this.entries.push([key, value]);
  19747. },
  19748. 'delete': function (key) {
  19749. var index = findIndex(this.entries, function (it) {
  19750. return it[0] === key;
  19751. });
  19752. if (~index) splice(this.entries, index, 1);
  19753. return !!~index;
  19754. }
  19755. };
  19756. module.exports = {
  19757. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  19758. var Constructor = wrapper(function (that, iterable) {
  19759. anInstance(that, Prototype);
  19760. setInternalState(that, {
  19761. type: CONSTRUCTOR_NAME,
  19762. id: id++,
  19763. frozen: undefined
  19764. });
  19765. if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  19766. });
  19767. var Prototype = Constructor.prototype;
  19768. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  19769. var define = function (that, key, value) {
  19770. var state = getInternalState(that);
  19771. var data = getWeakData(anObject(key), true);
  19772. if (data === true) uncaughtFrozenStore(state).set(key, value);
  19773. else data[state.id] = value;
  19774. return that;
  19775. };
  19776. defineBuiltIns(Prototype, {
  19777. // `{ WeakMap, WeakSet }.prototype.delete(key)` methods
  19778. // https://tc39.es/ecma262/#sec-weakmap.prototype.delete
  19779. // https://tc39.es/ecma262/#sec-weakset.prototype.delete
  19780. 'delete': function (key) {
  19781. var state = getInternalState(this);
  19782. if (!isObject(key)) return false;
  19783. var data = getWeakData(key);
  19784. if (data === true) return uncaughtFrozenStore(state)['delete'](key);
  19785. return data && hasOwn(data, state.id) && delete data[state.id];
  19786. },
  19787. // `{ WeakMap, WeakSet }.prototype.has(key)` methods
  19788. // https://tc39.es/ecma262/#sec-weakmap.prototype.has
  19789. // https://tc39.es/ecma262/#sec-weakset.prototype.has
  19790. has: function has(key) {
  19791. var state = getInternalState(this);
  19792. if (!isObject(key)) return false;
  19793. var data = getWeakData(key);
  19794. if (data === true) return uncaughtFrozenStore(state).has(key);
  19795. return data && hasOwn(data, state.id);
  19796. }
  19797. });
  19798. defineBuiltIns(Prototype, IS_MAP ? {
  19799. // `WeakMap.prototype.get(key)` method
  19800. // https://tc39.es/ecma262/#sec-weakmap.prototype.get
  19801. get: function get(key) {
  19802. var state = getInternalState(this);
  19803. if (isObject(key)) {
  19804. var data = getWeakData(key);
  19805. if (data === true) return uncaughtFrozenStore(state).get(key);
  19806. return data ? data[state.id] : undefined;
  19807. }
  19808. },
  19809. // `WeakMap.prototype.set(key, value)` method
  19810. // https://tc39.es/ecma262/#sec-weakmap.prototype.set
  19811. set: function set(key, value) {
  19812. return define(this, key, value);
  19813. }
  19814. } : {
  19815. // `WeakSet.prototype.add(value)` method
  19816. // https://tc39.es/ecma262/#sec-weakset.prototype.add
  19817. add: function add(value) {
  19818. return define(this, value, true);
  19819. }
  19820. });
  19821. return Constructor;
  19822. }
  19823. };
  19824. },{"../internals/an-instance":275,"../internals/an-object":276,"../internals/array-iteration":281,"../internals/define-built-ins":309,"../internals/function-uncurry-this":340,"../internals/has-own-property":347,"../internals/internal-metadata":355,"../internals/internal-state":356,"../internals/is-null-or-undefined":364,"../internals/is-object":365,"../internals/iterate":369}],300:[function(_dereq_,module,exports){
  19825. 'use strict';
  19826. var $ = _dereq_('../internals/export');
  19827. var global = _dereq_('../internals/global');
  19828. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  19829. var fails = _dereq_('../internals/fails');
  19830. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  19831. var iterate = _dereq_('../internals/iterate');
  19832. var anInstance = _dereq_('../internals/an-instance');
  19833. var isCallable = _dereq_('../internals/is-callable');
  19834. var isObject = _dereq_('../internals/is-object');
  19835. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  19836. var defineProperty = _dereq_('../internals/object-define-property').f;
  19837. var forEach = _dereq_('../internals/array-iteration').forEach;
  19838. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19839. var InternalStateModule = _dereq_('../internals/internal-state');
  19840. var setInternalState = InternalStateModule.set;
  19841. var internalStateGetterFor = InternalStateModule.getterFor;
  19842. module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
  19843. var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
  19844. var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
  19845. var ADDER = IS_MAP ? 'set' : 'add';
  19846. var NativeConstructor = global[CONSTRUCTOR_NAME];
  19847. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  19848. var exported = {};
  19849. var Constructor;
  19850. if (!DESCRIPTORS || !isCallable(NativeConstructor)
  19851. || !(IS_WEAK || NativePrototype.forEach && !fails(function () { new NativeConstructor().entries().next(); }))
  19852. ) {
  19853. // create collection constructor
  19854. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  19855. InternalMetadataModule.enable();
  19856. } else {
  19857. Constructor = wrapper(function (target, iterable) {
  19858. setInternalState(anInstance(target, Prototype), {
  19859. type: CONSTRUCTOR_NAME,
  19860. collection: new NativeConstructor()
  19861. });
  19862. if (iterable != undefined) iterate(iterable, target[ADDER], { that: target, AS_ENTRIES: IS_MAP });
  19863. });
  19864. var Prototype = Constructor.prototype;
  19865. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  19866. forEach(['add', 'clear', 'delete', 'forEach', 'get', 'has', 'set', 'keys', 'values', 'entries'], function (KEY) {
  19867. var IS_ADDER = KEY == 'add' || KEY == 'set';
  19868. if (KEY in NativePrototype && !(IS_WEAK && KEY == 'clear')) {
  19869. createNonEnumerableProperty(Prototype, KEY, function (a, b) {
  19870. var collection = getInternalState(this).collection;
  19871. if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
  19872. var result = collection[KEY](a === 0 ? 0 : a, b);
  19873. return IS_ADDER ? this : result;
  19874. });
  19875. }
  19876. });
  19877. IS_WEAK || defineProperty(Prototype, 'size', {
  19878. configurable: true,
  19879. get: function () {
  19880. return getInternalState(this).collection.size;
  19881. }
  19882. });
  19883. }
  19884. setToStringTag(Constructor, CONSTRUCTOR_NAME, false, true);
  19885. exported[CONSTRUCTOR_NAME] = Constructor;
  19886. $({ global: true, forced: true }, exported);
  19887. if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  19888. return Constructor;
  19889. };
  19890. },{"../internals/an-instance":275,"../internals/array-iteration":281,"../internals/create-non-enumerable-property":305,"../internals/descriptors":312,"../internals/export":331,"../internals/fails":332,"../internals/global":346,"../internals/internal-metadata":355,"../internals/internal-state":356,"../internals/is-callable":359,"../internals/is-object":365,"../internals/iterate":369,"../internals/object-define-property":387,"../internals/set-to-string-tag":414}],301:[function(_dereq_,module,exports){
  19891. var hasOwn = _dereq_('../internals/has-own-property');
  19892. var ownKeys = _dereq_('../internals/own-keys');
  19893. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  19894. var definePropertyModule = _dereq_('../internals/object-define-property');
  19895. module.exports = function (target, source, exceptions) {
  19896. var keys = ownKeys(source);
  19897. var defineProperty = definePropertyModule.f;
  19898. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  19899. for (var i = 0; i < keys.length; i++) {
  19900. var key = keys[i];
  19901. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  19902. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  19903. }
  19904. }
  19905. };
  19906. },{"../internals/has-own-property":347,"../internals/object-define-property":387,"../internals/object-get-own-property-descriptor":388,"../internals/own-keys":402}],302:[function(_dereq_,module,exports){
  19907. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19908. var MATCH = wellKnownSymbol('match');
  19909. module.exports = function (METHOD_NAME) {
  19910. var regexp = /./;
  19911. try {
  19912. '/./'[METHOD_NAME](regexp);
  19913. } catch (error1) {
  19914. try {
  19915. regexp[MATCH] = false;
  19916. return '/./'[METHOD_NAME](regexp);
  19917. } catch (error2) { /* empty */ }
  19918. } return false;
  19919. };
  19920. },{"../internals/well-known-symbol":442}],303:[function(_dereq_,module,exports){
  19921. var fails = _dereq_('../internals/fails');
  19922. module.exports = !fails(function () {
  19923. function F() { /* empty */ }
  19924. F.prototype.constructor = null;
  19925. // eslint-disable-next-line es-x/no-object-getprototypeof -- required for testing
  19926. return Object.getPrototypeOf(new F()) !== F.prototype;
  19927. });
  19928. },{"../internals/fails":332}],304:[function(_dereq_,module,exports){
  19929. // `CreateIterResultObject` abstract operation
  19930. // https://tc39.es/ecma262/#sec-createiterresultobject
  19931. module.exports = function (value, done) {
  19932. return { value: value, done: done };
  19933. };
  19934. },{}],305:[function(_dereq_,module,exports){
  19935. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19936. var definePropertyModule = _dereq_('../internals/object-define-property');
  19937. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  19938. module.exports = DESCRIPTORS ? function (object, key, value) {
  19939. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  19940. } : function (object, key, value) {
  19941. object[key] = value;
  19942. return object;
  19943. };
  19944. },{"../internals/create-property-descriptor":306,"../internals/descriptors":312,"../internals/object-define-property":387}],306:[function(_dereq_,module,exports){
  19945. module.exports = function (bitmap, value) {
  19946. return {
  19947. enumerable: !(bitmap & 1),
  19948. configurable: !(bitmap & 2),
  19949. writable: !(bitmap & 4),
  19950. value: value
  19951. };
  19952. };
  19953. },{}],307:[function(_dereq_,module,exports){
  19954. 'use strict';
  19955. var toPropertyKey = _dereq_('../internals/to-property-key');
  19956. var definePropertyModule = _dereq_('../internals/object-define-property');
  19957. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  19958. module.exports = function (object, key, value) {
  19959. var propertyKey = toPropertyKey(key);
  19960. if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  19961. else object[propertyKey] = value;
  19962. };
  19963. },{"../internals/create-property-descriptor":306,"../internals/object-define-property":387,"../internals/to-property-key":431}],308:[function(_dereq_,module,exports){
  19964. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  19965. module.exports = function (target, key, value, options) {
  19966. if (options && options.enumerable) target[key] = value;
  19967. else createNonEnumerableProperty(target, key, value);
  19968. return target;
  19969. };
  19970. },{"../internals/create-non-enumerable-property":305}],309:[function(_dereq_,module,exports){
  19971. var defineBuiltIn = _dereq_('../internals/define-built-in');
  19972. module.exports = function (target, src, options) {
  19973. for (var key in src) {
  19974. if (options && options.unsafe && target[key]) target[key] = src[key];
  19975. else defineBuiltIn(target, key, src[key], options);
  19976. } return target;
  19977. };
  19978. },{"../internals/define-built-in":308}],310:[function(_dereq_,module,exports){
  19979. var global = _dereq_('../internals/global');
  19980. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  19981. var defineProperty = Object.defineProperty;
  19982. module.exports = function (key, value) {
  19983. try {
  19984. defineProperty(global, key, { value: value, configurable: true, writable: true });
  19985. } catch (error) {
  19986. global[key] = value;
  19987. } return value;
  19988. };
  19989. },{"../internals/global":346}],311:[function(_dereq_,module,exports){
  19990. 'use strict';
  19991. var tryToString = _dereq_('../internals/try-to-string');
  19992. var $TypeError = TypeError;
  19993. module.exports = function (O, P) {
  19994. if (!delete O[P]) throw $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O));
  19995. };
  19996. },{"../internals/try-to-string":434}],312:[function(_dereq_,module,exports){
  19997. var fails = _dereq_('../internals/fails');
  19998. // Detect IE8's incomplete defineProperty implementation
  19999. module.exports = !fails(function () {
  20000. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  20001. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  20002. });
  20003. },{"../internals/fails":332}],313:[function(_dereq_,module,exports){
  20004. var global = _dereq_('../internals/global');
  20005. var isObject = _dereq_('../internals/is-object');
  20006. var document = global.document;
  20007. // typeof document.createElement is 'object' in old IE
  20008. var EXISTS = isObject(document) && isObject(document.createElement);
  20009. module.exports = function (it) {
  20010. return EXISTS ? document.createElement(it) : {};
  20011. };
  20012. },{"../internals/global":346,"../internals/is-object":365}],314:[function(_dereq_,module,exports){
  20013. var $TypeError = TypeError;
  20014. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
  20015. module.exports = function (it) {
  20016. if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded');
  20017. return it;
  20018. };
  20019. },{}],315:[function(_dereq_,module,exports){
  20020. // iterable DOM collections
  20021. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  20022. module.exports = {
  20023. CSSRuleList: 0,
  20024. CSSStyleDeclaration: 0,
  20025. CSSValueList: 0,
  20026. ClientRectList: 0,
  20027. DOMRectList: 0,
  20028. DOMStringList: 0,
  20029. DOMTokenList: 1,
  20030. DataTransferItemList: 0,
  20031. FileList: 0,
  20032. HTMLAllCollection: 0,
  20033. HTMLCollection: 0,
  20034. HTMLFormElement: 0,
  20035. HTMLSelectElement: 0,
  20036. MediaList: 0,
  20037. MimeTypeArray: 0,
  20038. NamedNodeMap: 0,
  20039. NodeList: 1,
  20040. PaintRequestList: 0,
  20041. Plugin: 0,
  20042. PluginArray: 0,
  20043. SVGLengthList: 0,
  20044. SVGNumberList: 0,
  20045. SVGPathSegList: 0,
  20046. SVGPointList: 0,
  20047. SVGStringList: 0,
  20048. SVGTransformList: 0,
  20049. SourceBufferList: 0,
  20050. StyleSheetList: 0,
  20051. TextTrackCueList: 0,
  20052. TextTrackList: 0,
  20053. TouchList: 0
  20054. };
  20055. },{}],316:[function(_dereq_,module,exports){
  20056. var userAgent = _dereq_('../internals/engine-user-agent');
  20057. var firefox = userAgent.match(/firefox\/(\d+)/i);
  20058. module.exports = !!firefox && +firefox[1];
  20059. },{"../internals/engine-user-agent":324}],317:[function(_dereq_,module,exports){
  20060. var IS_DENO = _dereq_('../internals/engine-is-deno');
  20061. var IS_NODE = _dereq_('../internals/engine-is-node');
  20062. module.exports = !IS_DENO && !IS_NODE
  20063. && typeof window == 'object'
  20064. && typeof document == 'object';
  20065. },{"../internals/engine-is-deno":318,"../internals/engine-is-node":322}],318:[function(_dereq_,module,exports){
  20066. /* global Deno -- Deno case */
  20067. module.exports = typeof Deno == 'object' && Deno && typeof Deno.version == 'object';
  20068. },{}],319:[function(_dereq_,module,exports){
  20069. var UA = _dereq_('../internals/engine-user-agent');
  20070. module.exports = /MSIE|Trident/.test(UA);
  20071. },{"../internals/engine-user-agent":324}],320:[function(_dereq_,module,exports){
  20072. var userAgent = _dereq_('../internals/engine-user-agent');
  20073. var global = _dereq_('../internals/global');
  20074. module.exports = /ipad|iphone|ipod/i.test(userAgent) && global.Pebble !== undefined;
  20075. },{"../internals/engine-user-agent":324,"../internals/global":346}],321:[function(_dereq_,module,exports){
  20076. var userAgent = _dereq_('../internals/engine-user-agent');
  20077. module.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
  20078. },{"../internals/engine-user-agent":324}],322:[function(_dereq_,module,exports){
  20079. var classof = _dereq_('../internals/classof-raw');
  20080. var global = _dereq_('../internals/global');
  20081. module.exports = classof(global.process) == 'process';
  20082. },{"../internals/classof-raw":293,"../internals/global":346}],323:[function(_dereq_,module,exports){
  20083. var userAgent = _dereq_('../internals/engine-user-agent');
  20084. module.exports = /web0s(?!.*chrome)/i.test(userAgent);
  20085. },{"../internals/engine-user-agent":324}],324:[function(_dereq_,module,exports){
  20086. var getBuiltIn = _dereq_('../internals/get-built-in');
  20087. module.exports = getBuiltIn('navigator', 'userAgent') || '';
  20088. },{"../internals/get-built-in":341}],325:[function(_dereq_,module,exports){
  20089. var global = _dereq_('../internals/global');
  20090. var userAgent = _dereq_('../internals/engine-user-agent');
  20091. var process = global.process;
  20092. var Deno = global.Deno;
  20093. var versions = process && process.versions || Deno && Deno.version;
  20094. var v8 = versions && versions.v8;
  20095. var match, version;
  20096. if (v8) {
  20097. match = v8.split('.');
  20098. // in old Chrome, versions of V8 isn't V8 = Chrome / 10
  20099. // but their correct versions are not interesting for us
  20100. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  20101. }
  20102. // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
  20103. // so check `userAgent` even if `.v8` exists, but 0
  20104. if (!version && userAgent) {
  20105. match = userAgent.match(/Edge\/(\d+)/);
  20106. if (!match || match[1] >= 74) {
  20107. match = userAgent.match(/Chrome\/(\d+)/);
  20108. if (match) version = +match[1];
  20109. }
  20110. }
  20111. module.exports = version;
  20112. },{"../internals/engine-user-agent":324,"../internals/global":346}],326:[function(_dereq_,module,exports){
  20113. var userAgent = _dereq_('../internals/engine-user-agent');
  20114. var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
  20115. module.exports = !!webkit && +webkit[1];
  20116. },{"../internals/engine-user-agent":324}],327:[function(_dereq_,module,exports){
  20117. var path = _dereq_('../internals/path');
  20118. module.exports = function (CONSTRUCTOR) {
  20119. return path[CONSTRUCTOR + 'Prototype'];
  20120. };
  20121. },{"../internals/path":403}],328:[function(_dereq_,module,exports){
  20122. // IE8- don't enum bug keys
  20123. module.exports = [
  20124. 'constructor',
  20125. 'hasOwnProperty',
  20126. 'isPrototypeOf',
  20127. 'propertyIsEnumerable',
  20128. 'toLocaleString',
  20129. 'toString',
  20130. 'valueOf'
  20131. ];
  20132. },{}],329:[function(_dereq_,module,exports){
  20133. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20134. var $Error = Error;
  20135. var replace = uncurryThis(''.replace);
  20136. var TEST = (function (arg) { return String($Error(arg).stack); })('zxcasd');
  20137. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  20138. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  20139. module.exports = function (stack, dropEntries) {
  20140. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
  20141. while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  20142. } return stack;
  20143. };
  20144. },{"../internals/function-uncurry-this":340}],330:[function(_dereq_,module,exports){
  20145. var fails = _dereq_('../internals/fails');
  20146. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  20147. module.exports = !fails(function () {
  20148. var error = Error('a');
  20149. if (!('stack' in error)) return true;
  20150. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  20151. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  20152. return error.stack !== 7;
  20153. });
  20154. },{"../internals/create-property-descriptor":306,"../internals/fails":332}],331:[function(_dereq_,module,exports){
  20155. 'use strict';
  20156. var global = _dereq_('../internals/global');
  20157. var apply = _dereq_('../internals/function-apply');
  20158. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20159. var isCallable = _dereq_('../internals/is-callable');
  20160. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  20161. var isForced = _dereq_('../internals/is-forced');
  20162. var path = _dereq_('../internals/path');
  20163. var bind = _dereq_('../internals/function-bind-context');
  20164. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  20165. var hasOwn = _dereq_('../internals/has-own-property');
  20166. var wrapConstructor = function (NativeConstructor) {
  20167. var Wrapper = function (a, b, c) {
  20168. if (this instanceof Wrapper) {
  20169. switch (arguments.length) {
  20170. case 0: return new NativeConstructor();
  20171. case 1: return new NativeConstructor(a);
  20172. case 2: return new NativeConstructor(a, b);
  20173. } return new NativeConstructor(a, b, c);
  20174. } return apply(NativeConstructor, this, arguments);
  20175. };
  20176. Wrapper.prototype = NativeConstructor.prototype;
  20177. return Wrapper;
  20178. };
  20179. /*
  20180. options.target - name of the target object
  20181. options.global - target is the global object
  20182. options.stat - export as static methods of target
  20183. options.proto - export as prototype methods of target
  20184. options.real - real prototype method for the `pure` version
  20185. options.forced - export even if the native feature is available
  20186. options.bind - bind methods to the target, required for the `pure` version
  20187. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  20188. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  20189. options.sham - add a flag to not completely full polyfills
  20190. options.enumerable - export as enumerable property
  20191. options.dontCallGetSet - prevent calling a getter on target
  20192. options.name - the .name of the function if it does not match the key
  20193. */
  20194. module.exports = function (options, source) {
  20195. var TARGET = options.target;
  20196. var GLOBAL = options.global;
  20197. var STATIC = options.stat;
  20198. var PROTO = options.proto;
  20199. var nativeSource = GLOBAL ? global : STATIC ? global[TARGET] : (global[TARGET] || {}).prototype;
  20200. var target = GLOBAL ? path : path[TARGET] || createNonEnumerableProperty(path, TARGET, {})[TARGET];
  20201. var targetPrototype = target.prototype;
  20202. var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
  20203. var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
  20204. for (key in source) {
  20205. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  20206. // contains in native
  20207. USE_NATIVE = !FORCED && nativeSource && hasOwn(nativeSource, key);
  20208. targetProperty = target[key];
  20209. if (USE_NATIVE) if (options.dontCallGetSet) {
  20210. descriptor = getOwnPropertyDescriptor(nativeSource, key);
  20211. nativeProperty = descriptor && descriptor.value;
  20212. } else nativeProperty = nativeSource[key];
  20213. // export native or implementation
  20214. sourceProperty = (USE_NATIVE && nativeProperty) ? nativeProperty : source[key];
  20215. if (USE_NATIVE && typeof targetProperty == typeof sourceProperty) continue;
  20216. // bind timers to global for call from export context
  20217. if (options.bind && USE_NATIVE) resultProperty = bind(sourceProperty, global);
  20218. // wrap global constructors for prevent changs in this version
  20219. else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty);
  20220. // make static versions for prototype methods
  20221. else if (PROTO && isCallable(sourceProperty)) resultProperty = uncurryThis(sourceProperty);
  20222. // default case
  20223. else resultProperty = sourceProperty;
  20224. // add a flag to not completely full polyfills
  20225. if (options.sham || (sourceProperty && sourceProperty.sham) || (targetProperty && targetProperty.sham)) {
  20226. createNonEnumerableProperty(resultProperty, 'sham', true);
  20227. }
  20228. createNonEnumerableProperty(target, key, resultProperty);
  20229. if (PROTO) {
  20230. VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
  20231. if (!hasOwn(path, VIRTUAL_PROTOTYPE)) {
  20232. createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
  20233. }
  20234. // export virtual prototype methods
  20235. createNonEnumerableProperty(path[VIRTUAL_PROTOTYPE], key, sourceProperty);
  20236. // export real prototype methods
  20237. if (options.real && targetPrototype && !targetPrototype[key]) {
  20238. createNonEnumerableProperty(targetPrototype, key, sourceProperty);
  20239. }
  20240. }
  20241. }
  20242. };
  20243. },{"../internals/create-non-enumerable-property":305,"../internals/function-apply":334,"../internals/function-bind-context":335,"../internals/function-uncurry-this":340,"../internals/global":346,"../internals/has-own-property":347,"../internals/is-callable":359,"../internals/is-forced":362,"../internals/object-get-own-property-descriptor":388,"../internals/path":403}],332:[function(_dereq_,module,exports){
  20244. module.exports = function (exec) {
  20245. try {
  20246. return !!exec();
  20247. } catch (error) {
  20248. return true;
  20249. }
  20250. };
  20251. },{}],333:[function(_dereq_,module,exports){
  20252. var fails = _dereq_('../internals/fails');
  20253. module.exports = !fails(function () {
  20254. // eslint-disable-next-line es-x/no-object-isextensible, es-x/no-object-preventextensions -- required for testing
  20255. return Object.isExtensible(Object.preventExtensions({}));
  20256. });
  20257. },{"../internals/fails":332}],334:[function(_dereq_,module,exports){
  20258. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  20259. var FunctionPrototype = Function.prototype;
  20260. var apply = FunctionPrototype.apply;
  20261. var call = FunctionPrototype.call;
  20262. // eslint-disable-next-line es-x/no-reflect -- safe
  20263. module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
  20264. return call.apply(apply, arguments);
  20265. });
  20266. },{"../internals/function-bind-native":336}],335:[function(_dereq_,module,exports){
  20267. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20268. var aCallable = _dereq_('../internals/a-callable');
  20269. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  20270. var bind = uncurryThis(uncurryThis.bind);
  20271. // optional / simple context binding
  20272. module.exports = function (fn, that) {
  20273. aCallable(fn);
  20274. return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
  20275. return fn.apply(that, arguments);
  20276. };
  20277. };
  20278. },{"../internals/a-callable":271,"../internals/function-bind-native":336,"../internals/function-uncurry-this":340}],336:[function(_dereq_,module,exports){
  20279. var fails = _dereq_('../internals/fails');
  20280. module.exports = !fails(function () {
  20281. // eslint-disable-next-line es-x/no-function-prototype-bind -- safe
  20282. var test = (function () { /* empty */ }).bind();
  20283. // eslint-disable-next-line no-prototype-builtins -- safe
  20284. return typeof test != 'function' || test.hasOwnProperty('prototype');
  20285. });
  20286. },{"../internals/fails":332}],337:[function(_dereq_,module,exports){
  20287. 'use strict';
  20288. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20289. var aCallable = _dereq_('../internals/a-callable');
  20290. var isObject = _dereq_('../internals/is-object');
  20291. var hasOwn = _dereq_('../internals/has-own-property');
  20292. var arraySlice = _dereq_('../internals/array-slice');
  20293. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  20294. var $Function = Function;
  20295. var concat = uncurryThis([].concat);
  20296. var join = uncurryThis([].join);
  20297. var factories = {};
  20298. var construct = function (C, argsLength, args) {
  20299. if (!hasOwn(factories, argsLength)) {
  20300. for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
  20301. factories[argsLength] = $Function('C,a', 'return new C(' + join(list, ',') + ')');
  20302. } return factories[argsLength](C, args);
  20303. };
  20304. // `Function.prototype.bind` method implementation
  20305. // https://tc39.es/ecma262/#sec-function.prototype.bind
  20306. module.exports = NATIVE_BIND ? $Function.bind : function bind(that /* , ...args */) {
  20307. var F = aCallable(this);
  20308. var Prototype = F.prototype;
  20309. var partArgs = arraySlice(arguments, 1);
  20310. var boundFunction = function bound(/* args... */) {
  20311. var args = concat(partArgs, arraySlice(arguments));
  20312. return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
  20313. };
  20314. if (isObject(Prototype)) boundFunction.prototype = Prototype;
  20315. return boundFunction;
  20316. };
  20317. },{"../internals/a-callable":271,"../internals/array-slice":287,"../internals/function-bind-native":336,"../internals/function-uncurry-this":340,"../internals/has-own-property":347,"../internals/is-object":365}],338:[function(_dereq_,module,exports){
  20318. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  20319. var call = Function.prototype.call;
  20320. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  20321. return call.apply(call, arguments);
  20322. };
  20323. },{"../internals/function-bind-native":336}],339:[function(_dereq_,module,exports){
  20324. var DESCRIPTORS = _dereq_('../internals/descriptors');
  20325. var hasOwn = _dereq_('../internals/has-own-property');
  20326. var FunctionPrototype = Function.prototype;
  20327. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  20328. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  20329. var EXISTS = hasOwn(FunctionPrototype, 'name');
  20330. // additional protection from minified / mangled / dropped function names
  20331. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  20332. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
  20333. module.exports = {
  20334. EXISTS: EXISTS,
  20335. PROPER: PROPER,
  20336. CONFIGURABLE: CONFIGURABLE
  20337. };
  20338. },{"../internals/descriptors":312,"../internals/has-own-property":347}],340:[function(_dereq_,module,exports){
  20339. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  20340. var FunctionPrototype = Function.prototype;
  20341. var bind = FunctionPrototype.bind;
  20342. var call = FunctionPrototype.call;
  20343. var uncurryThis = NATIVE_BIND && bind.bind(call, call);
  20344. module.exports = NATIVE_BIND ? function (fn) {
  20345. return fn && uncurryThis(fn);
  20346. } : function (fn) {
  20347. return fn && function () {
  20348. return call.apply(fn, arguments);
  20349. };
  20350. };
  20351. },{"../internals/function-bind-native":336}],341:[function(_dereq_,module,exports){
  20352. var path = _dereq_('../internals/path');
  20353. var global = _dereq_('../internals/global');
  20354. var isCallable = _dereq_('../internals/is-callable');
  20355. var aFunction = function (variable) {
  20356. return isCallable(variable) ? variable : undefined;
  20357. };
  20358. module.exports = function (namespace, method) {
  20359. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])
  20360. : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
  20361. };
  20362. },{"../internals/global":346,"../internals/is-callable":359,"../internals/path":403}],342:[function(_dereq_,module,exports){
  20363. var classof = _dereq_('../internals/classof');
  20364. var getMethod = _dereq_('../internals/get-method');
  20365. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  20366. var Iterators = _dereq_('../internals/iterators');
  20367. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20368. var ITERATOR = wellKnownSymbol('iterator');
  20369. module.exports = function (it) {
  20370. if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR)
  20371. || getMethod(it, '@@iterator')
  20372. || Iterators[classof(it)];
  20373. };
  20374. },{"../internals/classof":294,"../internals/get-method":345,"../internals/is-null-or-undefined":364,"../internals/iterators":374,"../internals/well-known-symbol":442}],343:[function(_dereq_,module,exports){
  20375. var call = _dereq_('../internals/function-call');
  20376. var aCallable = _dereq_('../internals/a-callable');
  20377. var anObject = _dereq_('../internals/an-object');
  20378. var tryToString = _dereq_('../internals/try-to-string');
  20379. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  20380. var $TypeError = TypeError;
  20381. module.exports = function (argument, usingIterator) {
  20382. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
  20383. if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
  20384. throw $TypeError(tryToString(argument) + ' is not iterable');
  20385. };
  20386. },{"../internals/a-callable":271,"../internals/an-object":276,"../internals/function-call":338,"../internals/get-iterator-method":342,"../internals/try-to-string":434}],344:[function(_dereq_,module,exports){
  20387. var getIterator = _dereq_('../internals/get-iterator');
  20388. module.exports = getIterator;
  20389. },{"../internals/get-iterator":343}],345:[function(_dereq_,module,exports){
  20390. var aCallable = _dereq_('../internals/a-callable');
  20391. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  20392. // `GetMethod` abstract operation
  20393. // https://tc39.es/ecma262/#sec-getmethod
  20394. module.exports = function (V, P) {
  20395. var func = V[P];
  20396. return isNullOrUndefined(func) ? undefined : aCallable(func);
  20397. };
  20398. },{"../internals/a-callable":271,"../internals/is-null-or-undefined":364}],346:[function(_dereq_,module,exports){
  20399. (function (global){(function (){
  20400. var check = function (it) {
  20401. return it && it.Math == Math && it;
  20402. };
  20403. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  20404. module.exports =
  20405. // eslint-disable-next-line es-x/no-global-this -- safe
  20406. check(typeof globalThis == 'object' && globalThis) ||
  20407. check(typeof window == 'object' && window) ||
  20408. // eslint-disable-next-line no-restricted-globals -- safe
  20409. check(typeof self == 'object' && self) ||
  20410. check(typeof global == 'object' && global) ||
  20411. // eslint-disable-next-line no-new-func -- fallback
  20412. (function () { return this; })() || Function('return this')();
  20413. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  20414. },{}],347:[function(_dereq_,module,exports){
  20415. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20416. var toObject = _dereq_('../internals/to-object');
  20417. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  20418. // `HasOwnProperty` abstract operation
  20419. // https://tc39.es/ecma262/#sec-hasownproperty
  20420. // eslint-disable-next-line es-x/no-object-hasown -- safe
  20421. module.exports = Object.hasOwn || function hasOwn(it, key) {
  20422. return hasOwnProperty(toObject(it), key);
  20423. };
  20424. },{"../internals/function-uncurry-this":340,"../internals/to-object":429}],348:[function(_dereq_,module,exports){
  20425. module.exports = {};
  20426. },{}],349:[function(_dereq_,module,exports){
  20427. var global = _dereq_('../internals/global');
  20428. module.exports = function (a, b) {
  20429. var console = global.console;
  20430. if (console && console.error) {
  20431. arguments.length == 1 ? console.error(a) : console.error(a, b);
  20432. }
  20433. };
  20434. },{"../internals/global":346}],350:[function(_dereq_,module,exports){
  20435. var getBuiltIn = _dereq_('../internals/get-built-in');
  20436. module.exports = getBuiltIn('document', 'documentElement');
  20437. },{"../internals/get-built-in":341}],351:[function(_dereq_,module,exports){
  20438. var DESCRIPTORS = _dereq_('../internals/descriptors');
  20439. var fails = _dereq_('../internals/fails');
  20440. var createElement = _dereq_('../internals/document-create-element');
  20441. // Thanks to IE8 for its funny defineProperty
  20442. module.exports = !DESCRIPTORS && !fails(function () {
  20443. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  20444. return Object.defineProperty(createElement('div'), 'a', {
  20445. get: function () { return 7; }
  20446. }).a != 7;
  20447. });
  20448. },{"../internals/descriptors":312,"../internals/document-create-element":313,"../internals/fails":332}],352:[function(_dereq_,module,exports){
  20449. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20450. var fails = _dereq_('../internals/fails');
  20451. var classof = _dereq_('../internals/classof-raw');
  20452. var $Object = Object;
  20453. var split = uncurryThis(''.split);
  20454. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  20455. module.exports = fails(function () {
  20456. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  20457. // eslint-disable-next-line no-prototype-builtins -- safe
  20458. return !$Object('z').propertyIsEnumerable(0);
  20459. }) ? function (it) {
  20460. return classof(it) == 'String' ? split(it, '') : $Object(it);
  20461. } : $Object;
  20462. },{"../internals/classof-raw":293,"../internals/fails":332,"../internals/function-uncurry-this":340}],353:[function(_dereq_,module,exports){
  20463. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20464. var isCallable = _dereq_('../internals/is-callable');
  20465. var store = _dereq_('../internals/shared-store');
  20466. var functionToString = uncurryThis(Function.toString);
  20467. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  20468. if (!isCallable(store.inspectSource)) {
  20469. store.inspectSource = function (it) {
  20470. return functionToString(it);
  20471. };
  20472. }
  20473. module.exports = store.inspectSource;
  20474. },{"../internals/function-uncurry-this":340,"../internals/is-callable":359,"../internals/shared-store":416}],354:[function(_dereq_,module,exports){
  20475. var isObject = _dereq_('../internals/is-object');
  20476. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  20477. // `InstallErrorCause` abstract operation
  20478. // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
  20479. module.exports = function (O, options) {
  20480. if (isObject(options) && 'cause' in options) {
  20481. createNonEnumerableProperty(O, 'cause', options.cause);
  20482. }
  20483. };
  20484. },{"../internals/create-non-enumerable-property":305,"../internals/is-object":365}],355:[function(_dereq_,module,exports){
  20485. var $ = _dereq_('../internals/export');
  20486. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20487. var hiddenKeys = _dereq_('../internals/hidden-keys');
  20488. var isObject = _dereq_('../internals/is-object');
  20489. var hasOwn = _dereq_('../internals/has-own-property');
  20490. var defineProperty = _dereq_('../internals/object-define-property').f;
  20491. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  20492. var getOwnPropertyNamesExternalModule = _dereq_('../internals/object-get-own-property-names-external');
  20493. var isExtensible = _dereq_('../internals/object-is-extensible');
  20494. var uid = _dereq_('../internals/uid');
  20495. var FREEZING = _dereq_('../internals/freezing');
  20496. var REQUIRED = false;
  20497. var METADATA = uid('meta');
  20498. var id = 0;
  20499. var setMetadata = function (it) {
  20500. defineProperty(it, METADATA, { value: {
  20501. objectID: 'O' + id++, // object ID
  20502. weakData: {} // weak collections IDs
  20503. } });
  20504. };
  20505. var fastKey = function (it, create) {
  20506. // return a primitive with prefix
  20507. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  20508. if (!hasOwn(it, METADATA)) {
  20509. // can't set metadata to uncaught frozen object
  20510. if (!isExtensible(it)) return 'F';
  20511. // not necessary to add metadata
  20512. if (!create) return 'E';
  20513. // add missing metadata
  20514. setMetadata(it);
  20515. // return object ID
  20516. } return it[METADATA].objectID;
  20517. };
  20518. var getWeakData = function (it, create) {
  20519. if (!hasOwn(it, METADATA)) {
  20520. // can't set metadata to uncaught frozen object
  20521. if (!isExtensible(it)) return true;
  20522. // not necessary to add metadata
  20523. if (!create) return false;
  20524. // add missing metadata
  20525. setMetadata(it);
  20526. // return the store of weak collections IDs
  20527. } return it[METADATA].weakData;
  20528. };
  20529. // add metadata on freeze-family methods calling
  20530. var onFreeze = function (it) {
  20531. if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it);
  20532. return it;
  20533. };
  20534. var enable = function () {
  20535. meta.enable = function () { /* empty */ };
  20536. REQUIRED = true;
  20537. var getOwnPropertyNames = getOwnPropertyNamesModule.f;
  20538. var splice = uncurryThis([].splice);
  20539. var test = {};
  20540. test[METADATA] = 1;
  20541. // prevent exposing of metadata key
  20542. if (getOwnPropertyNames(test).length) {
  20543. getOwnPropertyNamesModule.f = function (it) {
  20544. var result = getOwnPropertyNames(it);
  20545. for (var i = 0, length = result.length; i < length; i++) {
  20546. if (result[i] === METADATA) {
  20547. splice(result, i, 1);
  20548. break;
  20549. }
  20550. } return result;
  20551. };
  20552. $({ target: 'Object', stat: true, forced: true }, {
  20553. getOwnPropertyNames: getOwnPropertyNamesExternalModule.f
  20554. });
  20555. }
  20556. };
  20557. var meta = module.exports = {
  20558. enable: enable,
  20559. fastKey: fastKey,
  20560. getWeakData: getWeakData,
  20561. onFreeze: onFreeze
  20562. };
  20563. hiddenKeys[METADATA] = true;
  20564. },{"../internals/export":331,"../internals/freezing":333,"../internals/function-uncurry-this":340,"../internals/has-own-property":347,"../internals/hidden-keys":348,"../internals/is-object":365,"../internals/object-define-property":387,"../internals/object-get-own-property-names":390,"../internals/object-get-own-property-names-external":389,"../internals/object-is-extensible":393,"../internals/uid":435}],356:[function(_dereq_,module,exports){
  20565. var NATIVE_WEAK_MAP = _dereq_('../internals/weak-map-basic-detection');
  20566. var global = _dereq_('../internals/global');
  20567. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20568. var isObject = _dereq_('../internals/is-object');
  20569. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  20570. var hasOwn = _dereq_('../internals/has-own-property');
  20571. var shared = _dereq_('../internals/shared-store');
  20572. var sharedKey = _dereq_('../internals/shared-key');
  20573. var hiddenKeys = _dereq_('../internals/hidden-keys');
  20574. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  20575. var TypeError = global.TypeError;
  20576. var WeakMap = global.WeakMap;
  20577. var set, get, has;
  20578. var enforce = function (it) {
  20579. return has(it) ? get(it) : set(it, {});
  20580. };
  20581. var getterFor = function (TYPE) {
  20582. return function (it) {
  20583. var state;
  20584. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  20585. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  20586. } return state;
  20587. };
  20588. };
  20589. if (NATIVE_WEAK_MAP || shared.state) {
  20590. var store = shared.state || (shared.state = new WeakMap());
  20591. var wmget = uncurryThis(store.get);
  20592. var wmhas = uncurryThis(store.has);
  20593. var wmset = uncurryThis(store.set);
  20594. set = function (it, metadata) {
  20595. if (wmhas(store, it)) throw TypeError(OBJECT_ALREADY_INITIALIZED);
  20596. metadata.facade = it;
  20597. wmset(store, it, metadata);
  20598. return metadata;
  20599. };
  20600. get = function (it) {
  20601. return wmget(store, it) || {};
  20602. };
  20603. has = function (it) {
  20604. return wmhas(store, it);
  20605. };
  20606. } else {
  20607. var STATE = sharedKey('state');
  20608. hiddenKeys[STATE] = true;
  20609. set = function (it, metadata) {
  20610. if (hasOwn(it, STATE)) throw TypeError(OBJECT_ALREADY_INITIALIZED);
  20611. metadata.facade = it;
  20612. createNonEnumerableProperty(it, STATE, metadata);
  20613. return metadata;
  20614. };
  20615. get = function (it) {
  20616. return hasOwn(it, STATE) ? it[STATE] : {};
  20617. };
  20618. has = function (it) {
  20619. return hasOwn(it, STATE);
  20620. };
  20621. }
  20622. module.exports = {
  20623. set: set,
  20624. get: get,
  20625. has: has,
  20626. enforce: enforce,
  20627. getterFor: getterFor
  20628. };
  20629. },{"../internals/create-non-enumerable-property":305,"../internals/function-uncurry-this":340,"../internals/global":346,"../internals/has-own-property":347,"../internals/hidden-keys":348,"../internals/is-object":365,"../internals/shared-key":415,"../internals/shared-store":416,"../internals/weak-map-basic-detection":439}],357:[function(_dereq_,module,exports){
  20630. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20631. var Iterators = _dereq_('../internals/iterators');
  20632. var ITERATOR = wellKnownSymbol('iterator');
  20633. var ArrayPrototype = Array.prototype;
  20634. // check on default Array iterator
  20635. module.exports = function (it) {
  20636. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  20637. };
  20638. },{"../internals/iterators":374,"../internals/well-known-symbol":442}],358:[function(_dereq_,module,exports){
  20639. var classof = _dereq_('../internals/classof-raw');
  20640. // `IsArray` abstract operation
  20641. // https://tc39.es/ecma262/#sec-isarray
  20642. // eslint-disable-next-line es-x/no-array-isarray -- safe
  20643. module.exports = Array.isArray || function isArray(argument) {
  20644. return classof(argument) == 'Array';
  20645. };
  20646. },{"../internals/classof-raw":293}],359:[function(_dereq_,module,exports){
  20647. // `IsCallable` abstract operation
  20648. // https://tc39.es/ecma262/#sec-iscallable
  20649. module.exports = function (argument) {
  20650. return typeof argument == 'function';
  20651. };
  20652. },{}],360:[function(_dereq_,module,exports){
  20653. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20654. var fails = _dereq_('../internals/fails');
  20655. var isCallable = _dereq_('../internals/is-callable');
  20656. var classof = _dereq_('../internals/classof');
  20657. var getBuiltIn = _dereq_('../internals/get-built-in');
  20658. var inspectSource = _dereq_('../internals/inspect-source');
  20659. var noop = function () { /* empty */ };
  20660. var empty = [];
  20661. var construct = getBuiltIn('Reflect', 'construct');
  20662. var constructorRegExp = /^\s*(?:class|function)\b/;
  20663. var exec = uncurryThis(constructorRegExp.exec);
  20664. var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
  20665. var isConstructorModern = function isConstructor(argument) {
  20666. if (!isCallable(argument)) return false;
  20667. try {
  20668. construct(noop, empty, argument);
  20669. return true;
  20670. } catch (error) {
  20671. return false;
  20672. }
  20673. };
  20674. var isConstructorLegacy = function isConstructor(argument) {
  20675. if (!isCallable(argument)) return false;
  20676. switch (classof(argument)) {
  20677. case 'AsyncFunction':
  20678. case 'GeneratorFunction':
  20679. case 'AsyncGeneratorFunction': return false;
  20680. }
  20681. try {
  20682. // we can't check .prototype since constructors produced by .bind haven't it
  20683. // `Function#toString` throws on some built-it function in some legacy engines
  20684. // (for example, `DOMQuad` and similar in FF41-)
  20685. return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
  20686. } catch (error) {
  20687. return true;
  20688. }
  20689. };
  20690. isConstructorLegacy.sham = true;
  20691. // `IsConstructor` abstract operation
  20692. // https://tc39.es/ecma262/#sec-isconstructor
  20693. module.exports = !construct || fails(function () {
  20694. var called;
  20695. return isConstructorModern(isConstructorModern.call)
  20696. || !isConstructorModern(Object)
  20697. || !isConstructorModern(function () { called = true; })
  20698. || called;
  20699. }) ? isConstructorLegacy : isConstructorModern;
  20700. },{"../internals/classof":294,"../internals/fails":332,"../internals/function-uncurry-this":340,"../internals/get-built-in":341,"../internals/inspect-source":353,"../internals/is-callable":359}],361:[function(_dereq_,module,exports){
  20701. var hasOwn = _dereq_('../internals/has-own-property');
  20702. module.exports = function (descriptor) {
  20703. return descriptor !== undefined && (hasOwn(descriptor, 'value') || hasOwn(descriptor, 'writable'));
  20704. };
  20705. },{"../internals/has-own-property":347}],362:[function(_dereq_,module,exports){
  20706. var fails = _dereq_('../internals/fails');
  20707. var isCallable = _dereq_('../internals/is-callable');
  20708. var replacement = /#|\.prototype\./;
  20709. var isForced = function (feature, detection) {
  20710. var value = data[normalize(feature)];
  20711. return value == POLYFILL ? true
  20712. : value == NATIVE ? false
  20713. : isCallable(detection) ? fails(detection)
  20714. : !!detection;
  20715. };
  20716. var normalize = isForced.normalize = function (string) {
  20717. return String(string).replace(replacement, '.').toLowerCase();
  20718. };
  20719. var data = isForced.data = {};
  20720. var NATIVE = isForced.NATIVE = 'N';
  20721. var POLYFILL = isForced.POLYFILL = 'P';
  20722. module.exports = isForced;
  20723. },{"../internals/fails":332,"../internals/is-callable":359}],363:[function(_dereq_,module,exports){
  20724. var isObject = _dereq_('../internals/is-object');
  20725. var floor = Math.floor;
  20726. // `IsIntegralNumber` abstract operation
  20727. // https://tc39.es/ecma262/#sec-isintegralnumber
  20728. // eslint-disable-next-line es-x/no-number-isinteger -- safe
  20729. module.exports = Number.isInteger || function isInteger(it) {
  20730. return !isObject(it) && isFinite(it) && floor(it) === it;
  20731. };
  20732. },{"../internals/is-object":365}],364:[function(_dereq_,module,exports){
  20733. // we can't use just `it == null` since of `document.all` special case
  20734. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
  20735. module.exports = function (it) {
  20736. return it === null || it === undefined;
  20737. };
  20738. },{}],365:[function(_dereq_,module,exports){
  20739. var isCallable = _dereq_('../internals/is-callable');
  20740. var documentAll = typeof document == 'object' && document.all;
  20741. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
  20742. var SPECIAL_DOCUMENT_ALL = typeof documentAll == 'undefined' && documentAll !== undefined;
  20743. module.exports = SPECIAL_DOCUMENT_ALL ? function (it) {
  20744. return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll;
  20745. } : function (it) {
  20746. return typeof it == 'object' ? it !== null : isCallable(it);
  20747. };
  20748. },{"../internals/is-callable":359}],366:[function(_dereq_,module,exports){
  20749. module.exports = true;
  20750. },{}],367:[function(_dereq_,module,exports){
  20751. var isObject = _dereq_('../internals/is-object');
  20752. var classof = _dereq_('../internals/classof-raw');
  20753. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20754. var MATCH = wellKnownSymbol('match');
  20755. // `IsRegExp` abstract operation
  20756. // https://tc39.es/ecma262/#sec-isregexp
  20757. module.exports = function (it) {
  20758. var isRegExp;
  20759. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
  20760. };
  20761. },{"../internals/classof-raw":293,"../internals/is-object":365,"../internals/well-known-symbol":442}],368:[function(_dereq_,module,exports){
  20762. var getBuiltIn = _dereq_('../internals/get-built-in');
  20763. var isCallable = _dereq_('../internals/is-callable');
  20764. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  20765. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  20766. var $Object = Object;
  20767. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  20768. return typeof it == 'symbol';
  20769. } : function (it) {
  20770. var $Symbol = getBuiltIn('Symbol');
  20771. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  20772. };
  20773. },{"../internals/get-built-in":341,"../internals/is-callable":359,"../internals/object-is-prototype-of":394,"../internals/use-symbol-as-uid":436}],369:[function(_dereq_,module,exports){
  20774. var bind = _dereq_('../internals/function-bind-context');
  20775. var call = _dereq_('../internals/function-call');
  20776. var anObject = _dereq_('../internals/an-object');
  20777. var tryToString = _dereq_('../internals/try-to-string');
  20778. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  20779. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  20780. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  20781. var getIterator = _dereq_('../internals/get-iterator');
  20782. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  20783. var iteratorClose = _dereq_('../internals/iterator-close');
  20784. var $TypeError = TypeError;
  20785. var Result = function (stopped, result) {
  20786. this.stopped = stopped;
  20787. this.result = result;
  20788. };
  20789. var ResultPrototype = Result.prototype;
  20790. module.exports = function (iterable, unboundFunction, options) {
  20791. var that = options && options.that;
  20792. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  20793. var IS_RECORD = !!(options && options.IS_RECORD);
  20794. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  20795. var INTERRUPTED = !!(options && options.INTERRUPTED);
  20796. var fn = bind(unboundFunction, that);
  20797. var iterator, iterFn, index, length, result, next, step;
  20798. var stop = function (condition) {
  20799. if (iterator) iteratorClose(iterator, 'normal', condition);
  20800. return new Result(true, condition);
  20801. };
  20802. var callFn = function (value) {
  20803. if (AS_ENTRIES) {
  20804. anObject(value);
  20805. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  20806. } return INTERRUPTED ? fn(value, stop) : fn(value);
  20807. };
  20808. if (IS_RECORD) {
  20809. iterator = iterable.iterator;
  20810. } else if (IS_ITERATOR) {
  20811. iterator = iterable;
  20812. } else {
  20813. iterFn = getIteratorMethod(iterable);
  20814. if (!iterFn) throw $TypeError(tryToString(iterable) + ' is not iterable');
  20815. // optimisation for array iterators
  20816. if (isArrayIteratorMethod(iterFn)) {
  20817. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  20818. result = callFn(iterable[index]);
  20819. if (result && isPrototypeOf(ResultPrototype, result)) return result;
  20820. } return new Result(false);
  20821. }
  20822. iterator = getIterator(iterable, iterFn);
  20823. }
  20824. next = IS_RECORD ? iterable.next : iterator.next;
  20825. while (!(step = call(next, iterator)).done) {
  20826. try {
  20827. result = callFn(step.value);
  20828. } catch (error) {
  20829. iteratorClose(iterator, 'throw', error);
  20830. }
  20831. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
  20832. } return new Result(false);
  20833. };
  20834. },{"../internals/an-object":276,"../internals/function-bind-context":335,"../internals/function-call":338,"../internals/get-iterator":343,"../internals/get-iterator-method":342,"../internals/is-array-iterator-method":357,"../internals/iterator-close":370,"../internals/length-of-array-like":375,"../internals/object-is-prototype-of":394,"../internals/try-to-string":434}],370:[function(_dereq_,module,exports){
  20835. var call = _dereq_('../internals/function-call');
  20836. var anObject = _dereq_('../internals/an-object');
  20837. var getMethod = _dereq_('../internals/get-method');
  20838. module.exports = function (iterator, kind, value) {
  20839. var innerResult, innerError;
  20840. anObject(iterator);
  20841. try {
  20842. innerResult = getMethod(iterator, 'return');
  20843. if (!innerResult) {
  20844. if (kind === 'throw') throw value;
  20845. return value;
  20846. }
  20847. innerResult = call(innerResult, iterator);
  20848. } catch (error) {
  20849. innerError = true;
  20850. innerResult = error;
  20851. }
  20852. if (kind === 'throw') throw value;
  20853. if (innerError) throw innerResult;
  20854. anObject(innerResult);
  20855. return value;
  20856. };
  20857. },{"../internals/an-object":276,"../internals/function-call":338,"../internals/get-method":345}],371:[function(_dereq_,module,exports){
  20858. 'use strict';
  20859. var IteratorPrototype = _dereq_('../internals/iterators-core').IteratorPrototype;
  20860. var create = _dereq_('../internals/object-create');
  20861. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  20862. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  20863. var Iterators = _dereq_('../internals/iterators');
  20864. var returnThis = function () { return this; };
  20865. module.exports = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
  20866. var TO_STRING_TAG = NAME + ' Iterator';
  20867. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
  20868. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  20869. Iterators[TO_STRING_TAG] = returnThis;
  20870. return IteratorConstructor;
  20871. };
  20872. },{"../internals/create-property-descriptor":306,"../internals/iterators":374,"../internals/iterators-core":373,"../internals/object-create":385,"../internals/set-to-string-tag":414}],372:[function(_dereq_,module,exports){
  20873. 'use strict';
  20874. var $ = _dereq_('../internals/export');
  20875. var call = _dereq_('../internals/function-call');
  20876. var IS_PURE = _dereq_('../internals/is-pure');
  20877. var FunctionName = _dereq_('../internals/function-name');
  20878. var isCallable = _dereq_('../internals/is-callable');
  20879. var createIteratorConstructor = _dereq_('../internals/iterator-create-constructor');
  20880. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  20881. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  20882. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  20883. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  20884. var defineBuiltIn = _dereq_('../internals/define-built-in');
  20885. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20886. var Iterators = _dereq_('../internals/iterators');
  20887. var IteratorsCore = _dereq_('../internals/iterators-core');
  20888. var PROPER_FUNCTION_NAME = FunctionName.PROPER;
  20889. var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
  20890. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  20891. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  20892. var ITERATOR = wellKnownSymbol('iterator');
  20893. var KEYS = 'keys';
  20894. var VALUES = 'values';
  20895. var ENTRIES = 'entries';
  20896. var returnThis = function () { return this; };
  20897. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  20898. createIteratorConstructor(IteratorConstructor, NAME, next);
  20899. var getIterationMethod = function (KIND) {
  20900. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  20901. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
  20902. switch (KIND) {
  20903. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  20904. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  20905. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  20906. } return function () { return new IteratorConstructor(this); };
  20907. };
  20908. var TO_STRING_TAG = NAME + ' Iterator';
  20909. var INCORRECT_VALUES_NAME = false;
  20910. var IterablePrototype = Iterable.prototype;
  20911. var nativeIterator = IterablePrototype[ITERATOR]
  20912. || IterablePrototype['@@iterator']
  20913. || DEFAULT && IterablePrototype[DEFAULT];
  20914. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  20915. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  20916. var CurrentIteratorPrototype, methods, KEY;
  20917. // fix native
  20918. if (anyNativeIterator) {
  20919. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  20920. if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  20921. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  20922. if (setPrototypeOf) {
  20923. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  20924. } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
  20925. defineBuiltIn(CurrentIteratorPrototype, ITERATOR, returnThis);
  20926. }
  20927. }
  20928. // Set @@toStringTag to native iterators
  20929. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  20930. if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
  20931. }
  20932. }
  20933. // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
  20934. if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  20935. if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) {
  20936. createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
  20937. } else {
  20938. INCORRECT_VALUES_NAME = true;
  20939. defaultIterator = function values() { return call(nativeIterator, this); };
  20940. }
  20941. }
  20942. // export additional methods
  20943. if (DEFAULT) {
  20944. methods = {
  20945. values: getIterationMethod(VALUES),
  20946. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  20947. entries: getIterationMethod(ENTRIES)
  20948. };
  20949. if (FORCED) for (KEY in methods) {
  20950. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  20951. defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
  20952. }
  20953. } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
  20954. }
  20955. // define iterator
  20956. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  20957. defineBuiltIn(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });
  20958. }
  20959. Iterators[NAME] = defaultIterator;
  20960. return methods;
  20961. };
  20962. },{"../internals/create-non-enumerable-property":305,"../internals/define-built-in":308,"../internals/export":331,"../internals/function-call":338,"../internals/function-name":339,"../internals/is-callable":359,"../internals/is-pure":366,"../internals/iterator-create-constructor":371,"../internals/iterators":374,"../internals/iterators-core":373,"../internals/object-get-prototype-of":392,"../internals/object-set-prototype-of":398,"../internals/set-to-string-tag":414,"../internals/well-known-symbol":442}],373:[function(_dereq_,module,exports){
  20963. 'use strict';
  20964. var fails = _dereq_('../internals/fails');
  20965. var isCallable = _dereq_('../internals/is-callable');
  20966. var isObject = _dereq_('../internals/is-object');
  20967. var create = _dereq_('../internals/object-create');
  20968. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  20969. var defineBuiltIn = _dereq_('../internals/define-built-in');
  20970. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20971. var IS_PURE = _dereq_('../internals/is-pure');
  20972. var ITERATOR = wellKnownSymbol('iterator');
  20973. var BUGGY_SAFARI_ITERATORS = false;
  20974. // `%IteratorPrototype%` object
  20975. // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
  20976. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  20977. /* eslint-disable es-x/no-array-prototype-keys -- safe */
  20978. if ([].keys) {
  20979. arrayIterator = [].keys();
  20980. // Safari 8 has buggy iterators w/o `next`
  20981. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  20982. else {
  20983. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  20984. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  20985. }
  20986. }
  20987. var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () {
  20988. var test = {};
  20989. // FF44- legacy iterators case
  20990. return IteratorPrototype[ITERATOR].call(test) !== test;
  20991. });
  20992. if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
  20993. else if (IS_PURE) IteratorPrototype = create(IteratorPrototype);
  20994. // `%IteratorPrototype%[@@iterator]()` method
  20995. // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
  20996. if (!isCallable(IteratorPrototype[ITERATOR])) {
  20997. defineBuiltIn(IteratorPrototype, ITERATOR, function () {
  20998. return this;
  20999. });
  21000. }
  21001. module.exports = {
  21002. IteratorPrototype: IteratorPrototype,
  21003. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  21004. };
  21005. },{"../internals/define-built-in":308,"../internals/fails":332,"../internals/is-callable":359,"../internals/is-object":365,"../internals/is-pure":366,"../internals/object-create":385,"../internals/object-get-prototype-of":392,"../internals/well-known-symbol":442}],374:[function(_dereq_,module,exports){
  21006. arguments[4][348][0].apply(exports,arguments)
  21007. },{"dup":348}],375:[function(_dereq_,module,exports){
  21008. var toLength = _dereq_('../internals/to-length');
  21009. // `LengthOfArrayLike` abstract operation
  21010. // https://tc39.es/ecma262/#sec-lengthofarraylike
  21011. module.exports = function (obj) {
  21012. return toLength(obj.length);
  21013. };
  21014. },{"../internals/to-length":428}],376:[function(_dereq_,module,exports){
  21015. 'use strict';
  21016. var call = _dereq_('../internals/function-call');
  21017. var aCallable = _dereq_('../internals/a-callable');
  21018. var anObject = _dereq_('../internals/an-object');
  21019. // `Map.prototype.emplace` method
  21020. // https://github.com/thumbsupep/proposal-upsert
  21021. module.exports = function emplace(key, handler) {
  21022. var map = anObject(this);
  21023. var get = aCallable(map.get);
  21024. var has = aCallable(map.has);
  21025. var set = aCallable(map.set);
  21026. var value, inserted;
  21027. if (call(has, map, key)) {
  21028. value = call(get, map, key);
  21029. if ('update' in handler) {
  21030. value = handler.update(value, key, map);
  21031. call(set, map, key, value);
  21032. } return value;
  21033. }
  21034. inserted = handler.insert(key, map);
  21035. call(set, map, key, inserted);
  21036. return inserted;
  21037. };
  21038. },{"../internals/a-callable":271,"../internals/an-object":276,"../internals/function-call":338}],377:[function(_dereq_,module,exports){
  21039. 'use strict';
  21040. var call = _dereq_('../internals/function-call');
  21041. var aCallable = _dereq_('../internals/a-callable');
  21042. var isCallable = _dereq_('../internals/is-callable');
  21043. var anObject = _dereq_('../internals/an-object');
  21044. var $TypeError = TypeError;
  21045. // `Map.prototype.upsert` method
  21046. // https://github.com/thumbsupep/proposal-upsert
  21047. module.exports = function upsert(key, updateFn /* , insertFn */) {
  21048. var map = anObject(this);
  21049. var get = aCallable(map.get);
  21050. var has = aCallable(map.has);
  21051. var set = aCallable(map.set);
  21052. var insertFn = arguments.length > 2 ? arguments[2] : undefined;
  21053. var value;
  21054. if (!isCallable(updateFn) && !isCallable(insertFn)) {
  21055. throw $TypeError('At least one callback required');
  21056. }
  21057. if (call(has, map, key)) {
  21058. value = call(get, map, key);
  21059. if (isCallable(updateFn)) {
  21060. value = updateFn(value);
  21061. call(set, map, key, value);
  21062. }
  21063. } else if (isCallable(insertFn)) {
  21064. value = insertFn();
  21065. call(set, map, key, value);
  21066. } return value;
  21067. };
  21068. },{"../internals/a-callable":271,"../internals/an-object":276,"../internals/function-call":338,"../internals/is-callable":359}],378:[function(_dereq_,module,exports){
  21069. var ceil = Math.ceil;
  21070. var floor = Math.floor;
  21071. // `Math.trunc` method
  21072. // https://tc39.es/ecma262/#sec-math.trunc
  21073. // eslint-disable-next-line es-x/no-math-trunc -- safe
  21074. module.exports = Math.trunc || function trunc(x) {
  21075. var n = +x;
  21076. return (n > 0 ? floor : ceil)(n);
  21077. };
  21078. },{}],379:[function(_dereq_,module,exports){
  21079. var global = _dereq_('../internals/global');
  21080. var bind = _dereq_('../internals/function-bind-context');
  21081. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  21082. var macrotask = _dereq_('../internals/task').set;
  21083. var IS_IOS = _dereq_('../internals/engine-is-ios');
  21084. var IS_IOS_PEBBLE = _dereq_('../internals/engine-is-ios-pebble');
  21085. var IS_WEBOS_WEBKIT = _dereq_('../internals/engine-is-webos-webkit');
  21086. var IS_NODE = _dereq_('../internals/engine-is-node');
  21087. var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
  21088. var document = global.document;
  21089. var process = global.process;
  21090. var Promise = global.Promise;
  21091. // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
  21092. var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
  21093. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  21094. var flush, head, last, notify, toggle, node, promise, then;
  21095. // modern engines have queueMicrotask method
  21096. if (!queueMicrotask) {
  21097. flush = function () {
  21098. var parent, fn;
  21099. if (IS_NODE && (parent = process.domain)) parent.exit();
  21100. while (head) {
  21101. fn = head.fn;
  21102. head = head.next;
  21103. try {
  21104. fn();
  21105. } catch (error) {
  21106. if (head) notify();
  21107. else last = undefined;
  21108. throw error;
  21109. }
  21110. } last = undefined;
  21111. if (parent) parent.enter();
  21112. };
  21113. // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
  21114. // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
  21115. if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {
  21116. toggle = true;
  21117. node = document.createTextNode('');
  21118. new MutationObserver(flush).observe(node, { characterData: true });
  21119. notify = function () {
  21120. node.data = toggle = !toggle;
  21121. };
  21122. // environments with maybe non-completely correct, but existent Promise
  21123. } else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) {
  21124. // Promise.resolve without an argument throws an error in LG WebOS 2
  21125. promise = Promise.resolve(undefined);
  21126. // workaround of WebKit ~ iOS Safari 10.1 bug
  21127. promise.constructor = Promise;
  21128. then = bind(promise.then, promise);
  21129. notify = function () {
  21130. then(flush);
  21131. };
  21132. // Node.js without promises
  21133. } else if (IS_NODE) {
  21134. notify = function () {
  21135. process.nextTick(flush);
  21136. };
  21137. // for other environments - macrotask based on:
  21138. // - setImmediate
  21139. // - MessageChannel
  21140. // - window.postMessage
  21141. // - onreadystatechange
  21142. // - setTimeout
  21143. } else {
  21144. // strange IE + webpack dev server bug - use .bind(global)
  21145. macrotask = bind(macrotask, global);
  21146. notify = function () {
  21147. macrotask(flush);
  21148. };
  21149. }
  21150. }
  21151. module.exports = queueMicrotask || function (fn) {
  21152. var task = { fn: fn, next: undefined };
  21153. if (last) last.next = task;
  21154. if (!head) {
  21155. head = task;
  21156. notify();
  21157. } last = task;
  21158. };
  21159. },{"../internals/engine-is-ios":321,"../internals/engine-is-ios-pebble":320,"../internals/engine-is-node":322,"../internals/engine-is-webos-webkit":323,"../internals/function-bind-context":335,"../internals/global":346,"../internals/object-get-own-property-descriptor":388,"../internals/task":424}],380:[function(_dereq_,module,exports){
  21160. 'use strict';
  21161. var aCallable = _dereq_('../internals/a-callable');
  21162. var $TypeError = TypeError;
  21163. var PromiseCapability = function (C) {
  21164. var resolve, reject;
  21165. this.promise = new C(function ($$resolve, $$reject) {
  21166. if (resolve !== undefined || reject !== undefined) throw $TypeError('Bad Promise constructor');
  21167. resolve = $$resolve;
  21168. reject = $$reject;
  21169. });
  21170. this.resolve = aCallable(resolve);
  21171. this.reject = aCallable(reject);
  21172. };
  21173. // `NewPromiseCapability` abstract operation
  21174. // https://tc39.es/ecma262/#sec-newpromisecapability
  21175. module.exports.f = function (C) {
  21176. return new PromiseCapability(C);
  21177. };
  21178. },{"../internals/a-callable":271}],381:[function(_dereq_,module,exports){
  21179. var toString = _dereq_('../internals/to-string');
  21180. module.exports = function (argument, $default) {
  21181. return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
  21182. };
  21183. },{"../internals/to-string":433}],382:[function(_dereq_,module,exports){
  21184. var isRegExp = _dereq_('../internals/is-regexp');
  21185. var $TypeError = TypeError;
  21186. module.exports = function (it) {
  21187. if (isRegExp(it)) {
  21188. throw $TypeError("The method doesn't accept regular expressions");
  21189. } return it;
  21190. };
  21191. },{"../internals/is-regexp":367}],383:[function(_dereq_,module,exports){
  21192. var global = _dereq_('../internals/global');
  21193. var fails = _dereq_('../internals/fails');
  21194. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21195. var toString = _dereq_('../internals/to-string');
  21196. var trim = _dereq_('../internals/string-trim').trim;
  21197. var whitespaces = _dereq_('../internals/whitespaces');
  21198. var $parseInt = global.parseInt;
  21199. var Symbol = global.Symbol;
  21200. var ITERATOR = Symbol && Symbol.iterator;
  21201. var hex = /^[+-]?0x/i;
  21202. var exec = uncurryThis(hex.exec);
  21203. var FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22
  21204. // MS Edge 18- broken with boxed symbols
  21205. || (ITERATOR && !fails(function () { $parseInt(Object(ITERATOR)); }));
  21206. // `parseInt` method
  21207. // https://tc39.es/ecma262/#sec-parseint-string-radix
  21208. module.exports = FORCED ? function parseInt(string, radix) {
  21209. var S = trim(toString(string));
  21210. return $parseInt(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
  21211. } : $parseInt;
  21212. },{"../internals/fails":332,"../internals/function-uncurry-this":340,"../internals/global":346,"../internals/string-trim":420,"../internals/to-string":433,"../internals/whitespaces":443}],384:[function(_dereq_,module,exports){
  21213. 'use strict';
  21214. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21215. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21216. var call = _dereq_('../internals/function-call');
  21217. var fails = _dereq_('../internals/fails');
  21218. var objectKeys = _dereq_('../internals/object-keys');
  21219. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  21220. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  21221. var toObject = _dereq_('../internals/to-object');
  21222. var IndexedObject = _dereq_('../internals/indexed-object');
  21223. // eslint-disable-next-line es-x/no-object-assign -- safe
  21224. var $assign = Object.assign;
  21225. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  21226. var defineProperty = Object.defineProperty;
  21227. var concat = uncurryThis([].concat);
  21228. // `Object.assign` method
  21229. // https://tc39.es/ecma262/#sec-object.assign
  21230. module.exports = !$assign || fails(function () {
  21231. // should have correct order of operations (Edge bug)
  21232. if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
  21233. enumerable: true,
  21234. get: function () {
  21235. defineProperty(this, 'b', {
  21236. value: 3,
  21237. enumerable: false
  21238. });
  21239. }
  21240. }), { b: 2 })).b !== 1) return true;
  21241. // should work with symbols and should have deterministic property order (V8 bug)
  21242. var A = {};
  21243. var B = {};
  21244. // eslint-disable-next-line es-x/no-symbol -- safe
  21245. var symbol = Symbol();
  21246. var alphabet = 'abcdefghijklmnopqrst';
  21247. A[symbol] = 7;
  21248. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  21249. return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet;
  21250. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
  21251. var T = toObject(target);
  21252. var argumentsLength = arguments.length;
  21253. var index = 1;
  21254. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  21255. var propertyIsEnumerable = propertyIsEnumerableModule.f;
  21256. while (argumentsLength > index) {
  21257. var S = IndexedObject(arguments[index++]);
  21258. var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
  21259. var length = keys.length;
  21260. var j = 0;
  21261. var key;
  21262. while (length > j) {
  21263. key = keys[j++];
  21264. if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
  21265. }
  21266. } return T;
  21267. } : $assign;
  21268. },{"../internals/descriptors":312,"../internals/fails":332,"../internals/function-call":338,"../internals/function-uncurry-this":340,"../internals/indexed-object":352,"../internals/object-get-own-property-symbols":391,"../internals/object-keys":396,"../internals/object-property-is-enumerable":397,"../internals/to-object":429}],385:[function(_dereq_,module,exports){
  21269. /* global ActiveXObject -- old IE, WSH */
  21270. var anObject = _dereq_('../internals/an-object');
  21271. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  21272. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  21273. var hiddenKeys = _dereq_('../internals/hidden-keys');
  21274. var html = _dereq_('../internals/html');
  21275. var documentCreateElement = _dereq_('../internals/document-create-element');
  21276. var sharedKey = _dereq_('../internals/shared-key');
  21277. var GT = '>';
  21278. var LT = '<';
  21279. var PROTOTYPE = 'prototype';
  21280. var SCRIPT = 'script';
  21281. var IE_PROTO = sharedKey('IE_PROTO');
  21282. var EmptyConstructor = function () { /* empty */ };
  21283. var scriptTag = function (content) {
  21284. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  21285. };
  21286. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  21287. var NullProtoObjectViaActiveX = function (activeXDocument) {
  21288. activeXDocument.write(scriptTag(''));
  21289. activeXDocument.close();
  21290. var temp = activeXDocument.parentWindow.Object;
  21291. activeXDocument = null; // avoid memory leak
  21292. return temp;
  21293. };
  21294. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  21295. var NullProtoObjectViaIFrame = function () {
  21296. // Thrash, waste and sodomy: IE GC bug
  21297. var iframe = documentCreateElement('iframe');
  21298. var JS = 'java' + SCRIPT + ':';
  21299. var iframeDocument;
  21300. iframe.style.display = 'none';
  21301. html.appendChild(iframe);
  21302. // https://github.com/zloirock/core-js/issues/475
  21303. iframe.src = String(JS);
  21304. iframeDocument = iframe.contentWindow.document;
  21305. iframeDocument.open();
  21306. iframeDocument.write(scriptTag('document.F=Object'));
  21307. iframeDocument.close();
  21308. return iframeDocument.F;
  21309. };
  21310. // Check for document.domain and active x support
  21311. // No need to use active x approach when document.domain is not set
  21312. // see https://github.com/es-shims/es5-shim/issues/150
  21313. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  21314. // avoid IE GC bug
  21315. var activeXDocument;
  21316. var NullProtoObject = function () {
  21317. try {
  21318. activeXDocument = new ActiveXObject('htmlfile');
  21319. } catch (error) { /* ignore */ }
  21320. NullProtoObject = typeof document != 'undefined'
  21321. ? document.domain && activeXDocument
  21322. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  21323. : NullProtoObjectViaIFrame()
  21324. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  21325. var length = enumBugKeys.length;
  21326. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  21327. return NullProtoObject();
  21328. };
  21329. hiddenKeys[IE_PROTO] = true;
  21330. // `Object.create` method
  21331. // https://tc39.es/ecma262/#sec-object.create
  21332. // eslint-disable-next-line es-x/no-object-create -- safe
  21333. module.exports = Object.create || function create(O, Properties) {
  21334. var result;
  21335. if (O !== null) {
  21336. EmptyConstructor[PROTOTYPE] = anObject(O);
  21337. result = new EmptyConstructor();
  21338. EmptyConstructor[PROTOTYPE] = null;
  21339. // add "__proto__" for Object.getPrototypeOf polyfill
  21340. result[IE_PROTO] = O;
  21341. } else result = NullProtoObject();
  21342. return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
  21343. };
  21344. },{"../internals/an-object":276,"../internals/document-create-element":313,"../internals/enum-bug-keys":328,"../internals/hidden-keys":348,"../internals/html":350,"../internals/object-define-properties":386,"../internals/shared-key":415}],386:[function(_dereq_,module,exports){
  21345. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21346. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  21347. var definePropertyModule = _dereq_('../internals/object-define-property');
  21348. var anObject = _dereq_('../internals/an-object');
  21349. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  21350. var objectKeys = _dereq_('../internals/object-keys');
  21351. // `Object.defineProperties` method
  21352. // https://tc39.es/ecma262/#sec-object.defineproperties
  21353. // eslint-disable-next-line es-x/no-object-defineproperties -- safe
  21354. exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
  21355. anObject(O);
  21356. var props = toIndexedObject(Properties);
  21357. var keys = objectKeys(Properties);
  21358. var length = keys.length;
  21359. var index = 0;
  21360. var key;
  21361. while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
  21362. return O;
  21363. };
  21364. },{"../internals/an-object":276,"../internals/descriptors":312,"../internals/object-define-property":387,"../internals/object-keys":396,"../internals/to-indexed-object":426,"../internals/v8-prototype-define-bug":437}],387:[function(_dereq_,module,exports){
  21365. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21366. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  21367. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  21368. var anObject = _dereq_('../internals/an-object');
  21369. var toPropertyKey = _dereq_('../internals/to-property-key');
  21370. var $TypeError = TypeError;
  21371. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  21372. var $defineProperty = Object.defineProperty;
  21373. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  21374. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  21375. var ENUMERABLE = 'enumerable';
  21376. var CONFIGURABLE = 'configurable';
  21377. var WRITABLE = 'writable';
  21378. // `Object.defineProperty` method
  21379. // https://tc39.es/ecma262/#sec-object.defineproperty
  21380. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  21381. anObject(O);
  21382. P = toPropertyKey(P);
  21383. anObject(Attributes);
  21384. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  21385. var current = $getOwnPropertyDescriptor(O, P);
  21386. if (current && current[WRITABLE]) {
  21387. O[P] = Attributes.value;
  21388. Attributes = {
  21389. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  21390. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  21391. writable: false
  21392. };
  21393. }
  21394. } return $defineProperty(O, P, Attributes);
  21395. } : $defineProperty : function defineProperty(O, P, Attributes) {
  21396. anObject(O);
  21397. P = toPropertyKey(P);
  21398. anObject(Attributes);
  21399. if (IE8_DOM_DEFINE) try {
  21400. return $defineProperty(O, P, Attributes);
  21401. } catch (error) { /* empty */ }
  21402. if ('get' in Attributes || 'set' in Attributes) throw $TypeError('Accessors not supported');
  21403. if ('value' in Attributes) O[P] = Attributes.value;
  21404. return O;
  21405. };
  21406. },{"../internals/an-object":276,"../internals/descriptors":312,"../internals/ie8-dom-define":351,"../internals/to-property-key":431,"../internals/v8-prototype-define-bug":437}],388:[function(_dereq_,module,exports){
  21407. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21408. var call = _dereq_('../internals/function-call');
  21409. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  21410. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  21411. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  21412. var toPropertyKey = _dereq_('../internals/to-property-key');
  21413. var hasOwn = _dereq_('../internals/has-own-property');
  21414. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  21415. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  21416. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  21417. // `Object.getOwnPropertyDescriptor` method
  21418. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  21419. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  21420. O = toIndexedObject(O);
  21421. P = toPropertyKey(P);
  21422. if (IE8_DOM_DEFINE) try {
  21423. return $getOwnPropertyDescriptor(O, P);
  21424. } catch (error) { /* empty */ }
  21425. if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  21426. };
  21427. },{"../internals/create-property-descriptor":306,"../internals/descriptors":312,"../internals/function-call":338,"../internals/has-own-property":347,"../internals/ie8-dom-define":351,"../internals/object-property-is-enumerable":397,"../internals/to-indexed-object":426,"../internals/to-property-key":431}],389:[function(_dereq_,module,exports){
  21428. /* eslint-disable es-x/no-object-getownpropertynames -- safe */
  21429. var classof = _dereq_('../internals/classof-raw');
  21430. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  21431. var $getOwnPropertyNames = _dereq_('../internals/object-get-own-property-names').f;
  21432. var arraySlice = _dereq_('../internals/array-slice-simple');
  21433. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  21434. ? Object.getOwnPropertyNames(window) : [];
  21435. var getWindowNames = function (it) {
  21436. try {
  21437. return $getOwnPropertyNames(it);
  21438. } catch (error) {
  21439. return arraySlice(windowNames);
  21440. }
  21441. };
  21442. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  21443. module.exports.f = function getOwnPropertyNames(it) {
  21444. return windowNames && classof(it) == 'Window'
  21445. ? getWindowNames(it)
  21446. : $getOwnPropertyNames(toIndexedObject(it));
  21447. };
  21448. },{"../internals/array-slice-simple":286,"../internals/classof-raw":293,"../internals/object-get-own-property-names":390,"../internals/to-indexed-object":426}],390:[function(_dereq_,module,exports){
  21449. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  21450. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  21451. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  21452. // `Object.getOwnPropertyNames` method
  21453. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  21454. // eslint-disable-next-line es-x/no-object-getownpropertynames -- safe
  21455. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  21456. return internalObjectKeys(O, hiddenKeys);
  21457. };
  21458. },{"../internals/enum-bug-keys":328,"../internals/object-keys-internal":395}],391:[function(_dereq_,module,exports){
  21459. // eslint-disable-next-line es-x/no-object-getownpropertysymbols -- safe
  21460. exports.f = Object.getOwnPropertySymbols;
  21461. },{}],392:[function(_dereq_,module,exports){
  21462. var hasOwn = _dereq_('../internals/has-own-property');
  21463. var isCallable = _dereq_('../internals/is-callable');
  21464. var toObject = _dereq_('../internals/to-object');
  21465. var sharedKey = _dereq_('../internals/shared-key');
  21466. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  21467. var IE_PROTO = sharedKey('IE_PROTO');
  21468. var $Object = Object;
  21469. var ObjectPrototype = $Object.prototype;
  21470. // `Object.getPrototypeOf` method
  21471. // https://tc39.es/ecma262/#sec-object.getprototypeof
  21472. // eslint-disable-next-line es-x/no-object-getprototypeof -- safe
  21473. module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
  21474. var object = toObject(O);
  21475. if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
  21476. var constructor = object.constructor;
  21477. if (isCallable(constructor) && object instanceof constructor) {
  21478. return constructor.prototype;
  21479. } return object instanceof $Object ? ObjectPrototype : null;
  21480. };
  21481. },{"../internals/correct-prototype-getter":303,"../internals/has-own-property":347,"../internals/is-callable":359,"../internals/shared-key":415,"../internals/to-object":429}],393:[function(_dereq_,module,exports){
  21482. var fails = _dereq_('../internals/fails');
  21483. var isObject = _dereq_('../internals/is-object');
  21484. var classof = _dereq_('../internals/classof-raw');
  21485. var ARRAY_BUFFER_NON_EXTENSIBLE = _dereq_('../internals/array-buffer-non-extensible');
  21486. // eslint-disable-next-line es-x/no-object-isextensible -- safe
  21487. var $isExtensible = Object.isExtensible;
  21488. var FAILS_ON_PRIMITIVES = fails(function () { $isExtensible(1); });
  21489. // `Object.isExtensible` method
  21490. // https://tc39.es/ecma262/#sec-object.isextensible
  21491. module.exports = (FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE) ? function isExtensible(it) {
  21492. if (!isObject(it)) return false;
  21493. if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return false;
  21494. return $isExtensible ? $isExtensible(it) : true;
  21495. } : $isExtensible;
  21496. },{"../internals/array-buffer-non-extensible":277,"../internals/classof-raw":293,"../internals/fails":332,"../internals/is-object":365}],394:[function(_dereq_,module,exports){
  21497. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21498. module.exports = uncurryThis({}.isPrototypeOf);
  21499. },{"../internals/function-uncurry-this":340}],395:[function(_dereq_,module,exports){
  21500. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21501. var hasOwn = _dereq_('../internals/has-own-property');
  21502. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  21503. var indexOf = _dereq_('../internals/array-includes').indexOf;
  21504. var hiddenKeys = _dereq_('../internals/hidden-keys');
  21505. var push = uncurryThis([].push);
  21506. module.exports = function (object, names) {
  21507. var O = toIndexedObject(object);
  21508. var i = 0;
  21509. var result = [];
  21510. var key;
  21511. for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  21512. // Don't enum bug & hidden keys
  21513. while (names.length > i) if (hasOwn(O, key = names[i++])) {
  21514. ~indexOf(result, key) || push(result, key);
  21515. }
  21516. return result;
  21517. };
  21518. },{"../internals/array-includes":280,"../internals/function-uncurry-this":340,"../internals/has-own-property":347,"../internals/hidden-keys":348,"../internals/to-indexed-object":426}],396:[function(_dereq_,module,exports){
  21519. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  21520. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  21521. // `Object.keys` method
  21522. // https://tc39.es/ecma262/#sec-object.keys
  21523. // eslint-disable-next-line es-x/no-object-keys -- safe
  21524. module.exports = Object.keys || function keys(O) {
  21525. return internalObjectKeys(O, enumBugKeys);
  21526. };
  21527. },{"../internals/enum-bug-keys":328,"../internals/object-keys-internal":395}],397:[function(_dereq_,module,exports){
  21528. 'use strict';
  21529. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  21530. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  21531. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  21532. // Nashorn ~ JDK8 bug
  21533. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  21534. // `Object.prototype.propertyIsEnumerable` method implementation
  21535. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  21536. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  21537. var descriptor = getOwnPropertyDescriptor(this, V);
  21538. return !!descriptor && descriptor.enumerable;
  21539. } : $propertyIsEnumerable;
  21540. },{}],398:[function(_dereq_,module,exports){
  21541. /* eslint-disable no-proto -- safe */
  21542. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21543. var anObject = _dereq_('../internals/an-object');
  21544. var aPossiblePrototype = _dereq_('../internals/a-possible-prototype');
  21545. // `Object.setPrototypeOf` method
  21546. // https://tc39.es/ecma262/#sec-object.setprototypeof
  21547. // Works with __proto__ only. Old v8 can't work with null proto objects.
  21548. // eslint-disable-next-line es-x/no-object-setprototypeof -- safe
  21549. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  21550. var CORRECT_SETTER = false;
  21551. var test = {};
  21552. var setter;
  21553. try {
  21554. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  21555. setter = uncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
  21556. setter(test, []);
  21557. CORRECT_SETTER = test instanceof Array;
  21558. } catch (error) { /* empty */ }
  21559. return function setPrototypeOf(O, proto) {
  21560. anObject(O);
  21561. aPossiblePrototype(proto);
  21562. if (CORRECT_SETTER) setter(O, proto);
  21563. else O.__proto__ = proto;
  21564. return O;
  21565. };
  21566. }() : undefined);
  21567. },{"../internals/a-possible-prototype":273,"../internals/an-object":276,"../internals/function-uncurry-this":340}],399:[function(_dereq_,module,exports){
  21568. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21569. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21570. var objectKeys = _dereq_('../internals/object-keys');
  21571. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  21572. var $propertyIsEnumerable = _dereq_('../internals/object-property-is-enumerable').f;
  21573. var propertyIsEnumerable = uncurryThis($propertyIsEnumerable);
  21574. var push = uncurryThis([].push);
  21575. // `Object.{ entries, values }` methods implementation
  21576. var createMethod = function (TO_ENTRIES) {
  21577. return function (it) {
  21578. var O = toIndexedObject(it);
  21579. var keys = objectKeys(O);
  21580. var length = keys.length;
  21581. var i = 0;
  21582. var result = [];
  21583. var key;
  21584. while (length > i) {
  21585. key = keys[i++];
  21586. if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
  21587. push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
  21588. }
  21589. }
  21590. return result;
  21591. };
  21592. };
  21593. module.exports = {
  21594. // `Object.entries` method
  21595. // https://tc39.es/ecma262/#sec-object.entries
  21596. entries: createMethod(true),
  21597. // `Object.values` method
  21598. // https://tc39.es/ecma262/#sec-object.values
  21599. values: createMethod(false)
  21600. };
  21601. },{"../internals/descriptors":312,"../internals/function-uncurry-this":340,"../internals/object-keys":396,"../internals/object-property-is-enumerable":397,"../internals/to-indexed-object":426}],400:[function(_dereq_,module,exports){
  21602. 'use strict';
  21603. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  21604. var classof = _dereq_('../internals/classof');
  21605. // `Object.prototype.toString` method implementation
  21606. // https://tc39.es/ecma262/#sec-object.prototype.tostring
  21607. module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
  21608. return '[object ' + classof(this) + ']';
  21609. };
  21610. },{"../internals/classof":294,"../internals/to-string-tag-support":432}],401:[function(_dereq_,module,exports){
  21611. var call = _dereq_('../internals/function-call');
  21612. var isCallable = _dereq_('../internals/is-callable');
  21613. var isObject = _dereq_('../internals/is-object');
  21614. var $TypeError = TypeError;
  21615. // `OrdinaryToPrimitive` abstract operation
  21616. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  21617. module.exports = function (input, pref) {
  21618. var fn, val;
  21619. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  21620. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
  21621. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  21622. throw $TypeError("Can't convert object to primitive value");
  21623. };
  21624. },{"../internals/function-call":338,"../internals/is-callable":359,"../internals/is-object":365}],402:[function(_dereq_,module,exports){
  21625. var getBuiltIn = _dereq_('../internals/get-built-in');
  21626. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21627. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  21628. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  21629. var anObject = _dereq_('../internals/an-object');
  21630. var concat = uncurryThis([].concat);
  21631. // all object keys, includes non-enumerable and symbols
  21632. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  21633. var keys = getOwnPropertyNamesModule.f(anObject(it));
  21634. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  21635. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  21636. };
  21637. },{"../internals/an-object":276,"../internals/function-uncurry-this":340,"../internals/get-built-in":341,"../internals/object-get-own-property-names":390,"../internals/object-get-own-property-symbols":391}],403:[function(_dereq_,module,exports){
  21638. arguments[4][348][0].apply(exports,arguments)
  21639. },{"dup":348}],404:[function(_dereq_,module,exports){
  21640. module.exports = function (exec) {
  21641. try {
  21642. return { error: false, value: exec() };
  21643. } catch (error) {
  21644. return { error: true, value: error };
  21645. }
  21646. };
  21647. },{}],405:[function(_dereq_,module,exports){
  21648. var global = _dereq_('../internals/global');
  21649. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  21650. var isCallable = _dereq_('../internals/is-callable');
  21651. var isForced = _dereq_('../internals/is-forced');
  21652. var inspectSource = _dereq_('../internals/inspect-source');
  21653. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  21654. var IS_BROWSER = _dereq_('../internals/engine-is-browser');
  21655. var IS_DENO = _dereq_('../internals/engine-is-deno');
  21656. var IS_PURE = _dereq_('../internals/is-pure');
  21657. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  21658. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  21659. var SPECIES = wellKnownSymbol('species');
  21660. var SUBCLASSING = false;
  21661. var NATIVE_PROMISE_REJECTION_EVENT = isCallable(global.PromiseRejectionEvent);
  21662. var FORCED_PROMISE_CONSTRUCTOR = isForced('Promise', function () {
  21663. var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(NativePromiseConstructor);
  21664. var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(NativePromiseConstructor);
  21665. // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  21666. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  21667. // We can't detect it synchronously, so just check versions
  21668. if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
  21669. // We need Promise#{ catch, finally } in the pure version for preventing prototype pollution
  21670. if (IS_PURE && !(NativePromisePrototype['catch'] && NativePromisePrototype['finally'])) return true;
  21671. // We can't use @@species feature detection in V8 since it causes
  21672. // deoptimization and performance degradation
  21673. // https://github.com/zloirock/core-js/issues/679
  21674. if (!V8_VERSION || V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) {
  21675. // Detect correctness of subclassing with @@species support
  21676. var promise = new NativePromiseConstructor(function (resolve) { resolve(1); });
  21677. var FakePromise = function (exec) {
  21678. exec(function () { /* empty */ }, function () { /* empty */ });
  21679. };
  21680. var constructor = promise.constructor = {};
  21681. constructor[SPECIES] = FakePromise;
  21682. SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
  21683. if (!SUBCLASSING) return true;
  21684. // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  21685. } return !GLOBAL_CORE_JS_PROMISE && (IS_BROWSER || IS_DENO) && !NATIVE_PROMISE_REJECTION_EVENT;
  21686. });
  21687. module.exports = {
  21688. CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR,
  21689. REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT,
  21690. SUBCLASSING: SUBCLASSING
  21691. };
  21692. },{"../internals/engine-is-browser":317,"../internals/engine-is-deno":318,"../internals/engine-v8-version":325,"../internals/global":346,"../internals/inspect-source":353,"../internals/is-callable":359,"../internals/is-forced":362,"../internals/is-pure":366,"../internals/promise-native-constructor":406,"../internals/well-known-symbol":442}],406:[function(_dereq_,module,exports){
  21693. var global = _dereq_('../internals/global');
  21694. module.exports = global.Promise;
  21695. },{"../internals/global":346}],407:[function(_dereq_,module,exports){
  21696. var anObject = _dereq_('../internals/an-object');
  21697. var isObject = _dereq_('../internals/is-object');
  21698. var newPromiseCapability = _dereq_('../internals/new-promise-capability');
  21699. module.exports = function (C, x) {
  21700. anObject(C);
  21701. if (isObject(x) && x.constructor === C) return x;
  21702. var promiseCapability = newPromiseCapability.f(C);
  21703. var resolve = promiseCapability.resolve;
  21704. resolve(x);
  21705. return promiseCapability.promise;
  21706. };
  21707. },{"../internals/an-object":276,"../internals/is-object":365,"../internals/new-promise-capability":380}],408:[function(_dereq_,module,exports){
  21708. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  21709. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  21710. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  21711. module.exports = FORCED_PROMISE_CONSTRUCTOR || !checkCorrectnessOfIteration(function (iterable) {
  21712. NativePromiseConstructor.all(iterable).then(undefined, function () { /* empty */ });
  21713. });
  21714. },{"../internals/check-correctness-of-iteration":292,"../internals/promise-constructor-detection":405,"../internals/promise-native-constructor":406}],409:[function(_dereq_,module,exports){
  21715. var Queue = function () {
  21716. this.head = null;
  21717. this.tail = null;
  21718. };
  21719. Queue.prototype = {
  21720. add: function (item) {
  21721. var entry = { item: item, next: null };
  21722. if (this.head) this.tail.next = entry;
  21723. else this.head = entry;
  21724. this.tail = entry;
  21725. },
  21726. get: function () {
  21727. var entry = this.head;
  21728. if (entry) {
  21729. this.head = entry.next;
  21730. if (this.tail === entry) this.tail = null;
  21731. return entry.item;
  21732. }
  21733. }
  21734. };
  21735. module.exports = Queue;
  21736. },{}],410:[function(_dereq_,module,exports){
  21737. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  21738. var $TypeError = TypeError;
  21739. // `RequireObjectCoercible` abstract operation
  21740. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  21741. module.exports = function (it) {
  21742. if (isNullOrUndefined(it)) throw $TypeError("Can't call method on " + it);
  21743. return it;
  21744. };
  21745. },{"../internals/is-null-or-undefined":364}],411:[function(_dereq_,module,exports){
  21746. // `SameValueZero` abstract operation
  21747. // https://tc39.es/ecma262/#sec-samevaluezero
  21748. module.exports = function (x, y) {
  21749. // eslint-disable-next-line no-self-compare -- NaN check
  21750. return x === y || x != x && y != y;
  21751. };
  21752. },{}],412:[function(_dereq_,module,exports){
  21753. var global = _dereq_('../internals/global');
  21754. var apply = _dereq_('../internals/function-apply');
  21755. var isCallable = _dereq_('../internals/is-callable');
  21756. var userAgent = _dereq_('../internals/engine-user-agent');
  21757. var arraySlice = _dereq_('../internals/array-slice');
  21758. var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
  21759. var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
  21760. var Function = global.Function;
  21761. var wrap = function (scheduler) {
  21762. return MSIE ? function (handler, timeout /* , ...arguments */) {
  21763. var boundArgs = validateArgumentsLength(arguments.length, 1) > 2;
  21764. var fn = isCallable(handler) ? handler : Function(handler);
  21765. var args = boundArgs ? arraySlice(arguments, 2) : undefined;
  21766. return scheduler(boundArgs ? function () {
  21767. apply(fn, this, args);
  21768. } : fn, timeout);
  21769. } : scheduler;
  21770. };
  21771. // ie9- setTimeout & setInterval additional parameters fix
  21772. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
  21773. module.exports = {
  21774. // `setTimeout` method
  21775. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
  21776. setTimeout: wrap(global.setTimeout),
  21777. // `setInterval` method
  21778. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
  21779. setInterval: wrap(global.setInterval)
  21780. };
  21781. },{"../internals/array-slice":287,"../internals/engine-user-agent":324,"../internals/function-apply":334,"../internals/global":346,"../internals/is-callable":359,"../internals/validate-arguments-length":438}],413:[function(_dereq_,module,exports){
  21782. 'use strict';
  21783. var getBuiltIn = _dereq_('../internals/get-built-in');
  21784. var definePropertyModule = _dereq_('../internals/object-define-property');
  21785. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  21786. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21787. var SPECIES = wellKnownSymbol('species');
  21788. module.exports = function (CONSTRUCTOR_NAME) {
  21789. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  21790. var defineProperty = definePropertyModule.f;
  21791. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  21792. defineProperty(Constructor, SPECIES, {
  21793. configurable: true,
  21794. get: function () { return this; }
  21795. });
  21796. }
  21797. };
  21798. },{"../internals/descriptors":312,"../internals/get-built-in":341,"../internals/object-define-property":387,"../internals/well-known-symbol":442}],414:[function(_dereq_,module,exports){
  21799. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  21800. var defineProperty = _dereq_('../internals/object-define-property').f;
  21801. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  21802. var hasOwn = _dereq_('../internals/has-own-property');
  21803. var toString = _dereq_('../internals/object-to-string');
  21804. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  21805. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  21806. module.exports = function (it, TAG, STATIC, SET_METHOD) {
  21807. if (it) {
  21808. var target = STATIC ? it : it.prototype;
  21809. if (!hasOwn(target, TO_STRING_TAG)) {
  21810. defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });
  21811. }
  21812. if (SET_METHOD && !TO_STRING_TAG_SUPPORT) {
  21813. createNonEnumerableProperty(target, 'toString', toString);
  21814. }
  21815. }
  21816. };
  21817. },{"../internals/create-non-enumerable-property":305,"../internals/has-own-property":347,"../internals/object-define-property":387,"../internals/object-to-string":400,"../internals/to-string-tag-support":432,"../internals/well-known-symbol":442}],415:[function(_dereq_,module,exports){
  21818. var shared = _dereq_('../internals/shared');
  21819. var uid = _dereq_('../internals/uid');
  21820. var keys = shared('keys');
  21821. module.exports = function (key) {
  21822. return keys[key] || (keys[key] = uid(key));
  21823. };
  21824. },{"../internals/shared":417,"../internals/uid":435}],416:[function(_dereq_,module,exports){
  21825. var global = _dereq_('../internals/global');
  21826. var defineGlobalProperty = _dereq_('../internals/define-global-property');
  21827. var SHARED = '__core-js_shared__';
  21828. var store = global[SHARED] || defineGlobalProperty(SHARED, {});
  21829. module.exports = store;
  21830. },{"../internals/define-global-property":310,"../internals/global":346}],417:[function(_dereq_,module,exports){
  21831. var IS_PURE = _dereq_('../internals/is-pure');
  21832. var store = _dereq_('../internals/shared-store');
  21833. (module.exports = function (key, value) {
  21834. return store[key] || (store[key] = value !== undefined ? value : {});
  21835. })('versions', []).push({
  21836. version: '3.25.1',
  21837. mode: IS_PURE ? 'pure' : 'global',
  21838. copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
  21839. license: 'https://github.com/zloirock/core-js/blob/v3.25.1/LICENSE',
  21840. source: 'https://github.com/zloirock/core-js'
  21841. });
  21842. },{"../internals/is-pure":366,"../internals/shared-store":416}],418:[function(_dereq_,module,exports){
  21843. var anObject = _dereq_('../internals/an-object');
  21844. var aConstructor = _dereq_('../internals/a-constructor');
  21845. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  21846. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  21847. var SPECIES = wellKnownSymbol('species');
  21848. // `SpeciesConstructor` abstract operation
  21849. // https://tc39.es/ecma262/#sec-speciesconstructor
  21850. module.exports = function (O, defaultConstructor) {
  21851. var C = anObject(O).constructor;
  21852. var S;
  21853. return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES]) ? defaultConstructor : aConstructor(S);
  21854. };
  21855. },{"../internals/a-constructor":272,"../internals/an-object":276,"../internals/is-null-or-undefined":364,"../internals/well-known-symbol":442}],419:[function(_dereq_,module,exports){
  21856. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21857. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  21858. var toString = _dereq_('../internals/to-string');
  21859. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  21860. var charAt = uncurryThis(''.charAt);
  21861. var charCodeAt = uncurryThis(''.charCodeAt);
  21862. var stringSlice = uncurryThis(''.slice);
  21863. var createMethod = function (CONVERT_TO_STRING) {
  21864. return function ($this, pos) {
  21865. var S = toString(requireObjectCoercible($this));
  21866. var position = toIntegerOrInfinity(pos);
  21867. var size = S.length;
  21868. var first, second;
  21869. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  21870. first = charCodeAt(S, position);
  21871. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  21872. || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
  21873. ? CONVERT_TO_STRING
  21874. ? charAt(S, position)
  21875. : first
  21876. : CONVERT_TO_STRING
  21877. ? stringSlice(S, position, position + 2)
  21878. : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  21879. };
  21880. };
  21881. module.exports = {
  21882. // `String.prototype.codePointAt` method
  21883. // https://tc39.es/ecma262/#sec-string.prototype.codepointat
  21884. codeAt: createMethod(false),
  21885. // `String.prototype.at` method
  21886. // https://github.com/mathiasbynens/String.prototype.at
  21887. charAt: createMethod(true)
  21888. };
  21889. },{"../internals/function-uncurry-this":340,"../internals/require-object-coercible":410,"../internals/to-integer-or-infinity":427,"../internals/to-string":433}],420:[function(_dereq_,module,exports){
  21890. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21891. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  21892. var toString = _dereq_('../internals/to-string');
  21893. var whitespaces = _dereq_('../internals/whitespaces');
  21894. var replace = uncurryThis(''.replace);
  21895. var whitespace = '[' + whitespaces + ']';
  21896. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  21897. var rtrim = RegExp(whitespace + whitespace + '*$');
  21898. // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
  21899. var createMethod = function (TYPE) {
  21900. return function ($this) {
  21901. var string = toString(requireObjectCoercible($this));
  21902. if (TYPE & 1) string = replace(string, ltrim, '');
  21903. if (TYPE & 2) string = replace(string, rtrim, '');
  21904. return string;
  21905. };
  21906. };
  21907. module.exports = {
  21908. // `String.prototype.{ trimLeft, trimStart }` methods
  21909. // https://tc39.es/ecma262/#sec-string.prototype.trimstart
  21910. start: createMethod(1),
  21911. // `String.prototype.{ trimRight, trimEnd }` methods
  21912. // https://tc39.es/ecma262/#sec-string.prototype.trimend
  21913. end: createMethod(2),
  21914. // `String.prototype.trim` method
  21915. // https://tc39.es/ecma262/#sec-string.prototype.trim
  21916. trim: createMethod(3)
  21917. };
  21918. },{"../internals/function-uncurry-this":340,"../internals/require-object-coercible":410,"../internals/to-string":433,"../internals/whitespaces":443}],421:[function(_dereq_,module,exports){
  21919. /* eslint-disable es-x/no-symbol -- required for testing */
  21920. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  21921. var fails = _dereq_('../internals/fails');
  21922. // eslint-disable-next-line es-x/no-object-getownpropertysymbols -- required for testing
  21923. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  21924. var symbol = Symbol();
  21925. // Chrome 38 Symbol has incorrect toString conversion
  21926. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  21927. return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
  21928. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  21929. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  21930. });
  21931. },{"../internals/engine-v8-version":325,"../internals/fails":332}],422:[function(_dereq_,module,exports){
  21932. var call = _dereq_('../internals/function-call');
  21933. var getBuiltIn = _dereq_('../internals/get-built-in');
  21934. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  21935. var defineBuiltIn = _dereq_('../internals/define-built-in');
  21936. module.exports = function () {
  21937. var Symbol = getBuiltIn('Symbol');
  21938. var SymbolPrototype = Symbol && Symbol.prototype;
  21939. var valueOf = SymbolPrototype && SymbolPrototype.valueOf;
  21940. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  21941. if (SymbolPrototype && !SymbolPrototype[TO_PRIMITIVE]) {
  21942. // `Symbol.prototype[@@toPrimitive]` method
  21943. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  21944. // eslint-disable-next-line no-unused-vars -- required for .length
  21945. defineBuiltIn(SymbolPrototype, TO_PRIMITIVE, function (hint) {
  21946. return call(valueOf, this);
  21947. }, { arity: 1 });
  21948. }
  21949. };
  21950. },{"../internals/define-built-in":308,"../internals/function-call":338,"../internals/get-built-in":341,"../internals/well-known-symbol":442}],423:[function(_dereq_,module,exports){
  21951. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  21952. /* eslint-disable es-x/no-symbol -- safe */
  21953. module.exports = NATIVE_SYMBOL && !!Symbol['for'] && !!Symbol.keyFor;
  21954. },{"../internals/symbol-constructor-detection":421}],424:[function(_dereq_,module,exports){
  21955. var global = _dereq_('../internals/global');
  21956. var apply = _dereq_('../internals/function-apply');
  21957. var bind = _dereq_('../internals/function-bind-context');
  21958. var isCallable = _dereq_('../internals/is-callable');
  21959. var hasOwn = _dereq_('../internals/has-own-property');
  21960. var fails = _dereq_('../internals/fails');
  21961. var html = _dereq_('../internals/html');
  21962. var arraySlice = _dereq_('../internals/array-slice');
  21963. var createElement = _dereq_('../internals/document-create-element');
  21964. var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
  21965. var IS_IOS = _dereq_('../internals/engine-is-ios');
  21966. var IS_NODE = _dereq_('../internals/engine-is-node');
  21967. var set = global.setImmediate;
  21968. var clear = global.clearImmediate;
  21969. var process = global.process;
  21970. var Dispatch = global.Dispatch;
  21971. var Function = global.Function;
  21972. var MessageChannel = global.MessageChannel;
  21973. var String = global.String;
  21974. var counter = 0;
  21975. var queue = {};
  21976. var ONREADYSTATECHANGE = 'onreadystatechange';
  21977. var location, defer, channel, port;
  21978. try {
  21979. // Deno throws a ReferenceError on `location` access without `--location` flag
  21980. location = global.location;
  21981. } catch (error) { /* empty */ }
  21982. var run = function (id) {
  21983. if (hasOwn(queue, id)) {
  21984. var fn = queue[id];
  21985. delete queue[id];
  21986. fn();
  21987. }
  21988. };
  21989. var runner = function (id) {
  21990. return function () {
  21991. run(id);
  21992. };
  21993. };
  21994. var listener = function (event) {
  21995. run(event.data);
  21996. };
  21997. var post = function (id) {
  21998. // old engines have not location.origin
  21999. global.postMessage(String(id), location.protocol + '//' + location.host);
  22000. };
  22001. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  22002. if (!set || !clear) {
  22003. set = function setImmediate(handler) {
  22004. validateArgumentsLength(arguments.length, 1);
  22005. var fn = isCallable(handler) ? handler : Function(handler);
  22006. var args = arraySlice(arguments, 1);
  22007. queue[++counter] = function () {
  22008. apply(fn, undefined, args);
  22009. };
  22010. defer(counter);
  22011. return counter;
  22012. };
  22013. clear = function clearImmediate(id) {
  22014. delete queue[id];
  22015. };
  22016. // Node.js 0.8-
  22017. if (IS_NODE) {
  22018. defer = function (id) {
  22019. process.nextTick(runner(id));
  22020. };
  22021. // Sphere (JS game engine) Dispatch API
  22022. } else if (Dispatch && Dispatch.now) {
  22023. defer = function (id) {
  22024. Dispatch.now(runner(id));
  22025. };
  22026. // Browsers with MessageChannel, includes WebWorkers
  22027. // except iOS - https://github.com/zloirock/core-js/issues/624
  22028. } else if (MessageChannel && !IS_IOS) {
  22029. channel = new MessageChannel();
  22030. port = channel.port2;
  22031. channel.port1.onmessage = listener;
  22032. defer = bind(port.postMessage, port);
  22033. // Browsers with postMessage, skip WebWorkers
  22034. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  22035. } else if (
  22036. global.addEventListener &&
  22037. isCallable(global.postMessage) &&
  22038. !global.importScripts &&
  22039. location && location.protocol !== 'file:' &&
  22040. !fails(post)
  22041. ) {
  22042. defer = post;
  22043. global.addEventListener('message', listener, false);
  22044. // IE8-
  22045. } else if (ONREADYSTATECHANGE in createElement('script')) {
  22046. defer = function (id) {
  22047. html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
  22048. html.removeChild(this);
  22049. run(id);
  22050. };
  22051. };
  22052. // Rest old browsers
  22053. } else {
  22054. defer = function (id) {
  22055. setTimeout(runner(id), 0);
  22056. };
  22057. }
  22058. }
  22059. module.exports = {
  22060. set: set,
  22061. clear: clear
  22062. };
  22063. },{"../internals/array-slice":287,"../internals/document-create-element":313,"../internals/engine-is-ios":321,"../internals/engine-is-node":322,"../internals/fails":332,"../internals/function-apply":334,"../internals/function-bind-context":335,"../internals/global":346,"../internals/has-own-property":347,"../internals/html":350,"../internals/is-callable":359,"../internals/validate-arguments-length":438}],425:[function(_dereq_,module,exports){
  22064. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  22065. var max = Math.max;
  22066. var min = Math.min;
  22067. // Helper for a popular repeating case of the spec:
  22068. // Let integer be ? ToInteger(index).
  22069. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  22070. module.exports = function (index, length) {
  22071. var integer = toIntegerOrInfinity(index);
  22072. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  22073. };
  22074. },{"../internals/to-integer-or-infinity":427}],426:[function(_dereq_,module,exports){
  22075. // toObject with fallback for non-array-like ES3 strings
  22076. var IndexedObject = _dereq_('../internals/indexed-object');
  22077. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  22078. module.exports = function (it) {
  22079. return IndexedObject(requireObjectCoercible(it));
  22080. };
  22081. },{"../internals/indexed-object":352,"../internals/require-object-coercible":410}],427:[function(_dereq_,module,exports){
  22082. var trunc = _dereq_('../internals/math-trunc');
  22083. // `ToIntegerOrInfinity` abstract operation
  22084. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  22085. module.exports = function (argument) {
  22086. var number = +argument;
  22087. // eslint-disable-next-line no-self-compare -- NaN check
  22088. return number !== number || number === 0 ? 0 : trunc(number);
  22089. };
  22090. },{"../internals/math-trunc":378}],428:[function(_dereq_,module,exports){
  22091. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  22092. var min = Math.min;
  22093. // `ToLength` abstract operation
  22094. // https://tc39.es/ecma262/#sec-tolength
  22095. module.exports = function (argument) {
  22096. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  22097. };
  22098. },{"../internals/to-integer-or-infinity":427}],429:[function(_dereq_,module,exports){
  22099. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  22100. var $Object = Object;
  22101. // `ToObject` abstract operation
  22102. // https://tc39.es/ecma262/#sec-toobject
  22103. module.exports = function (argument) {
  22104. return $Object(requireObjectCoercible(argument));
  22105. };
  22106. },{"../internals/require-object-coercible":410}],430:[function(_dereq_,module,exports){
  22107. var call = _dereq_('../internals/function-call');
  22108. var isObject = _dereq_('../internals/is-object');
  22109. var isSymbol = _dereq_('../internals/is-symbol');
  22110. var getMethod = _dereq_('../internals/get-method');
  22111. var ordinaryToPrimitive = _dereq_('../internals/ordinary-to-primitive');
  22112. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22113. var $TypeError = TypeError;
  22114. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  22115. // `ToPrimitive` abstract operation
  22116. // https://tc39.es/ecma262/#sec-toprimitive
  22117. module.exports = function (input, pref) {
  22118. if (!isObject(input) || isSymbol(input)) return input;
  22119. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  22120. var result;
  22121. if (exoticToPrim) {
  22122. if (pref === undefined) pref = 'default';
  22123. result = call(exoticToPrim, input, pref);
  22124. if (!isObject(result) || isSymbol(result)) return result;
  22125. throw $TypeError("Can't convert object to primitive value");
  22126. }
  22127. if (pref === undefined) pref = 'number';
  22128. return ordinaryToPrimitive(input, pref);
  22129. };
  22130. },{"../internals/function-call":338,"../internals/get-method":345,"../internals/is-object":365,"../internals/is-symbol":368,"../internals/ordinary-to-primitive":401,"../internals/well-known-symbol":442}],431:[function(_dereq_,module,exports){
  22131. var toPrimitive = _dereq_('../internals/to-primitive');
  22132. var isSymbol = _dereq_('../internals/is-symbol');
  22133. // `ToPropertyKey` abstract operation
  22134. // https://tc39.es/ecma262/#sec-topropertykey
  22135. module.exports = function (argument) {
  22136. var key = toPrimitive(argument, 'string');
  22137. return isSymbol(key) ? key : key + '';
  22138. };
  22139. },{"../internals/is-symbol":368,"../internals/to-primitive":430}],432:[function(_dereq_,module,exports){
  22140. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22141. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  22142. var test = {};
  22143. test[TO_STRING_TAG] = 'z';
  22144. module.exports = String(test) === '[object z]';
  22145. },{"../internals/well-known-symbol":442}],433:[function(_dereq_,module,exports){
  22146. var classof = _dereq_('../internals/classof');
  22147. var $String = String;
  22148. module.exports = function (argument) {
  22149. if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
  22150. return $String(argument);
  22151. };
  22152. },{"../internals/classof":294}],434:[function(_dereq_,module,exports){
  22153. var $String = String;
  22154. module.exports = function (argument) {
  22155. try {
  22156. return $String(argument);
  22157. } catch (error) {
  22158. return 'Object';
  22159. }
  22160. };
  22161. },{}],435:[function(_dereq_,module,exports){
  22162. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  22163. var id = 0;
  22164. var postfix = Math.random();
  22165. var toString = uncurryThis(1.0.toString);
  22166. module.exports = function (key) {
  22167. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  22168. };
  22169. },{"../internals/function-uncurry-this":340}],436:[function(_dereq_,module,exports){
  22170. /* eslint-disable es-x/no-symbol -- required for testing */
  22171. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  22172. module.exports = NATIVE_SYMBOL
  22173. && !Symbol.sham
  22174. && typeof Symbol.iterator == 'symbol';
  22175. },{"../internals/symbol-constructor-detection":421}],437:[function(_dereq_,module,exports){
  22176. var DESCRIPTORS = _dereq_('../internals/descriptors');
  22177. var fails = _dereq_('../internals/fails');
  22178. // V8 ~ Chrome 36-
  22179. // https://bugs.chromium.org/p/v8/issues/detail?id=3334
  22180. module.exports = DESCRIPTORS && fails(function () {
  22181. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  22182. return Object.defineProperty(function () { /* empty */ }, 'prototype', {
  22183. value: 42,
  22184. writable: false
  22185. }).prototype != 42;
  22186. });
  22187. },{"../internals/descriptors":312,"../internals/fails":332}],438:[function(_dereq_,module,exports){
  22188. var $TypeError = TypeError;
  22189. module.exports = function (passed, required) {
  22190. if (passed < required) throw $TypeError('Not enough arguments');
  22191. return passed;
  22192. };
  22193. },{}],439:[function(_dereq_,module,exports){
  22194. var global = _dereq_('../internals/global');
  22195. var isCallable = _dereq_('../internals/is-callable');
  22196. var WeakMap = global.WeakMap;
  22197. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  22198. },{"../internals/global":346,"../internals/is-callable":359}],440:[function(_dereq_,module,exports){
  22199. var path = _dereq_('../internals/path');
  22200. var hasOwn = _dereq_('../internals/has-own-property');
  22201. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  22202. var defineProperty = _dereq_('../internals/object-define-property').f;
  22203. module.exports = function (NAME) {
  22204. var Symbol = path.Symbol || (path.Symbol = {});
  22205. if (!hasOwn(Symbol, NAME)) defineProperty(Symbol, NAME, {
  22206. value: wrappedWellKnownSymbolModule.f(NAME)
  22207. });
  22208. };
  22209. },{"../internals/has-own-property":347,"../internals/object-define-property":387,"../internals/path":403,"../internals/well-known-symbol-wrapped":441}],441:[function(_dereq_,module,exports){
  22210. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22211. exports.f = wellKnownSymbol;
  22212. },{"../internals/well-known-symbol":442}],442:[function(_dereq_,module,exports){
  22213. var global = _dereq_('../internals/global');
  22214. var shared = _dereq_('../internals/shared');
  22215. var hasOwn = _dereq_('../internals/has-own-property');
  22216. var uid = _dereq_('../internals/uid');
  22217. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  22218. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  22219. var WellKnownSymbolsStore = shared('wks');
  22220. var Symbol = global.Symbol;
  22221. var symbolFor = Symbol && Symbol['for'];
  22222. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
  22223. module.exports = function (name) {
  22224. if (!hasOwn(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
  22225. var description = 'Symbol.' + name;
  22226. if (NATIVE_SYMBOL && hasOwn(Symbol, name)) {
  22227. WellKnownSymbolsStore[name] = Symbol[name];
  22228. } else if (USE_SYMBOL_AS_UID && symbolFor) {
  22229. WellKnownSymbolsStore[name] = symbolFor(description);
  22230. } else {
  22231. WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
  22232. }
  22233. } return WellKnownSymbolsStore[name];
  22234. };
  22235. },{"../internals/global":346,"../internals/has-own-property":347,"../internals/shared":417,"../internals/symbol-constructor-detection":421,"../internals/uid":435,"../internals/use-symbol-as-uid":436}],443:[function(_dereq_,module,exports){
  22236. // a string of all valid unicode whitespaces
  22237. module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
  22238. '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  22239. },{}],444:[function(_dereq_,module,exports){
  22240. 'use strict';
  22241. var $ = _dereq_('../internals/export');
  22242. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  22243. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  22244. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  22245. var copyConstructorProperties = _dereq_('../internals/copy-constructor-properties');
  22246. var create = _dereq_('../internals/object-create');
  22247. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  22248. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  22249. var clearErrorStack = _dereq_('../internals/error-stack-clear');
  22250. var installErrorCause = _dereq_('../internals/install-error-cause');
  22251. var iterate = _dereq_('../internals/iterate');
  22252. var normalizeStringArgument = _dereq_('../internals/normalize-string-argument');
  22253. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22254. var ERROR_STACK_INSTALLABLE = _dereq_('../internals/error-stack-installable');
  22255. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  22256. var $Error = Error;
  22257. var push = [].push;
  22258. var $AggregateError = function AggregateError(errors, message /* , options */) {
  22259. var options = arguments.length > 2 ? arguments[2] : undefined;
  22260. var isInstance = isPrototypeOf(AggregateErrorPrototype, this);
  22261. var that;
  22262. if (setPrototypeOf) {
  22263. that = setPrototypeOf($Error(), isInstance ? getPrototypeOf(this) : AggregateErrorPrototype);
  22264. } else {
  22265. that = isInstance ? this : create(AggregateErrorPrototype);
  22266. createNonEnumerableProperty(that, TO_STRING_TAG, 'Error');
  22267. }
  22268. if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message));
  22269. if (ERROR_STACK_INSTALLABLE) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1));
  22270. installErrorCause(that, options);
  22271. var errorsArray = [];
  22272. iterate(errors, push, { that: errorsArray });
  22273. createNonEnumerableProperty(that, 'errors', errorsArray);
  22274. return that;
  22275. };
  22276. if (setPrototypeOf) setPrototypeOf($AggregateError, $Error);
  22277. else copyConstructorProperties($AggregateError, $Error, { name: true });
  22278. var AggregateErrorPrototype = $AggregateError.prototype = create($Error.prototype, {
  22279. constructor: createPropertyDescriptor(1, $AggregateError),
  22280. message: createPropertyDescriptor(1, ''),
  22281. name: createPropertyDescriptor(1, 'AggregateError')
  22282. });
  22283. // `AggregateError` constructor
  22284. // https://tc39.es/ecma262/#sec-aggregate-error-constructor
  22285. $({ global: true, constructor: true, arity: 2 }, {
  22286. AggregateError: $AggregateError
  22287. });
  22288. },{"../internals/copy-constructor-properties":301,"../internals/create-non-enumerable-property":305,"../internals/create-property-descriptor":306,"../internals/error-stack-clear":329,"../internals/error-stack-installable":330,"../internals/export":331,"../internals/install-error-cause":354,"../internals/iterate":369,"../internals/normalize-string-argument":381,"../internals/object-create":385,"../internals/object-get-prototype-of":392,"../internals/object-is-prototype-of":394,"../internals/object-set-prototype-of":398,"../internals/well-known-symbol":442}],445:[function(_dereq_,module,exports){
  22289. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  22290. _dereq_('../modules/es.aggregate-error.constructor');
  22291. },{"../modules/es.aggregate-error.constructor":444}],446:[function(_dereq_,module,exports){
  22292. 'use strict';
  22293. var $ = _dereq_('../internals/export');
  22294. var fails = _dereq_('../internals/fails');
  22295. var isArray = _dereq_('../internals/is-array');
  22296. var isObject = _dereq_('../internals/is-object');
  22297. var toObject = _dereq_('../internals/to-object');
  22298. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  22299. var doesNotExceedSafeInteger = _dereq_('../internals/does-not-exceed-safe-integer');
  22300. var createProperty = _dereq_('../internals/create-property');
  22301. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  22302. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  22303. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22304. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  22305. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  22306. // We can't use this feature detection in V8 since it causes
  22307. // deoptimization and serious performance degradation
  22308. // https://github.com/zloirock/core-js/issues/679
  22309. var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
  22310. var array = [];
  22311. array[IS_CONCAT_SPREADABLE] = false;
  22312. return array.concat()[0] !== array;
  22313. });
  22314. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  22315. var isConcatSpreadable = function (O) {
  22316. if (!isObject(O)) return false;
  22317. var spreadable = O[IS_CONCAT_SPREADABLE];
  22318. return spreadable !== undefined ? !!spreadable : isArray(O);
  22319. };
  22320. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  22321. // `Array.prototype.concat` method
  22322. // https://tc39.es/ecma262/#sec-array.prototype.concat
  22323. // with adding support of @@isConcatSpreadable and @@species
  22324. $({ target: 'Array', proto: true, arity: 1, forced: FORCED }, {
  22325. // eslint-disable-next-line no-unused-vars -- required for `.length`
  22326. concat: function concat(arg) {
  22327. var O = toObject(this);
  22328. var A = arraySpeciesCreate(O, 0);
  22329. var n = 0;
  22330. var i, k, length, len, E;
  22331. for (i = -1, length = arguments.length; i < length; i++) {
  22332. E = i === -1 ? O : arguments[i];
  22333. if (isConcatSpreadable(E)) {
  22334. len = lengthOfArrayLike(E);
  22335. doesNotExceedSafeInteger(n + len);
  22336. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  22337. } else {
  22338. doesNotExceedSafeInteger(n + 1);
  22339. createProperty(A, n++, E);
  22340. }
  22341. }
  22342. A.length = n;
  22343. return A;
  22344. }
  22345. });
  22346. },{"../internals/array-method-has-species-support":282,"../internals/array-species-create":290,"../internals/create-property":307,"../internals/does-not-exceed-safe-integer":314,"../internals/engine-v8-version":325,"../internals/export":331,"../internals/fails":332,"../internals/is-array":358,"../internals/is-object":365,"../internals/length-of-array-like":375,"../internals/to-object":429,"../internals/well-known-symbol":442}],447:[function(_dereq_,module,exports){
  22347. 'use strict';
  22348. var $ = _dereq_('../internals/export');
  22349. var $every = _dereq_('../internals/array-iteration').every;
  22350. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  22351. var STRICT_METHOD = arrayMethodIsStrict('every');
  22352. // `Array.prototype.every` method
  22353. // https://tc39.es/ecma262/#sec-array.prototype.every
  22354. $({ target: 'Array', proto: true, forced: !STRICT_METHOD }, {
  22355. every: function every(callbackfn /* , thisArg */) {
  22356. return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  22357. }
  22358. });
  22359. },{"../internals/array-iteration":281,"../internals/array-method-is-strict":283,"../internals/export":331}],448:[function(_dereq_,module,exports){
  22360. 'use strict';
  22361. var $ = _dereq_('../internals/export');
  22362. var $filter = _dereq_('../internals/array-iteration').filter;
  22363. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  22364. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
  22365. // `Array.prototype.filter` method
  22366. // https://tc39.es/ecma262/#sec-array.prototype.filter
  22367. // with adding support of @@species
  22368. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  22369. filter: function filter(callbackfn /* , thisArg */) {
  22370. return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  22371. }
  22372. });
  22373. },{"../internals/array-iteration":281,"../internals/array-method-has-species-support":282,"../internals/export":331}],449:[function(_dereq_,module,exports){
  22374. 'use strict';
  22375. var $ = _dereq_('../internals/export');
  22376. var $findIndex = _dereq_('../internals/array-iteration').findIndex;
  22377. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  22378. var FIND_INDEX = 'findIndex';
  22379. var SKIPS_HOLES = true;
  22380. // Shouldn't skip holes
  22381. if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; });
  22382. // `Array.prototype.findIndex` method
  22383. // https://tc39.es/ecma262/#sec-array.prototype.findindex
  22384. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  22385. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  22386. return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  22387. }
  22388. });
  22389. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  22390. addToUnscopables(FIND_INDEX);
  22391. },{"../internals/add-to-unscopables":274,"../internals/array-iteration":281,"../internals/export":331}],450:[function(_dereq_,module,exports){
  22392. 'use strict';
  22393. var $ = _dereq_('../internals/export');
  22394. var $find = _dereq_('../internals/array-iteration').find;
  22395. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  22396. var FIND = 'find';
  22397. var SKIPS_HOLES = true;
  22398. // Shouldn't skip holes
  22399. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  22400. // `Array.prototype.find` method
  22401. // https://tc39.es/ecma262/#sec-array.prototype.find
  22402. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  22403. find: function find(callbackfn /* , that = undefined */) {
  22404. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  22405. }
  22406. });
  22407. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  22408. addToUnscopables(FIND);
  22409. },{"../internals/add-to-unscopables":274,"../internals/array-iteration":281,"../internals/export":331}],451:[function(_dereq_,module,exports){
  22410. 'use strict';
  22411. var $ = _dereq_('../internals/export');
  22412. var forEach = _dereq_('../internals/array-for-each');
  22413. // `Array.prototype.forEach` method
  22414. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  22415. // eslint-disable-next-line es-x/no-array-prototype-foreach -- safe
  22416. $({ target: 'Array', proto: true, forced: [].forEach != forEach }, {
  22417. forEach: forEach
  22418. });
  22419. },{"../internals/array-for-each":278,"../internals/export":331}],452:[function(_dereq_,module,exports){
  22420. var $ = _dereq_('../internals/export');
  22421. var from = _dereq_('../internals/array-from');
  22422. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  22423. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  22424. // eslint-disable-next-line es-x/no-array-from -- required for testing
  22425. Array.from(iterable);
  22426. });
  22427. // `Array.from` method
  22428. // https://tc39.es/ecma262/#sec-array.from
  22429. $({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
  22430. from: from
  22431. });
  22432. },{"../internals/array-from":279,"../internals/check-correctness-of-iteration":292,"../internals/export":331}],453:[function(_dereq_,module,exports){
  22433. 'use strict';
  22434. var $ = _dereq_('../internals/export');
  22435. var $includes = _dereq_('../internals/array-includes').includes;
  22436. var fails = _dereq_('../internals/fails');
  22437. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  22438. // FF99+ bug
  22439. var BROKEN_ON_SPARSE = fails(function () {
  22440. return !Array(1).includes();
  22441. });
  22442. // `Array.prototype.includes` method
  22443. // https://tc39.es/ecma262/#sec-array.prototype.includes
  22444. $({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
  22445. includes: function includes(el /* , fromIndex = 0 */) {
  22446. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  22447. }
  22448. });
  22449. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  22450. addToUnscopables('includes');
  22451. },{"../internals/add-to-unscopables":274,"../internals/array-includes":280,"../internals/export":331,"../internals/fails":332}],454:[function(_dereq_,module,exports){
  22452. 'use strict';
  22453. /* eslint-disable es-x/no-array-prototype-indexof -- required for testing */
  22454. var $ = _dereq_('../internals/export');
  22455. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  22456. var $indexOf = _dereq_('../internals/array-includes').indexOf;
  22457. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  22458. var nativeIndexOf = uncurryThis([].indexOf);
  22459. var NEGATIVE_ZERO = !!nativeIndexOf && 1 / nativeIndexOf([1], 1, -0) < 0;
  22460. var STRICT_METHOD = arrayMethodIsStrict('indexOf');
  22461. // `Array.prototype.indexOf` method
  22462. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  22463. $({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD }, {
  22464. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  22465. var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
  22466. return NEGATIVE_ZERO
  22467. // convert -0 to +0
  22468. ? nativeIndexOf(this, searchElement, fromIndex) || 0
  22469. : $indexOf(this, searchElement, fromIndex);
  22470. }
  22471. });
  22472. },{"../internals/array-includes":280,"../internals/array-method-is-strict":283,"../internals/export":331,"../internals/function-uncurry-this":340}],455:[function(_dereq_,module,exports){
  22473. var $ = _dereq_('../internals/export');
  22474. var isArray = _dereq_('../internals/is-array');
  22475. // `Array.isArray` method
  22476. // https://tc39.es/ecma262/#sec-array.isarray
  22477. $({ target: 'Array', stat: true }, {
  22478. isArray: isArray
  22479. });
  22480. },{"../internals/export":331,"../internals/is-array":358}],456:[function(_dereq_,module,exports){
  22481. 'use strict';
  22482. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  22483. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  22484. var Iterators = _dereq_('../internals/iterators');
  22485. var InternalStateModule = _dereq_('../internals/internal-state');
  22486. var defineProperty = _dereq_('../internals/object-define-property').f;
  22487. var defineIterator = _dereq_('../internals/iterator-define');
  22488. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  22489. var IS_PURE = _dereq_('../internals/is-pure');
  22490. var DESCRIPTORS = _dereq_('../internals/descriptors');
  22491. var ARRAY_ITERATOR = 'Array Iterator';
  22492. var setInternalState = InternalStateModule.set;
  22493. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  22494. // `Array.prototype.entries` method
  22495. // https://tc39.es/ecma262/#sec-array.prototype.entries
  22496. // `Array.prototype.keys` method
  22497. // https://tc39.es/ecma262/#sec-array.prototype.keys
  22498. // `Array.prototype.values` method
  22499. // https://tc39.es/ecma262/#sec-array.prototype.values
  22500. // `Array.prototype[@@iterator]` method
  22501. // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
  22502. // `CreateArrayIterator` internal method
  22503. // https://tc39.es/ecma262/#sec-createarrayiterator
  22504. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  22505. setInternalState(this, {
  22506. type: ARRAY_ITERATOR,
  22507. target: toIndexedObject(iterated), // target
  22508. index: 0, // next index
  22509. kind: kind // kind
  22510. });
  22511. // `%ArrayIteratorPrototype%.next` method
  22512. // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
  22513. }, function () {
  22514. var state = getInternalState(this);
  22515. var target = state.target;
  22516. var kind = state.kind;
  22517. var index = state.index++;
  22518. if (!target || index >= target.length) {
  22519. state.target = undefined;
  22520. return createIterResultObject(undefined, true);
  22521. }
  22522. if (kind == 'keys') return createIterResultObject(index, false);
  22523. if (kind == 'values') return createIterResultObject(target[index], false);
  22524. return createIterResultObject([index, target[index]], false);
  22525. }, 'values');
  22526. // argumentsList[@@iterator] is %ArrayProto_values%
  22527. // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
  22528. // https://tc39.es/ecma262/#sec-createmappedargumentsobject
  22529. var values = Iterators.Arguments = Iterators.Array;
  22530. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  22531. addToUnscopables('keys');
  22532. addToUnscopables('values');
  22533. addToUnscopables('entries');
  22534. // V8 ~ Chrome 45- bug
  22535. if (!IS_PURE && DESCRIPTORS && values.name !== 'values') try {
  22536. defineProperty(values, 'name', { value: 'values' });
  22537. } catch (error) { /* empty */ }
  22538. },{"../internals/add-to-unscopables":274,"../internals/create-iter-result-object":304,"../internals/descriptors":312,"../internals/internal-state":356,"../internals/is-pure":366,"../internals/iterator-define":372,"../internals/iterators":374,"../internals/object-define-property":387,"../internals/to-indexed-object":426}],457:[function(_dereq_,module,exports){
  22539. 'use strict';
  22540. var $ = _dereq_('../internals/export');
  22541. var $map = _dereq_('../internals/array-iteration').map;
  22542. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  22543. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');
  22544. // `Array.prototype.map` method
  22545. // https://tc39.es/ecma262/#sec-array.prototype.map
  22546. // with adding support of @@species
  22547. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  22548. map: function map(callbackfn /* , thisArg */) {
  22549. return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  22550. }
  22551. });
  22552. },{"../internals/array-iteration":281,"../internals/array-method-has-species-support":282,"../internals/export":331}],458:[function(_dereq_,module,exports){
  22553. 'use strict';
  22554. var $ = _dereq_('../internals/export');
  22555. var $reduce = _dereq_('../internals/array-reduce').left;
  22556. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  22557. var CHROME_VERSION = _dereq_('../internals/engine-v8-version');
  22558. var IS_NODE = _dereq_('../internals/engine-is-node');
  22559. var STRICT_METHOD = arrayMethodIsStrict('reduce');
  22560. // Chrome 80-82 has a critical bug
  22561. // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
  22562. var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
  22563. // `Array.prototype.reduce` method
  22564. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  22565. $({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
  22566. reduce: function reduce(callbackfn /* , initialValue */) {
  22567. var length = arguments.length;
  22568. return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
  22569. }
  22570. });
  22571. },{"../internals/array-method-is-strict":283,"../internals/array-reduce":284,"../internals/engine-is-node":322,"../internals/engine-v8-version":325,"../internals/export":331}],459:[function(_dereq_,module,exports){
  22572. 'use strict';
  22573. var $ = _dereq_('../internals/export');
  22574. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  22575. var isArray = _dereq_('../internals/is-array');
  22576. var nativeReverse = uncurryThis([].reverse);
  22577. var test = [1, 2];
  22578. // `Array.prototype.reverse` method
  22579. // https://tc39.es/ecma262/#sec-array.prototype.reverse
  22580. // fix for Safari 12.0 bug
  22581. // https://bugs.webkit.org/show_bug.cgi?id=188794
  22582. $({ target: 'Array', proto: true, forced: String(test) === String(test.reverse()) }, {
  22583. reverse: function reverse() {
  22584. // eslint-disable-next-line no-self-assign -- dirty hack
  22585. if (isArray(this)) this.length = this.length;
  22586. return nativeReverse(this);
  22587. }
  22588. });
  22589. },{"../internals/export":331,"../internals/function-uncurry-this":340,"../internals/is-array":358}],460:[function(_dereq_,module,exports){
  22590. 'use strict';
  22591. var $ = _dereq_('../internals/export');
  22592. var isArray = _dereq_('../internals/is-array');
  22593. var isConstructor = _dereq_('../internals/is-constructor');
  22594. var isObject = _dereq_('../internals/is-object');
  22595. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  22596. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  22597. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  22598. var createProperty = _dereq_('../internals/create-property');
  22599. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22600. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  22601. var nativeSlice = _dereq_('../internals/array-slice');
  22602. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
  22603. var SPECIES = wellKnownSymbol('species');
  22604. var $Array = Array;
  22605. var max = Math.max;
  22606. // `Array.prototype.slice` method
  22607. // https://tc39.es/ecma262/#sec-array.prototype.slice
  22608. // fallback for not array-like ES3 strings and DOM objects
  22609. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  22610. slice: function slice(start, end) {
  22611. var O = toIndexedObject(this);
  22612. var length = lengthOfArrayLike(O);
  22613. var k = toAbsoluteIndex(start, length);
  22614. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  22615. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  22616. var Constructor, result, n;
  22617. if (isArray(O)) {
  22618. Constructor = O.constructor;
  22619. // cross-realm fallback
  22620. if (isConstructor(Constructor) && (Constructor === $Array || isArray(Constructor.prototype))) {
  22621. Constructor = undefined;
  22622. } else if (isObject(Constructor)) {
  22623. Constructor = Constructor[SPECIES];
  22624. if (Constructor === null) Constructor = undefined;
  22625. }
  22626. if (Constructor === $Array || Constructor === undefined) {
  22627. return nativeSlice(O, k, fin);
  22628. }
  22629. }
  22630. result = new (Constructor === undefined ? $Array : Constructor)(max(fin - k, 0));
  22631. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  22632. result.length = n;
  22633. return result;
  22634. }
  22635. });
  22636. },{"../internals/array-method-has-species-support":282,"../internals/array-slice":287,"../internals/create-property":307,"../internals/export":331,"../internals/is-array":358,"../internals/is-constructor":360,"../internals/is-object":365,"../internals/length-of-array-like":375,"../internals/to-absolute-index":425,"../internals/to-indexed-object":426,"../internals/well-known-symbol":442}],461:[function(_dereq_,module,exports){
  22637. 'use strict';
  22638. var $ = _dereq_('../internals/export');
  22639. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  22640. var aCallable = _dereq_('../internals/a-callable');
  22641. var toObject = _dereq_('../internals/to-object');
  22642. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  22643. var deletePropertyOrThrow = _dereq_('../internals/delete-property-or-throw');
  22644. var toString = _dereq_('../internals/to-string');
  22645. var fails = _dereq_('../internals/fails');
  22646. var internalSort = _dereq_('../internals/array-sort');
  22647. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  22648. var FF = _dereq_('../internals/engine-ff-version');
  22649. var IE_OR_EDGE = _dereq_('../internals/engine-is-ie-or-edge');
  22650. var V8 = _dereq_('../internals/engine-v8-version');
  22651. var WEBKIT = _dereq_('../internals/engine-webkit-version');
  22652. var test = [];
  22653. var nativeSort = uncurryThis(test.sort);
  22654. var push = uncurryThis(test.push);
  22655. // IE8-
  22656. var FAILS_ON_UNDEFINED = fails(function () {
  22657. test.sort(undefined);
  22658. });
  22659. // V8 bug
  22660. var FAILS_ON_NULL = fails(function () {
  22661. test.sort(null);
  22662. });
  22663. // Old WebKit
  22664. var STRICT_METHOD = arrayMethodIsStrict('sort');
  22665. var STABLE_SORT = !fails(function () {
  22666. // feature detection can be too slow, so check engines versions
  22667. if (V8) return V8 < 70;
  22668. if (FF && FF > 3) return;
  22669. if (IE_OR_EDGE) return true;
  22670. if (WEBKIT) return WEBKIT < 603;
  22671. var result = '';
  22672. var code, chr, value, index;
  22673. // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
  22674. for (code = 65; code < 76; code++) {
  22675. chr = String.fromCharCode(code);
  22676. switch (code) {
  22677. case 66: case 69: case 70: case 72: value = 3; break;
  22678. case 68: case 71: value = 4; break;
  22679. default: value = 2;
  22680. }
  22681. for (index = 0; index < 47; index++) {
  22682. test.push({ k: chr + index, v: value });
  22683. }
  22684. }
  22685. test.sort(function (a, b) { return b.v - a.v; });
  22686. for (index = 0; index < test.length; index++) {
  22687. chr = test[index].k.charAt(0);
  22688. if (result.charAt(result.length - 1) !== chr) result += chr;
  22689. }
  22690. return result !== 'DGBEFHACIJK';
  22691. });
  22692. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
  22693. var getSortCompare = function (comparefn) {
  22694. return function (x, y) {
  22695. if (y === undefined) return -1;
  22696. if (x === undefined) return 1;
  22697. if (comparefn !== undefined) return +comparefn(x, y) || 0;
  22698. return toString(x) > toString(y) ? 1 : -1;
  22699. };
  22700. };
  22701. // `Array.prototype.sort` method
  22702. // https://tc39.es/ecma262/#sec-array.prototype.sort
  22703. $({ target: 'Array', proto: true, forced: FORCED }, {
  22704. sort: function sort(comparefn) {
  22705. if (comparefn !== undefined) aCallable(comparefn);
  22706. var array = toObject(this);
  22707. if (STABLE_SORT) return comparefn === undefined ? nativeSort(array) : nativeSort(array, comparefn);
  22708. var items = [];
  22709. var arrayLength = lengthOfArrayLike(array);
  22710. var itemsLength, index;
  22711. for (index = 0; index < arrayLength; index++) {
  22712. if (index in array) push(items, array[index]);
  22713. }
  22714. internalSort(items, getSortCompare(comparefn));
  22715. itemsLength = lengthOfArrayLike(items);
  22716. index = 0;
  22717. while (index < itemsLength) array[index] = items[index++];
  22718. while (index < arrayLength) deletePropertyOrThrow(array, index++);
  22719. return array;
  22720. }
  22721. });
  22722. },{"../internals/a-callable":271,"../internals/array-method-is-strict":283,"../internals/array-sort":288,"../internals/delete-property-or-throw":311,"../internals/engine-ff-version":316,"../internals/engine-is-ie-or-edge":319,"../internals/engine-v8-version":325,"../internals/engine-webkit-version":326,"../internals/export":331,"../internals/fails":332,"../internals/function-uncurry-this":340,"../internals/length-of-array-like":375,"../internals/to-object":429,"../internals/to-string":433}],462:[function(_dereq_,module,exports){
  22723. 'use strict';
  22724. var $ = _dereq_('../internals/export');
  22725. var toObject = _dereq_('../internals/to-object');
  22726. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  22727. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  22728. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  22729. var setArrayLength = _dereq_('../internals/array-set-length');
  22730. var doesNotExceedSafeInteger = _dereq_('../internals/does-not-exceed-safe-integer');
  22731. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  22732. var createProperty = _dereq_('../internals/create-property');
  22733. var deletePropertyOrThrow = _dereq_('../internals/delete-property-or-throw');
  22734. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  22735. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
  22736. var max = Math.max;
  22737. var min = Math.min;
  22738. // `Array.prototype.splice` method
  22739. // https://tc39.es/ecma262/#sec-array.prototype.splice
  22740. // with adding support of @@species
  22741. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  22742. splice: function splice(start, deleteCount /* , ...items */) {
  22743. var O = toObject(this);
  22744. var len = lengthOfArrayLike(O);
  22745. var actualStart = toAbsoluteIndex(start, len);
  22746. var argumentsLength = arguments.length;
  22747. var insertCount, actualDeleteCount, A, k, from, to;
  22748. if (argumentsLength === 0) {
  22749. insertCount = actualDeleteCount = 0;
  22750. } else if (argumentsLength === 1) {
  22751. insertCount = 0;
  22752. actualDeleteCount = len - actualStart;
  22753. } else {
  22754. insertCount = argumentsLength - 2;
  22755. actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
  22756. }
  22757. doesNotExceedSafeInteger(len + insertCount - actualDeleteCount);
  22758. A = arraySpeciesCreate(O, actualDeleteCount);
  22759. for (k = 0; k < actualDeleteCount; k++) {
  22760. from = actualStart + k;
  22761. if (from in O) createProperty(A, k, O[from]);
  22762. }
  22763. A.length = actualDeleteCount;
  22764. if (insertCount < actualDeleteCount) {
  22765. for (k = actualStart; k < len - actualDeleteCount; k++) {
  22766. from = k + actualDeleteCount;
  22767. to = k + insertCount;
  22768. if (from in O) O[to] = O[from];
  22769. else deletePropertyOrThrow(O, to);
  22770. }
  22771. for (k = len; k > len - actualDeleteCount + insertCount; k--) deletePropertyOrThrow(O, k - 1);
  22772. } else if (insertCount > actualDeleteCount) {
  22773. for (k = len - actualDeleteCount; k > actualStart; k--) {
  22774. from = k + actualDeleteCount - 1;
  22775. to = k + insertCount - 1;
  22776. if (from in O) O[to] = O[from];
  22777. else deletePropertyOrThrow(O, to);
  22778. }
  22779. }
  22780. for (k = 0; k < insertCount; k++) {
  22781. O[k + actualStart] = arguments[k + 2];
  22782. }
  22783. setArrayLength(O, len - actualDeleteCount + insertCount);
  22784. return A;
  22785. }
  22786. });
  22787. },{"../internals/array-method-has-species-support":282,"../internals/array-set-length":285,"../internals/array-species-create":290,"../internals/create-property":307,"../internals/delete-property-or-throw":311,"../internals/does-not-exceed-safe-integer":314,"../internals/export":331,"../internals/length-of-array-like":375,"../internals/to-absolute-index":425,"../internals/to-integer-or-infinity":427,"../internals/to-object":429}],463:[function(_dereq_,module,exports){
  22788. // empty
  22789. },{}],464:[function(_dereq_,module,exports){
  22790. // TODO: Remove from `core-js@4`
  22791. var $ = _dereq_('../internals/export');
  22792. var bind = _dereq_('../internals/function-bind');
  22793. // `Function.prototype.bind` method
  22794. // https://tc39.es/ecma262/#sec-function.prototype.bind
  22795. $({ target: 'Function', proto: true, forced: Function.bind !== bind }, {
  22796. bind: bind
  22797. });
  22798. },{"../internals/export":331,"../internals/function-bind":337}],465:[function(_dereq_,module,exports){
  22799. var $ = _dereq_('../internals/export');
  22800. var getBuiltIn = _dereq_('../internals/get-built-in');
  22801. var apply = _dereq_('../internals/function-apply');
  22802. var call = _dereq_('../internals/function-call');
  22803. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  22804. var fails = _dereq_('../internals/fails');
  22805. var isArray = _dereq_('../internals/is-array');
  22806. var isCallable = _dereq_('../internals/is-callable');
  22807. var isObject = _dereq_('../internals/is-object');
  22808. var isSymbol = _dereq_('../internals/is-symbol');
  22809. var arraySlice = _dereq_('../internals/array-slice');
  22810. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  22811. var $stringify = getBuiltIn('JSON', 'stringify');
  22812. var exec = uncurryThis(/./.exec);
  22813. var charAt = uncurryThis(''.charAt);
  22814. var charCodeAt = uncurryThis(''.charCodeAt);
  22815. var replace = uncurryThis(''.replace);
  22816. var numberToString = uncurryThis(1.0.toString);
  22817. var tester = /[\uD800-\uDFFF]/g;
  22818. var low = /^[\uD800-\uDBFF]$/;
  22819. var hi = /^[\uDC00-\uDFFF]$/;
  22820. var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () {
  22821. var symbol = getBuiltIn('Symbol')();
  22822. // MS Edge converts symbol values to JSON as {}
  22823. return $stringify([symbol]) != '[null]'
  22824. // WebKit converts symbol values to JSON as null
  22825. || $stringify({ a: symbol }) != '{}'
  22826. // V8 throws on boxed symbols
  22827. || $stringify(Object(symbol)) != '{}';
  22828. });
  22829. // https://github.com/tc39/proposal-well-formed-stringify
  22830. var ILL_FORMED_UNICODE = fails(function () {
  22831. return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"'
  22832. || $stringify('\uDEAD') !== '"\\udead"';
  22833. });
  22834. var stringifyWithSymbolsFix = function (it, replacer) {
  22835. var args = arraySlice(arguments);
  22836. var $replacer = replacer;
  22837. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  22838. if (!isArray(replacer)) replacer = function (key, value) {
  22839. if (isCallable($replacer)) value = call($replacer, this, key, value);
  22840. if (!isSymbol(value)) return value;
  22841. };
  22842. args[1] = replacer;
  22843. return apply($stringify, null, args);
  22844. };
  22845. var fixIllFormed = function (match, offset, string) {
  22846. var prev = charAt(string, offset - 1);
  22847. var next = charAt(string, offset + 1);
  22848. if ((exec(low, match) && !exec(hi, next)) || (exec(hi, match) && !exec(low, prev))) {
  22849. return '\\u' + numberToString(charCodeAt(match, 0), 16);
  22850. } return match;
  22851. };
  22852. if ($stringify) {
  22853. // `JSON.stringify` method
  22854. // https://tc39.es/ecma262/#sec-json.stringify
  22855. $({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, {
  22856. // eslint-disable-next-line no-unused-vars -- required for `.length`
  22857. stringify: function stringify(it, replacer, space) {
  22858. var args = arraySlice(arguments);
  22859. var result = apply(WRONG_SYMBOLS_CONVERSION ? stringifyWithSymbolsFix : $stringify, null, args);
  22860. return ILL_FORMED_UNICODE && typeof result == 'string' ? replace(result, tester, fixIllFormed) : result;
  22861. }
  22862. });
  22863. }
  22864. },{"../internals/array-slice":287,"../internals/export":331,"../internals/fails":332,"../internals/function-apply":334,"../internals/function-call":338,"../internals/function-uncurry-this":340,"../internals/get-built-in":341,"../internals/is-array":358,"../internals/is-callable":359,"../internals/is-object":365,"../internals/is-symbol":368,"../internals/symbol-constructor-detection":421}],466:[function(_dereq_,module,exports){
  22865. var global = _dereq_('../internals/global');
  22866. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  22867. // JSON[@@toStringTag] property
  22868. // https://tc39.es/ecma262/#sec-json-@@tostringtag
  22869. setToStringTag(global.JSON, 'JSON', true);
  22870. },{"../internals/global":346,"../internals/set-to-string-tag":414}],467:[function(_dereq_,module,exports){
  22871. 'use strict';
  22872. var collection = _dereq_('../internals/collection');
  22873. var collectionStrong = _dereq_('../internals/collection-strong');
  22874. // `Map` constructor
  22875. // https://tc39.es/ecma262/#sec-map-objects
  22876. collection('Map', function (init) {
  22877. return function Map() { return init(this, arguments.length ? arguments[0] : undefined); };
  22878. }, collectionStrong);
  22879. },{"../internals/collection":300,"../internals/collection-strong":298}],468:[function(_dereq_,module,exports){
  22880. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  22881. _dereq_('../modules/es.map.constructor');
  22882. },{"../modules/es.map.constructor":467}],469:[function(_dereq_,module,exports){
  22883. arguments[4][463][0].apply(exports,arguments)
  22884. },{"dup":463}],470:[function(_dereq_,module,exports){
  22885. var $ = _dereq_('../internals/export');
  22886. var isIntegralNumber = _dereq_('../internals/is-integral-number');
  22887. // `Number.isInteger` method
  22888. // https://tc39.es/ecma262/#sec-number.isinteger
  22889. $({ target: 'Number', stat: true }, {
  22890. isInteger: isIntegralNumber
  22891. });
  22892. },{"../internals/export":331,"../internals/is-integral-number":363}],471:[function(_dereq_,module,exports){
  22893. var $ = _dereq_('../internals/export');
  22894. var assign = _dereq_('../internals/object-assign');
  22895. // `Object.assign` method
  22896. // https://tc39.es/ecma262/#sec-object.assign
  22897. // eslint-disable-next-line es-x/no-object-assign -- required for testing
  22898. $({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
  22899. assign: assign
  22900. });
  22901. },{"../internals/export":331,"../internals/object-assign":384}],472:[function(_dereq_,module,exports){
  22902. // TODO: Remove from `core-js@4`
  22903. var $ = _dereq_('../internals/export');
  22904. var DESCRIPTORS = _dereq_('../internals/descriptors');
  22905. var create = _dereq_('../internals/object-create');
  22906. // `Object.create` method
  22907. // https://tc39.es/ecma262/#sec-object.create
  22908. $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
  22909. create: create
  22910. });
  22911. },{"../internals/descriptors":312,"../internals/export":331,"../internals/object-create":385}],473:[function(_dereq_,module,exports){
  22912. var $ = _dereq_('../internals/export');
  22913. var DESCRIPTORS = _dereq_('../internals/descriptors');
  22914. var defineProperties = _dereq_('../internals/object-define-properties').f;
  22915. // `Object.defineProperties` method
  22916. // https://tc39.es/ecma262/#sec-object.defineproperties
  22917. // eslint-disable-next-line es-x/no-object-defineproperties -- safe
  22918. $({ target: 'Object', stat: true, forced: Object.defineProperties !== defineProperties, sham: !DESCRIPTORS }, {
  22919. defineProperties: defineProperties
  22920. });
  22921. },{"../internals/descriptors":312,"../internals/export":331,"../internals/object-define-properties":386}],474:[function(_dereq_,module,exports){
  22922. var $ = _dereq_('../internals/export');
  22923. var DESCRIPTORS = _dereq_('../internals/descriptors');
  22924. var defineProperty = _dereq_('../internals/object-define-property').f;
  22925. // `Object.defineProperty` method
  22926. // https://tc39.es/ecma262/#sec-object.defineproperty
  22927. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  22928. $({ target: 'Object', stat: true, forced: Object.defineProperty !== defineProperty, sham: !DESCRIPTORS }, {
  22929. defineProperty: defineProperty
  22930. });
  22931. },{"../internals/descriptors":312,"../internals/export":331,"../internals/object-define-property":387}],475:[function(_dereq_,module,exports){
  22932. var $ = _dereq_('../internals/export');
  22933. var $entries = _dereq_('../internals/object-to-array').entries;
  22934. // `Object.entries` method
  22935. // https://tc39.es/ecma262/#sec-object.entries
  22936. $({ target: 'Object', stat: true }, {
  22937. entries: function entries(O) {
  22938. return $entries(O);
  22939. }
  22940. });
  22941. },{"../internals/export":331,"../internals/object-to-array":399}],476:[function(_dereq_,module,exports){
  22942. var $ = _dereq_('../internals/export');
  22943. var FREEZING = _dereq_('../internals/freezing');
  22944. var fails = _dereq_('../internals/fails');
  22945. var isObject = _dereq_('../internals/is-object');
  22946. var onFreeze = _dereq_('../internals/internal-metadata').onFreeze;
  22947. // eslint-disable-next-line es-x/no-object-freeze -- safe
  22948. var $freeze = Object.freeze;
  22949. var FAILS_ON_PRIMITIVES = fails(function () { $freeze(1); });
  22950. // `Object.freeze` method
  22951. // https://tc39.es/ecma262/#sec-object.freeze
  22952. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {
  22953. freeze: function freeze(it) {
  22954. return $freeze && isObject(it) ? $freeze(onFreeze(it)) : it;
  22955. }
  22956. });
  22957. },{"../internals/export":331,"../internals/fails":332,"../internals/freezing":333,"../internals/internal-metadata":355,"../internals/is-object":365}],477:[function(_dereq_,module,exports){
  22958. var $ = _dereq_('../internals/export');
  22959. var fails = _dereq_('../internals/fails');
  22960. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  22961. var nativeGetOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  22962. var DESCRIPTORS = _dereq_('../internals/descriptors');
  22963. var FAILS_ON_PRIMITIVES = fails(function () { nativeGetOwnPropertyDescriptor(1); });
  22964. var FORCED = !DESCRIPTORS || FAILS_ON_PRIMITIVES;
  22965. // `Object.getOwnPropertyDescriptor` method
  22966. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  22967. $({ target: 'Object', stat: true, forced: FORCED, sham: !DESCRIPTORS }, {
  22968. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
  22969. return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key);
  22970. }
  22971. });
  22972. },{"../internals/descriptors":312,"../internals/export":331,"../internals/fails":332,"../internals/object-get-own-property-descriptor":388,"../internals/to-indexed-object":426}],478:[function(_dereq_,module,exports){
  22973. var $ = _dereq_('../internals/export');
  22974. var DESCRIPTORS = _dereq_('../internals/descriptors');
  22975. var ownKeys = _dereq_('../internals/own-keys');
  22976. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  22977. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  22978. var createProperty = _dereq_('../internals/create-property');
  22979. // `Object.getOwnPropertyDescriptors` method
  22980. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  22981. $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
  22982. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  22983. var O = toIndexedObject(object);
  22984. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  22985. var keys = ownKeys(O);
  22986. var result = {};
  22987. var index = 0;
  22988. var key, descriptor;
  22989. while (keys.length > index) {
  22990. descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
  22991. if (descriptor !== undefined) createProperty(result, key, descriptor);
  22992. }
  22993. return result;
  22994. }
  22995. });
  22996. },{"../internals/create-property":307,"../internals/descriptors":312,"../internals/export":331,"../internals/object-get-own-property-descriptor":388,"../internals/own-keys":402,"../internals/to-indexed-object":426}],479:[function(_dereq_,module,exports){
  22997. var $ = _dereq_('../internals/export');
  22998. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  22999. var fails = _dereq_('../internals/fails');
  23000. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  23001. var toObject = _dereq_('../internals/to-object');
  23002. // V8 ~ Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
  23003. // https://bugs.chromium.org/p/v8/issues/detail?id=3443
  23004. var FORCED = !NATIVE_SYMBOL || fails(function () { getOwnPropertySymbolsModule.f(1); });
  23005. // `Object.getOwnPropertySymbols` method
  23006. // https://tc39.es/ecma262/#sec-object.getownpropertysymbols
  23007. $({ target: 'Object', stat: true, forced: FORCED }, {
  23008. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  23009. var $getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  23010. return $getOwnPropertySymbols ? $getOwnPropertySymbols(toObject(it)) : [];
  23011. }
  23012. });
  23013. },{"../internals/export":331,"../internals/fails":332,"../internals/object-get-own-property-symbols":391,"../internals/symbol-constructor-detection":421,"../internals/to-object":429}],480:[function(_dereq_,module,exports){
  23014. var $ = _dereq_('../internals/export');
  23015. var fails = _dereq_('../internals/fails');
  23016. var toObject = _dereq_('../internals/to-object');
  23017. var nativeGetPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  23018. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  23019. var FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });
  23020. // `Object.getPrototypeOf` method
  23021. // https://tc39.es/ecma262/#sec-object.getprototypeof
  23022. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {
  23023. getPrototypeOf: function getPrototypeOf(it) {
  23024. return nativeGetPrototypeOf(toObject(it));
  23025. }
  23026. });
  23027. },{"../internals/correct-prototype-getter":303,"../internals/export":331,"../internals/fails":332,"../internals/object-get-prototype-of":392,"../internals/to-object":429}],481:[function(_dereq_,module,exports){
  23028. var $ = _dereq_('../internals/export');
  23029. var toObject = _dereq_('../internals/to-object');
  23030. var nativeKeys = _dereq_('../internals/object-keys');
  23031. var fails = _dereq_('../internals/fails');
  23032. var FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });
  23033. // `Object.keys` method
  23034. // https://tc39.es/ecma262/#sec-object.keys
  23035. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  23036. keys: function keys(it) {
  23037. return nativeKeys(toObject(it));
  23038. }
  23039. });
  23040. },{"../internals/export":331,"../internals/fails":332,"../internals/object-keys":396,"../internals/to-object":429}],482:[function(_dereq_,module,exports){
  23041. var $ = _dereq_('../internals/export');
  23042. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  23043. // `Object.setPrototypeOf` method
  23044. // https://tc39.es/ecma262/#sec-object.setprototypeof
  23045. $({ target: 'Object', stat: true }, {
  23046. setPrototypeOf: setPrototypeOf
  23047. });
  23048. },{"../internals/export":331,"../internals/object-set-prototype-of":398}],483:[function(_dereq_,module,exports){
  23049. arguments[4][463][0].apply(exports,arguments)
  23050. },{"dup":463}],484:[function(_dereq_,module,exports){
  23051. var $ = _dereq_('../internals/export');
  23052. var $parseInt = _dereq_('../internals/number-parse-int');
  23053. // `parseInt` method
  23054. // https://tc39.es/ecma262/#sec-parseint-string-radix
  23055. $({ global: true, forced: parseInt != $parseInt }, {
  23056. parseInt: $parseInt
  23057. });
  23058. },{"../internals/export":331,"../internals/number-parse-int":383}],485:[function(_dereq_,module,exports){
  23059. 'use strict';
  23060. var $ = _dereq_('../internals/export');
  23061. var call = _dereq_('../internals/function-call');
  23062. var aCallable = _dereq_('../internals/a-callable');
  23063. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23064. var perform = _dereq_('../internals/perform');
  23065. var iterate = _dereq_('../internals/iterate');
  23066. // `Promise.allSettled` method
  23067. // https://tc39.es/ecma262/#sec-promise.allsettled
  23068. $({ target: 'Promise', stat: true }, {
  23069. allSettled: function allSettled(iterable) {
  23070. var C = this;
  23071. var capability = newPromiseCapabilityModule.f(C);
  23072. var resolve = capability.resolve;
  23073. var reject = capability.reject;
  23074. var result = perform(function () {
  23075. var promiseResolve = aCallable(C.resolve);
  23076. var values = [];
  23077. var counter = 0;
  23078. var remaining = 1;
  23079. iterate(iterable, function (promise) {
  23080. var index = counter++;
  23081. var alreadyCalled = false;
  23082. remaining++;
  23083. call(promiseResolve, C, promise).then(function (value) {
  23084. if (alreadyCalled) return;
  23085. alreadyCalled = true;
  23086. values[index] = { status: 'fulfilled', value: value };
  23087. --remaining || resolve(values);
  23088. }, function (error) {
  23089. if (alreadyCalled) return;
  23090. alreadyCalled = true;
  23091. values[index] = { status: 'rejected', reason: error };
  23092. --remaining || resolve(values);
  23093. });
  23094. });
  23095. --remaining || resolve(values);
  23096. });
  23097. if (result.error) reject(result.value);
  23098. return capability.promise;
  23099. }
  23100. });
  23101. },{"../internals/a-callable":271,"../internals/export":331,"../internals/function-call":338,"../internals/iterate":369,"../internals/new-promise-capability":380,"../internals/perform":404}],486:[function(_dereq_,module,exports){
  23102. 'use strict';
  23103. var $ = _dereq_('../internals/export');
  23104. var call = _dereq_('../internals/function-call');
  23105. var aCallable = _dereq_('../internals/a-callable');
  23106. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23107. var perform = _dereq_('../internals/perform');
  23108. var iterate = _dereq_('../internals/iterate');
  23109. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  23110. // `Promise.all` method
  23111. // https://tc39.es/ecma262/#sec-promise.all
  23112. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  23113. all: function all(iterable) {
  23114. var C = this;
  23115. var capability = newPromiseCapabilityModule.f(C);
  23116. var resolve = capability.resolve;
  23117. var reject = capability.reject;
  23118. var result = perform(function () {
  23119. var $promiseResolve = aCallable(C.resolve);
  23120. var values = [];
  23121. var counter = 0;
  23122. var remaining = 1;
  23123. iterate(iterable, function (promise) {
  23124. var index = counter++;
  23125. var alreadyCalled = false;
  23126. remaining++;
  23127. call($promiseResolve, C, promise).then(function (value) {
  23128. if (alreadyCalled) return;
  23129. alreadyCalled = true;
  23130. values[index] = value;
  23131. --remaining || resolve(values);
  23132. }, reject);
  23133. });
  23134. --remaining || resolve(values);
  23135. });
  23136. if (result.error) reject(result.value);
  23137. return capability.promise;
  23138. }
  23139. });
  23140. },{"../internals/a-callable":271,"../internals/export":331,"../internals/function-call":338,"../internals/iterate":369,"../internals/new-promise-capability":380,"../internals/perform":404,"../internals/promise-statics-incorrect-iteration":408}],487:[function(_dereq_,module,exports){
  23141. 'use strict';
  23142. var $ = _dereq_('../internals/export');
  23143. var call = _dereq_('../internals/function-call');
  23144. var aCallable = _dereq_('../internals/a-callable');
  23145. var getBuiltIn = _dereq_('../internals/get-built-in');
  23146. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23147. var perform = _dereq_('../internals/perform');
  23148. var iterate = _dereq_('../internals/iterate');
  23149. var PROMISE_ANY_ERROR = 'No one promise resolved';
  23150. // `Promise.any` method
  23151. // https://tc39.es/ecma262/#sec-promise.any
  23152. $({ target: 'Promise', stat: true }, {
  23153. any: function any(iterable) {
  23154. var C = this;
  23155. var AggregateError = getBuiltIn('AggregateError');
  23156. var capability = newPromiseCapabilityModule.f(C);
  23157. var resolve = capability.resolve;
  23158. var reject = capability.reject;
  23159. var result = perform(function () {
  23160. var promiseResolve = aCallable(C.resolve);
  23161. var errors = [];
  23162. var counter = 0;
  23163. var remaining = 1;
  23164. var alreadyResolved = false;
  23165. iterate(iterable, function (promise) {
  23166. var index = counter++;
  23167. var alreadyRejected = false;
  23168. remaining++;
  23169. call(promiseResolve, C, promise).then(function (value) {
  23170. if (alreadyRejected || alreadyResolved) return;
  23171. alreadyResolved = true;
  23172. resolve(value);
  23173. }, function (error) {
  23174. if (alreadyRejected || alreadyResolved) return;
  23175. alreadyRejected = true;
  23176. errors[index] = error;
  23177. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  23178. });
  23179. });
  23180. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  23181. });
  23182. if (result.error) reject(result.value);
  23183. return capability.promise;
  23184. }
  23185. });
  23186. },{"../internals/a-callable":271,"../internals/export":331,"../internals/function-call":338,"../internals/get-built-in":341,"../internals/iterate":369,"../internals/new-promise-capability":380,"../internals/perform":404}],488:[function(_dereq_,module,exports){
  23187. 'use strict';
  23188. var $ = _dereq_('../internals/export');
  23189. var IS_PURE = _dereq_('../internals/is-pure');
  23190. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  23191. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  23192. var getBuiltIn = _dereq_('../internals/get-built-in');
  23193. var isCallable = _dereq_('../internals/is-callable');
  23194. var defineBuiltIn = _dereq_('../internals/define-built-in');
  23195. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  23196. // `Promise.prototype.catch` method
  23197. // https://tc39.es/ecma262/#sec-promise.prototype.catch
  23198. $({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR, real: true }, {
  23199. 'catch': function (onRejected) {
  23200. return this.then(undefined, onRejected);
  23201. }
  23202. });
  23203. // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
  23204. if (!IS_PURE && isCallable(NativePromiseConstructor)) {
  23205. var method = getBuiltIn('Promise').prototype['catch'];
  23206. if (NativePromisePrototype['catch'] !== method) {
  23207. defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true });
  23208. }
  23209. }
  23210. },{"../internals/define-built-in":308,"../internals/export":331,"../internals/get-built-in":341,"../internals/is-callable":359,"../internals/is-pure":366,"../internals/promise-constructor-detection":405,"../internals/promise-native-constructor":406}],489:[function(_dereq_,module,exports){
  23211. 'use strict';
  23212. var $ = _dereq_('../internals/export');
  23213. var IS_PURE = _dereq_('../internals/is-pure');
  23214. var IS_NODE = _dereq_('../internals/engine-is-node');
  23215. var global = _dereq_('../internals/global');
  23216. var call = _dereq_('../internals/function-call');
  23217. var defineBuiltIn = _dereq_('../internals/define-built-in');
  23218. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  23219. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  23220. var setSpecies = _dereq_('../internals/set-species');
  23221. var aCallable = _dereq_('../internals/a-callable');
  23222. var isCallable = _dereq_('../internals/is-callable');
  23223. var isObject = _dereq_('../internals/is-object');
  23224. var anInstance = _dereq_('../internals/an-instance');
  23225. var speciesConstructor = _dereq_('../internals/species-constructor');
  23226. var task = _dereq_('../internals/task').set;
  23227. var microtask = _dereq_('../internals/microtask');
  23228. var hostReportErrors = _dereq_('../internals/host-report-errors');
  23229. var perform = _dereq_('../internals/perform');
  23230. var Queue = _dereq_('../internals/queue');
  23231. var InternalStateModule = _dereq_('../internals/internal-state');
  23232. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  23233. var PromiseConstructorDetection = _dereq_('../internals/promise-constructor-detection');
  23234. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23235. var PROMISE = 'Promise';
  23236. var FORCED_PROMISE_CONSTRUCTOR = PromiseConstructorDetection.CONSTRUCTOR;
  23237. var NATIVE_PROMISE_REJECTION_EVENT = PromiseConstructorDetection.REJECTION_EVENT;
  23238. var NATIVE_PROMISE_SUBCLASSING = PromiseConstructorDetection.SUBCLASSING;
  23239. var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
  23240. var setInternalState = InternalStateModule.set;
  23241. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  23242. var PromiseConstructor = NativePromiseConstructor;
  23243. var PromisePrototype = NativePromisePrototype;
  23244. var TypeError = global.TypeError;
  23245. var document = global.document;
  23246. var process = global.process;
  23247. var newPromiseCapability = newPromiseCapabilityModule.f;
  23248. var newGenericPromiseCapability = newPromiseCapability;
  23249. var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
  23250. var UNHANDLED_REJECTION = 'unhandledrejection';
  23251. var REJECTION_HANDLED = 'rejectionhandled';
  23252. var PENDING = 0;
  23253. var FULFILLED = 1;
  23254. var REJECTED = 2;
  23255. var HANDLED = 1;
  23256. var UNHANDLED = 2;
  23257. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  23258. // helpers
  23259. var isThenable = function (it) {
  23260. var then;
  23261. return isObject(it) && isCallable(then = it.then) ? then : false;
  23262. };
  23263. var callReaction = function (reaction, state) {
  23264. var value = state.value;
  23265. var ok = state.state == FULFILLED;
  23266. var handler = ok ? reaction.ok : reaction.fail;
  23267. var resolve = reaction.resolve;
  23268. var reject = reaction.reject;
  23269. var domain = reaction.domain;
  23270. var result, then, exited;
  23271. try {
  23272. if (handler) {
  23273. if (!ok) {
  23274. if (state.rejection === UNHANDLED) onHandleUnhandled(state);
  23275. state.rejection = HANDLED;
  23276. }
  23277. if (handler === true) result = value;
  23278. else {
  23279. if (domain) domain.enter();
  23280. result = handler(value); // can throw
  23281. if (domain) {
  23282. domain.exit();
  23283. exited = true;
  23284. }
  23285. }
  23286. if (result === reaction.promise) {
  23287. reject(TypeError('Promise-chain cycle'));
  23288. } else if (then = isThenable(result)) {
  23289. call(then, result, resolve, reject);
  23290. } else resolve(result);
  23291. } else reject(value);
  23292. } catch (error) {
  23293. if (domain && !exited) domain.exit();
  23294. reject(error);
  23295. }
  23296. };
  23297. var notify = function (state, isReject) {
  23298. if (state.notified) return;
  23299. state.notified = true;
  23300. microtask(function () {
  23301. var reactions = state.reactions;
  23302. var reaction;
  23303. while (reaction = reactions.get()) {
  23304. callReaction(reaction, state);
  23305. }
  23306. state.notified = false;
  23307. if (isReject && !state.rejection) onUnhandled(state);
  23308. });
  23309. };
  23310. var dispatchEvent = function (name, promise, reason) {
  23311. var event, handler;
  23312. if (DISPATCH_EVENT) {
  23313. event = document.createEvent('Event');
  23314. event.promise = promise;
  23315. event.reason = reason;
  23316. event.initEvent(name, false, true);
  23317. global.dispatchEvent(event);
  23318. } else event = { promise: promise, reason: reason };
  23319. if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = global['on' + name])) handler(event);
  23320. else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
  23321. };
  23322. var onUnhandled = function (state) {
  23323. call(task, global, function () {
  23324. var promise = state.facade;
  23325. var value = state.value;
  23326. var IS_UNHANDLED = isUnhandled(state);
  23327. var result;
  23328. if (IS_UNHANDLED) {
  23329. result = perform(function () {
  23330. if (IS_NODE) {
  23331. process.emit('unhandledRejection', value, promise);
  23332. } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
  23333. });
  23334. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  23335. state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
  23336. if (result.error) throw result.value;
  23337. }
  23338. });
  23339. };
  23340. var isUnhandled = function (state) {
  23341. return state.rejection !== HANDLED && !state.parent;
  23342. };
  23343. var onHandleUnhandled = function (state) {
  23344. call(task, global, function () {
  23345. var promise = state.facade;
  23346. if (IS_NODE) {
  23347. process.emit('rejectionHandled', promise);
  23348. } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
  23349. });
  23350. };
  23351. var bind = function (fn, state, unwrap) {
  23352. return function (value) {
  23353. fn(state, value, unwrap);
  23354. };
  23355. };
  23356. var internalReject = function (state, value, unwrap) {
  23357. if (state.done) return;
  23358. state.done = true;
  23359. if (unwrap) state = unwrap;
  23360. state.value = value;
  23361. state.state = REJECTED;
  23362. notify(state, true);
  23363. };
  23364. var internalResolve = function (state, value, unwrap) {
  23365. if (state.done) return;
  23366. state.done = true;
  23367. if (unwrap) state = unwrap;
  23368. try {
  23369. if (state.facade === value) throw TypeError("Promise can't be resolved itself");
  23370. var then = isThenable(value);
  23371. if (then) {
  23372. microtask(function () {
  23373. var wrapper = { done: false };
  23374. try {
  23375. call(then, value,
  23376. bind(internalResolve, wrapper, state),
  23377. bind(internalReject, wrapper, state)
  23378. );
  23379. } catch (error) {
  23380. internalReject(wrapper, error, state);
  23381. }
  23382. });
  23383. } else {
  23384. state.value = value;
  23385. state.state = FULFILLED;
  23386. notify(state, false);
  23387. }
  23388. } catch (error) {
  23389. internalReject({ done: false }, error, state);
  23390. }
  23391. };
  23392. // constructor polyfill
  23393. if (FORCED_PROMISE_CONSTRUCTOR) {
  23394. // 25.4.3.1 Promise(executor)
  23395. PromiseConstructor = function Promise(executor) {
  23396. anInstance(this, PromisePrototype);
  23397. aCallable(executor);
  23398. call(Internal, this);
  23399. var state = getInternalPromiseState(this);
  23400. try {
  23401. executor(bind(internalResolve, state), bind(internalReject, state));
  23402. } catch (error) {
  23403. internalReject(state, error);
  23404. }
  23405. };
  23406. PromisePrototype = PromiseConstructor.prototype;
  23407. // eslint-disable-next-line no-unused-vars -- required for `.length`
  23408. Internal = function Promise(executor) {
  23409. setInternalState(this, {
  23410. type: PROMISE,
  23411. done: false,
  23412. notified: false,
  23413. parent: false,
  23414. reactions: new Queue(),
  23415. rejection: false,
  23416. state: PENDING,
  23417. value: undefined
  23418. });
  23419. };
  23420. // `Promise.prototype.then` method
  23421. // https://tc39.es/ecma262/#sec-promise.prototype.then
  23422. Internal.prototype = defineBuiltIn(PromisePrototype, 'then', function then(onFulfilled, onRejected) {
  23423. var state = getInternalPromiseState(this);
  23424. var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
  23425. state.parent = true;
  23426. reaction.ok = isCallable(onFulfilled) ? onFulfilled : true;
  23427. reaction.fail = isCallable(onRejected) && onRejected;
  23428. reaction.domain = IS_NODE ? process.domain : undefined;
  23429. if (state.state == PENDING) state.reactions.add(reaction);
  23430. else microtask(function () {
  23431. callReaction(reaction, state);
  23432. });
  23433. return reaction.promise;
  23434. });
  23435. OwnPromiseCapability = function () {
  23436. var promise = new Internal();
  23437. var state = getInternalPromiseState(promise);
  23438. this.promise = promise;
  23439. this.resolve = bind(internalResolve, state);
  23440. this.reject = bind(internalReject, state);
  23441. };
  23442. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  23443. return C === PromiseConstructor || C === PromiseWrapper
  23444. ? new OwnPromiseCapability(C)
  23445. : newGenericPromiseCapability(C);
  23446. };
  23447. if (!IS_PURE && isCallable(NativePromiseConstructor) && NativePromisePrototype !== Object.prototype) {
  23448. nativeThen = NativePromisePrototype.then;
  23449. if (!NATIVE_PROMISE_SUBCLASSING) {
  23450. // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
  23451. defineBuiltIn(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {
  23452. var that = this;
  23453. return new PromiseConstructor(function (resolve, reject) {
  23454. call(nativeThen, that, resolve, reject);
  23455. }).then(onFulfilled, onRejected);
  23456. // https://github.com/zloirock/core-js/issues/640
  23457. }, { unsafe: true });
  23458. }
  23459. // make `.constructor === Promise` work for native promise-based APIs
  23460. try {
  23461. delete NativePromisePrototype.constructor;
  23462. } catch (error) { /* empty */ }
  23463. // make `instanceof Promise` work for native promise-based APIs
  23464. if (setPrototypeOf) {
  23465. setPrototypeOf(NativePromisePrototype, PromisePrototype);
  23466. }
  23467. }
  23468. }
  23469. $({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
  23470. Promise: PromiseConstructor
  23471. });
  23472. setToStringTag(PromiseConstructor, PROMISE, false, true);
  23473. setSpecies(PROMISE);
  23474. },{"../internals/a-callable":271,"../internals/an-instance":275,"../internals/define-built-in":308,"../internals/engine-is-node":322,"../internals/export":331,"../internals/function-call":338,"../internals/global":346,"../internals/host-report-errors":349,"../internals/internal-state":356,"../internals/is-callable":359,"../internals/is-object":365,"../internals/is-pure":366,"../internals/microtask":379,"../internals/new-promise-capability":380,"../internals/object-set-prototype-of":398,"../internals/perform":404,"../internals/promise-constructor-detection":405,"../internals/promise-native-constructor":406,"../internals/queue":409,"../internals/set-species":413,"../internals/set-to-string-tag":414,"../internals/species-constructor":418,"../internals/task":424}],490:[function(_dereq_,module,exports){
  23475. 'use strict';
  23476. var $ = _dereq_('../internals/export');
  23477. var IS_PURE = _dereq_('../internals/is-pure');
  23478. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  23479. var fails = _dereq_('../internals/fails');
  23480. var getBuiltIn = _dereq_('../internals/get-built-in');
  23481. var isCallable = _dereq_('../internals/is-callable');
  23482. var speciesConstructor = _dereq_('../internals/species-constructor');
  23483. var promiseResolve = _dereq_('../internals/promise-resolve');
  23484. var defineBuiltIn = _dereq_('../internals/define-built-in');
  23485. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  23486. // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
  23487. var NON_GENERIC = !!NativePromiseConstructor && fails(function () {
  23488. // eslint-disable-next-line unicorn/no-thenable -- required for testing
  23489. NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
  23490. });
  23491. // `Promise.prototype.finally` method
  23492. // https://tc39.es/ecma262/#sec-promise.prototype.finally
  23493. $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
  23494. 'finally': function (onFinally) {
  23495. var C = speciesConstructor(this, getBuiltIn('Promise'));
  23496. var isFunction = isCallable(onFinally);
  23497. return this.then(
  23498. isFunction ? function (x) {
  23499. return promiseResolve(C, onFinally()).then(function () { return x; });
  23500. } : onFinally,
  23501. isFunction ? function (e) {
  23502. return promiseResolve(C, onFinally()).then(function () { throw e; });
  23503. } : onFinally
  23504. );
  23505. }
  23506. });
  23507. // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
  23508. if (!IS_PURE && isCallable(NativePromiseConstructor)) {
  23509. var method = getBuiltIn('Promise').prototype['finally'];
  23510. if (NativePromisePrototype['finally'] !== method) {
  23511. defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true });
  23512. }
  23513. }
  23514. },{"../internals/define-built-in":308,"../internals/export":331,"../internals/fails":332,"../internals/get-built-in":341,"../internals/is-callable":359,"../internals/is-pure":366,"../internals/promise-native-constructor":406,"../internals/promise-resolve":407,"../internals/species-constructor":418}],491:[function(_dereq_,module,exports){
  23515. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  23516. _dereq_('../modules/es.promise.constructor');
  23517. _dereq_('../modules/es.promise.all');
  23518. _dereq_('../modules/es.promise.catch');
  23519. _dereq_('../modules/es.promise.race');
  23520. _dereq_('../modules/es.promise.reject');
  23521. _dereq_('../modules/es.promise.resolve');
  23522. },{"../modules/es.promise.all":486,"../modules/es.promise.catch":488,"../modules/es.promise.constructor":489,"../modules/es.promise.race":492,"../modules/es.promise.reject":493,"../modules/es.promise.resolve":494}],492:[function(_dereq_,module,exports){
  23523. 'use strict';
  23524. var $ = _dereq_('../internals/export');
  23525. var call = _dereq_('../internals/function-call');
  23526. var aCallable = _dereq_('../internals/a-callable');
  23527. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23528. var perform = _dereq_('../internals/perform');
  23529. var iterate = _dereq_('../internals/iterate');
  23530. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  23531. // `Promise.race` method
  23532. // https://tc39.es/ecma262/#sec-promise.race
  23533. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  23534. race: function race(iterable) {
  23535. var C = this;
  23536. var capability = newPromiseCapabilityModule.f(C);
  23537. var reject = capability.reject;
  23538. var result = perform(function () {
  23539. var $promiseResolve = aCallable(C.resolve);
  23540. iterate(iterable, function (promise) {
  23541. call($promiseResolve, C, promise).then(capability.resolve, reject);
  23542. });
  23543. });
  23544. if (result.error) reject(result.value);
  23545. return capability.promise;
  23546. }
  23547. });
  23548. },{"../internals/a-callable":271,"../internals/export":331,"../internals/function-call":338,"../internals/iterate":369,"../internals/new-promise-capability":380,"../internals/perform":404,"../internals/promise-statics-incorrect-iteration":408}],493:[function(_dereq_,module,exports){
  23549. 'use strict';
  23550. var $ = _dereq_('../internals/export');
  23551. var call = _dereq_('../internals/function-call');
  23552. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23553. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  23554. // `Promise.reject` method
  23555. // https://tc39.es/ecma262/#sec-promise.reject
  23556. $({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
  23557. reject: function reject(r) {
  23558. var capability = newPromiseCapabilityModule.f(this);
  23559. call(capability.reject, undefined, r);
  23560. return capability.promise;
  23561. }
  23562. });
  23563. },{"../internals/export":331,"../internals/function-call":338,"../internals/new-promise-capability":380,"../internals/promise-constructor-detection":405}],494:[function(_dereq_,module,exports){
  23564. 'use strict';
  23565. var $ = _dereq_('../internals/export');
  23566. var getBuiltIn = _dereq_('../internals/get-built-in');
  23567. var IS_PURE = _dereq_('../internals/is-pure');
  23568. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  23569. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  23570. var promiseResolve = _dereq_('../internals/promise-resolve');
  23571. var PromiseConstructorWrapper = getBuiltIn('Promise');
  23572. var CHECK_WRAPPER = IS_PURE && !FORCED_PROMISE_CONSTRUCTOR;
  23573. // `Promise.resolve` method
  23574. // https://tc39.es/ecma262/#sec-promise.resolve
  23575. $({ target: 'Promise', stat: true, forced: IS_PURE || FORCED_PROMISE_CONSTRUCTOR }, {
  23576. resolve: function resolve(x) {
  23577. return promiseResolve(CHECK_WRAPPER && this === PromiseConstructorWrapper ? NativePromiseConstructor : this, x);
  23578. }
  23579. });
  23580. },{"../internals/export":331,"../internals/get-built-in":341,"../internals/is-pure":366,"../internals/promise-constructor-detection":405,"../internals/promise-native-constructor":406,"../internals/promise-resolve":407}],495:[function(_dereq_,module,exports){
  23581. var $ = _dereq_('../internals/export');
  23582. var getBuiltIn = _dereq_('../internals/get-built-in');
  23583. var apply = _dereq_('../internals/function-apply');
  23584. var bind = _dereq_('../internals/function-bind');
  23585. var aConstructor = _dereq_('../internals/a-constructor');
  23586. var anObject = _dereq_('../internals/an-object');
  23587. var isObject = _dereq_('../internals/is-object');
  23588. var create = _dereq_('../internals/object-create');
  23589. var fails = _dereq_('../internals/fails');
  23590. var nativeConstruct = getBuiltIn('Reflect', 'construct');
  23591. var ObjectPrototype = Object.prototype;
  23592. var push = [].push;
  23593. // `Reflect.construct` method
  23594. // https://tc39.es/ecma262/#sec-reflect.construct
  23595. // MS Edge supports only 2 arguments and argumentsList argument is optional
  23596. // FF Nightly sets third argument as `new.target`, but does not create `this` from it
  23597. var NEW_TARGET_BUG = fails(function () {
  23598. function F() { /* empty */ }
  23599. return !(nativeConstruct(function () { /* empty */ }, [], F) instanceof F);
  23600. });
  23601. var ARGS_BUG = !fails(function () {
  23602. nativeConstruct(function () { /* empty */ });
  23603. });
  23604. var FORCED = NEW_TARGET_BUG || ARGS_BUG;
  23605. $({ target: 'Reflect', stat: true, forced: FORCED, sham: FORCED }, {
  23606. construct: function construct(Target, args /* , newTarget */) {
  23607. aConstructor(Target);
  23608. anObject(args);
  23609. var newTarget = arguments.length < 3 ? Target : aConstructor(arguments[2]);
  23610. if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);
  23611. if (Target == newTarget) {
  23612. // w/o altered newTarget, optimization for 0-4 arguments
  23613. switch (args.length) {
  23614. case 0: return new Target();
  23615. case 1: return new Target(args[0]);
  23616. case 2: return new Target(args[0], args[1]);
  23617. case 3: return new Target(args[0], args[1], args[2]);
  23618. case 4: return new Target(args[0], args[1], args[2], args[3]);
  23619. }
  23620. // w/o altered newTarget, lot of arguments case
  23621. var $args = [null];
  23622. apply(push, $args, args);
  23623. return new (apply(bind, Target, $args))();
  23624. }
  23625. // with altered newTarget, not support built-in constructors
  23626. var proto = newTarget.prototype;
  23627. var instance = create(isObject(proto) ? proto : ObjectPrototype);
  23628. var result = apply(Target, instance, args);
  23629. return isObject(result) ? result : instance;
  23630. }
  23631. });
  23632. },{"../internals/a-constructor":272,"../internals/an-object":276,"../internals/export":331,"../internals/fails":332,"../internals/function-apply":334,"../internals/function-bind":337,"../internals/get-built-in":341,"../internals/is-object":365,"../internals/object-create":385}],496:[function(_dereq_,module,exports){
  23633. var $ = _dereq_('../internals/export');
  23634. var call = _dereq_('../internals/function-call');
  23635. var isObject = _dereq_('../internals/is-object');
  23636. var anObject = _dereq_('../internals/an-object');
  23637. var isDataDescriptor = _dereq_('../internals/is-data-descriptor');
  23638. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  23639. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  23640. // `Reflect.get` method
  23641. // https://tc39.es/ecma262/#sec-reflect.get
  23642. function get(target, propertyKey /* , receiver */) {
  23643. var receiver = arguments.length < 3 ? target : arguments[2];
  23644. var descriptor, prototype;
  23645. if (anObject(target) === receiver) return target[propertyKey];
  23646. descriptor = getOwnPropertyDescriptorModule.f(target, propertyKey);
  23647. if (descriptor) return isDataDescriptor(descriptor)
  23648. ? descriptor.value
  23649. : descriptor.get === undefined ? undefined : call(descriptor.get, receiver);
  23650. if (isObject(prototype = getPrototypeOf(target))) return get(prototype, propertyKey, receiver);
  23651. }
  23652. $({ target: 'Reflect', stat: true }, {
  23653. get: get
  23654. });
  23655. },{"../internals/an-object":276,"../internals/export":331,"../internals/function-call":338,"../internals/is-data-descriptor":361,"../internals/is-object":365,"../internals/object-get-own-property-descriptor":388,"../internals/object-get-prototype-of":392}],497:[function(_dereq_,module,exports){
  23656. arguments[4][463][0].apply(exports,arguments)
  23657. },{"dup":463}],498:[function(_dereq_,module,exports){
  23658. 'use strict';
  23659. var collection = _dereq_('../internals/collection');
  23660. var collectionStrong = _dereq_('../internals/collection-strong');
  23661. // `Set` constructor
  23662. // https://tc39.es/ecma262/#sec-set-objects
  23663. collection('Set', function (init) {
  23664. return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };
  23665. }, collectionStrong);
  23666. },{"../internals/collection":300,"../internals/collection-strong":298}],499:[function(_dereq_,module,exports){
  23667. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  23668. _dereq_('../modules/es.set.constructor');
  23669. },{"../modules/es.set.constructor":498}],500:[function(_dereq_,module,exports){
  23670. 'use strict';
  23671. var $ = _dereq_('../internals/export');
  23672. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  23673. var notARegExp = _dereq_('../internals/not-a-regexp');
  23674. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  23675. var toString = _dereq_('../internals/to-string');
  23676. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  23677. var stringIndexOf = uncurryThis(''.indexOf);
  23678. // `String.prototype.includes` method
  23679. // https://tc39.es/ecma262/#sec-string.prototype.includes
  23680. $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
  23681. includes: function includes(searchString /* , position = 0 */) {
  23682. return !!~stringIndexOf(
  23683. toString(requireObjectCoercible(this)),
  23684. toString(notARegExp(searchString)),
  23685. arguments.length > 1 ? arguments[1] : undefined
  23686. );
  23687. }
  23688. });
  23689. },{"../internals/correct-is-regexp-logic":302,"../internals/export":331,"../internals/function-uncurry-this":340,"../internals/not-a-regexp":382,"../internals/require-object-coercible":410,"../internals/to-string":433}],501:[function(_dereq_,module,exports){
  23690. 'use strict';
  23691. var charAt = _dereq_('../internals/string-multibyte').charAt;
  23692. var toString = _dereq_('../internals/to-string');
  23693. var InternalStateModule = _dereq_('../internals/internal-state');
  23694. var defineIterator = _dereq_('../internals/iterator-define');
  23695. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  23696. var STRING_ITERATOR = 'String Iterator';
  23697. var setInternalState = InternalStateModule.set;
  23698. var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
  23699. // `String.prototype[@@iterator]` method
  23700. // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
  23701. defineIterator(String, 'String', function (iterated) {
  23702. setInternalState(this, {
  23703. type: STRING_ITERATOR,
  23704. string: toString(iterated),
  23705. index: 0
  23706. });
  23707. // `%StringIteratorPrototype%.next` method
  23708. // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
  23709. }, function next() {
  23710. var state = getInternalState(this);
  23711. var string = state.string;
  23712. var index = state.index;
  23713. var point;
  23714. if (index >= string.length) return createIterResultObject(undefined, true);
  23715. point = charAt(string, index);
  23716. state.index += point.length;
  23717. return createIterResultObject(point, false);
  23718. });
  23719. },{"../internals/create-iter-result-object":304,"../internals/internal-state":356,"../internals/iterator-define":372,"../internals/string-multibyte":419,"../internals/to-string":433}],502:[function(_dereq_,module,exports){
  23720. 'use strict';
  23721. var $ = _dereq_('../internals/export');
  23722. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  23723. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  23724. var toLength = _dereq_('../internals/to-length');
  23725. var toString = _dereq_('../internals/to-string');
  23726. var notARegExp = _dereq_('../internals/not-a-regexp');
  23727. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  23728. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  23729. var IS_PURE = _dereq_('../internals/is-pure');
  23730. // eslint-disable-next-line es-x/no-string-prototype-startswith -- safe
  23731. var nativeStartsWith = uncurryThis(''.startsWith);
  23732. var stringSlice = uncurryThis(''.slice);
  23733. var min = Math.min;
  23734. var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');
  23735. // https://github.com/zloirock/core-js/pull/702
  23736. var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
  23737. var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
  23738. return descriptor && !descriptor.writable;
  23739. }();
  23740. // `String.prototype.startsWith` method
  23741. // https://tc39.es/ecma262/#sec-string.prototype.startswith
  23742. $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
  23743. startsWith: function startsWith(searchString /* , position = 0 */) {
  23744. var that = toString(requireObjectCoercible(this));
  23745. notARegExp(searchString);
  23746. var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  23747. var search = toString(searchString);
  23748. return nativeStartsWith
  23749. ? nativeStartsWith(that, search, index)
  23750. : stringSlice(that, index, index + search.length) === search;
  23751. }
  23752. });
  23753. },{"../internals/correct-is-regexp-logic":302,"../internals/export":331,"../internals/function-uncurry-this":340,"../internals/is-pure":366,"../internals/not-a-regexp":382,"../internals/object-get-own-property-descriptor":388,"../internals/require-object-coercible":410,"../internals/to-length":428,"../internals/to-string":433}],503:[function(_dereq_,module,exports){
  23754. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  23755. // `Symbol.asyncIterator` well-known symbol
  23756. // https://tc39.es/ecma262/#sec-symbol.asynciterator
  23757. defineWellKnownSymbol('asyncIterator');
  23758. },{"../internals/well-known-symbol-define":440}],504:[function(_dereq_,module,exports){
  23759. 'use strict';
  23760. var $ = _dereq_('../internals/export');
  23761. var global = _dereq_('../internals/global');
  23762. var call = _dereq_('../internals/function-call');
  23763. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  23764. var IS_PURE = _dereq_('../internals/is-pure');
  23765. var DESCRIPTORS = _dereq_('../internals/descriptors');
  23766. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  23767. var fails = _dereq_('../internals/fails');
  23768. var hasOwn = _dereq_('../internals/has-own-property');
  23769. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  23770. var anObject = _dereq_('../internals/an-object');
  23771. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  23772. var toPropertyKey = _dereq_('../internals/to-property-key');
  23773. var $toString = _dereq_('../internals/to-string');
  23774. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  23775. var nativeObjectCreate = _dereq_('../internals/object-create');
  23776. var objectKeys = _dereq_('../internals/object-keys');
  23777. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  23778. var getOwnPropertyNamesExternal = _dereq_('../internals/object-get-own-property-names-external');
  23779. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  23780. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  23781. var definePropertyModule = _dereq_('../internals/object-define-property');
  23782. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  23783. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  23784. var defineBuiltIn = _dereq_('../internals/define-built-in');
  23785. var shared = _dereq_('../internals/shared');
  23786. var sharedKey = _dereq_('../internals/shared-key');
  23787. var hiddenKeys = _dereq_('../internals/hidden-keys');
  23788. var uid = _dereq_('../internals/uid');
  23789. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  23790. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  23791. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  23792. var defineSymbolToPrimitive = _dereq_('../internals/symbol-define-to-primitive');
  23793. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  23794. var InternalStateModule = _dereq_('../internals/internal-state');
  23795. var $forEach = _dereq_('../internals/array-iteration').forEach;
  23796. var HIDDEN = sharedKey('hidden');
  23797. var SYMBOL = 'Symbol';
  23798. var PROTOTYPE = 'prototype';
  23799. var setInternalState = InternalStateModule.set;
  23800. var getInternalState = InternalStateModule.getterFor(SYMBOL);
  23801. var ObjectPrototype = Object[PROTOTYPE];
  23802. var $Symbol = global.Symbol;
  23803. var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE];
  23804. var TypeError = global.TypeError;
  23805. var QObject = global.QObject;
  23806. var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  23807. var nativeDefineProperty = definePropertyModule.f;
  23808. var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
  23809. var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
  23810. var push = uncurryThis([].push);
  23811. var AllSymbols = shared('symbols');
  23812. var ObjectPrototypeSymbols = shared('op-symbols');
  23813. var WellKnownSymbolsStore = shared('wks');
  23814. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  23815. var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  23816. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  23817. var setSymbolDescriptor = DESCRIPTORS && fails(function () {
  23818. return nativeObjectCreate(nativeDefineProperty({}, 'a', {
  23819. get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }
  23820. })).a != 7;
  23821. }) ? function (O, P, Attributes) {
  23822. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
  23823. if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
  23824. nativeDefineProperty(O, P, Attributes);
  23825. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  23826. nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
  23827. }
  23828. } : nativeDefineProperty;
  23829. var wrap = function (tag, description) {
  23830. var symbol = AllSymbols[tag] = nativeObjectCreate(SymbolPrototype);
  23831. setInternalState(symbol, {
  23832. type: SYMBOL,
  23833. tag: tag,
  23834. description: description
  23835. });
  23836. if (!DESCRIPTORS) symbol.description = description;
  23837. return symbol;
  23838. };
  23839. var $defineProperty = function defineProperty(O, P, Attributes) {
  23840. if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  23841. anObject(O);
  23842. var key = toPropertyKey(P);
  23843. anObject(Attributes);
  23844. if (hasOwn(AllSymbols, key)) {
  23845. if (!Attributes.enumerable) {
  23846. if (!hasOwn(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
  23847. O[HIDDEN][key] = true;
  23848. } else {
  23849. if (hasOwn(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
  23850. Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  23851. } return setSymbolDescriptor(O, key, Attributes);
  23852. } return nativeDefineProperty(O, key, Attributes);
  23853. };
  23854. var $defineProperties = function defineProperties(O, Properties) {
  23855. anObject(O);
  23856. var properties = toIndexedObject(Properties);
  23857. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  23858. $forEach(keys, function (key) {
  23859. if (!DESCRIPTORS || call($propertyIsEnumerable, properties, key)) $defineProperty(O, key, properties[key]);
  23860. });
  23861. return O;
  23862. };
  23863. var $create = function create(O, Properties) {
  23864. return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
  23865. };
  23866. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  23867. var P = toPropertyKey(V);
  23868. var enumerable = call(nativePropertyIsEnumerable, this, P);
  23869. if (this === ObjectPrototype && hasOwn(AllSymbols, P) && !hasOwn(ObjectPrototypeSymbols, P)) return false;
  23870. return enumerable || !hasOwn(this, P) || !hasOwn(AllSymbols, P) || hasOwn(this, HIDDEN) && this[HIDDEN][P]
  23871. ? enumerable : true;
  23872. };
  23873. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  23874. var it = toIndexedObject(O);
  23875. var key = toPropertyKey(P);
  23876. if (it === ObjectPrototype && hasOwn(AllSymbols, key) && !hasOwn(ObjectPrototypeSymbols, key)) return;
  23877. var descriptor = nativeGetOwnPropertyDescriptor(it, key);
  23878. if (descriptor && hasOwn(AllSymbols, key) && !(hasOwn(it, HIDDEN) && it[HIDDEN][key])) {
  23879. descriptor.enumerable = true;
  23880. }
  23881. return descriptor;
  23882. };
  23883. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  23884. var names = nativeGetOwnPropertyNames(toIndexedObject(O));
  23885. var result = [];
  23886. $forEach(names, function (key) {
  23887. if (!hasOwn(AllSymbols, key) && !hasOwn(hiddenKeys, key)) push(result, key);
  23888. });
  23889. return result;
  23890. };
  23891. var $getOwnPropertySymbols = function (O) {
  23892. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  23893. var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  23894. var result = [];
  23895. $forEach(names, function (key) {
  23896. if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) {
  23897. push(result, AllSymbols[key]);
  23898. }
  23899. });
  23900. return result;
  23901. };
  23902. // `Symbol` constructor
  23903. // https://tc39.es/ecma262/#sec-symbol-constructor
  23904. if (!NATIVE_SYMBOL) {
  23905. $Symbol = function Symbol() {
  23906. if (isPrototypeOf(SymbolPrototype, this)) throw TypeError('Symbol is not a constructor');
  23907. var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);
  23908. var tag = uid(description);
  23909. var setter = function (value) {
  23910. if (this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value);
  23911. if (hasOwn(this, HIDDEN) && hasOwn(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  23912. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  23913. };
  23914. if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
  23915. return wrap(tag, description);
  23916. };
  23917. SymbolPrototype = $Symbol[PROTOTYPE];
  23918. defineBuiltIn(SymbolPrototype, 'toString', function toString() {
  23919. return getInternalState(this).tag;
  23920. });
  23921. defineBuiltIn($Symbol, 'withoutSetter', function (description) {
  23922. return wrap(uid(description), description);
  23923. });
  23924. propertyIsEnumerableModule.f = $propertyIsEnumerable;
  23925. definePropertyModule.f = $defineProperty;
  23926. definePropertiesModule.f = $defineProperties;
  23927. getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
  23928. getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  23929. getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
  23930. wrappedWellKnownSymbolModule.f = function (name) {
  23931. return wrap(wellKnownSymbol(name), name);
  23932. };
  23933. if (DESCRIPTORS) {
  23934. // https://github.com/tc39/proposal-Symbol-description
  23935. nativeDefineProperty(SymbolPrototype, 'description', {
  23936. configurable: true,
  23937. get: function description() {
  23938. return getInternalState(this).description;
  23939. }
  23940. });
  23941. if (!IS_PURE) {
  23942. defineBuiltIn(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  23943. }
  23944. }
  23945. }
  23946. $({ global: true, constructor: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {
  23947. Symbol: $Symbol
  23948. });
  23949. $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
  23950. defineWellKnownSymbol(name);
  23951. });
  23952. $({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {
  23953. useSetter: function () { USE_SETTER = true; },
  23954. useSimple: function () { USE_SETTER = false; }
  23955. });
  23956. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {
  23957. // `Object.create` method
  23958. // https://tc39.es/ecma262/#sec-object.create
  23959. create: $create,
  23960. // `Object.defineProperty` method
  23961. // https://tc39.es/ecma262/#sec-object.defineproperty
  23962. defineProperty: $defineProperty,
  23963. // `Object.defineProperties` method
  23964. // https://tc39.es/ecma262/#sec-object.defineproperties
  23965. defineProperties: $defineProperties,
  23966. // `Object.getOwnPropertyDescriptor` method
  23967. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  23968. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  23969. });
  23970. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {
  23971. // `Object.getOwnPropertyNames` method
  23972. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  23973. getOwnPropertyNames: $getOwnPropertyNames
  23974. });
  23975. // `Symbol.prototype[@@toPrimitive]` method
  23976. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  23977. defineSymbolToPrimitive();
  23978. // `Symbol.prototype[@@toStringTag]` property
  23979. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  23980. setToStringTag($Symbol, SYMBOL);
  23981. hiddenKeys[HIDDEN] = true;
  23982. },{"../internals/an-object":276,"../internals/array-iteration":281,"../internals/create-property-descriptor":306,"../internals/define-built-in":308,"../internals/descriptors":312,"../internals/export":331,"../internals/fails":332,"../internals/function-call":338,"../internals/function-uncurry-this":340,"../internals/global":346,"../internals/has-own-property":347,"../internals/hidden-keys":348,"../internals/internal-state":356,"../internals/is-pure":366,"../internals/object-create":385,"../internals/object-define-properties":386,"../internals/object-define-property":387,"../internals/object-get-own-property-descriptor":388,"../internals/object-get-own-property-names":390,"../internals/object-get-own-property-names-external":389,"../internals/object-get-own-property-symbols":391,"../internals/object-is-prototype-of":394,"../internals/object-keys":396,"../internals/object-property-is-enumerable":397,"../internals/set-to-string-tag":414,"../internals/shared":417,"../internals/shared-key":415,"../internals/symbol-constructor-detection":421,"../internals/symbol-define-to-primitive":422,"../internals/to-indexed-object":426,"../internals/to-property-key":431,"../internals/to-string":433,"../internals/uid":435,"../internals/well-known-symbol":442,"../internals/well-known-symbol-define":440,"../internals/well-known-symbol-wrapped":441}],505:[function(_dereq_,module,exports){
  23983. arguments[4][463][0].apply(exports,arguments)
  23984. },{"dup":463}],506:[function(_dereq_,module,exports){
  23985. var $ = _dereq_('../internals/export');
  23986. var getBuiltIn = _dereq_('../internals/get-built-in');
  23987. var hasOwn = _dereq_('../internals/has-own-property');
  23988. var toString = _dereq_('../internals/to-string');
  23989. var shared = _dereq_('../internals/shared');
  23990. var NATIVE_SYMBOL_REGISTRY = _dereq_('../internals/symbol-registry-detection');
  23991. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  23992. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  23993. // `Symbol.for` method
  23994. // https://tc39.es/ecma262/#sec-symbol.for
  23995. $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, {
  23996. 'for': function (key) {
  23997. var string = toString(key);
  23998. if (hasOwn(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
  23999. var symbol = getBuiltIn('Symbol')(string);
  24000. StringToSymbolRegistry[string] = symbol;
  24001. SymbolToStringRegistry[symbol] = string;
  24002. return symbol;
  24003. }
  24004. });
  24005. },{"../internals/export":331,"../internals/get-built-in":341,"../internals/has-own-property":347,"../internals/shared":417,"../internals/symbol-registry-detection":423,"../internals/to-string":433}],507:[function(_dereq_,module,exports){
  24006. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24007. // `Symbol.hasInstance` well-known symbol
  24008. // https://tc39.es/ecma262/#sec-symbol.hasinstance
  24009. defineWellKnownSymbol('hasInstance');
  24010. },{"../internals/well-known-symbol-define":440}],508:[function(_dereq_,module,exports){
  24011. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24012. // `Symbol.isConcatSpreadable` well-known symbol
  24013. // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
  24014. defineWellKnownSymbol('isConcatSpreadable');
  24015. },{"../internals/well-known-symbol-define":440}],509:[function(_dereq_,module,exports){
  24016. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24017. // `Symbol.iterator` well-known symbol
  24018. // https://tc39.es/ecma262/#sec-symbol.iterator
  24019. defineWellKnownSymbol('iterator');
  24020. },{"../internals/well-known-symbol-define":440}],510:[function(_dereq_,module,exports){
  24021. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  24022. _dereq_('../modules/es.symbol.constructor');
  24023. _dereq_('../modules/es.symbol.for');
  24024. _dereq_('../modules/es.symbol.key-for');
  24025. _dereq_('../modules/es.json.stringify');
  24026. _dereq_('../modules/es.object.get-own-property-symbols');
  24027. },{"../modules/es.json.stringify":465,"../modules/es.object.get-own-property-symbols":479,"../modules/es.symbol.constructor":504,"../modules/es.symbol.for":506,"../modules/es.symbol.key-for":511}],511:[function(_dereq_,module,exports){
  24028. var $ = _dereq_('../internals/export');
  24029. var hasOwn = _dereq_('../internals/has-own-property');
  24030. var isSymbol = _dereq_('../internals/is-symbol');
  24031. var tryToString = _dereq_('../internals/try-to-string');
  24032. var shared = _dereq_('../internals/shared');
  24033. var NATIVE_SYMBOL_REGISTRY = _dereq_('../internals/symbol-registry-detection');
  24034. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  24035. // `Symbol.keyFor` method
  24036. // https://tc39.es/ecma262/#sec-symbol.keyfor
  24037. $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, {
  24038. keyFor: function keyFor(sym) {
  24039. if (!isSymbol(sym)) throw TypeError(tryToString(sym) + ' is not a symbol');
  24040. if (hasOwn(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
  24041. }
  24042. });
  24043. },{"../internals/export":331,"../internals/has-own-property":347,"../internals/is-symbol":368,"../internals/shared":417,"../internals/symbol-registry-detection":423,"../internals/try-to-string":434}],512:[function(_dereq_,module,exports){
  24044. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24045. // `Symbol.matchAll` well-known symbol
  24046. // https://tc39.es/ecma262/#sec-symbol.matchall
  24047. defineWellKnownSymbol('matchAll');
  24048. },{"../internals/well-known-symbol-define":440}],513:[function(_dereq_,module,exports){
  24049. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24050. // `Symbol.match` well-known symbol
  24051. // https://tc39.es/ecma262/#sec-symbol.match
  24052. defineWellKnownSymbol('match');
  24053. },{"../internals/well-known-symbol-define":440}],514:[function(_dereq_,module,exports){
  24054. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24055. // `Symbol.replace` well-known symbol
  24056. // https://tc39.es/ecma262/#sec-symbol.replace
  24057. defineWellKnownSymbol('replace');
  24058. },{"../internals/well-known-symbol-define":440}],515:[function(_dereq_,module,exports){
  24059. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24060. // `Symbol.search` well-known symbol
  24061. // https://tc39.es/ecma262/#sec-symbol.search
  24062. defineWellKnownSymbol('search');
  24063. },{"../internals/well-known-symbol-define":440}],516:[function(_dereq_,module,exports){
  24064. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24065. // `Symbol.species` well-known symbol
  24066. // https://tc39.es/ecma262/#sec-symbol.species
  24067. defineWellKnownSymbol('species');
  24068. },{"../internals/well-known-symbol-define":440}],517:[function(_dereq_,module,exports){
  24069. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24070. // `Symbol.split` well-known symbol
  24071. // https://tc39.es/ecma262/#sec-symbol.split
  24072. defineWellKnownSymbol('split');
  24073. },{"../internals/well-known-symbol-define":440}],518:[function(_dereq_,module,exports){
  24074. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24075. var defineSymbolToPrimitive = _dereq_('../internals/symbol-define-to-primitive');
  24076. // `Symbol.toPrimitive` well-known symbol
  24077. // https://tc39.es/ecma262/#sec-symbol.toprimitive
  24078. defineWellKnownSymbol('toPrimitive');
  24079. // `Symbol.prototype[@@toPrimitive]` method
  24080. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  24081. defineSymbolToPrimitive();
  24082. },{"../internals/symbol-define-to-primitive":422,"../internals/well-known-symbol-define":440}],519:[function(_dereq_,module,exports){
  24083. var getBuiltIn = _dereq_('../internals/get-built-in');
  24084. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24085. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  24086. // `Symbol.toStringTag` well-known symbol
  24087. // https://tc39.es/ecma262/#sec-symbol.tostringtag
  24088. defineWellKnownSymbol('toStringTag');
  24089. // `Symbol.prototype[@@toStringTag]` property
  24090. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  24091. setToStringTag(getBuiltIn('Symbol'), 'Symbol');
  24092. },{"../internals/get-built-in":341,"../internals/set-to-string-tag":414,"../internals/well-known-symbol-define":440}],520:[function(_dereq_,module,exports){
  24093. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24094. // `Symbol.unscopables` well-known symbol
  24095. // https://tc39.es/ecma262/#sec-symbol.unscopables
  24096. defineWellKnownSymbol('unscopables');
  24097. },{"../internals/well-known-symbol-define":440}],521:[function(_dereq_,module,exports){
  24098. 'use strict';
  24099. var global = _dereq_('../internals/global');
  24100. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  24101. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  24102. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  24103. var collection = _dereq_('../internals/collection');
  24104. var collectionWeak = _dereq_('../internals/collection-weak');
  24105. var isObject = _dereq_('../internals/is-object');
  24106. var isExtensible = _dereq_('../internals/object-is-extensible');
  24107. var enforceInternalState = _dereq_('../internals/internal-state').enforce;
  24108. var NATIVE_WEAK_MAP = _dereq_('../internals/weak-map-basic-detection');
  24109. var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
  24110. var InternalWeakMap;
  24111. var wrapper = function (init) {
  24112. return function WeakMap() {
  24113. return init(this, arguments.length ? arguments[0] : undefined);
  24114. };
  24115. };
  24116. // `WeakMap` constructor
  24117. // https://tc39.es/ecma262/#sec-weakmap-constructor
  24118. var $WeakMap = collection('WeakMap', wrapper, collectionWeak);
  24119. // IE11 WeakMap frozen keys fix
  24120. // We can't use feature detection because it crash some old IE builds
  24121. // https://github.com/zloirock/core-js/issues/485
  24122. if (NATIVE_WEAK_MAP && IS_IE11) {
  24123. InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
  24124. InternalMetadataModule.enable();
  24125. var WeakMapPrototype = $WeakMap.prototype;
  24126. var nativeDelete = uncurryThis(WeakMapPrototype['delete']);
  24127. var nativeHas = uncurryThis(WeakMapPrototype.has);
  24128. var nativeGet = uncurryThis(WeakMapPrototype.get);
  24129. var nativeSet = uncurryThis(WeakMapPrototype.set);
  24130. defineBuiltIns(WeakMapPrototype, {
  24131. 'delete': function (key) {
  24132. if (isObject(key) && !isExtensible(key)) {
  24133. var state = enforceInternalState(this);
  24134. if (!state.frozen) state.frozen = new InternalWeakMap();
  24135. return nativeDelete(this, key) || state.frozen['delete'](key);
  24136. } return nativeDelete(this, key);
  24137. },
  24138. has: function has(key) {
  24139. if (isObject(key) && !isExtensible(key)) {
  24140. var state = enforceInternalState(this);
  24141. if (!state.frozen) state.frozen = new InternalWeakMap();
  24142. return nativeHas(this, key) || state.frozen.has(key);
  24143. } return nativeHas(this, key);
  24144. },
  24145. get: function get(key) {
  24146. if (isObject(key) && !isExtensible(key)) {
  24147. var state = enforceInternalState(this);
  24148. if (!state.frozen) state.frozen = new InternalWeakMap();
  24149. return nativeHas(this, key) ? nativeGet(this, key) : state.frozen.get(key);
  24150. } return nativeGet(this, key);
  24151. },
  24152. set: function set(key, value) {
  24153. if (isObject(key) && !isExtensible(key)) {
  24154. var state = enforceInternalState(this);
  24155. if (!state.frozen) state.frozen = new InternalWeakMap();
  24156. nativeHas(this, key) ? nativeSet(this, key, value) : state.frozen.set(key, value);
  24157. } else nativeSet(this, key, value);
  24158. return this;
  24159. }
  24160. });
  24161. }
  24162. },{"../internals/collection":300,"../internals/collection-weak":299,"../internals/define-built-ins":309,"../internals/function-uncurry-this":340,"../internals/global":346,"../internals/internal-metadata":355,"../internals/internal-state":356,"../internals/is-object":365,"../internals/object-is-extensible":393,"../internals/weak-map-basic-detection":439}],522:[function(_dereq_,module,exports){
  24163. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  24164. _dereq_('../modules/es.weak-map.constructor');
  24165. },{"../modules/es.weak-map.constructor":521}],523:[function(_dereq_,module,exports){
  24166. // TODO: Remove from `core-js@4`
  24167. _dereq_('../modules/es.aggregate-error');
  24168. },{"../modules/es.aggregate-error":445}],524:[function(_dereq_,module,exports){
  24169. 'use strict';
  24170. var $ = _dereq_('../internals/export');
  24171. var deleteAll = _dereq_('../internals/collection-delete-all');
  24172. // `Map.prototype.deleteAll` method
  24173. // https://github.com/tc39/proposal-collection-methods
  24174. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24175. deleteAll: deleteAll
  24176. });
  24177. },{"../internals/collection-delete-all":295,"../internals/export":331}],525:[function(_dereq_,module,exports){
  24178. 'use strict';
  24179. var $ = _dereq_('../internals/export');
  24180. var emplace = _dereq_('../internals/map-emplace');
  24181. // `Map.prototype.emplace` method
  24182. // https://github.com/thumbsupep/proposal-upsert
  24183. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24184. emplace: emplace
  24185. });
  24186. },{"../internals/export":331,"../internals/map-emplace":376}],526:[function(_dereq_,module,exports){
  24187. 'use strict';
  24188. var $ = _dereq_('../internals/export');
  24189. var anObject = _dereq_('../internals/an-object');
  24190. var bind = _dereq_('../internals/function-bind-context');
  24191. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24192. var iterate = _dereq_('../internals/iterate');
  24193. // `Map.prototype.every` method
  24194. // https://github.com/tc39/proposal-collection-methods
  24195. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24196. every: function every(callbackfn /* , thisArg */) {
  24197. var map = anObject(this);
  24198. var iterator = getMapIterator(map);
  24199. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24200. return !iterate(iterator, function (key, value, stop) {
  24201. if (!boundFunction(value, key, map)) return stop();
  24202. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  24203. }
  24204. });
  24205. },{"../internals/an-object":276,"../internals/export":331,"../internals/function-bind-context":335,"../internals/get-map-iterator":344,"../internals/iterate":369}],527:[function(_dereq_,module,exports){
  24206. 'use strict';
  24207. var $ = _dereq_('../internals/export');
  24208. var getBuiltIn = _dereq_('../internals/get-built-in');
  24209. var bind = _dereq_('../internals/function-bind-context');
  24210. var call = _dereq_('../internals/function-call');
  24211. var aCallable = _dereq_('../internals/a-callable');
  24212. var anObject = _dereq_('../internals/an-object');
  24213. var speciesConstructor = _dereq_('../internals/species-constructor');
  24214. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24215. var iterate = _dereq_('../internals/iterate');
  24216. // `Map.prototype.filter` method
  24217. // https://github.com/tc39/proposal-collection-methods
  24218. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24219. filter: function filter(callbackfn /* , thisArg */) {
  24220. var map = anObject(this);
  24221. var iterator = getMapIterator(map);
  24222. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24223. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  24224. var setter = aCallable(newMap.set);
  24225. iterate(iterator, function (key, value) {
  24226. if (boundFunction(value, key, map)) call(setter, newMap, key, value);
  24227. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  24228. return newMap;
  24229. }
  24230. });
  24231. },{"../internals/a-callable":271,"../internals/an-object":276,"../internals/export":331,"../internals/function-bind-context":335,"../internals/function-call":338,"../internals/get-built-in":341,"../internals/get-map-iterator":344,"../internals/iterate":369,"../internals/species-constructor":418}],528:[function(_dereq_,module,exports){
  24232. 'use strict';
  24233. var $ = _dereq_('../internals/export');
  24234. var anObject = _dereq_('../internals/an-object');
  24235. var bind = _dereq_('../internals/function-bind-context');
  24236. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24237. var iterate = _dereq_('../internals/iterate');
  24238. // `Map.prototype.findKey` method
  24239. // https://github.com/tc39/proposal-collection-methods
  24240. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24241. findKey: function findKey(callbackfn /* , thisArg */) {
  24242. var map = anObject(this);
  24243. var iterator = getMapIterator(map);
  24244. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24245. return iterate(iterator, function (key, value, stop) {
  24246. if (boundFunction(value, key, map)) return stop(key);
  24247. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  24248. }
  24249. });
  24250. },{"../internals/an-object":276,"../internals/export":331,"../internals/function-bind-context":335,"../internals/get-map-iterator":344,"../internals/iterate":369}],529:[function(_dereq_,module,exports){
  24251. 'use strict';
  24252. var $ = _dereq_('../internals/export');
  24253. var anObject = _dereq_('../internals/an-object');
  24254. var bind = _dereq_('../internals/function-bind-context');
  24255. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24256. var iterate = _dereq_('../internals/iterate');
  24257. // `Map.prototype.find` method
  24258. // https://github.com/tc39/proposal-collection-methods
  24259. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24260. find: function find(callbackfn /* , thisArg */) {
  24261. var map = anObject(this);
  24262. var iterator = getMapIterator(map);
  24263. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24264. return iterate(iterator, function (key, value, stop) {
  24265. if (boundFunction(value, key, map)) return stop(value);
  24266. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  24267. }
  24268. });
  24269. },{"../internals/an-object":276,"../internals/export":331,"../internals/function-bind-context":335,"../internals/get-map-iterator":344,"../internals/iterate":369}],530:[function(_dereq_,module,exports){
  24270. var $ = _dereq_('../internals/export');
  24271. var from = _dereq_('../internals/collection-from');
  24272. // `Map.from` method
  24273. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
  24274. $({ target: 'Map', stat: true, forced: true }, {
  24275. from: from
  24276. });
  24277. },{"../internals/collection-from":296,"../internals/export":331}],531:[function(_dereq_,module,exports){
  24278. 'use strict';
  24279. var $ = _dereq_('../internals/export');
  24280. var call = _dereq_('../internals/function-call');
  24281. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  24282. var aCallable = _dereq_('../internals/a-callable');
  24283. var getIterator = _dereq_('../internals/get-iterator');
  24284. var iterate = _dereq_('../internals/iterate');
  24285. var push = uncurryThis([].push);
  24286. // `Map.groupBy` method
  24287. // https://github.com/tc39/proposal-collection-methods
  24288. $({ target: 'Map', stat: true, forced: true }, {
  24289. groupBy: function groupBy(iterable, keyDerivative) {
  24290. aCallable(keyDerivative);
  24291. var iterator = getIterator(iterable);
  24292. var newMap = new this();
  24293. var has = aCallable(newMap.has);
  24294. var get = aCallable(newMap.get);
  24295. var set = aCallable(newMap.set);
  24296. iterate(iterator, function (element) {
  24297. var derivedKey = keyDerivative(element);
  24298. if (!call(has, newMap, derivedKey)) call(set, newMap, derivedKey, [element]);
  24299. else push(call(get, newMap, derivedKey), element);
  24300. }, { IS_ITERATOR: true });
  24301. return newMap;
  24302. }
  24303. });
  24304. },{"../internals/a-callable":271,"../internals/export":331,"../internals/function-call":338,"../internals/function-uncurry-this":340,"../internals/get-iterator":343,"../internals/iterate":369}],532:[function(_dereq_,module,exports){
  24305. 'use strict';
  24306. var $ = _dereq_('../internals/export');
  24307. var anObject = _dereq_('../internals/an-object');
  24308. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24309. var sameValueZero = _dereq_('../internals/same-value-zero');
  24310. var iterate = _dereq_('../internals/iterate');
  24311. // `Map.prototype.includes` method
  24312. // https://github.com/tc39/proposal-collection-methods
  24313. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24314. includes: function includes(searchElement) {
  24315. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  24316. if (sameValueZero(value, searchElement)) return stop();
  24317. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  24318. }
  24319. });
  24320. },{"../internals/an-object":276,"../internals/export":331,"../internals/get-map-iterator":344,"../internals/iterate":369,"../internals/same-value-zero":411}],533:[function(_dereq_,module,exports){
  24321. 'use strict';
  24322. var $ = _dereq_('../internals/export');
  24323. var call = _dereq_('../internals/function-call');
  24324. var iterate = _dereq_('../internals/iterate');
  24325. var aCallable = _dereq_('../internals/a-callable');
  24326. // `Map.keyBy` method
  24327. // https://github.com/tc39/proposal-collection-methods
  24328. $({ target: 'Map', stat: true, forced: true }, {
  24329. keyBy: function keyBy(iterable, keyDerivative) {
  24330. var newMap = new this();
  24331. aCallable(keyDerivative);
  24332. var setter = aCallable(newMap.set);
  24333. iterate(iterable, function (element) {
  24334. call(setter, newMap, keyDerivative(element), element);
  24335. });
  24336. return newMap;
  24337. }
  24338. });
  24339. },{"../internals/a-callable":271,"../internals/export":331,"../internals/function-call":338,"../internals/iterate":369}],534:[function(_dereq_,module,exports){
  24340. 'use strict';
  24341. var $ = _dereq_('../internals/export');
  24342. var anObject = _dereq_('../internals/an-object');
  24343. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24344. var iterate = _dereq_('../internals/iterate');
  24345. // `Map.prototype.keyOf` method
  24346. // https://github.com/tc39/proposal-collection-methods
  24347. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24348. keyOf: function keyOf(searchElement) {
  24349. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  24350. if (value === searchElement) return stop(key);
  24351. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  24352. }
  24353. });
  24354. },{"../internals/an-object":276,"../internals/export":331,"../internals/get-map-iterator":344,"../internals/iterate":369}],535:[function(_dereq_,module,exports){
  24355. 'use strict';
  24356. var $ = _dereq_('../internals/export');
  24357. var getBuiltIn = _dereq_('../internals/get-built-in');
  24358. var bind = _dereq_('../internals/function-bind-context');
  24359. var call = _dereq_('../internals/function-call');
  24360. var aCallable = _dereq_('../internals/a-callable');
  24361. var anObject = _dereq_('../internals/an-object');
  24362. var speciesConstructor = _dereq_('../internals/species-constructor');
  24363. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24364. var iterate = _dereq_('../internals/iterate');
  24365. // `Map.prototype.mapKeys` method
  24366. // https://github.com/tc39/proposal-collection-methods
  24367. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24368. mapKeys: function mapKeys(callbackfn /* , thisArg */) {
  24369. var map = anObject(this);
  24370. var iterator = getMapIterator(map);
  24371. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24372. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  24373. var setter = aCallable(newMap.set);
  24374. iterate(iterator, function (key, value) {
  24375. call(setter, newMap, boundFunction(value, key, map), value);
  24376. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  24377. return newMap;
  24378. }
  24379. });
  24380. },{"../internals/a-callable":271,"../internals/an-object":276,"../internals/export":331,"../internals/function-bind-context":335,"../internals/function-call":338,"../internals/get-built-in":341,"../internals/get-map-iterator":344,"../internals/iterate":369,"../internals/species-constructor":418}],536:[function(_dereq_,module,exports){
  24381. 'use strict';
  24382. var $ = _dereq_('../internals/export');
  24383. var getBuiltIn = _dereq_('../internals/get-built-in');
  24384. var bind = _dereq_('../internals/function-bind-context');
  24385. var call = _dereq_('../internals/function-call');
  24386. var aCallable = _dereq_('../internals/a-callable');
  24387. var anObject = _dereq_('../internals/an-object');
  24388. var speciesConstructor = _dereq_('../internals/species-constructor');
  24389. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24390. var iterate = _dereq_('../internals/iterate');
  24391. // `Map.prototype.mapValues` method
  24392. // https://github.com/tc39/proposal-collection-methods
  24393. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24394. mapValues: function mapValues(callbackfn /* , thisArg */) {
  24395. var map = anObject(this);
  24396. var iterator = getMapIterator(map);
  24397. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24398. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  24399. var setter = aCallable(newMap.set);
  24400. iterate(iterator, function (key, value) {
  24401. call(setter, newMap, key, boundFunction(value, key, map));
  24402. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  24403. return newMap;
  24404. }
  24405. });
  24406. },{"../internals/a-callable":271,"../internals/an-object":276,"../internals/export":331,"../internals/function-bind-context":335,"../internals/function-call":338,"../internals/get-built-in":341,"../internals/get-map-iterator":344,"../internals/iterate":369,"../internals/species-constructor":418}],537:[function(_dereq_,module,exports){
  24407. 'use strict';
  24408. var $ = _dereq_('../internals/export');
  24409. var aCallable = _dereq_('../internals/a-callable');
  24410. var anObject = _dereq_('../internals/an-object');
  24411. var iterate = _dereq_('../internals/iterate');
  24412. // `Map.prototype.merge` method
  24413. // https://github.com/tc39/proposal-collection-methods
  24414. $({ target: 'Map', proto: true, real: true, arity: 1, forced: true }, {
  24415. // eslint-disable-next-line no-unused-vars -- required for `.length`
  24416. merge: function merge(iterable /* ...iterables */) {
  24417. var map = anObject(this);
  24418. var setter = aCallable(map.set);
  24419. var argumentsLength = arguments.length;
  24420. var i = 0;
  24421. while (i < argumentsLength) {
  24422. iterate(arguments[i++], setter, { that: map, AS_ENTRIES: true });
  24423. }
  24424. return map;
  24425. }
  24426. });
  24427. },{"../internals/a-callable":271,"../internals/an-object":276,"../internals/export":331,"../internals/iterate":369}],538:[function(_dereq_,module,exports){
  24428. var $ = _dereq_('../internals/export');
  24429. var of = _dereq_('../internals/collection-of');
  24430. // `Map.of` method
  24431. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
  24432. $({ target: 'Map', stat: true, forced: true }, {
  24433. of: of
  24434. });
  24435. },{"../internals/collection-of":297,"../internals/export":331}],539:[function(_dereq_,module,exports){
  24436. 'use strict';
  24437. var $ = _dereq_('../internals/export');
  24438. var anObject = _dereq_('../internals/an-object');
  24439. var aCallable = _dereq_('../internals/a-callable');
  24440. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24441. var iterate = _dereq_('../internals/iterate');
  24442. var $TypeError = TypeError;
  24443. // `Map.prototype.reduce` method
  24444. // https://github.com/tc39/proposal-collection-methods
  24445. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24446. reduce: function reduce(callbackfn /* , initialValue */) {
  24447. var map = anObject(this);
  24448. var iterator = getMapIterator(map);
  24449. var noInitial = arguments.length < 2;
  24450. var accumulator = noInitial ? undefined : arguments[1];
  24451. aCallable(callbackfn);
  24452. iterate(iterator, function (key, value) {
  24453. if (noInitial) {
  24454. noInitial = false;
  24455. accumulator = value;
  24456. } else {
  24457. accumulator = callbackfn(accumulator, value, key, map);
  24458. }
  24459. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  24460. if (noInitial) throw $TypeError('Reduce of empty map with no initial value');
  24461. return accumulator;
  24462. }
  24463. });
  24464. },{"../internals/a-callable":271,"../internals/an-object":276,"../internals/export":331,"../internals/get-map-iterator":344,"../internals/iterate":369}],540:[function(_dereq_,module,exports){
  24465. 'use strict';
  24466. var $ = _dereq_('../internals/export');
  24467. var anObject = _dereq_('../internals/an-object');
  24468. var bind = _dereq_('../internals/function-bind-context');
  24469. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24470. var iterate = _dereq_('../internals/iterate');
  24471. // `Set.prototype.some` method
  24472. // https://github.com/tc39/proposal-collection-methods
  24473. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24474. some: function some(callbackfn /* , thisArg */) {
  24475. var map = anObject(this);
  24476. var iterator = getMapIterator(map);
  24477. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24478. return iterate(iterator, function (key, value, stop) {
  24479. if (boundFunction(value, key, map)) return stop();
  24480. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  24481. }
  24482. });
  24483. },{"../internals/an-object":276,"../internals/export":331,"../internals/function-bind-context":335,"../internals/get-map-iterator":344,"../internals/iterate":369}],541:[function(_dereq_,module,exports){
  24484. 'use strict';
  24485. // TODO: remove from `core-js@4`
  24486. var $ = _dereq_('../internals/export');
  24487. var upsert = _dereq_('../internals/map-upsert');
  24488. // `Map.prototype.updateOrInsert` method (replaced by `Map.prototype.emplace`)
  24489. // https://github.com/thumbsupep/proposal-upsert
  24490. $({ target: 'Map', proto: true, real: true, name: 'upsert', forced: true }, {
  24491. updateOrInsert: upsert
  24492. });
  24493. },{"../internals/export":331,"../internals/map-upsert":377}],542:[function(_dereq_,module,exports){
  24494. 'use strict';
  24495. var $ = _dereq_('../internals/export');
  24496. var call = _dereq_('../internals/function-call');
  24497. var anObject = _dereq_('../internals/an-object');
  24498. var aCallable = _dereq_('../internals/a-callable');
  24499. var $TypeError = TypeError;
  24500. // `Set.prototype.update` method
  24501. // https://github.com/tc39/proposal-collection-methods
  24502. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24503. update: function update(key, callback /* , thunk */) {
  24504. var map = anObject(this);
  24505. var get = aCallable(map.get);
  24506. var has = aCallable(map.has);
  24507. var set = aCallable(map.set);
  24508. var length = arguments.length;
  24509. aCallable(callback);
  24510. var isPresentInMap = call(has, map, key);
  24511. if (!isPresentInMap && length < 3) {
  24512. throw $TypeError('Updating absent value');
  24513. }
  24514. var value = isPresentInMap ? call(get, map, key) : aCallable(length > 2 ? arguments[2] : undefined)(key, map);
  24515. call(set, map, key, callback(value, key, map));
  24516. return map;
  24517. }
  24518. });
  24519. },{"../internals/a-callable":271,"../internals/an-object":276,"../internals/export":331,"../internals/function-call":338}],543:[function(_dereq_,module,exports){
  24520. 'use strict';
  24521. // TODO: remove from `core-js@4`
  24522. var $ = _dereq_('../internals/export');
  24523. var upsert = _dereq_('../internals/map-upsert');
  24524. // `Map.prototype.upsert` method (replaced by `Map.prototype.emplace`)
  24525. // https://github.com/thumbsupep/proposal-upsert
  24526. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24527. upsert: upsert
  24528. });
  24529. },{"../internals/export":331,"../internals/map-upsert":377}],544:[function(_dereq_,module,exports){
  24530. // TODO: Remove from `core-js@4`
  24531. _dereq_('../modules/es.promise.all-settled.js');
  24532. },{"../modules/es.promise.all-settled.js":485}],545:[function(_dereq_,module,exports){
  24533. // TODO: Remove from `core-js@4`
  24534. _dereq_('../modules/es.promise.any');
  24535. },{"../modules/es.promise.any":487}],546:[function(_dereq_,module,exports){
  24536. 'use strict';
  24537. // TODO: Remove from `core-js@4`
  24538. var $ = _dereq_('../internals/export');
  24539. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  24540. var perform = _dereq_('../internals/perform');
  24541. // `Promise.try` method
  24542. // https://github.com/tc39/proposal-promise-try
  24543. $({ target: 'Promise', stat: true, forced: true }, {
  24544. 'try': function (callbackfn) {
  24545. var promiseCapability = newPromiseCapabilityModule.f(this);
  24546. var result = perform(callbackfn);
  24547. (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);
  24548. return promiseCapability.promise;
  24549. }
  24550. });
  24551. },{"../internals/export":331,"../internals/new-promise-capability":380,"../internals/perform":404}],547:[function(_dereq_,module,exports){
  24552. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24553. // `Symbol.asyncDispose` well-known symbol
  24554. // https://github.com/tc39/proposal-using-statement
  24555. defineWellKnownSymbol('asyncDispose');
  24556. },{"../internals/well-known-symbol-define":440}],548:[function(_dereq_,module,exports){
  24557. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24558. // `Symbol.dispose` well-known symbol
  24559. // https://github.com/tc39/proposal-using-statement
  24560. defineWellKnownSymbol('dispose');
  24561. },{"../internals/well-known-symbol-define":440}],549:[function(_dereq_,module,exports){
  24562. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24563. // `Symbol.matcher` well-known symbol
  24564. // https://github.com/tc39/proposal-pattern-matching
  24565. defineWellKnownSymbol('matcher');
  24566. },{"../internals/well-known-symbol-define":440}],550:[function(_dereq_,module,exports){
  24567. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24568. // `Symbol.metadataKey` well-known symbol
  24569. // https://github.com/tc39/proposal-decorator-metadata
  24570. defineWellKnownSymbol('metadataKey');
  24571. },{"../internals/well-known-symbol-define":440}],551:[function(_dereq_,module,exports){
  24572. // TODO: Remove from `core-js@4`
  24573. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24574. // `Symbol.metadata` well-known symbol
  24575. // https://github.com/tc39/proposal-decorators
  24576. defineWellKnownSymbol('metadata');
  24577. },{"../internals/well-known-symbol-define":440}],552:[function(_dereq_,module,exports){
  24578. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24579. // `Symbol.observable` well-known symbol
  24580. // https://github.com/tc39/proposal-observable
  24581. defineWellKnownSymbol('observable');
  24582. },{"../internals/well-known-symbol-define":440}],553:[function(_dereq_,module,exports){
  24583. // TODO: remove from `core-js@4`
  24584. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24585. // `Symbol.patternMatch` well-known symbol
  24586. // https://github.com/tc39/proposal-pattern-matching
  24587. defineWellKnownSymbol('patternMatch');
  24588. },{"../internals/well-known-symbol-define":440}],554:[function(_dereq_,module,exports){
  24589. // TODO: remove from `core-js@4`
  24590. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24591. defineWellKnownSymbol('replaceAll');
  24592. },{"../internals/well-known-symbol-define":440}],555:[function(_dereq_,module,exports){
  24593. _dereq_('../modules/es.array.iterator');
  24594. var DOMIterables = _dereq_('../internals/dom-iterables');
  24595. var global = _dereq_('../internals/global');
  24596. var classof = _dereq_('../internals/classof');
  24597. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  24598. var Iterators = _dereq_('../internals/iterators');
  24599. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  24600. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  24601. for (var COLLECTION_NAME in DOMIterables) {
  24602. var Collection = global[COLLECTION_NAME];
  24603. var CollectionPrototype = Collection && Collection.prototype;
  24604. if (CollectionPrototype && classof(CollectionPrototype) !== TO_STRING_TAG) {
  24605. createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
  24606. }
  24607. Iterators[COLLECTION_NAME] = Iterators.Array;
  24608. }
  24609. },{"../internals/classof":294,"../internals/create-non-enumerable-property":305,"../internals/dom-iterables":315,"../internals/global":346,"../internals/iterators":374,"../internals/well-known-symbol":442,"../modules/es.array.iterator":456}],556:[function(_dereq_,module,exports){
  24610. var $ = _dereq_('../internals/export');
  24611. var global = _dereq_('../internals/global');
  24612. var setInterval = _dereq_('../internals/schedulers-fix').setInterval;
  24613. // ie9- setInterval additional parameters fix
  24614. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
  24615. $({ global: true, bind: true, forced: global.setInterval !== setInterval }, {
  24616. setInterval: setInterval
  24617. });
  24618. },{"../internals/export":331,"../internals/global":346,"../internals/schedulers-fix":412}],557:[function(_dereq_,module,exports){
  24619. var $ = _dereq_('../internals/export');
  24620. var global = _dereq_('../internals/global');
  24621. var setTimeout = _dereq_('../internals/schedulers-fix').setTimeout;
  24622. // ie9- setTimeout additional parameters fix
  24623. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
  24624. $({ global: true, bind: true, forced: global.setTimeout !== setTimeout }, {
  24625. setTimeout: setTimeout
  24626. });
  24627. },{"../internals/export":331,"../internals/global":346,"../internals/schedulers-fix":412}],558:[function(_dereq_,module,exports){
  24628. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  24629. _dereq_('../modules/web.set-interval');
  24630. _dereq_('../modules/web.set-timeout');
  24631. },{"../modules/web.set-interval":556,"../modules/web.set-timeout":557}],559:[function(_dereq_,module,exports){
  24632. var parent = _dereq_('../../es/array/from');
  24633. module.exports = parent;
  24634. },{"../../es/array/from":169}],560:[function(_dereq_,module,exports){
  24635. var parent = _dereq_('../../es/array/is-array');
  24636. module.exports = parent;
  24637. },{"../../es/array/is-array":170}],561:[function(_dereq_,module,exports){
  24638. var parent = _dereq_('../../../es/array/virtual/entries');
  24639. module.exports = parent;
  24640. },{"../../../es/array/virtual/entries":172}],562:[function(_dereq_,module,exports){
  24641. var parent = _dereq_('../../../es/array/virtual/for-each');
  24642. module.exports = parent;
  24643. },{"../../../es/array/virtual/for-each":177}],563:[function(_dereq_,module,exports){
  24644. var parent = _dereq_('../../../es/array/virtual/keys');
  24645. module.exports = parent;
  24646. },{"../../../es/array/virtual/keys":180}],564:[function(_dereq_,module,exports){
  24647. var parent = _dereq_('../../../es/array/virtual/values');
  24648. module.exports = parent;
  24649. },{"../../../es/array/virtual/values":187}],565:[function(_dereq_,module,exports){
  24650. var parent = _dereq_('../es/get-iterator-method');
  24651. _dereq_('../modules/web.dom-collections.iterator');
  24652. module.exports = parent;
  24653. },{"../es/get-iterator-method":189,"../modules/web.dom-collections.iterator":555}],566:[function(_dereq_,module,exports){
  24654. var parent = _dereq_('../../es/instance/bind');
  24655. module.exports = parent;
  24656. },{"../../es/instance/bind":190}],567:[function(_dereq_,module,exports){
  24657. var parent = _dereq_('../../es/instance/concat');
  24658. module.exports = parent;
  24659. },{"../../es/instance/concat":191}],568:[function(_dereq_,module,exports){
  24660. _dereq_('../../modules/web.dom-collections.iterator');
  24661. var classof = _dereq_('../../internals/classof');
  24662. var hasOwn = _dereq_('../../internals/has-own-property');
  24663. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  24664. var method = _dereq_('../array/virtual/entries');
  24665. var ArrayPrototype = Array.prototype;
  24666. var DOMIterables = {
  24667. DOMTokenList: true,
  24668. NodeList: true
  24669. };
  24670. module.exports = function (it) {
  24671. var own = it.entries;
  24672. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.entries)
  24673. || hasOwn(DOMIterables, classof(it)) ? method : own;
  24674. };
  24675. },{"../../internals/classof":294,"../../internals/has-own-property":347,"../../internals/object-is-prototype-of":394,"../../modules/web.dom-collections.iterator":555,"../array/virtual/entries":561}],569:[function(_dereq_,module,exports){
  24676. var parent = _dereq_('../../es/instance/every');
  24677. module.exports = parent;
  24678. },{"../../es/instance/every":192}],570:[function(_dereq_,module,exports){
  24679. var parent = _dereq_('../../es/instance/filter');
  24680. module.exports = parent;
  24681. },{"../../es/instance/filter":193}],571:[function(_dereq_,module,exports){
  24682. var parent = _dereq_('../../es/instance/find-index');
  24683. module.exports = parent;
  24684. },{"../../es/instance/find-index":194}],572:[function(_dereq_,module,exports){
  24685. var parent = _dereq_('../../es/instance/find');
  24686. module.exports = parent;
  24687. },{"../../es/instance/find":195}],573:[function(_dereq_,module,exports){
  24688. _dereq_('../../modules/web.dom-collections.iterator');
  24689. var classof = _dereq_('../../internals/classof');
  24690. var hasOwn = _dereq_('../../internals/has-own-property');
  24691. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  24692. var method = _dereq_('../array/virtual/for-each');
  24693. var ArrayPrototype = Array.prototype;
  24694. var DOMIterables = {
  24695. DOMTokenList: true,
  24696. NodeList: true
  24697. };
  24698. module.exports = function (it) {
  24699. var own = it.forEach;
  24700. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.forEach)
  24701. || hasOwn(DOMIterables, classof(it)) ? method : own;
  24702. };
  24703. },{"../../internals/classof":294,"../../internals/has-own-property":347,"../../internals/object-is-prototype-of":394,"../../modules/web.dom-collections.iterator":555,"../array/virtual/for-each":562}],574:[function(_dereq_,module,exports){
  24704. var parent = _dereq_('../../es/instance/includes');
  24705. module.exports = parent;
  24706. },{"../../es/instance/includes":196}],575:[function(_dereq_,module,exports){
  24707. var parent = _dereq_('../../es/instance/index-of');
  24708. module.exports = parent;
  24709. },{"../../es/instance/index-of":197}],576:[function(_dereq_,module,exports){
  24710. _dereq_('../../modules/web.dom-collections.iterator');
  24711. var classof = _dereq_('../../internals/classof');
  24712. var hasOwn = _dereq_('../../internals/has-own-property');
  24713. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  24714. var method = _dereq_('../array/virtual/keys');
  24715. var ArrayPrototype = Array.prototype;
  24716. var DOMIterables = {
  24717. DOMTokenList: true,
  24718. NodeList: true
  24719. };
  24720. module.exports = function (it) {
  24721. var own = it.keys;
  24722. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.keys)
  24723. || hasOwn(DOMIterables, classof(it)) ? method : own;
  24724. };
  24725. },{"../../internals/classof":294,"../../internals/has-own-property":347,"../../internals/object-is-prototype-of":394,"../../modules/web.dom-collections.iterator":555,"../array/virtual/keys":563}],577:[function(_dereq_,module,exports){
  24726. var parent = _dereq_('../../es/instance/map');
  24727. module.exports = parent;
  24728. },{"../../es/instance/map":198}],578:[function(_dereq_,module,exports){
  24729. var parent = _dereq_('../../es/instance/reduce');
  24730. module.exports = parent;
  24731. },{"../../es/instance/reduce":199}],579:[function(_dereq_,module,exports){
  24732. var parent = _dereq_('../../es/instance/reverse');
  24733. module.exports = parent;
  24734. },{"../../es/instance/reverse":200}],580:[function(_dereq_,module,exports){
  24735. var parent = _dereq_('../../es/instance/slice');
  24736. module.exports = parent;
  24737. },{"../../es/instance/slice":201}],581:[function(_dereq_,module,exports){
  24738. var parent = _dereq_('../../es/instance/sort');
  24739. module.exports = parent;
  24740. },{"../../es/instance/sort":202}],582:[function(_dereq_,module,exports){
  24741. var parent = _dereq_('../../es/instance/splice');
  24742. module.exports = parent;
  24743. },{"../../es/instance/splice":203}],583:[function(_dereq_,module,exports){
  24744. var parent = _dereq_('../../es/instance/starts-with');
  24745. module.exports = parent;
  24746. },{"../../es/instance/starts-with":204}],584:[function(_dereq_,module,exports){
  24747. _dereq_('../../modules/web.dom-collections.iterator');
  24748. var classof = _dereq_('../../internals/classof');
  24749. var hasOwn = _dereq_('../../internals/has-own-property');
  24750. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  24751. var method = _dereq_('../array/virtual/values');
  24752. var ArrayPrototype = Array.prototype;
  24753. var DOMIterables = {
  24754. DOMTokenList: true,
  24755. NodeList: true
  24756. };
  24757. module.exports = function (it) {
  24758. var own = it.values;
  24759. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.values)
  24760. || hasOwn(DOMIterables, classof(it)) ? method : own;
  24761. };
  24762. },{"../../internals/classof":294,"../../internals/has-own-property":347,"../../internals/object-is-prototype-of":394,"../../modules/web.dom-collections.iterator":555,"../array/virtual/values":564}],585:[function(_dereq_,module,exports){
  24763. var parent = _dereq_('../../es/json/stringify');
  24764. module.exports = parent;
  24765. },{"../../es/json/stringify":205}],586:[function(_dereq_,module,exports){
  24766. var parent = _dereq_('../../es/map');
  24767. _dereq_('../../modules/web.dom-collections.iterator');
  24768. module.exports = parent;
  24769. },{"../../es/map":206,"../../modules/web.dom-collections.iterator":555}],587:[function(_dereq_,module,exports){
  24770. var parent = _dereq_('../../es/number/is-integer');
  24771. module.exports = parent;
  24772. },{"../../es/number/is-integer":207}],588:[function(_dereq_,module,exports){
  24773. var parent = _dereq_('../../es/object/assign');
  24774. module.exports = parent;
  24775. },{"../../es/object/assign":208}],589:[function(_dereq_,module,exports){
  24776. var parent = _dereq_('../../es/object/create');
  24777. module.exports = parent;
  24778. },{"../../es/object/create":209}],590:[function(_dereq_,module,exports){
  24779. var parent = _dereq_('../../es/object/define-properties');
  24780. module.exports = parent;
  24781. },{"../../es/object/define-properties":210}],591:[function(_dereq_,module,exports){
  24782. var parent = _dereq_('../../es/object/define-property');
  24783. module.exports = parent;
  24784. },{"../../es/object/define-property":211}],592:[function(_dereq_,module,exports){
  24785. var parent = _dereq_('../../es/object/entries');
  24786. module.exports = parent;
  24787. },{"../../es/object/entries":212}],593:[function(_dereq_,module,exports){
  24788. var parent = _dereq_('../../es/object/freeze');
  24789. module.exports = parent;
  24790. },{"../../es/object/freeze":213}],594:[function(_dereq_,module,exports){
  24791. var parent = _dereq_('../../es/object/get-own-property-descriptor');
  24792. module.exports = parent;
  24793. },{"../../es/object/get-own-property-descriptor":214}],595:[function(_dereq_,module,exports){
  24794. var parent = _dereq_('../../es/object/get-own-property-descriptors');
  24795. module.exports = parent;
  24796. },{"../../es/object/get-own-property-descriptors":215}],596:[function(_dereq_,module,exports){
  24797. var parent = _dereq_('../../es/object/get-own-property-symbols');
  24798. module.exports = parent;
  24799. },{"../../es/object/get-own-property-symbols":216}],597:[function(_dereq_,module,exports){
  24800. var parent = _dereq_('../../es/object/get-prototype-of');
  24801. module.exports = parent;
  24802. },{"../../es/object/get-prototype-of":217}],598:[function(_dereq_,module,exports){
  24803. var parent = _dereq_('../../es/object/keys');
  24804. module.exports = parent;
  24805. },{"../../es/object/keys":218}],599:[function(_dereq_,module,exports){
  24806. var parent = _dereq_('../../es/object/set-prototype-of');
  24807. module.exports = parent;
  24808. },{"../../es/object/set-prototype-of":219}],600:[function(_dereq_,module,exports){
  24809. var parent = _dereq_('../es/parse-int');
  24810. module.exports = parent;
  24811. },{"../es/parse-int":220}],601:[function(_dereq_,module,exports){
  24812. var parent = _dereq_('../../es/promise');
  24813. _dereq_('../../modules/web.dom-collections.iterator');
  24814. module.exports = parent;
  24815. },{"../../es/promise":221,"../../modules/web.dom-collections.iterator":555}],602:[function(_dereq_,module,exports){
  24816. var parent = _dereq_('../../es/reflect/construct');
  24817. module.exports = parent;
  24818. },{"../../es/reflect/construct":222}],603:[function(_dereq_,module,exports){
  24819. var parent = _dereq_('../../es/reflect/get');
  24820. module.exports = parent;
  24821. },{"../../es/reflect/get":223}],604:[function(_dereq_,module,exports){
  24822. _dereq_('../modules/web.timers');
  24823. var path = _dereq_('../internals/path');
  24824. module.exports = path.setInterval;
  24825. },{"../internals/path":403,"../modules/web.timers":558}],605:[function(_dereq_,module,exports){
  24826. _dereq_('../modules/web.timers');
  24827. var path = _dereq_('../internals/path');
  24828. module.exports = path.setTimeout;
  24829. },{"../internals/path":403,"../modules/web.timers":558}],606:[function(_dereq_,module,exports){
  24830. var parent = _dereq_('../../es/set');
  24831. _dereq_('../../modules/web.dom-collections.iterator');
  24832. module.exports = parent;
  24833. },{"../../es/set":224,"../../modules/web.dom-collections.iterator":555}],607:[function(_dereq_,module,exports){
  24834. var parent = _dereq_('../../es/symbol');
  24835. _dereq_('../../modules/web.dom-collections.iterator');
  24836. module.exports = parent;
  24837. },{"../../es/symbol":227,"../../modules/web.dom-collections.iterator":555}],608:[function(_dereq_,module,exports){
  24838. var parent = _dereq_('../../es/symbol/iterator');
  24839. _dereq_('../../modules/web.dom-collections.iterator');
  24840. module.exports = parent;
  24841. },{"../../es/symbol/iterator":228,"../../modules/web.dom-collections.iterator":555}],609:[function(_dereq_,module,exports){
  24842. var parent = _dereq_('../../es/symbol/to-primitive');
  24843. module.exports = parent;
  24844. },{"../../es/symbol/to-primitive":229}],610:[function(_dereq_,module,exports){
  24845. var parent = _dereq_('../../es/weak-map');
  24846. _dereq_('../../modules/web.dom-collections.iterator');
  24847. module.exports = parent;
  24848. },{"../../es/weak-map":230,"../../modules/web.dom-collections.iterator":555}],611:[function(_dereq_,module,exports){
  24849. ;(function (root, factory, undef) {
  24850. if (typeof exports === "object") {
  24851. // CommonJS
  24852. module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
  24853. }
  24854. else if (typeof define === "function" && define.amd) {
  24855. // AMD
  24856. define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  24857. }
  24858. else {
  24859. // Global (browser)
  24860. factory(root.CryptoJS);
  24861. }
  24862. }(this, function (CryptoJS) {
  24863. (function () {
  24864. // Shortcuts
  24865. var C = CryptoJS;
  24866. var C_lib = C.lib;
  24867. var BlockCipher = C_lib.BlockCipher;
  24868. var C_algo = C.algo;
  24869. // Lookup tables
  24870. var SBOX = [];
  24871. var INV_SBOX = [];
  24872. var SUB_MIX_0 = [];
  24873. var SUB_MIX_1 = [];
  24874. var SUB_MIX_2 = [];
  24875. var SUB_MIX_3 = [];
  24876. var INV_SUB_MIX_0 = [];
  24877. var INV_SUB_MIX_1 = [];
  24878. var INV_SUB_MIX_2 = [];
  24879. var INV_SUB_MIX_3 = [];
  24880. // Compute lookup tables
  24881. (function () {
  24882. // Compute double table
  24883. var d = [];
  24884. for (var i = 0; i < 256; i++) {
  24885. if (i < 128) {
  24886. d[i] = i << 1;
  24887. } else {
  24888. d[i] = (i << 1) ^ 0x11b;
  24889. }
  24890. }
  24891. // Walk GF(2^8)
  24892. var x = 0;
  24893. var xi = 0;
  24894. for (var i = 0; i < 256; i++) {
  24895. // Compute sbox
  24896. var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  24897. sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  24898. SBOX[x] = sx;
  24899. INV_SBOX[sx] = x;
  24900. // Compute multiplication
  24901. var x2 = d[x];
  24902. var x4 = d[x2];
  24903. var x8 = d[x4];
  24904. // Compute sub bytes, mix columns tables
  24905. var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  24906. SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  24907. SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  24908. SUB_MIX_2[x] = (t << 8) | (t >>> 24);
  24909. SUB_MIX_3[x] = t;
  24910. // Compute inv sub bytes, inv mix columns tables
  24911. var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  24912. INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  24913. INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  24914. INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
  24915. INV_SUB_MIX_3[sx] = t;
  24916. // Compute next counter
  24917. if (!x) {
  24918. x = xi = 1;
  24919. } else {
  24920. x = x2 ^ d[d[d[x8 ^ x2]]];
  24921. xi ^= d[d[xi]];
  24922. }
  24923. }
  24924. }());
  24925. // Precomputed Rcon lookup
  24926. var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  24927. /**
  24928. * AES block cipher algorithm.
  24929. */
  24930. var AES = C_algo.AES = BlockCipher.extend({
  24931. _doReset: function () {
  24932. var t;
  24933. // Skip reset of nRounds has been set before and key did not change
  24934. if (this._nRounds && this._keyPriorReset === this._key) {
  24935. return;
  24936. }
  24937. // Shortcuts
  24938. var key = this._keyPriorReset = this._key;
  24939. var keyWords = key.words;
  24940. var keySize = key.sigBytes / 4;
  24941. // Compute number of rounds
  24942. var nRounds = this._nRounds = keySize + 6;
  24943. // Compute number of key schedule rows
  24944. var ksRows = (nRounds + 1) * 4;
  24945. // Compute key schedule
  24946. var keySchedule = this._keySchedule = [];
  24947. for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  24948. if (ksRow < keySize) {
  24949. keySchedule[ksRow] = keyWords[ksRow];
  24950. } else {
  24951. t = keySchedule[ksRow - 1];
  24952. if (!(ksRow % keySize)) {
  24953. // Rot word
  24954. t = (t << 8) | (t >>> 24);
  24955. // Sub word
  24956. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  24957. // Mix Rcon
  24958. t ^= RCON[(ksRow / keySize) | 0] << 24;
  24959. } else if (keySize > 6 && ksRow % keySize == 4) {
  24960. // Sub word
  24961. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  24962. }
  24963. keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  24964. }
  24965. }
  24966. // Compute inv key schedule
  24967. var invKeySchedule = this._invKeySchedule = [];
  24968. for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  24969. var ksRow = ksRows - invKsRow;
  24970. if (invKsRow % 4) {
  24971. var t = keySchedule[ksRow];
  24972. } else {
  24973. var t = keySchedule[ksRow - 4];
  24974. }
  24975. if (invKsRow < 4 || ksRow <= 4) {
  24976. invKeySchedule[invKsRow] = t;
  24977. } else {
  24978. invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  24979. INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  24980. }
  24981. }
  24982. },
  24983. encryptBlock: function (M, offset) {
  24984. this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  24985. },
  24986. decryptBlock: function (M, offset) {
  24987. // Swap 2nd and 4th rows
  24988. var t = M[offset + 1];
  24989. M[offset + 1] = M[offset + 3];
  24990. M[offset + 3] = t;
  24991. this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  24992. // Inv swap 2nd and 4th rows
  24993. var t = M[offset + 1];
  24994. M[offset + 1] = M[offset + 3];
  24995. M[offset + 3] = t;
  24996. },
  24997. _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  24998. // Shortcut
  24999. var nRounds = this._nRounds;
  25000. // Get input, add round key
  25001. var s0 = M[offset] ^ keySchedule[0];
  25002. var s1 = M[offset + 1] ^ keySchedule[1];
  25003. var s2 = M[offset + 2] ^ keySchedule[2];
  25004. var s3 = M[offset + 3] ^ keySchedule[3];
  25005. // Key schedule row counter
  25006. var ksRow = 4;
  25007. // Rounds
  25008. for (var round = 1; round < nRounds; round++) {
  25009. // Shift rows, sub bytes, mix columns, add round key
  25010. var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
  25011. var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
  25012. var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
  25013. var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
  25014. // Update state
  25015. s0 = t0;
  25016. s1 = t1;
  25017. s2 = t2;
  25018. s3 = t3;
  25019. }
  25020. // Shift rows, sub bytes, add round key
  25021. var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  25022. var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  25023. var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  25024. var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  25025. // Set output
  25026. M[offset] = t0;
  25027. M[offset + 1] = t1;
  25028. M[offset + 2] = t2;
  25029. M[offset + 3] = t3;
  25030. },
  25031. keySize: 256/32
  25032. });
  25033. /**
  25034. * Shortcut functions to the cipher's object interface.
  25035. *
  25036. * @example
  25037. *
  25038. * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  25039. * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  25040. */
  25041. C.AES = BlockCipher._createHelper(AES);
  25042. }());
  25043. return CryptoJS.AES;
  25044. }));
  25045. },{"./cipher-core":612,"./core":613,"./enc-base64":614,"./evpkdf":616,"./md5":618}],612:[function(_dereq_,module,exports){
  25046. ;(function (root, factory, undef) {
  25047. if (typeof exports === "object") {
  25048. // CommonJS
  25049. module.exports = exports = factory(_dereq_("./core"), _dereq_("./evpkdf"));
  25050. }
  25051. else if (typeof define === "function" && define.amd) {
  25052. // AMD
  25053. define(["./core", "./evpkdf"], factory);
  25054. }
  25055. else {
  25056. // Global (browser)
  25057. factory(root.CryptoJS);
  25058. }
  25059. }(this, function (CryptoJS) {
  25060. /**
  25061. * Cipher core components.
  25062. */
  25063. CryptoJS.lib.Cipher || (function (undefined) {
  25064. // Shortcuts
  25065. var C = CryptoJS;
  25066. var C_lib = C.lib;
  25067. var Base = C_lib.Base;
  25068. var WordArray = C_lib.WordArray;
  25069. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  25070. var C_enc = C.enc;
  25071. var Utf8 = C_enc.Utf8;
  25072. var Base64 = C_enc.Base64;
  25073. var C_algo = C.algo;
  25074. var EvpKDF = C_algo.EvpKDF;
  25075. /**
  25076. * Abstract base cipher template.
  25077. *
  25078. * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  25079. * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  25080. * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  25081. * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  25082. */
  25083. var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  25084. /**
  25085. * Configuration options.
  25086. *
  25087. * @property {WordArray} iv The IV to use for this operation.
  25088. */
  25089. cfg: Base.extend(),
  25090. /**
  25091. * Creates this cipher in encryption mode.
  25092. *
  25093. * @param {WordArray} key The key.
  25094. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25095. *
  25096. * @return {Cipher} A cipher instance.
  25097. *
  25098. * @static
  25099. *
  25100. * @example
  25101. *
  25102. * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  25103. */
  25104. createEncryptor: function (key, cfg) {
  25105. return this.create(this._ENC_XFORM_MODE, key, cfg);
  25106. },
  25107. /**
  25108. * Creates this cipher in decryption mode.
  25109. *
  25110. * @param {WordArray} key The key.
  25111. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25112. *
  25113. * @return {Cipher} A cipher instance.
  25114. *
  25115. * @static
  25116. *
  25117. * @example
  25118. *
  25119. * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  25120. */
  25121. createDecryptor: function (key, cfg) {
  25122. return this.create(this._DEC_XFORM_MODE, key, cfg);
  25123. },
  25124. /**
  25125. * Initializes a newly created cipher.
  25126. *
  25127. * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  25128. * @param {WordArray} key The key.
  25129. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25130. *
  25131. * @example
  25132. *
  25133. * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  25134. */
  25135. init: function (xformMode, key, cfg) {
  25136. // Apply config defaults
  25137. this.cfg = this.cfg.extend(cfg);
  25138. // Store transform mode and key
  25139. this._xformMode = xformMode;
  25140. this._key = key;
  25141. // Set initial values
  25142. this.reset();
  25143. },
  25144. /**
  25145. * Resets this cipher to its initial state.
  25146. *
  25147. * @example
  25148. *
  25149. * cipher.reset();
  25150. */
  25151. reset: function () {
  25152. // Reset data buffer
  25153. BufferedBlockAlgorithm.reset.call(this);
  25154. // Perform concrete-cipher logic
  25155. this._doReset();
  25156. },
  25157. /**
  25158. * Adds data to be encrypted or decrypted.
  25159. *
  25160. * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  25161. *
  25162. * @return {WordArray} The data after processing.
  25163. *
  25164. * @example
  25165. *
  25166. * var encrypted = cipher.process('data');
  25167. * var encrypted = cipher.process(wordArray);
  25168. */
  25169. process: function (dataUpdate) {
  25170. // Append
  25171. this._append(dataUpdate);
  25172. // Process available blocks
  25173. return this._process();
  25174. },
  25175. /**
  25176. * Finalizes the encryption or decryption process.
  25177. * Note that the finalize operation is effectively a destructive, read-once operation.
  25178. *
  25179. * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  25180. *
  25181. * @return {WordArray} The data after final processing.
  25182. *
  25183. * @example
  25184. *
  25185. * var encrypted = cipher.finalize();
  25186. * var encrypted = cipher.finalize('data');
  25187. * var encrypted = cipher.finalize(wordArray);
  25188. */
  25189. finalize: function (dataUpdate) {
  25190. // Final data update
  25191. if (dataUpdate) {
  25192. this._append(dataUpdate);
  25193. }
  25194. // Perform concrete-cipher logic
  25195. var finalProcessedData = this._doFinalize();
  25196. return finalProcessedData;
  25197. },
  25198. keySize: 128/32,
  25199. ivSize: 128/32,
  25200. _ENC_XFORM_MODE: 1,
  25201. _DEC_XFORM_MODE: 2,
  25202. /**
  25203. * Creates shortcut functions to a cipher's object interface.
  25204. *
  25205. * @param {Cipher} cipher The cipher to create a helper for.
  25206. *
  25207. * @return {Object} An object with encrypt and decrypt shortcut functions.
  25208. *
  25209. * @static
  25210. *
  25211. * @example
  25212. *
  25213. * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  25214. */
  25215. _createHelper: (function () {
  25216. function selectCipherStrategy(key) {
  25217. if (typeof key == 'string') {
  25218. return PasswordBasedCipher;
  25219. } else {
  25220. return SerializableCipher;
  25221. }
  25222. }
  25223. return function (cipher) {
  25224. return {
  25225. encrypt: function (message, key, cfg) {
  25226. return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  25227. },
  25228. decrypt: function (ciphertext, key, cfg) {
  25229. return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  25230. }
  25231. };
  25232. };
  25233. }())
  25234. });
  25235. /**
  25236. * Abstract base stream cipher template.
  25237. *
  25238. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  25239. */
  25240. var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  25241. _doFinalize: function () {
  25242. // Process partial blocks
  25243. var finalProcessedBlocks = this._process(!!'flush');
  25244. return finalProcessedBlocks;
  25245. },
  25246. blockSize: 1
  25247. });
  25248. /**
  25249. * Mode namespace.
  25250. */
  25251. var C_mode = C.mode = {};
  25252. /**
  25253. * Abstract base block cipher mode template.
  25254. */
  25255. var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  25256. /**
  25257. * Creates this mode for encryption.
  25258. *
  25259. * @param {Cipher} cipher A block cipher instance.
  25260. * @param {Array} iv The IV words.
  25261. *
  25262. * @static
  25263. *
  25264. * @example
  25265. *
  25266. * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  25267. */
  25268. createEncryptor: function (cipher, iv) {
  25269. return this.Encryptor.create(cipher, iv);
  25270. },
  25271. /**
  25272. * Creates this mode for decryption.
  25273. *
  25274. * @param {Cipher} cipher A block cipher instance.
  25275. * @param {Array} iv The IV words.
  25276. *
  25277. * @static
  25278. *
  25279. * @example
  25280. *
  25281. * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  25282. */
  25283. createDecryptor: function (cipher, iv) {
  25284. return this.Decryptor.create(cipher, iv);
  25285. },
  25286. /**
  25287. * Initializes a newly created mode.
  25288. *
  25289. * @param {Cipher} cipher A block cipher instance.
  25290. * @param {Array} iv The IV words.
  25291. *
  25292. * @example
  25293. *
  25294. * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  25295. */
  25296. init: function (cipher, iv) {
  25297. this._cipher = cipher;
  25298. this._iv = iv;
  25299. }
  25300. });
  25301. /**
  25302. * Cipher Block Chaining mode.
  25303. */
  25304. var CBC = C_mode.CBC = (function () {
  25305. /**
  25306. * Abstract base CBC mode.
  25307. */
  25308. var CBC = BlockCipherMode.extend();
  25309. /**
  25310. * CBC encryptor.
  25311. */
  25312. CBC.Encryptor = CBC.extend({
  25313. /**
  25314. * Processes the data block at offset.
  25315. *
  25316. * @param {Array} words The data words to operate on.
  25317. * @param {number} offset The offset where the block starts.
  25318. *
  25319. * @example
  25320. *
  25321. * mode.processBlock(data.words, offset);
  25322. */
  25323. processBlock: function (words, offset) {
  25324. // Shortcuts
  25325. var cipher = this._cipher;
  25326. var blockSize = cipher.blockSize;
  25327. // XOR and encrypt
  25328. xorBlock.call(this, words, offset, blockSize);
  25329. cipher.encryptBlock(words, offset);
  25330. // Remember this block to use with next block
  25331. this._prevBlock = words.slice(offset, offset + blockSize);
  25332. }
  25333. });
  25334. /**
  25335. * CBC decryptor.
  25336. */
  25337. CBC.Decryptor = CBC.extend({
  25338. /**
  25339. * Processes the data block at offset.
  25340. *
  25341. * @param {Array} words The data words to operate on.
  25342. * @param {number} offset The offset where the block starts.
  25343. *
  25344. * @example
  25345. *
  25346. * mode.processBlock(data.words, offset);
  25347. */
  25348. processBlock: function (words, offset) {
  25349. // Shortcuts
  25350. var cipher = this._cipher;
  25351. var blockSize = cipher.blockSize;
  25352. // Remember this block to use with next block
  25353. var thisBlock = words.slice(offset, offset + blockSize);
  25354. // Decrypt and XOR
  25355. cipher.decryptBlock(words, offset);
  25356. xorBlock.call(this, words, offset, blockSize);
  25357. // This block becomes the previous block
  25358. this._prevBlock = thisBlock;
  25359. }
  25360. });
  25361. function xorBlock(words, offset, blockSize) {
  25362. var block;
  25363. // Shortcut
  25364. var iv = this._iv;
  25365. // Choose mixing block
  25366. if (iv) {
  25367. block = iv;
  25368. // Remove IV for subsequent blocks
  25369. this._iv = undefined;
  25370. } else {
  25371. block = this._prevBlock;
  25372. }
  25373. // XOR blocks
  25374. for (var i = 0; i < blockSize; i++) {
  25375. words[offset + i] ^= block[i];
  25376. }
  25377. }
  25378. return CBC;
  25379. }());
  25380. /**
  25381. * Padding namespace.
  25382. */
  25383. var C_pad = C.pad = {};
  25384. /**
  25385. * PKCS #5/7 padding strategy.
  25386. */
  25387. var Pkcs7 = C_pad.Pkcs7 = {
  25388. /**
  25389. * Pads data using the algorithm defined in PKCS #5/7.
  25390. *
  25391. * @param {WordArray} data The data to pad.
  25392. * @param {number} blockSize The multiple that the data should be padded to.
  25393. *
  25394. * @static
  25395. *
  25396. * @example
  25397. *
  25398. * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  25399. */
  25400. pad: function (data, blockSize) {
  25401. // Shortcut
  25402. var blockSizeBytes = blockSize * 4;
  25403. // Count padding bytes
  25404. var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  25405. // Create padding word
  25406. var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  25407. // Create padding
  25408. var paddingWords = [];
  25409. for (var i = 0; i < nPaddingBytes; i += 4) {
  25410. paddingWords.push(paddingWord);
  25411. }
  25412. var padding = WordArray.create(paddingWords, nPaddingBytes);
  25413. // Add padding
  25414. data.concat(padding);
  25415. },
  25416. /**
  25417. * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  25418. *
  25419. * @param {WordArray} data The data to unpad.
  25420. *
  25421. * @static
  25422. *
  25423. * @example
  25424. *
  25425. * CryptoJS.pad.Pkcs7.unpad(wordArray);
  25426. */
  25427. unpad: function (data) {
  25428. // Get number of padding bytes from last byte
  25429. var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  25430. // Remove padding
  25431. data.sigBytes -= nPaddingBytes;
  25432. }
  25433. };
  25434. /**
  25435. * Abstract base block cipher template.
  25436. *
  25437. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  25438. */
  25439. var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  25440. /**
  25441. * Configuration options.
  25442. *
  25443. * @property {Mode} mode The block mode to use. Default: CBC
  25444. * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  25445. */
  25446. cfg: Cipher.cfg.extend({
  25447. mode: CBC,
  25448. padding: Pkcs7
  25449. }),
  25450. reset: function () {
  25451. var modeCreator;
  25452. // Reset cipher
  25453. Cipher.reset.call(this);
  25454. // Shortcuts
  25455. var cfg = this.cfg;
  25456. var iv = cfg.iv;
  25457. var mode = cfg.mode;
  25458. // Reset block mode
  25459. if (this._xformMode == this._ENC_XFORM_MODE) {
  25460. modeCreator = mode.createEncryptor;
  25461. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  25462. modeCreator = mode.createDecryptor;
  25463. // Keep at least one block in the buffer for unpadding
  25464. this._minBufferSize = 1;
  25465. }
  25466. if (this._mode && this._mode.__creator == modeCreator) {
  25467. this._mode.init(this, iv && iv.words);
  25468. } else {
  25469. this._mode = modeCreator.call(mode, this, iv && iv.words);
  25470. this._mode.__creator = modeCreator;
  25471. }
  25472. },
  25473. _doProcessBlock: function (words, offset) {
  25474. this._mode.processBlock(words, offset);
  25475. },
  25476. _doFinalize: function () {
  25477. var finalProcessedBlocks;
  25478. // Shortcut
  25479. var padding = this.cfg.padding;
  25480. // Finalize
  25481. if (this._xformMode == this._ENC_XFORM_MODE) {
  25482. // Pad data
  25483. padding.pad(this._data, this.blockSize);
  25484. // Process final blocks
  25485. finalProcessedBlocks = this._process(!!'flush');
  25486. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  25487. // Process final blocks
  25488. finalProcessedBlocks = this._process(!!'flush');
  25489. // Unpad data
  25490. padding.unpad(finalProcessedBlocks);
  25491. }
  25492. return finalProcessedBlocks;
  25493. },
  25494. blockSize: 128/32
  25495. });
  25496. /**
  25497. * A collection of cipher parameters.
  25498. *
  25499. * @property {WordArray} ciphertext The raw ciphertext.
  25500. * @property {WordArray} key The key to this ciphertext.
  25501. * @property {WordArray} iv The IV used in the ciphering operation.
  25502. * @property {WordArray} salt The salt used with a key derivation function.
  25503. * @property {Cipher} algorithm The cipher algorithm.
  25504. * @property {Mode} mode The block mode used in the ciphering operation.
  25505. * @property {Padding} padding The padding scheme used in the ciphering operation.
  25506. * @property {number} blockSize The block size of the cipher.
  25507. * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  25508. */
  25509. var CipherParams = C_lib.CipherParams = Base.extend({
  25510. /**
  25511. * Initializes a newly created cipher params object.
  25512. *
  25513. * @param {Object} cipherParams An object with any of the possible cipher parameters.
  25514. *
  25515. * @example
  25516. *
  25517. * var cipherParams = CryptoJS.lib.CipherParams.create({
  25518. * ciphertext: ciphertextWordArray,
  25519. * key: keyWordArray,
  25520. * iv: ivWordArray,
  25521. * salt: saltWordArray,
  25522. * algorithm: CryptoJS.algo.AES,
  25523. * mode: CryptoJS.mode.CBC,
  25524. * padding: CryptoJS.pad.PKCS7,
  25525. * blockSize: 4,
  25526. * formatter: CryptoJS.format.OpenSSL
  25527. * });
  25528. */
  25529. init: function (cipherParams) {
  25530. this.mixIn(cipherParams);
  25531. },
  25532. /**
  25533. * Converts this cipher params object to a string.
  25534. *
  25535. * @param {Format} formatter (Optional) The formatting strategy to use.
  25536. *
  25537. * @return {string} The stringified cipher params.
  25538. *
  25539. * @throws Error If neither the formatter nor the default formatter is set.
  25540. *
  25541. * @example
  25542. *
  25543. * var string = cipherParams + '';
  25544. * var string = cipherParams.toString();
  25545. * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  25546. */
  25547. toString: function (formatter) {
  25548. return (formatter || this.formatter).stringify(this);
  25549. }
  25550. });
  25551. /**
  25552. * Format namespace.
  25553. */
  25554. var C_format = C.format = {};
  25555. /**
  25556. * OpenSSL formatting strategy.
  25557. */
  25558. var OpenSSLFormatter = C_format.OpenSSL = {
  25559. /**
  25560. * Converts a cipher params object to an OpenSSL-compatible string.
  25561. *
  25562. * @param {CipherParams} cipherParams The cipher params object.
  25563. *
  25564. * @return {string} The OpenSSL-compatible string.
  25565. *
  25566. * @static
  25567. *
  25568. * @example
  25569. *
  25570. * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  25571. */
  25572. stringify: function (cipherParams) {
  25573. var wordArray;
  25574. // Shortcuts
  25575. var ciphertext = cipherParams.ciphertext;
  25576. var salt = cipherParams.salt;
  25577. // Format
  25578. if (salt) {
  25579. wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  25580. } else {
  25581. wordArray = ciphertext;
  25582. }
  25583. return wordArray.toString(Base64);
  25584. },
  25585. /**
  25586. * Converts an OpenSSL-compatible string to a cipher params object.
  25587. *
  25588. * @param {string} openSSLStr The OpenSSL-compatible string.
  25589. *
  25590. * @return {CipherParams} The cipher params object.
  25591. *
  25592. * @static
  25593. *
  25594. * @example
  25595. *
  25596. * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  25597. */
  25598. parse: function (openSSLStr) {
  25599. var salt;
  25600. // Parse base64
  25601. var ciphertext = Base64.parse(openSSLStr);
  25602. // Shortcut
  25603. var ciphertextWords = ciphertext.words;
  25604. // Test for salt
  25605. if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  25606. // Extract salt
  25607. salt = WordArray.create(ciphertextWords.slice(2, 4));
  25608. // Remove salt from ciphertext
  25609. ciphertextWords.splice(0, 4);
  25610. ciphertext.sigBytes -= 16;
  25611. }
  25612. return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  25613. }
  25614. };
  25615. /**
  25616. * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  25617. */
  25618. var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  25619. /**
  25620. * Configuration options.
  25621. *
  25622. * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  25623. */
  25624. cfg: Base.extend({
  25625. format: OpenSSLFormatter
  25626. }),
  25627. /**
  25628. * Encrypts a message.
  25629. *
  25630. * @param {Cipher} cipher The cipher algorithm to use.
  25631. * @param {WordArray|string} message The message to encrypt.
  25632. * @param {WordArray} key The key.
  25633. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25634. *
  25635. * @return {CipherParams} A cipher params object.
  25636. *
  25637. * @static
  25638. *
  25639. * @example
  25640. *
  25641. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  25642. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  25643. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  25644. */
  25645. encrypt: function (cipher, message, key, cfg) {
  25646. // Apply config defaults
  25647. cfg = this.cfg.extend(cfg);
  25648. // Encrypt
  25649. var encryptor = cipher.createEncryptor(key, cfg);
  25650. var ciphertext = encryptor.finalize(message);
  25651. // Shortcut
  25652. var cipherCfg = encryptor.cfg;
  25653. // Create and return serializable cipher params
  25654. return CipherParams.create({
  25655. ciphertext: ciphertext,
  25656. key: key,
  25657. iv: cipherCfg.iv,
  25658. algorithm: cipher,
  25659. mode: cipherCfg.mode,
  25660. padding: cipherCfg.padding,
  25661. blockSize: cipher.blockSize,
  25662. formatter: cfg.format
  25663. });
  25664. },
  25665. /**
  25666. * Decrypts serialized ciphertext.
  25667. *
  25668. * @param {Cipher} cipher The cipher algorithm to use.
  25669. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  25670. * @param {WordArray} key The key.
  25671. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25672. *
  25673. * @return {WordArray} The plaintext.
  25674. *
  25675. * @static
  25676. *
  25677. * @example
  25678. *
  25679. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  25680. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  25681. */
  25682. decrypt: function (cipher, ciphertext, key, cfg) {
  25683. // Apply config defaults
  25684. cfg = this.cfg.extend(cfg);
  25685. // Convert string to CipherParams
  25686. ciphertext = this._parse(ciphertext, cfg.format);
  25687. // Decrypt
  25688. var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  25689. return plaintext;
  25690. },
  25691. /**
  25692. * Converts serialized ciphertext to CipherParams,
  25693. * else assumed CipherParams already and returns ciphertext unchanged.
  25694. *
  25695. * @param {CipherParams|string} ciphertext The ciphertext.
  25696. * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  25697. *
  25698. * @return {CipherParams} The unserialized ciphertext.
  25699. *
  25700. * @static
  25701. *
  25702. * @example
  25703. *
  25704. * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  25705. */
  25706. _parse: function (ciphertext, format) {
  25707. if (typeof ciphertext == 'string') {
  25708. return format.parse(ciphertext, this);
  25709. } else {
  25710. return ciphertext;
  25711. }
  25712. }
  25713. });
  25714. /**
  25715. * Key derivation function namespace.
  25716. */
  25717. var C_kdf = C.kdf = {};
  25718. /**
  25719. * OpenSSL key derivation function.
  25720. */
  25721. var OpenSSLKdf = C_kdf.OpenSSL = {
  25722. /**
  25723. * Derives a key and IV from a password.
  25724. *
  25725. * @param {string} password The password to derive from.
  25726. * @param {number} keySize The size in words of the key to generate.
  25727. * @param {number} ivSize The size in words of the IV to generate.
  25728. * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  25729. *
  25730. * @return {CipherParams} A cipher params object with the key, IV, and salt.
  25731. *
  25732. * @static
  25733. *
  25734. * @example
  25735. *
  25736. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  25737. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  25738. */
  25739. execute: function (password, keySize, ivSize, salt) {
  25740. // Generate random salt
  25741. if (!salt) {
  25742. salt = WordArray.random(64/8);
  25743. }
  25744. // Derive key and IV
  25745. var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  25746. // Separate key and IV
  25747. var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  25748. key.sigBytes = keySize * 4;
  25749. // Return params
  25750. return CipherParams.create({ key: key, iv: iv, salt: salt });
  25751. }
  25752. };
  25753. /**
  25754. * A serializable cipher wrapper that derives the key from a password,
  25755. * and returns ciphertext as a serializable cipher params object.
  25756. */
  25757. var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  25758. /**
  25759. * Configuration options.
  25760. *
  25761. * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  25762. */
  25763. cfg: SerializableCipher.cfg.extend({
  25764. kdf: OpenSSLKdf
  25765. }),
  25766. /**
  25767. * Encrypts a message using a password.
  25768. *
  25769. * @param {Cipher} cipher The cipher algorithm to use.
  25770. * @param {WordArray|string} message The message to encrypt.
  25771. * @param {string} password The password.
  25772. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25773. *
  25774. * @return {CipherParams} A cipher params object.
  25775. *
  25776. * @static
  25777. *
  25778. * @example
  25779. *
  25780. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  25781. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  25782. */
  25783. encrypt: function (cipher, message, password, cfg) {
  25784. // Apply config defaults
  25785. cfg = this.cfg.extend(cfg);
  25786. // Derive key and other params
  25787. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  25788. // Add IV to config
  25789. cfg.iv = derivedParams.iv;
  25790. // Encrypt
  25791. var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  25792. // Mix in derived params
  25793. ciphertext.mixIn(derivedParams);
  25794. return ciphertext;
  25795. },
  25796. /**
  25797. * Decrypts serialized ciphertext using a password.
  25798. *
  25799. * @param {Cipher} cipher The cipher algorithm to use.
  25800. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  25801. * @param {string} password The password.
  25802. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25803. *
  25804. * @return {WordArray} The plaintext.
  25805. *
  25806. * @static
  25807. *
  25808. * @example
  25809. *
  25810. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  25811. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  25812. */
  25813. decrypt: function (cipher, ciphertext, password, cfg) {
  25814. // Apply config defaults
  25815. cfg = this.cfg.extend(cfg);
  25816. // Convert string to CipherParams
  25817. ciphertext = this._parse(ciphertext, cfg.format);
  25818. // Derive key and other params
  25819. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  25820. // Add IV to config
  25821. cfg.iv = derivedParams.iv;
  25822. // Decrypt
  25823. var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  25824. return plaintext;
  25825. }
  25826. });
  25827. }());
  25828. }));
  25829. },{"./core":613,"./evpkdf":616}],613:[function(_dereq_,module,exports){
  25830. (function (global){(function (){
  25831. ;(function (root, factory) {
  25832. if (typeof exports === "object") {
  25833. // CommonJS
  25834. module.exports = exports = factory();
  25835. }
  25836. else if (typeof define === "function" && define.amd) {
  25837. // AMD
  25838. define([], factory);
  25839. }
  25840. else {
  25841. // Global (browser)
  25842. root.CryptoJS = factory();
  25843. }
  25844. }(this, function () {
  25845. /*globals window, global, require*/
  25846. /**
  25847. * CryptoJS core components.
  25848. */
  25849. var CryptoJS = CryptoJS || (function (Math, undefined) {
  25850. var crypto;
  25851. // Native crypto from window (Browser)
  25852. if (typeof window !== 'undefined' && window.crypto) {
  25853. crypto = window.crypto;
  25854. }
  25855. // Native crypto in web worker (Browser)
  25856. if (typeof self !== 'undefined' && self.crypto) {
  25857. crypto = self.crypto;
  25858. }
  25859. // Native crypto from worker
  25860. if (typeof globalThis !== 'undefined' && globalThis.crypto) {
  25861. crypto = globalThis.crypto;
  25862. }
  25863. // Native (experimental IE 11) crypto from window (Browser)
  25864. if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
  25865. crypto = window.msCrypto;
  25866. }
  25867. // Native crypto from global (NodeJS)
  25868. if (!crypto && typeof global !== 'undefined' && global.crypto) {
  25869. crypto = global.crypto;
  25870. }
  25871. // Native crypto import via require (NodeJS)
  25872. if (!crypto && typeof _dereq_ === 'function') {
  25873. try {
  25874. crypto = _dereq_('crypto');
  25875. } catch (err) {}
  25876. }
  25877. /*
  25878. * Cryptographically secure pseudorandom number generator
  25879. *
  25880. * As Math.random() is cryptographically not safe to use
  25881. */
  25882. var cryptoSecureRandomInt = function () {
  25883. if (crypto) {
  25884. // Use getRandomValues method (Browser)
  25885. if (typeof crypto.getRandomValues === 'function') {
  25886. try {
  25887. return crypto.getRandomValues(new Uint32Array(1))[0];
  25888. } catch (err) {}
  25889. }
  25890. // Use randomBytes method (NodeJS)
  25891. if (typeof crypto.randomBytes === 'function') {
  25892. try {
  25893. return crypto.randomBytes(4).readInt32LE();
  25894. } catch (err) {}
  25895. }
  25896. }
  25897. throw new Error('Native crypto module could not be used to get secure random number.');
  25898. };
  25899. /*
  25900. * Local polyfill of Object.create
  25901. */
  25902. var create = Object.create || (function () {
  25903. function F() {}
  25904. return function (obj) {
  25905. var subtype;
  25906. F.prototype = obj;
  25907. subtype = new F();
  25908. F.prototype = null;
  25909. return subtype;
  25910. };
  25911. }());
  25912. /**
  25913. * CryptoJS namespace.
  25914. */
  25915. var C = {};
  25916. /**
  25917. * Library namespace.
  25918. */
  25919. var C_lib = C.lib = {};
  25920. /**
  25921. * Base object for prototypal inheritance.
  25922. */
  25923. var Base = C_lib.Base = (function () {
  25924. return {
  25925. /**
  25926. * Creates a new object that inherits from this object.
  25927. *
  25928. * @param {Object} overrides Properties to copy into the new object.
  25929. *
  25930. * @return {Object} The new object.
  25931. *
  25932. * @static
  25933. *
  25934. * @example
  25935. *
  25936. * var MyType = CryptoJS.lib.Base.extend({
  25937. * field: 'value',
  25938. *
  25939. * method: function () {
  25940. * }
  25941. * });
  25942. */
  25943. extend: function (overrides) {
  25944. // Spawn
  25945. var subtype = create(this);
  25946. // Augment
  25947. if (overrides) {
  25948. subtype.mixIn(overrides);
  25949. }
  25950. // Create default initializer
  25951. if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  25952. subtype.init = function () {
  25953. subtype.$super.init.apply(this, arguments);
  25954. };
  25955. }
  25956. // Initializer's prototype is the subtype object
  25957. subtype.init.prototype = subtype;
  25958. // Reference supertype
  25959. subtype.$super = this;
  25960. return subtype;
  25961. },
  25962. /**
  25963. * Extends this object and runs the init method.
  25964. * Arguments to create() will be passed to init().
  25965. *
  25966. * @return {Object} The new object.
  25967. *
  25968. * @static
  25969. *
  25970. * @example
  25971. *
  25972. * var instance = MyType.create();
  25973. */
  25974. create: function () {
  25975. var instance = this.extend();
  25976. instance.init.apply(instance, arguments);
  25977. return instance;
  25978. },
  25979. /**
  25980. * Initializes a newly created object.
  25981. * Override this method to add some logic when your objects are created.
  25982. *
  25983. * @example
  25984. *
  25985. * var MyType = CryptoJS.lib.Base.extend({
  25986. * init: function () {
  25987. * // ...
  25988. * }
  25989. * });
  25990. */
  25991. init: function () {
  25992. },
  25993. /**
  25994. * Copies properties into this object.
  25995. *
  25996. * @param {Object} properties The properties to mix in.
  25997. *
  25998. * @example
  25999. *
  26000. * MyType.mixIn({
  26001. * field: 'value'
  26002. * });
  26003. */
  26004. mixIn: function (properties) {
  26005. for (var propertyName in properties) {
  26006. if (properties.hasOwnProperty(propertyName)) {
  26007. this[propertyName] = properties[propertyName];
  26008. }
  26009. }
  26010. // IE won't copy toString using the loop above
  26011. if (properties.hasOwnProperty('toString')) {
  26012. this.toString = properties.toString;
  26013. }
  26014. },
  26015. /**
  26016. * Creates a copy of this object.
  26017. *
  26018. * @return {Object} The clone.
  26019. *
  26020. * @example
  26021. *
  26022. * var clone = instance.clone();
  26023. */
  26024. clone: function () {
  26025. return this.init.prototype.extend(this);
  26026. }
  26027. };
  26028. }());
  26029. /**
  26030. * An array of 32-bit words.
  26031. *
  26032. * @property {Array} words The array of 32-bit words.
  26033. * @property {number} sigBytes The number of significant bytes in this word array.
  26034. */
  26035. var WordArray = C_lib.WordArray = Base.extend({
  26036. /**
  26037. * Initializes a newly created word array.
  26038. *
  26039. * @param {Array} words (Optional) An array of 32-bit words.
  26040. * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  26041. *
  26042. * @example
  26043. *
  26044. * var wordArray = CryptoJS.lib.WordArray.create();
  26045. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  26046. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  26047. */
  26048. init: function (words, sigBytes) {
  26049. words = this.words = words || [];
  26050. if (sigBytes != undefined) {
  26051. this.sigBytes = sigBytes;
  26052. } else {
  26053. this.sigBytes = words.length * 4;
  26054. }
  26055. },
  26056. /**
  26057. * Converts this word array to a string.
  26058. *
  26059. * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  26060. *
  26061. * @return {string} The stringified word array.
  26062. *
  26063. * @example
  26064. *
  26065. * var string = wordArray + '';
  26066. * var string = wordArray.toString();
  26067. * var string = wordArray.toString(CryptoJS.enc.Utf8);
  26068. */
  26069. toString: function (encoder) {
  26070. return (encoder || Hex).stringify(this);
  26071. },
  26072. /**
  26073. * Concatenates a word array to this word array.
  26074. *
  26075. * @param {WordArray} wordArray The word array to append.
  26076. *
  26077. * @return {WordArray} This word array.
  26078. *
  26079. * @example
  26080. *
  26081. * wordArray1.concat(wordArray2);
  26082. */
  26083. concat: function (wordArray) {
  26084. // Shortcuts
  26085. var thisWords = this.words;
  26086. var thatWords = wordArray.words;
  26087. var thisSigBytes = this.sigBytes;
  26088. var thatSigBytes = wordArray.sigBytes;
  26089. // Clamp excess bits
  26090. this.clamp();
  26091. // Concat
  26092. if (thisSigBytes % 4) {
  26093. // Copy one byte at a time
  26094. for (var i = 0; i < thatSigBytes; i++) {
  26095. var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  26096. thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  26097. }
  26098. } else {
  26099. // Copy one word at a time
  26100. for (var j = 0; j < thatSigBytes; j += 4) {
  26101. thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
  26102. }
  26103. }
  26104. this.sigBytes += thatSigBytes;
  26105. // Chainable
  26106. return this;
  26107. },
  26108. /**
  26109. * Removes insignificant bits.
  26110. *
  26111. * @example
  26112. *
  26113. * wordArray.clamp();
  26114. */
  26115. clamp: function () {
  26116. // Shortcuts
  26117. var words = this.words;
  26118. var sigBytes = this.sigBytes;
  26119. // Clamp
  26120. words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  26121. words.length = Math.ceil(sigBytes / 4);
  26122. },
  26123. /**
  26124. * Creates a copy of this word array.
  26125. *
  26126. * @return {WordArray} The clone.
  26127. *
  26128. * @example
  26129. *
  26130. * var clone = wordArray.clone();
  26131. */
  26132. clone: function () {
  26133. var clone = Base.clone.call(this);
  26134. clone.words = this.words.slice(0);
  26135. return clone;
  26136. },
  26137. /**
  26138. * Creates a word array filled with random bytes.
  26139. *
  26140. * @param {number} nBytes The number of random bytes to generate.
  26141. *
  26142. * @return {WordArray} The random word array.
  26143. *
  26144. * @static
  26145. *
  26146. * @example
  26147. *
  26148. * var wordArray = CryptoJS.lib.WordArray.random(16);
  26149. */
  26150. random: function (nBytes) {
  26151. var words = [];
  26152. for (var i = 0; i < nBytes; i += 4) {
  26153. words.push(cryptoSecureRandomInt());
  26154. }
  26155. return new WordArray.init(words, nBytes);
  26156. }
  26157. });
  26158. /**
  26159. * Encoder namespace.
  26160. */
  26161. var C_enc = C.enc = {};
  26162. /**
  26163. * Hex encoding strategy.
  26164. */
  26165. var Hex = C_enc.Hex = {
  26166. /**
  26167. * Converts a word array to a hex string.
  26168. *
  26169. * @param {WordArray} wordArray The word array.
  26170. *
  26171. * @return {string} The hex string.
  26172. *
  26173. * @static
  26174. *
  26175. * @example
  26176. *
  26177. * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  26178. */
  26179. stringify: function (wordArray) {
  26180. // Shortcuts
  26181. var words = wordArray.words;
  26182. var sigBytes = wordArray.sigBytes;
  26183. // Convert
  26184. var hexChars = [];
  26185. for (var i = 0; i < sigBytes; i++) {
  26186. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  26187. hexChars.push((bite >>> 4).toString(16));
  26188. hexChars.push((bite & 0x0f).toString(16));
  26189. }
  26190. return hexChars.join('');
  26191. },
  26192. /**
  26193. * Converts a hex string to a word array.
  26194. *
  26195. * @param {string} hexStr The hex string.
  26196. *
  26197. * @return {WordArray} The word array.
  26198. *
  26199. * @static
  26200. *
  26201. * @example
  26202. *
  26203. * var wordArray = CryptoJS.enc.Hex.parse(hexString);
  26204. */
  26205. parse: function (hexStr) {
  26206. // Shortcut
  26207. var hexStrLength = hexStr.length;
  26208. // Convert
  26209. var words = [];
  26210. for (var i = 0; i < hexStrLength; i += 2) {
  26211. words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  26212. }
  26213. return new WordArray.init(words, hexStrLength / 2);
  26214. }
  26215. };
  26216. /**
  26217. * Latin1 encoding strategy.
  26218. */
  26219. var Latin1 = C_enc.Latin1 = {
  26220. /**
  26221. * Converts a word array to a Latin1 string.
  26222. *
  26223. * @param {WordArray} wordArray The word array.
  26224. *
  26225. * @return {string} The Latin1 string.
  26226. *
  26227. * @static
  26228. *
  26229. * @example
  26230. *
  26231. * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  26232. */
  26233. stringify: function (wordArray) {
  26234. // Shortcuts
  26235. var words = wordArray.words;
  26236. var sigBytes = wordArray.sigBytes;
  26237. // Convert
  26238. var latin1Chars = [];
  26239. for (var i = 0; i < sigBytes; i++) {
  26240. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  26241. latin1Chars.push(String.fromCharCode(bite));
  26242. }
  26243. return latin1Chars.join('');
  26244. },
  26245. /**
  26246. * Converts a Latin1 string to a word array.
  26247. *
  26248. * @param {string} latin1Str The Latin1 string.
  26249. *
  26250. * @return {WordArray} The word array.
  26251. *
  26252. * @static
  26253. *
  26254. * @example
  26255. *
  26256. * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  26257. */
  26258. parse: function (latin1Str) {
  26259. // Shortcut
  26260. var latin1StrLength = latin1Str.length;
  26261. // Convert
  26262. var words = [];
  26263. for (var i = 0; i < latin1StrLength; i++) {
  26264. words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  26265. }
  26266. return new WordArray.init(words, latin1StrLength);
  26267. }
  26268. };
  26269. /**
  26270. * UTF-8 encoding strategy.
  26271. */
  26272. var Utf8 = C_enc.Utf8 = {
  26273. /**
  26274. * Converts a word array to a UTF-8 string.
  26275. *
  26276. * @param {WordArray} wordArray The word array.
  26277. *
  26278. * @return {string} The UTF-8 string.
  26279. *
  26280. * @static
  26281. *
  26282. * @example
  26283. *
  26284. * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  26285. */
  26286. stringify: function (wordArray) {
  26287. try {
  26288. return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  26289. } catch (e) {
  26290. throw new Error('Malformed UTF-8 data');
  26291. }
  26292. },
  26293. /**
  26294. * Converts a UTF-8 string to a word array.
  26295. *
  26296. * @param {string} utf8Str The UTF-8 string.
  26297. *
  26298. * @return {WordArray} The word array.
  26299. *
  26300. * @static
  26301. *
  26302. * @example
  26303. *
  26304. * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  26305. */
  26306. parse: function (utf8Str) {
  26307. return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  26308. }
  26309. };
  26310. /**
  26311. * Abstract buffered block algorithm template.
  26312. *
  26313. * The property blockSize must be implemented in a concrete subtype.
  26314. *
  26315. * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  26316. */
  26317. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  26318. /**
  26319. * Resets this block algorithm's data buffer to its initial state.
  26320. *
  26321. * @example
  26322. *
  26323. * bufferedBlockAlgorithm.reset();
  26324. */
  26325. reset: function () {
  26326. // Initial values
  26327. this._data = new WordArray.init();
  26328. this._nDataBytes = 0;
  26329. },
  26330. /**
  26331. * Adds new data to this block algorithm's buffer.
  26332. *
  26333. * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  26334. *
  26335. * @example
  26336. *
  26337. * bufferedBlockAlgorithm._append('data');
  26338. * bufferedBlockAlgorithm._append(wordArray);
  26339. */
  26340. _append: function (data) {
  26341. // Convert string to WordArray, else assume WordArray already
  26342. if (typeof data == 'string') {
  26343. data = Utf8.parse(data);
  26344. }
  26345. // Append
  26346. this._data.concat(data);
  26347. this._nDataBytes += data.sigBytes;
  26348. },
  26349. /**
  26350. * Processes available data blocks.
  26351. *
  26352. * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  26353. *
  26354. * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  26355. *
  26356. * @return {WordArray} The processed data.
  26357. *
  26358. * @example
  26359. *
  26360. * var processedData = bufferedBlockAlgorithm._process();
  26361. * var processedData = bufferedBlockAlgorithm._process(!!'flush');
  26362. */
  26363. _process: function (doFlush) {
  26364. var processedWords;
  26365. // Shortcuts
  26366. var data = this._data;
  26367. var dataWords = data.words;
  26368. var dataSigBytes = data.sigBytes;
  26369. var blockSize = this.blockSize;
  26370. var blockSizeBytes = blockSize * 4;
  26371. // Count blocks ready
  26372. var nBlocksReady = dataSigBytes / blockSizeBytes;
  26373. if (doFlush) {
  26374. // Round up to include partial blocks
  26375. nBlocksReady = Math.ceil(nBlocksReady);
  26376. } else {
  26377. // Round down to include only full blocks,
  26378. // less the number of blocks that must remain in the buffer
  26379. nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  26380. }
  26381. // Count words ready
  26382. var nWordsReady = nBlocksReady * blockSize;
  26383. // Count bytes ready
  26384. var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  26385. // Process blocks
  26386. if (nWordsReady) {
  26387. for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  26388. // Perform concrete-algorithm logic
  26389. this._doProcessBlock(dataWords, offset);
  26390. }
  26391. // Remove processed words
  26392. processedWords = dataWords.splice(0, nWordsReady);
  26393. data.sigBytes -= nBytesReady;
  26394. }
  26395. // Return processed words
  26396. return new WordArray.init(processedWords, nBytesReady);
  26397. },
  26398. /**
  26399. * Creates a copy of this object.
  26400. *
  26401. * @return {Object} The clone.
  26402. *
  26403. * @example
  26404. *
  26405. * var clone = bufferedBlockAlgorithm.clone();
  26406. */
  26407. clone: function () {
  26408. var clone = Base.clone.call(this);
  26409. clone._data = this._data.clone();
  26410. return clone;
  26411. },
  26412. _minBufferSize: 0
  26413. });
  26414. /**
  26415. * Abstract hasher template.
  26416. *
  26417. * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  26418. */
  26419. var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  26420. /**
  26421. * Configuration options.
  26422. */
  26423. cfg: Base.extend(),
  26424. /**
  26425. * Initializes a newly created hasher.
  26426. *
  26427. * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  26428. *
  26429. * @example
  26430. *
  26431. * var hasher = CryptoJS.algo.SHA256.create();
  26432. */
  26433. init: function (cfg) {
  26434. // Apply config defaults
  26435. this.cfg = this.cfg.extend(cfg);
  26436. // Set initial values
  26437. this.reset();
  26438. },
  26439. /**
  26440. * Resets this hasher to its initial state.
  26441. *
  26442. * @example
  26443. *
  26444. * hasher.reset();
  26445. */
  26446. reset: function () {
  26447. // Reset data buffer
  26448. BufferedBlockAlgorithm.reset.call(this);
  26449. // Perform concrete-hasher logic
  26450. this._doReset();
  26451. },
  26452. /**
  26453. * Updates this hasher with a message.
  26454. *
  26455. * @param {WordArray|string} messageUpdate The message to append.
  26456. *
  26457. * @return {Hasher} This hasher.
  26458. *
  26459. * @example
  26460. *
  26461. * hasher.update('message');
  26462. * hasher.update(wordArray);
  26463. */
  26464. update: function (messageUpdate) {
  26465. // Append
  26466. this._append(messageUpdate);
  26467. // Update the hash
  26468. this._process();
  26469. // Chainable
  26470. return this;
  26471. },
  26472. /**
  26473. * Finalizes the hash computation.
  26474. * Note that the finalize operation is effectively a destructive, read-once operation.
  26475. *
  26476. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  26477. *
  26478. * @return {WordArray} The hash.
  26479. *
  26480. * @example
  26481. *
  26482. * var hash = hasher.finalize();
  26483. * var hash = hasher.finalize('message');
  26484. * var hash = hasher.finalize(wordArray);
  26485. */
  26486. finalize: function (messageUpdate) {
  26487. // Final message update
  26488. if (messageUpdate) {
  26489. this._append(messageUpdate);
  26490. }
  26491. // Perform concrete-hasher logic
  26492. var hash = this._doFinalize();
  26493. return hash;
  26494. },
  26495. blockSize: 512/32,
  26496. /**
  26497. * Creates a shortcut function to a hasher's object interface.
  26498. *
  26499. * @param {Hasher} hasher The hasher to create a helper for.
  26500. *
  26501. * @return {Function} The shortcut function.
  26502. *
  26503. * @static
  26504. *
  26505. * @example
  26506. *
  26507. * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  26508. */
  26509. _createHelper: function (hasher) {
  26510. return function (message, cfg) {
  26511. return new hasher.init(cfg).finalize(message);
  26512. };
  26513. },
  26514. /**
  26515. * Creates a shortcut function to the HMAC's object interface.
  26516. *
  26517. * @param {Hasher} hasher The hasher to use in this HMAC helper.
  26518. *
  26519. * @return {Function} The shortcut function.
  26520. *
  26521. * @static
  26522. *
  26523. * @example
  26524. *
  26525. * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  26526. */
  26527. _createHmacHelper: function (hasher) {
  26528. return function (message, key) {
  26529. return new C_algo.HMAC.init(hasher, key).finalize(message);
  26530. };
  26531. }
  26532. });
  26533. /**
  26534. * Algorithm namespace.
  26535. */
  26536. var C_algo = C.algo = {};
  26537. return C;
  26538. }(Math));
  26539. return CryptoJS;
  26540. }));
  26541. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  26542. },{"crypto":undefined}],614:[function(_dereq_,module,exports){
  26543. ;(function (root, factory) {
  26544. if (typeof exports === "object") {
  26545. // CommonJS
  26546. module.exports = exports = factory(_dereq_("./core"));
  26547. }
  26548. else if (typeof define === "function" && define.amd) {
  26549. // AMD
  26550. define(["./core"], factory);
  26551. }
  26552. else {
  26553. // Global (browser)
  26554. factory(root.CryptoJS);
  26555. }
  26556. }(this, function (CryptoJS) {
  26557. (function () {
  26558. // Shortcuts
  26559. var C = CryptoJS;
  26560. var C_lib = C.lib;
  26561. var WordArray = C_lib.WordArray;
  26562. var C_enc = C.enc;
  26563. /**
  26564. * Base64 encoding strategy.
  26565. */
  26566. var Base64 = C_enc.Base64 = {
  26567. /**
  26568. * Converts a word array to a Base64 string.
  26569. *
  26570. * @param {WordArray} wordArray The word array.
  26571. *
  26572. * @return {string} The Base64 string.
  26573. *
  26574. * @static
  26575. *
  26576. * @example
  26577. *
  26578. * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  26579. */
  26580. stringify: function (wordArray) {
  26581. // Shortcuts
  26582. var words = wordArray.words;
  26583. var sigBytes = wordArray.sigBytes;
  26584. var map = this._map;
  26585. // Clamp excess bits
  26586. wordArray.clamp();
  26587. // Convert
  26588. var base64Chars = [];
  26589. for (var i = 0; i < sigBytes; i += 3) {
  26590. var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  26591. var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  26592. var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  26593. var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  26594. for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  26595. base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  26596. }
  26597. }
  26598. // Add padding
  26599. var paddingChar = map.charAt(64);
  26600. if (paddingChar) {
  26601. while (base64Chars.length % 4) {
  26602. base64Chars.push(paddingChar);
  26603. }
  26604. }
  26605. return base64Chars.join('');
  26606. },
  26607. /**
  26608. * Converts a Base64 string to a word array.
  26609. *
  26610. * @param {string} base64Str The Base64 string.
  26611. *
  26612. * @return {WordArray} The word array.
  26613. *
  26614. * @static
  26615. *
  26616. * @example
  26617. *
  26618. * var wordArray = CryptoJS.enc.Base64.parse(base64String);
  26619. */
  26620. parse: function (base64Str) {
  26621. // Shortcuts
  26622. var base64StrLength = base64Str.length;
  26623. var map = this._map;
  26624. var reverseMap = this._reverseMap;
  26625. if (!reverseMap) {
  26626. reverseMap = this._reverseMap = [];
  26627. for (var j = 0; j < map.length; j++) {
  26628. reverseMap[map.charCodeAt(j)] = j;
  26629. }
  26630. }
  26631. // Ignore padding
  26632. var paddingChar = map.charAt(64);
  26633. if (paddingChar) {
  26634. var paddingIndex = base64Str.indexOf(paddingChar);
  26635. if (paddingIndex !== -1) {
  26636. base64StrLength = paddingIndex;
  26637. }
  26638. }
  26639. // Convert
  26640. return parseLoop(base64Str, base64StrLength, reverseMap);
  26641. },
  26642. _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  26643. };
  26644. function parseLoop(base64Str, base64StrLength, reverseMap) {
  26645. var words = [];
  26646. var nBytes = 0;
  26647. for (var i = 0; i < base64StrLength; i++) {
  26648. if (i % 4) {
  26649. var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  26650. var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  26651. var bitsCombined = bits1 | bits2;
  26652. words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
  26653. nBytes++;
  26654. }
  26655. }
  26656. return WordArray.create(words, nBytes);
  26657. }
  26658. }());
  26659. return CryptoJS.enc.Base64;
  26660. }));
  26661. },{"./core":613}],615:[function(_dereq_,module,exports){
  26662. ;(function (root, factory) {
  26663. if (typeof exports === "object") {
  26664. // CommonJS
  26665. module.exports = exports = factory(_dereq_("./core"));
  26666. }
  26667. else if (typeof define === "function" && define.amd) {
  26668. // AMD
  26669. define(["./core"], factory);
  26670. }
  26671. else {
  26672. // Global (browser)
  26673. factory(root.CryptoJS);
  26674. }
  26675. }(this, function (CryptoJS) {
  26676. return CryptoJS.enc.Utf8;
  26677. }));
  26678. },{"./core":613}],616:[function(_dereq_,module,exports){
  26679. ;(function (root, factory, undef) {
  26680. if (typeof exports === "object") {
  26681. // CommonJS
  26682. module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
  26683. }
  26684. else if (typeof define === "function" && define.amd) {
  26685. // AMD
  26686. define(["./core", "./sha1", "./hmac"], factory);
  26687. }
  26688. else {
  26689. // Global (browser)
  26690. factory(root.CryptoJS);
  26691. }
  26692. }(this, function (CryptoJS) {
  26693. (function () {
  26694. // Shortcuts
  26695. var C = CryptoJS;
  26696. var C_lib = C.lib;
  26697. var Base = C_lib.Base;
  26698. var WordArray = C_lib.WordArray;
  26699. var C_algo = C.algo;
  26700. var MD5 = C_algo.MD5;
  26701. /**
  26702. * This key derivation function is meant to conform with EVP_BytesToKey.
  26703. * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  26704. */
  26705. var EvpKDF = C_algo.EvpKDF = Base.extend({
  26706. /**
  26707. * Configuration options.
  26708. *
  26709. * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  26710. * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  26711. * @property {number} iterations The number of iterations to perform. Default: 1
  26712. */
  26713. cfg: Base.extend({
  26714. keySize: 128/32,
  26715. hasher: MD5,
  26716. iterations: 1
  26717. }),
  26718. /**
  26719. * Initializes a newly created key derivation function.
  26720. *
  26721. * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  26722. *
  26723. * @example
  26724. *
  26725. * var kdf = CryptoJS.algo.EvpKDF.create();
  26726. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  26727. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  26728. */
  26729. init: function (cfg) {
  26730. this.cfg = this.cfg.extend(cfg);
  26731. },
  26732. /**
  26733. * Derives a key from a password.
  26734. *
  26735. * @param {WordArray|string} password The password.
  26736. * @param {WordArray|string} salt A salt.
  26737. *
  26738. * @return {WordArray} The derived key.
  26739. *
  26740. * @example
  26741. *
  26742. * var key = kdf.compute(password, salt);
  26743. */
  26744. compute: function (password, salt) {
  26745. var block;
  26746. // Shortcut
  26747. var cfg = this.cfg;
  26748. // Init hasher
  26749. var hasher = cfg.hasher.create();
  26750. // Initial values
  26751. var derivedKey = WordArray.create();
  26752. // Shortcuts
  26753. var derivedKeyWords = derivedKey.words;
  26754. var keySize = cfg.keySize;
  26755. var iterations = cfg.iterations;
  26756. // Generate key
  26757. while (derivedKeyWords.length < keySize) {
  26758. if (block) {
  26759. hasher.update(block);
  26760. }
  26761. block = hasher.update(password).finalize(salt);
  26762. hasher.reset();
  26763. // Iterations
  26764. for (var i = 1; i < iterations; i++) {
  26765. block = hasher.finalize(block);
  26766. hasher.reset();
  26767. }
  26768. derivedKey.concat(block);
  26769. }
  26770. derivedKey.sigBytes = keySize * 4;
  26771. return derivedKey;
  26772. }
  26773. });
  26774. /**
  26775. * Derives a key from a password.
  26776. *
  26777. * @param {WordArray|string} password The password.
  26778. * @param {WordArray|string} salt A salt.
  26779. * @param {Object} cfg (Optional) The configuration options to use for this computation.
  26780. *
  26781. * @return {WordArray} The derived key.
  26782. *
  26783. * @static
  26784. *
  26785. * @example
  26786. *
  26787. * var key = CryptoJS.EvpKDF(password, salt);
  26788. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  26789. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  26790. */
  26791. C.EvpKDF = function (password, salt, cfg) {
  26792. return EvpKDF.create(cfg).compute(password, salt);
  26793. };
  26794. }());
  26795. return CryptoJS.EvpKDF;
  26796. }));
  26797. },{"./core":613,"./hmac":617,"./sha1":619}],617:[function(_dereq_,module,exports){
  26798. ;(function (root, factory) {
  26799. if (typeof exports === "object") {
  26800. // CommonJS
  26801. module.exports = exports = factory(_dereq_("./core"));
  26802. }
  26803. else if (typeof define === "function" && define.amd) {
  26804. // AMD
  26805. define(["./core"], factory);
  26806. }
  26807. else {
  26808. // Global (browser)
  26809. factory(root.CryptoJS);
  26810. }
  26811. }(this, function (CryptoJS) {
  26812. (function () {
  26813. // Shortcuts
  26814. var C = CryptoJS;
  26815. var C_lib = C.lib;
  26816. var Base = C_lib.Base;
  26817. var C_enc = C.enc;
  26818. var Utf8 = C_enc.Utf8;
  26819. var C_algo = C.algo;
  26820. /**
  26821. * HMAC algorithm.
  26822. */
  26823. var HMAC = C_algo.HMAC = Base.extend({
  26824. /**
  26825. * Initializes a newly created HMAC.
  26826. *
  26827. * @param {Hasher} hasher The hash algorithm to use.
  26828. * @param {WordArray|string} key The secret key.
  26829. *
  26830. * @example
  26831. *
  26832. * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  26833. */
  26834. init: function (hasher, key) {
  26835. // Init hasher
  26836. hasher = this._hasher = new hasher.init();
  26837. // Convert string to WordArray, else assume WordArray already
  26838. if (typeof key == 'string') {
  26839. key = Utf8.parse(key);
  26840. }
  26841. // Shortcuts
  26842. var hasherBlockSize = hasher.blockSize;
  26843. var hasherBlockSizeBytes = hasherBlockSize * 4;
  26844. // Allow arbitrary length keys
  26845. if (key.sigBytes > hasherBlockSizeBytes) {
  26846. key = hasher.finalize(key);
  26847. }
  26848. // Clamp excess bits
  26849. key.clamp();
  26850. // Clone key for inner and outer pads
  26851. var oKey = this._oKey = key.clone();
  26852. var iKey = this._iKey = key.clone();
  26853. // Shortcuts
  26854. var oKeyWords = oKey.words;
  26855. var iKeyWords = iKey.words;
  26856. // XOR keys with pad constants
  26857. for (var i = 0; i < hasherBlockSize; i++) {
  26858. oKeyWords[i] ^= 0x5c5c5c5c;
  26859. iKeyWords[i] ^= 0x36363636;
  26860. }
  26861. oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  26862. // Set initial values
  26863. this.reset();
  26864. },
  26865. /**
  26866. * Resets this HMAC to its initial state.
  26867. *
  26868. * @example
  26869. *
  26870. * hmacHasher.reset();
  26871. */
  26872. reset: function () {
  26873. // Shortcut
  26874. var hasher = this._hasher;
  26875. // Reset
  26876. hasher.reset();
  26877. hasher.update(this._iKey);
  26878. },
  26879. /**
  26880. * Updates this HMAC with a message.
  26881. *
  26882. * @param {WordArray|string} messageUpdate The message to append.
  26883. *
  26884. * @return {HMAC} This HMAC instance.
  26885. *
  26886. * @example
  26887. *
  26888. * hmacHasher.update('message');
  26889. * hmacHasher.update(wordArray);
  26890. */
  26891. update: function (messageUpdate) {
  26892. this._hasher.update(messageUpdate);
  26893. // Chainable
  26894. return this;
  26895. },
  26896. /**
  26897. * Finalizes the HMAC computation.
  26898. * Note that the finalize operation is effectively a destructive, read-once operation.
  26899. *
  26900. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  26901. *
  26902. * @return {WordArray} The HMAC.
  26903. *
  26904. * @example
  26905. *
  26906. * var hmac = hmacHasher.finalize();
  26907. * var hmac = hmacHasher.finalize('message');
  26908. * var hmac = hmacHasher.finalize(wordArray);
  26909. */
  26910. finalize: function (messageUpdate) {
  26911. // Shortcut
  26912. var hasher = this._hasher;
  26913. // Compute HMAC
  26914. var innerHash = hasher.finalize(messageUpdate);
  26915. hasher.reset();
  26916. var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  26917. return hmac;
  26918. }
  26919. });
  26920. }());
  26921. }));
  26922. },{"./core":613}],618:[function(_dereq_,module,exports){
  26923. ;(function (root, factory) {
  26924. if (typeof exports === "object") {
  26925. // CommonJS
  26926. module.exports = exports = factory(_dereq_("./core"));
  26927. }
  26928. else if (typeof define === "function" && define.amd) {
  26929. // AMD
  26930. define(["./core"], factory);
  26931. }
  26932. else {
  26933. // Global (browser)
  26934. factory(root.CryptoJS);
  26935. }
  26936. }(this, function (CryptoJS) {
  26937. (function (Math) {
  26938. // Shortcuts
  26939. var C = CryptoJS;
  26940. var C_lib = C.lib;
  26941. var WordArray = C_lib.WordArray;
  26942. var Hasher = C_lib.Hasher;
  26943. var C_algo = C.algo;
  26944. // Constants table
  26945. var T = [];
  26946. // Compute constants
  26947. (function () {
  26948. for (var i = 0; i < 64; i++) {
  26949. T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  26950. }
  26951. }());
  26952. /**
  26953. * MD5 hash algorithm.
  26954. */
  26955. var MD5 = C_algo.MD5 = Hasher.extend({
  26956. _doReset: function () {
  26957. this._hash = new WordArray.init([
  26958. 0x67452301, 0xefcdab89,
  26959. 0x98badcfe, 0x10325476
  26960. ]);
  26961. },
  26962. _doProcessBlock: function (M, offset) {
  26963. // Swap endian
  26964. for (var i = 0; i < 16; i++) {
  26965. // Shortcuts
  26966. var offset_i = offset + i;
  26967. var M_offset_i = M[offset_i];
  26968. M[offset_i] = (
  26969. (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  26970. (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  26971. );
  26972. }
  26973. // Shortcuts
  26974. var H = this._hash.words;
  26975. var M_offset_0 = M[offset + 0];
  26976. var M_offset_1 = M[offset + 1];
  26977. var M_offset_2 = M[offset + 2];
  26978. var M_offset_3 = M[offset + 3];
  26979. var M_offset_4 = M[offset + 4];
  26980. var M_offset_5 = M[offset + 5];
  26981. var M_offset_6 = M[offset + 6];
  26982. var M_offset_7 = M[offset + 7];
  26983. var M_offset_8 = M[offset + 8];
  26984. var M_offset_9 = M[offset + 9];
  26985. var M_offset_10 = M[offset + 10];
  26986. var M_offset_11 = M[offset + 11];
  26987. var M_offset_12 = M[offset + 12];
  26988. var M_offset_13 = M[offset + 13];
  26989. var M_offset_14 = M[offset + 14];
  26990. var M_offset_15 = M[offset + 15];
  26991. // Working varialbes
  26992. var a = H[0];
  26993. var b = H[1];
  26994. var c = H[2];
  26995. var d = H[3];
  26996. // Computation
  26997. a = FF(a, b, c, d, M_offset_0, 7, T[0]);
  26998. d = FF(d, a, b, c, M_offset_1, 12, T[1]);
  26999. c = FF(c, d, a, b, M_offset_2, 17, T[2]);
  27000. b = FF(b, c, d, a, M_offset_3, 22, T[3]);
  27001. a = FF(a, b, c, d, M_offset_4, 7, T[4]);
  27002. d = FF(d, a, b, c, M_offset_5, 12, T[5]);
  27003. c = FF(c, d, a, b, M_offset_6, 17, T[6]);
  27004. b = FF(b, c, d, a, M_offset_7, 22, T[7]);
  27005. a = FF(a, b, c, d, M_offset_8, 7, T[8]);
  27006. d = FF(d, a, b, c, M_offset_9, 12, T[9]);
  27007. c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  27008. b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  27009. a = FF(a, b, c, d, M_offset_12, 7, T[12]);
  27010. d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  27011. c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  27012. b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  27013. a = GG(a, b, c, d, M_offset_1, 5, T[16]);
  27014. d = GG(d, a, b, c, M_offset_6, 9, T[17]);
  27015. c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  27016. b = GG(b, c, d, a, M_offset_0, 20, T[19]);
  27017. a = GG(a, b, c, d, M_offset_5, 5, T[20]);
  27018. d = GG(d, a, b, c, M_offset_10, 9, T[21]);
  27019. c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  27020. b = GG(b, c, d, a, M_offset_4, 20, T[23]);
  27021. a = GG(a, b, c, d, M_offset_9, 5, T[24]);
  27022. d = GG(d, a, b, c, M_offset_14, 9, T[25]);
  27023. c = GG(c, d, a, b, M_offset_3, 14, T[26]);
  27024. b = GG(b, c, d, a, M_offset_8, 20, T[27]);
  27025. a = GG(a, b, c, d, M_offset_13, 5, T[28]);
  27026. d = GG(d, a, b, c, M_offset_2, 9, T[29]);
  27027. c = GG(c, d, a, b, M_offset_7, 14, T[30]);
  27028. b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  27029. a = HH(a, b, c, d, M_offset_5, 4, T[32]);
  27030. d = HH(d, a, b, c, M_offset_8, 11, T[33]);
  27031. c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  27032. b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  27033. a = HH(a, b, c, d, M_offset_1, 4, T[36]);
  27034. d = HH(d, a, b, c, M_offset_4, 11, T[37]);
  27035. c = HH(c, d, a, b, M_offset_7, 16, T[38]);
  27036. b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  27037. a = HH(a, b, c, d, M_offset_13, 4, T[40]);
  27038. d = HH(d, a, b, c, M_offset_0, 11, T[41]);
  27039. c = HH(c, d, a, b, M_offset_3, 16, T[42]);
  27040. b = HH(b, c, d, a, M_offset_6, 23, T[43]);
  27041. a = HH(a, b, c, d, M_offset_9, 4, T[44]);
  27042. d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  27043. c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  27044. b = HH(b, c, d, a, M_offset_2, 23, T[47]);
  27045. a = II(a, b, c, d, M_offset_0, 6, T[48]);
  27046. d = II(d, a, b, c, M_offset_7, 10, T[49]);
  27047. c = II(c, d, a, b, M_offset_14, 15, T[50]);
  27048. b = II(b, c, d, a, M_offset_5, 21, T[51]);
  27049. a = II(a, b, c, d, M_offset_12, 6, T[52]);
  27050. d = II(d, a, b, c, M_offset_3, 10, T[53]);
  27051. c = II(c, d, a, b, M_offset_10, 15, T[54]);
  27052. b = II(b, c, d, a, M_offset_1, 21, T[55]);
  27053. a = II(a, b, c, d, M_offset_8, 6, T[56]);
  27054. d = II(d, a, b, c, M_offset_15, 10, T[57]);
  27055. c = II(c, d, a, b, M_offset_6, 15, T[58]);
  27056. b = II(b, c, d, a, M_offset_13, 21, T[59]);
  27057. a = II(a, b, c, d, M_offset_4, 6, T[60]);
  27058. d = II(d, a, b, c, M_offset_11, 10, T[61]);
  27059. c = II(c, d, a, b, M_offset_2, 15, T[62]);
  27060. b = II(b, c, d, a, M_offset_9, 21, T[63]);
  27061. // Intermediate hash value
  27062. H[0] = (H[0] + a) | 0;
  27063. H[1] = (H[1] + b) | 0;
  27064. H[2] = (H[2] + c) | 0;
  27065. H[3] = (H[3] + d) | 0;
  27066. },
  27067. _doFinalize: function () {
  27068. // Shortcuts
  27069. var data = this._data;
  27070. var dataWords = data.words;
  27071. var nBitsTotal = this._nDataBytes * 8;
  27072. var nBitsLeft = data.sigBytes * 8;
  27073. // Add padding
  27074. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  27075. var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  27076. var nBitsTotalL = nBitsTotal;
  27077. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  27078. (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  27079. (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
  27080. );
  27081. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  27082. (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  27083. (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
  27084. );
  27085. data.sigBytes = (dataWords.length + 1) * 4;
  27086. // Hash final blocks
  27087. this._process();
  27088. // Shortcuts
  27089. var hash = this._hash;
  27090. var H = hash.words;
  27091. // Swap endian
  27092. for (var i = 0; i < 4; i++) {
  27093. // Shortcut
  27094. var H_i = H[i];
  27095. H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  27096. (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
  27097. }
  27098. // Return final computed hash
  27099. return hash;
  27100. },
  27101. clone: function () {
  27102. var clone = Hasher.clone.call(this);
  27103. clone._hash = this._hash.clone();
  27104. return clone;
  27105. }
  27106. });
  27107. function FF(a, b, c, d, x, s, t) {
  27108. var n = a + ((b & c) | (~b & d)) + x + t;
  27109. return ((n << s) | (n >>> (32 - s))) + b;
  27110. }
  27111. function GG(a, b, c, d, x, s, t) {
  27112. var n = a + ((b & d) | (c & ~d)) + x + t;
  27113. return ((n << s) | (n >>> (32 - s))) + b;
  27114. }
  27115. function HH(a, b, c, d, x, s, t) {
  27116. var n = a + (b ^ c ^ d) + x + t;
  27117. return ((n << s) | (n >>> (32 - s))) + b;
  27118. }
  27119. function II(a, b, c, d, x, s, t) {
  27120. var n = a + (c ^ (b | ~d)) + x + t;
  27121. return ((n << s) | (n >>> (32 - s))) + b;
  27122. }
  27123. /**
  27124. * Shortcut function to the hasher's object interface.
  27125. *
  27126. * @param {WordArray|string} message The message to hash.
  27127. *
  27128. * @return {WordArray} The hash.
  27129. *
  27130. * @static
  27131. *
  27132. * @example
  27133. *
  27134. * var hash = CryptoJS.MD5('message');
  27135. * var hash = CryptoJS.MD5(wordArray);
  27136. */
  27137. C.MD5 = Hasher._createHelper(MD5);
  27138. /**
  27139. * Shortcut function to the HMAC's object interface.
  27140. *
  27141. * @param {WordArray|string} message The message to hash.
  27142. * @param {WordArray|string} key The secret key.
  27143. *
  27144. * @return {WordArray} The HMAC.
  27145. *
  27146. * @static
  27147. *
  27148. * @example
  27149. *
  27150. * var hmac = CryptoJS.HmacMD5(message, key);
  27151. */
  27152. C.HmacMD5 = Hasher._createHmacHelper(MD5);
  27153. }(Math));
  27154. return CryptoJS.MD5;
  27155. }));
  27156. },{"./core":613}],619:[function(_dereq_,module,exports){
  27157. ;(function (root, factory) {
  27158. if (typeof exports === "object") {
  27159. // CommonJS
  27160. module.exports = exports = factory(_dereq_("./core"));
  27161. }
  27162. else if (typeof define === "function" && define.amd) {
  27163. // AMD
  27164. define(["./core"], factory);
  27165. }
  27166. else {
  27167. // Global (browser)
  27168. factory(root.CryptoJS);
  27169. }
  27170. }(this, function (CryptoJS) {
  27171. (function () {
  27172. // Shortcuts
  27173. var C = CryptoJS;
  27174. var C_lib = C.lib;
  27175. var WordArray = C_lib.WordArray;
  27176. var Hasher = C_lib.Hasher;
  27177. var C_algo = C.algo;
  27178. // Reusable object
  27179. var W = [];
  27180. /**
  27181. * SHA-1 hash algorithm.
  27182. */
  27183. var SHA1 = C_algo.SHA1 = Hasher.extend({
  27184. _doReset: function () {
  27185. this._hash = new WordArray.init([
  27186. 0x67452301, 0xefcdab89,
  27187. 0x98badcfe, 0x10325476,
  27188. 0xc3d2e1f0
  27189. ]);
  27190. },
  27191. _doProcessBlock: function (M, offset) {
  27192. // Shortcut
  27193. var H = this._hash.words;
  27194. // Working variables
  27195. var a = H[0];
  27196. var b = H[1];
  27197. var c = H[2];
  27198. var d = H[3];
  27199. var e = H[4];
  27200. // Computation
  27201. for (var i = 0; i < 80; i++) {
  27202. if (i < 16) {
  27203. W[i] = M[offset + i] | 0;
  27204. } else {
  27205. var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
  27206. W[i] = (n << 1) | (n >>> 31);
  27207. }
  27208. var t = ((a << 5) | (a >>> 27)) + e + W[i];
  27209. if (i < 20) {
  27210. t += ((b & c) | (~b & d)) + 0x5a827999;
  27211. } else if (i < 40) {
  27212. t += (b ^ c ^ d) + 0x6ed9eba1;
  27213. } else if (i < 60) {
  27214. t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
  27215. } else /* if (i < 80) */ {
  27216. t += (b ^ c ^ d) - 0x359d3e2a;
  27217. }
  27218. e = d;
  27219. d = c;
  27220. c = (b << 30) | (b >>> 2);
  27221. b = a;
  27222. a = t;
  27223. }
  27224. // Intermediate hash value
  27225. H[0] = (H[0] + a) | 0;
  27226. H[1] = (H[1] + b) | 0;
  27227. H[2] = (H[2] + c) | 0;
  27228. H[3] = (H[3] + d) | 0;
  27229. H[4] = (H[4] + e) | 0;
  27230. },
  27231. _doFinalize: function () {
  27232. // Shortcuts
  27233. var data = this._data;
  27234. var dataWords = data.words;
  27235. var nBitsTotal = this._nDataBytes * 8;
  27236. var nBitsLeft = data.sigBytes * 8;
  27237. // Add padding
  27238. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  27239. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  27240. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  27241. data.sigBytes = dataWords.length * 4;
  27242. // Hash final blocks
  27243. this._process();
  27244. // Return final computed hash
  27245. return this._hash;
  27246. },
  27247. clone: function () {
  27248. var clone = Hasher.clone.call(this);
  27249. clone._hash = this._hash.clone();
  27250. return clone;
  27251. }
  27252. });
  27253. /**
  27254. * Shortcut function to the hasher's object interface.
  27255. *
  27256. * @param {WordArray|string} message The message to hash.
  27257. *
  27258. * @return {WordArray} The hash.
  27259. *
  27260. * @static
  27261. *
  27262. * @example
  27263. *
  27264. * var hash = CryptoJS.SHA1('message');
  27265. * var hash = CryptoJS.SHA1(wordArray);
  27266. */
  27267. C.SHA1 = Hasher._createHelper(SHA1);
  27268. /**
  27269. * Shortcut function to the HMAC's object interface.
  27270. *
  27271. * @param {WordArray|string} message The message to hash.
  27272. * @param {WordArray|string} key The secret key.
  27273. *
  27274. * @return {WordArray} The HMAC.
  27275. *
  27276. * @static
  27277. *
  27278. * @example
  27279. *
  27280. * var hmac = CryptoJS.HmacSHA1(message, key);
  27281. */
  27282. C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
  27283. }());
  27284. return CryptoJS.SHA1;
  27285. }));
  27286. },{"./core":613}],620:[function(_dereq_,module,exports){
  27287. // Copyright Joyent, Inc. and other Node contributors.
  27288. //
  27289. // Permission is hereby granted, free of charge, to any person obtaining a
  27290. // copy of this software and associated documentation files (the
  27291. // "Software"), to deal in the Software without restriction, including
  27292. // without limitation the rights to use, copy, modify, merge, publish,
  27293. // distribute, sublicense, and/or sell copies of the Software, and to permit
  27294. // persons to whom the Software is furnished to do so, subject to the
  27295. // following conditions:
  27296. //
  27297. // The above copyright notice and this permission notice shall be included
  27298. // in all copies or substantial portions of the Software.
  27299. //
  27300. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  27301. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27302. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  27303. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  27304. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  27305. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  27306. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  27307. 'use strict';
  27308. var R = typeof Reflect === 'object' ? Reflect : null
  27309. var ReflectApply = R && typeof R.apply === 'function'
  27310. ? R.apply
  27311. : function ReflectApply(target, receiver, args) {
  27312. return Function.prototype.apply.call(target, receiver, args);
  27313. }
  27314. var ReflectOwnKeys
  27315. if (R && typeof R.ownKeys === 'function') {
  27316. ReflectOwnKeys = R.ownKeys
  27317. } else if (Object.getOwnPropertySymbols) {
  27318. ReflectOwnKeys = function ReflectOwnKeys(target) {
  27319. return Object.getOwnPropertyNames(target)
  27320. .concat(Object.getOwnPropertySymbols(target));
  27321. };
  27322. } else {
  27323. ReflectOwnKeys = function ReflectOwnKeys(target) {
  27324. return Object.getOwnPropertyNames(target);
  27325. };
  27326. }
  27327. function ProcessEmitWarning(warning) {
  27328. if (console && console.warn) console.warn(warning);
  27329. }
  27330. var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
  27331. return value !== value;
  27332. }
  27333. function EventEmitter() {
  27334. EventEmitter.init.call(this);
  27335. }
  27336. module.exports = EventEmitter;
  27337. module.exports.once = once;
  27338. // Backwards-compat with node 0.10.x
  27339. EventEmitter.EventEmitter = EventEmitter;
  27340. EventEmitter.prototype._events = undefined;
  27341. EventEmitter.prototype._eventsCount = 0;
  27342. EventEmitter.prototype._maxListeners = undefined;
  27343. // By default EventEmitters will print a warning if more than 10 listeners are
  27344. // added to it. This is a useful default which helps finding memory leaks.
  27345. var defaultMaxListeners = 10;
  27346. function checkListener(listener) {
  27347. if (typeof listener !== 'function') {
  27348. throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
  27349. }
  27350. }
  27351. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  27352. enumerable: true,
  27353. get: function() {
  27354. return defaultMaxListeners;
  27355. },
  27356. set: function(arg) {
  27357. if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
  27358. throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
  27359. }
  27360. defaultMaxListeners = arg;
  27361. }
  27362. });
  27363. EventEmitter.init = function() {
  27364. if (this._events === undefined ||
  27365. this._events === Object.getPrototypeOf(this)._events) {
  27366. this._events = Object.create(null);
  27367. this._eventsCount = 0;
  27368. }
  27369. this._maxListeners = this._maxListeners || undefined;
  27370. };
  27371. // Obviously not all Emitters should be limited to 10. This function allows
  27372. // that to be increased. Set to zero for unlimited.
  27373. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  27374. if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
  27375. throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
  27376. }
  27377. this._maxListeners = n;
  27378. return this;
  27379. };
  27380. function _getMaxListeners(that) {
  27381. if (that._maxListeners === undefined)
  27382. return EventEmitter.defaultMaxListeners;
  27383. return that._maxListeners;
  27384. }
  27385. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  27386. return _getMaxListeners(this);
  27387. };
  27388. EventEmitter.prototype.emit = function emit(type) {
  27389. var args = [];
  27390. for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
  27391. var doError = (type === 'error');
  27392. var events = this._events;
  27393. if (events !== undefined)
  27394. doError = (doError && events.error === undefined);
  27395. else if (!doError)
  27396. return false;
  27397. // If there is no 'error' event listener then throw.
  27398. if (doError) {
  27399. var er;
  27400. if (args.length > 0)
  27401. er = args[0];
  27402. if (er instanceof Error) {
  27403. // Note: The comments on the `throw` lines are intentional, they show
  27404. // up in Node's output if this results in an unhandled exception.
  27405. throw er; // Unhandled 'error' event
  27406. }
  27407. // At least give some kind of context to the user
  27408. var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
  27409. err.context = er;
  27410. throw err; // Unhandled 'error' event
  27411. }
  27412. var handler = events[type];
  27413. if (handler === undefined)
  27414. return false;
  27415. if (typeof handler === 'function') {
  27416. ReflectApply(handler, this, args);
  27417. } else {
  27418. var len = handler.length;
  27419. var listeners = arrayClone(handler, len);
  27420. for (var i = 0; i < len; ++i)
  27421. ReflectApply(listeners[i], this, args);
  27422. }
  27423. return true;
  27424. };
  27425. function _addListener(target, type, listener, prepend) {
  27426. var m;
  27427. var events;
  27428. var existing;
  27429. checkListener(listener);
  27430. events = target._events;
  27431. if (events === undefined) {
  27432. events = target._events = Object.create(null);
  27433. target._eventsCount = 0;
  27434. } else {
  27435. // To avoid recursion in the case that type === "newListener"! Before
  27436. // adding it to the listeners, first emit "newListener".
  27437. if (events.newListener !== undefined) {
  27438. target.emit('newListener', type,
  27439. listener.listener ? listener.listener : listener);
  27440. // Re-assign `events` because a newListener handler could have caused the
  27441. // this._events to be assigned to a new object
  27442. events = target._events;
  27443. }
  27444. existing = events[type];
  27445. }
  27446. if (existing === undefined) {
  27447. // Optimize the case of one listener. Don't need the extra array object.
  27448. existing = events[type] = listener;
  27449. ++target._eventsCount;
  27450. } else {
  27451. if (typeof existing === 'function') {
  27452. // Adding the second element, need to change to array.
  27453. existing = events[type] =
  27454. prepend ? [listener, existing] : [existing, listener];
  27455. // If we've already got an array, just append.
  27456. } else if (prepend) {
  27457. existing.unshift(listener);
  27458. } else {
  27459. existing.push(listener);
  27460. }
  27461. // Check for listener leak
  27462. m = _getMaxListeners(target);
  27463. if (m > 0 && existing.length > m && !existing.warned) {
  27464. existing.warned = true;
  27465. // No error code for this since it is a Warning
  27466. // eslint-disable-next-line no-restricted-syntax
  27467. var w = new Error('Possible EventEmitter memory leak detected. ' +
  27468. existing.length + ' ' + String(type) + ' listeners ' +
  27469. 'added. Use emitter.setMaxListeners() to ' +
  27470. 'increase limit');
  27471. w.name = 'MaxListenersExceededWarning';
  27472. w.emitter = target;
  27473. w.type = type;
  27474. w.count = existing.length;
  27475. ProcessEmitWarning(w);
  27476. }
  27477. }
  27478. return target;
  27479. }
  27480. EventEmitter.prototype.addListener = function addListener(type, listener) {
  27481. return _addListener(this, type, listener, false);
  27482. };
  27483. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  27484. EventEmitter.prototype.prependListener =
  27485. function prependListener(type, listener) {
  27486. return _addListener(this, type, listener, true);
  27487. };
  27488. function onceWrapper() {
  27489. if (!this.fired) {
  27490. this.target.removeListener(this.type, this.wrapFn);
  27491. this.fired = true;
  27492. if (arguments.length === 0)
  27493. return this.listener.call(this.target);
  27494. return this.listener.apply(this.target, arguments);
  27495. }
  27496. }
  27497. function _onceWrap(target, type, listener) {
  27498. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  27499. var wrapped = onceWrapper.bind(state);
  27500. wrapped.listener = listener;
  27501. state.wrapFn = wrapped;
  27502. return wrapped;
  27503. }
  27504. EventEmitter.prototype.once = function once(type, listener) {
  27505. checkListener(listener);
  27506. this.on(type, _onceWrap(this, type, listener));
  27507. return this;
  27508. };
  27509. EventEmitter.prototype.prependOnceListener =
  27510. function prependOnceListener(type, listener) {
  27511. checkListener(listener);
  27512. this.prependListener(type, _onceWrap(this, type, listener));
  27513. return this;
  27514. };
  27515. // Emits a 'removeListener' event if and only if the listener was removed.
  27516. EventEmitter.prototype.removeListener =
  27517. function removeListener(type, listener) {
  27518. var list, events, position, i, originalListener;
  27519. checkListener(listener);
  27520. events = this._events;
  27521. if (events === undefined)
  27522. return this;
  27523. list = events[type];
  27524. if (list === undefined)
  27525. return this;
  27526. if (list === listener || list.listener === listener) {
  27527. if (--this._eventsCount === 0)
  27528. this._events = Object.create(null);
  27529. else {
  27530. delete events[type];
  27531. if (events.removeListener)
  27532. this.emit('removeListener', type, list.listener || listener);
  27533. }
  27534. } else if (typeof list !== 'function') {
  27535. position = -1;
  27536. for (i = list.length - 1; i >= 0; i--) {
  27537. if (list[i] === listener || list[i].listener === listener) {
  27538. originalListener = list[i].listener;
  27539. position = i;
  27540. break;
  27541. }
  27542. }
  27543. if (position < 0)
  27544. return this;
  27545. if (position === 0)
  27546. list.shift();
  27547. else {
  27548. spliceOne(list, position);
  27549. }
  27550. if (list.length === 1)
  27551. events[type] = list[0];
  27552. if (events.removeListener !== undefined)
  27553. this.emit('removeListener', type, originalListener || listener);
  27554. }
  27555. return this;
  27556. };
  27557. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  27558. EventEmitter.prototype.removeAllListeners =
  27559. function removeAllListeners(type) {
  27560. var listeners, events, i;
  27561. events = this._events;
  27562. if (events === undefined)
  27563. return this;
  27564. // not listening for removeListener, no need to emit
  27565. if (events.removeListener === undefined) {
  27566. if (arguments.length === 0) {
  27567. this._events = Object.create(null);
  27568. this._eventsCount = 0;
  27569. } else if (events[type] !== undefined) {
  27570. if (--this._eventsCount === 0)
  27571. this._events = Object.create(null);
  27572. else
  27573. delete events[type];
  27574. }
  27575. return this;
  27576. }
  27577. // emit removeListener for all listeners on all events
  27578. if (arguments.length === 0) {
  27579. var keys = Object.keys(events);
  27580. var key;
  27581. for (i = 0; i < keys.length; ++i) {
  27582. key = keys[i];
  27583. if (key === 'removeListener') continue;
  27584. this.removeAllListeners(key);
  27585. }
  27586. this.removeAllListeners('removeListener');
  27587. this._events = Object.create(null);
  27588. this._eventsCount = 0;
  27589. return this;
  27590. }
  27591. listeners = events[type];
  27592. if (typeof listeners === 'function') {
  27593. this.removeListener(type, listeners);
  27594. } else if (listeners !== undefined) {
  27595. // LIFO order
  27596. for (i = listeners.length - 1; i >= 0; i--) {
  27597. this.removeListener(type, listeners[i]);
  27598. }
  27599. }
  27600. return this;
  27601. };
  27602. function _listeners(target, type, unwrap) {
  27603. var events = target._events;
  27604. if (events === undefined)
  27605. return [];
  27606. var evlistener = events[type];
  27607. if (evlistener === undefined)
  27608. return [];
  27609. if (typeof evlistener === 'function')
  27610. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  27611. return unwrap ?
  27612. unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  27613. }
  27614. EventEmitter.prototype.listeners = function listeners(type) {
  27615. return _listeners(this, type, true);
  27616. };
  27617. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  27618. return _listeners(this, type, false);
  27619. };
  27620. EventEmitter.listenerCount = function(emitter, type) {
  27621. if (typeof emitter.listenerCount === 'function') {
  27622. return emitter.listenerCount(type);
  27623. } else {
  27624. return listenerCount.call(emitter, type);
  27625. }
  27626. };
  27627. EventEmitter.prototype.listenerCount = listenerCount;
  27628. function listenerCount(type) {
  27629. var events = this._events;
  27630. if (events !== undefined) {
  27631. var evlistener = events[type];
  27632. if (typeof evlistener === 'function') {
  27633. return 1;
  27634. } else if (evlistener !== undefined) {
  27635. return evlistener.length;
  27636. }
  27637. }
  27638. return 0;
  27639. }
  27640. EventEmitter.prototype.eventNames = function eventNames() {
  27641. return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
  27642. };
  27643. function arrayClone(arr, n) {
  27644. var copy = new Array(n);
  27645. for (var i = 0; i < n; ++i)
  27646. copy[i] = arr[i];
  27647. return copy;
  27648. }
  27649. function spliceOne(list, index) {
  27650. for (; index + 1 < list.length; index++)
  27651. list[index] = list[index + 1];
  27652. list.pop();
  27653. }
  27654. function unwrapListeners(arr) {
  27655. var ret = new Array(arr.length);
  27656. for (var i = 0; i < ret.length; ++i) {
  27657. ret[i] = arr[i].listener || arr[i];
  27658. }
  27659. return ret;
  27660. }
  27661. function once(emitter, name) {
  27662. return new Promise(function (resolve, reject) {
  27663. function errorListener(err) {
  27664. emitter.removeListener(name, resolver);
  27665. reject(err);
  27666. }
  27667. function resolver() {
  27668. if (typeof emitter.removeListener === 'function') {
  27669. emitter.removeListener('error', errorListener);
  27670. }
  27671. resolve([].slice.call(arguments));
  27672. };
  27673. eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
  27674. if (name !== 'error') {
  27675. addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
  27676. }
  27677. });
  27678. }
  27679. function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
  27680. if (typeof emitter.on === 'function') {
  27681. eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
  27682. }
  27683. }
  27684. function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
  27685. if (typeof emitter.on === 'function') {
  27686. if (flags.once) {
  27687. emitter.once(name, listener);
  27688. } else {
  27689. emitter.on(name, listener);
  27690. }
  27691. } else if (typeof emitter.addEventListener === 'function') {
  27692. // EventTarget does not have `error` event semantics like Node
  27693. // EventEmitters, we do not listen for `error` events here.
  27694. emitter.addEventListener(name, function wrapListener(arg) {
  27695. // IE does not have builtin `{ once: true }` support so we
  27696. // have to do it manually.
  27697. if (flags.once) {
  27698. emitter.removeEventListener(name, wrapListener);
  27699. }
  27700. listener(arg);
  27701. });
  27702. } else {
  27703. throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
  27704. }
  27705. }
  27706. },{}],621:[function(_dereq_,module,exports){
  27707. 'use strict';
  27708. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  27709. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  27710. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  27711. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  27712. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  27713. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  27714. Object.defineProperty(exports, '__esModule', {
  27715. value: true
  27716. });
  27717. function promisifyRequest(request) {
  27718. return new Promise(function (resolve, reject) {
  27719. // @ts-ignore - file size hacks
  27720. request.oncomplete = request.onsuccess = function () {
  27721. return resolve(request.result);
  27722. }; // @ts-ignore - file size hacks
  27723. request.onabort = request.onerror = function () {
  27724. return reject(request.error);
  27725. };
  27726. });
  27727. }
  27728. function createStore(dbName, storeName) {
  27729. var request = indexedDB.open(dbName);
  27730. request.onupgradeneeded = function () {
  27731. return request.result.createObjectStore(storeName);
  27732. };
  27733. var dbp = promisifyRequest(request);
  27734. return function (txMode, callback) {
  27735. return dbp.then(function (db) {
  27736. return callback(db.transaction(storeName, txMode).objectStore(storeName));
  27737. });
  27738. };
  27739. }
  27740. var defaultGetStoreFunc;
  27741. function defaultGetStore() {
  27742. if (!defaultGetStoreFunc) {
  27743. defaultGetStoreFunc = createStore('keyval-store', 'keyval');
  27744. }
  27745. return defaultGetStoreFunc;
  27746. }
  27747. /**
  27748. * Get a value by its key.
  27749. *
  27750. * @param key
  27751. * @param customStore Method to get a custom store. Use with caution (see the docs).
  27752. */
  27753. function get(key) {
  27754. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  27755. return customStore('readonly', function (store) {
  27756. return promisifyRequest(store.get(key));
  27757. });
  27758. }
  27759. /**
  27760. * Set a value with a key.
  27761. *
  27762. * @param key
  27763. * @param value
  27764. * @param customStore Method to get a custom store. Use with caution (see the docs).
  27765. */
  27766. function set(key, value) {
  27767. var customStore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultGetStore();
  27768. return customStore('readwrite', function (store) {
  27769. store.put(value, key);
  27770. return promisifyRequest(store.transaction);
  27771. });
  27772. }
  27773. /**
  27774. * Set multiple values at once. This is faster than calling set() multiple times.
  27775. * It's also atomic – if one of the pairs can't be added, none will be added.
  27776. *
  27777. * @param entries Array of entries, where each entry is an array of `[key, value]`.
  27778. * @param customStore Method to get a custom store. Use with caution (see the docs).
  27779. */
  27780. function setMany(entries) {
  27781. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  27782. return customStore('readwrite', function (store) {
  27783. entries.forEach(function (entry) {
  27784. return store.put(entry[1], entry[0]);
  27785. });
  27786. return promisifyRequest(store.transaction);
  27787. });
  27788. }
  27789. /**
  27790. * Get multiple values by their keys
  27791. *
  27792. * @param keys
  27793. * @param customStore Method to get a custom store. Use with caution (see the docs).
  27794. */
  27795. function getMany(keys) {
  27796. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  27797. return customStore('readonly', function (store) {
  27798. return Promise.all(keys.map(function (key) {
  27799. return promisifyRequest(store.get(key));
  27800. }));
  27801. });
  27802. }
  27803. /**
  27804. * Update a value. This lets you see the old value and update it as an atomic operation.
  27805. *
  27806. * @param key
  27807. * @param updater A callback that takes the old value and returns a new value.
  27808. * @param customStore Method to get a custom store. Use with caution (see the docs).
  27809. */
  27810. function update(key, updater) {
  27811. var customStore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultGetStore();
  27812. return customStore('readwrite', function (store) {
  27813. return (// Need to create the promise manually.
  27814. // If I try to chain promises, the transaction closes in browsers
  27815. // that use a promise polyfill (IE10/11).
  27816. new Promise(function (resolve, reject) {
  27817. store.get(key).onsuccess = function () {
  27818. try {
  27819. store.put(updater(this.result), key);
  27820. resolve(promisifyRequest(store.transaction));
  27821. } catch (err) {
  27822. reject(err);
  27823. }
  27824. };
  27825. })
  27826. );
  27827. });
  27828. }
  27829. /**
  27830. * Delete a particular key from the store.
  27831. *
  27832. * @param key
  27833. * @param customStore Method to get a custom store. Use with caution (see the docs).
  27834. */
  27835. function del(key) {
  27836. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  27837. return customStore('readwrite', function (store) {
  27838. store.delete(key);
  27839. return promisifyRequest(store.transaction);
  27840. });
  27841. }
  27842. /**
  27843. * Delete multiple keys at once.
  27844. *
  27845. * @param keys List of keys to delete.
  27846. * @param customStore Method to get a custom store. Use with caution (see the docs).
  27847. */
  27848. function delMany(keys) {
  27849. var customStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultGetStore();
  27850. return customStore('readwrite', function (store) {
  27851. keys.forEach(function (key) {
  27852. return store.delete(key);
  27853. });
  27854. return promisifyRequest(store.transaction);
  27855. });
  27856. }
  27857. /**
  27858. * Clear all values in the store.
  27859. *
  27860. * @param customStore Method to get a custom store. Use with caution (see the docs).
  27861. */
  27862. function clear() {
  27863. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  27864. return customStore('readwrite', function (store) {
  27865. store.clear();
  27866. return promisifyRequest(store.transaction);
  27867. });
  27868. }
  27869. function eachCursor(store, callback) {
  27870. store.openCursor().onsuccess = function () {
  27871. if (!this.result) return;
  27872. callback(this.result);
  27873. this.result.continue();
  27874. };
  27875. return promisifyRequest(store.transaction);
  27876. }
  27877. /**
  27878. * Get all keys in the store.
  27879. *
  27880. * @param customStore Method to get a custom store. Use with caution (see the docs).
  27881. */
  27882. function keys() {
  27883. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  27884. return customStore('readonly', function (store) {
  27885. // Fast path for modern browsers
  27886. if (store.getAllKeys) {
  27887. return promisifyRequest(store.getAllKeys());
  27888. }
  27889. var items = [];
  27890. return eachCursor(store, function (cursor) {
  27891. return items.push(cursor.key);
  27892. }).then(function () {
  27893. return items;
  27894. });
  27895. });
  27896. }
  27897. /**
  27898. * Get all values in the store.
  27899. *
  27900. * @param customStore Method to get a custom store. Use with caution (see the docs).
  27901. */
  27902. function values() {
  27903. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  27904. return customStore('readonly', function (store) {
  27905. // Fast path for modern browsers
  27906. if (store.getAll) {
  27907. return promisifyRequest(store.getAll());
  27908. }
  27909. var items = [];
  27910. return eachCursor(store, function (cursor) {
  27911. return items.push(cursor.value);
  27912. }).then(function () {
  27913. return items;
  27914. });
  27915. });
  27916. }
  27917. /**
  27918. * Get all entries in the store. Each entry is an array of `[key, value]`.
  27919. *
  27920. * @param customStore Method to get a custom store. Use with caution (see the docs).
  27921. */
  27922. function entries() {
  27923. var customStore = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultGetStore();
  27924. return customStore('readonly', function (store) {
  27925. // Fast path for modern browsers
  27926. // (although, hopefully we'll get a simpler path some day)
  27927. if (store.getAll && store.getAllKeys) {
  27928. return Promise.all([promisifyRequest(store.getAllKeys()), promisifyRequest(store.getAll())]).then(function (_ref) {
  27929. var _ref2 = _slicedToArray(_ref, 2),
  27930. keys = _ref2[0],
  27931. values = _ref2[1];
  27932. return keys.map(function (key, i) {
  27933. return [key, values[i]];
  27934. });
  27935. });
  27936. }
  27937. var items = [];
  27938. return customStore('readonly', function (store) {
  27939. return eachCursor(store, function (cursor) {
  27940. return items.push([cursor.key, cursor.value]);
  27941. }).then(function () {
  27942. return items;
  27943. });
  27944. });
  27945. });
  27946. }
  27947. exports.clear = clear;
  27948. exports.createStore = createStore;
  27949. exports.del = del;
  27950. exports.delMany = delMany;
  27951. exports.entries = entries;
  27952. exports.get = get;
  27953. exports.getMany = getMany;
  27954. exports.keys = keys;
  27955. exports.promisifyRequest = promisifyRequest;
  27956. exports.set = set;
  27957. exports.setMany = setMany;
  27958. exports.update = update;
  27959. exports.values = values;
  27960. },{}],622:[function(_dereq_,module,exports){
  27961. "use strict";
  27962. Object.defineProperty(exports, "__esModule", {
  27963. value: true
  27964. });
  27965. Object.defineProperty(exports, "NIL", {
  27966. enumerable: true,
  27967. get: function () {
  27968. return _nil.default;
  27969. }
  27970. });
  27971. Object.defineProperty(exports, "parse", {
  27972. enumerable: true,
  27973. get: function () {
  27974. return _parse.default;
  27975. }
  27976. });
  27977. Object.defineProperty(exports, "stringify", {
  27978. enumerable: true,
  27979. get: function () {
  27980. return _stringify.default;
  27981. }
  27982. });
  27983. Object.defineProperty(exports, "v1", {
  27984. enumerable: true,
  27985. get: function () {
  27986. return _v.default;
  27987. }
  27988. });
  27989. Object.defineProperty(exports, "v3", {
  27990. enumerable: true,
  27991. get: function () {
  27992. return _v2.default;
  27993. }
  27994. });
  27995. Object.defineProperty(exports, "v4", {
  27996. enumerable: true,
  27997. get: function () {
  27998. return _v3.default;
  27999. }
  28000. });
  28001. Object.defineProperty(exports, "v5", {
  28002. enumerable: true,
  28003. get: function () {
  28004. return _v4.default;
  28005. }
  28006. });
  28007. Object.defineProperty(exports, "validate", {
  28008. enumerable: true,
  28009. get: function () {
  28010. return _validate.default;
  28011. }
  28012. });
  28013. Object.defineProperty(exports, "version", {
  28014. enumerable: true,
  28015. get: function () {
  28016. return _version.default;
  28017. }
  28018. });
  28019. var _v = _interopRequireDefault(_dereq_("./v1.js"));
  28020. var _v2 = _interopRequireDefault(_dereq_("./v3.js"));
  28021. var _v3 = _interopRequireDefault(_dereq_("./v4.js"));
  28022. var _v4 = _interopRequireDefault(_dereq_("./v5.js"));
  28023. var _nil = _interopRequireDefault(_dereq_("./nil.js"));
  28024. var _version = _interopRequireDefault(_dereq_("./version.js"));
  28025. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  28026. var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
  28027. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  28028. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28029. },{"./nil.js":625,"./parse.js":626,"./stringify.js":630,"./v1.js":631,"./v3.js":632,"./v4.js":634,"./v5.js":635,"./validate.js":636,"./version.js":637}],623:[function(_dereq_,module,exports){
  28030. "use strict";
  28031. Object.defineProperty(exports, "__esModule", {
  28032. value: true
  28033. });
  28034. exports.default = void 0;
  28035. /*
  28036. * Browser-compatible JavaScript MD5
  28037. *
  28038. * Modification of JavaScript MD5
  28039. * https://github.com/blueimp/JavaScript-MD5
  28040. *
  28041. * Copyright 2011, Sebastian Tschan
  28042. * https://blueimp.net
  28043. *
  28044. * Licensed under the MIT license:
  28045. * https://opensource.org/licenses/MIT
  28046. *
  28047. * Based on
  28048. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  28049. * Digest Algorithm, as defined in RFC 1321.
  28050. * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
  28051. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  28052. * Distributed under the BSD License
  28053. * See http://pajhome.org.uk/crypt/md5 for more info.
  28054. */
  28055. function md5(bytes) {
  28056. if (typeof bytes === 'string') {
  28057. const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
  28058. bytes = new Uint8Array(msg.length);
  28059. for (let i = 0; i < msg.length; ++i) {
  28060. bytes[i] = msg.charCodeAt(i);
  28061. }
  28062. }
  28063. return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
  28064. }
  28065. /*
  28066. * Convert an array of little-endian words to an array of bytes
  28067. */
  28068. function md5ToHexEncodedArray(input) {
  28069. const output = [];
  28070. const length32 = input.length * 32;
  28071. const hexTab = '0123456789abcdef';
  28072. for (let i = 0; i < length32; i += 8) {
  28073. const x = input[i >> 5] >>> i % 32 & 0xff;
  28074. const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
  28075. output.push(hex);
  28076. }
  28077. return output;
  28078. }
  28079. /**
  28080. * Calculate output length with padding and bit length
  28081. */
  28082. function getOutputLength(inputLength8) {
  28083. return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
  28084. }
  28085. /*
  28086. * Calculate the MD5 of an array of little-endian words, and a bit length.
  28087. */
  28088. function wordsToMd5(x, len) {
  28089. /* append padding */
  28090. x[len >> 5] |= 0x80 << len % 32;
  28091. x[getOutputLength(len) - 1] = len;
  28092. let a = 1732584193;
  28093. let b = -271733879;
  28094. let c = -1732584194;
  28095. let d = 271733878;
  28096. for (let i = 0; i < x.length; i += 16) {
  28097. const olda = a;
  28098. const oldb = b;
  28099. const oldc = c;
  28100. const oldd = d;
  28101. a = md5ff(a, b, c, d, x[i], 7, -680876936);
  28102. d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
  28103. c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
  28104. b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
  28105. a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
  28106. d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
  28107. c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
  28108. b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
  28109. a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
  28110. d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
  28111. c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
  28112. b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
  28113. a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
  28114. d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
  28115. c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
  28116. b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
  28117. a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
  28118. d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
  28119. c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
  28120. b = md5gg(b, c, d, a, x[i], 20, -373897302);
  28121. a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
  28122. d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
  28123. c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
  28124. b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
  28125. a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
  28126. d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
  28127. c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
  28128. b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
  28129. a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
  28130. d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
  28131. c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
  28132. b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
  28133. a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
  28134. d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
  28135. c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
  28136. b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
  28137. a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
  28138. d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
  28139. c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
  28140. b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
  28141. a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
  28142. d = md5hh(d, a, b, c, x[i], 11, -358537222);
  28143. c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
  28144. b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
  28145. a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
  28146. d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
  28147. c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
  28148. b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
  28149. a = md5ii(a, b, c, d, x[i], 6, -198630844);
  28150. d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
  28151. c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
  28152. b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
  28153. a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
  28154. d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
  28155. c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
  28156. b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
  28157. a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
  28158. d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
  28159. c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
  28160. b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
  28161. a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
  28162. d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
  28163. c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
  28164. b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
  28165. a = safeAdd(a, olda);
  28166. b = safeAdd(b, oldb);
  28167. c = safeAdd(c, oldc);
  28168. d = safeAdd(d, oldd);
  28169. }
  28170. return [a, b, c, d];
  28171. }
  28172. /*
  28173. * Convert an array bytes to an array of little-endian words
  28174. * Characters >255 have their high-byte silently ignored.
  28175. */
  28176. function bytesToWords(input) {
  28177. if (input.length === 0) {
  28178. return [];
  28179. }
  28180. const length8 = input.length * 8;
  28181. const output = new Uint32Array(getOutputLength(length8));
  28182. for (let i = 0; i < length8; i += 8) {
  28183. output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
  28184. }
  28185. return output;
  28186. }
  28187. /*
  28188. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  28189. * to work around bugs in some JS interpreters.
  28190. */
  28191. function safeAdd(x, y) {
  28192. const lsw = (x & 0xffff) + (y & 0xffff);
  28193. const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  28194. return msw << 16 | lsw & 0xffff;
  28195. }
  28196. /*
  28197. * Bitwise rotate a 32-bit number to the left.
  28198. */
  28199. function bitRotateLeft(num, cnt) {
  28200. return num << cnt | num >>> 32 - cnt;
  28201. }
  28202. /*
  28203. * These functions implement the four basic operations the algorithm uses.
  28204. */
  28205. function md5cmn(q, a, b, x, s, t) {
  28206. return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
  28207. }
  28208. function md5ff(a, b, c, d, x, s, t) {
  28209. return md5cmn(b & c | ~b & d, a, b, x, s, t);
  28210. }
  28211. function md5gg(a, b, c, d, x, s, t) {
  28212. return md5cmn(b & d | c & ~d, a, b, x, s, t);
  28213. }
  28214. function md5hh(a, b, c, d, x, s, t) {
  28215. return md5cmn(b ^ c ^ d, a, b, x, s, t);
  28216. }
  28217. function md5ii(a, b, c, d, x, s, t) {
  28218. return md5cmn(c ^ (b | ~d), a, b, x, s, t);
  28219. }
  28220. var _default = md5;
  28221. exports.default = _default;
  28222. },{}],624:[function(_dereq_,module,exports){
  28223. "use strict";
  28224. Object.defineProperty(exports, "__esModule", {
  28225. value: true
  28226. });
  28227. exports.default = void 0;
  28228. const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
  28229. var _default = {
  28230. randomUUID
  28231. };
  28232. exports.default = _default;
  28233. },{}],625:[function(_dereq_,module,exports){
  28234. "use strict";
  28235. Object.defineProperty(exports, "__esModule", {
  28236. value: true
  28237. });
  28238. exports.default = void 0;
  28239. var _default = '00000000-0000-0000-0000-000000000000';
  28240. exports.default = _default;
  28241. },{}],626:[function(_dereq_,module,exports){
  28242. "use strict";
  28243. Object.defineProperty(exports, "__esModule", {
  28244. value: true
  28245. });
  28246. exports.default = void 0;
  28247. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  28248. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28249. function parse(uuid) {
  28250. if (!(0, _validate.default)(uuid)) {
  28251. throw TypeError('Invalid UUID');
  28252. }
  28253. let v;
  28254. const arr = new Uint8Array(16); // Parse ########-....-....-....-............
  28255. arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
  28256. arr[1] = v >>> 16 & 0xff;
  28257. arr[2] = v >>> 8 & 0xff;
  28258. arr[3] = v & 0xff; // Parse ........-####-....-....-............
  28259. arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
  28260. arr[5] = v & 0xff; // Parse ........-....-####-....-............
  28261. arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
  28262. arr[7] = v & 0xff; // Parse ........-....-....-####-............
  28263. arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
  28264. arr[9] = v & 0xff; // Parse ........-....-....-....-############
  28265. // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
  28266. arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
  28267. arr[11] = v / 0x100000000 & 0xff;
  28268. arr[12] = v >>> 24 & 0xff;
  28269. arr[13] = v >>> 16 & 0xff;
  28270. arr[14] = v >>> 8 & 0xff;
  28271. arr[15] = v & 0xff;
  28272. return arr;
  28273. }
  28274. var _default = parse;
  28275. exports.default = _default;
  28276. },{"./validate.js":636}],627:[function(_dereq_,module,exports){
  28277. "use strict";
  28278. Object.defineProperty(exports, "__esModule", {
  28279. value: true
  28280. });
  28281. exports.default = void 0;
  28282. var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
  28283. exports.default = _default;
  28284. },{}],628:[function(_dereq_,module,exports){
  28285. "use strict";
  28286. Object.defineProperty(exports, "__esModule", {
  28287. value: true
  28288. });
  28289. exports.default = rng;
  28290. // Unique ID creation requires a high quality random # generator. In the browser we therefore
  28291. // require the crypto API and do not support built-in fallback to lower quality random number
  28292. // generators (like Math.random()).
  28293. let getRandomValues;
  28294. const rnds8 = new Uint8Array(16);
  28295. function rng() {
  28296. // lazy load so that environments that need to polyfill have a chance to do so
  28297. if (!getRandomValues) {
  28298. // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
  28299. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
  28300. if (!getRandomValues) {
  28301. throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
  28302. }
  28303. }
  28304. return getRandomValues(rnds8);
  28305. }
  28306. },{}],629:[function(_dereq_,module,exports){
  28307. "use strict";
  28308. Object.defineProperty(exports, "__esModule", {
  28309. value: true
  28310. });
  28311. exports.default = void 0;
  28312. // Adapted from Chris Veness' SHA1 code at
  28313. // http://www.movable-type.co.uk/scripts/sha1.html
  28314. function f(s, x, y, z) {
  28315. switch (s) {
  28316. case 0:
  28317. return x & y ^ ~x & z;
  28318. case 1:
  28319. return x ^ y ^ z;
  28320. case 2:
  28321. return x & y ^ x & z ^ y & z;
  28322. case 3:
  28323. return x ^ y ^ z;
  28324. }
  28325. }
  28326. function ROTL(x, n) {
  28327. return x << n | x >>> 32 - n;
  28328. }
  28329. function sha1(bytes) {
  28330. const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
  28331. const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
  28332. if (typeof bytes === 'string') {
  28333. const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
  28334. bytes = [];
  28335. for (let i = 0; i < msg.length; ++i) {
  28336. bytes.push(msg.charCodeAt(i));
  28337. }
  28338. } else if (!Array.isArray(bytes)) {
  28339. // Convert Array-like to Array
  28340. bytes = Array.prototype.slice.call(bytes);
  28341. }
  28342. bytes.push(0x80);
  28343. const l = bytes.length / 4 + 2;
  28344. const N = Math.ceil(l / 16);
  28345. const M = new Array(N);
  28346. for (let i = 0; i < N; ++i) {
  28347. const arr = new Uint32Array(16);
  28348. for (let j = 0; j < 16; ++j) {
  28349. arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
  28350. }
  28351. M[i] = arr;
  28352. }
  28353. M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
  28354. M[N - 1][14] = Math.floor(M[N - 1][14]);
  28355. M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
  28356. for (let i = 0; i < N; ++i) {
  28357. const W = new Uint32Array(80);
  28358. for (let t = 0; t < 16; ++t) {
  28359. W[t] = M[i][t];
  28360. }
  28361. for (let t = 16; t < 80; ++t) {
  28362. W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
  28363. }
  28364. let a = H[0];
  28365. let b = H[1];
  28366. let c = H[2];
  28367. let d = H[3];
  28368. let e = H[4];
  28369. for (let t = 0; t < 80; ++t) {
  28370. const s = Math.floor(t / 20);
  28371. const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
  28372. e = d;
  28373. d = c;
  28374. c = ROTL(b, 30) >>> 0;
  28375. b = a;
  28376. a = T;
  28377. }
  28378. H[0] = H[0] + a >>> 0;
  28379. H[1] = H[1] + b >>> 0;
  28380. H[2] = H[2] + c >>> 0;
  28381. H[3] = H[3] + d >>> 0;
  28382. H[4] = H[4] + e >>> 0;
  28383. }
  28384. return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
  28385. }
  28386. var _default = sha1;
  28387. exports.default = _default;
  28388. },{}],630:[function(_dereq_,module,exports){
  28389. "use strict";
  28390. Object.defineProperty(exports, "__esModule", {
  28391. value: true
  28392. });
  28393. exports.default = void 0;
  28394. exports.unsafeStringify = unsafeStringify;
  28395. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  28396. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28397. /**
  28398. * Convert array of 16 byte values to UUID string format of the form:
  28399. * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  28400. */
  28401. const byteToHex = [];
  28402. for (let i = 0; i < 256; ++i) {
  28403. byteToHex.push((i + 0x100).toString(16).slice(1));
  28404. }
  28405. function unsafeStringify(arr, offset = 0) {
  28406. // Note: Be careful editing this code! It's been tuned for performance
  28407. // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
  28408. return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
  28409. }
  28410. function stringify(arr, offset = 0) {
  28411. const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one
  28412. // of the following:
  28413. // - One or more input array values don't map to a hex octet (leading to
  28414. // "undefined" in the uuid)
  28415. // - Invalid input values for the RFC `version` or `variant` fields
  28416. if (!(0, _validate.default)(uuid)) {
  28417. throw TypeError('Stringified UUID is invalid');
  28418. }
  28419. return uuid;
  28420. }
  28421. var _default = stringify;
  28422. exports.default = _default;
  28423. },{"./validate.js":636}],631:[function(_dereq_,module,exports){
  28424. "use strict";
  28425. Object.defineProperty(exports, "__esModule", {
  28426. value: true
  28427. });
  28428. exports.default = void 0;
  28429. var _rng = _interopRequireDefault(_dereq_("./rng.js"));
  28430. var _stringify = _dereq_("./stringify.js");
  28431. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28432. // **`v1()` - Generate time-based UUID**
  28433. //
  28434. // Inspired by https://github.com/LiosK/UUID.js
  28435. // and http://docs.python.org/library/uuid.html
  28436. let _nodeId;
  28437. let _clockseq; // Previous uuid creation time
  28438. let _lastMSecs = 0;
  28439. let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
  28440. function v1(options, buf, offset) {
  28441. let i = buf && offset || 0;
  28442. const b = buf || new Array(16);
  28443. options = options || {};
  28444. let node = options.node || _nodeId;
  28445. let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
  28446. // specified. We do this lazily to minimize issues related to insufficient
  28447. // system entropy. See #189
  28448. if (node == null || clockseq == null) {
  28449. const seedBytes = options.random || (options.rng || _rng.default)();
  28450. if (node == null) {
  28451. // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
  28452. node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
  28453. }
  28454. if (clockseq == null) {
  28455. // Per 4.2.2, randomize (14 bit) clockseq
  28456. clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
  28457. }
  28458. } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
  28459. // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
  28460. // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
  28461. // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
  28462. let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
  28463. // cycle to simulate higher resolution clock
  28464. let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
  28465. const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
  28466. if (dt < 0 && options.clockseq === undefined) {
  28467. clockseq = clockseq + 1 & 0x3fff;
  28468. } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
  28469. // time interval
  28470. if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
  28471. nsecs = 0;
  28472. } // Per 4.2.1.2 Throw error if too many uuids are requested
  28473. if (nsecs >= 10000) {
  28474. throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
  28475. }
  28476. _lastMSecs = msecs;
  28477. _lastNSecs = nsecs;
  28478. _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
  28479. msecs += 12219292800000; // `time_low`
  28480. const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
  28481. b[i++] = tl >>> 24 & 0xff;
  28482. b[i++] = tl >>> 16 & 0xff;
  28483. b[i++] = tl >>> 8 & 0xff;
  28484. b[i++] = tl & 0xff; // `time_mid`
  28485. const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
  28486. b[i++] = tmh >>> 8 & 0xff;
  28487. b[i++] = tmh & 0xff; // `time_high_and_version`
  28488. b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
  28489. b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
  28490. b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
  28491. b[i++] = clockseq & 0xff; // `node`
  28492. for (let n = 0; n < 6; ++n) {
  28493. b[i + n] = node[n];
  28494. }
  28495. return buf || (0, _stringify.unsafeStringify)(b);
  28496. }
  28497. var _default = v1;
  28498. exports.default = _default;
  28499. },{"./rng.js":628,"./stringify.js":630}],632:[function(_dereq_,module,exports){
  28500. "use strict";
  28501. Object.defineProperty(exports, "__esModule", {
  28502. value: true
  28503. });
  28504. exports.default = void 0;
  28505. var _v = _interopRequireDefault(_dereq_("./v35.js"));
  28506. var _md = _interopRequireDefault(_dereq_("./md5.js"));
  28507. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28508. const v3 = (0, _v.default)('v3', 0x30, _md.default);
  28509. var _default = v3;
  28510. exports.default = _default;
  28511. },{"./md5.js":623,"./v35.js":633}],633:[function(_dereq_,module,exports){
  28512. "use strict";
  28513. Object.defineProperty(exports, "__esModule", {
  28514. value: true
  28515. });
  28516. exports.URL = exports.DNS = void 0;
  28517. exports.default = v35;
  28518. var _stringify = _dereq_("./stringify.js");
  28519. var _parse = _interopRequireDefault(_dereq_("./parse.js"));
  28520. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28521. function stringToBytes(str) {
  28522. str = unescape(encodeURIComponent(str)); // UTF8 escape
  28523. const bytes = [];
  28524. for (let i = 0; i < str.length; ++i) {
  28525. bytes.push(str.charCodeAt(i));
  28526. }
  28527. return bytes;
  28528. }
  28529. const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
  28530. exports.DNS = DNS;
  28531. const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
  28532. exports.URL = URL;
  28533. function v35(name, version, hashfunc) {
  28534. function generateUUID(value, namespace, buf, offset) {
  28535. var _namespace;
  28536. if (typeof value === 'string') {
  28537. value = stringToBytes(value);
  28538. }
  28539. if (typeof namespace === 'string') {
  28540. namespace = (0, _parse.default)(namespace);
  28541. }
  28542. if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
  28543. throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
  28544. } // Compute hash of namespace and value, Per 4.3
  28545. // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
  28546. // hashfunc([...namespace, ... value])`
  28547. let bytes = new Uint8Array(16 + value.length);
  28548. bytes.set(namespace);
  28549. bytes.set(value, namespace.length);
  28550. bytes = hashfunc(bytes);
  28551. bytes[6] = bytes[6] & 0x0f | version;
  28552. bytes[8] = bytes[8] & 0x3f | 0x80;
  28553. if (buf) {
  28554. offset = offset || 0;
  28555. for (let i = 0; i < 16; ++i) {
  28556. buf[offset + i] = bytes[i];
  28557. }
  28558. return buf;
  28559. }
  28560. return (0, _stringify.unsafeStringify)(bytes);
  28561. } // Function#name is not settable on some platforms (#270)
  28562. try {
  28563. generateUUID.name = name; // eslint-disable-next-line no-empty
  28564. } catch (err) {} // For CommonJS default export support
  28565. generateUUID.DNS = DNS;
  28566. generateUUID.URL = URL;
  28567. return generateUUID;
  28568. }
  28569. },{"./parse.js":626,"./stringify.js":630}],634:[function(_dereq_,module,exports){
  28570. "use strict";
  28571. Object.defineProperty(exports, "__esModule", {
  28572. value: true
  28573. });
  28574. exports.default = void 0;
  28575. var _native = _interopRequireDefault(_dereq_("./native.js"));
  28576. var _rng = _interopRequireDefault(_dereq_("./rng.js"));
  28577. var _stringify = _dereq_("./stringify.js");
  28578. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28579. function v4(options, buf, offset) {
  28580. if (_native.default.randomUUID && !buf && !options) {
  28581. return _native.default.randomUUID();
  28582. }
  28583. options = options || {};
  28584. const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  28585. rnds[6] = rnds[6] & 0x0f | 0x40;
  28586. rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
  28587. if (buf) {
  28588. offset = offset || 0;
  28589. for (let i = 0; i < 16; ++i) {
  28590. buf[offset + i] = rnds[i];
  28591. }
  28592. return buf;
  28593. }
  28594. return (0, _stringify.unsafeStringify)(rnds);
  28595. }
  28596. var _default = v4;
  28597. exports.default = _default;
  28598. },{"./native.js":624,"./rng.js":628,"./stringify.js":630}],635:[function(_dereq_,module,exports){
  28599. "use strict";
  28600. Object.defineProperty(exports, "__esModule", {
  28601. value: true
  28602. });
  28603. exports.default = void 0;
  28604. var _v = _interopRequireDefault(_dereq_("./v35.js"));
  28605. var _sha = _interopRequireDefault(_dereq_("./sha1.js"));
  28606. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28607. const v5 = (0, _v.default)('v5', 0x50, _sha.default);
  28608. var _default = v5;
  28609. exports.default = _default;
  28610. },{"./sha1.js":629,"./v35.js":633}],636:[function(_dereq_,module,exports){
  28611. "use strict";
  28612. Object.defineProperty(exports, "__esModule", {
  28613. value: true
  28614. });
  28615. exports.default = void 0;
  28616. var _regex = _interopRequireDefault(_dereq_("./regex.js"));
  28617. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28618. function validate(uuid) {
  28619. return typeof uuid === 'string' && _regex.default.test(uuid);
  28620. }
  28621. var _default = validate;
  28622. exports.default = _default;
  28623. },{"./regex.js":627}],637:[function(_dereq_,module,exports){
  28624. "use strict";
  28625. Object.defineProperty(exports, "__esModule", {
  28626. value: true
  28627. });
  28628. exports.default = void 0;
  28629. var _validate = _interopRequireDefault(_dereq_("./validate.js"));
  28630. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28631. function version(uuid) {
  28632. if (!(0, _validate.default)(uuid)) {
  28633. throw TypeError('Invalid UUID');
  28634. }
  28635. return parseInt(uuid.slice(14, 15), 16);
  28636. }
  28637. var _default = version;
  28638. exports.default = _default;
  28639. },{"./validate.js":636}]},{},[18])(18)
  28640. });