parse.weapp.js 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974
  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":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],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":34,"./uuid":55,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],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":21,"./ParseObject":26,"./ParseQuery":29,"./decode":46,"./encode":47,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],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":59,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"_process":149}],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":76,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"crypto-js/aes":612,"crypto-js/enc-utf8":616}],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":621}],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":26,"./ParseQuery":29,"./Storage":39,"@babel/runtime-corejs3/core-js-stable/instance/find":64,"@babel/runtime-corejs3/core-js-stable/instance/find-index":63,"@babel/runtime-corejs3/core-js-stable/instance/splice":73,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/set-interval":93,"@babel/runtime-corejs3/helpers/asyncToGenerator":122,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/toConsumableArray":142,"@babel/runtime-corejs3/regenerator":148}],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":34,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],9:[function(_dereq_,module,exports){
  1506. "use strict";
  1507. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1508. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  1509. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  1510. /**
  1511. * @flow
  1512. */
  1513. var uuidv4 = _dereq_('./uuid');
  1514. var iidCache = null;
  1515. var InstallationController = {
  1516. currentInstallationId: function () /*: Promise<string>*/{
  1517. if (typeof iidCache === 'string') {
  1518. return _promise.default.resolve(iidCache);
  1519. }
  1520. var path = _Storage.default.generatePath('installationId');
  1521. return _Storage.default.getItemAsync(path).then(function (iid) {
  1522. if (!iid) {
  1523. iid = uuidv4();
  1524. return _Storage.default.setItemAsync(path, iid).then(function () {
  1525. iidCache = iid;
  1526. return iid;
  1527. });
  1528. }
  1529. iidCache = iid;
  1530. return iid;
  1531. });
  1532. },
  1533. _clearCache: function () {
  1534. iidCache = null;
  1535. },
  1536. _setInstallationIdCache: function (iid /*: string*/) {
  1537. iidCache = iid;
  1538. }
  1539. };
  1540. module.exports = InstallationController;
  1541. },{"./Storage":39,"./uuid":55,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],10:[function(_dereq_,module,exports){
  1542. "use strict";
  1543. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  1544. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  1545. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  1546. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  1547. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  1548. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  1549. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  1550. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  1551. _Object$defineProperty(exports, "__esModule", {
  1552. value: true
  1553. });
  1554. exports.default = void 0;
  1555. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  1556. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
  1557. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  1558. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  1559. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  1560. var _values = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/values"));
  1561. var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
  1562. var _bind = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/bind"));
  1563. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  1564. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  1565. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  1566. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  1567. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  1568. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  1569. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  1570. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  1571. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  1572. var _EventEmitter2 = _interopRequireDefault(_dereq_("./EventEmitter"));
  1573. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  1574. var _LiveQuerySubscription = _interopRequireDefault(_dereq_("./LiveQuerySubscription"));
  1575. var _promiseUtils = _dereq_("./promiseUtils");
  1576. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  1577. function _createForOfIteratorHelper(o, allowArrayLike) {
  1578. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  1579. if (!it) {
  1580. if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  1581. if (it) o = it;
  1582. var i = 0;
  1583. var F = function () {};
  1584. return {
  1585. s: F,
  1586. n: function () {
  1587. if (i >= o.length) return {
  1588. done: true
  1589. };
  1590. return {
  1591. done: false,
  1592. value: o[i++]
  1593. };
  1594. },
  1595. e: function (_e) {
  1596. throw _e;
  1597. },
  1598. f: F
  1599. };
  1600. }
  1601. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1602. }
  1603. var normalCompletion = true,
  1604. didErr = false,
  1605. err;
  1606. return {
  1607. s: function () {
  1608. it = it.call(o);
  1609. },
  1610. n: function () {
  1611. var step = it.next();
  1612. normalCompletion = step.done;
  1613. return step;
  1614. },
  1615. e: function (_e2) {
  1616. didErr = true;
  1617. err = _e2;
  1618. },
  1619. f: function () {
  1620. try {
  1621. if (!normalCompletion && it.return != null) it.return();
  1622. } finally {
  1623. if (didErr) throw err;
  1624. }
  1625. }
  1626. };
  1627. }
  1628. function _unsupportedIterableToArray(o, minLen) {
  1629. var _context6;
  1630. if (!o) return;
  1631. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  1632. var n = _sliceInstanceProperty(_context6 = Object.prototype.toString.call(o)).call(_context6, 8, -1);
  1633. if (n === "Object" && o.constructor) n = o.constructor.name;
  1634. if (n === "Map" || n === "Set") return _Array$from(o);
  1635. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  1636. }
  1637. function _arrayLikeToArray(arr, len) {
  1638. if (len == null || len > arr.length) len = arr.length;
  1639. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  1640. return arr2;
  1641. }
  1642. function _createSuper(Derived) {
  1643. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  1644. return function () {
  1645. var Super = (0, _getPrototypeOf2.default)(Derived),
  1646. result;
  1647. if (hasNativeReflectConstruct) {
  1648. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  1649. result = _Reflect$construct(Super, arguments, NewTarget);
  1650. } else {
  1651. result = Super.apply(this, arguments);
  1652. }
  1653. return (0, _possibleConstructorReturn2.default)(this, result);
  1654. };
  1655. }
  1656. function _isNativeReflectConstruct() {
  1657. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  1658. if (_Reflect$construct.sham) return false;
  1659. if (typeof Proxy === "function") return true;
  1660. try {
  1661. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  1662. return true;
  1663. } catch (e) {
  1664. return false;
  1665. }
  1666. } /* global WebSocket */
  1667. // The LiveQuery client inner state
  1668. var CLIENT_STATE = {
  1669. INITIALIZED: 'initialized',
  1670. CONNECTING: 'connecting',
  1671. CONNECTED: 'connected',
  1672. CLOSED: 'closed',
  1673. RECONNECTING: 'reconnecting',
  1674. DISCONNECTED: 'disconnected'
  1675. };
  1676. // The event type the LiveQuery client should sent to server
  1677. var OP_TYPES = {
  1678. CONNECT: 'connect',
  1679. SUBSCRIBE: 'subscribe',
  1680. UNSUBSCRIBE: 'unsubscribe',
  1681. ERROR: 'error'
  1682. };
  1683. // The event we get back from LiveQuery server
  1684. var OP_EVENTS = {
  1685. CONNECTED: 'connected',
  1686. SUBSCRIBED: 'subscribed',
  1687. UNSUBSCRIBED: 'unsubscribed',
  1688. ERROR: 'error',
  1689. CREATE: 'create',
  1690. UPDATE: 'update',
  1691. ENTER: 'enter',
  1692. LEAVE: 'leave',
  1693. DELETE: 'delete'
  1694. };
  1695. // The event the LiveQuery client should emit
  1696. var CLIENT_EMMITER_TYPES = {
  1697. CLOSE: 'close',
  1698. ERROR: 'error',
  1699. OPEN: 'open'
  1700. };
  1701. // The event the LiveQuery subscription should emit
  1702. var SUBSCRIPTION_EMMITER_TYPES = {
  1703. OPEN: 'open',
  1704. CLOSE: 'close',
  1705. ERROR: 'error',
  1706. CREATE: 'create',
  1707. UPDATE: 'update',
  1708. ENTER: 'enter',
  1709. LEAVE: 'leave',
  1710. DELETE: 'delete'
  1711. };
  1712. var generateInterval = function (k) {
  1713. return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1000;
  1714. };
  1715. /**
  1716. * Creates a new LiveQueryClient.
  1717. * Extends events.EventEmitter
  1718. * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
  1719. *
  1720. * A wrapper of a standard WebSocket client. We add several useful methods to
  1721. * help you connect/disconnect to LiveQueryServer, subscribe/unsubscribe a ParseQuery easily.
  1722. *
  1723. * javascriptKey and masterKey are used for verifying the LiveQueryClient when it tries
  1724. * to connect to the LiveQuery server
  1725. *
  1726. * We expose three events to help you monitor the status of the LiveQueryClient.
  1727. *
  1728. * <pre>
  1729. * let Parse = require('parse/node');
  1730. * let LiveQueryClient = Parse.LiveQueryClient;
  1731. * let client = new LiveQueryClient({
  1732. * applicationId: '',
  1733. * serverURL: '',
  1734. * javascriptKey: '',
  1735. * masterKey: ''
  1736. * });
  1737. * </pre>
  1738. *
  1739. * Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
  1740. * <pre>
  1741. * client.on('open', () => {
  1742. *
  1743. * });</pre>
  1744. *
  1745. * Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
  1746. * <pre>
  1747. * client.on('close', () => {
  1748. *
  1749. * });</pre>
  1750. *
  1751. * Error - When some network error or LiveQuery server error happens, you'll get this event.
  1752. * <pre>
  1753. * client.on('error', (error) => {
  1754. *
  1755. * });</pre>
  1756. *
  1757. * @alias Parse.LiveQueryClient
  1758. */
  1759. var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
  1760. (0, _inherits2.default)(LiveQueryClient, _EventEmitter);
  1761. var _super = _createSuper(LiveQueryClient);
  1762. /**
  1763. * @param {object} options
  1764. * @param {string} options.applicationId - applicationId of your Parse app
  1765. * @param {string} options.serverURL - <b>the URL of your LiveQuery server</b>
  1766. * @param {string} options.javascriptKey (optional)
  1767. * @param {string} options.masterKey (optional) Your Parse Master Key. (Node.js only!)
  1768. * @param {string} options.sessionToken (optional)
  1769. * @param {string} options.installationId (optional)
  1770. */
  1771. function LiveQueryClient(_ref) {
  1772. var _this;
  1773. var applicationId = _ref.applicationId,
  1774. serverURL = _ref.serverURL,
  1775. javascriptKey = _ref.javascriptKey,
  1776. masterKey = _ref.masterKey,
  1777. sessionToken = _ref.sessionToken,
  1778. installationId = _ref.installationId;
  1779. (0, _classCallCheck2.default)(this, LiveQueryClient);
  1780. _this = _super.call(this);
  1781. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "attempts", void 0);
  1782. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "id", void 0);
  1783. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "requestId", void 0);
  1784. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "applicationId", void 0);
  1785. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "serverURL", void 0);
  1786. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "javascriptKey", void 0);
  1787. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "masterKey", void 0);
  1788. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sessionToken", void 0);
  1789. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "installationId", void 0);
  1790. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "additionalProperties", void 0);
  1791. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "connectPromise", void 0);
  1792. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "subscriptions", void 0);
  1793. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "socket", void 0);
  1794. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", void 0);
  1795. if (!serverURL || (0, _indexOf.default)(serverURL).call(serverURL, 'ws') !== 0) {
  1796. throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
  1797. }
  1798. _this.reconnectHandle = null;
  1799. _this.attempts = 1;
  1800. _this.id = 0;
  1801. _this.requestId = 1;
  1802. _this.serverURL = serverURL;
  1803. _this.applicationId = applicationId;
  1804. _this.javascriptKey = javascriptKey || undefined;
  1805. _this.masterKey = masterKey || undefined;
  1806. _this.sessionToken = sessionToken || undefined;
  1807. _this.installationId = installationId || undefined;
  1808. _this.additionalProperties = true;
  1809. _this.connectPromise = (0, _promiseUtils.resolvingPromise)();
  1810. _this.subscriptions = new _map.default();
  1811. _this.state = CLIENT_STATE.INITIALIZED;
  1812. // adding listener so process does not crash
  1813. // best practice is for developer to register their own listener
  1814. _this.on('error', function () {});
  1815. return _this;
  1816. }
  1817. (0, _createClass2.default)(LiveQueryClient, [{
  1818. key: "shouldOpen",
  1819. value: function () /*: any*/{
  1820. return this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED;
  1821. }
  1822. /**
  1823. * Subscribes to a ParseQuery
  1824. *
  1825. * If you provide the sessionToken, when the LiveQuery server gets ParseObject's
  1826. * updates from parse server, it'll try to check whether the sessionToken fulfills
  1827. * the ParseObject's ACL. The LiveQuery server will only send updates to clients whose
  1828. * sessionToken is fit for the ParseObject's ACL. You can check the LiveQuery protocol
  1829. * <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
  1830. * from our Standard API.
  1831. *
  1832. * @param {object} query - the ParseQuery you want to subscribe to
  1833. * @param {string} sessionToken (optional)
  1834. * @returns {LiveQuerySubscription | undefined}
  1835. */
  1836. }, {
  1837. key: "subscribe",
  1838. value: function (query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
  1839. var _queryJSON$keys,
  1840. _queryJSON$watch,
  1841. _this2 = this;
  1842. if (!query) {
  1843. return;
  1844. }
  1845. var className = query.className;
  1846. var queryJSON = query.toJSON();
  1847. var where = queryJSON.where;
  1848. var fields = (_queryJSON$keys = (0, _keys.default)(queryJSON)) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
  1849. var watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
  1850. var subscribeRequest = {
  1851. op: OP_TYPES.SUBSCRIBE,
  1852. requestId: this.requestId,
  1853. query: {
  1854. className: className,
  1855. where: where,
  1856. fields: fields,
  1857. watch: watch
  1858. }
  1859. };
  1860. if (sessionToken) {
  1861. subscribeRequest.sessionToken = sessionToken;
  1862. }
  1863. var subscription = new _LiveQuerySubscription.default(this.requestId, query, sessionToken);
  1864. this.subscriptions.set(this.requestId, subscription);
  1865. this.requestId += 1;
  1866. this.connectPromise.then(function () {
  1867. _this2.socket.send((0, _stringify.default)(subscribeRequest));
  1868. }).catch(function (error) {
  1869. subscription.subscribePromise.reject(error);
  1870. });
  1871. return subscription;
  1872. }
  1873. /**
  1874. * After calling unsubscribe you'll stop receiving events from the subscription object.
  1875. *
  1876. * @param {object} subscription - subscription you would like to unsubscribe from.
  1877. * @returns {Promise | undefined}
  1878. */
  1879. }, {
  1880. key: "unsubscribe",
  1881. value: function (subscription /*: Object*/) /*: ?Promise*/{
  1882. var _this3 = this;
  1883. if (!subscription) {
  1884. return;
  1885. }
  1886. var unsubscribeRequest = {
  1887. op: OP_TYPES.UNSUBSCRIBE,
  1888. requestId: subscription.id
  1889. };
  1890. return this.connectPromise.then(function () {
  1891. return _this3.socket.send((0, _stringify.default)(unsubscribeRequest));
  1892. }).then(function () {
  1893. return subscription.unsubscribePromise;
  1894. });
  1895. }
  1896. /**
  1897. * After open is called, the LiveQueryClient will try to send a connect request
  1898. * to the LiveQuery server.
  1899. *
  1900. */
  1901. }, {
  1902. key: "open",
  1903. value: function () {
  1904. var _this4 = this;
  1905. var WebSocketImplementation = _CoreManager.default.getWebSocketController();
  1906. if (!WebSocketImplementation) {
  1907. this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
  1908. return;
  1909. }
  1910. if (this.state !== CLIENT_STATE.RECONNECTING) {
  1911. this.state = CLIENT_STATE.CONNECTING;
  1912. }
  1913. this.socket = new WebSocketImplementation(this.serverURL);
  1914. this.socket.closingPromise = (0, _promiseUtils.resolvingPromise)();
  1915. // Bind WebSocket callbacks
  1916. this.socket.onopen = function () {
  1917. _this4._handleWebSocketOpen();
  1918. };
  1919. this.socket.onmessage = function (event) {
  1920. _this4._handleWebSocketMessage(event);
  1921. };
  1922. this.socket.onclose = function (event) {
  1923. _this4.socket.closingPromise.resolve(event);
  1924. _this4._handleWebSocketClose();
  1925. };
  1926. this.socket.onerror = function (error) {
  1927. _this4._handleWebSocketError(error);
  1928. };
  1929. }
  1930. }, {
  1931. key: "resubscribe",
  1932. value: function () {
  1933. var _context,
  1934. _this5 = this;
  1935. (0, _forEach.default)(_context = this.subscriptions).call(_context, function (subscription, requestId) {
  1936. var query = subscription.query;
  1937. var queryJSON = query.toJSON();
  1938. var where = queryJSON.where;
  1939. var fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
  1940. var className = query.className;
  1941. var sessionToken = subscription.sessionToken;
  1942. var subscribeRequest = {
  1943. op: OP_TYPES.SUBSCRIBE,
  1944. requestId: requestId,
  1945. query: {
  1946. className: className,
  1947. where: where,
  1948. fields: fields
  1949. }
  1950. };
  1951. if (sessionToken) {
  1952. subscribeRequest.sessionToken = sessionToken;
  1953. }
  1954. _this5.connectPromise.then(function () {
  1955. _this5.socket.send((0, _stringify.default)(subscribeRequest));
  1956. });
  1957. });
  1958. }
  1959. /**
  1960. * This method will close the WebSocket connection to this LiveQueryClient,
  1961. * cancel the auto reconnect and unsubscribe all subscriptions based on it.
  1962. *
  1963. * @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event}
  1964. */
  1965. }, {
  1966. key: "close",
  1967. value: function () /*: ?Promise*/{
  1968. var _this$socket, _this$socket2, _context2;
  1969. if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
  1970. return;
  1971. }
  1972. this.state = CLIENT_STATE.DISCONNECTED;
  1973. (_this$socket = this.socket) === null || _this$socket === void 0 ? void 0 : _this$socket.close();
  1974. // Notify each subscription about the close
  1975. var _iterator = _createForOfIteratorHelper((0, _values.default)(_context2 = this.subscriptions).call(_context2)),
  1976. _step;
  1977. try {
  1978. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  1979. var subscription = _step.value;
  1980. subscription.subscribed = false;
  1981. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
  1982. }
  1983. } catch (err) {
  1984. _iterator.e(err);
  1985. } finally {
  1986. _iterator.f();
  1987. }
  1988. this._handleReset();
  1989. this.emit(CLIENT_EMMITER_TYPES.CLOSE);
  1990. return (_this$socket2 = this.socket) === null || _this$socket2 === void 0 ? void 0 : _this$socket2.closingPromise;
  1991. }
  1992. // ensure we start with valid state if connect is called again after close
  1993. }, {
  1994. key: "_handleReset",
  1995. value: function () {
  1996. this.attempts = 1;
  1997. this.id = 0;
  1998. this.requestId = 1;
  1999. this.connectPromise = (0, _promiseUtils.resolvingPromise)();
  2000. this.subscriptions = new _map.default();
  2001. }
  2002. }, {
  2003. key: "_handleWebSocketOpen",
  2004. value: function () {
  2005. this.attempts = 1;
  2006. var connectRequest = {
  2007. op: OP_TYPES.CONNECT,
  2008. applicationId: this.applicationId,
  2009. javascriptKey: this.javascriptKey,
  2010. masterKey: this.masterKey,
  2011. sessionToken: this.sessionToken
  2012. };
  2013. if (this.additionalProperties) {
  2014. connectRequest.installationId = this.installationId;
  2015. }
  2016. this.socket.send((0, _stringify.default)(connectRequest));
  2017. }
  2018. }, {
  2019. key: "_handleWebSocketMessage",
  2020. value: function (event /*: any*/) {
  2021. var data = event.data;
  2022. if (typeof data === 'string') {
  2023. data = JSON.parse(data);
  2024. }
  2025. var subscription = null;
  2026. if (data.requestId) {
  2027. subscription = this.subscriptions.get(data.requestId);
  2028. }
  2029. var response = {
  2030. clientId: data.clientId,
  2031. installationId: data.installationId
  2032. };
  2033. switch (data.op) {
  2034. case OP_EVENTS.CONNECTED:
  2035. if (this.state === CLIENT_STATE.RECONNECTING) {
  2036. this.resubscribe();
  2037. }
  2038. this.emit(CLIENT_EMMITER_TYPES.OPEN);
  2039. this.id = data.clientId;
  2040. this.connectPromise.resolve();
  2041. this.state = CLIENT_STATE.CONNECTED;
  2042. break;
  2043. case OP_EVENTS.SUBSCRIBED:
  2044. if (subscription) {
  2045. subscription.subscribed = true;
  2046. subscription.subscribePromise.resolve();
  2047. (0, _setTimeout2.default)(function () {
  2048. return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response);
  2049. }, 200);
  2050. }
  2051. break;
  2052. case OP_EVENTS.ERROR:
  2053. {
  2054. var parseError = new _ParseError.default(data.code, data.error);
  2055. if (!this.id) {
  2056. this.connectPromise.reject(parseError);
  2057. this.state = CLIENT_STATE.DISCONNECTED;
  2058. }
  2059. if (data.requestId) {
  2060. if (subscription) {
  2061. subscription.subscribePromise.reject(parseError);
  2062. (0, _setTimeout2.default)(function () {
  2063. return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error);
  2064. }, 200);
  2065. }
  2066. } else {
  2067. this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
  2068. }
  2069. if (data.error === 'Additional properties not allowed') {
  2070. this.additionalProperties = false;
  2071. }
  2072. if (data.reconnect) {
  2073. this._handleReconnect();
  2074. }
  2075. break;
  2076. }
  2077. case OP_EVENTS.UNSUBSCRIBED:
  2078. {
  2079. if (subscription) {
  2080. this.subscriptions.delete(data.requestId);
  2081. subscription.subscribed = false;
  2082. subscription.unsubscribePromise.resolve();
  2083. }
  2084. break;
  2085. }
  2086. default:
  2087. {
  2088. // create, update, enter, leave, delete cases
  2089. if (!subscription) {
  2090. break;
  2091. }
  2092. var override = false;
  2093. if (data.original) {
  2094. override = true;
  2095. delete data.original.__type;
  2096. // Check for removed fields
  2097. for (var field in data.original) {
  2098. if (!(field in data.object)) {
  2099. data.object[field] = undefined;
  2100. }
  2101. }
  2102. data.original = _ParseObject.default.fromJSON(data.original, false);
  2103. }
  2104. delete data.object.__type;
  2105. var parseObject = _ParseObject.default.fromJSON(data.object, !(subscription.query && subscription.query._select) ? override : false);
  2106. if (data.original) {
  2107. subscription.emit(data.op, parseObject, data.original, response);
  2108. } else {
  2109. subscription.emit(data.op, parseObject, response);
  2110. }
  2111. var localDatastore = _CoreManager.default.getLocalDatastore();
  2112. if (override && localDatastore.isEnabled) {
  2113. localDatastore._updateObjectIfPinned(parseObject).then(function () {});
  2114. }
  2115. }
  2116. }
  2117. }
  2118. }, {
  2119. key: "_handleWebSocketClose",
  2120. value: function () {
  2121. var _context3;
  2122. if (this.state === CLIENT_STATE.DISCONNECTED) {
  2123. return;
  2124. }
  2125. this.state = CLIENT_STATE.CLOSED;
  2126. this.emit(CLIENT_EMMITER_TYPES.CLOSE);
  2127. // Notify each subscription about the close
  2128. var _iterator2 = _createForOfIteratorHelper((0, _values.default)(_context3 = this.subscriptions).call(_context3)),
  2129. _step2;
  2130. try {
  2131. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  2132. var subscription = _step2.value;
  2133. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
  2134. }
  2135. } catch (err) {
  2136. _iterator2.e(err);
  2137. } finally {
  2138. _iterator2.f();
  2139. }
  2140. this._handleReconnect();
  2141. }
  2142. }, {
  2143. key: "_handleWebSocketError",
  2144. value: function (error /*: any*/) {
  2145. var _context4;
  2146. this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
  2147. var _iterator3 = _createForOfIteratorHelper((0, _values.default)(_context4 = this.subscriptions).call(_context4)),
  2148. _step3;
  2149. try {
  2150. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  2151. var subscription = _step3.value;
  2152. subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, error);
  2153. }
  2154. } catch (err) {
  2155. _iterator3.e(err);
  2156. } finally {
  2157. _iterator3.f();
  2158. }
  2159. this._handleReconnect();
  2160. }
  2161. }, {
  2162. key: "_handleReconnect",
  2163. value: function () {
  2164. var _context5,
  2165. _this6 = this;
  2166. // if closed or currently reconnecting we stop attempting to reconnect
  2167. if (this.state === CLIENT_STATE.DISCONNECTED) {
  2168. return;
  2169. }
  2170. this.state = CLIENT_STATE.RECONNECTING;
  2171. var time = generateInterval(this.attempts);
  2172. // handle case when both close/error occur at frequent rates we ensure we do not reconnect unnecessarily.
  2173. // we're unable to distinguish different between close/error when we're unable to reconnect therefore
  2174. // we try to reconnect in both cases
  2175. // server side ws and browser WebSocket behave differently in when close/error get triggered
  2176. if (this.reconnectHandle) {
  2177. clearTimeout(this.reconnectHandle);
  2178. }
  2179. this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context5 = function () {
  2180. _this6.attempts++;
  2181. _this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
  2182. _this6.open();
  2183. }).call(_context5, this), time);
  2184. }
  2185. }]);
  2186. return LiveQueryClient;
  2187. }(_EventEmitter2.default);
  2188. _CoreManager.default.setWebSocketController(_dereq_('./Socket.weapp'));
  2189. var _default = LiveQueryClient;
  2190. exports.default = _default;
  2191. },{"./CoreManager":4,"./EventEmitter":6,"./LiveQuerySubscription":11,"./ParseError":21,"./ParseObject":26,"./Socket.weapp":38,"./promiseUtils":52,"@babel/runtime-corejs3/core-js-stable/array/from":56,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/bind":58,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/instance/keys":68,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/instance/values":75,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/map":77,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":92,"@babel/runtime-corejs3/core-js-stable/set-timeout":94,"@babel/runtime-corejs3/core-js-stable/symbol":96,"@babel/runtime-corejs3/core-js/get-iterator-method":100,"@babel/runtime-corejs3/helpers/assertThisInitialized":121,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/getPrototypeOf":128,"@babel/runtime-corejs3/helpers/inherits":129,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":137,"@babel/runtime-corejs3/helpers/typeof":145}],11:[function(_dereq_,module,exports){
  2192. "use strict";
  2193. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  2194. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  2195. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2196. _Object$defineProperty(exports, "__esModule", {
  2197. value: true
  2198. });
  2199. exports.default = void 0;
  2200. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  2201. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  2202. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  2203. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  2204. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  2205. var _EventEmitter2 = _interopRequireDefault(_dereq_("./EventEmitter"));
  2206. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  2207. var _promiseUtils = _dereq_("./promiseUtils");
  2208. function _createSuper(Derived) {
  2209. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  2210. return function () {
  2211. var Super = (0, _getPrototypeOf2.default)(Derived),
  2212. result;
  2213. if (hasNativeReflectConstruct) {
  2214. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  2215. result = _Reflect$construct(Super, arguments, NewTarget);
  2216. } else {
  2217. result = Super.apply(this, arguments);
  2218. }
  2219. return (0, _possibleConstructorReturn2.default)(this, result);
  2220. };
  2221. }
  2222. function _isNativeReflectConstruct() {
  2223. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  2224. if (_Reflect$construct.sham) return false;
  2225. if (typeof Proxy === "function") return true;
  2226. try {
  2227. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  2228. return true;
  2229. } catch (e) {
  2230. return false;
  2231. }
  2232. }
  2233. /**
  2234. * Creates a new LiveQuery Subscription.
  2235. * Extends events.EventEmitter
  2236. * <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
  2237. *
  2238. * <p>Response Object - Contains data from the client that made the request
  2239. * <ul>
  2240. * <li>clientId</li>
  2241. * <li>installationId - requires Parse Server 4.0.0+</li>
  2242. * </ul>
  2243. * </p>
  2244. *
  2245. * <p>Open Event - When you call query.subscribe(), we send a subscribe request to
  2246. * the LiveQuery server, when we get the confirmation from the LiveQuery server,
  2247. * this event will be emitted. When the client loses WebSocket connection to the
  2248. * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we
  2249. * reconnect the LiveQuery server and successfully resubscribe the ParseQuery,
  2250. * you'll also get this event.
  2251. *
  2252. * <pre>
  2253. * subscription.on('open', (response) => {
  2254. *
  2255. * });</pre></p>
  2256. *
  2257. * <p>Create Event - When a new ParseObject is created and it fulfills the ParseQuery you subscribe,
  2258. * you'll get this event. The object is the ParseObject which is created.
  2259. *
  2260. * <pre>
  2261. * subscription.on('create', (object, response) => {
  2262. *
  2263. * });</pre></p>
  2264. *
  2265. * <p>Update Event - When an existing ParseObject (original) which fulfills the ParseQuery you subscribe
  2266. * is updated (The ParseObject fulfills the ParseQuery before and after changes),
  2267. * you'll get this event. The object is the ParseObject which is updated.
  2268. * Its content is the latest value of the ParseObject.
  2269. *
  2270. * Parse-Server 3.1.3+ Required for original object parameter
  2271. *
  2272. * <pre>
  2273. * subscription.on('update', (object, original, response) => {
  2274. *
  2275. * });</pre></p>
  2276. *
  2277. * <p>Enter Event - When an existing ParseObject's (original) old value doesn't fulfill the ParseQuery
  2278. * but its new value fulfills the ParseQuery, you'll get this event. The object is the
  2279. * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject.
  2280. *
  2281. * Parse-Server 3.1.3+ Required for original object parameter
  2282. *
  2283. * <pre>
  2284. * subscription.on('enter', (object, original, response) => {
  2285. *
  2286. * });</pre></p>
  2287. *
  2288. *
  2289. * <p>Update Event - When an existing ParseObject's old value fulfills the ParseQuery but its new value
  2290. * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject
  2291. * which leaves the ParseQuery. Its content is the latest value of the ParseObject.
  2292. *
  2293. * <pre>
  2294. * subscription.on('leave', (object, response) => {
  2295. *
  2296. * });</pre></p>
  2297. *
  2298. *
  2299. * <p>Delete Event - When an existing ParseObject which fulfills the ParseQuery is deleted, you'll
  2300. * get this event. The object is the ParseObject which is deleted.
  2301. *
  2302. * <pre>
  2303. * subscription.on('delete', (object, response) => {
  2304. *
  2305. * });</pre></p>
  2306. *
  2307. *
  2308. * <p>Close Event - When the client loses the WebSocket connection to the LiveQuery
  2309. * server and we stop receiving events, you'll get this event.
  2310. *
  2311. * <pre>
  2312. * subscription.on('close', () => {
  2313. *
  2314. * });</pre></p>
  2315. *
  2316. * @alias Parse.LiveQuerySubscription
  2317. */
  2318. var Subscription = /*#__PURE__*/function (_EventEmitter) {
  2319. (0, _inherits2.default)(Subscription, _EventEmitter);
  2320. var _super = _createSuper(Subscription);
  2321. /*
  2322. * @param {string} id - subscription id
  2323. * @param {string} query - query to subscribe to
  2324. * @param {string} sessionToken - optional session token
  2325. */
  2326. function Subscription(id, query, sessionToken) {
  2327. var _this;
  2328. (0, _classCallCheck2.default)(this, Subscription);
  2329. _this = _super.call(this);
  2330. _this.id = id;
  2331. _this.query = query;
  2332. _this.sessionToken = sessionToken;
  2333. _this.subscribePromise = (0, _promiseUtils.resolvingPromise)();
  2334. _this.unsubscribePromise = (0, _promiseUtils.resolvingPromise)();
  2335. _this.subscribed = false;
  2336. // adding listener so process does not crash
  2337. // best practice is for developer to register their own listener
  2338. _this.on('error', function () {});
  2339. return _this;
  2340. }
  2341. /**
  2342. * Close the subscription
  2343. *
  2344. * @returns {Promise}
  2345. */
  2346. (0, _createClass2.default)(Subscription, [{
  2347. key: "unsubscribe",
  2348. value: function () /*: Promise*/{
  2349. var _this2 = this;
  2350. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(function (liveQueryClient) {
  2351. _this2.emit('close');
  2352. return liveQueryClient.unsubscribe(_this2);
  2353. });
  2354. }
  2355. }]);
  2356. return Subscription;
  2357. }(_EventEmitter2.default);
  2358. var _default = Subscription;
  2359. exports.default = _default;
  2360. },{"./CoreManager":4,"./EventEmitter":6,"./promiseUtils":52,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":92,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/getPrototypeOf":128,"@babel/runtime-corejs3/helpers/inherits":129,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":137}],12:[function(_dereq_,module,exports){
  2361. "use strict";
  2362. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  2363. var _Array$from2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  2364. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  2365. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  2366. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  2367. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  2368. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  2369. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  2370. var _set = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set"));
  2371. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  2372. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  2373. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  2374. var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  2375. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  2376. var _keys3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  2377. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  2378. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  2379. var _from = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/from"));
  2380. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  2381. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  2382. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  2383. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  2384. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  2385. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  2386. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  2387. function _createForOfIteratorHelper(o, allowArrayLike) {
  2388. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  2389. if (!it) {
  2390. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  2391. if (it) o = it;
  2392. var i = 0;
  2393. var F = function () {};
  2394. return {
  2395. s: F,
  2396. n: function () {
  2397. if (i >= o.length) return {
  2398. done: true
  2399. };
  2400. return {
  2401. done: false,
  2402. value: o[i++]
  2403. };
  2404. },
  2405. e: function (_e) {
  2406. throw _e;
  2407. },
  2408. f: F
  2409. };
  2410. }
  2411. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2412. }
  2413. var normalCompletion = true,
  2414. didErr = false,
  2415. err;
  2416. return {
  2417. s: function () {
  2418. it = it.call(o);
  2419. },
  2420. n: function () {
  2421. var step = it.next();
  2422. normalCompletion = step.done;
  2423. return step;
  2424. },
  2425. e: function (_e2) {
  2426. didErr = true;
  2427. err = _e2;
  2428. },
  2429. f: function () {
  2430. try {
  2431. if (!normalCompletion && it.return != null) it.return();
  2432. } finally {
  2433. if (didErr) throw err;
  2434. }
  2435. }
  2436. };
  2437. }
  2438. function _unsupportedIterableToArray(o, minLen) {
  2439. var _context16;
  2440. if (!o) return;
  2441. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  2442. var n = _sliceInstanceProperty(_context16 = Object.prototype.toString.call(o)).call(_context16, 8, -1);
  2443. if (n === "Object" && o.constructor) n = o.constructor.name;
  2444. if (n === "Map" || n === "Set") return _Array$from2(o);
  2445. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  2446. }
  2447. function _arrayLikeToArray(arr, len) {
  2448. if (len == null || len > arr.length) len = arr.length;
  2449. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  2450. return arr2;
  2451. } /**
  2452. * @flow
  2453. */ /*:: import type ParseObject from './ParseObject';*/
  2454. /**
  2455. * Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
  2456. * To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
  2457. *
  2458. * Pin object to add to local datastore
  2459. *
  2460. * <pre>await object.pin();</pre>
  2461. * <pre>await object.pinWithName('pinName');</pre>
  2462. *
  2463. * Query pinned objects
  2464. *
  2465. * <pre>query.fromLocalDatastore();</pre>
  2466. * <pre>query.fromPin();</pre>
  2467. * <pre>query.fromPinWithName();</pre>
  2468. *
  2469. * <pre>const localObjects = await query.find();</pre>
  2470. *
  2471. * @class Parse.LocalDatastore
  2472. * @static
  2473. */
  2474. var LocalDatastore = {
  2475. isEnabled: false,
  2476. isSyncing: false,
  2477. fromPinWithName: function (name /*: string*/) /*: Promise<Array<Object>>*/{
  2478. var controller = _CoreManager.default.getLocalDatastoreController();
  2479. return controller.fromPinWithName(name);
  2480. },
  2481. pinWithName: function (name /*: string*/, value /*: any*/) /*: Promise<void>*/{
  2482. var controller = _CoreManager.default.getLocalDatastoreController();
  2483. return controller.pinWithName(name, value);
  2484. },
  2485. unPinWithName: function (name /*: string*/) /*: Promise<void>*/{
  2486. var controller = _CoreManager.default.getLocalDatastoreController();
  2487. return controller.unPinWithName(name);
  2488. },
  2489. _getAllContents: function () /*: Promise<Object>*/{
  2490. var controller = _CoreManager.default.getLocalDatastoreController();
  2491. return controller.getAllContents();
  2492. },
  2493. // Use for testing
  2494. _getRawStorage: function () /*: Promise<Object>*/{
  2495. var controller = _CoreManager.default.getLocalDatastoreController();
  2496. return controller.getRawStorage();
  2497. },
  2498. _clear: function () /*: Promise<void>*/{
  2499. var controller = _CoreManager.default.getLocalDatastoreController();
  2500. return controller.clear();
  2501. },
  2502. // Pin the object and children recursively
  2503. // Saves the object and children key to Pin Name
  2504. _handlePinAllWithName: function (name /*: string*/, objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
  2505. var _this = this;
  2506. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  2507. var _context;
  2508. var pinName, toPinPromises, objectKeys, _iterator, _step, parent, children, parentKey, json, objectKey, fromPinPromise, _yield$Promise$all, _yield$Promise$all2, pinned, toPin;
  2509. return _regenerator.default.wrap(function (_context2) {
  2510. while (1) switch (_context2.prev = _context2.next) {
  2511. case 0:
  2512. pinName = _this.getPinName(name);
  2513. toPinPromises = [];
  2514. objectKeys = [];
  2515. _iterator = _createForOfIteratorHelper(objects);
  2516. try {
  2517. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  2518. parent = _step.value;
  2519. children = _this._getChildren(parent);
  2520. parentKey = _this.getKeyForObject(parent);
  2521. json = parent._toFullJSON(undefined, true);
  2522. if (parent._localId) {
  2523. json._localId = parent._localId;
  2524. }
  2525. children[parentKey] = json;
  2526. for (objectKey in children) {
  2527. objectKeys.push(objectKey);
  2528. toPinPromises.push(_this.pinWithName(objectKey, [children[objectKey]]));
  2529. }
  2530. }
  2531. } catch (err) {
  2532. _iterator.e(err);
  2533. } finally {
  2534. _iterator.f();
  2535. }
  2536. fromPinPromise = _this.fromPinWithName(pinName);
  2537. _context2.next = 8;
  2538. return _promise.default.all([fromPinPromise, toPinPromises]);
  2539. case 8:
  2540. _yield$Promise$all = _context2.sent;
  2541. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1);
  2542. pinned = _yield$Promise$all2[0];
  2543. toPin = (0, _toConsumableArray2.default)(new _set.default((0, _concat.default)(_context = []).call(_context, (0, _toConsumableArray2.default)(pinned || []), objectKeys)));
  2544. return _context2.abrupt("return", _this.pinWithName(pinName, toPin));
  2545. case 13:
  2546. case "end":
  2547. return _context2.stop();
  2548. }
  2549. }, _callee);
  2550. }))();
  2551. },
  2552. // Removes object and children keys from pin name
  2553. // Keeps the object and children pinned
  2554. _handleUnPinAllWithName: function (name /*: string*/, objects /*: Array<ParseObject>*/) {
  2555. var _this2 = this;
  2556. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  2557. var localDatastore, pinName, promises, objectKeys, _iterator2, _step2, _objectKeys, _context3, parent, children, parentKey, pinned, _iterator3, _step3, objectKey, hasReference, key, pinnedObjects;
  2558. return _regenerator.default.wrap(function (_context4) {
  2559. while (1) switch (_context4.prev = _context4.next) {
  2560. case 0:
  2561. _context4.next = 2;
  2562. return _this2._getAllContents();
  2563. case 2:
  2564. localDatastore = _context4.sent;
  2565. pinName = _this2.getPinName(name);
  2566. promises = [];
  2567. objectKeys = [];
  2568. _iterator2 = _createForOfIteratorHelper(objects);
  2569. try {
  2570. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  2571. parent = _step2.value;
  2572. children = _this2._getChildren(parent);
  2573. parentKey = _this2.getKeyForObject(parent);
  2574. (_objectKeys = objectKeys).push.apply(_objectKeys, (0, _concat.default)(_context3 = [parentKey]).call(_context3, (0, _toConsumableArray2.default)((0, _keys2.default)(children))));
  2575. }
  2576. } catch (err) {
  2577. _iterator2.e(err);
  2578. } finally {
  2579. _iterator2.f();
  2580. }
  2581. objectKeys = (0, _toConsumableArray2.default)(new _set.default(objectKeys));
  2582. pinned = localDatastore[pinName] || [];
  2583. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  2584. return !(0, _includes.default)(objectKeys).call(objectKeys, item);
  2585. });
  2586. if (pinned.length == 0) {
  2587. promises.push(_this2.unPinWithName(pinName));
  2588. delete localDatastore[pinName];
  2589. } else {
  2590. promises.push(_this2.pinWithName(pinName, pinned));
  2591. localDatastore[pinName] = pinned;
  2592. }
  2593. _iterator3 = _createForOfIteratorHelper(objectKeys);
  2594. _context4.prev = 13;
  2595. _iterator3.s();
  2596. case 15:
  2597. if ((_step3 = _iterator3.n()).done) {
  2598. _context4.next = 31;
  2599. break;
  2600. }
  2601. objectKey = _step3.value;
  2602. hasReference = false;
  2603. _context4.t0 = (0, _keys3.default)(_regenerator.default).call(_regenerator.default, localDatastore);
  2604. case 19:
  2605. if ((_context4.t1 = _context4.t0()).done) {
  2606. _context4.next = 28;
  2607. break;
  2608. }
  2609. key = _context4.t1.value;
  2610. if (!(key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX))) {
  2611. _context4.next = 26;
  2612. break;
  2613. }
  2614. pinnedObjects = localDatastore[key] || [];
  2615. if (!(0, _includes.default)(pinnedObjects).call(pinnedObjects, objectKey)) {
  2616. _context4.next = 26;
  2617. break;
  2618. }
  2619. hasReference = true;
  2620. return _context4.abrupt("break", 28);
  2621. case 26:
  2622. _context4.next = 19;
  2623. break;
  2624. case 28:
  2625. if (!hasReference) {
  2626. promises.push(_this2.unPinWithName(objectKey));
  2627. }
  2628. case 29:
  2629. _context4.next = 15;
  2630. break;
  2631. case 31:
  2632. _context4.next = 36;
  2633. break;
  2634. case 33:
  2635. _context4.prev = 33;
  2636. _context4.t2 = _context4["catch"](13);
  2637. _iterator3.e(_context4.t2);
  2638. case 36:
  2639. _context4.prev = 36;
  2640. _iterator3.f();
  2641. return _context4.finish(36);
  2642. case 39:
  2643. return _context4.abrupt("return", _promise.default.all(promises));
  2644. case 40:
  2645. case "end":
  2646. return _context4.stop();
  2647. }
  2648. }, _callee2, null, [[13, 33, 36, 39]]);
  2649. }))();
  2650. },
  2651. // Retrieve all pointer fields from object recursively
  2652. _getChildren: function (object /*: ParseObject*/) {
  2653. var encountered = {};
  2654. var json = object._toFullJSON(undefined, true);
  2655. for (var key in json) {
  2656. if (json[key] && json[key].__type && json[key].__type === 'Object') {
  2657. this._traverse(json[key], encountered);
  2658. }
  2659. }
  2660. return encountered;
  2661. },
  2662. _traverse: function (object /*: any*/, encountered /*: any*/) {
  2663. if (!object.objectId) {
  2664. return;
  2665. } else {
  2666. var objectKey = this.getKeyForObject(object);
  2667. if (encountered[objectKey]) {
  2668. return;
  2669. }
  2670. encountered[objectKey] = object;
  2671. }
  2672. for (var key in object) {
  2673. var json = object[key];
  2674. if (!object[key]) {
  2675. json = object;
  2676. }
  2677. if (json.__type && json.__type === 'Object') {
  2678. this._traverse(json, encountered);
  2679. }
  2680. }
  2681. },
  2682. // Transform keys in pin name to objects
  2683. _serializeObjectsFromPinName: function (name /*: string*/) {
  2684. var _this3 = this;
  2685. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  2686. var _ref;
  2687. var localDatastore, allObjects, key, pinName, pinned, promises, objects;
  2688. return _regenerator.default.wrap(function (_context5) {
  2689. while (1) switch (_context5.prev = _context5.next) {
  2690. case 0:
  2691. _context5.next = 2;
  2692. return _this3._getAllContents();
  2693. case 2:
  2694. localDatastore = _context5.sent;
  2695. allObjects = [];
  2696. for (key in localDatastore) {
  2697. if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
  2698. allObjects.push(localDatastore[key][0]);
  2699. }
  2700. }
  2701. if (name) {
  2702. _context5.next = 7;
  2703. break;
  2704. }
  2705. return _context5.abrupt("return", allObjects);
  2706. case 7:
  2707. pinName = _this3.getPinName(name);
  2708. pinned = localDatastore[pinName];
  2709. if ((0, _isArray.default)(pinned)) {
  2710. _context5.next = 11;
  2711. break;
  2712. }
  2713. return _context5.abrupt("return", []);
  2714. case 11:
  2715. promises = (0, _map.default)(pinned).call(pinned, function (objectKey) {
  2716. return _this3.fromPinWithName(objectKey);
  2717. });
  2718. _context5.next = 14;
  2719. return _promise.default.all(promises);
  2720. case 14:
  2721. objects = _context5.sent;
  2722. objects = (0, _concat.default)(_ref = []).apply(_ref, (0, _toConsumableArray2.default)(objects));
  2723. return _context5.abrupt("return", (0, _filter.default)(objects).call(objects, function (object) {
  2724. return object != null;
  2725. }));
  2726. case 17:
  2727. case "end":
  2728. return _context5.stop();
  2729. }
  2730. }, _callee3);
  2731. }))();
  2732. },
  2733. // Replaces object pointers with pinned pointers
  2734. // The object pointers may contain old data
  2735. // Uses Breadth First Search Algorithm
  2736. _serializeObject: function (objectKey /*: string*/, localDatastore /*: any*/) {
  2737. var _this4 = this;
  2738. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
  2739. var LDS, root, queue, meta, uniqueId, nodeId, subTreeRoot, field, value, key, pointer;
  2740. return _regenerator.default.wrap(function (_context6) {
  2741. while (1) switch (_context6.prev = _context6.next) {
  2742. case 0:
  2743. LDS = localDatastore;
  2744. if (LDS) {
  2745. _context6.next = 5;
  2746. break;
  2747. }
  2748. _context6.next = 4;
  2749. return _this4._getAllContents();
  2750. case 4:
  2751. LDS = _context6.sent;
  2752. case 5:
  2753. if (!(!LDS[objectKey] || LDS[objectKey].length === 0)) {
  2754. _context6.next = 7;
  2755. break;
  2756. }
  2757. return _context6.abrupt("return", null);
  2758. case 7:
  2759. root = LDS[objectKey][0];
  2760. queue = [];
  2761. meta = {};
  2762. uniqueId = 0;
  2763. meta[uniqueId] = root;
  2764. queue.push(uniqueId);
  2765. while (queue.length !== 0) {
  2766. nodeId = queue.shift();
  2767. subTreeRoot = meta[nodeId];
  2768. for (field in subTreeRoot) {
  2769. value = subTreeRoot[field];
  2770. if (value.__type && value.__type === 'Object') {
  2771. key = _this4.getKeyForObject(value);
  2772. if (LDS[key] && LDS[key].length > 0) {
  2773. pointer = LDS[key][0];
  2774. uniqueId++;
  2775. meta[uniqueId] = pointer;
  2776. subTreeRoot[field] = pointer;
  2777. queue.push(uniqueId);
  2778. }
  2779. }
  2780. }
  2781. }
  2782. return _context6.abrupt("return", root);
  2783. case 15:
  2784. case "end":
  2785. return _context6.stop();
  2786. }
  2787. }, _callee4);
  2788. }))();
  2789. },
  2790. // Called when an object is save / fetched
  2791. // Update object pin value
  2792. _updateObjectIfPinned: function (object /*: ParseObject*/) /*: Promise<void>*/{
  2793. var _this5 = this;
  2794. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  2795. var objectKey, pinned;
  2796. return _regenerator.default.wrap(function (_context7) {
  2797. while (1) switch (_context7.prev = _context7.next) {
  2798. case 0:
  2799. if (_this5.isEnabled) {
  2800. _context7.next = 2;
  2801. break;
  2802. }
  2803. return _context7.abrupt("return");
  2804. case 2:
  2805. objectKey = _this5.getKeyForObject(object);
  2806. _context7.next = 5;
  2807. return _this5.fromPinWithName(objectKey);
  2808. case 5:
  2809. pinned = _context7.sent;
  2810. if (!(!pinned || pinned.length === 0)) {
  2811. _context7.next = 8;
  2812. break;
  2813. }
  2814. return _context7.abrupt("return");
  2815. case 8:
  2816. return _context7.abrupt("return", _this5.pinWithName(objectKey, [object._toFullJSON()]));
  2817. case 9:
  2818. case "end":
  2819. return _context7.stop();
  2820. }
  2821. }, _callee5);
  2822. }))();
  2823. },
  2824. // Called when object is destroyed
  2825. // Unpin object and remove all references from pin names
  2826. // TODO: Destroy children?
  2827. _destroyObjectIfPinned: function (object /*: ParseObject*/) {
  2828. var _this6 = this;
  2829. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  2830. var localDatastore, objectKey, pin, promises, key, pinned;
  2831. return _regenerator.default.wrap(function (_context8) {
  2832. while (1) switch (_context8.prev = _context8.next) {
  2833. case 0:
  2834. if (_this6.isEnabled) {
  2835. _context8.next = 2;
  2836. break;
  2837. }
  2838. return _context8.abrupt("return");
  2839. case 2:
  2840. _context8.next = 4;
  2841. return _this6._getAllContents();
  2842. case 4:
  2843. localDatastore = _context8.sent;
  2844. objectKey = _this6.getKeyForObject(object);
  2845. pin = localDatastore[objectKey];
  2846. if (pin) {
  2847. _context8.next = 9;
  2848. break;
  2849. }
  2850. return _context8.abrupt("return");
  2851. case 9:
  2852. promises = [_this6.unPinWithName(objectKey)];
  2853. delete localDatastore[objectKey];
  2854. for (key in localDatastore) {
  2855. if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
  2856. pinned = localDatastore[key] || [];
  2857. if ((0, _includes.default)(pinned).call(pinned, objectKey)) {
  2858. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  2859. return item !== objectKey;
  2860. });
  2861. if (pinned.length == 0) {
  2862. promises.push(_this6.unPinWithName(key));
  2863. delete localDatastore[key];
  2864. } else {
  2865. promises.push(_this6.pinWithName(key, pinned));
  2866. localDatastore[key] = pinned;
  2867. }
  2868. }
  2869. }
  2870. }
  2871. return _context8.abrupt("return", _promise.default.all(promises));
  2872. case 13:
  2873. case "end":
  2874. return _context8.stop();
  2875. }
  2876. }, _callee6);
  2877. }))();
  2878. },
  2879. // Update pin and references of the unsaved object
  2880. _updateLocalIdForObject: function (localId /*: string*/, object /*: ParseObject*/) {
  2881. var _this7 = this;
  2882. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
  2883. var _context9, _context10;
  2884. var localKey, objectKey, unsaved, promises, localDatastore, key, pinned;
  2885. return _regenerator.default.wrap(function (_context11) {
  2886. while (1) switch (_context11.prev = _context11.next) {
  2887. case 0:
  2888. if (_this7.isEnabled) {
  2889. _context11.next = 2;
  2890. break;
  2891. }
  2892. return _context11.abrupt("return");
  2893. case 2:
  2894. localKey = (0, _concat.default)(_context9 = (0, _concat.default)(_context10 = "".concat(_LocalDatastoreUtils.OBJECT_PREFIX)).call(_context10, object.className, "_")).call(_context9, localId);
  2895. objectKey = _this7.getKeyForObject(object);
  2896. _context11.next = 6;
  2897. return _this7.fromPinWithName(localKey);
  2898. case 6:
  2899. unsaved = _context11.sent;
  2900. if (!(!unsaved || unsaved.length === 0)) {
  2901. _context11.next = 9;
  2902. break;
  2903. }
  2904. return _context11.abrupt("return");
  2905. case 9:
  2906. promises = [_this7.unPinWithName(localKey), _this7.pinWithName(objectKey, unsaved)];
  2907. _context11.next = 12;
  2908. return _this7._getAllContents();
  2909. case 12:
  2910. localDatastore = _context11.sent;
  2911. for (key in localDatastore) {
  2912. if (key === _LocalDatastoreUtils.DEFAULT_PIN || (0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.PIN_PREFIX)) {
  2913. pinned = localDatastore[key] || [];
  2914. if ((0, _includes.default)(pinned).call(pinned, localKey)) {
  2915. pinned = (0, _filter.default)(pinned).call(pinned, function (item) {
  2916. return item !== localKey;
  2917. });
  2918. pinned.push(objectKey);
  2919. promises.push(_this7.pinWithName(key, pinned));
  2920. localDatastore[key] = pinned;
  2921. }
  2922. }
  2923. }
  2924. return _context11.abrupt("return", _promise.default.all(promises));
  2925. case 15:
  2926. case "end":
  2927. return _context11.stop();
  2928. }
  2929. }, _callee7);
  2930. }))();
  2931. },
  2932. /**
  2933. * Updates Local Datastore from Server
  2934. *
  2935. * <pre>
  2936. * await Parse.LocalDatastore.updateFromServer();
  2937. * </pre>
  2938. *
  2939. * @function updateFromServer
  2940. * @name Parse.LocalDatastore.updateFromServer
  2941. * @static
  2942. */
  2943. updateFromServer: function () {
  2944. var _this8 = this;
  2945. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
  2946. var _context12;
  2947. var localDatastore, keys, key, pointersHash, _i, _keys, _key, _key$split, _key$split2, className, objectId, queryPromises, responses, objects, pinPromises;
  2948. return _regenerator.default.wrap(function (_context13) {
  2949. while (1) switch (_context13.prev = _context13.next) {
  2950. case 0:
  2951. if (!(!_this8.checkIfEnabled() || _this8.isSyncing)) {
  2952. _context13.next = 2;
  2953. break;
  2954. }
  2955. return _context13.abrupt("return");
  2956. case 2:
  2957. _context13.next = 4;
  2958. return _this8._getAllContents();
  2959. case 4:
  2960. localDatastore = _context13.sent;
  2961. keys = [];
  2962. for (key in localDatastore) {
  2963. if ((0, _startsWith.default)(key).call(key, _LocalDatastoreUtils.OBJECT_PREFIX)) {
  2964. keys.push(key);
  2965. }
  2966. }
  2967. if (!(keys.length === 0)) {
  2968. _context13.next = 9;
  2969. break;
  2970. }
  2971. return _context13.abrupt("return");
  2972. case 9:
  2973. _this8.isSyncing = true;
  2974. pointersHash = {};
  2975. _i = 0, _keys = keys;
  2976. case 12:
  2977. if (!(_i < _keys.length)) {
  2978. _context13.next = 23;
  2979. break;
  2980. }
  2981. _key = _keys[_i];
  2982. // Ignore the OBJECT_PREFIX
  2983. _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' ]
  2984. if (_key.split('_').length === 5 && _key.split('_')[3] === 'User') {
  2985. className = '_User';
  2986. objectId = _key.split('_')[4];
  2987. }
  2988. if (!(0, _startsWith.default)(objectId).call(objectId, 'local')) {
  2989. _context13.next = 18;
  2990. break;
  2991. }
  2992. return _context13.abrupt("continue", 20);
  2993. case 18:
  2994. if (!(className in pointersHash)) {
  2995. pointersHash[className] = new _set.default();
  2996. }
  2997. pointersHash[className].add(objectId);
  2998. case 20:
  2999. _i++;
  3000. _context13.next = 12;
  3001. break;
  3002. case 23:
  3003. queryPromises = (0, _map.default)(_context12 = (0, _keys2.default)(pointersHash)).call(_context12, function (className) {
  3004. var objectIds = (0, _from.default)(pointersHash[className]);
  3005. var query = new _ParseQuery.default(className);
  3006. query.limit(objectIds.length);
  3007. if (objectIds.length === 1) {
  3008. query.equalTo('objectId', objectIds[0]);
  3009. } else {
  3010. query.containedIn('objectId', objectIds);
  3011. }
  3012. return (0, _find.default)(query).call(query);
  3013. });
  3014. _context13.prev = 24;
  3015. _context13.next = 27;
  3016. return _promise.default.all(queryPromises);
  3017. case 27:
  3018. responses = _context13.sent;
  3019. objects = (0, _concat.default)([]).apply([], responses);
  3020. pinPromises = (0, _map.default)(objects).call(objects, function (object) {
  3021. var objectKey = _this8.getKeyForObject(object);
  3022. return _this8.pinWithName(objectKey, object._toFullJSON());
  3023. });
  3024. _context13.next = 32;
  3025. return _promise.default.all(pinPromises);
  3026. case 32:
  3027. _this8.isSyncing = false;
  3028. _context13.next = 39;
  3029. break;
  3030. case 35:
  3031. _context13.prev = 35;
  3032. _context13.t0 = _context13["catch"](24);
  3033. console.error('Error syncing LocalDatastore: ', _context13.t0);
  3034. _this8.isSyncing = false;
  3035. case 39:
  3036. case "end":
  3037. return _context13.stop();
  3038. }
  3039. }, _callee8, null, [[24, 35]]);
  3040. }))();
  3041. },
  3042. getKeyForObject: function (object /*: any*/) {
  3043. var _context14, _context15;
  3044. var objectId = object.objectId || object._getId();
  3045. return (0, _concat.default)(_context14 = (0, _concat.default)(_context15 = "".concat(_LocalDatastoreUtils.OBJECT_PREFIX)).call(_context15, object.className, "_")).call(_context14, objectId);
  3046. },
  3047. getPinName: function (pinName /*: ?string*/) {
  3048. if (!pinName || pinName === _LocalDatastoreUtils.DEFAULT_PIN) {
  3049. return _LocalDatastoreUtils.DEFAULT_PIN;
  3050. }
  3051. return _LocalDatastoreUtils.PIN_PREFIX + pinName;
  3052. },
  3053. checkIfEnabled: function () {
  3054. if (!this.isEnabled) {
  3055. console.error('Parse.enableLocalDatastore() must be called first');
  3056. }
  3057. return this.isEnabled;
  3058. }
  3059. };
  3060. module.exports = LocalDatastore;
  3061. _CoreManager.default.setLocalDatastoreController(_dereq_('./LocalDatastoreController'));
  3062. _CoreManager.default.setLocalDatastore(LocalDatastore);
  3063. },{"./CoreManager":4,"./LocalDatastoreController":13,"./LocalDatastoreUtils":14,"./ParseQuery":29,"@babel/runtime-corejs3/core-js-stable/array/from":56,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/concat":59,"@babel/runtime-corejs3/core-js-stable/instance/filter":62,"@babel/runtime-corejs3/core-js-stable/instance/find":64,"@babel/runtime-corejs3/core-js-stable/instance/includes":66,"@babel/runtime-corejs3/core-js-stable/instance/keys":68,"@babel/runtime-corejs3/core-js-stable/instance/map":69,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":74,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/core-js-stable/set":95,"@babel/runtime-corejs3/core-js-stable/symbol":96,"@babel/runtime-corejs3/core-js/get-iterator-method":100,"@babel/runtime-corejs3/helpers/asyncToGenerator":122,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/slicedToArray":140,"@babel/runtime-corejs3/helpers/toConsumableArray":142,"@babel/runtime-corejs3/regenerator":148}],13:[function(_dereq_,module,exports){
  3064. "use strict";
  3065. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  3066. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  3067. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  3068. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  3069. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  3070. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3071. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  3072. var _reduce = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
  3073. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  3074. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  3075. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  3076. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  3077. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  3078. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  3079. function _createForOfIteratorHelper(o, allowArrayLike) {
  3080. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  3081. if (!it) {
  3082. if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  3083. if (it) o = it;
  3084. var i = 0;
  3085. var F = function () {};
  3086. return {
  3087. s: F,
  3088. n: function () {
  3089. if (i >= o.length) return {
  3090. done: true
  3091. };
  3092. return {
  3093. done: false,
  3094. value: o[i++]
  3095. };
  3096. },
  3097. e: function (_e) {
  3098. throw _e;
  3099. },
  3100. f: F
  3101. };
  3102. }
  3103. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3104. }
  3105. var normalCompletion = true,
  3106. didErr = false,
  3107. err;
  3108. return {
  3109. s: function () {
  3110. it = it.call(o);
  3111. },
  3112. n: function () {
  3113. var step = it.next();
  3114. normalCompletion = step.done;
  3115. return step;
  3116. },
  3117. e: function (_e2) {
  3118. didErr = true;
  3119. err = _e2;
  3120. },
  3121. f: function () {
  3122. try {
  3123. if (!normalCompletion && it.return != null) it.return();
  3124. } finally {
  3125. if (didErr) throw err;
  3126. }
  3127. }
  3128. };
  3129. }
  3130. function _unsupportedIterableToArray(o, minLen) {
  3131. var _context7;
  3132. if (!o) return;
  3133. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  3134. var n = _sliceInstanceProperty(_context7 = Object.prototype.toString.call(o)).call(_context7, 8, -1);
  3135. if (n === "Object" && o.constructor) n = o.constructor.name;
  3136. if (n === "Map" || n === "Set") return _Array$from(o);
  3137. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  3138. }
  3139. function _arrayLikeToArray(arr, len) {
  3140. if (len == null || len > arr.length) len = arr.length;
  3141. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  3142. return arr2;
  3143. } /**
  3144. * @flow
  3145. */
  3146. var LocalDatastoreController = {
  3147. fromPinWithName: function (name /*: string*/) /*: Array<Object>*/{
  3148. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  3149. var values, objects;
  3150. return _regenerator.default.wrap(function (_context) {
  3151. while (1) switch (_context.prev = _context.next) {
  3152. case 0:
  3153. _context.next = 2;
  3154. return _Storage.default.getItemAsync(name);
  3155. case 2:
  3156. values = _context.sent;
  3157. if (values) {
  3158. _context.next = 5;
  3159. break;
  3160. }
  3161. return _context.abrupt("return", []);
  3162. case 5:
  3163. objects = JSON.parse(values);
  3164. return _context.abrupt("return", objects);
  3165. case 7:
  3166. case "end":
  3167. return _context.stop();
  3168. }
  3169. }, _callee);
  3170. }))();
  3171. },
  3172. pinWithName: function (name /*: string*/, value /*: any*/) {
  3173. var values = (0, _stringify.default)(value);
  3174. return _Storage.default.setItemAsync(name, values);
  3175. },
  3176. unPinWithName: function (name /*: string*/) {
  3177. return _Storage.default.removeItemAsync(name);
  3178. },
  3179. getAllContents: function () /*: Object*/{
  3180. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  3181. var keys;
  3182. return _regenerator.default.wrap(function (_context3) {
  3183. while (1) switch (_context3.prev = _context3.next) {
  3184. case 0:
  3185. _context3.next = 2;
  3186. return _Storage.default.getAllKeysAsync();
  3187. case 2:
  3188. keys = _context3.sent;
  3189. return _context3.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
  3190. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(previousPromise, key) {
  3191. var LDS, value;
  3192. return _regenerator.default.wrap(function (_context2) {
  3193. while (1) switch (_context2.prev = _context2.next) {
  3194. case 0:
  3195. _context2.next = 2;
  3196. return previousPromise;
  3197. case 2:
  3198. LDS = _context2.sent;
  3199. if (!(0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  3200. _context2.next = 8;
  3201. break;
  3202. }
  3203. _context2.next = 6;
  3204. return _Storage.default.getItemAsync(key);
  3205. case 6:
  3206. value = _context2.sent;
  3207. try {
  3208. LDS[key] = JSON.parse(value);
  3209. } catch (error) {
  3210. console.error('Error getAllContents: ', error);
  3211. }
  3212. case 8:
  3213. return _context2.abrupt("return", LDS);
  3214. case 9:
  3215. case "end":
  3216. return _context2.stop();
  3217. }
  3218. }, _callee2);
  3219. }));
  3220. return function () {
  3221. return _ref.apply(this, arguments);
  3222. };
  3223. }(), _promise.default.resolve({})));
  3224. case 4:
  3225. case "end":
  3226. return _context3.stop();
  3227. }
  3228. }, _callee3);
  3229. }))();
  3230. },
  3231. // Used for testing
  3232. getRawStorage: function () /*: Object*/{
  3233. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  3234. var keys;
  3235. return _regenerator.default.wrap(function (_context5) {
  3236. while (1) switch (_context5.prev = _context5.next) {
  3237. case 0:
  3238. _context5.next = 2;
  3239. return _Storage.default.getAllKeysAsync();
  3240. case 2:
  3241. keys = _context5.sent;
  3242. return _context5.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
  3243. var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(previousPromise, key) {
  3244. var LDS, value;
  3245. return _regenerator.default.wrap(function (_context4) {
  3246. while (1) switch (_context4.prev = _context4.next) {
  3247. case 0:
  3248. _context4.next = 2;
  3249. return previousPromise;
  3250. case 2:
  3251. LDS = _context4.sent;
  3252. _context4.next = 5;
  3253. return _Storage.default.getItemAsync(key);
  3254. case 5:
  3255. value = _context4.sent;
  3256. LDS[key] = value;
  3257. return _context4.abrupt("return", LDS);
  3258. case 8:
  3259. case "end":
  3260. return _context4.stop();
  3261. }
  3262. }, _callee4);
  3263. }));
  3264. return function () {
  3265. return _ref2.apply(this, arguments);
  3266. };
  3267. }(), _promise.default.resolve({})));
  3268. case 4:
  3269. case "end":
  3270. return _context5.stop();
  3271. }
  3272. }, _callee5);
  3273. }))();
  3274. },
  3275. clear: function () /*: Promise*/{
  3276. var _this = this;
  3277. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  3278. var keys, toRemove, _iterator, _step, key, promises;
  3279. return _regenerator.default.wrap(function (_context6) {
  3280. while (1) switch (_context6.prev = _context6.next) {
  3281. case 0:
  3282. _context6.next = 2;
  3283. return _Storage.default.getAllKeysAsync();
  3284. case 2:
  3285. keys = _context6.sent;
  3286. toRemove = [];
  3287. _iterator = _createForOfIteratorHelper(keys);
  3288. try {
  3289. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3290. key = _step.value;
  3291. if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
  3292. toRemove.push(key);
  3293. }
  3294. }
  3295. } catch (err) {
  3296. _iterator.e(err);
  3297. } finally {
  3298. _iterator.f();
  3299. }
  3300. promises = (0, _map.default)(toRemove).call(toRemove, _this.unPinWithName);
  3301. return _context6.abrupt("return", _promise.default.all(promises));
  3302. case 8:
  3303. case "end":
  3304. return _context6.stop();
  3305. }
  3306. }, _callee6);
  3307. }))();
  3308. }
  3309. };
  3310. module.exports = LocalDatastoreController;
  3311. },{"./LocalDatastoreUtils":14,"./Storage":39,"@babel/runtime-corejs3/core-js-stable/array/from":56,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/map":69,"@babel/runtime-corejs3/core-js-stable/instance/reduce":70,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/core-js-stable/symbol":96,"@babel/runtime-corejs3/core-js/get-iterator-method":100,"@babel/runtime-corejs3/helpers/asyncToGenerator":122,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/regenerator":148}],14:[function(_dereq_,module,exports){
  3312. "use strict";
  3313. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3314. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3315. _Object$defineProperty(exports, "__esModule", {
  3316. value: true
  3317. });
  3318. exports.PIN_PREFIX = exports.OBJECT_PREFIX = exports.DEFAULT_PIN = void 0;
  3319. exports.isLocalDatastoreKey = isLocalDatastoreKey;
  3320. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  3321. /**
  3322. * @flow
  3323. * @private
  3324. */
  3325. var DEFAULT_PIN = '_default';
  3326. exports.DEFAULT_PIN = DEFAULT_PIN;
  3327. var PIN_PREFIX = 'parsePin_';
  3328. exports.PIN_PREFIX = PIN_PREFIX;
  3329. var OBJECT_PREFIX = 'Parse_LDS_';
  3330. exports.OBJECT_PREFIX = OBJECT_PREFIX;
  3331. function isLocalDatastoreKey(key /*: string*/) /*: boolean*/{
  3332. return !!(key && (key === DEFAULT_PIN || (0, _startsWith.default)(key).call(key, PIN_PREFIX) || (0, _startsWith.default)(key).call(key, OBJECT_PREFIX)));
  3333. }
  3334. },{"@babel/runtime-corejs3/core-js-stable/instance/starts-with":74,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],15:[function(_dereq_,module,exports){
  3335. "use strict";
  3336. var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  3337. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  3338. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  3339. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  3340. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  3341. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  3342. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  3343. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  3344. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3345. _Object$defineProperty(exports, "__esModule", {
  3346. value: true
  3347. });
  3348. exports.commitServerChanges = commitServerChanges;
  3349. exports.defaultState = defaultState;
  3350. exports.estimateAttribute = estimateAttribute;
  3351. exports.estimateAttributes = estimateAttributes;
  3352. exports.mergeFirstPendingState = mergeFirstPendingState;
  3353. exports.popPendingState = popPendingState;
  3354. exports.pushPendingState = pushPendingState;
  3355. exports.setPendingOp = setPendingOp;
  3356. exports.setServerData = setServerData;
  3357. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  3358. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  3359. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  3360. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  3361. var _encode = _interopRequireDefault(_dereq_("./encode"));
  3362. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  3363. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  3364. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  3365. var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
  3366. var _ParseOp = _dereq_("./ParseOp");
  3367. function ownKeys(object, enumerableOnly) {
  3368. var keys = _Object$keys(object);
  3369. if (_Object$getOwnPropertySymbols) {
  3370. var symbols = _Object$getOwnPropertySymbols(object);
  3371. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  3372. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  3373. })), keys.push.apply(keys, symbols);
  3374. }
  3375. return keys;
  3376. }
  3377. function _objectSpread(target) {
  3378. for (var i = 1; i < arguments.length; i++) {
  3379. var _context, _context2;
  3380. var source = null != arguments[i] ? arguments[i] : {};
  3381. i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) {
  3382. (0, _defineProperty2.default)(target, key, source[key]);
  3383. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) {
  3384. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  3385. });
  3386. }
  3387. return target;
  3388. } /**
  3389. * @flow
  3390. */
  3391. /*:: import type { Op } from './ParseOp';*/
  3392. /*:: export type AttributeMap = { [attr: string]: any };*/
  3393. /*:: export type OpsMap = { [attr: string]: Op };*/
  3394. /*:: export type ObjectCache = { [attr: string]: string };*/
  3395. /*:: export type State = {
  3396. serverData: AttributeMap,
  3397. pendingOps: Array<OpsMap>,
  3398. objectCache: ObjectCache,
  3399. tasks: TaskQueue,
  3400. existed: boolean,
  3401. };*/
  3402. function defaultState() /*: State*/{
  3403. return {
  3404. serverData: {},
  3405. pendingOps: [{}],
  3406. objectCache: {},
  3407. tasks: new _TaskQueue.default(),
  3408. existed: false
  3409. };
  3410. }
  3411. function setServerData(serverData /*: AttributeMap*/, attributes /*: AttributeMap*/) {
  3412. for (var _attr in attributes) {
  3413. if (typeof attributes[_attr] !== 'undefined') {
  3414. serverData[_attr] = attributes[_attr];
  3415. } else {
  3416. delete serverData[_attr];
  3417. }
  3418. }
  3419. }
  3420. function setPendingOp(pendingOps /*: Array<OpsMap>*/, attr /*: string*/, op /*: ?Op*/) {
  3421. var last = pendingOps.length - 1;
  3422. if (op) {
  3423. pendingOps[last][attr] = op;
  3424. } else {
  3425. delete pendingOps[last][attr];
  3426. }
  3427. }
  3428. function pushPendingState(pendingOps /*: Array<OpsMap>*/) {
  3429. pendingOps.push({});
  3430. }
  3431. function popPendingState(pendingOps /*: Array<OpsMap>*/) /*: OpsMap*/{
  3432. var first = pendingOps.shift();
  3433. if (!pendingOps.length) {
  3434. pendingOps[0] = {};
  3435. }
  3436. return first;
  3437. }
  3438. function mergeFirstPendingState(pendingOps /*: Array<OpsMap>*/) {
  3439. var first = popPendingState(pendingOps);
  3440. var next = pendingOps[0];
  3441. for (var _attr2 in first) {
  3442. if (next[_attr2] && first[_attr2]) {
  3443. var merged = next[_attr2].mergeWith(first[_attr2]);
  3444. if (merged) {
  3445. next[_attr2] = merged;
  3446. }
  3447. } else {
  3448. next[_attr2] = first[_attr2];
  3449. }
  3450. }
  3451. }
  3452. function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/, attr /*: string*/) /*: mixed*/{
  3453. var value = serverData[attr];
  3454. for (var i = 0; i < pendingOps.length; i++) {
  3455. if (pendingOps[i][attr]) {
  3456. if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
  3457. if (id) {
  3458. value = pendingOps[i][attr].applyTo(value, {
  3459. className: className,
  3460. id: id
  3461. }, attr);
  3462. }
  3463. } else {
  3464. value = pendingOps[i][attr].applyTo(value);
  3465. }
  3466. }
  3467. }
  3468. return value;
  3469. }
  3470. function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, className /*: string*/, id /*: ?string*/) /*: AttributeMap*/{
  3471. var data = {};
  3472. for (var attr in serverData) {
  3473. data[attr] = serverData[attr];
  3474. }
  3475. for (var i = 0; i < pendingOps.length; i++) {
  3476. for (attr in pendingOps[i]) {
  3477. if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
  3478. if (id) {
  3479. data[attr] = pendingOps[i][attr].applyTo(data[attr], {
  3480. className: className,
  3481. id: id
  3482. }, attr);
  3483. }
  3484. } else {
  3485. if ((0, _includes.default)(attr).call(attr, '.')) {
  3486. // convert a.b.c into { a: { b: { c: value } } }
  3487. var fields = attr.split('.');
  3488. var first = fields[0];
  3489. var last = fields[fields.length - 1];
  3490. data[first] = _objectSpread({}, serverData[first]);
  3491. var object = _objectSpread({}, data);
  3492. for (var _i = 0; _i < fields.length - 1; _i++) {
  3493. var key = fields[_i];
  3494. if (!(key in object)) {
  3495. object[key] = {};
  3496. }
  3497. object = object[key];
  3498. }
  3499. object[last] = pendingOps[i][attr].applyTo(object[last]);
  3500. } else {
  3501. data[attr] = pendingOps[i][attr].applyTo(data[attr]);
  3502. }
  3503. }
  3504. }
  3505. }
  3506. return data;
  3507. }
  3508. function nestedSet(obj, key, value) {
  3509. var path = key.split('.');
  3510. for (var i = 0; i < path.length - 1; i++) {
  3511. if (!(path[i] in obj)) obj[path[i]] = {};
  3512. obj = obj[path[i]];
  3513. }
  3514. if (typeof value === 'undefined') {
  3515. delete obj[path[path.length - 1]];
  3516. } else {
  3517. obj[path[path.length - 1]] = value;
  3518. }
  3519. }
  3520. function commitServerChanges(serverData /*: AttributeMap*/, objectCache /*: ObjectCache*/, changes /*: AttributeMap*/) {
  3521. for (var _attr3 in changes) {
  3522. var val = changes[_attr3];
  3523. nestedSet(serverData, _attr3, val);
  3524. if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof _ParseObject.default) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
  3525. var json = (0, _encode.default)(val, false, true);
  3526. objectCache[_attr3] = (0, _stringify.default)(json);
  3527. }
  3528. }
  3529. }
  3530. },{"./ParseFile":22,"./ParseObject":26,"./ParseOp":27,"./ParseRelation":30,"./TaskQueue":41,"./encode":47,"@babel/runtime-corejs3/core-js-stable/instance/filter":62,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/instance/includes":66,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/define-properties":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":86,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":87,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],16:[function(_dereq_,module,exports){
  3531. "use strict";
  3532. var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  3533. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  3534. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  3535. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  3536. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  3537. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3538. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  3539. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  3540. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  3541. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  3542. var _filter = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  3543. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  3544. var _isInteger = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/number/is-integer"));
  3545. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  3546. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  3547. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  3548. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  3549. function _createForOfIteratorHelper(o, allowArrayLike) {
  3550. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  3551. if (!it) {
  3552. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  3553. if (it) o = it;
  3554. var i = 0;
  3555. var F = function () {};
  3556. return {
  3557. s: F,
  3558. n: function () {
  3559. if (i >= o.length) return {
  3560. done: true
  3561. };
  3562. return {
  3563. done: false,
  3564. value: o[i++]
  3565. };
  3566. },
  3567. e: function (_e) {
  3568. throw _e;
  3569. },
  3570. f: F
  3571. };
  3572. }
  3573. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3574. }
  3575. var normalCompletion = true,
  3576. didErr = false,
  3577. err;
  3578. return {
  3579. s: function () {
  3580. it = it.call(o);
  3581. },
  3582. n: function () {
  3583. var step = it.next();
  3584. normalCompletion = step.done;
  3585. return step;
  3586. },
  3587. e: function (_e2) {
  3588. didErr = true;
  3589. err = _e2;
  3590. },
  3591. f: function () {
  3592. try {
  3593. if (!normalCompletion && it.return != null) it.return();
  3594. } finally {
  3595. if (didErr) throw err;
  3596. }
  3597. }
  3598. };
  3599. }
  3600. function _unsupportedIterableToArray(o, minLen) {
  3601. var _context6;
  3602. if (!o) return;
  3603. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  3604. var n = _sliceInstanceProperty2(_context6 = Object.prototype.toString.call(o)).call(_context6, 8, -1);
  3605. if (n === "Object" && o.constructor) n = o.constructor.name;
  3606. if (n === "Map" || n === "Set") return _Array$from(o);
  3607. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  3608. }
  3609. function _arrayLikeToArray(arr, len) {
  3610. if (len == null || len > arr.length) len = arr.length;
  3611. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  3612. return arr2;
  3613. }
  3614. var equalObjects = _dereq_('./equals').default;
  3615. var decode = _dereq_('./decode').default;
  3616. var ParseError = _dereq_('./ParseError').default;
  3617. var ParsePolygon = _dereq_('./ParsePolygon').default;
  3618. var ParseGeoPoint = _dereq_('./ParseGeoPoint').default;
  3619. /**
  3620. * contains -- Determines if an object is contained in a list with special handling for Parse pointers.
  3621. *
  3622. * @param haystack
  3623. * @param needle
  3624. * @private
  3625. * @returns {boolean}
  3626. */
  3627. function contains(haystack, needle) {
  3628. if (needle && needle.__type && (needle.__type === 'Pointer' || needle.__type === 'Object')) {
  3629. for (var i in haystack) {
  3630. var ptr = haystack[i];
  3631. if (typeof ptr === 'string' && ptr === needle.objectId) {
  3632. return true;
  3633. }
  3634. if (ptr.className === needle.className && ptr.objectId === needle.objectId) {
  3635. return true;
  3636. }
  3637. }
  3638. return false;
  3639. }
  3640. if ((0, _isArray.default)(needle)) {
  3641. var _iterator = _createForOfIteratorHelper(needle),
  3642. _step;
  3643. try {
  3644. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3645. var need = _step.value;
  3646. if (contains(haystack, need)) {
  3647. return true;
  3648. }
  3649. }
  3650. } catch (err) {
  3651. _iterator.e(err);
  3652. } finally {
  3653. _iterator.f();
  3654. }
  3655. }
  3656. return (0, _indexOf.default)(haystack).call(haystack, needle) > -1;
  3657. }
  3658. function transformObject(object) {
  3659. if (object._toFullJSON) {
  3660. return object._toFullJSON();
  3661. }
  3662. return object;
  3663. }
  3664. /**
  3665. * matchesQuery -- Determines if an object would be returned by a Parse Query
  3666. * It's a lightweight, where-clause only implementation of a full query engine.
  3667. * Since we find queries that match objects, rather than objects that match
  3668. * queries, we can avoid building a full-blown query tool.
  3669. *
  3670. * @param className
  3671. * @param object
  3672. * @param objects
  3673. * @param query
  3674. * @private
  3675. * @returns {boolean}
  3676. */
  3677. function matchesQuery(className, object, objects, query) {
  3678. if (object.className !== className) {
  3679. return false;
  3680. }
  3681. var obj = object;
  3682. var q = query;
  3683. if (object.toJSON) {
  3684. obj = object.toJSON();
  3685. }
  3686. if (query.toJSON) {
  3687. q = query.toJSON().where;
  3688. }
  3689. obj.className = className;
  3690. for (var field in q) {
  3691. if (!matchesKeyConstraints(className, obj, objects, field, q[field])) {
  3692. return false;
  3693. }
  3694. }
  3695. return true;
  3696. }
  3697. function equalObjectsGeneric(obj, compareTo, eqlFn) {
  3698. if ((0, _isArray.default)(obj)) {
  3699. for (var i = 0; i < obj.length; i++) {
  3700. if (eqlFn(obj[i], compareTo)) {
  3701. return true;
  3702. }
  3703. }
  3704. return false;
  3705. }
  3706. return eqlFn(obj, compareTo);
  3707. }
  3708. /**
  3709. * @typedef RelativeTimeToDateResult
  3710. * @property {string} status The conversion status, `error` if conversion failed or
  3711. * `success` if conversion succeeded.
  3712. * @property {string} info The error message if conversion failed, or the relative
  3713. * time indication (`past`, `present`, `future`) if conversion succeeded.
  3714. * @property {Date|undefined} result The converted date, or `undefined` if conversion
  3715. * failed.
  3716. */
  3717. /**
  3718. * Converts human readable relative date string, for example, 'in 10 days' to a date
  3719. * relative to now.
  3720. *
  3721. * @param {string} text The text to convert.
  3722. * @param {Date} [now=new Date()] The date from which add or subtract. Default is now.
  3723. * @returns {RelativeTimeToDateResult}
  3724. */
  3725. function relativeTimeToDate(text) {
  3726. var now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Date();
  3727. text = text.toLowerCase();
  3728. var parts = text.split(' ');
  3729. // Filter out whitespace
  3730. parts = (0, _filter.default)(parts).call(parts, function (part) {
  3731. return part !== '';
  3732. });
  3733. var future = parts[0] === 'in';
  3734. var past = parts[parts.length - 1] === 'ago';
  3735. if (!future && !past && text !== 'now') {
  3736. return {
  3737. status: 'error',
  3738. info: "Time should either start with 'in' or end with 'ago'"
  3739. };
  3740. }
  3741. if (future && past) {
  3742. return {
  3743. status: 'error',
  3744. info: "Time cannot have both 'in' and 'ago'"
  3745. };
  3746. }
  3747. // strip the 'ago' or 'in'
  3748. if (future) {
  3749. parts = (0, _slice.default)(parts).call(parts, 1);
  3750. } else {
  3751. // past
  3752. parts = (0, _slice.default)(parts).call(parts, 0, parts.length - 1);
  3753. }
  3754. if (parts.length % 2 !== 0 && text !== 'now') {
  3755. return {
  3756. status: 'error',
  3757. info: 'Invalid time string. Dangling unit or number.'
  3758. };
  3759. }
  3760. var pairs = [];
  3761. while (parts.length) {
  3762. pairs.push([parts.shift(), parts.shift()]);
  3763. }
  3764. var seconds = 0;
  3765. for (var _i = 0, _pairs = pairs; _i < _pairs.length; _i++) {
  3766. var _pairs$_i = (0, _slicedToArray2.default)(_pairs[_i], 2),
  3767. num = _pairs$_i[0],
  3768. interval = _pairs$_i[1];
  3769. var val = Number(num);
  3770. if (!(0, _isInteger.default)(val)) {
  3771. return {
  3772. status: 'error',
  3773. info: "'".concat(num, "' is not an integer.")
  3774. };
  3775. }
  3776. switch (interval) {
  3777. case 'yr':
  3778. case 'yrs':
  3779. case 'year':
  3780. case 'years':
  3781. seconds += val * 31536000; // 365 * 24 * 60 * 60
  3782. break;
  3783. case 'wk':
  3784. case 'wks':
  3785. case 'week':
  3786. case 'weeks':
  3787. seconds += val * 604800; // 7 * 24 * 60 * 60
  3788. break;
  3789. case 'd':
  3790. case 'day':
  3791. case 'days':
  3792. seconds += val * 86400; // 24 * 60 * 60
  3793. break;
  3794. case 'hr':
  3795. case 'hrs':
  3796. case 'hour':
  3797. case 'hours':
  3798. seconds += val * 3600; // 60 * 60
  3799. break;
  3800. case 'min':
  3801. case 'mins':
  3802. case 'minute':
  3803. case 'minutes':
  3804. seconds += val * 60;
  3805. break;
  3806. case 'sec':
  3807. case 'secs':
  3808. case 'second':
  3809. case 'seconds':
  3810. seconds += val;
  3811. break;
  3812. default:
  3813. return {
  3814. status: 'error',
  3815. info: "Invalid interval: '".concat(interval, "'")
  3816. };
  3817. }
  3818. }
  3819. var milliseconds = seconds * 1000;
  3820. if (future) {
  3821. return {
  3822. status: 'success',
  3823. info: 'future',
  3824. result: new Date(now.valueOf() + milliseconds)
  3825. };
  3826. } else if (past) {
  3827. return {
  3828. status: 'success',
  3829. info: 'past',
  3830. result: new Date(now.valueOf() - milliseconds)
  3831. };
  3832. } else {
  3833. return {
  3834. status: 'success',
  3835. info: 'present',
  3836. result: new Date(now.valueOf())
  3837. };
  3838. }
  3839. }
  3840. /**
  3841. * Determines whether an object matches a single key's constraints
  3842. *
  3843. * @param className
  3844. * @param object
  3845. * @param objects
  3846. * @param key
  3847. * @param constraints
  3848. * @private
  3849. * @returns {boolean}
  3850. */
  3851. function matchesKeyConstraints(className, object, objects, key, constraints) {
  3852. if (constraints === null) {
  3853. return false;
  3854. }
  3855. if ((0, _indexOf.default)(key).call(key, '.') >= 0) {
  3856. // Key references a subobject
  3857. var keyComponents = key.split('.');
  3858. var subObjectKey = keyComponents[0];
  3859. var keyRemainder = (0, _slice.default)(keyComponents).call(keyComponents, 1).join('.');
  3860. return matchesKeyConstraints(className, object[subObjectKey] || {}, objects, keyRemainder, constraints);
  3861. }
  3862. var i;
  3863. if (key === '$or') {
  3864. for (i = 0; i < constraints.length; i++) {
  3865. if (matchesQuery(className, object, objects, constraints[i])) {
  3866. return true;
  3867. }
  3868. }
  3869. return false;
  3870. }
  3871. if (key === '$and') {
  3872. for (i = 0; i < constraints.length; i++) {
  3873. if (!matchesQuery(className, object, objects, constraints[i])) {
  3874. return false;
  3875. }
  3876. }
  3877. return true;
  3878. }
  3879. if (key === '$nor') {
  3880. for (i = 0; i < constraints.length; i++) {
  3881. if (matchesQuery(className, object, objects, constraints[i])) {
  3882. return false;
  3883. }
  3884. }
  3885. return true;
  3886. }
  3887. if (key === '$relatedTo') {
  3888. // Bail! We can't handle relational queries locally
  3889. return false;
  3890. }
  3891. if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(key)) {
  3892. throw new ParseError(ParseError.INVALID_KEY_NAME, "Invalid Key: ".concat(key));
  3893. }
  3894. // Equality (or Array contains) cases
  3895. if ((0, _typeof2.default)(constraints) !== 'object') {
  3896. if ((0, _isArray.default)(object[key])) {
  3897. var _context;
  3898. return (0, _indexOf.default)(_context = object[key]).call(_context, constraints) > -1;
  3899. }
  3900. return object[key] === constraints;
  3901. }
  3902. var compareTo;
  3903. if (constraints.__type) {
  3904. if (constraints.__type === 'Pointer') {
  3905. return equalObjectsGeneric(object[key], constraints, function (obj, ptr) {
  3906. return typeof obj !== 'undefined' && ptr.className === obj.className && ptr.objectId === obj.objectId;
  3907. });
  3908. }
  3909. return equalObjectsGeneric(decode(object[key]), decode(constraints), equalObjects);
  3910. }
  3911. // More complex cases
  3912. for (var condition in constraints) {
  3913. compareTo = constraints[condition];
  3914. if (compareTo.__type) {
  3915. compareTo = decode(compareTo);
  3916. }
  3917. // is it a $relativeTime? convert to date
  3918. if (compareTo['$relativeTime']) {
  3919. var parserResult = relativeTimeToDate(compareTo['$relativeTime']);
  3920. if (parserResult.status !== 'success') {
  3921. var _context2;
  3922. throw new ParseError(ParseError.INVALID_JSON, (0, _concat.default)(_context2 = "bad $relativeTime (".concat(key, ") value. ")).call(_context2, parserResult.info));
  3923. }
  3924. compareTo = parserResult.result;
  3925. }
  3926. // Compare Date Object or Date String
  3927. if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' && new Date(compareTo) !== 'Invalid Date' && !isNaN(new Date(compareTo))) {
  3928. object[key] = new Date(object[key].iso ? object[key].iso : object[key]);
  3929. }
  3930. switch (condition) {
  3931. case '$lt':
  3932. if (object[key] >= compareTo) {
  3933. return false;
  3934. }
  3935. break;
  3936. case '$lte':
  3937. if (object[key] > compareTo) {
  3938. return false;
  3939. }
  3940. break;
  3941. case '$gt':
  3942. if (object[key] <= compareTo) {
  3943. return false;
  3944. }
  3945. break;
  3946. case '$gte':
  3947. if (object[key] < compareTo) {
  3948. return false;
  3949. }
  3950. break;
  3951. case '$ne':
  3952. if (equalObjects(object[key], compareTo)) {
  3953. return false;
  3954. }
  3955. break;
  3956. case '$in':
  3957. if (!contains(compareTo, object[key])) {
  3958. return false;
  3959. }
  3960. break;
  3961. case '$nin':
  3962. if (contains(compareTo, object[key])) {
  3963. return false;
  3964. }
  3965. break;
  3966. case '$all':
  3967. for (i = 0; i < compareTo.length; i++) {
  3968. var _context3;
  3969. if ((0, _indexOf.default)(_context3 = object[key]).call(_context3, compareTo[i]) < 0) {
  3970. return false;
  3971. }
  3972. }
  3973. break;
  3974. case '$exists':
  3975. {
  3976. var propertyExists = typeof object[key] !== 'undefined';
  3977. var existenceIsRequired = constraints['$exists'];
  3978. if (typeof constraints['$exists'] !== 'boolean') {
  3979. // The SDK will never submit a non-boolean for $exists, but if someone
  3980. // tries to submit a non-boolean for $exits outside the SDKs, just ignore it.
  3981. break;
  3982. }
  3983. if (!propertyExists && existenceIsRequired || propertyExists && !existenceIsRequired) {
  3984. return false;
  3985. }
  3986. break;
  3987. }
  3988. case '$regex':
  3989. {
  3990. if ((0, _typeof2.default)(compareTo) === 'object') {
  3991. return compareTo.test(object[key]);
  3992. }
  3993. // JS doesn't support perl-style escaping
  3994. var expString = '';
  3995. var escapeEnd = -2;
  3996. var escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q');
  3997. while (escapeStart > -1) {
  3998. // Add the unescaped portion
  3999. expString += compareTo.substring(escapeEnd + 2, escapeStart);
  4000. escapeEnd = (0, _indexOf.default)(compareTo).call(compareTo, '\\E', escapeStart);
  4001. if (escapeEnd > -1) {
  4002. expString += compareTo.substring(escapeStart + 2, escapeEnd).replace(/\\\\\\\\E/g, '\\E').replace(/\W/g, '\\$&');
  4003. }
  4004. escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q', escapeEnd);
  4005. }
  4006. expString += compareTo.substring(Math.max(escapeStart, escapeEnd + 2));
  4007. var modifiers = constraints.$options || '';
  4008. modifiers = modifiers.replace('x', '').replace('s', '');
  4009. // Parse Server / Mongo support x and s modifiers but JS RegExp doesn't
  4010. var exp = new RegExp(expString, modifiers);
  4011. if (!exp.test(object[key])) {
  4012. return false;
  4013. }
  4014. break;
  4015. }
  4016. case '$nearSphere':
  4017. {
  4018. if (!compareTo || !object[key]) {
  4019. return false;
  4020. }
  4021. var distance = compareTo.radiansTo(object[key]);
  4022. var max = constraints.$maxDistance || Infinity;
  4023. return distance <= max;
  4024. }
  4025. case '$within':
  4026. {
  4027. if (!compareTo || !object[key]) {
  4028. return false;
  4029. }
  4030. var southWest = compareTo.$box[0];
  4031. var northEast = compareTo.$box[1];
  4032. if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
  4033. // Invalid box, crosses the date line
  4034. return false;
  4035. }
  4036. return object[key].latitude > southWest.latitude && object[key].latitude < northEast.latitude && object[key].longitude > southWest.longitude && object[key].longitude < northEast.longitude;
  4037. }
  4038. case '$options':
  4039. // Not a query type, but a way to add options to $regex. Ignore and
  4040. // avoid the default
  4041. break;
  4042. case '$maxDistance':
  4043. // Not a query type, but a way to add a cap to $nearSphere. Ignore and
  4044. // avoid the default
  4045. break;
  4046. case '$select':
  4047. {
  4048. var subQueryObjects = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  4049. return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
  4050. });
  4051. for (var _i2 = 0; _i2 < subQueryObjects.length; _i2 += 1) {
  4052. var subObject = transformObject(subQueryObjects[_i2]);
  4053. return equalObjects(object[key], subObject[compareTo.key]);
  4054. }
  4055. return false;
  4056. }
  4057. case '$dontSelect':
  4058. {
  4059. var _subQueryObjects = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  4060. return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
  4061. });
  4062. for (var _i3 = 0; _i3 < _subQueryObjects.length; _i3 += 1) {
  4063. var _subObject = transformObject(_subQueryObjects[_i3]);
  4064. return !equalObjects(object[key], _subObject[compareTo.key]);
  4065. }
  4066. return false;
  4067. }
  4068. case '$inQuery':
  4069. {
  4070. var _subQueryObjects2 = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  4071. return matchesQuery(compareTo.className, obj, arr, compareTo.where);
  4072. });
  4073. for (var _i4 = 0; _i4 < _subQueryObjects2.length; _i4 += 1) {
  4074. var _subObject2 = transformObject(_subQueryObjects2[_i4]);
  4075. if (object[key].className === _subObject2.className && object[key].objectId === _subObject2.objectId) {
  4076. return true;
  4077. }
  4078. }
  4079. return false;
  4080. }
  4081. case '$notInQuery':
  4082. {
  4083. var _subQueryObjects3 = (0, _filter.default)(objects).call(objects, function (obj, index, arr) {
  4084. return matchesQuery(compareTo.className, obj, arr, compareTo.where);
  4085. });
  4086. for (var _i5 = 0; _i5 < _subQueryObjects3.length; _i5 += 1) {
  4087. var _subObject3 = transformObject(_subQueryObjects3[_i5]);
  4088. if (object[key].className === _subObject3.className && object[key].objectId === _subObject3.objectId) {
  4089. return false;
  4090. }
  4091. }
  4092. return true;
  4093. }
  4094. case '$containedBy':
  4095. {
  4096. var _iterator2 = _createForOfIteratorHelper(object[key]),
  4097. _step2;
  4098. try {
  4099. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  4100. var value = _step2.value;
  4101. if (!contains(compareTo, value)) {
  4102. return false;
  4103. }
  4104. }
  4105. } catch (err) {
  4106. _iterator2.e(err);
  4107. } finally {
  4108. _iterator2.f();
  4109. }
  4110. return true;
  4111. }
  4112. case '$geoWithin':
  4113. {
  4114. if (compareTo.$polygon) {
  4115. var _context4;
  4116. var points = (0, _map.default)(_context4 = compareTo.$polygon).call(_context4, function (geoPoint) {
  4117. return [geoPoint.latitude, geoPoint.longitude];
  4118. });
  4119. var polygon = new ParsePolygon(points);
  4120. return polygon.containsPoint(object[key]);
  4121. }
  4122. if (compareTo.$centerSphere) {
  4123. var _compareTo$$centerSph = (0, _slicedToArray2.default)(compareTo.$centerSphere, 2),
  4124. WGS84Point = _compareTo$$centerSph[0],
  4125. maxDistance = _compareTo$$centerSph[1];
  4126. var centerPoint = new ParseGeoPoint({
  4127. latitude: WGS84Point[1],
  4128. longitude: WGS84Point[0]
  4129. });
  4130. var point = new ParseGeoPoint(object[key]);
  4131. var _distance = point.radiansTo(centerPoint);
  4132. return _distance <= maxDistance;
  4133. }
  4134. break;
  4135. }
  4136. case '$geoIntersects':
  4137. {
  4138. var _polygon = new ParsePolygon(object[key].coordinates);
  4139. var _point = new ParseGeoPoint(compareTo.$point);
  4140. return _polygon.containsPoint(_point);
  4141. }
  4142. default:
  4143. return false;
  4144. }
  4145. }
  4146. return true;
  4147. }
  4148. function validateQuery(query /*: any*/) {
  4149. var _context5;
  4150. var q = query;
  4151. if (query.toJSON) {
  4152. q = query.toJSON().where;
  4153. }
  4154. var specialQuerykeys = ['$and', '$or', '$nor', '_rperm', '_wperm', '_perishable_token', '_email_verify_token', '_email_verify_token_expires_at', '_account_lockout_expires_at', '_failed_login_count'];
  4155. (0, _forEach.default)(_context5 = (0, _keys.default)(q)).call(_context5, function (key) {
  4156. if (q && q[key] && q[key].$regex) {
  4157. if (typeof q[key].$options === 'string') {
  4158. if (!q[key].$options.match(/^[imxs]+$/)) {
  4159. throw new ParseError(ParseError.INVALID_QUERY, "Bad $options value for query: ".concat(q[key].$options));
  4160. }
  4161. }
  4162. }
  4163. if ((0, _indexOf.default)(specialQuerykeys).call(specialQuerykeys, key) < 0 && !key.match(/^[a-zA-Z][a-zA-Z0-9_\.]*$/)) {
  4164. throw new ParseError(ParseError.INVALID_KEY_NAME, "Invalid key name: ".concat(key));
  4165. }
  4166. });
  4167. }
  4168. var OfflineQuery = {
  4169. matchesQuery: matchesQuery,
  4170. validateQuery: validateQuery
  4171. };
  4172. module.exports = OfflineQuery;
  4173. },{"./ParseError":21,"./ParseGeoPoint":23,"./ParsePolygon":28,"./decode":46,"./equals":48,"@babel/runtime-corejs3/core-js-stable/array/from":56,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/concat":59,"@babel/runtime-corejs3/core-js-stable/instance/filter":62,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/instance/map":69,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/number/is-integer":78,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/symbol":96,"@babel/runtime-corejs3/core-js/get-iterator-method":100,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/slicedToArray":140,"@babel/runtime-corejs3/helpers/typeof":145}],17:[function(_dereq_,module,exports){
  4174. "use strict";
  4175. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  4176. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  4177. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4178. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  4179. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4180. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  4181. var _decode = _interopRequireDefault(_dereq_("./decode"));
  4182. var _encode = _interopRequireDefault(_dereq_("./encode"));
  4183. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  4184. var _CryptoController = _interopRequireDefault(_dereq_("./CryptoController"));
  4185. var _EventuallyQueue = _interopRequireDefault(_dereq_("./EventuallyQueue"));
  4186. var _InstallationController = _interopRequireDefault(_dereq_("./InstallationController"));
  4187. var ParseOp = _interopRequireWildcard(_dereq_("./ParseOp"));
  4188. var _RESTController = _interopRequireDefault(_dereq_("./RESTController"));
  4189. function _getRequireWildcardCache(nodeInterop) {
  4190. if (typeof _WeakMap !== "function") return null;
  4191. var cacheBabelInterop = new _WeakMap();
  4192. var cacheNodeInterop = new _WeakMap();
  4193. return (_getRequireWildcardCache = function (nodeInterop) {
  4194. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  4195. })(nodeInterop);
  4196. }
  4197. function _interopRequireWildcard(obj, nodeInterop) {
  4198. if (!nodeInterop && obj && obj.__esModule) {
  4199. return obj;
  4200. }
  4201. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  4202. return {
  4203. default: obj
  4204. };
  4205. }
  4206. var cache = _getRequireWildcardCache(nodeInterop);
  4207. if (cache && cache.has(obj)) {
  4208. return cache.get(obj);
  4209. }
  4210. var newObj = {};
  4211. for (var key in obj) {
  4212. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  4213. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  4214. if (desc && (desc.get || desc.set)) {
  4215. _Object$defineProperty(newObj, key, desc);
  4216. } else {
  4217. newObj[key] = obj[key];
  4218. }
  4219. }
  4220. }
  4221. newObj.default = obj;
  4222. if (cache) {
  4223. cache.set(obj, newObj);
  4224. }
  4225. return newObj;
  4226. }
  4227. /**
  4228. * Contains all Parse API classes and functions.
  4229. *
  4230. * @static
  4231. * @global
  4232. * @class
  4233. * @hideconstructor
  4234. */
  4235. var Parse = {
  4236. /**
  4237. * Call this method first to set up your authentication tokens for Parse.
  4238. *
  4239. * @param {string} applicationId Your Parse Application ID.
  4240. * @param {string} [javaScriptKey] Your Parse JavaScript Key (Not needed for parse-server)
  4241. * @param {string} [masterKey] Your Parse Master Key. (Node.js only!)
  4242. * @static
  4243. */
  4244. initialize: function (applicationId /*: string*/, javaScriptKey /*: string*/) {
  4245. Parse._initialize(applicationId, javaScriptKey);
  4246. },
  4247. _initialize: function (applicationId /*: string*/, javaScriptKey /*: string*/, masterKey /*: string*/) {
  4248. _CoreManager.default.set('APPLICATION_ID', applicationId);
  4249. _CoreManager.default.set('JAVASCRIPT_KEY', javaScriptKey);
  4250. _CoreManager.default.set('MASTER_KEY', masterKey);
  4251. _CoreManager.default.set('USE_MASTER_KEY', false);
  4252. },
  4253. /**
  4254. * Call this method to set your AsyncStorage engine
  4255. * Starting Parse@1.11, the ParseSDK do not provide a React AsyncStorage as the ReactNative module
  4256. * is not provided at a stable path and changes over versions.
  4257. *
  4258. * @param {AsyncStorage} storage a react native async storage.
  4259. * @static
  4260. */
  4261. setAsyncStorage: function (storage /*: any*/) {
  4262. _CoreManager.default.setAsyncStorage(storage);
  4263. },
  4264. /**
  4265. * Call this method to set your LocalDatastoreStorage engine
  4266. * If using React-Native use {@link Parse.setAsyncStorage Parse.setAsyncStorage()}
  4267. *
  4268. * @param {LocalDatastoreController} controller a data storage.
  4269. * @static
  4270. */
  4271. setLocalDatastoreController: function (controller /*: any*/) {
  4272. _CoreManager.default.setLocalDatastoreController(controller);
  4273. },
  4274. /**
  4275. * Returns information regarding the current server's health
  4276. *
  4277. * @returns {Promise}
  4278. * @static
  4279. */
  4280. getServerHealth: function () {
  4281. return _CoreManager.default.getRESTController().request('GET', 'health');
  4282. },
  4283. /**
  4284. * @member {string} Parse.applicationId
  4285. * @static
  4286. */
  4287. set applicationId(value) {
  4288. _CoreManager.default.set('APPLICATION_ID', value);
  4289. },
  4290. get applicationId() {
  4291. return _CoreManager.default.get('APPLICATION_ID');
  4292. },
  4293. /**
  4294. * @member {string} Parse.javaScriptKey
  4295. * @static
  4296. */
  4297. set javaScriptKey(value) {
  4298. _CoreManager.default.set('JAVASCRIPT_KEY', value);
  4299. },
  4300. get javaScriptKey() {
  4301. return _CoreManager.default.get('JAVASCRIPT_KEY');
  4302. },
  4303. /**
  4304. * @member {string} Parse.masterKey
  4305. * @static
  4306. */
  4307. set masterKey(value) {
  4308. _CoreManager.default.set('MASTER_KEY', value);
  4309. },
  4310. get masterKey() {
  4311. return _CoreManager.default.get('MASTER_KEY');
  4312. },
  4313. /**
  4314. * @member {string} Parse.serverURL
  4315. * @static
  4316. */
  4317. set serverURL(value) {
  4318. _CoreManager.default.set('SERVER_URL', value);
  4319. },
  4320. get serverURL() {
  4321. return _CoreManager.default.get('SERVER_URL');
  4322. },
  4323. /**
  4324. * @member {string} Parse.serverAuthToken
  4325. * @static
  4326. */
  4327. set serverAuthToken(value) {
  4328. _CoreManager.default.set('SERVER_AUTH_TOKEN', value);
  4329. },
  4330. get serverAuthToken() {
  4331. return _CoreManager.default.get('SERVER_AUTH_TOKEN');
  4332. },
  4333. /**
  4334. * @member {string} Parse.serverAuthType
  4335. * @static
  4336. */
  4337. set serverAuthType(value) {
  4338. _CoreManager.default.set('SERVER_AUTH_TYPE', value);
  4339. },
  4340. get serverAuthType() {
  4341. return _CoreManager.default.get('SERVER_AUTH_TYPE');
  4342. },
  4343. /**
  4344. * @member {string} Parse.liveQueryServerURL
  4345. * @static
  4346. */
  4347. set liveQueryServerURL(value) {
  4348. _CoreManager.default.set('LIVEQUERY_SERVER_URL', value);
  4349. },
  4350. get liveQueryServerURL() {
  4351. return _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  4352. },
  4353. /**
  4354. * @member {string} Parse.encryptedUser
  4355. * @static
  4356. */
  4357. set encryptedUser(value) {
  4358. _CoreManager.default.set('ENCRYPTED_USER', value);
  4359. },
  4360. get encryptedUser() {
  4361. return _CoreManager.default.get('ENCRYPTED_USER');
  4362. },
  4363. /**
  4364. * @member {string} Parse.secret
  4365. * @static
  4366. */
  4367. set secret(value) {
  4368. _CoreManager.default.set('ENCRYPTED_KEY', value);
  4369. },
  4370. get secret() {
  4371. return _CoreManager.default.get('ENCRYPTED_KEY');
  4372. },
  4373. /**
  4374. * @member {boolean} Parse.idempotency
  4375. * @static
  4376. */
  4377. set idempotency(value) {
  4378. _CoreManager.default.set('IDEMPOTENCY', value);
  4379. },
  4380. get idempotency() {
  4381. return _CoreManager.default.get('IDEMPOTENCY');
  4382. },
  4383. /**
  4384. * @member {boolean} Parse.allowCustomObjectId
  4385. * @static
  4386. */
  4387. set allowCustomObjectId(value) {
  4388. _CoreManager.default.set('ALLOW_CUSTOM_OBJECT_ID', value);
  4389. },
  4390. get allowCustomObjectId() {
  4391. return _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
  4392. }
  4393. };
  4394. Parse.ACL = _dereq_('./ParseACL').default;
  4395. Parse.Analytics = _dereq_('./Analytics');
  4396. Parse.AnonymousUtils = _dereq_('./AnonymousUtils').default;
  4397. Parse.Cloud = _dereq_('./Cloud');
  4398. Parse.CLP = _dereq_('./ParseCLP').default;
  4399. Parse.CoreManager = _dereq_('./CoreManager');
  4400. Parse.Config = _dereq_('./ParseConfig').default;
  4401. Parse.Error = _dereq_('./ParseError').default;
  4402. Parse.EventuallyQueue = _EventuallyQueue.default;
  4403. Parse.FacebookUtils = _dereq_('./FacebookUtils').default;
  4404. Parse.File = _dereq_('./ParseFile').default;
  4405. Parse.GeoPoint = _dereq_('./ParseGeoPoint').default;
  4406. Parse.Polygon = _dereq_('./ParsePolygon').default;
  4407. Parse.Installation = _dereq_('./ParseInstallation').default;
  4408. Parse.LocalDatastore = _dereq_('./LocalDatastore');
  4409. Parse.Object = _dereq_('./ParseObject').default;
  4410. Parse.Op = {
  4411. Set: ParseOp.SetOp,
  4412. Unset: ParseOp.UnsetOp,
  4413. Increment: ParseOp.IncrementOp,
  4414. Add: ParseOp.AddOp,
  4415. Remove: ParseOp.RemoveOp,
  4416. AddUnique: ParseOp.AddUniqueOp,
  4417. Relation: ParseOp.RelationOp
  4418. };
  4419. Parse.Push = _dereq_('./Push');
  4420. Parse.Query = _dereq_('./ParseQuery').default;
  4421. Parse.Relation = _dereq_('./ParseRelation').default;
  4422. Parse.Role = _dereq_('./ParseRole').default;
  4423. Parse.Schema = _dereq_('./ParseSchema').default;
  4424. Parse.Session = _dereq_('./ParseSession').default;
  4425. Parse.Storage = _dereq_('./Storage');
  4426. Parse.User = _dereq_('./ParseUser').default;
  4427. Parse.LiveQuery = _dereq_('./ParseLiveQuery').default;
  4428. Parse.LiveQueryClient = _dereq_('./LiveQueryClient').default;
  4429. Parse._request = function () {
  4430. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  4431. args[_key] = arguments[_key];
  4432. }
  4433. return _CoreManager.default.getRESTController().request.apply(null, args);
  4434. };
  4435. Parse._ajax = function () {
  4436. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  4437. args[_key2] = arguments[_key2];
  4438. }
  4439. return _CoreManager.default.getRESTController().ajax.apply(null, args);
  4440. };
  4441. // We attempt to match the signatures of the legacy versions of these methods
  4442. Parse._decode = function (_, value) {
  4443. return (0, _decode.default)(value);
  4444. };
  4445. Parse._encode = function (value, _, disallowObjects) {
  4446. return (0, _encode.default)(value, disallowObjects);
  4447. };
  4448. Parse._getInstallationId = function () {
  4449. return _CoreManager.default.getInstallationController().currentInstallationId();
  4450. };
  4451. /**
  4452. * Enable pinning in your application.
  4453. * This must be called after `Parse.initialize` in your application.
  4454. *
  4455. * @param [polling] Allow pinging the server /health endpoint. Default true
  4456. * @param [ms] Milliseconds to ping the server. Default 2000ms
  4457. * @static
  4458. */
  4459. Parse.enableLocalDatastore = function () {
  4460. var polling = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  4461. var ms /*: number*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
  4462. if (!Parse.applicationId) {
  4463. console.log("'enableLocalDataStore' must be called after 'initialize'");
  4464. return;
  4465. }
  4466. if (!Parse.LocalDatastore.isEnabled) {
  4467. Parse.LocalDatastore.isEnabled = true;
  4468. if (polling) {
  4469. _EventuallyQueue.default.poll(ms);
  4470. }
  4471. }
  4472. };
  4473. /**
  4474. * Flag that indicates whether Local Datastore is enabled.
  4475. *
  4476. * @static
  4477. * @returns {boolean}
  4478. */
  4479. Parse.isLocalDatastoreEnabled = function () {
  4480. return Parse.LocalDatastore.isEnabled;
  4481. };
  4482. /**
  4483. * Gets all contents from Local Datastore
  4484. *
  4485. * <pre>
  4486. * await Parse.dumpLocalDatastore();
  4487. * </pre>
  4488. *
  4489. * @static
  4490. * @returns {object}
  4491. */
  4492. Parse.dumpLocalDatastore = function () {
  4493. if (!Parse.LocalDatastore.isEnabled) {
  4494. console.log('Parse.enableLocalDatastore() must be called first'); // eslint-disable-line no-console
  4495. return _promise.default.resolve({});
  4496. } else {
  4497. return Parse.LocalDatastore._getAllContents();
  4498. }
  4499. };
  4500. /**
  4501. * Enable the current user encryption.
  4502. * This must be called before login any user.
  4503. *
  4504. * @static
  4505. */
  4506. Parse.enableEncryptedUser = function () {
  4507. Parse.encryptedUser = true;
  4508. };
  4509. /**
  4510. * Flag that indicates whether Encrypted User is enabled.
  4511. *
  4512. * @static
  4513. * @returns {boolean}
  4514. */
  4515. Parse.isEncryptedUserEnabled = function () {
  4516. return Parse.encryptedUser;
  4517. };
  4518. _CoreManager.default.setCryptoController(_CryptoController.default);
  4519. _CoreManager.default.setInstallationController(_InstallationController.default);
  4520. _CoreManager.default.setRESTController(_RESTController.default);
  4521. // For legacy requires, of the form `var Parse = require('parse').Parse`
  4522. Parse.Parse = Parse;
  4523. module.exports = Parse;
  4524. },{"./Analytics":1,"./AnonymousUtils":2,"./Cloud":3,"./CoreManager":4,"./CryptoController":5,"./EventuallyQueue":7,"./FacebookUtils":8,"./InstallationController":9,"./LiveQueryClient":10,"./LocalDatastore":12,"./ParseACL":18,"./ParseCLP":19,"./ParseConfig":20,"./ParseError":21,"./ParseFile":22,"./ParseGeoPoint":23,"./ParseInstallation":24,"./ParseLiveQuery":25,"./ParseObject":26,"./ParseOp":27,"./ParsePolygon":28,"./ParseQuery":29,"./ParseRelation":30,"./ParseRole":31,"./ParseSchema":32,"./ParseSession":33,"./ParseUser":34,"./Push":35,"./RESTController":36,"./Storage":39,"./decode":46,"./encode":47,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/core-js-stable/weak-map":97,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],18:[function(_dereq_,module,exports){
  4525. "use strict";
  4526. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4527. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4528. _Object$defineProperty(exports, "__esModule", {
  4529. value: true
  4530. });
  4531. exports.default = void 0;
  4532. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  4533. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  4534. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  4535. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  4536. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  4537. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  4538. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  4539. /**
  4540. * @flow
  4541. */
  4542. /*:: type PermissionsMap = { [permission: string]: boolean };*/
  4543. /*:: type ByIdMap = { [userId: string]: PermissionsMap };*/
  4544. var PUBLIC_KEY = '*';
  4545. /**
  4546. * Creates a new ACL.
  4547. * If no argument is given, the ACL has no permissions for anyone.
  4548. * If the argument is a Parse.User, the ACL will have read and write
  4549. * permission for only that user.
  4550. * If the argument is any other JSON object, that object will be interpretted
  4551. * as a serialized ACL created with toJSON().
  4552. *
  4553. * <p>An ACL, or Access Control List can be added to any
  4554. * <code>Parse.Object</code> to restrict access to only a subset of users
  4555. * of your application.</p>
  4556. *
  4557. * @alias Parse.ACL
  4558. */
  4559. var ParseACL = /*#__PURE__*/function () {
  4560. /**
  4561. * @param {(Parse.User | object)} arg1 The user to initialize the ACL for
  4562. */
  4563. function ParseACL(arg1 /*: ParseUser | ByIdMap*/) {
  4564. (0, _classCallCheck2.default)(this, ParseACL);
  4565. (0, _defineProperty2.default)(this, "permissionsById", void 0);
  4566. this.permissionsById = {};
  4567. if (arg1 && (0, _typeof2.default)(arg1) === 'object') {
  4568. if (arg1 instanceof _ParseUser.default) {
  4569. this.setReadAccess(arg1, true);
  4570. this.setWriteAccess(arg1, true);
  4571. } else {
  4572. for (var _userId in arg1) {
  4573. var accessList = arg1[_userId];
  4574. this.permissionsById[_userId] = {};
  4575. for (var _permission in accessList) {
  4576. var allowed = accessList[_permission];
  4577. if (_permission !== 'read' && _permission !== 'write') {
  4578. throw new TypeError('Tried to create an ACL with an invalid permission type.');
  4579. }
  4580. if (typeof allowed !== 'boolean') {
  4581. throw new TypeError('Tried to create an ACL with an invalid permission value.');
  4582. }
  4583. this.permissionsById[_userId][_permission] = allowed;
  4584. }
  4585. }
  4586. }
  4587. } else if (typeof arg1 === 'function') {
  4588. throw new TypeError('ParseACL constructed with a function. Did you forget ()?');
  4589. }
  4590. }
  4591. /**
  4592. * Returns a JSON-encoded version of the ACL.
  4593. *
  4594. * @returns {object}
  4595. */
  4596. (0, _createClass2.default)(ParseACL, [{
  4597. key: "toJSON",
  4598. value: function () /*: ByIdMap*/{
  4599. var permissions = {};
  4600. for (var p in this.permissionsById) {
  4601. permissions[p] = this.permissionsById[p];
  4602. }
  4603. return permissions;
  4604. }
  4605. /**
  4606. * Returns whether this ACL is equal to another object
  4607. *
  4608. * @param {ParseACL} other The other object's ACL to compare to
  4609. * @returns {boolean}
  4610. */
  4611. }, {
  4612. key: "equals",
  4613. value: function (other /*: ParseACL*/) /*: boolean*/{
  4614. if (!(other instanceof ParseACL)) {
  4615. return false;
  4616. }
  4617. var users = (0, _keys.default)(this.permissionsById);
  4618. var otherUsers = (0, _keys.default)(other.permissionsById);
  4619. if (users.length !== otherUsers.length) {
  4620. return false;
  4621. }
  4622. for (var u in this.permissionsById) {
  4623. if (!other.permissionsById[u]) {
  4624. return false;
  4625. }
  4626. if (this.permissionsById[u].read !== other.permissionsById[u].read) {
  4627. return false;
  4628. }
  4629. if (this.permissionsById[u].write !== other.permissionsById[u].write) {
  4630. return false;
  4631. }
  4632. }
  4633. return true;
  4634. }
  4635. }, {
  4636. key: "_setAccess",
  4637. value: function (accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
  4638. if (userId instanceof _ParseUser.default) {
  4639. userId = userId.id;
  4640. } else if (userId instanceof _ParseRole.default) {
  4641. var name = userId.getName();
  4642. if (!name) {
  4643. throw new TypeError('Role must have a name');
  4644. }
  4645. userId = 'role:' + name;
  4646. }
  4647. if (typeof userId !== 'string') {
  4648. throw new TypeError('userId must be a string.');
  4649. }
  4650. if (typeof allowed !== 'boolean') {
  4651. throw new TypeError('allowed must be either true or false.');
  4652. }
  4653. var permissions = this.permissionsById[userId];
  4654. if (!permissions) {
  4655. if (!allowed) {
  4656. // The user already doesn't have this permission, so no action is needed
  4657. return;
  4658. } else {
  4659. permissions = {};
  4660. this.permissionsById[userId] = permissions;
  4661. }
  4662. }
  4663. if (allowed) {
  4664. this.permissionsById[userId][accessType] = true;
  4665. } else {
  4666. delete permissions[accessType];
  4667. if ((0, _keys.default)(permissions).length === 0) {
  4668. delete this.permissionsById[userId];
  4669. }
  4670. }
  4671. }
  4672. }, {
  4673. key: "_getAccess",
  4674. value: function (accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
  4675. if (userId instanceof _ParseUser.default) {
  4676. userId = userId.id;
  4677. if (!userId) {
  4678. throw new Error('Cannot get access for a ParseUser without an ID');
  4679. }
  4680. } else if (userId instanceof _ParseRole.default) {
  4681. var name = userId.getName();
  4682. if (!name) {
  4683. throw new TypeError('Role must have a name');
  4684. }
  4685. userId = 'role:' + name;
  4686. }
  4687. var permissions = this.permissionsById[userId];
  4688. if (!permissions) {
  4689. return false;
  4690. }
  4691. return !!permissions[accessType];
  4692. }
  4693. /**
  4694. * Sets whether the given user is allowed to read this object.
  4695. *
  4696. * @param userId An instance of Parse.User or its objectId.
  4697. * @param {boolean} allowed Whether that user should have read access.
  4698. */
  4699. }, {
  4700. key: "setReadAccess",
  4701. value: function (userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
  4702. this._setAccess('read', userId, allowed);
  4703. }
  4704. /**
  4705. * Get whether the given user id is *explicitly* allowed to read this object.
  4706. * Even if this returns false, the user may still be able to access it if
  4707. * getPublicReadAccess returns true or a role that the user belongs to has
  4708. * write access.
  4709. *
  4710. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  4711. * @returns {boolean}
  4712. */
  4713. }, {
  4714. key: "getReadAccess",
  4715. value: function (userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
  4716. return this._getAccess('read', userId);
  4717. }
  4718. /**
  4719. * Sets whether the given user id is allowed to write this object.
  4720. *
  4721. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  4722. * @param {boolean} allowed Whether that user should have write access.
  4723. */
  4724. }, {
  4725. key: "setWriteAccess",
  4726. value: function (userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
  4727. this._setAccess('write', userId, allowed);
  4728. }
  4729. /**
  4730. * Gets whether the given user id is *explicitly* allowed to write this object.
  4731. * Even if this returns false, the user may still be able to write it if
  4732. * getPublicWriteAccess returns true or a role that the user belongs to has
  4733. * write access.
  4734. *
  4735. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  4736. * @returns {boolean}
  4737. */
  4738. }, {
  4739. key: "getWriteAccess",
  4740. value: function (userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
  4741. return this._getAccess('write', userId);
  4742. }
  4743. /**
  4744. * Sets whether the public is allowed to read this object.
  4745. *
  4746. * @param {boolean} allowed
  4747. */
  4748. }, {
  4749. key: "setPublicReadAccess",
  4750. value: function (allowed /*: boolean*/) {
  4751. this.setReadAccess(PUBLIC_KEY, allowed);
  4752. }
  4753. /**
  4754. * Gets whether the public is allowed to read this object.
  4755. *
  4756. * @returns {boolean}
  4757. */
  4758. }, {
  4759. key: "getPublicReadAccess",
  4760. value: function () /*: boolean*/{
  4761. return this.getReadAccess(PUBLIC_KEY);
  4762. }
  4763. /**
  4764. * Sets whether the public is allowed to write this object.
  4765. *
  4766. * @param {boolean} allowed
  4767. */
  4768. }, {
  4769. key: "setPublicWriteAccess",
  4770. value: function (allowed /*: boolean*/) {
  4771. this.setWriteAccess(PUBLIC_KEY, allowed);
  4772. }
  4773. /**
  4774. * Gets whether the public is allowed to write this object.
  4775. *
  4776. * @returns {boolean}
  4777. */
  4778. }, {
  4779. key: "getPublicWriteAccess",
  4780. value: function () /*: boolean*/{
  4781. return this.getWriteAccess(PUBLIC_KEY);
  4782. }
  4783. /**
  4784. * Gets whether users belonging to the given role are allowed
  4785. * to read this object. Even if this returns false, the role may
  4786. * still be able to write it if a parent role has read access.
  4787. *
  4788. * @param role The name of the role, or a Parse.Role object.
  4789. * @returns {boolean} true if the role has read access. false otherwise.
  4790. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4791. */
  4792. }, {
  4793. key: "getRoleReadAccess",
  4794. value: function (role /*: ParseRole | string*/) /*: boolean*/{
  4795. if (role instanceof _ParseRole.default) {
  4796. // Normalize to the String name
  4797. role = role.getName();
  4798. }
  4799. if (typeof role !== 'string') {
  4800. throw new TypeError('role must be a ParseRole or a String');
  4801. }
  4802. return this.getReadAccess('role:' + role);
  4803. }
  4804. /**
  4805. * Gets whether users belonging to the given role are allowed
  4806. * to write this object. Even if this returns false, the role may
  4807. * still be able to write it if a parent role has write access.
  4808. *
  4809. * @param role The name of the role, or a Parse.Role object.
  4810. * @returns {boolean} true if the role has write access. false otherwise.
  4811. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4812. */
  4813. }, {
  4814. key: "getRoleWriteAccess",
  4815. value: function (role /*: ParseRole | string*/) /*: boolean*/{
  4816. if (role instanceof _ParseRole.default) {
  4817. // Normalize to the String name
  4818. role = role.getName();
  4819. }
  4820. if (typeof role !== 'string') {
  4821. throw new TypeError('role must be a ParseRole or a String');
  4822. }
  4823. return this.getWriteAccess('role:' + role);
  4824. }
  4825. /**
  4826. * Sets whether users belonging to the given role are allowed
  4827. * to read this object.
  4828. *
  4829. * @param role The name of the role, or a Parse.Role object.
  4830. * @param {boolean} allowed Whether the given role can read this object.
  4831. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4832. */
  4833. }, {
  4834. key: "setRoleReadAccess",
  4835. value: function (role /*: ParseRole | string*/, allowed /*: 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. this.setReadAccess('role:' + role, allowed);
  4844. }
  4845. /**
  4846. * Sets whether users belonging to the given role are allowed
  4847. * to write this object.
  4848. *
  4849. * @param role The name of the role, or a Parse.Role object.
  4850. * @param {boolean} allowed Whether the given role can write this object.
  4851. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  4852. */
  4853. }, {
  4854. key: "setRoleWriteAccess",
  4855. value: function (role /*: ParseRole | string*/, allowed /*: boolean*/) {
  4856. if (role instanceof _ParseRole.default) {
  4857. // Normalize to the String name
  4858. role = role.getName();
  4859. }
  4860. if (typeof role !== 'string') {
  4861. throw new TypeError('role must be a ParseRole or a String');
  4862. }
  4863. this.setWriteAccess('role:' + role, allowed);
  4864. }
  4865. }]);
  4866. return ParseACL;
  4867. }();
  4868. var _default = ParseACL;
  4869. exports.default = _default;
  4870. },{"./ParseRole":31,"./ParseUser":34,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],19:[function(_dereq_,module,exports){
  4871. "use strict";
  4872. var _sliceInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  4873. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  4874. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  4875. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  4876. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  4877. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  4878. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  4879. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  4880. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  4881. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  4882. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  4883. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  4884. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4885. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  4886. _Object$defineProperty(exports, "__esModule", {
  4887. value: true
  4888. });
  4889. exports.default = void 0;
  4890. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  4891. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  4892. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  4893. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  4894. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  4895. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/map"));
  4896. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  4897. var _every = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/every"));
  4898. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/entries"));
  4899. var _assign = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/assign"));
  4900. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  4901. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  4902. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  4903. var _ParseRole = _interopRequireDefault(_dereq_("./ParseRole"));
  4904. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  4905. function ownKeys(object, enumerableOnly) {
  4906. var keys = _Object$keys2(object);
  4907. if (_Object$getOwnPropertySymbols) {
  4908. var symbols = _Object$getOwnPropertySymbols(object);
  4909. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  4910. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  4911. })), keys.push.apply(keys, symbols);
  4912. }
  4913. return keys;
  4914. }
  4915. function _objectSpread(target) {
  4916. for (var i = 1; i < arguments.length; i++) {
  4917. var _context3, _context4;
  4918. var source = null != arguments[i] ? arguments[i] : {};
  4919. i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) {
  4920. (0, _defineProperty2.default)(target, key, source[key]);
  4921. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) {
  4922. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  4923. });
  4924. }
  4925. return target;
  4926. }
  4927. function _createForOfIteratorHelper(o, allowArrayLike) {
  4928. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  4929. if (!it) {
  4930. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  4931. if (it) o = it;
  4932. var i = 0;
  4933. var F = function () {};
  4934. return {
  4935. s: F,
  4936. n: function () {
  4937. if (i >= o.length) return {
  4938. done: true
  4939. };
  4940. return {
  4941. done: false,
  4942. value: o[i++]
  4943. };
  4944. },
  4945. e: function (_e) {
  4946. throw _e;
  4947. },
  4948. f: F
  4949. };
  4950. }
  4951. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  4952. }
  4953. var normalCompletion = true,
  4954. didErr = false,
  4955. err;
  4956. return {
  4957. s: function () {
  4958. it = it.call(o);
  4959. },
  4960. n: function () {
  4961. var step = it.next();
  4962. normalCompletion = step.done;
  4963. return step;
  4964. },
  4965. e: function (_e2) {
  4966. didErr = true;
  4967. err = _e2;
  4968. },
  4969. f: function () {
  4970. try {
  4971. if (!normalCompletion && it.return != null) it.return();
  4972. } finally {
  4973. if (didErr) throw err;
  4974. }
  4975. }
  4976. };
  4977. }
  4978. function _unsupportedIterableToArray(o, minLen) {
  4979. var _context2;
  4980. if (!o) return;
  4981. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  4982. var n = _sliceInstanceProperty2(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1);
  4983. if (n === "Object" && o.constructor) n = o.constructor.name;
  4984. if (n === "Map" || n === "Set") return _Array$from(o);
  4985. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  4986. }
  4987. function _arrayLikeToArray(arr, len) {
  4988. if (len == null || len > arr.length) len = arr.length;
  4989. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  4990. return arr2;
  4991. } /**
  4992. * @flow
  4993. */
  4994. /*:: type Entity = Entity;*/
  4995. /*:: type UsersMap = { [userId: string]: boolean | any };*/
  4996. /*:: export type PermissionsMap = { [permission: string]: UsersMap };*/
  4997. var PUBLIC_KEY = '*';
  4998. var VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new _map.default(
  4999. /*:: <string, UsersMap>*/
  5000. );
  5001. VALID_PERMISSIONS.set('get', {});
  5002. VALID_PERMISSIONS.set('find', {});
  5003. VALID_PERMISSIONS.set('count', {});
  5004. VALID_PERMISSIONS.set('create', {});
  5005. VALID_PERMISSIONS.set('update', {});
  5006. VALID_PERMISSIONS.set('delete', {});
  5007. VALID_PERMISSIONS.set('addField', {});
  5008. var VALID_PERMISSIONS_EXTENDED /*: Map<string, UsersMap>*/ = new _map.default(
  5009. /*:: <string, UsersMap>*/
  5010. );
  5011. VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
  5012. /**
  5013. * Creates a new CLP.
  5014. * If no argument is given, the CLP has no permissions for anyone.
  5015. * If the argument is a Parse.User or Parse.Role, the CLP will have read and write
  5016. * permission for only that user or role.
  5017. * If the argument is any other JSON object, that object will be interpretted
  5018. * as a serialized CLP created with toJSON().
  5019. *
  5020. * <p>A CLP, or Class Level Permissions can be added to any
  5021. * <code>Parse.Schema</code> to restrict access to only a subset of users
  5022. * of your application.</p>
  5023. *
  5024. * <p>
  5025. * For get/count/find/create/update/delete/addField using the following functions:
  5026. *
  5027. * Entity is type Parse.User or Parse.Role or string
  5028. * Role is type Parse.Role or Name of Parse.Role
  5029. *
  5030. * getGetRequiresAuthentication()
  5031. * setGetRequiresAuthentication(allowed: boolean)
  5032. * getGetPointerFields()
  5033. * setGetPointerFields(pointerFields: string[])
  5034. * getGetAccess(entity: Entity)
  5035. * setGetAccess(entity: Entity, allowed: boolean)
  5036. * getPublicGetAccess()
  5037. * setPublicGetAccess(allowed: boolean)
  5038. * getRoleGetAccess(role: Role)
  5039. * setRoleGetAccess(role: Role, allowed: boolean)
  5040. * getFindRequiresAuthentication()
  5041. * setFindRequiresAuthentication(allowed: boolean)
  5042. * getFindPointerFields()
  5043. * setFindPointerFields(pointerFields: string[])
  5044. * getFindAccess(entity: Entity)
  5045. * setFindAccess(entity: Entity, allowed: boolean)
  5046. * getPublicFindAccess()
  5047. * setPublicFindAccess(allowed: boolean)
  5048. * getRoleFindAccess(role: Role)
  5049. * setRoleFindAccess(role: Role, allowed: boolean)
  5050. * getCountRequiresAuthentication()
  5051. * setCountRequiresAuthentication(allowed: boolean)
  5052. * getCountPointerFields()
  5053. * setCountPointerFields(pointerFields: string[])
  5054. * getCountAccess(entity: Entity)
  5055. * setCountAccess(entity: Entity, allowed: boolean)
  5056. * getPublicCountAccess()
  5057. * setPublicCountAccess(allowed: boolean)
  5058. * getRoleCountAccess(role: Role)
  5059. * setRoleCountAccess(role: Role, allowed: boolean)
  5060. * getCreateRequiresAuthentication()
  5061. * setCreateRequiresAuthentication(allowed: boolean)
  5062. * getCreatePointerFields()
  5063. * setCreatePointerFields(pointerFields: string[])
  5064. * getCreateAccess(entity: Entity)
  5065. * setCreateAccess(entity: Entity, allowed: boolean)
  5066. * getPublicCreateAccess()
  5067. * setPublicCreateAccess(allowed: Boolean)
  5068. * getRoleCreateAccess(role: Role)
  5069. * setRoleCreateAccess(role: Role, allowed: boolean)
  5070. * getUpdateRequiresAuthentication()
  5071. * setUpdateRequiresAuthentication(allowed: boolean)
  5072. * getUpdatePointerFields()
  5073. * setUpdatePointerFields(pointerFields: string[])
  5074. * getUpdateAccess(entity: Entity)
  5075. * setUpdateAccess(entity: Entity, allowed: boolean)
  5076. * getPublicUpdateAccess()
  5077. * setPublicUpdateAccess(allowed: boolean)
  5078. * getRoleUpdateAccess(role: Role)
  5079. * setRoleUpdateAccess(role: Role, allowed: boolean)
  5080. * getDeleteRequiresAuthentication()
  5081. * setDeleteRequiresAuthentication(allowed: boolean)
  5082. * getDeletePointerFields()
  5083. * setDeletePointerFields(pointerFields: string[])
  5084. * getDeleteAccess(entity: Entity)
  5085. * setDeleteAccess(entity: Entity, allowed: boolean)
  5086. * getPublicDeleteAccess()
  5087. * setPublicDeleteAccess(allowed: boolean)
  5088. * getRoleDeleteAccess(role: Role)
  5089. * setRoleDeleteAccess(role: Role, allowed: boolean)
  5090. * getAddFieldRequiresAuthentication()
  5091. * setAddFieldRequiresAuthentication(allowed: boolean)
  5092. * getAddFieldPointerFields()
  5093. * setAddFieldPointerFields(pointerFields: string[])
  5094. * getAddFieldAccess(entity: Entity)
  5095. * setAddFieldAccess(entity: Entity, allowed: boolean)
  5096. * getPublicAddFieldAccess()
  5097. * setPublicAddFieldAccess(allowed: boolean)
  5098. * getRoleAddFieldAccess(role: Role)
  5099. * setRoleAddFieldAccess(role: Role, allowed: boolean)
  5100. * </p>
  5101. *
  5102. * @alias Parse.CLP
  5103. */
  5104. var ParseCLP = /*#__PURE__*/function () {
  5105. /**
  5106. * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
  5107. */
  5108. function ParseCLP(userId /*: ParseUser | ParseRole | PermissionsMap*/) {
  5109. var _this = this;
  5110. (0, _classCallCheck2.default)(this, ParseCLP);
  5111. (0, _defineProperty2.default)(this, "permissionsMap", void 0);
  5112. this.permissionsMap = {};
  5113. // Initialize permissions Map with default permissions
  5114. var _iterator = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS).call(VALID_PERMISSIONS)),
  5115. _step;
  5116. try {
  5117. var _loop = function _loop() {
  5118. var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
  5119. operation = _step$value[0],
  5120. group = _step$value[1];
  5121. _this.permissionsMap[operation] = (0, _assign.default)({}, group);
  5122. var action = operation.charAt(0).toUpperCase() + (0, _slice.default)(operation).call(operation, 1);
  5123. _this["get".concat(action, "RequiresAuthentication")] = function () {
  5124. return this._getAccess(operation, 'requiresAuthentication');
  5125. };
  5126. _this["set".concat(action, "RequiresAuthentication")] = function (allowed) {
  5127. this._setAccess(operation, 'requiresAuthentication', allowed);
  5128. };
  5129. _this["get".concat(action, "PointerFields")] = function () {
  5130. return this._getAccess(operation, 'pointerFields', false);
  5131. };
  5132. _this["set".concat(action, "PointerFields")] = function (pointerFields) {
  5133. this._setArrayAccess(operation, 'pointerFields', pointerFields);
  5134. };
  5135. _this["get".concat(action, "Access")] = function (entity) {
  5136. return this._getAccess(operation, entity);
  5137. };
  5138. _this["set".concat(action, "Access")] = function (entity, allowed) {
  5139. this._setAccess(operation, entity, allowed);
  5140. };
  5141. _this["getPublic".concat(action, "Access")] = function () {
  5142. return this["get".concat(action, "Access")](PUBLIC_KEY);
  5143. };
  5144. _this["setPublic".concat(action, "Access")] = function (allowed) {
  5145. this["set".concat(action, "Access")](PUBLIC_KEY, allowed);
  5146. };
  5147. _this["getRole".concat(action, "Access")] = function (role) {
  5148. return this["get".concat(action, "Access")](this._getRoleName(role));
  5149. };
  5150. _this["setRole".concat(action, "Access")] = function (role, allowed) {
  5151. this["set".concat(action, "Access")](this._getRoleName(role), allowed);
  5152. };
  5153. };
  5154. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5155. _loop();
  5156. }
  5157. // Initialize permissions Map with default extended permissions
  5158. } catch (err) {
  5159. _iterator.e(err);
  5160. } finally {
  5161. _iterator.f();
  5162. }
  5163. var _iterator2 = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS_EXTENDED).call(VALID_PERMISSIONS_EXTENDED)),
  5164. _step2;
  5165. try {
  5166. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  5167. var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
  5168. operation = _step2$value[0],
  5169. group = _step2$value[1];
  5170. this.permissionsMap[operation] = (0, _assign.default)({}, group);
  5171. }
  5172. } catch (err) {
  5173. _iterator2.e(err);
  5174. } finally {
  5175. _iterator2.f();
  5176. }
  5177. if (userId && (0, _typeof2.default)(userId) === 'object') {
  5178. if (userId instanceof _ParseUser.default) {
  5179. this.setReadAccess(userId, true);
  5180. this.setWriteAccess(userId, true);
  5181. } else if (userId instanceof _ParseRole.default) {
  5182. this.setRoleReadAccess(userId, true);
  5183. this.setRoleWriteAccess(userId, true);
  5184. } else {
  5185. for (var _permission in userId) {
  5186. var _context;
  5187. var users = userId[_permission];
  5188. var isValidPermission = !!VALID_PERMISSIONS.get(_permission);
  5189. var isValidPermissionExtended = !!VALID_PERMISSIONS_EXTENDED.get(_permission);
  5190. var isValidGroupPermission = (0, _includes.default)(_context = ['readUserFields', 'writeUserFields']).call(_context, _permission);
  5191. if (typeof _permission !== 'string' || !(isValidPermission || isValidPermissionExtended || isValidGroupPermission)) {
  5192. throw new TypeError('Tried to create an CLP with an invalid permission type.');
  5193. }
  5194. if (isValidGroupPermission) {
  5195. if ((0, _every.default)(users).call(users, function (pointer) {
  5196. return typeof pointer === 'string';
  5197. })) {
  5198. this.permissionsMap[_permission] = users;
  5199. continue;
  5200. } else {
  5201. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  5202. }
  5203. }
  5204. for (var user in users) {
  5205. var allowed = users[user];
  5206. if (typeof allowed !== 'boolean' && !isValidPermissionExtended && user !== 'pointerFields') {
  5207. throw new TypeError('Tried to create an CLP with an invalid permission value.');
  5208. }
  5209. this.permissionsMap[_permission][user] = allowed;
  5210. }
  5211. }
  5212. }
  5213. } else if (typeof userId === 'function') {
  5214. throw new TypeError('ParseCLP constructed with a function. Did you forget ()?');
  5215. }
  5216. }
  5217. /**
  5218. * Returns a JSON-encoded version of the CLP.
  5219. *
  5220. * @returns {object}
  5221. */
  5222. (0, _createClass2.default)(ParseCLP, [{
  5223. key: "toJSON",
  5224. value: function toJSON() /*: PermissionsMap*/{
  5225. return _objectSpread({}, this.permissionsMap);
  5226. }
  5227. /**
  5228. * Returns whether this CLP is equal to another object
  5229. *
  5230. * @param other The other object to compare to
  5231. * @returns {boolean}
  5232. */
  5233. }, {
  5234. key: "equals",
  5235. value: function equals(other /*: ParseCLP*/) /*: boolean*/{
  5236. if (!(other instanceof ParseCLP)) {
  5237. return false;
  5238. }
  5239. var permissions = (0, _keys.default)(this.permissionsMap);
  5240. var otherPermissions = (0, _keys.default)(other.permissionsMap);
  5241. if (permissions.length !== otherPermissions.length) {
  5242. return false;
  5243. }
  5244. for (var _permission2 in this.permissionsMap) {
  5245. if (!other.permissionsMap[_permission2]) {
  5246. return false;
  5247. }
  5248. var users = (0, _keys.default)(this.permissionsMap[_permission2]);
  5249. var otherUsers = (0, _keys.default)(other.permissionsMap[_permission2]);
  5250. if (users.length !== otherUsers.length) {
  5251. return false;
  5252. }
  5253. for (var user in this.permissionsMap[_permission2]) {
  5254. if (!other.permissionsMap[_permission2][user]) {
  5255. return false;
  5256. }
  5257. if (this.permissionsMap[_permission2][user] !== other.permissionsMap[_permission2][user]) {
  5258. return false;
  5259. }
  5260. }
  5261. }
  5262. return true;
  5263. }
  5264. }, {
  5265. key: "_getRoleName",
  5266. value: function _getRoleName(role /*: ParseRole | string*/) /*: string*/{
  5267. var name = role;
  5268. if (role instanceof _ParseRole.default) {
  5269. // Normalize to the String name
  5270. name = role.getName();
  5271. }
  5272. if (typeof name !== 'string') {
  5273. throw new TypeError('role must be a Parse.Role or a String');
  5274. }
  5275. return "role:".concat(name);
  5276. }
  5277. }, {
  5278. key: "_parseEntity",
  5279. value: function _parseEntity(entity /*: Entity*/) {
  5280. var userId = entity;
  5281. if (userId instanceof _ParseUser.default) {
  5282. userId = userId.id;
  5283. if (!userId) {
  5284. throw new Error('Cannot get access for a Parse.User without an id.');
  5285. }
  5286. } else if (userId instanceof _ParseRole.default) {
  5287. userId = this._getRoleName(userId);
  5288. }
  5289. if (typeof userId !== 'string') {
  5290. throw new TypeError('userId must be a string.');
  5291. }
  5292. return userId;
  5293. }
  5294. }, {
  5295. key: "_setAccess",
  5296. value: function _setAccess(permission /*: string*/, userId /*: Entity*/, allowed /*: boolean*/) {
  5297. userId = this._parseEntity(userId);
  5298. if (typeof allowed !== 'boolean') {
  5299. throw new TypeError('allowed must be either true or false.');
  5300. }
  5301. var permissions = this.permissionsMap[permission][userId];
  5302. if (!permissions) {
  5303. if (!allowed) {
  5304. // The user already doesn't have this permission, so no action is needed
  5305. return;
  5306. } else {
  5307. this.permissionsMap[permission][userId] = {};
  5308. }
  5309. }
  5310. if (allowed) {
  5311. this.permissionsMap[permission][userId] = true;
  5312. } else {
  5313. delete this.permissionsMap[permission][userId];
  5314. }
  5315. }
  5316. }, {
  5317. key: "_getAccess",
  5318. value: function _getAccess(permission /*: string*/, userId /*: Entity*/) /*: boolean | string[]*/{
  5319. var returnBoolean = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  5320. userId = this._parseEntity(userId);
  5321. var permissions = this.permissionsMap[permission][userId];
  5322. if (returnBoolean) {
  5323. if (!permissions) {
  5324. return false;
  5325. }
  5326. return !!this.permissionsMap[permission][userId];
  5327. }
  5328. return permissions;
  5329. }
  5330. }, {
  5331. key: "_setArrayAccess",
  5332. value: function _setArrayAccess(permission /*: string*/, userId /*: Entity*/, fields /*: string*/) {
  5333. userId = this._parseEntity(userId);
  5334. var permissions = this.permissionsMap[permission][userId];
  5335. if (!permissions) {
  5336. this.permissionsMap[permission][userId] = [];
  5337. }
  5338. if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
  5339. delete this.permissionsMap[permission][userId];
  5340. } else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, function (field) {
  5341. return typeof field === 'string';
  5342. })) {
  5343. this.permissionsMap[permission][userId] = fields;
  5344. } else {
  5345. throw new TypeError('fields must be an array of strings or undefined.');
  5346. }
  5347. }
  5348. }, {
  5349. key: "_setGroupPointerPermission",
  5350. value: function _setGroupPointerPermission(operation /*: string*/, pointerFields /*: string[]*/) {
  5351. var fields = this.permissionsMap[operation];
  5352. if (!fields) {
  5353. this.permissionsMap[operation] = [];
  5354. }
  5355. if (!pointerFields || (0, _isArray.default)(pointerFields) && pointerFields.length === 0) {
  5356. delete this.permissionsMap[operation];
  5357. } else if ((0, _isArray.default)(pointerFields) && (0, _every.default)(pointerFields).call(pointerFields, function (field) {
  5358. return typeof field === 'string';
  5359. })) {
  5360. this.permissionsMap[operation] = pointerFields;
  5361. } else {
  5362. throw new TypeError("".concat(operation, ".pointerFields must be an array of strings or undefined."));
  5363. }
  5364. }
  5365. }, {
  5366. key: "_getGroupPointerPermissions",
  5367. value: function _getGroupPointerPermissions(operation /*: string*/) /*: string[]*/{
  5368. return this.permissionsMap[operation];
  5369. }
  5370. /**
  5371. * Sets user pointer fields to allow permission for get/count/find operations.
  5372. *
  5373. * @param {string[]} pointerFields User pointer fields
  5374. */
  5375. }, {
  5376. key: "setReadUserFields",
  5377. value: function setReadUserFields(pointerFields /*: string[]*/) {
  5378. this._setGroupPointerPermission('readUserFields', pointerFields);
  5379. }
  5380. /**
  5381. * @returns {string[]} User pointer fields
  5382. */
  5383. }, {
  5384. key: "getReadUserFields",
  5385. value: function getReadUserFields() /*: string[]*/{
  5386. return this._getGroupPointerPermissions('readUserFields');
  5387. }
  5388. /**
  5389. * Sets user pointer fields to allow permission for create/delete/update/addField operations
  5390. *
  5391. * @param {string[]} pointerFields User pointer fields
  5392. */
  5393. }, {
  5394. key: "setWriteUserFields",
  5395. value: function setWriteUserFields(pointerFields /*: string[]*/) {
  5396. this._setGroupPointerPermission('writeUserFields', pointerFields);
  5397. }
  5398. /**
  5399. * @returns {string[]} User pointer fields
  5400. */
  5401. }, {
  5402. key: "getWriteUserFields",
  5403. value: function getWriteUserFields() /*: string[]*/{
  5404. return this._getGroupPointerPermissions('writeUserFields');
  5405. }
  5406. /**
  5407. * Sets whether the given user is allowed to retrieve fields from this class.
  5408. *
  5409. * @param userId An instance of Parse.User or its objectId.
  5410. * @param {string[]} fields fields to be protected
  5411. */
  5412. }, {
  5413. key: "setProtectedFields",
  5414. value: function setProtectedFields(userId /*: Entity*/, fields /*: string[]*/) {
  5415. this._setArrayAccess('protectedFields', userId, fields);
  5416. }
  5417. /**
  5418. * Returns array of fields are accessable to this user.
  5419. *
  5420. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  5421. * @returns {string[]}
  5422. */
  5423. }, {
  5424. key: "getProtectedFields",
  5425. value: function getProtectedFields(userId /*: Entity*/) /*: string[]*/{
  5426. return this._getAccess('protectedFields', userId, false);
  5427. }
  5428. /**
  5429. * Sets whether the given user is allowed to read from this class.
  5430. *
  5431. * @param userId An instance of Parse.User or its objectId.
  5432. * @param {boolean} allowed whether that user should have read access.
  5433. */
  5434. }, {
  5435. key: "setReadAccess",
  5436. value: function setReadAccess(userId /*: Entity*/, allowed /*: boolean*/) {
  5437. this._setAccess('find', userId, allowed);
  5438. this._setAccess('get', userId, allowed);
  5439. this._setAccess('count', userId, allowed);
  5440. }
  5441. /**
  5442. * Get whether the given user id is *explicitly* allowed to read from this class.
  5443. * Even if this returns false, the user may still be able to access it if
  5444. * getPublicReadAccess returns true or a role that the user belongs to has
  5445. * write access.
  5446. *
  5447. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  5448. * @returns {boolean}
  5449. */
  5450. }, {
  5451. key: "getReadAccess",
  5452. value: function getReadAccess(userId /*: Entity*/) /*: boolean*/{
  5453. return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
  5454. }
  5455. /**
  5456. * Sets whether the given user id is allowed to write to this class.
  5457. *
  5458. * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
  5459. * @param {boolean} allowed Whether that user should have write access.
  5460. */
  5461. }, {
  5462. key: "setWriteAccess",
  5463. value: function setWriteAccess(userId /*: Entity*/, allowed /*: boolean*/) {
  5464. this._setAccess('create', userId, allowed);
  5465. this._setAccess('update', userId, allowed);
  5466. this._setAccess('delete', userId, allowed);
  5467. this._setAccess('addField', userId, allowed);
  5468. }
  5469. /**
  5470. * Gets whether the given user id is *explicitly* allowed to write to this class.
  5471. * Even if this returns false, the user may still be able to write it if
  5472. * getPublicWriteAccess returns true or a role that the user belongs to has
  5473. * write access.
  5474. *
  5475. * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
  5476. * @returns {boolean}
  5477. */
  5478. }, {
  5479. key: "getWriteAccess",
  5480. value: function getWriteAccess(userId /*: Entity*/) /*: boolean*/{
  5481. return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
  5482. }
  5483. /**
  5484. * Sets whether the public is allowed to read from this class.
  5485. *
  5486. * @param {boolean} allowed
  5487. */
  5488. }, {
  5489. key: "setPublicReadAccess",
  5490. value: function setPublicReadAccess(allowed /*: boolean*/) {
  5491. this.setReadAccess(PUBLIC_KEY, allowed);
  5492. }
  5493. /**
  5494. * Gets whether the public is allowed to read from this class.
  5495. *
  5496. * @returns {boolean}
  5497. */
  5498. }, {
  5499. key: "getPublicReadAccess",
  5500. value: function getPublicReadAccess() /*: boolean*/{
  5501. return this.getReadAccess(PUBLIC_KEY);
  5502. }
  5503. /**
  5504. * Sets whether the public is allowed to write to this class.
  5505. *
  5506. * @param {boolean} allowed
  5507. */
  5508. }, {
  5509. key: "setPublicWriteAccess",
  5510. value: function setPublicWriteAccess(allowed /*: boolean*/) {
  5511. this.setWriteAccess(PUBLIC_KEY, allowed);
  5512. }
  5513. /**
  5514. * Gets whether the public is allowed to write to this class.
  5515. *
  5516. * @returns {boolean}
  5517. */
  5518. }, {
  5519. key: "getPublicWriteAccess",
  5520. value: function getPublicWriteAccess() /*: boolean*/{
  5521. return this.getWriteAccess(PUBLIC_KEY);
  5522. }
  5523. /**
  5524. * Sets whether the public is allowed to protect fields in this class.
  5525. *
  5526. * @param {string[]} fields
  5527. */
  5528. }, {
  5529. key: "setPublicProtectedFields",
  5530. value: function setPublicProtectedFields(fields /*: string[]*/) {
  5531. this.setProtectedFields(PUBLIC_KEY, fields);
  5532. }
  5533. /**
  5534. * Gets whether the public is allowed to read fields from this class.
  5535. *
  5536. * @returns {string[]}
  5537. */
  5538. }, {
  5539. key: "getPublicProtectedFields",
  5540. value: function getPublicProtectedFields() /*: string[]*/{
  5541. return this.getProtectedFields(PUBLIC_KEY);
  5542. }
  5543. /**
  5544. * Gets whether users belonging to the given role are allowed
  5545. * to read from this class. Even if this returns false, the role may
  5546. * still be able to write it if a parent role has read access.
  5547. *
  5548. * @param role The name of the role, or a Parse.Role object.
  5549. * @returns {boolean} true if the role has read access. false otherwise.
  5550. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5551. */
  5552. }, {
  5553. key: "getRoleReadAccess",
  5554. value: function getRoleReadAccess(role /*: ParseRole | string*/) /*: boolean*/{
  5555. return this.getReadAccess(this._getRoleName(role));
  5556. }
  5557. /**
  5558. * Gets whether users belonging to the given role are allowed
  5559. * to write to this user. Even if this returns false, the role may
  5560. * still be able to write it if a parent role has write access.
  5561. *
  5562. * @param role The name of the role, or a Parse.Role object.
  5563. * @returns {boolean} true if the role has write access. false otherwise.
  5564. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5565. */
  5566. }, {
  5567. key: "getRoleWriteAccess",
  5568. value: function getRoleWriteAccess(role /*: ParseRole | string*/) /*: boolean*/{
  5569. return this.getWriteAccess(this._getRoleName(role));
  5570. }
  5571. /**
  5572. * Sets whether users belonging to the given role are allowed
  5573. * to read from this class.
  5574. *
  5575. * @param role The name of the role, or a Parse.Role object.
  5576. * @param {boolean} allowed Whether the given role can read this object.
  5577. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5578. */
  5579. }, {
  5580. key: "setRoleReadAccess",
  5581. value: function setRoleReadAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
  5582. this.setReadAccess(this._getRoleName(role), allowed);
  5583. }
  5584. /**
  5585. * Sets whether users belonging to the given role are allowed
  5586. * to write to this class.
  5587. *
  5588. * @param role The name of the role, or a Parse.Role object.
  5589. * @param {boolean} allowed Whether the given role can write this object.
  5590. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5591. */
  5592. }, {
  5593. key: "setRoleWriteAccess",
  5594. value: function setRoleWriteAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
  5595. this.setWriteAccess(this._getRoleName(role), allowed);
  5596. }
  5597. /**
  5598. * Gets whether users belonging to the given role are allowed
  5599. * to count to this user. Even if this returns false, the role may
  5600. * still be able to count it if a parent role has count access.
  5601. *
  5602. * @param role The name of the role, or a Parse.Role object.
  5603. * @returns {string[]}
  5604. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5605. */
  5606. }, {
  5607. key: "getRoleProtectedFields",
  5608. value: function getRoleProtectedFields(role /*: ParseRole | string*/) /*: string[]*/{
  5609. return this.getProtectedFields(this._getRoleName(role));
  5610. }
  5611. /**
  5612. * Sets whether users belonging to the given role are allowed
  5613. * to set access field in this class.
  5614. *
  5615. * @param role The name of the role, or a Parse.Role object.
  5616. * @param {string[]} fields Fields to be protected by Role.
  5617. * @throws {TypeError} If role is neither a Parse.Role nor a String.
  5618. */
  5619. }, {
  5620. key: "setRoleProtectedFields",
  5621. value: function setRoleProtectedFields(role /*: ParseRole | string*/, fields /*: string[]*/) {
  5622. this.setProtectedFields(this._getRoleName(role), fields);
  5623. }
  5624. }]);
  5625. return ParseCLP;
  5626. }();
  5627. var _default = ParseCLP;
  5628. exports.default = _default;
  5629. },{"./ParseRole":31,"./ParseUser":34,"@babel/runtime-corejs3/core-js-stable/array/from":56,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/entries":60,"@babel/runtime-corejs3/core-js-stable/instance/every":61,"@babel/runtime-corejs3/core-js-stable/instance/filter":62,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/instance/includes":66,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/map":77,"@babel/runtime-corejs3/core-js-stable/object/assign":79,"@babel/runtime-corejs3/core-js-stable/object/define-properties":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":86,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":87,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/symbol":96,"@babel/runtime-corejs3/core-js/get-iterator-method":100,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/slicedToArray":140,"@babel/runtime-corejs3/helpers/typeof":145}],20:[function(_dereq_,module,exports){
  5630. "use strict";
  5631. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5632. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5633. _Object$defineProperty(exports, "__esModule", {
  5634. value: true
  5635. });
  5636. exports.default = void 0;
  5637. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  5638. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  5639. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  5640. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  5641. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  5642. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  5643. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  5644. var _decode = _interopRequireDefault(_dereq_("./decode"));
  5645. var _encode = _interopRequireDefault(_dereq_("./encode"));
  5646. var _escape2 = _interopRequireDefault(_dereq_("./escape"));
  5647. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  5648. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  5649. /**
  5650. * @flow
  5651. */
  5652. /*:: import type { RequestOptions } from './RESTController';*/
  5653. /**
  5654. * Parse.Config is a local representation of configuration data that
  5655. * can be set from the Parse dashboard.
  5656. *
  5657. * @alias Parse.Config
  5658. */
  5659. var ParseConfig = /*#__PURE__*/function () {
  5660. function ParseConfig() {
  5661. (0, _classCallCheck2.default)(this, ParseConfig);
  5662. (0, _defineProperty2.default)(this, "attributes", void 0);
  5663. (0, _defineProperty2.default)(this, "_escapedAttributes", void 0);
  5664. this.attributes = {};
  5665. this._escapedAttributes = {};
  5666. }
  5667. /**
  5668. * Gets the value of an attribute.
  5669. *
  5670. * @param {string} attr The name of an attribute.
  5671. * @returns {*}
  5672. */
  5673. (0, _createClass2.default)(ParseConfig, [{
  5674. key: "get",
  5675. value: function (attr /*: string*/) /*: any*/{
  5676. return this.attributes[attr];
  5677. }
  5678. /**
  5679. * Gets the HTML-escaped value of an attribute.
  5680. *
  5681. * @param {string} attr The name of an attribute.
  5682. * @returns {string}
  5683. */
  5684. }, {
  5685. key: "escape",
  5686. value: function (attr /*: string*/) /*: string*/{
  5687. var html = this._escapedAttributes[attr];
  5688. if (html) {
  5689. return html;
  5690. }
  5691. var val = this.attributes[attr];
  5692. var escaped = '';
  5693. if (val != null) {
  5694. escaped = (0, _escape2.default)(val.toString());
  5695. }
  5696. this._escapedAttributes[attr] = escaped;
  5697. return escaped;
  5698. }
  5699. /**
  5700. * Retrieves the most recently-fetched configuration object, either from
  5701. * memory or from local storage if necessary.
  5702. *
  5703. * @static
  5704. * @returns {Parse.Config} The most recently-fetched Parse.Config if it
  5705. * exists, else an empty Parse.Config.
  5706. */
  5707. }], [{
  5708. key: "current",
  5709. value: function () {
  5710. var controller = _CoreManager.default.getConfigController();
  5711. return controller.current();
  5712. }
  5713. /**
  5714. * Gets a new configuration object from the server.
  5715. *
  5716. * @static
  5717. * @param {object} options
  5718. * Valid options are:<ul>
  5719. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  5720. * be used for this request.
  5721. * </ul>
  5722. * @returns {Promise} A promise that is resolved with a newly-created
  5723. * configuration object when the get completes.
  5724. */
  5725. }, {
  5726. key: "get",
  5727. value: function () {
  5728. var options /*: RequestOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5729. var controller = _CoreManager.default.getConfigController();
  5730. return controller.get(options);
  5731. }
  5732. /**
  5733. * Save value keys to the server.
  5734. *
  5735. * @static
  5736. * @param {object} attrs The config parameters and values.
  5737. * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed
  5738. * in `attrs` should be retrievable only by using the master key.
  5739. * For example: `param1: true` makes `param1` only retrievable by using the master key.
  5740. * If a parameter is not provided or set to `false`, it can be retrieved without
  5741. * using the master key.
  5742. * @returns {Promise} A promise that is resolved with a newly-created
  5743. * configuration object or with the current with the update.
  5744. */
  5745. }, {
  5746. key: "save",
  5747. value: function (attrs /*: { [key: string]: any }*/, masterKeyOnlyFlags /*: { [key: string]: any }*/) {
  5748. var controller = _CoreManager.default.getConfigController();
  5749. //To avoid a mismatch with the local and the cloud config we get a new version
  5750. return controller.save(attrs, masterKeyOnlyFlags).then(function () {
  5751. return controller.get({
  5752. useMasterKey: true
  5753. });
  5754. }, function (error) {
  5755. return _promise.default.reject(error);
  5756. });
  5757. }
  5758. /**
  5759. * Used for testing
  5760. *
  5761. * @private
  5762. */
  5763. }, {
  5764. key: "_clearCache",
  5765. value: function () {
  5766. currentConfig = null;
  5767. }
  5768. }]);
  5769. return ParseConfig;
  5770. }();
  5771. var currentConfig = null;
  5772. var CURRENT_CONFIG_KEY = 'currentConfig';
  5773. function decodePayload(data) {
  5774. try {
  5775. var json = JSON.parse(data);
  5776. if (json && (0, _typeof2.default)(json) === 'object') {
  5777. return (0, _decode.default)(json);
  5778. }
  5779. } catch (e) {
  5780. return null;
  5781. }
  5782. }
  5783. var DefaultController = {
  5784. current: function () {
  5785. if (currentConfig) {
  5786. return currentConfig;
  5787. }
  5788. var config = new ParseConfig();
  5789. var storagePath = _Storage.default.generatePath(CURRENT_CONFIG_KEY);
  5790. if (!_Storage.default.async()) {
  5791. var configData = _Storage.default.getItem(storagePath);
  5792. if (configData) {
  5793. var attributes = decodePayload(configData);
  5794. if (attributes) {
  5795. config.attributes = attributes;
  5796. currentConfig = config;
  5797. }
  5798. }
  5799. return config;
  5800. }
  5801. // Return a promise for async storage controllers
  5802. return _Storage.default.getItemAsync(storagePath).then(function (configData) {
  5803. if (configData) {
  5804. var _attributes = decodePayload(configData);
  5805. if (_attributes) {
  5806. config.attributes = _attributes;
  5807. currentConfig = config;
  5808. }
  5809. }
  5810. return config;
  5811. });
  5812. },
  5813. get: function () {
  5814. var options /*: RequestOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5815. var RESTController = _CoreManager.default.getRESTController();
  5816. return RESTController.request('GET', 'config', {}, options).then(function (response) {
  5817. if (!response || !response.params) {
  5818. var error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Config JSON response invalid.');
  5819. return _promise.default.reject(error);
  5820. }
  5821. var config = new ParseConfig();
  5822. config.attributes = {};
  5823. for (var attr in response.params) {
  5824. config.attributes[attr] = (0, _decode.default)(response.params[attr]);
  5825. }
  5826. currentConfig = config;
  5827. return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(function () {
  5828. return config;
  5829. });
  5830. });
  5831. },
  5832. save: function (attrs /*: { [key: string]: any }*/, masterKeyOnlyFlags /*: { [key: string]: any }*/) {
  5833. var RESTController = _CoreManager.default.getRESTController();
  5834. var encodedAttrs = {};
  5835. for (var _key in attrs) {
  5836. encodedAttrs[_key] = (0, _encode.default)(attrs[_key]);
  5837. }
  5838. return RESTController.request('PUT', 'config', {
  5839. params: encodedAttrs,
  5840. masterKeyOnly: masterKeyOnlyFlags
  5841. }, {
  5842. useMasterKey: true
  5843. }).then(function (response) {
  5844. if (response && response.result) {
  5845. return _promise.default.resolve();
  5846. } else {
  5847. var error = new _ParseError.default(_ParseError.default.INTERNAL_SERVER_ERROR, 'Error occured updating Config.');
  5848. return _promise.default.reject(error);
  5849. }
  5850. });
  5851. }
  5852. };
  5853. _CoreManager.default.setConfigController(DefaultController);
  5854. var _default = ParseConfig;
  5855. exports.default = _default;
  5856. },{"./CoreManager":4,"./ParseError":21,"./Storage":39,"./decode":46,"./encode":47,"./escape":49,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],21:[function(_dereq_,module,exports){
  5857. "use strict";
  5858. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  5859. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  5860. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  5861. _Object$defineProperty2(exports, "__esModule", {
  5862. value: true
  5863. });
  5864. exports.default = void 0;
  5865. var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  5866. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  5867. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  5868. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  5869. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  5870. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  5871. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  5872. var _wrapNativeSuper2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
  5873. function _createSuper(Derived) {
  5874. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  5875. return function () {
  5876. var Super = (0, _getPrototypeOf2.default)(Derived),
  5877. result;
  5878. if (hasNativeReflectConstruct) {
  5879. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  5880. result = _Reflect$construct(Super, arguments, NewTarget);
  5881. } else {
  5882. result = Super.apply(this, arguments);
  5883. }
  5884. return (0, _possibleConstructorReturn2.default)(this, result);
  5885. };
  5886. }
  5887. function _isNativeReflectConstruct() {
  5888. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  5889. if (_Reflect$construct.sham) return false;
  5890. if (typeof Proxy === "function") return true;
  5891. try {
  5892. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  5893. return true;
  5894. } catch (e) {
  5895. return false;
  5896. }
  5897. }
  5898. /**
  5899. * Constructs a new Parse.Error object with the given code and message.
  5900. *
  5901. * @alias Parse.Error
  5902. */
  5903. var ParseError = /*#__PURE__*/function (_Error) {
  5904. (0, _inherits2.default)(ParseError, _Error);
  5905. var _super = _createSuper(ParseError);
  5906. /**
  5907. * @param {number} code An error code constant from <code>Parse.Error</code>.
  5908. * @param {string} message A detailed description of the error.
  5909. */
  5910. function ParseError(code, message) {
  5911. var _this;
  5912. (0, _classCallCheck2.default)(this, ParseError);
  5913. _this = _super.call(this, message);
  5914. _this.code = code;
  5915. (0, _defineProperty.default)((0, _assertThisInitialized2.default)(_this), 'message', {
  5916. enumerable: true,
  5917. value: message
  5918. });
  5919. return _this;
  5920. }
  5921. (0, _createClass2.default)(ParseError, [{
  5922. key: "toString",
  5923. value: function () {
  5924. return 'ParseError: ' + this.code + ' ' + this.message;
  5925. }
  5926. }]);
  5927. return ParseError;
  5928. }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
  5929. /**
  5930. * Error code indicating some error other than those enumerated here.
  5931. *
  5932. * @property {number} OTHER_CAUSE
  5933. * @static
  5934. */
  5935. ParseError.OTHER_CAUSE = -1;
  5936. /**
  5937. * Error code indicating that something has gone wrong with the server.
  5938. *
  5939. * @property {number} INTERNAL_SERVER_ERROR
  5940. * @static
  5941. */
  5942. ParseError.INTERNAL_SERVER_ERROR = 1;
  5943. /**
  5944. * Error code indicating the connection to the Parse servers failed.
  5945. *
  5946. * @property {number} CONNECTION_FAILED
  5947. * @static
  5948. */
  5949. ParseError.CONNECTION_FAILED = 100;
  5950. /**
  5951. * Error code indicating the specified object doesn't exist.
  5952. *
  5953. * @property {number} OBJECT_NOT_FOUND
  5954. * @static
  5955. */
  5956. ParseError.OBJECT_NOT_FOUND = 101;
  5957. /**
  5958. * Error code indicating you tried to query with a datatype that doesn't
  5959. * support it, like exact matching an array or object.
  5960. *
  5961. * @property {number} INVALID_QUERY
  5962. * @static
  5963. */
  5964. ParseError.INVALID_QUERY = 102;
  5965. /**
  5966. * Error code indicating a missing or invalid classname. Classnames are
  5967. * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
  5968. * only valid characters.
  5969. *
  5970. * @property {number} INVALID_CLASS_NAME
  5971. * @static
  5972. */
  5973. ParseError.INVALID_CLASS_NAME = 103;
  5974. /**
  5975. * Error code indicating an unspecified object id.
  5976. *
  5977. * @property {number} MISSING_OBJECT_ID
  5978. * @static
  5979. */
  5980. ParseError.MISSING_OBJECT_ID = 104;
  5981. /**
  5982. * Error code indicating an invalid key name. Keys are case-sensitive. They
  5983. * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
  5984. *
  5985. * @property {number} INVALID_KEY_NAME
  5986. * @static
  5987. */
  5988. ParseError.INVALID_KEY_NAME = 105;
  5989. /**
  5990. * Error code indicating a malformed pointer. You should not see this unless
  5991. * you have been mucking about changing internal Parse code.
  5992. *
  5993. * @property {number} INVALID_POINTER
  5994. * @static
  5995. */
  5996. ParseError.INVALID_POINTER = 106;
  5997. /**
  5998. * Error code indicating that badly formed JSON was received upstream. This
  5999. * either indicates you have done something unusual with modifying how
  6000. * things encode to JSON, or the network is failing badly.
  6001. *
  6002. * @property {number} INVALID_JSON
  6003. * @static
  6004. */
  6005. ParseError.INVALID_JSON = 107;
  6006. /**
  6007. * Error code indicating that the feature you tried to access is only
  6008. * available internally for testing purposes.
  6009. *
  6010. * @property {number} COMMAND_UNAVAILABLE
  6011. * @static
  6012. */
  6013. ParseError.COMMAND_UNAVAILABLE = 108;
  6014. /**
  6015. * You must call Parse.initialize before using the Parse library.
  6016. *
  6017. * @property {number} NOT_INITIALIZED
  6018. * @static
  6019. */
  6020. ParseError.NOT_INITIALIZED = 109;
  6021. /**
  6022. * Error code indicating that a field was set to an inconsistent type.
  6023. *
  6024. * @property {number} INCORRECT_TYPE
  6025. * @static
  6026. */
  6027. ParseError.INCORRECT_TYPE = 111;
  6028. /**
  6029. * Error code indicating an invalid channel name. A channel name is either
  6030. * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
  6031. * characters and starts with a letter.
  6032. *
  6033. * @property {number} INVALID_CHANNEL_NAME
  6034. * @static
  6035. */
  6036. ParseError.INVALID_CHANNEL_NAME = 112;
  6037. /**
  6038. * Error code indicating that push is misconfigured.
  6039. *
  6040. * @property {number} PUSH_MISCONFIGURED
  6041. * @static
  6042. */
  6043. ParseError.PUSH_MISCONFIGURED = 115;
  6044. /**
  6045. * Error code indicating that the object is too large.
  6046. *
  6047. * @property {number} OBJECT_TOO_LARGE
  6048. * @static
  6049. */
  6050. ParseError.OBJECT_TOO_LARGE = 116;
  6051. /**
  6052. * Error code indicating that the operation isn't allowed for clients.
  6053. *
  6054. * @property {number} OPERATION_FORBIDDEN
  6055. * @static
  6056. */
  6057. ParseError.OPERATION_FORBIDDEN = 119;
  6058. /**
  6059. * Error code indicating the result was not found in the cache.
  6060. *
  6061. * @property {number} CACHE_MISS
  6062. * @static
  6063. */
  6064. ParseError.CACHE_MISS = 120;
  6065. /**
  6066. * Error code indicating that an invalid key was used in a nested
  6067. * JSONObject.
  6068. *
  6069. * @property {number} INVALID_NESTED_KEY
  6070. * @static
  6071. */
  6072. ParseError.INVALID_NESTED_KEY = 121;
  6073. /**
  6074. * Error code indicating that an invalid filename was used for ParseFile.
  6075. * A valid file name contains only a-zA-Z0-9_. characters and is between 1
  6076. * and 128 characters.
  6077. *
  6078. * @property {number} INVALID_FILE_NAME
  6079. * @static
  6080. */
  6081. ParseError.INVALID_FILE_NAME = 122;
  6082. /**
  6083. * Error code indicating an invalid ACL was provided.
  6084. *
  6085. * @property {number} INVALID_ACL
  6086. * @static
  6087. */
  6088. ParseError.INVALID_ACL = 123;
  6089. /**
  6090. * Error code indicating that the request timed out on the server. Typically
  6091. * this indicates that the request is too expensive to run.
  6092. *
  6093. * @property {number} TIMEOUT
  6094. * @static
  6095. */
  6096. ParseError.TIMEOUT = 124;
  6097. /**
  6098. * Error code indicating that the email address was invalid.
  6099. *
  6100. * @property {number} INVALID_EMAIL_ADDRESS
  6101. * @static
  6102. */
  6103. ParseError.INVALID_EMAIL_ADDRESS = 125;
  6104. /**
  6105. * Error code indicating a missing content type.
  6106. *
  6107. * @property {number} MISSING_CONTENT_TYPE
  6108. * @static
  6109. */
  6110. ParseError.MISSING_CONTENT_TYPE = 126;
  6111. /**
  6112. * Error code indicating a missing content length.
  6113. *
  6114. * @property {number} MISSING_CONTENT_LENGTH
  6115. * @static
  6116. */
  6117. ParseError.MISSING_CONTENT_LENGTH = 127;
  6118. /**
  6119. * Error code indicating an invalid content length.
  6120. *
  6121. * @property {number} INVALID_CONTENT_LENGTH
  6122. * @static
  6123. */
  6124. ParseError.INVALID_CONTENT_LENGTH = 128;
  6125. /**
  6126. * Error code indicating a file that was too large.
  6127. *
  6128. * @property {number} FILE_TOO_LARGE
  6129. * @static
  6130. */
  6131. ParseError.FILE_TOO_LARGE = 129;
  6132. /**
  6133. * Error code indicating an error saving a file.
  6134. *
  6135. * @property {number} FILE_SAVE_ERROR
  6136. * @static
  6137. */
  6138. ParseError.FILE_SAVE_ERROR = 130;
  6139. /**
  6140. * Error code indicating that a unique field was given a value that is
  6141. * already taken.
  6142. *
  6143. * @property {number} DUPLICATE_VALUE
  6144. * @static
  6145. */
  6146. ParseError.DUPLICATE_VALUE = 137;
  6147. /**
  6148. * Error code indicating that a role's name is invalid.
  6149. *
  6150. * @property {number} INVALID_ROLE_NAME
  6151. * @static
  6152. */
  6153. ParseError.INVALID_ROLE_NAME = 139;
  6154. /**
  6155. * Error code indicating that an application quota was exceeded. Upgrade to
  6156. * resolve.
  6157. *
  6158. * @property {number} EXCEEDED_QUOTA
  6159. * @static
  6160. */
  6161. ParseError.EXCEEDED_QUOTA = 140;
  6162. /**
  6163. * Error code indicating that a Cloud Code script failed.
  6164. *
  6165. * @property {number} SCRIPT_FAILED
  6166. * @static
  6167. */
  6168. ParseError.SCRIPT_FAILED = 141;
  6169. /**
  6170. * Error code indicating that a Cloud Code validation failed.
  6171. *
  6172. * @property {number} VALIDATION_ERROR
  6173. * @static
  6174. */
  6175. ParseError.VALIDATION_ERROR = 142;
  6176. /**
  6177. * Error code indicating that invalid image data was provided.
  6178. *
  6179. * @property {number} INVALID_IMAGE_DATA
  6180. * @static
  6181. */
  6182. ParseError.INVALID_IMAGE_DATA = 143;
  6183. /**
  6184. * Error code indicating an unsaved file.
  6185. *
  6186. * @property {number} UNSAVED_FILE_ERROR
  6187. * @static
  6188. */
  6189. ParseError.UNSAVED_FILE_ERROR = 151;
  6190. /**
  6191. * Error code indicating an invalid push time.
  6192. *
  6193. * @property {number} INVALID_PUSH_TIME_ERROR
  6194. * @static
  6195. */
  6196. ParseError.INVALID_PUSH_TIME_ERROR = 152;
  6197. /**
  6198. * Error code indicating an error deleting a file.
  6199. *
  6200. * @property {number} FILE_DELETE_ERROR
  6201. * @static
  6202. */
  6203. ParseError.FILE_DELETE_ERROR = 153;
  6204. /**
  6205. * Error code indicating an error deleting an unnamed file.
  6206. *
  6207. * @property {number} FILE_DELETE_UNNAMED_ERROR
  6208. * @static
  6209. */
  6210. ParseError.FILE_DELETE_UNNAMED_ERROR = 161;
  6211. /**
  6212. * Error code indicating that the application has exceeded its request
  6213. * limit.
  6214. *
  6215. * @property {number} REQUEST_LIMIT_EXCEEDED
  6216. * @static
  6217. */
  6218. ParseError.REQUEST_LIMIT_EXCEEDED = 155;
  6219. /**
  6220. * Error code indicating that the request was a duplicate and has been discarded due to
  6221. * idempotency rules.
  6222. *
  6223. * @property {number} DUPLICATE_REQUEST
  6224. * @static
  6225. */
  6226. ParseError.DUPLICATE_REQUEST = 159;
  6227. /**
  6228. * Error code indicating an invalid event name.
  6229. *
  6230. * @property {number} INVALID_EVENT_NAME
  6231. * @static
  6232. */
  6233. ParseError.INVALID_EVENT_NAME = 160;
  6234. /**
  6235. * Error code indicating that a field had an invalid value.
  6236. *
  6237. * @property {number} INVALID_VALUE
  6238. * @static
  6239. */
  6240. ParseError.INVALID_VALUE = 162;
  6241. /**
  6242. * Error code indicating that the username is missing or empty.
  6243. *
  6244. * @property {number} USERNAME_MISSING
  6245. * @static
  6246. */
  6247. ParseError.USERNAME_MISSING = 200;
  6248. /**
  6249. * Error code indicating that the password is missing or empty.
  6250. *
  6251. * @property {number} PASSWORD_MISSING
  6252. * @static
  6253. */
  6254. ParseError.PASSWORD_MISSING = 201;
  6255. /**
  6256. * Error code indicating that the username has already been taken.
  6257. *
  6258. * @property {number} USERNAME_TAKEN
  6259. * @static
  6260. */
  6261. ParseError.USERNAME_TAKEN = 202;
  6262. /**
  6263. * Error code indicating that the email has already been taken.
  6264. *
  6265. * @property {number} EMAIL_TAKEN
  6266. * @static
  6267. */
  6268. ParseError.EMAIL_TAKEN = 203;
  6269. /**
  6270. * Error code indicating that the email is missing, but must be specified.
  6271. *
  6272. * @property {number} EMAIL_MISSING
  6273. * @static
  6274. */
  6275. ParseError.EMAIL_MISSING = 204;
  6276. /**
  6277. * Error code indicating that a user with the specified email was not found.
  6278. *
  6279. * @property {number} EMAIL_NOT_FOUND
  6280. * @static
  6281. */
  6282. ParseError.EMAIL_NOT_FOUND = 205;
  6283. /**
  6284. * Error code indicating that a user object without a valid session could
  6285. * not be altered.
  6286. *
  6287. * @property {number} SESSION_MISSING
  6288. * @static
  6289. */
  6290. ParseError.SESSION_MISSING = 206;
  6291. /**
  6292. * Error code indicating that a user can only be created through signup.
  6293. *
  6294. * @property {number} MUST_CREATE_USER_THROUGH_SIGNUP
  6295. * @static
  6296. */
  6297. ParseError.MUST_CREATE_USER_THROUGH_SIGNUP = 207;
  6298. /**
  6299. * Error code indicating that an an account being linked is already linked
  6300. * to another user.
  6301. *
  6302. * @property {number} ACCOUNT_ALREADY_LINKED
  6303. * @static
  6304. */
  6305. ParseError.ACCOUNT_ALREADY_LINKED = 208;
  6306. /**
  6307. * Error code indicating that the current session token is invalid.
  6308. *
  6309. * @property {number} INVALID_SESSION_TOKEN
  6310. * @static
  6311. */
  6312. ParseError.INVALID_SESSION_TOKEN = 209;
  6313. /**
  6314. * Error code indicating an error enabling or verifying MFA
  6315. *
  6316. * @property {number} MFA_ERROR
  6317. * @static
  6318. */
  6319. ParseError.MFA_ERROR = 210;
  6320. /**
  6321. * Error code indicating that a valid MFA token must be provided
  6322. *
  6323. * @property {number} MFA_TOKEN_REQUIRED
  6324. * @static
  6325. */
  6326. ParseError.MFA_TOKEN_REQUIRED = 211;
  6327. /**
  6328. * Error code indicating that a user cannot be linked to an account because
  6329. * that account's id could not be found.
  6330. *
  6331. * @property {number} LINKED_ID_MISSING
  6332. * @static
  6333. */
  6334. ParseError.LINKED_ID_MISSING = 250;
  6335. /**
  6336. * Error code indicating that a user with a linked (e.g. Facebook) account
  6337. * has an invalid session.
  6338. *
  6339. * @property {number} INVALID_LINKED_SESSION
  6340. * @static
  6341. */
  6342. ParseError.INVALID_LINKED_SESSION = 251;
  6343. /**
  6344. * Error code indicating that a service being linked (e.g. Facebook or
  6345. * Twitter) is unsupported.
  6346. *
  6347. * @property {number} UNSUPPORTED_SERVICE
  6348. * @static
  6349. */
  6350. ParseError.UNSUPPORTED_SERVICE = 252;
  6351. /**
  6352. * Error code indicating an invalid operation occured on schema
  6353. *
  6354. * @property {number} INVALID_SCHEMA_OPERATION
  6355. * @static
  6356. */
  6357. ParseError.INVALID_SCHEMA_OPERATION = 255;
  6358. /**
  6359. * Error code indicating that there were multiple errors. Aggregate errors
  6360. * have an "errors" property, which is an array of error objects with more
  6361. * detail about each error that occurred.
  6362. *
  6363. * @property {number} AGGREGATE_ERROR
  6364. * @static
  6365. */
  6366. ParseError.AGGREGATE_ERROR = 600;
  6367. /**
  6368. * Error code indicating the client was unable to read an input file.
  6369. *
  6370. * @property {number} FILE_READ_ERROR
  6371. * @static
  6372. */
  6373. ParseError.FILE_READ_ERROR = 601;
  6374. /**
  6375. * Error code indicating a real error code is unavailable because
  6376. * we had to use an XDomainRequest object to allow CORS requests in
  6377. * Internet Explorer, which strips the body from HTTP responses that have
  6378. * a non-2XX status code.
  6379. *
  6380. * @property {number} X_DOMAIN_REQUEST
  6381. * @static
  6382. */
  6383. ParseError.X_DOMAIN_REQUEST = 602;
  6384. var _default = ParseError;
  6385. exports.default = _default;
  6386. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":92,"@babel/runtime-corejs3/helpers/assertThisInitialized":121,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/getPrototypeOf":128,"@babel/runtime-corejs3/helpers/inherits":129,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":137,"@babel/runtime-corejs3/helpers/wrapNativeSuper":147}],22:[function(_dereq_,module,exports){
  6387. "use strict";
  6388. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  6389. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  6390. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  6391. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  6392. var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  6393. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  6394. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  6395. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  6396. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  6397. _Object$defineProperty(exports, "__esModule", {
  6398. value: true
  6399. });
  6400. exports.default = void 0;
  6401. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  6402. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  6403. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  6404. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  6405. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  6406. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  6407. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  6408. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  6409. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  6410. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  6411. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  6412. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  6413. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  6414. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  6415. function ownKeys(object, enumerableOnly) {
  6416. var keys = _Object$keys2(object);
  6417. if (_Object$getOwnPropertySymbols) {
  6418. var symbols = _Object$getOwnPropertySymbols(object);
  6419. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  6420. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  6421. })), keys.push.apply(keys, symbols);
  6422. }
  6423. return keys;
  6424. }
  6425. function _objectSpread(target) {
  6426. for (var i = 1; i < arguments.length; i++) {
  6427. var _context8, _context9;
  6428. var source = null != arguments[i] ? arguments[i] : {};
  6429. i % 2 ? _forEachInstanceProperty2(_context8 = ownKeys(Object(source), !0)).call(_context8, function (key) {
  6430. (0, _defineProperty2.default)(target, key, source[key]);
  6431. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context9 = ownKeys(Object(source))).call(_context9, function (key) {
  6432. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  6433. });
  6434. }
  6435. return target;
  6436. } /**
  6437. * @flow
  6438. */ /* global XMLHttpRequest, Blob */
  6439. /*:: import type { FullOptions } from './RESTController';*/
  6440. var ParseError = _dereq_('./ParseError').default;
  6441. var XHR = null;
  6442. if (typeof XMLHttpRequest !== 'undefined') {
  6443. XHR = XMLHttpRequest;
  6444. }
  6445. XHR = _dereq_('./Xhr.weapp');
  6446. /*:: type Base64 = { base64: string };*/
  6447. /*:: type Uri = { uri: string };*/
  6448. /*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
  6449. /*:: export type FileSource =
  6450. | {
  6451. format: 'file',
  6452. file: Blob,
  6453. type: string,
  6454. }
  6455. | {
  6456. format: 'base64',
  6457. base64: string,
  6458. type: string,
  6459. }
  6460. | {
  6461. format: 'uri',
  6462. uri: string,
  6463. type: string,
  6464. };*/
  6465. function b64Digit(number /*: number*/) /*: string*/{
  6466. if (number < 26) {
  6467. return String.fromCharCode(65 + number);
  6468. }
  6469. if (number < 52) {
  6470. return String.fromCharCode(97 + (number - 26));
  6471. }
  6472. if (number < 62) {
  6473. return String.fromCharCode(48 + (number - 52));
  6474. }
  6475. if (number === 62) {
  6476. return '+';
  6477. }
  6478. if (number === 63) {
  6479. return '/';
  6480. }
  6481. throw new TypeError('Tried to encode large digit ' + number + ' in base64.');
  6482. }
  6483. /**
  6484. * A Parse.File is a local representation of a file that is saved to the Parse
  6485. * cloud.
  6486. *
  6487. * @alias Parse.File
  6488. */
  6489. var ParseFile = /*#__PURE__*/function () {
  6490. /**
  6491. * @param name {String} The file's name. This will be prefixed by a unique
  6492. * value once the file has finished saving. The file name must begin with
  6493. * an alphanumeric character, and consist of alphanumeric characters,
  6494. * periods, spaces, underscores, or dashes.
  6495. * @param data {Array} The data for the file, as either:
  6496. * 1. an Array of byte value Numbers, or
  6497. * 2. an Object like { base64: "..." } with a base64-encoded String.
  6498. * 3. an Object like { uri: "..." } with a uri String.
  6499. * 4. a File object selected with a file upload control. (3) only works
  6500. * in Firefox 3.6+, Safari 6.0.2+, Chrome 7+, and IE 10+.
  6501. * For example:
  6502. * <pre>
  6503. * var fileUploadControl = $("#profilePhotoFileUpload")[0];
  6504. * if (fileUploadControl.files.length > 0) {
  6505. * var file = fileUploadControl.files[0];
  6506. * var name = "photo.jpg";
  6507. * var parseFile = new Parse.File(name, file);
  6508. * parseFile.save().then(function() {
  6509. * // The file has been saved to Parse.
  6510. * }, function(error) {
  6511. * // The file either could not be read, or could not be saved to Parse.
  6512. * });
  6513. * }</pre>
  6514. * @param type {String} Optional Content-Type header to use for the file. If
  6515. * this is omitted, the content type will be inferred from the name's
  6516. * extension.
  6517. * @param metadata {Object} Optional key value pairs to be stored with file object
  6518. * @param tags {Object} Optional key value pairs to be stored with file object
  6519. */
  6520. function ParseFile(name /*: string*/, data /*:: ?: FileData*/, type /*:: ?: string*/, metadata /*:: ?: Object*/, tags /*:: ?: Object*/) {
  6521. (0, _classCallCheck2.default)(this, ParseFile);
  6522. (0, _defineProperty2.default)(this, "_name", void 0);
  6523. (0, _defineProperty2.default)(this, "_url", void 0);
  6524. (0, _defineProperty2.default)(this, "_source", void 0);
  6525. (0, _defineProperty2.default)(this, "_previousSave", void 0);
  6526. (0, _defineProperty2.default)(this, "_data", void 0);
  6527. (0, _defineProperty2.default)(this, "_requestTask", void 0);
  6528. (0, _defineProperty2.default)(this, "_metadata", void 0);
  6529. (0, _defineProperty2.default)(this, "_tags", void 0);
  6530. var specifiedType = type || '';
  6531. this._name = name;
  6532. this._metadata = metadata || {};
  6533. this._tags = tags || {};
  6534. if (data !== undefined) {
  6535. if ((0, _isArray.default)(data)) {
  6536. this._data = ParseFile.encodeBase64(data);
  6537. this._source = {
  6538. format: 'base64',
  6539. base64: this._data,
  6540. type: specifiedType
  6541. };
  6542. } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
  6543. this._source = {
  6544. format: 'file',
  6545. file: data,
  6546. type: specifiedType
  6547. };
  6548. } else if (data && typeof data.uri === 'string' && data.uri !== undefined) {
  6549. this._source = {
  6550. format: 'uri',
  6551. uri: data.uri,
  6552. type: specifiedType
  6553. };
  6554. } else if (data && typeof data.base64 === 'string') {
  6555. var _context, _context2, _context3;
  6556. var base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
  6557. 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';
  6558. this._data = base64;
  6559. this._source = {
  6560. format: 'base64',
  6561. base64: base64,
  6562. type: dataType
  6563. };
  6564. } else {
  6565. throw new TypeError('Cannot create a Parse.File with that data.');
  6566. }
  6567. }
  6568. }
  6569. /**
  6570. * Return the data for the file, downloading it if not already present.
  6571. * Data is present if initialized with Byte Array, Base64 or Saved with Uri.
  6572. * Data is cleared if saved with File object selected with a file upload control
  6573. *
  6574. * @returns {Promise} Promise that is resolve with base64 data
  6575. */
  6576. (0, _createClass2.default)(ParseFile, [{
  6577. key: "getData",
  6578. value: function () {
  6579. var _getData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  6580. var _this = this;
  6581. var options, controller, result;
  6582. return _regenerator.default.wrap(function (_context4) {
  6583. while (1) switch (_context4.prev = _context4.next) {
  6584. case 0:
  6585. if (!this._data) {
  6586. _context4.next = 2;
  6587. break;
  6588. }
  6589. return _context4.abrupt("return", this._data);
  6590. case 2:
  6591. if (this._url) {
  6592. _context4.next = 4;
  6593. break;
  6594. }
  6595. throw new Error('Cannot retrieve data for unsaved ParseFile.');
  6596. case 4:
  6597. options = {
  6598. requestTask: function (task) {
  6599. return _this._requestTask = task;
  6600. }
  6601. };
  6602. controller = _CoreManager.default.getFileController();
  6603. _context4.next = 8;
  6604. return controller.download(this._url, options);
  6605. case 8:
  6606. result = _context4.sent;
  6607. this._data = result.base64;
  6608. return _context4.abrupt("return", this._data);
  6609. case 11:
  6610. case "end":
  6611. return _context4.stop();
  6612. }
  6613. }, _callee, this);
  6614. }));
  6615. function getData() {
  6616. return _getData.apply(this, arguments);
  6617. }
  6618. return getData;
  6619. }()
  6620. /**
  6621. * Gets the name of the file. Before save is called, this is the filename
  6622. * given by the user. After save is called, that name gets prefixed with a
  6623. * unique identifier.
  6624. *
  6625. * @returns {string}
  6626. */
  6627. }, {
  6628. key: "name",
  6629. value: function () /*: string*/{
  6630. return this._name;
  6631. }
  6632. /**
  6633. * Gets the url of the file. It is only available after you save the file or
  6634. * after you get the file from a Parse.Object.
  6635. *
  6636. * @param {object} options An object to specify url options
  6637. * @returns {string | undefined}
  6638. */
  6639. }, {
  6640. key: "url",
  6641. value: function (options /*:: ?: { forceSecure?: boolean }*/) /*: ?string*/{
  6642. options = options || {};
  6643. if (!this._url) {
  6644. return;
  6645. }
  6646. if (options.forceSecure) {
  6647. return this._url.replace(/^http:\/\//i, 'https://');
  6648. } else {
  6649. return this._url;
  6650. }
  6651. }
  6652. /**
  6653. * Gets the metadata of the file.
  6654. *
  6655. * @returns {object}
  6656. */
  6657. }, {
  6658. key: "metadata",
  6659. value: function () /*: Object*/{
  6660. return this._metadata;
  6661. }
  6662. /**
  6663. * Gets the tags of the file.
  6664. *
  6665. * @returns {object}
  6666. */
  6667. }, {
  6668. key: "tags",
  6669. value: function () /*: Object*/{
  6670. return this._tags;
  6671. }
  6672. /**
  6673. * Saves the file to the Parse cloud.
  6674. *
  6675. * @param {object} options
  6676. * Valid options are:<ul>
  6677. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  6678. * be used for this request.
  6679. * <li>sessionToken: A valid session token, used for making a request on
  6680. * behalf of a specific user.
  6681. * <li>progress: In Browser only, callback for upload progress. For example:
  6682. * <pre>
  6683. * let parseFile = new Parse.File(name, file);
  6684. * parseFile.save({
  6685. * progress: (progressValue, loaded, total, { type }) => {
  6686. * if (type === "upload" && progressValue !== null) {
  6687. * // Update the UI using progressValue
  6688. * }
  6689. * }
  6690. * });
  6691. * </pre>
  6692. * </ul>
  6693. * @returns {Promise | undefined} Promise that is resolved when the save finishes.
  6694. */
  6695. }, {
  6696. key: "save",
  6697. value: function (options /*:: ?: FullOptions*/) /*: ?Promise*/{
  6698. var _this2 = this;
  6699. options = options || {};
  6700. options.requestTask = function (task) {
  6701. return _this2._requestTask = task;
  6702. };
  6703. options.metadata = this._metadata;
  6704. options.tags = this._tags;
  6705. var controller = _CoreManager.default.getFileController();
  6706. if (!this._previousSave) {
  6707. if (this._source.format === 'file') {
  6708. this._previousSave = controller.saveFile(this._name, this._source, options).then(function (res) {
  6709. _this2._name = res.name;
  6710. _this2._url = res.url;
  6711. _this2._data = null;
  6712. _this2._requestTask = null;
  6713. return _this2;
  6714. });
  6715. } else if (this._source.format === 'uri') {
  6716. this._previousSave = controller.download(this._source.uri, options).then(function (result) {
  6717. if (!(result && result.base64)) {
  6718. return {};
  6719. }
  6720. var newSource = {
  6721. format: 'base64',
  6722. base64: result.base64,
  6723. type: result.contentType
  6724. };
  6725. _this2._data = result.base64;
  6726. _this2._requestTask = null;
  6727. return controller.saveBase64(_this2._name, newSource, options);
  6728. }).then(function (res) {
  6729. _this2._name = res.name;
  6730. _this2._url = res.url;
  6731. _this2._requestTask = null;
  6732. return _this2;
  6733. });
  6734. } else {
  6735. this._previousSave = controller.saveBase64(this._name, this._source, options).then(function (res) {
  6736. _this2._name = res.name;
  6737. _this2._url = res.url;
  6738. _this2._requestTask = null;
  6739. return _this2;
  6740. });
  6741. }
  6742. }
  6743. if (this._previousSave) {
  6744. return this._previousSave;
  6745. }
  6746. }
  6747. /**
  6748. * Aborts the request if it has already been sent.
  6749. */
  6750. }, {
  6751. key: "cancel",
  6752. value: function () {
  6753. if (this._requestTask && typeof this._requestTask.abort === 'function') {
  6754. this._requestTask._aborted = true;
  6755. this._requestTask.abort();
  6756. }
  6757. this._requestTask = null;
  6758. }
  6759. /**
  6760. * Deletes the file from the Parse cloud.
  6761. * In Cloud Code and Node only with Master Key.
  6762. *
  6763. * @param {object} options
  6764. * Valid options are:<ul>
  6765. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  6766. * be used for this request.
  6767. * <pre>
  6768. * @returns {Promise} Promise that is resolved when the delete finishes.
  6769. */
  6770. }, {
  6771. key: "destroy",
  6772. value: function () {
  6773. var _this3 = this;
  6774. var options /*:: ?: FullOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  6775. if (!this._name) {
  6776. throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
  6777. }
  6778. var destroyOptions = {
  6779. useMasterKey: true
  6780. };
  6781. if (options.hasOwnProperty('useMasterKey')) {
  6782. destroyOptions.useMasterKey = options.useMasterKey;
  6783. }
  6784. var controller = _CoreManager.default.getFileController();
  6785. return controller.deleteFile(this._name, destroyOptions).then(function () {
  6786. _this3._data = null;
  6787. _this3._requestTask = null;
  6788. return _this3;
  6789. });
  6790. }
  6791. }, {
  6792. key: "toJSON",
  6793. value: function () /*: { name: ?string, url: ?string }*/{
  6794. return {
  6795. __type: 'File',
  6796. name: this._name,
  6797. url: this._url
  6798. };
  6799. }
  6800. }, {
  6801. key: "equals",
  6802. value: function (other /*: mixed*/) /*: boolean*/{
  6803. if (this === other) {
  6804. return true;
  6805. }
  6806. // Unsaved Files are never equal, since they will be saved to different URLs
  6807. return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
  6808. }
  6809. /**
  6810. * Sets metadata to be saved with file object. Overwrites existing metadata
  6811. *
  6812. * @param {object} metadata Key value pairs to be stored with file object
  6813. */
  6814. }, {
  6815. key: "setMetadata",
  6816. value: function (metadata /*: any*/) {
  6817. var _this4 = this;
  6818. if (metadata && (0, _typeof2.default)(metadata) === 'object') {
  6819. var _context5;
  6820. (0, _forEach.default)(_context5 = (0, _keys.default)(metadata)).call(_context5, function (key) {
  6821. _this4.addMetadata(key, metadata[key]);
  6822. });
  6823. }
  6824. }
  6825. /**
  6826. * Sets metadata to be saved with file object. Adds to existing metadata.
  6827. *
  6828. * @param {string} key key to store the metadata
  6829. * @param {*} value metadata
  6830. */
  6831. }, {
  6832. key: "addMetadata",
  6833. value: function (key /*: string*/, value /*: any*/) {
  6834. if (typeof key === 'string') {
  6835. this._metadata[key] = value;
  6836. }
  6837. }
  6838. /**
  6839. * Sets tags to be saved with file object. Overwrites existing tags
  6840. *
  6841. * @param {object} tags Key value pairs to be stored with file object
  6842. */
  6843. }, {
  6844. key: "setTags",
  6845. value: function (tags /*: any*/) {
  6846. var _this5 = this;
  6847. if (tags && (0, _typeof2.default)(tags) === 'object') {
  6848. var _context6;
  6849. (0, _forEach.default)(_context6 = (0, _keys.default)(tags)).call(_context6, function (key) {
  6850. _this5.addTag(key, tags[key]);
  6851. });
  6852. }
  6853. }
  6854. /**
  6855. * Sets tags to be saved with file object. Adds to existing tags.
  6856. *
  6857. * @param {string} key key to store tags
  6858. * @param {*} value tag
  6859. */
  6860. }, {
  6861. key: "addTag",
  6862. value: function (key /*: string*/, value /*: string*/) {
  6863. if (typeof key === 'string') {
  6864. this._tags[key] = value;
  6865. }
  6866. }
  6867. }], [{
  6868. key: "fromJSON",
  6869. value: function (obj) /*: ParseFile*/{
  6870. if (obj.__type !== 'File') {
  6871. throw new TypeError('JSON object does not represent a ParseFile');
  6872. }
  6873. var file = new ParseFile(obj.name);
  6874. file._url = obj.url;
  6875. return file;
  6876. }
  6877. }, {
  6878. key: "encodeBase64",
  6879. value: function (bytes /*: Array<number>*/) /*: string*/{
  6880. var chunks = [];
  6881. chunks.length = Math.ceil(bytes.length / 3);
  6882. for (var i = 0; i < chunks.length; i++) {
  6883. var b1 = bytes[i * 3];
  6884. var b2 = bytes[i * 3 + 1] || 0;
  6885. var b3 = bytes[i * 3 + 2] || 0;
  6886. var has2 = i * 3 + 1 < bytes.length;
  6887. var has3 = i * 3 + 2 < bytes.length;
  6888. 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('');
  6889. }
  6890. return chunks.join('');
  6891. }
  6892. }]);
  6893. return ParseFile;
  6894. }();
  6895. var DefaultController = {
  6896. saveFile: function () {
  6897. var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
  6898. var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
  6899. return _regenerator.default.wrap(function (_context7) {
  6900. while (1) switch (_context7.prev = _context7.next) {
  6901. case 0:
  6902. if (!(source.format !== 'file')) {
  6903. _context7.next = 2;
  6904. break;
  6905. }
  6906. throw new Error('saveFile can only be used with File-type sources.');
  6907. case 2:
  6908. _context7.next = 4;
  6909. return new _promise.default(function (res, rej) {
  6910. // eslint-disable-next-line no-undef
  6911. var reader = new FileReader();
  6912. reader.onload = function () {
  6913. return res(reader.result);
  6914. };
  6915. reader.onerror = function (error) {
  6916. return rej(error);
  6917. };
  6918. reader.readAsDataURL(source.file);
  6919. });
  6920. case 4:
  6921. base64Data = _context7.sent;
  6922. // we only want the data after the comma
  6923. // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
  6924. _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
  6925. // use the entire string instead
  6926. data = second ? second : first;
  6927. newSource = {
  6928. format: 'base64',
  6929. base64: data,
  6930. type: source.type || (source.file ? source.file.type : null)
  6931. };
  6932. _context7.next = 10;
  6933. return DefaultController.saveBase64(name, newSource, options);
  6934. case 10:
  6935. return _context7.abrupt("return", _context7.sent);
  6936. case 11:
  6937. case "end":
  6938. return _context7.stop();
  6939. }
  6940. }, _callee2);
  6941. }));
  6942. function saveFile() {
  6943. return _saveFile.apply(this, arguments);
  6944. }
  6945. return saveFile;
  6946. }(),
  6947. saveBase64: function (name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
  6948. if (source.format !== 'base64') {
  6949. throw new Error('saveBase64 can only be used with Base64-type sources.');
  6950. }
  6951. var data /*: { base64: any, _ContentType?: any, fileData: Object }*/ = {
  6952. base64: source.base64,
  6953. fileData: {
  6954. metadata: _objectSpread({}, options.metadata),
  6955. tags: _objectSpread({}, options.tags)
  6956. }
  6957. };
  6958. delete options.metadata;
  6959. delete options.tags;
  6960. if (source.type) {
  6961. data._ContentType = source.type;
  6962. }
  6963. return _CoreManager.default.getRESTController().request('POST', 'files/' + name, data, options);
  6964. },
  6965. download: function (uri, options) {
  6966. if (XHR) {
  6967. return this.downloadAjax(uri, options);
  6968. } else {
  6969. return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
  6970. }
  6971. },
  6972. downloadAjax: function (uri, options) {
  6973. return new _promise.default(function (resolve, reject) {
  6974. var xhr = new XHR();
  6975. xhr.open('GET', uri, true);
  6976. xhr.responseType = 'arraybuffer';
  6977. xhr.onerror = function (e) {
  6978. reject(e);
  6979. };
  6980. xhr.onreadystatechange = function () {
  6981. if (xhr.readyState !== xhr.DONE) {
  6982. return;
  6983. }
  6984. if (!this.response) {
  6985. return resolve({});
  6986. }
  6987. var bytes = new Uint8Array(this.response);
  6988. resolve({
  6989. base64: ParseFile.encodeBase64(bytes),
  6990. contentType: xhr.getResponseHeader('content-type')
  6991. });
  6992. };
  6993. options.requestTask(xhr);
  6994. xhr.send();
  6995. });
  6996. },
  6997. deleteFile: function (name /*: string*/, options /*:: ?: FullOptions*/) {
  6998. var headers = {
  6999. 'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
  7000. };
  7001. if (options.useMasterKey) {
  7002. headers['X-Parse-Master-Key'] = _CoreManager.default.get('MASTER_KEY');
  7003. }
  7004. var url = _CoreManager.default.get('SERVER_URL');
  7005. if (url[url.length - 1] !== '/') {
  7006. url += '/';
  7007. }
  7008. url += 'files/' + name;
  7009. return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(function (response) {
  7010. // TODO: return JSON object in server
  7011. if (!response || response === 'SyntaxError: Unexpected end of JSON input') {
  7012. return _promise.default.resolve();
  7013. } else {
  7014. return _CoreManager.default.getRESTController().handleError(response);
  7015. }
  7016. });
  7017. },
  7018. _setXHR: function (xhr /*: any*/) {
  7019. XHR = xhr;
  7020. },
  7021. _getXHR: function () {
  7022. return XHR;
  7023. }
  7024. };
  7025. _CoreManager.default.setFileController(DefaultController);
  7026. var _default = ParseFile;
  7027. exports.default = _default;
  7028. exports.b64Digit = b64Digit;
  7029. },{"./CoreManager":4,"./ParseError":21,"./Xhr.weapp":43,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/filter":62,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/object/define-properties":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":86,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":87,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/helpers/asyncToGenerator":122,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/slicedToArray":140,"@babel/runtime-corejs3/helpers/typeof":145,"@babel/runtime-corejs3/regenerator":148}],23:[function(_dereq_,module,exports){
  7030. "use strict";
  7031. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7032. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7033. _Object$defineProperty(exports, "__esModule", {
  7034. value: true
  7035. });
  7036. exports.default = void 0;
  7037. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  7038. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  7039. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  7040. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  7041. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  7042. /**
  7043. * @flow
  7044. */
  7045. /**
  7046. * Creates a new GeoPoint with any of the following forms:<br>
  7047. * <pre>
  7048. * new GeoPoint(otherGeoPoint)
  7049. * new GeoPoint(30, 30)
  7050. * new GeoPoint([30, 30])
  7051. * new GeoPoint({latitude: 30, longitude: 30})
  7052. * new GeoPoint() // defaults to (0, 0)
  7053. * </pre>
  7054. * <p>Represents a latitude / longitude point that may be associated
  7055. * with a key in a ParseObject or used as a reference point for geo queries.
  7056. * This allows proximity-based queries on the key.</p>
  7057. *
  7058. * <p>Only one key in a class may contain a GeoPoint.</p>
  7059. *
  7060. * <p>Example:<pre>
  7061. * var point = new Parse.GeoPoint(30.0, -20.0);
  7062. * var object = new Parse.Object("PlaceObject");
  7063. * object.set("location", point);
  7064. * object.save();</pre></p>
  7065. *
  7066. * @alias Parse.GeoPoint
  7067. */
  7068. /* global navigator */
  7069. var ParseGeoPoint = /*#__PURE__*/function () {
  7070. /**
  7071. * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
  7072. * @param {number} arg2 The longitude of the GeoPoint
  7073. */
  7074. function ParseGeoPoint(arg1 /*: Array<number> | { latitude: number, longitude: number } | number*/, arg2 /*:: ?: number*/) {
  7075. (0, _classCallCheck2.default)(this, ParseGeoPoint);
  7076. (0, _defineProperty2.default)(this, "_latitude", void 0);
  7077. (0, _defineProperty2.default)(this, "_longitude", void 0);
  7078. if ((0, _isArray.default)(arg1)) {
  7079. ParseGeoPoint._validate(arg1[0], arg1[1]);
  7080. this._latitude = arg1[0];
  7081. this._longitude = arg1[1];
  7082. } else if ((0, _typeof2.default)(arg1) === 'object') {
  7083. ParseGeoPoint._validate(arg1.latitude, arg1.longitude);
  7084. this._latitude = arg1.latitude;
  7085. this._longitude = arg1.longitude;
  7086. } else if (arg1 !== undefined && arg2 !== undefined) {
  7087. ParseGeoPoint._validate(arg1, arg2);
  7088. this._latitude = arg1;
  7089. this._longitude = arg2;
  7090. } else {
  7091. this._latitude = 0;
  7092. this._longitude = 0;
  7093. }
  7094. }
  7095. /**
  7096. * North-south portion of the coordinate, in range [-90, 90].
  7097. * Throws an exception if set out of range in a modern browser.
  7098. *
  7099. * @property {number} latitude
  7100. * @returns {number}
  7101. */
  7102. (0, _createClass2.default)(ParseGeoPoint, [{
  7103. key: "latitude",
  7104. get: function () /*: number*/{
  7105. return this._latitude;
  7106. },
  7107. set: function (val /*: number*/) {
  7108. ParseGeoPoint._validate(val, this.longitude);
  7109. this._latitude = val;
  7110. }
  7111. /**
  7112. * East-west portion of the coordinate, in range [-180, 180].
  7113. * Throws if set out of range in a modern browser.
  7114. *
  7115. * @property {number} longitude
  7116. * @returns {number}
  7117. */
  7118. }, {
  7119. key: "longitude",
  7120. get: function () /*: number*/{
  7121. return this._longitude;
  7122. },
  7123. set: function (val /*: number*/) {
  7124. ParseGeoPoint._validate(this.latitude, val);
  7125. this._longitude = val;
  7126. }
  7127. /**
  7128. * Returns a JSON representation of the GeoPoint, suitable for Parse.
  7129. *
  7130. * @returns {object}
  7131. */
  7132. }, {
  7133. key: "toJSON",
  7134. value: function () /*: { __type: string, latitude: number, longitude: number }*/{
  7135. ParseGeoPoint._validate(this._latitude, this._longitude);
  7136. return {
  7137. __type: 'GeoPoint',
  7138. latitude: this._latitude,
  7139. longitude: this._longitude
  7140. };
  7141. }
  7142. }, {
  7143. key: "equals",
  7144. value: function (other /*: mixed*/) /*: boolean*/{
  7145. return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
  7146. }
  7147. /**
  7148. * Returns the distance from this GeoPoint to another in radians.
  7149. *
  7150. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  7151. * @returns {number}
  7152. */
  7153. }, {
  7154. key: "radiansTo",
  7155. value: function (point /*: ParseGeoPoint*/) /*: number*/{
  7156. var d2r = Math.PI / 180.0;
  7157. var lat1rad = this.latitude * d2r;
  7158. var long1rad = this.longitude * d2r;
  7159. var lat2rad = point.latitude * d2r;
  7160. var long2rad = point.longitude * d2r;
  7161. var sinDeltaLatDiv2 = Math.sin((lat1rad - lat2rad) / 2);
  7162. var sinDeltaLongDiv2 = Math.sin((long1rad - long2rad) / 2);
  7163. // Square of half the straight line chord distance between both points.
  7164. var a = sinDeltaLatDiv2 * sinDeltaLatDiv2 + Math.cos(lat1rad) * Math.cos(lat2rad) * sinDeltaLongDiv2 * sinDeltaLongDiv2;
  7165. a = Math.min(1.0, a);
  7166. return 2 * Math.asin(Math.sqrt(a));
  7167. }
  7168. /**
  7169. * Returns the distance from this GeoPoint to another in kilometers.
  7170. *
  7171. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  7172. * @returns {number}
  7173. */
  7174. }, {
  7175. key: "kilometersTo",
  7176. value: function (point /*: ParseGeoPoint*/) /*: number*/{
  7177. return this.radiansTo(point) * 6371.0;
  7178. }
  7179. /**
  7180. * Returns the distance from this GeoPoint to another in miles.
  7181. *
  7182. * @param {Parse.GeoPoint} point the other Parse.GeoPoint.
  7183. * @returns {number}
  7184. */
  7185. }, {
  7186. key: "milesTo",
  7187. value: function (point /*: ParseGeoPoint*/) /*: number*/{
  7188. return this.radiansTo(point) * 3958.8;
  7189. }
  7190. /*
  7191. * Throws an exception if the given lat-long is out of bounds.
  7192. */
  7193. }], [{
  7194. key: "_validate",
  7195. value: function (latitude /*: number*/, longitude /*: number*/) {
  7196. if (isNaN(latitude) || isNaN(longitude) || typeof latitude !== 'number' || typeof longitude !== 'number') {
  7197. throw new TypeError('GeoPoint latitude and longitude must be valid numbers');
  7198. }
  7199. if (latitude < -90.0) {
  7200. throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' < -90.0.');
  7201. }
  7202. if (latitude > 90.0) {
  7203. throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' > 90.0.');
  7204. }
  7205. if (longitude < -180.0) {
  7206. throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' < -180.0.');
  7207. }
  7208. if (longitude > 180.0) {
  7209. throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' > 180.0.');
  7210. }
  7211. }
  7212. /**
  7213. * Creates a GeoPoint with the user's current location, if available.
  7214. *
  7215. * @static
  7216. * @returns {Parse.GeoPoint} User's current location
  7217. */
  7218. }, {
  7219. key: "current",
  7220. value: function () {
  7221. return navigator.geolocation.getCurrentPosition(function (location) {
  7222. return new ParseGeoPoint(location.coords.latitude, location.coords.longitude);
  7223. });
  7224. }
  7225. }]);
  7226. return ParseGeoPoint;
  7227. }();
  7228. var _default = ParseGeoPoint;
  7229. exports.default = _default;
  7230. },{"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],24:[function(_dereq_,module,exports){
  7231. "use strict";
  7232. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  7233. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7234. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7235. _Object$defineProperty(exports, "__esModule", {
  7236. value: true
  7237. });
  7238. exports.default = void 0;
  7239. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  7240. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  7241. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  7242. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  7243. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  7244. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  7245. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  7246. function _createSuper(Derived) {
  7247. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  7248. return function () {
  7249. var Super = (0, _getPrototypeOf2.default)(Derived),
  7250. result;
  7251. if (hasNativeReflectConstruct) {
  7252. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  7253. result = _Reflect$construct(Super, arguments, NewTarget);
  7254. } else {
  7255. result = Super.apply(this, arguments);
  7256. }
  7257. return (0, _possibleConstructorReturn2.default)(this, result);
  7258. };
  7259. }
  7260. function _isNativeReflectConstruct() {
  7261. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  7262. if (_Reflect$construct.sham) return false;
  7263. if (typeof Proxy === "function") return true;
  7264. try {
  7265. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  7266. return true;
  7267. } catch (e) {
  7268. return false;
  7269. }
  7270. } /**
  7271. * @flow
  7272. */
  7273. /*:: import type { AttributeMap } from './ObjectStateMutations';*/
  7274. var Installation = /*#__PURE__*/function (_ParseObject) {
  7275. (0, _inherits2.default)(Installation, _ParseObject);
  7276. var _super = _createSuper(Installation);
  7277. function Installation(attributes /*: ?AttributeMap*/) {
  7278. var _this;
  7279. (0, _classCallCheck2.default)(this, Installation);
  7280. _this = _super.call(this, '_Installation');
  7281. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  7282. if (!_this.set(attributes || {})) {
  7283. throw new Error("Can't create an invalid Installation");
  7284. }
  7285. }
  7286. return _this;
  7287. }
  7288. return (0, _createClass2.default)(Installation);
  7289. }(_ParseObject2.default);
  7290. exports.default = Installation;
  7291. _ParseObject2.default.registerSubclass('_Installation', Installation);
  7292. },{"./ParseObject":26,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":92,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/getPrototypeOf":128,"@babel/runtime-corejs3/helpers/inherits":129,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":137,"@babel/runtime-corejs3/helpers/typeof":145}],25:[function(_dereq_,module,exports){
  7293. "use strict";
  7294. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7295. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7296. _Object$defineProperty(exports, "__esModule", {
  7297. value: true
  7298. });
  7299. exports.default = void 0;
  7300. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  7301. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  7302. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  7303. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  7304. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  7305. var _EventEmitter = _interopRequireDefault(_dereq_("./EventEmitter"));
  7306. var _LiveQueryClient = _interopRequireDefault(_dereq_("./LiveQueryClient"));
  7307. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  7308. /**
  7309. * @flow
  7310. */
  7311. function getLiveQueryClient() /*: LiveQueryClient*/{
  7312. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  7313. }
  7314. /**
  7315. * We expose three events to help you monitor the status of the WebSocket connection:
  7316. *
  7317. * <p>Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.
  7318. *
  7319. * <pre>
  7320. * Parse.LiveQuery.on('open', () => {
  7321. *
  7322. * });</pre></p>
  7323. *
  7324. * <p>Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.
  7325. *
  7326. * <pre>
  7327. * Parse.LiveQuery.on('close', () => {
  7328. *
  7329. * });</pre></p>
  7330. *
  7331. * <p>Error - When some network error or LiveQuery server error happens, you'll get this event.
  7332. *
  7333. * <pre>
  7334. * Parse.LiveQuery.on('error', (error) => {
  7335. *
  7336. * });</pre></p>
  7337. *
  7338. * @class Parse.LiveQuery
  7339. * @static
  7340. */
  7341. var LiveQuery = new _EventEmitter.default();
  7342. /**
  7343. * After open is called, the LiveQuery will try to send a connect request
  7344. * to the LiveQuery server.
  7345. */
  7346. LiveQuery.open = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  7347. var liveQueryClient;
  7348. return _regenerator.default.wrap(function (_context) {
  7349. while (1) switch (_context.prev = _context.next) {
  7350. case 0:
  7351. _context.next = 2;
  7352. return getLiveQueryClient();
  7353. case 2:
  7354. liveQueryClient = _context.sent;
  7355. liveQueryClient.open();
  7356. case 4:
  7357. case "end":
  7358. return _context.stop();
  7359. }
  7360. }, _callee);
  7361. }));
  7362. /**
  7363. * When you're done using LiveQuery, you can call Parse.LiveQuery.close().
  7364. * This function will close the WebSocket connection to the LiveQuery server,
  7365. * cancel the auto reconnect, and unsubscribe all subscriptions based on it.
  7366. * If you call query.subscribe() after this, we'll create a new WebSocket
  7367. * connection to the LiveQuery server.
  7368. */
  7369. LiveQuery.close = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  7370. var liveQueryClient;
  7371. return _regenerator.default.wrap(function (_context2) {
  7372. while (1) switch (_context2.prev = _context2.next) {
  7373. case 0:
  7374. _context2.next = 2;
  7375. return getLiveQueryClient();
  7376. case 2:
  7377. liveQueryClient = _context2.sent;
  7378. liveQueryClient.close();
  7379. case 4:
  7380. case "end":
  7381. return _context2.stop();
  7382. }
  7383. }, _callee2);
  7384. }));
  7385. // Register a default onError callback to make sure we do not crash on error
  7386. LiveQuery.on('error', function () {});
  7387. var _default = LiveQuery;
  7388. exports.default = _default;
  7389. var defaultLiveQueryClient;
  7390. var DefaultLiveQueryController = {
  7391. setDefaultLiveQueryClient: function (liveQueryClient /*: LiveQueryClient*/) {
  7392. defaultLiveQueryClient = liveQueryClient;
  7393. },
  7394. getDefaultLiveQueryClient: function () /*: Promise<LiveQueryClient>*/{
  7395. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  7396. var _yield$Promise$all, _yield$Promise$all2, currentUser, installationId, sessionToken, liveQueryServerURL, serverURL, protocol, host, applicationId, javascriptKey, masterKey;
  7397. return _regenerator.default.wrap(function (_context3) {
  7398. while (1) switch (_context3.prev = _context3.next) {
  7399. case 0:
  7400. if (!defaultLiveQueryClient) {
  7401. _context3.next = 2;
  7402. break;
  7403. }
  7404. return _context3.abrupt("return", defaultLiveQueryClient);
  7405. case 2:
  7406. _context3.next = 4;
  7407. return _promise.default.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);
  7408. case 4:
  7409. _yield$Promise$all = _context3.sent;
  7410. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
  7411. currentUser = _yield$Promise$all2[0];
  7412. installationId = _yield$Promise$all2[1];
  7413. sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
  7414. liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');
  7415. if (!(liveQueryServerURL && (0, _indexOf.default)(liveQueryServerURL).call(liveQueryServerURL, 'ws') !== 0)) {
  7416. _context3.next = 12;
  7417. break;
  7418. }
  7419. throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
  7420. case 12:
  7421. // If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
  7422. if (!liveQueryServerURL) {
  7423. serverURL = _CoreManager.default.get('SERVER_URL');
  7424. protocol = (0, _indexOf.default)(serverURL).call(serverURL, 'https') === 0 ? 'wss://' : 'ws://';
  7425. host = serverURL.replace(/^https?:\/\//, '');
  7426. liveQueryServerURL = protocol + host;
  7427. _CoreManager.default.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);
  7428. }
  7429. applicationId = _CoreManager.default.get('APPLICATION_ID');
  7430. javascriptKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  7431. masterKey = _CoreManager.default.get('MASTER_KEY');
  7432. defaultLiveQueryClient = new _LiveQueryClient.default({
  7433. applicationId: applicationId,
  7434. serverURL: liveQueryServerURL,
  7435. javascriptKey: javascriptKey,
  7436. masterKey: masterKey,
  7437. sessionToken: sessionToken,
  7438. installationId: installationId
  7439. });
  7440. defaultLiveQueryClient.on('error', function (error) {
  7441. LiveQuery.emit('error', error);
  7442. });
  7443. defaultLiveQueryClient.on('open', function () {
  7444. LiveQuery.emit('open');
  7445. });
  7446. defaultLiveQueryClient.on('close', function () {
  7447. LiveQuery.emit('close');
  7448. });
  7449. return _context3.abrupt("return", defaultLiveQueryClient);
  7450. case 21:
  7451. case "end":
  7452. return _context3.stop();
  7453. }
  7454. }, _callee3);
  7455. }))();
  7456. },
  7457. _clearCachedDefaultClient: function () {
  7458. defaultLiveQueryClient = null;
  7459. }
  7460. };
  7461. _CoreManager.default.setLiveQueryController(DefaultLiveQueryController);
  7462. },{"./CoreManager":4,"./EventEmitter":6,"./LiveQueryClient":10,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/helpers/asyncToGenerator":122,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/slicedToArray":140,"@babel/runtime-corejs3/regenerator":148}],26:[function(_dereq_,module,exports){
  7463. "use strict";
  7464. var _typeof3 = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  7465. var _Object$keys2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  7466. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  7467. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  7468. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  7469. var _forEachInstanceProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  7470. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  7471. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  7472. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  7473. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice");
  7474. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js-stable/array/from");
  7475. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js-stable/symbol");
  7476. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  7477. var _Array$isArray2 = _dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array");
  7478. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  7479. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  7480. _Object$defineProperty2(exports, "__esModule", {
  7481. value: true
  7482. });
  7483. exports.default = void 0;
  7484. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  7485. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  7486. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  7487. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  7488. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  7489. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  7490. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  7491. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  7492. var _freeze = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/freeze"));
  7493. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  7494. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  7495. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  7496. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  7497. var _getPrototypeOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
  7498. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  7499. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  7500. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  7501. var _create = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/create"));
  7502. var _defineProperty3 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  7503. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  7504. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  7505. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  7506. var _canBeSerialized = _interopRequireDefault(_dereq_("./canBeSerialized"));
  7507. var _decode = _interopRequireDefault(_dereq_("./decode"));
  7508. var _encode = _interopRequireDefault(_dereq_("./encode"));
  7509. var _escape2 = _interopRequireDefault(_dereq_("./escape"));
  7510. var _EventuallyQueue = _interopRequireDefault(_dereq_("./EventuallyQueue"));
  7511. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  7512. var _parseDate = _interopRequireDefault(_dereq_("./parseDate"));
  7513. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  7514. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  7515. var _promiseUtils = _dereq_("./promiseUtils");
  7516. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  7517. var _ParseOp = _dereq_("./ParseOp");
  7518. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  7519. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  7520. var SingleInstanceStateController = _interopRequireWildcard(_dereq_("./SingleInstanceStateController"));
  7521. var _unique = _interopRequireDefault(_dereq_("./unique"));
  7522. var UniqueInstanceStateController = _interopRequireWildcard(_dereq_("./UniqueInstanceStateController"));
  7523. var _unsavedChildren = _interopRequireDefault(_dereq_("./unsavedChildren"));
  7524. function _getRequireWildcardCache(nodeInterop) {
  7525. if (typeof _WeakMap !== "function") return null;
  7526. var cacheBabelInterop = new _WeakMap();
  7527. var cacheNodeInterop = new _WeakMap();
  7528. return (_getRequireWildcardCache = function (nodeInterop) {
  7529. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  7530. })(nodeInterop);
  7531. }
  7532. function _interopRequireWildcard(obj, nodeInterop) {
  7533. if (!nodeInterop && obj && obj.__esModule) {
  7534. return obj;
  7535. }
  7536. if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") {
  7537. return {
  7538. default: obj
  7539. };
  7540. }
  7541. var cache = _getRequireWildcardCache(nodeInterop);
  7542. if (cache && cache.has(obj)) {
  7543. return cache.get(obj);
  7544. }
  7545. var newObj = {};
  7546. for (var key in obj) {
  7547. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  7548. var desc = _Object$defineProperty2 && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  7549. if (desc && (desc.get || desc.set)) {
  7550. _Object$defineProperty2(newObj, key, desc);
  7551. } else {
  7552. newObj[key] = obj[key];
  7553. }
  7554. }
  7555. }
  7556. newObj.default = obj;
  7557. if (cache) {
  7558. cache.set(obj, newObj);
  7559. }
  7560. return newObj;
  7561. }
  7562. function _createForOfIteratorHelper(o, allowArrayLike) {
  7563. var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
  7564. if (!it) {
  7565. if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  7566. if (it) o = it;
  7567. var i = 0;
  7568. var F = function () {};
  7569. return {
  7570. s: F,
  7571. n: function () {
  7572. if (i >= o.length) return {
  7573. done: true
  7574. };
  7575. return {
  7576. done: false,
  7577. value: o[i++]
  7578. };
  7579. },
  7580. e: function (_e) {
  7581. throw _e;
  7582. },
  7583. f: F
  7584. };
  7585. }
  7586. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  7587. }
  7588. var normalCompletion = true,
  7589. didErr = false,
  7590. err;
  7591. return {
  7592. s: function () {
  7593. it = it.call(o);
  7594. },
  7595. n: function () {
  7596. var step = it.next();
  7597. normalCompletion = step.done;
  7598. return step;
  7599. },
  7600. e: function (_e2) {
  7601. didErr = true;
  7602. err = _e2;
  7603. },
  7604. f: function () {
  7605. try {
  7606. if (!normalCompletion && it.return != null) it.return();
  7607. } finally {
  7608. if (didErr) throw err;
  7609. }
  7610. }
  7611. };
  7612. }
  7613. function _unsupportedIterableToArray(o, minLen) {
  7614. var _context19;
  7615. if (!o) return;
  7616. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  7617. var n = _sliceInstanceProperty(_context19 = Object.prototype.toString.call(o)).call(_context19, 8, -1);
  7618. if (n === "Object" && o.constructor) n = o.constructor.name;
  7619. if (n === "Map" || n === "Set") return _Array$from(o);
  7620. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  7621. }
  7622. function _arrayLikeToArray(arr, len) {
  7623. if (len == null || len > arr.length) len = arr.length;
  7624. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  7625. return arr2;
  7626. }
  7627. function ownKeys(object, enumerableOnly) {
  7628. var keys = _Object$keys2(object);
  7629. if (_Object$getOwnPropertySymbols) {
  7630. var symbols = _Object$getOwnPropertySymbols(object);
  7631. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  7632. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  7633. })), keys.push.apply(keys, symbols);
  7634. }
  7635. return keys;
  7636. }
  7637. function _objectSpread(target) {
  7638. for (var i = 1; i < arguments.length; i++) {
  7639. var _context17, _context18;
  7640. var source = null != arguments[i] ? arguments[i] : {};
  7641. i % 2 ? _forEachInstanceProperty2(_context17 = ownKeys(Object(source), !0)).call(_context17, function (key) {
  7642. (0, _defineProperty2.default)(target, key, source[key]);
  7643. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context18 = ownKeys(Object(source))).call(_context18, function (key) {
  7644. _Object$defineProperty2(target, key, _Object$getOwnPropertyDescriptor(source, key));
  7645. });
  7646. }
  7647. return target;
  7648. } /**
  7649. * @flow
  7650. */
  7651. /*:: import type { AttributeMap, OpsMap } from './ObjectStateMutations';*/
  7652. /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
  7653. var uuidv4 = _dereq_('./uuid');
  7654. /*:: export type Pointer = {
  7655. __type: string,
  7656. className: string,
  7657. objectId: string,
  7658. };*/
  7659. /*:: type SaveParams = {
  7660. method: string,
  7661. path: string,
  7662. body: AttributeMap,
  7663. };*/
  7664. /*:: export type SaveOptions = FullOptions & {
  7665. cascadeSave?: boolean,
  7666. context?: AttributeMap,
  7667. };*/
  7668. // Mapping of class names to constructors, so we can populate objects from the
  7669. // server with appropriate subclasses of ParseObject
  7670. var classMap = {};
  7671. // Global counter for generating unique Ids for non-single-instance objects
  7672. var objectCount = 0;
  7673. // On web clients, objects are single-instance: any two objects with the same Id
  7674. // will have the same attributes. However, this may be dangerous default
  7675. // behavior in a server scenario
  7676. var singleInstance = !_CoreManager.default.get('IS_NODE');
  7677. if (singleInstance) {
  7678. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  7679. } else {
  7680. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  7681. }
  7682. function getServerUrlPath() {
  7683. var serverUrl = _CoreManager.default.get('SERVER_URL');
  7684. if (serverUrl[serverUrl.length - 1] !== '/') {
  7685. serverUrl += '/';
  7686. }
  7687. var url = serverUrl.replace(/https?:\/\//, '');
  7688. return url.substr((0, _indexOf.default)(url).call(url, '/'));
  7689. }
  7690. /**
  7691. * Creates a new model with defined attributes.
  7692. *
  7693. * <p>You won't normally call this method directly. It is recommended that
  7694. * you use a subclass of <code>Parse.Object</code> instead, created by calling
  7695. * <code>extend</code>.</p>
  7696. *
  7697. * <p>However, if you don't want to use a subclass, or aren't sure which
  7698. * subclass is appropriate, you can use this form:<pre>
  7699. * var object = new Parse.Object("ClassName");
  7700. * </pre>
  7701. * That is basically equivalent to:<pre>
  7702. * var MyClass = Parse.Object.extend("ClassName");
  7703. * var object = new MyClass();
  7704. * </pre></p>
  7705. *
  7706. * @alias Parse.Object
  7707. */
  7708. var ParseObject = /*#__PURE__*/function () {
  7709. /**
  7710. * @param {string} className The class name for the object
  7711. * @param {object} attributes The initial set of data to store in the object.
  7712. * @param {object} options The options for this object instance.
  7713. */
  7714. function ParseObject(className /*: ?string | { className: string, [attr: string]: mixed }*/, attributes /*:: ?: { [attr: string]: mixed }*/, options /*:: ?: { ignoreValidation: boolean }*/) {
  7715. (0, _classCallCheck2.default)(this, ParseObject);
  7716. /**
  7717. * The ID of this object, unique within its class.
  7718. *
  7719. * @property {string} id
  7720. */
  7721. (0, _defineProperty2.default)(this, "id", void 0);
  7722. (0, _defineProperty2.default)(this, "_localId", void 0);
  7723. (0, _defineProperty2.default)(this, "_objCount", void 0);
  7724. (0, _defineProperty2.default)(this, "className", void 0);
  7725. // Enable legacy initializers
  7726. if (typeof this.initialize === 'function') {
  7727. this.initialize.apply(this, arguments);
  7728. }
  7729. var toSet = null;
  7730. this._objCount = objectCount++;
  7731. if (typeof className === 'string') {
  7732. this.className = className;
  7733. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  7734. toSet = attributes;
  7735. }
  7736. } else if (className && (0, _typeof2.default)(className) === 'object') {
  7737. this.className = className.className;
  7738. toSet = {};
  7739. for (var _attr in className) {
  7740. if (_attr !== 'className') {
  7741. toSet[_attr] = className[_attr];
  7742. }
  7743. }
  7744. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  7745. options = attributes;
  7746. }
  7747. }
  7748. if (toSet && !this.set(toSet, options)) {
  7749. throw new Error("Can't create an invalid Parse Object");
  7750. }
  7751. }
  7752. (0, _createClass2.default)(ParseObject, [{
  7753. key: "attributes",
  7754. get: /* Prototype getters / setters */
  7755. function () /*: AttributeMap*/{
  7756. var stateController = _CoreManager.default.getObjectStateController();
  7757. return (0, _freeze.default)(stateController.estimateAttributes(this._getStateIdentifier()));
  7758. }
  7759. /**
  7760. * The first time this object was saved on the server.
  7761. *
  7762. * @property {Date} createdAt
  7763. * @returns {Date}
  7764. */
  7765. }, {
  7766. key: "createdAt",
  7767. get: function () /*: ?Date*/{
  7768. return this._getServerData().createdAt;
  7769. }
  7770. /**
  7771. * The last time this object was updated on the server.
  7772. *
  7773. * @property {Date} updatedAt
  7774. * @returns {Date}
  7775. */
  7776. }, {
  7777. key: "updatedAt",
  7778. get: function () /*: ?Date*/{
  7779. return this._getServerData().updatedAt;
  7780. }
  7781. /* Private methods */
  7782. /**
  7783. * Returns a local or server Id used uniquely identify this object
  7784. *
  7785. * @returns {string}
  7786. */
  7787. }, {
  7788. key: "_getId",
  7789. value: function () /*: string*/{
  7790. if (typeof this.id === 'string') {
  7791. return this.id;
  7792. }
  7793. if (typeof this._localId === 'string') {
  7794. return this._localId;
  7795. }
  7796. var localId = 'local' + uuidv4();
  7797. this._localId = localId;
  7798. return localId;
  7799. }
  7800. /**
  7801. * Returns a unique identifier used to pull data from the State Controller.
  7802. *
  7803. * @returns {Parse.Object|object}
  7804. */
  7805. }, {
  7806. key: "_getStateIdentifier",
  7807. value: function () /*: ParseObject | { id: string, className: string }*/{
  7808. if (singleInstance) {
  7809. var id = this.id;
  7810. if (!id) {
  7811. id = this._getId();
  7812. }
  7813. return {
  7814. id: id,
  7815. className: this.className
  7816. };
  7817. } else {
  7818. return this;
  7819. }
  7820. }
  7821. }, {
  7822. key: "_getServerData",
  7823. value: function () /*: AttributeMap*/{
  7824. var stateController = _CoreManager.default.getObjectStateController();
  7825. return stateController.getServerData(this._getStateIdentifier());
  7826. }
  7827. }, {
  7828. key: "_clearServerData",
  7829. value: function () {
  7830. var serverData = this._getServerData();
  7831. var unset = {};
  7832. for (var _attr2 in serverData) {
  7833. unset[_attr2] = undefined;
  7834. }
  7835. var stateController = _CoreManager.default.getObjectStateController();
  7836. stateController.setServerData(this._getStateIdentifier(), unset);
  7837. }
  7838. }, {
  7839. key: "_getPendingOps",
  7840. value: function () /*: Array<OpsMap>*/{
  7841. var stateController = _CoreManager.default.getObjectStateController();
  7842. return stateController.getPendingOps(this._getStateIdentifier());
  7843. }
  7844. /**
  7845. * @param {Array<string>} [keysToClear] - if specified, only ops matching
  7846. * these fields will be cleared
  7847. */
  7848. }, {
  7849. key: "_clearPendingOps",
  7850. value: function (keysToClear /*:: ?: Array<string>*/) {
  7851. var pending = this._getPendingOps();
  7852. var latest = pending[pending.length - 1];
  7853. var keys = keysToClear || (0, _keys.default)(latest);
  7854. (0, _forEach.default)(keys).call(keys, function (key) {
  7855. delete latest[key];
  7856. });
  7857. }
  7858. }, {
  7859. key: "_getDirtyObjectAttributes",
  7860. value: function () /*: AttributeMap*/{
  7861. var attributes = this.attributes;
  7862. var stateController = _CoreManager.default.getObjectStateController();
  7863. var objectCache = stateController.getObjectCache(this._getStateIdentifier());
  7864. var dirty = {};
  7865. for (var _attr3 in attributes) {
  7866. var val = attributes[_attr3];
  7867. if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
  7868. // Due to the way browsers construct maps, the key order will not change
  7869. // unless the object is changed
  7870. try {
  7871. var json = (0, _encode.default)(val, false, true);
  7872. var stringified = (0, _stringify.default)(json);
  7873. if (objectCache[_attr3] !== stringified) {
  7874. dirty[_attr3] = val;
  7875. }
  7876. } catch (e) {
  7877. // Error occurred, possibly by a nested unsaved pointer in a mutable container
  7878. // No matter how it happened, it indicates a change in the attribute
  7879. dirty[_attr3] = val;
  7880. }
  7881. }
  7882. }
  7883. return dirty;
  7884. }
  7885. }, {
  7886. key: "_toFullJSON",
  7887. value: function (seen /*:: ?: Array<any>*/, offline /*:: ?: boolean*/) /*: AttributeMap*/{
  7888. var json /*: { [key: string]: mixed }*/ = this.toJSON(seen, offline);
  7889. json.__type = 'Object';
  7890. json.className = this.className;
  7891. return json;
  7892. }
  7893. }, {
  7894. key: "_getSaveJSON",
  7895. value: function () /*: AttributeMap*/{
  7896. var pending = this._getPendingOps();
  7897. var dirtyObjects = this._getDirtyObjectAttributes();
  7898. var json = {};
  7899. for (var attr in dirtyObjects) {
  7900. var isDotNotation = false;
  7901. for (var i = 0; i < pending.length; i += 1) {
  7902. for (var field in pending[i]) {
  7903. // Dot notation operations are handled later
  7904. if ((0, _includes.default)(field).call(field, '.')) {
  7905. var fieldName = field.split('.')[0];
  7906. if (fieldName === attr) {
  7907. isDotNotation = true;
  7908. break;
  7909. }
  7910. }
  7911. }
  7912. }
  7913. if (!isDotNotation) {
  7914. json[attr] = new _ParseOp.SetOp(dirtyObjects[attr]).toJSON();
  7915. }
  7916. }
  7917. for (attr in pending[0]) {
  7918. json[attr] = pending[0][attr].toJSON();
  7919. }
  7920. return json;
  7921. }
  7922. }, {
  7923. key: "_getSaveParams",
  7924. value: function () /*: SaveParams*/{
  7925. var method = this.id ? 'PUT' : 'POST';
  7926. var body = this._getSaveJSON();
  7927. var path = 'classes/' + this.className;
  7928. if (_CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID')) {
  7929. if (!this.createdAt) {
  7930. method = 'POST';
  7931. body.objectId = this.id;
  7932. } else {
  7933. method = 'PUT';
  7934. path += '/' + this.id;
  7935. }
  7936. } else if (this.id) {
  7937. path += '/' + this.id;
  7938. } else if (this.className === '_User') {
  7939. path = 'users';
  7940. }
  7941. return {
  7942. method: method,
  7943. body: body,
  7944. path: path
  7945. };
  7946. }
  7947. }, {
  7948. key: "_finishFetch",
  7949. value: function (serverData /*: AttributeMap*/) {
  7950. if (!this.id && serverData.objectId) {
  7951. this.id = serverData.objectId;
  7952. }
  7953. var stateController = _CoreManager.default.getObjectStateController();
  7954. stateController.initializeState(this._getStateIdentifier());
  7955. var decoded = {};
  7956. for (var _attr4 in serverData) {
  7957. if (_attr4 === 'ACL') {
  7958. decoded[_attr4] = new _ParseACL.default(serverData[_attr4]);
  7959. } else if (_attr4 !== 'objectId') {
  7960. decoded[_attr4] = (0, _decode.default)(serverData[_attr4]);
  7961. if (decoded[_attr4] instanceof _ParseRelation.default) {
  7962. decoded[_attr4]._ensureParentAndKey(this, _attr4);
  7963. }
  7964. }
  7965. }
  7966. if (decoded.createdAt && typeof decoded.createdAt === 'string') {
  7967. decoded.createdAt = (0, _parseDate.default)(decoded.createdAt);
  7968. }
  7969. if (decoded.updatedAt && typeof decoded.updatedAt === 'string') {
  7970. decoded.updatedAt = (0, _parseDate.default)(decoded.updatedAt);
  7971. }
  7972. if (!decoded.updatedAt && decoded.createdAt) {
  7973. decoded.updatedAt = decoded.createdAt;
  7974. }
  7975. stateController.commitServerChanges(this._getStateIdentifier(), decoded);
  7976. }
  7977. }, {
  7978. key: "_setExisted",
  7979. value: function (existed /*: boolean*/) {
  7980. var stateController = _CoreManager.default.getObjectStateController();
  7981. var state = stateController.getState(this._getStateIdentifier());
  7982. if (state) {
  7983. state.existed = existed;
  7984. }
  7985. }
  7986. }, {
  7987. key: "_migrateId",
  7988. value: function (serverId /*: string*/) {
  7989. if (this._localId && serverId) {
  7990. if (singleInstance) {
  7991. var stateController = _CoreManager.default.getObjectStateController();
  7992. var oldState = stateController.removeState(this._getStateIdentifier());
  7993. this.id = serverId;
  7994. delete this._localId;
  7995. if (oldState) {
  7996. stateController.initializeState(this._getStateIdentifier(), oldState);
  7997. }
  7998. } else {
  7999. this.id = serverId;
  8000. delete this._localId;
  8001. }
  8002. }
  8003. }
  8004. }, {
  8005. key: "_handleSaveResponse",
  8006. value: function (response /*: AttributeMap*/, status /*: number*/) {
  8007. var changes = {};
  8008. var stateController = _CoreManager.default.getObjectStateController();
  8009. var pending = stateController.popPendingState(this._getStateIdentifier());
  8010. for (var attr in pending) {
  8011. if (pending[attr] instanceof _ParseOp.RelationOp) {
  8012. changes[attr] = pending[attr].applyTo(undefined, this, attr);
  8013. } else if (!(attr in response)) {
  8014. // Only SetOps and UnsetOps should not come back with results
  8015. changes[attr] = pending[attr].applyTo(undefined);
  8016. }
  8017. }
  8018. for (attr in response) {
  8019. if ((attr === 'createdAt' || attr === 'updatedAt') && typeof response[attr] === 'string') {
  8020. changes[attr] = (0, _parseDate.default)(response[attr]);
  8021. } else if (attr === 'ACL') {
  8022. changes[attr] = new _ParseACL.default(response[attr]);
  8023. } else if (attr !== 'objectId') {
  8024. var val = (0, _decode.default)(response[attr]);
  8025. if (val && (0, _getPrototypeOf.default)(val) === Object.prototype) {
  8026. changes[attr] = _objectSpread(_objectSpread({}, this.attributes[attr]), val);
  8027. } else {
  8028. changes[attr] = val;
  8029. }
  8030. if (changes[attr] instanceof _ParseOp.UnsetOp) {
  8031. changes[attr] = undefined;
  8032. }
  8033. }
  8034. }
  8035. if (changes.createdAt && !changes.updatedAt) {
  8036. changes.updatedAt = changes.createdAt;
  8037. }
  8038. this._migrateId(response.objectId);
  8039. if (status !== 201) {
  8040. this._setExisted(true);
  8041. }
  8042. stateController.commitServerChanges(this._getStateIdentifier(), changes);
  8043. }
  8044. }, {
  8045. key: "_handleSaveError",
  8046. value: function () {
  8047. var stateController = _CoreManager.default.getObjectStateController();
  8048. stateController.mergeFirstPendingState(this._getStateIdentifier());
  8049. }
  8050. }, {
  8051. key: "initialize",
  8052. value: /* Public methods */
  8053. function () {
  8054. // NOOP
  8055. }
  8056. /**
  8057. * Returns a JSON version of the object suitable for saving to Parse.
  8058. *
  8059. * @param seen
  8060. * @param offline
  8061. * @returns {object}
  8062. */
  8063. }, {
  8064. key: "toJSON",
  8065. value: function (seen /*: Array<any> | void*/, offline /*:: ?: boolean*/) /*: AttributeMap*/{
  8066. var seenEntry = this.id ? this.className + ':' + this.id : this;
  8067. seen = seen || [seenEntry];
  8068. var json = {};
  8069. var attrs = this.attributes;
  8070. for (var _attr5 in attrs) {
  8071. if ((_attr5 === 'createdAt' || _attr5 === 'updatedAt') && attrs[_attr5].toJSON) {
  8072. json[_attr5] = attrs[_attr5].toJSON();
  8073. } else {
  8074. json[_attr5] = (0, _encode.default)(attrs[_attr5], false, false, seen, offline);
  8075. }
  8076. }
  8077. var pending = this._getPendingOps();
  8078. for (var _attr6 in pending[0]) {
  8079. json[_attr6] = pending[0][_attr6].toJSON(offline);
  8080. }
  8081. if (this.id) {
  8082. json.objectId = this.id;
  8083. }
  8084. return json;
  8085. }
  8086. /**
  8087. * Determines whether this ParseObject is equal to another ParseObject
  8088. *
  8089. * @param {object} other - An other object ot compare
  8090. * @returns {boolean}
  8091. */
  8092. }, {
  8093. key: "equals",
  8094. value: function (other /*: mixed*/) /*: boolean*/{
  8095. if (this === other) {
  8096. return true;
  8097. }
  8098. return other instanceof ParseObject && this.className === other.className && this.id === other.id && typeof this.id !== 'undefined';
  8099. }
  8100. /**
  8101. * Returns true if this object has been modified since its last
  8102. * save/refresh. If an attribute is specified, it returns true only if that
  8103. * particular attribute has been modified since the last save/refresh.
  8104. *
  8105. * @param {string} attr An attribute name (optional).
  8106. * @returns {boolean}
  8107. */
  8108. }, {
  8109. key: "dirty",
  8110. value: function (attr /*:: ?: string*/) /*: boolean*/{
  8111. if (!this.id) {
  8112. return true;
  8113. }
  8114. var pendingOps = this._getPendingOps();
  8115. var dirtyObjects = this._getDirtyObjectAttributes();
  8116. if (attr) {
  8117. if (dirtyObjects.hasOwnProperty(attr)) {
  8118. return true;
  8119. }
  8120. for (var i = 0; i < pendingOps.length; i++) {
  8121. if (pendingOps[i].hasOwnProperty(attr)) {
  8122. return true;
  8123. }
  8124. }
  8125. return false;
  8126. }
  8127. if ((0, _keys.default)(pendingOps[0]).length !== 0) {
  8128. return true;
  8129. }
  8130. if ((0, _keys.default)(dirtyObjects).length !== 0) {
  8131. return true;
  8132. }
  8133. return false;
  8134. }
  8135. /**
  8136. * Returns an array of keys that have been modified since last save/refresh
  8137. *
  8138. * @returns {string[]}
  8139. */
  8140. }, {
  8141. key: "dirtyKeys",
  8142. value: function () /*: Array<string>*/{
  8143. var pendingOps = this._getPendingOps();
  8144. var keys = {};
  8145. for (var i = 0; i < pendingOps.length; i++) {
  8146. for (var _attr7 in pendingOps[i]) {
  8147. keys[_attr7] = true;
  8148. }
  8149. }
  8150. var dirtyObjects = this._getDirtyObjectAttributes();
  8151. for (var _attr8 in dirtyObjects) {
  8152. keys[_attr8] = true;
  8153. }
  8154. return (0, _keys.default)(keys);
  8155. }
  8156. /**
  8157. * Returns true if the object has been fetched.
  8158. *
  8159. * @returns {boolean}
  8160. */
  8161. }, {
  8162. key: "isDataAvailable",
  8163. value: function () /*: boolean*/{
  8164. var serverData = this._getServerData();
  8165. return !!(0, _keys.default)(serverData).length;
  8166. }
  8167. /**
  8168. * Gets a Pointer referencing this Object.
  8169. *
  8170. * @returns {Pointer}
  8171. */
  8172. }, {
  8173. key: "toPointer",
  8174. value: function () /*: Pointer*/{
  8175. if (!this.id) {
  8176. throw new Error('Cannot create a pointer to an unsaved ParseObject');
  8177. }
  8178. return {
  8179. __type: 'Pointer',
  8180. className: this.className,
  8181. objectId: this.id
  8182. };
  8183. }
  8184. /**
  8185. * Gets a Pointer referencing this Object.
  8186. *
  8187. * @returns {Pointer}
  8188. */
  8189. }, {
  8190. key: "toOfflinePointer",
  8191. value: function () /*: Pointer*/{
  8192. if (!this._localId) {
  8193. throw new Error('Cannot create a offline pointer to a saved ParseObject');
  8194. }
  8195. return {
  8196. __type: 'Object',
  8197. className: this.className,
  8198. _localId: this._localId
  8199. };
  8200. }
  8201. /**
  8202. * Gets the value of an attribute.
  8203. *
  8204. * @param {string} attr The string name of an attribute.
  8205. * @returns {*}
  8206. */
  8207. }, {
  8208. key: "get",
  8209. value: function (attr /*: string*/) /*: mixed*/{
  8210. return this.attributes[attr];
  8211. }
  8212. /**
  8213. * Gets a relation on the given class for the attribute.
  8214. *
  8215. * @param {string} attr The attribute to get the relation for.
  8216. * @returns {Parse.Relation}
  8217. */
  8218. }, {
  8219. key: "relation",
  8220. value: function (attr /*: string*/) /*: ParseRelation*/{
  8221. var value = this.get(attr);
  8222. if (value) {
  8223. if (!(value instanceof _ParseRelation.default)) {
  8224. throw new Error('Called relation() on non-relation field ' + attr);
  8225. }
  8226. value._ensureParentAndKey(this, attr);
  8227. return value;
  8228. }
  8229. return new _ParseRelation.default(this, attr);
  8230. }
  8231. /**
  8232. * Gets the HTML-escaped value of an attribute.
  8233. *
  8234. * @param {string} attr The string name of an attribute.
  8235. * @returns {string}
  8236. */
  8237. }, {
  8238. key: "escape",
  8239. value: function (attr /*: string*/) /*: string*/{
  8240. var val = this.attributes[attr];
  8241. if (val == null) {
  8242. return '';
  8243. }
  8244. if (typeof val !== 'string') {
  8245. if (typeof val.toString !== 'function') {
  8246. return '';
  8247. }
  8248. val = val.toString();
  8249. }
  8250. return (0, _escape2.default)(val);
  8251. }
  8252. /**
  8253. * Returns <code>true</code> if the attribute contains a value that is not
  8254. * null or undefined.
  8255. *
  8256. * @param {string} attr The string name of the attribute.
  8257. * @returns {boolean}
  8258. */
  8259. }, {
  8260. key: "has",
  8261. value: function (attr /*: string*/) /*: boolean*/{
  8262. var attributes = this.attributes;
  8263. if (attributes.hasOwnProperty(attr)) {
  8264. return attributes[attr] != null;
  8265. }
  8266. return false;
  8267. }
  8268. /**
  8269. * Sets a hash of model attributes on the object.
  8270. *
  8271. * <p>You can call it with an object containing keys and values, with one
  8272. * key and value, or dot notation. For example:<pre>
  8273. * gameTurn.set({
  8274. * player: player1,
  8275. * diceRoll: 2
  8276. * }, {
  8277. * error: function(gameTurnAgain, error) {
  8278. * // The set failed validation.
  8279. * }
  8280. * });
  8281. *
  8282. * game.set("currentPlayer", player2, {
  8283. * error: function(gameTurnAgain, error) {
  8284. * // The set failed validation.
  8285. * }
  8286. * });
  8287. *
  8288. * game.set("finished", true);</pre></p>
  8289. *
  8290. * game.set("player.score", 10);</pre></p>
  8291. *
  8292. * @param {(string|object)} key The key to set.
  8293. * @param {(string|object)} value The value to give it.
  8294. * @param {object} options A set of options for the set.
  8295. * The only supported option is <code>error</code>.
  8296. * @returns {(ParseObject|boolean)} true if the set succeeded.
  8297. */
  8298. }, {
  8299. key: "set",
  8300. value: function (key /*: mixed*/, value /*: mixed*/, options /*:: ?: mixed*/) /*: ParseObject | boolean*/{
  8301. var changes = {};
  8302. var newOps = {};
  8303. if (key && (0, _typeof2.default)(key) === 'object') {
  8304. changes = key;
  8305. options = value;
  8306. } else if (typeof key === 'string') {
  8307. changes[key] = value;
  8308. } else {
  8309. return this;
  8310. }
  8311. options = options || {};
  8312. var readonly = [];
  8313. if (typeof this.constructor.readOnlyAttributes === 'function') {
  8314. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  8315. }
  8316. for (var k in changes) {
  8317. if (k === 'createdAt' || k === 'updatedAt') {
  8318. // This property is read-only, but for legacy reasons we silently
  8319. // ignore it
  8320. continue;
  8321. }
  8322. if ((0, _indexOf.default)(readonly).call(readonly, k) > -1) {
  8323. throw new Error('Cannot modify readonly attribute: ' + k);
  8324. }
  8325. if (options.unset) {
  8326. newOps[k] = new _ParseOp.UnsetOp();
  8327. } else if (changes[k] instanceof _ParseOp.Op) {
  8328. newOps[k] = changes[k];
  8329. } else if (changes[k] && (0, _typeof2.default)(changes[k]) === 'object' && typeof changes[k].__op === 'string') {
  8330. newOps[k] = (0, _ParseOp.opFromJSON)(changes[k]);
  8331. } else if (k === 'objectId' || k === 'id') {
  8332. if (typeof changes[k] === 'string') {
  8333. this.id = changes[k];
  8334. }
  8335. } else if (k === 'ACL' && (0, _typeof2.default)(changes[k]) === 'object' && !(changes[k] instanceof _ParseACL.default)) {
  8336. newOps[k] = new _ParseOp.SetOp(new _ParseACL.default(changes[k]));
  8337. } else if (changes[k] instanceof _ParseRelation.default) {
  8338. var relation = new _ParseRelation.default(this, k);
  8339. relation.targetClassName = changes[k].targetClassName;
  8340. newOps[k] = new _ParseOp.SetOp(relation);
  8341. } else {
  8342. newOps[k] = new _ParseOp.SetOp(changes[k]);
  8343. }
  8344. }
  8345. var currentAttributes = this.attributes;
  8346. // Calculate new values
  8347. var newValues = {};
  8348. for (var _attr9 in newOps) {
  8349. if (newOps[_attr9] instanceof _ParseOp.RelationOp) {
  8350. newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9], this, _attr9);
  8351. } else if (!(newOps[_attr9] instanceof _ParseOp.UnsetOp)) {
  8352. newValues[_attr9] = newOps[_attr9].applyTo(currentAttributes[_attr9]);
  8353. }
  8354. }
  8355. // Validate changes
  8356. if (!options.ignoreValidation) {
  8357. var validation = this.validate(newValues);
  8358. if (validation) {
  8359. if (typeof options.error === 'function') {
  8360. options.error(this, validation);
  8361. }
  8362. return false;
  8363. }
  8364. }
  8365. // Consolidate Ops
  8366. var pendingOps = this._getPendingOps();
  8367. var last = pendingOps.length - 1;
  8368. var stateController = _CoreManager.default.getObjectStateController();
  8369. for (var _attr10 in newOps) {
  8370. var nextOp = newOps[_attr10].mergeWith(pendingOps[last][_attr10]);
  8371. stateController.setPendingOp(this._getStateIdentifier(), _attr10, nextOp);
  8372. }
  8373. return this;
  8374. }
  8375. /**
  8376. * Remove an attribute from the model. This is a noop if the attribute doesn't
  8377. * exist.
  8378. *
  8379. * @param {string} attr The string name of an attribute.
  8380. * @param options
  8381. * @returns {(ParseObject | boolean)}
  8382. */
  8383. }, {
  8384. key: "unset",
  8385. value: function (attr /*: string*/, options /*:: ?: { [opt: string]: mixed }*/) /*: ParseObject | boolean*/{
  8386. options = options || {};
  8387. options.unset = true;
  8388. return this.set(attr, null, options);
  8389. }
  8390. /**
  8391. * Atomically increments the value of the given attribute the next time the
  8392. * object is saved. If no amount is specified, 1 is used by default.
  8393. *
  8394. * @param attr {String} The key.
  8395. * @param amount {Number} The amount to increment by (optional).
  8396. * @returns {(ParseObject|boolean)}
  8397. */
  8398. }, {
  8399. key: "increment",
  8400. value: function (attr /*: string*/, amount /*:: ?: number*/) /*: ParseObject | boolean*/{
  8401. if (typeof amount === 'undefined') {
  8402. amount = 1;
  8403. }
  8404. if (typeof amount !== 'number') {
  8405. throw new Error('Cannot increment by a non-numeric amount.');
  8406. }
  8407. return this.set(attr, new _ParseOp.IncrementOp(amount));
  8408. }
  8409. /**
  8410. * Atomically decrements the value of the given attribute the next time the
  8411. * object is saved. If no amount is specified, 1 is used by default.
  8412. *
  8413. * @param attr {String} The key.
  8414. * @param amount {Number} The amount to decrement by (optional).
  8415. * @returns {(ParseObject | boolean)}
  8416. */
  8417. }, {
  8418. key: "decrement",
  8419. value: function (attr /*: string*/, amount /*:: ?: number*/) /*: ParseObject | boolean*/{
  8420. if (typeof amount === 'undefined') {
  8421. amount = 1;
  8422. }
  8423. if (typeof amount !== 'number') {
  8424. throw new Error('Cannot decrement by a non-numeric amount.');
  8425. }
  8426. return this.set(attr, new _ParseOp.IncrementOp(amount * -1));
  8427. }
  8428. /**
  8429. * Atomically add an object to the end of the array associated with a given
  8430. * key.
  8431. *
  8432. * @param attr {String} The key.
  8433. * @param item {} The item to add.
  8434. * @returns {(ParseObject | boolean)}
  8435. */
  8436. }, {
  8437. key: "add",
  8438. value: function (attr /*: string*/, item /*: mixed*/) /*: ParseObject | boolean*/{
  8439. return this.set(attr, new _ParseOp.AddOp([item]));
  8440. }
  8441. /**
  8442. * Atomically add the objects to the end of the array associated with a given
  8443. * key.
  8444. *
  8445. * @param attr {String} The key.
  8446. * @param items {Object[]} The items to add.
  8447. * @returns {(ParseObject | boolean)}
  8448. */
  8449. }, {
  8450. key: "addAll",
  8451. value: function (attr /*: string*/, items /*: Array<mixed>*/) /*: ParseObject | boolean*/{
  8452. return this.set(attr, new _ParseOp.AddOp(items));
  8453. }
  8454. /**
  8455. * Atomically add an object to the array associated with a given key, only
  8456. * if it is not already present in the array. The position of the insert is
  8457. * not guaranteed.
  8458. *
  8459. * @param attr {String} The key.
  8460. * @param item {} The object to add.
  8461. * @returns {(ParseObject | boolean)}
  8462. */
  8463. }, {
  8464. key: "addUnique",
  8465. value: function (attr /*: string*/, item /*: mixed*/) /*: ParseObject | boolean*/{
  8466. return this.set(attr, new _ParseOp.AddUniqueOp([item]));
  8467. }
  8468. /**
  8469. * Atomically add the objects to the array associated with a given key, only
  8470. * if it is not already present in the array. The position of the insert is
  8471. * not guaranteed.
  8472. *
  8473. * @param attr {String} The key.
  8474. * @param items {Object[]} The objects to add.
  8475. * @returns {(ParseObject | boolean)}
  8476. */
  8477. }, {
  8478. key: "addAllUnique",
  8479. value: function (attr /*: string*/, items /*: Array<mixed>*/) /*: ParseObject | boolean*/{
  8480. return this.set(attr, new _ParseOp.AddUniqueOp(items));
  8481. }
  8482. /**
  8483. * Atomically remove all instances of an object from the array associated
  8484. * with a given key.
  8485. *
  8486. * @param attr {String} The key.
  8487. * @param item {} The object to remove.
  8488. * @returns {(ParseObject | boolean)}
  8489. */
  8490. }, {
  8491. key: "remove",
  8492. value: function (attr /*: string*/, item /*: mixed*/) /*: ParseObject | boolean*/{
  8493. return this.set(attr, new _ParseOp.RemoveOp([item]));
  8494. }
  8495. /**
  8496. * Atomically remove all instances of the objects from the array associated
  8497. * with a given key.
  8498. *
  8499. * @param attr {String} The key.
  8500. * @param items {Object[]} The object to remove.
  8501. * @returns {(ParseObject | boolean)}
  8502. */
  8503. }, {
  8504. key: "removeAll",
  8505. value: function (attr /*: string*/, items /*: Array<mixed>*/) /*: ParseObject | boolean*/{
  8506. return this.set(attr, new _ParseOp.RemoveOp(items));
  8507. }
  8508. /**
  8509. * Returns an instance of a subclass of Parse.Op describing what kind of
  8510. * modification has been performed on this field since the last time it was
  8511. * saved. For example, after calling object.increment("x"), calling
  8512. * object.op("x") would return an instance of Parse.Op.Increment.
  8513. *
  8514. * @param attr {String} The key.
  8515. * @returns {Parse.Op | undefined} The operation, or undefined if none.
  8516. */
  8517. }, {
  8518. key: "op",
  8519. value: function (attr /*: string*/) /*: ?Op*/{
  8520. var pending = this._getPendingOps();
  8521. for (var i = pending.length; i--;) {
  8522. if (pending[i][attr]) {
  8523. return pending[i][attr];
  8524. }
  8525. }
  8526. }
  8527. /**
  8528. * Creates a new model with identical attributes to this one.
  8529. *
  8530. * @returns {Parse.Object}
  8531. */
  8532. }, {
  8533. key: "clone",
  8534. value: function clone() /*: any*/{
  8535. var clone = new this.constructor(this.className);
  8536. var attributes = this.attributes;
  8537. if (typeof this.constructor.readOnlyAttributes === 'function') {
  8538. var readonly = this.constructor.readOnlyAttributes() || [];
  8539. // Attributes are frozen, so we have to rebuild an object,
  8540. // rather than delete readonly keys
  8541. var copy = {};
  8542. for (var a in attributes) {
  8543. if ((0, _indexOf.default)(readonly).call(readonly, a) < 0) {
  8544. copy[a] = attributes[a];
  8545. }
  8546. }
  8547. attributes = copy;
  8548. }
  8549. if (clone.set) {
  8550. clone.set(attributes);
  8551. }
  8552. return clone;
  8553. }
  8554. /**
  8555. * Creates a new instance of this object. Not to be confused with clone()
  8556. *
  8557. * @returns {Parse.Object}
  8558. */
  8559. }, {
  8560. key: "newInstance",
  8561. value: function () /*: any*/{
  8562. var clone = new this.constructor(this.className);
  8563. clone.id = this.id;
  8564. if (singleInstance) {
  8565. // Just return an object with the right id
  8566. return clone;
  8567. }
  8568. var stateController = _CoreManager.default.getObjectStateController();
  8569. if (stateController) {
  8570. stateController.duplicateState(this._getStateIdentifier(), clone._getStateIdentifier());
  8571. }
  8572. return clone;
  8573. }
  8574. /**
  8575. * Returns true if this object has never been saved to Parse.
  8576. *
  8577. * @returns {boolean}
  8578. */
  8579. }, {
  8580. key: "isNew",
  8581. value: function () /*: boolean*/{
  8582. return !this.id;
  8583. }
  8584. /**
  8585. * Returns true if this object was created by the Parse server when the
  8586. * object might have already been there (e.g. in the case of a Facebook
  8587. * login)
  8588. *
  8589. * @returns {boolean}
  8590. */
  8591. }, {
  8592. key: "existed",
  8593. value: function () /*: boolean*/{
  8594. if (!this.id) {
  8595. return false;
  8596. }
  8597. var stateController = _CoreManager.default.getObjectStateController();
  8598. var state = stateController.getState(this._getStateIdentifier());
  8599. if (state) {
  8600. return state.existed;
  8601. }
  8602. return false;
  8603. }
  8604. /**
  8605. * Returns true if this object exists on the Server
  8606. *
  8607. * @param {object} options
  8608. * Valid options are:<ul>
  8609. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8610. * be used for this request.
  8611. * <li>sessionToken: A valid session token, used for making a request on
  8612. * behalf of a specific user.
  8613. * </ul>
  8614. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object exists.
  8615. */
  8616. }, {
  8617. key: "exists",
  8618. value: function () {
  8619. var _exists = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options /*:: ?: RequestOptions*/) {
  8620. var query;
  8621. return _regenerator.default.wrap(function (_context) {
  8622. while (1) switch (_context.prev = _context.next) {
  8623. case 0:
  8624. if (this.id) {
  8625. _context.next = 2;
  8626. break;
  8627. }
  8628. return _context.abrupt("return", false);
  8629. case 2:
  8630. _context.prev = 2;
  8631. query = new _ParseQuery.default(this.className);
  8632. _context.next = 6;
  8633. return query.get(this.id, options);
  8634. case 6:
  8635. return _context.abrupt("return", true);
  8636. case 9:
  8637. _context.prev = 9;
  8638. _context.t0 = _context["catch"](2);
  8639. if (!(_context.t0.code === _ParseError.default.OBJECT_NOT_FOUND)) {
  8640. _context.next = 13;
  8641. break;
  8642. }
  8643. return _context.abrupt("return", false);
  8644. case 13:
  8645. throw _context.t0;
  8646. case 14:
  8647. case "end":
  8648. return _context.stop();
  8649. }
  8650. }, _callee, this, [[2, 9]]);
  8651. }));
  8652. function exists() {
  8653. return _exists.apply(this, arguments);
  8654. }
  8655. return exists;
  8656. }()
  8657. /**
  8658. * Checks if the model is currently in a valid state.
  8659. *
  8660. * @returns {boolean}
  8661. */
  8662. }, {
  8663. key: "isValid",
  8664. value: function () /*: boolean*/{
  8665. return !this.validate(this.attributes);
  8666. }
  8667. /**
  8668. * You should not call this function directly unless you subclass
  8669. * <code>Parse.Object</code>, in which case you can override this method
  8670. * to provide additional validation on <code>set</code> and
  8671. * <code>save</code>. Your implementation should return
  8672. *
  8673. * @param {object} attrs The current data to validate.
  8674. * @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise.
  8675. * @see Parse.Object#set
  8676. */
  8677. }, {
  8678. key: "validate",
  8679. value: function (attrs /*: AttributeMap*/) /*: ParseError | boolean*/{
  8680. if (attrs.hasOwnProperty('ACL') && !(attrs.ACL instanceof _ParseACL.default)) {
  8681. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'ACL must be a Parse ACL.');
  8682. }
  8683. for (var _key in attrs) {
  8684. if (!/^[A-Za-z][0-9A-Za-z_.]*$/.test(_key)) {
  8685. return new _ParseError.default(_ParseError.default.INVALID_KEY_NAME);
  8686. }
  8687. }
  8688. return false;
  8689. }
  8690. /**
  8691. * Returns the ACL for this object.
  8692. *
  8693. * @returns {Parse.ACL} An instance of Parse.ACL.
  8694. * @see Parse.Object#get
  8695. */
  8696. }, {
  8697. key: "getACL",
  8698. value: function () /*: ?ParseACL*/{
  8699. var acl = this.get('ACL');
  8700. if (acl instanceof _ParseACL.default) {
  8701. return acl;
  8702. }
  8703. return null;
  8704. }
  8705. /**
  8706. * Sets the ACL to be used for this object.
  8707. *
  8708. * @param {Parse.ACL} acl An instance of Parse.ACL.
  8709. * @param {object} options
  8710. * @returns {(ParseObject | boolean)} Whether the set passed validation.
  8711. * @see Parse.Object#set
  8712. */
  8713. }, {
  8714. key: "setACL",
  8715. value: function (acl /*: ParseACL*/, options /*:: ?: mixed*/) /*: ParseObject | boolean*/{
  8716. return this.set('ACL', acl, options);
  8717. }
  8718. /**
  8719. * Clears any (or specific) changes to this object made since the last call to save()
  8720. *
  8721. * @param {string} [keys] - specify which fields to revert
  8722. */
  8723. }, {
  8724. key: "revert",
  8725. value: function () /*: void*/{
  8726. var keysToRevert;
  8727. for (var _len = arguments.length, keys = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
  8728. keys[_key2] = arguments[_key2];
  8729. }
  8730. if (keys.length) {
  8731. keysToRevert = [];
  8732. var _iterator = _createForOfIteratorHelper(keys),
  8733. _step;
  8734. try {
  8735. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8736. var _key3 = _step.value;
  8737. if (typeof _key3 === 'string') {
  8738. keysToRevert.push(_key3);
  8739. } else {
  8740. throw new Error('Parse.Object#revert expects either no, or a list of string, arguments.');
  8741. }
  8742. }
  8743. } catch (err) {
  8744. _iterator.e(err);
  8745. } finally {
  8746. _iterator.f();
  8747. }
  8748. }
  8749. this._clearPendingOps(keysToRevert);
  8750. }
  8751. /**
  8752. * Clears all attributes on a model
  8753. *
  8754. * @returns {(ParseObject | boolean)}
  8755. */
  8756. }, {
  8757. key: "clear",
  8758. value: function () /*: ParseObject | boolean*/{
  8759. var attributes = this.attributes;
  8760. var erasable = {};
  8761. var readonly = ['createdAt', 'updatedAt'];
  8762. if (typeof this.constructor.readOnlyAttributes === 'function') {
  8763. readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
  8764. }
  8765. for (var _attr11 in attributes) {
  8766. if ((0, _indexOf.default)(readonly).call(readonly, _attr11) < 0) {
  8767. erasable[_attr11] = true;
  8768. }
  8769. }
  8770. return this.set(erasable, {
  8771. unset: true
  8772. });
  8773. }
  8774. /**
  8775. * Fetch the model from the server. If the server's representation of the
  8776. * model differs from its current attributes, they will be overriden.
  8777. *
  8778. * @param {object} options
  8779. * Valid options are:<ul>
  8780. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8781. * be used for this request.
  8782. * <li>sessionToken: A valid session token, used for making a request on
  8783. * behalf of a specific user.
  8784. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  8785. * or an array of array of strings.
  8786. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  8787. * </ul>
  8788. * @returns {Promise} A promise that is fulfilled when the fetch
  8789. * completes.
  8790. */
  8791. }, {
  8792. key: "fetch",
  8793. value: function (options /*: RequestOptions*/) /*: Promise*/{
  8794. options = options || {};
  8795. var fetchOptions = {};
  8796. if (options.hasOwnProperty('useMasterKey')) {
  8797. fetchOptions.useMasterKey = options.useMasterKey;
  8798. }
  8799. if (options.hasOwnProperty('sessionToken')) {
  8800. fetchOptions.sessionToken = options.sessionToken;
  8801. }
  8802. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  8803. fetchOptions.context = options.context;
  8804. }
  8805. if (options.hasOwnProperty('include')) {
  8806. fetchOptions.include = [];
  8807. if ((0, _isArray.default)(options.include)) {
  8808. var _context2;
  8809. (0, _forEach.default)(_context2 = options.include).call(_context2, function (key) {
  8810. if ((0, _isArray.default)(key)) {
  8811. var _context3;
  8812. fetchOptions.include = (0, _concat.default)(_context3 = fetchOptions.include).call(_context3, key);
  8813. } else {
  8814. fetchOptions.include.push(key);
  8815. }
  8816. });
  8817. } else {
  8818. fetchOptions.include.push(options.include);
  8819. }
  8820. }
  8821. var controller = _CoreManager.default.getObjectController();
  8822. return controller.fetch(this, true, fetchOptions);
  8823. }
  8824. /**
  8825. * Fetch the model from the server. If the server's representation of the
  8826. * model differs from its current attributes, they will be overriden.
  8827. *
  8828. * Includes nested Parse.Objects for the provided key. You can use dot
  8829. * notation to specify which fields in the included object are also fetched.
  8830. *
  8831. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  8832. * @param {object} options
  8833. * Valid options are:<ul>
  8834. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8835. * be used for this request.
  8836. * <li>sessionToken: A valid session token, used for making a request on
  8837. * behalf of a specific user.
  8838. * </ul>
  8839. * @returns {Promise} A promise that is fulfilled when the fetch
  8840. * completes.
  8841. */
  8842. }, {
  8843. key: "fetchWithInclude",
  8844. value: function (keys /*: String | Array<string | Array<string>>*/, options /*: RequestOptions*/) /*: Promise*/{
  8845. options = options || {};
  8846. options.include = keys;
  8847. return this.fetch(options);
  8848. }
  8849. /**
  8850. * Saves this object to the server at some unspecified time in the future,
  8851. * even if Parse is currently inaccessible.
  8852. *
  8853. * Use this when you may not have a solid network connection, and don't need to know when the save completes.
  8854. * If there is some problem with the object such that it can't be saved, it will be silently discarded.
  8855. *
  8856. * Objects saved with this method will be stored locally in an on-disk cache until they can be delivered to Parse.
  8857. * They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection is
  8858. * available. Objects saved this way will persist even after the app is closed, in which case they will be sent the
  8859. * next time the app is opened.
  8860. *
  8861. * @param {object} [options]
  8862. * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
  8863. * Valid options are:
  8864. * <ul>
  8865. * <li>sessionToken: A valid session token, used for making a request on
  8866. * behalf of a specific user.
  8867. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  8868. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  8869. * </ul>
  8870. * @returns {Promise} A promise that is fulfilled when the save
  8871. * completes.
  8872. */
  8873. }, {
  8874. key: "saveEventually",
  8875. value: function () {
  8876. var _saveEventually = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(options /*: SaveOptions*/) {
  8877. return _regenerator.default.wrap(function (_context4) {
  8878. while (1) switch (_context4.prev = _context4.next) {
  8879. case 0:
  8880. _context4.prev = 0;
  8881. _context4.next = 3;
  8882. return this.save(null, options);
  8883. case 3:
  8884. _context4.next = 11;
  8885. break;
  8886. case 5:
  8887. _context4.prev = 5;
  8888. _context4.t0 = _context4["catch"](0);
  8889. if (!(_context4.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
  8890. _context4.next = 11;
  8891. break;
  8892. }
  8893. _context4.next = 10;
  8894. return _EventuallyQueue.default.save(this, options);
  8895. case 10:
  8896. _EventuallyQueue.default.poll();
  8897. case 11:
  8898. return _context4.abrupt("return", this);
  8899. case 12:
  8900. case "end":
  8901. return _context4.stop();
  8902. }
  8903. }, _callee2, this, [[0, 5]]);
  8904. }));
  8905. function saveEventually() {
  8906. return _saveEventually.apply(this, arguments);
  8907. }
  8908. return saveEventually;
  8909. }()
  8910. /**
  8911. * Set a hash of model attributes, and save the model to the server.
  8912. * updatedAt will be updated when the request returns.
  8913. * You can either call it as:<pre>
  8914. * object.save();</pre>
  8915. * or<pre>
  8916. * object.save(attrs);</pre>
  8917. * or<pre>
  8918. * object.save(null, options);</pre>
  8919. * or<pre>
  8920. * object.save(attrs, options);</pre>
  8921. * or<pre>
  8922. * object.save(key, value);</pre>
  8923. * or<pre>
  8924. * object.save(key, value, options);</pre>
  8925. *
  8926. * Example 1: <pre>
  8927. * gameTurn.save({
  8928. * player: "Jake Cutter",
  8929. * diceRoll: 2
  8930. * }).then(function(gameTurnAgain) {
  8931. * // The save was successful.
  8932. * }, function(error) {
  8933. * // The save failed. Error is an instance of Parse.Error.
  8934. * });</pre>
  8935. *
  8936. * Example 2: <pre>
  8937. * gameTurn.save("player", "Jake Cutter");</pre>
  8938. *
  8939. * @param {string | object | null} [arg1]
  8940. * Valid options are:<ul>
  8941. * <li>`Object` - Key/value pairs to update on the object.</li>
  8942. * <li>`String` Key - Key of attribute to update (requires arg2 to also be string)</li>
  8943. * <li>`null` - Passing null for arg1 allows you to save the object with options passed in arg2.</li>
  8944. * </ul>
  8945. * @param {string | object} [arg2]
  8946. * <ul>
  8947. * <li>`String` Value - If arg1 was passed as a key, arg2 is the value that should be set on that key.</li>
  8948. * <li>`Object` Options - Valid options are:
  8949. * <ul>
  8950. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8951. * be used for this request.
  8952. * <li>sessionToken: A valid session token, used for making a request on
  8953. * behalf of a specific user.
  8954. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  8955. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  8956. * </ul>
  8957. * </li>
  8958. * </ul>
  8959. * @param {object} [arg3]
  8960. * Used to pass option parameters to method if arg1 and arg2 were both passed as strings.
  8961. * Valid options are:
  8962. * <ul>
  8963. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  8964. * be used for this request.
  8965. * <li>sessionToken: A valid session token, used for making a request on
  8966. * behalf of a specific user.
  8967. * <li>cascadeSave: If `false`, nested objects will not be saved (default is `true`).
  8968. * <li>context: A dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers.
  8969. * </ul>
  8970. * @returns {Promise} A promise that is fulfilled when the save
  8971. * completes.
  8972. */
  8973. }, {
  8974. key: "save",
  8975. value: function (arg1 /*: ?string | { [attr: string]: mixed }*/, arg2 /*: SaveOptions | mixed*/, arg3 /*:: ?: SaveOptions*/) /*: Promise*/{
  8976. var _this = this;
  8977. var attrs;
  8978. var options;
  8979. if ((0, _typeof2.default)(arg1) === 'object' || typeof arg1 === 'undefined') {
  8980. attrs = arg1;
  8981. if ((0, _typeof2.default)(arg2) === 'object') {
  8982. options = arg2;
  8983. }
  8984. } else {
  8985. attrs = {};
  8986. attrs[arg1] = arg2;
  8987. options = arg3;
  8988. }
  8989. if (attrs) {
  8990. var validation = this.validate(attrs);
  8991. if (validation) {
  8992. return _promise.default.reject(validation);
  8993. }
  8994. this.set(attrs, options);
  8995. }
  8996. options = options || {};
  8997. var saveOptions = {};
  8998. if (options.hasOwnProperty('useMasterKey')) {
  8999. saveOptions.useMasterKey = !!options.useMasterKey;
  9000. }
  9001. if (options.hasOwnProperty('sessionToken') && typeof options.sessionToken === 'string') {
  9002. saveOptions.sessionToken = options.sessionToken;
  9003. }
  9004. if (options.hasOwnProperty('installationId') && typeof options.installationId === 'string') {
  9005. saveOptions.installationId = options.installationId;
  9006. }
  9007. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  9008. saveOptions.context = options.context;
  9009. }
  9010. var controller = _CoreManager.default.getObjectController();
  9011. var unsaved = options.cascadeSave !== false ? (0, _unsavedChildren.default)(this) : null;
  9012. return controller.save(unsaved, saveOptions).then(function () {
  9013. return controller.save(_this, saveOptions);
  9014. });
  9015. }
  9016. /**
  9017. * Deletes this object from the server at some unspecified time in the future,
  9018. * even if Parse is currently inaccessible.
  9019. *
  9020. * Use this when you may not have a solid network connection,
  9021. * and don't need to know when the delete completes. If there is some problem with the object
  9022. * such that it can't be deleted, the request will be silently discarded.
  9023. *
  9024. * Delete instructions made with this method will be stored locally in an on-disk cache until they can be transmitted
  9025. * to Parse. They will be sent immediately if possible. Otherwise, they will be sent the next time a network connection
  9026. * is available. Delete requests will persist even after the app is closed, in which case they will be sent the
  9027. * next time the app is opened.
  9028. *
  9029. * @param {object} [options]
  9030. * Valid options are:<ul>
  9031. * <li>sessionToken: A valid session token, used for making a request on
  9032. * behalf of a specific user.
  9033. * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
  9034. * </ul>
  9035. * @returns {Promise} A promise that is fulfilled when the destroy
  9036. * completes.
  9037. */
  9038. }, {
  9039. key: "destroyEventually",
  9040. value: function () {
  9041. var _destroyEventually = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(options /*: RequestOptions*/) {
  9042. return _regenerator.default.wrap(function (_context5) {
  9043. while (1) switch (_context5.prev = _context5.next) {
  9044. case 0:
  9045. _context5.prev = 0;
  9046. _context5.next = 3;
  9047. return this.destroy(options);
  9048. case 3:
  9049. _context5.next = 11;
  9050. break;
  9051. case 5:
  9052. _context5.prev = 5;
  9053. _context5.t0 = _context5["catch"](0);
  9054. if (!(_context5.t0.message === 'XMLHttpRequest failed: "Unable to connect to the Parse API"')) {
  9055. _context5.next = 11;
  9056. break;
  9057. }
  9058. _context5.next = 10;
  9059. return _EventuallyQueue.default.destroy(this, options);
  9060. case 10:
  9061. _EventuallyQueue.default.poll();
  9062. case 11:
  9063. return _context5.abrupt("return", this);
  9064. case 12:
  9065. case "end":
  9066. return _context5.stop();
  9067. }
  9068. }, _callee3, this, [[0, 5]]);
  9069. }));
  9070. function destroyEventually() {
  9071. return _destroyEventually.apply(this, arguments);
  9072. }
  9073. return destroyEventually;
  9074. }()
  9075. /**
  9076. * Destroy this model on the server if it was already persisted.
  9077. *
  9078. * @param {object} options
  9079. * Valid options are:<ul>
  9080. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  9081. * be used for this request.
  9082. * <li>sessionToken: A valid session token, used for making a request on
  9083. * behalf of a specific user.
  9084. * <li>context: A dictionary that is accessible in Cloud Code `beforeDelete` and `afterDelete` triggers.
  9085. * </ul>
  9086. * @returns {Promise} A promise that is fulfilled when the destroy
  9087. * completes.
  9088. */
  9089. }, {
  9090. key: "destroy",
  9091. value: function (options /*: RequestOptions*/) /*: Promise*/{
  9092. options = options || {};
  9093. var destroyOptions = {};
  9094. if (options.hasOwnProperty('useMasterKey')) {
  9095. destroyOptions.useMasterKey = options.useMasterKey;
  9096. }
  9097. if (options.hasOwnProperty('sessionToken')) {
  9098. destroyOptions.sessionToken = options.sessionToken;
  9099. }
  9100. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  9101. destroyOptions.context = options.context;
  9102. }
  9103. if (!this.id) {
  9104. return _promise.default.resolve();
  9105. }
  9106. return _CoreManager.default.getObjectController().destroy(this, destroyOptions);
  9107. }
  9108. /**
  9109. * Asynchronously stores the object and every object it points to in the local datastore,
  9110. * recursively, using a default pin name: _default.
  9111. *
  9112. * If those other objects have not been fetched from Parse, they will not be stored.
  9113. * However, if they have changed data, all the changes will be retained.
  9114. *
  9115. * <pre>
  9116. * await object.pin();
  9117. * </pre>
  9118. *
  9119. * To retrieve object:
  9120. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  9121. *
  9122. * @returns {Promise} A promise that is fulfilled when the pin completes.
  9123. */
  9124. }, {
  9125. key: "pin",
  9126. value: function () /*: Promise<void>*/{
  9127. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  9128. }
  9129. /**
  9130. * Asynchronously removes the object and every object it points to in the local datastore,
  9131. * recursively, using a default pin name: _default.
  9132. *
  9133. * <pre>
  9134. * await object.unPin();
  9135. * </pre>
  9136. *
  9137. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9138. */
  9139. }, {
  9140. key: "unPin",
  9141. value: function () /*: Promise<void>*/{
  9142. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, [this]);
  9143. }
  9144. /**
  9145. * Asynchronously returns if the object is pinned
  9146. *
  9147. * <pre>
  9148. * const isPinned = await object.isPinned();
  9149. * </pre>
  9150. *
  9151. * @returns {Promise<boolean>} A boolean promise that is fulfilled if object is pinned.
  9152. */
  9153. }, {
  9154. key: "isPinned",
  9155. value: function () {
  9156. var _isPinned = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
  9157. var localDatastore, objectKey, pin;
  9158. return _regenerator.default.wrap(function (_context6) {
  9159. while (1) switch (_context6.prev = _context6.next) {
  9160. case 0:
  9161. localDatastore = _CoreManager.default.getLocalDatastore();
  9162. if (localDatastore.isEnabled) {
  9163. _context6.next = 3;
  9164. break;
  9165. }
  9166. return _context6.abrupt("return", _promise.default.reject('Parse.enableLocalDatastore() must be called first'));
  9167. case 3:
  9168. objectKey = localDatastore.getKeyForObject(this);
  9169. _context6.next = 6;
  9170. return localDatastore.fromPinWithName(objectKey);
  9171. case 6:
  9172. pin = _context6.sent;
  9173. return _context6.abrupt("return", pin.length > 0);
  9174. case 8:
  9175. case "end":
  9176. return _context6.stop();
  9177. }
  9178. }, _callee4, this);
  9179. }));
  9180. function isPinned() {
  9181. return _isPinned.apply(this, arguments);
  9182. }
  9183. return isPinned;
  9184. }()
  9185. /**
  9186. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  9187. *
  9188. * If those other objects have not been fetched from Parse, they will not be stored.
  9189. * However, if they have changed data, all the changes will be retained.
  9190. *
  9191. * <pre>
  9192. * await object.pinWithName(name);
  9193. * </pre>
  9194. *
  9195. * To retrieve object:
  9196. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  9197. *
  9198. * @param {string} name Name of Pin.
  9199. * @returns {Promise} A promise that is fulfilled when the pin completes.
  9200. */
  9201. }, {
  9202. key: "pinWithName",
  9203. value: function (name /*: string*/) /*: Promise<void>*/{
  9204. return ParseObject.pinAllWithName(name, [this]);
  9205. }
  9206. /**
  9207. * Asynchronously removes the object and every object it points to in the local datastore, recursively.
  9208. *
  9209. * <pre>
  9210. * await object.unPinWithName(name);
  9211. * </pre>
  9212. *
  9213. * @param {string} name Name of Pin.
  9214. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9215. */
  9216. }, {
  9217. key: "unPinWithName",
  9218. value: function (name /*: string*/) /*: Promise<void>*/{
  9219. return ParseObject.unPinAllWithName(name, [this]);
  9220. }
  9221. /**
  9222. * Asynchronously loads data from the local datastore into this object.
  9223. *
  9224. * <pre>
  9225. * await object.fetchFromLocalDatastore();
  9226. * </pre>
  9227. *
  9228. * You can create an unfetched pointer with <code>Parse.Object.createWithoutData()</code>
  9229. * and then call <code>fetchFromLocalDatastore()</code> on it.
  9230. *
  9231. * @returns {Promise} A promise that is fulfilled when the fetch completes.
  9232. */
  9233. }, {
  9234. key: "fetchFromLocalDatastore",
  9235. value: function () {
  9236. var _fetchFromLocalDatastore = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  9237. var localDatastore, objectKey, pinned, result;
  9238. return _regenerator.default.wrap(function (_context7) {
  9239. while (1) switch (_context7.prev = _context7.next) {
  9240. case 0:
  9241. localDatastore = _CoreManager.default.getLocalDatastore();
  9242. if (localDatastore.isEnabled) {
  9243. _context7.next = 3;
  9244. break;
  9245. }
  9246. throw new Error('Parse.enableLocalDatastore() must be called first');
  9247. case 3:
  9248. objectKey = localDatastore.getKeyForObject(this);
  9249. _context7.next = 6;
  9250. return localDatastore._serializeObject(objectKey);
  9251. case 6:
  9252. pinned = _context7.sent;
  9253. if (pinned) {
  9254. _context7.next = 9;
  9255. break;
  9256. }
  9257. throw new Error('Cannot fetch an unsaved ParseObject');
  9258. case 9:
  9259. result = ParseObject.fromJSON(pinned);
  9260. this._finishFetch(result.toJSON());
  9261. return _context7.abrupt("return", this);
  9262. case 12:
  9263. case "end":
  9264. return _context7.stop();
  9265. }
  9266. }, _callee5, this);
  9267. }));
  9268. function fetchFromLocalDatastore() {
  9269. return _fetchFromLocalDatastore.apply(this, arguments);
  9270. }
  9271. return fetchFromLocalDatastore;
  9272. }() /* Static methods */
  9273. }], [{
  9274. key: "_getClassMap",
  9275. value: function () {
  9276. return classMap;
  9277. }
  9278. }, {
  9279. key: "_clearAllState",
  9280. value: function () {
  9281. var stateController = _CoreManager.default.getObjectStateController();
  9282. stateController.clearAllState();
  9283. }
  9284. /**
  9285. * Fetches the given list of Parse.Object.
  9286. * If any error is encountered, stops and calls the error handler.
  9287. *
  9288. * <pre>
  9289. * Parse.Object.fetchAll([object1, object2, ...])
  9290. * .then((list) => {
  9291. * // All the objects were fetched.
  9292. * }, (error) => {
  9293. * // An error occurred while fetching one of the objects.
  9294. * });
  9295. * </pre>
  9296. *
  9297. * @param {Array} list A list of <code>Parse.Object</code>.
  9298. * @param {object} options
  9299. * Valid options are:<ul>
  9300. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  9301. * be used for this request.
  9302. * <li>sessionToken: A valid session token, used for making a request on
  9303. * behalf of a specific user.
  9304. * <li>include: The name(s) of the key(s) to include. Can be a string, an array of strings,
  9305. * or an array of array of strings.
  9306. * </ul>
  9307. * @static
  9308. * @returns {Parse.Object[]}
  9309. */
  9310. }, {
  9311. key: "fetchAll",
  9312. value: function (list /*: Array<ParseObject>*/) {
  9313. var options /*: RequestOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  9314. var queryOptions = {};
  9315. if (options.hasOwnProperty('useMasterKey')) {
  9316. queryOptions.useMasterKey = options.useMasterKey;
  9317. }
  9318. if (options.hasOwnProperty('sessionToken')) {
  9319. queryOptions.sessionToken = options.sessionToken;
  9320. }
  9321. if (options.hasOwnProperty('include')) {
  9322. queryOptions.include = ParseObject.handleIncludeOptions(options);
  9323. }
  9324. return _CoreManager.default.getObjectController().fetch(list, true, queryOptions);
  9325. }
  9326. /**
  9327. * Fetches the given list of Parse.Object.
  9328. *
  9329. * Includes nested Parse.Objects for the provided key. You can use dot
  9330. * notation to specify which fields in the included object are also fetched.
  9331. *
  9332. * If any error is encountered, stops and calls the error handler.
  9333. *
  9334. * <pre>
  9335. * Parse.Object.fetchAllWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  9336. * .then((list) => {
  9337. * // All the objects were fetched.
  9338. * }, (error) => {
  9339. * // An error occurred while fetching one of the objects.
  9340. * });
  9341. * </pre>
  9342. *
  9343. * @param {Array} list A list of <code>Parse.Object</code>.
  9344. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  9345. * @param {object} options
  9346. * Valid options are:<ul>
  9347. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  9348. * be used for this request.
  9349. * <li>sessionToken: A valid session token, used for making a request on
  9350. * behalf of a specific user.
  9351. * </ul>
  9352. * @static
  9353. * @returns {Parse.Object[]}
  9354. */
  9355. }, {
  9356. key: "fetchAllWithInclude",
  9357. value: function (list /*: Array<ParseObject>*/, keys /*: String | Array<string | Array<string>>*/, options /*: RequestOptions*/) {
  9358. options = options || {};
  9359. options.include = keys;
  9360. return ParseObject.fetchAll(list, options);
  9361. }
  9362. /**
  9363. * Fetches the given list of Parse.Object if needed.
  9364. * If any error is encountered, stops and calls the error handler.
  9365. *
  9366. * Includes nested Parse.Objects for the provided key. You can use dot
  9367. * notation to specify which fields in the included object are also fetched.
  9368. *
  9369. * If any error is encountered, stops and calls the error handler.
  9370. *
  9371. * <pre>
  9372. * Parse.Object.fetchAllIfNeededWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
  9373. * .then((list) => {
  9374. * // All the objects were fetched.
  9375. * }, (error) => {
  9376. * // An error occurred while fetching one of the objects.
  9377. * });
  9378. * </pre>
  9379. *
  9380. * @param {Array} list A list of <code>Parse.Object</code>.
  9381. * @param {string | Array<string | Array<string>>} keys The name(s) of the key(s) to include.
  9382. * @param {object} options
  9383. * Valid options are:<ul>
  9384. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  9385. * be used for this request.
  9386. * <li>sessionToken: A valid session token, used for making a request on
  9387. * behalf of a specific user.
  9388. * </ul>
  9389. * @static
  9390. * @returns {Parse.Object[]}
  9391. */
  9392. }, {
  9393. key: "fetchAllIfNeededWithInclude",
  9394. value: function (list /*: Array<ParseObject>*/, keys /*: String | Array<string | Array<string>>*/, options /*: RequestOptions*/) {
  9395. options = options || {};
  9396. options.include = keys;
  9397. return ParseObject.fetchAllIfNeeded(list, options);
  9398. }
  9399. /**
  9400. * Fetches the given list of Parse.Object if needed.
  9401. * If any error is encountered, stops and calls the error handler.
  9402. *
  9403. * <pre>
  9404. * Parse.Object.fetchAllIfNeeded([object1, ...])
  9405. * .then((list) => {
  9406. * // Objects were fetched and updated.
  9407. * }, (error) => {
  9408. * // An error occurred while fetching one of the objects.
  9409. * });
  9410. * </pre>
  9411. *
  9412. * @param {Array} list A list of <code>Parse.Object</code>.
  9413. * @param {object} options
  9414. * @static
  9415. * @returns {Parse.Object[]}
  9416. */
  9417. }, {
  9418. key: "fetchAllIfNeeded",
  9419. value: function (list /*: Array<ParseObject>*/, options) {
  9420. options = options || {};
  9421. var queryOptions = {};
  9422. if (options.hasOwnProperty('useMasterKey')) {
  9423. queryOptions.useMasterKey = options.useMasterKey;
  9424. }
  9425. if (options.hasOwnProperty('sessionToken')) {
  9426. queryOptions.sessionToken = options.sessionToken;
  9427. }
  9428. if (options.hasOwnProperty('include')) {
  9429. queryOptions.include = ParseObject.handleIncludeOptions(options);
  9430. }
  9431. return _CoreManager.default.getObjectController().fetch(list, false, queryOptions);
  9432. }
  9433. }, {
  9434. key: "handleIncludeOptions",
  9435. value: function (options) {
  9436. var include = [];
  9437. if ((0, _isArray.default)(options.include)) {
  9438. var _context8;
  9439. (0, _forEach.default)(_context8 = options.include).call(_context8, function (key) {
  9440. if ((0, _isArray.default)(key)) {
  9441. include = (0, _concat.default)(include).call(include, key);
  9442. } else {
  9443. include.push(key);
  9444. }
  9445. });
  9446. } else {
  9447. include.push(options.include);
  9448. }
  9449. return include;
  9450. }
  9451. /**
  9452. * Destroy the given list of models on the server if it was already persisted.
  9453. *
  9454. * <p>Unlike saveAll, if an error occurs while deleting an individual model,
  9455. * this method will continue trying to delete the rest of the models if
  9456. * possible, except in the case of a fatal error like a connection error.
  9457. *
  9458. * <p>In particular, the Parse.Error object returned in the case of error may
  9459. * be one of two types:
  9460. *
  9461. * <ul>
  9462. * <li>A Parse.Error.AGGREGATE_ERROR. This object's "errors" property is an
  9463. * array of other Parse.Error objects. Each error object in this array
  9464. * has an "object" property that references the object that could not be
  9465. * deleted (for instance, because that object could not be found).</li>
  9466. * <li>A non-aggregate Parse.Error. This indicates a serious error that
  9467. * caused the delete operation to be aborted partway through (for
  9468. * instance, a connection failure in the middle of the delete).</li>
  9469. * </ul>
  9470. *
  9471. * <pre>
  9472. * Parse.Object.destroyAll([object1, object2, ...])
  9473. * .then((list) => {
  9474. * // All the objects were deleted.
  9475. * }, (error) => {
  9476. * // An error occurred while deleting one or more of the objects.
  9477. * // If this is an aggregate error, then we can inspect each error
  9478. * // object individually to determine the reason why a particular
  9479. * // object was not deleted.
  9480. * if (error.code === Parse.Error.AGGREGATE_ERROR) {
  9481. * for (var i = 0; i < error.errors.length; i++) {
  9482. * console.log("Couldn't delete " + error.errors[i].object.id +
  9483. * "due to " + error.errors[i].message);
  9484. * }
  9485. * } else {
  9486. * console.log("Delete aborted because of " + error.message);
  9487. * }
  9488. * });
  9489. * </pre>
  9490. *
  9491. * @param {Array} list A list of <code>Parse.Object</code>.
  9492. * @param {object} options
  9493. * @static
  9494. * @returns {Promise} A promise that is fulfilled when the destroyAll
  9495. * completes.
  9496. */
  9497. }, {
  9498. key: "destroyAll",
  9499. value: function (list /*: Array<ParseObject>*/) {
  9500. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  9501. var destroyOptions = {};
  9502. if (options.hasOwnProperty('useMasterKey')) {
  9503. destroyOptions.useMasterKey = options.useMasterKey;
  9504. }
  9505. if (options.hasOwnProperty('sessionToken')) {
  9506. destroyOptions.sessionToken = options.sessionToken;
  9507. }
  9508. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  9509. destroyOptions.batchSize = options.batchSize;
  9510. }
  9511. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  9512. destroyOptions.context = options.context;
  9513. }
  9514. return _CoreManager.default.getObjectController().destroy(list, destroyOptions);
  9515. }
  9516. /**
  9517. * Saves the given list of Parse.Object.
  9518. * If any error is encountered, stops and calls the error handler.
  9519. *
  9520. * <pre>
  9521. * Parse.Object.saveAll([object1, object2, ...])
  9522. * .then((list) => {
  9523. * // All the objects were saved.
  9524. * }, (error) => {
  9525. * // An error occurred while saving one of the objects.
  9526. * });
  9527. * </pre>
  9528. *
  9529. * @param {Array} list A list of <code>Parse.Object</code>.
  9530. * @param {object} options
  9531. * @static
  9532. * @returns {Parse.Object[]}
  9533. */
  9534. }, {
  9535. key: "saveAll",
  9536. value: function (list /*: Array<ParseObject>*/) {
  9537. var options /*: RequestOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  9538. var saveOptions = {};
  9539. if (options.hasOwnProperty('useMasterKey')) {
  9540. saveOptions.useMasterKey = options.useMasterKey;
  9541. }
  9542. if (options.hasOwnProperty('sessionToken')) {
  9543. saveOptions.sessionToken = options.sessionToken;
  9544. }
  9545. if (options.hasOwnProperty('batchSize') && typeof options.batchSize === 'number') {
  9546. saveOptions.batchSize = options.batchSize;
  9547. }
  9548. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  9549. saveOptions.context = options.context;
  9550. }
  9551. return _CoreManager.default.getObjectController().save(list, saveOptions);
  9552. }
  9553. /**
  9554. * Creates a reference to a subclass of Parse.Object with the given id. This
  9555. * does not exist on Parse.Object, only on subclasses.
  9556. *
  9557. * <p>A shortcut for: <pre>
  9558. * var Foo = Parse.Object.extend("Foo");
  9559. * var pointerToFoo = new Foo();
  9560. * pointerToFoo.id = "myObjectId";
  9561. * </pre>
  9562. *
  9563. * @param {string} id The ID of the object to create a reference to.
  9564. * @static
  9565. * @returns {Parse.Object} A Parse.Object reference.
  9566. */
  9567. }, {
  9568. key: "createWithoutData",
  9569. value: function (id /*: string*/) {
  9570. var obj = new this();
  9571. obj.id = id;
  9572. return obj;
  9573. }
  9574. /**
  9575. * Creates a new instance of a Parse Object from a JSON representation.
  9576. *
  9577. * @param {object} json The JSON map of the Object's data
  9578. * @param {boolean} override In single instance mode, all old server data
  9579. * is overwritten if this is set to true
  9580. * @param {boolean} dirty Whether the Parse.Object should set JSON keys to dirty
  9581. * @static
  9582. * @returns {Parse.Object} A Parse.Object reference
  9583. */
  9584. }, {
  9585. key: "fromJSON",
  9586. value: function (json /*: any*/, override /*:: ?: boolean*/, dirty /*:: ?: boolean*/) {
  9587. if (!json.className) {
  9588. throw new Error('Cannot create an object without a className');
  9589. }
  9590. var constructor = classMap[json.className];
  9591. var o = constructor ? new constructor(json.className) : new ParseObject(json.className);
  9592. var otherAttributes = {};
  9593. for (var _attr12 in json) {
  9594. if (_attr12 !== 'className' && _attr12 !== '__type') {
  9595. otherAttributes[_attr12] = json[_attr12];
  9596. if (dirty) {
  9597. o.set(_attr12, json[_attr12]);
  9598. }
  9599. }
  9600. }
  9601. if (override) {
  9602. // id needs to be set before clearServerData can work
  9603. if (otherAttributes.objectId) {
  9604. o.id = otherAttributes.objectId;
  9605. }
  9606. var preserved = null;
  9607. if (typeof o._preserveFieldsOnFetch === 'function') {
  9608. preserved = o._preserveFieldsOnFetch();
  9609. }
  9610. o._clearServerData();
  9611. if (preserved) {
  9612. o._finishFetch(preserved);
  9613. }
  9614. }
  9615. o._finishFetch(otherAttributes);
  9616. if (json.objectId) {
  9617. o._setExisted(true);
  9618. }
  9619. return o;
  9620. }
  9621. /**
  9622. * Registers a subclass of Parse.Object with a specific class name.
  9623. * When objects of that class are retrieved from a query, they will be
  9624. * instantiated with this subclass.
  9625. * This is only necessary when using ES6 subclassing.
  9626. *
  9627. * @param {string} className The class name of the subclass
  9628. * @param {Function} constructor The subclass
  9629. */
  9630. }, {
  9631. key: "registerSubclass",
  9632. value: function (className /*: string*/, constructor /*: any*/) {
  9633. if (typeof className !== 'string') {
  9634. throw new TypeError('The first argument must be a valid class name.');
  9635. }
  9636. if (typeof constructor === 'undefined') {
  9637. throw new TypeError('You must supply a subclass constructor.');
  9638. }
  9639. if (typeof constructor !== 'function') {
  9640. throw new TypeError('You must register the subclass constructor. ' + 'Did you attempt to register an instance of the subclass?');
  9641. }
  9642. classMap[className] = constructor;
  9643. if (!constructor.className) {
  9644. constructor.className = className;
  9645. }
  9646. }
  9647. /**
  9648. * Unegisters a subclass of Parse.Object with a specific class name.
  9649. *
  9650. * @param {string} className The class name of the subclass
  9651. */
  9652. }, {
  9653. key: "unregisterSubclass",
  9654. value: function (className /*: string*/) {
  9655. if (typeof className !== 'string') {
  9656. throw new TypeError('The first argument must be a valid class name.');
  9657. }
  9658. delete classMap[className];
  9659. }
  9660. /**
  9661. * Creates a new subclass of Parse.Object for the given Parse class name.
  9662. *
  9663. * <p>Every extension of a Parse class will inherit from the most recent
  9664. * previous extension of that class. When a Parse.Object is automatically
  9665. * created by parsing JSON, it will use the most recent extension of that
  9666. * class.</p>
  9667. *
  9668. * <p>You should call either:<pre>
  9669. * var MyClass = Parse.Object.extend("MyClass", {
  9670. * <i>Instance methods</i>,
  9671. * initialize: function(attrs, options) {
  9672. * this.someInstanceProperty = [],
  9673. * <i>Other instance properties</i>
  9674. * }
  9675. * }, {
  9676. * <i>Class properties</i>
  9677. * });</pre>
  9678. * or, for Backbone compatibility:<pre>
  9679. * var MyClass = Parse.Object.extend({
  9680. * className: "MyClass",
  9681. * <i>Instance methods</i>,
  9682. * initialize: function(attrs, options) {
  9683. * this.someInstanceProperty = [],
  9684. * <i>Other instance properties</i>
  9685. * }
  9686. * }, {
  9687. * <i>Class properties</i>
  9688. * });</pre></p>
  9689. *
  9690. * @param {string} className The name of the Parse class backing this model.
  9691. * @param {object} protoProps Instance properties to add to instances of the
  9692. * class returned from this method.
  9693. * @param {object} classProps Class properties to add the class returned from
  9694. * this method.
  9695. * @returns {Parse.Object} A new subclass of Parse.Object.
  9696. */
  9697. }, {
  9698. key: "extend",
  9699. value: function (className /*: any*/, protoProps /*: any*/, classProps /*: any*/) {
  9700. if (typeof className !== 'string') {
  9701. if (className && typeof className.className === 'string') {
  9702. return ParseObject.extend(className.className, className, protoProps);
  9703. } else {
  9704. throw new Error("Parse.Object.extend's first argument should be the className.");
  9705. }
  9706. }
  9707. var adjustedClassName = className;
  9708. if (adjustedClassName === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  9709. adjustedClassName = '_User';
  9710. }
  9711. var parentProto = ParseObject.prototype;
  9712. if (this.hasOwnProperty('__super__') && this.__super__) {
  9713. parentProto = this.prototype;
  9714. }
  9715. var ParseObjectSubclass = function (attributes, options) {
  9716. this.className = adjustedClassName;
  9717. this._objCount = objectCount++;
  9718. // Enable legacy initializers
  9719. if (typeof this.initialize === 'function') {
  9720. this.initialize.apply(this, arguments);
  9721. }
  9722. if (this._initializers) {
  9723. var _iterator2 = _createForOfIteratorHelper(this._initializers),
  9724. _step2;
  9725. try {
  9726. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  9727. var initializer = _step2.value;
  9728. initializer.apply(this, arguments);
  9729. }
  9730. } catch (err) {
  9731. _iterator2.e(err);
  9732. } finally {
  9733. _iterator2.f();
  9734. }
  9735. }
  9736. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  9737. if (!this.set(attributes || {}, options)) {
  9738. throw new Error("Can't create an invalid Parse Object");
  9739. }
  9740. }
  9741. };
  9742. if (classMap[adjustedClassName]) {
  9743. ParseObjectSubclass = classMap[adjustedClassName];
  9744. } else {
  9745. ParseObjectSubclass.extend = function (name, protoProps, classProps) {
  9746. if (typeof name === 'string') {
  9747. return ParseObject.extend.call(ParseObjectSubclass, name, protoProps, classProps);
  9748. }
  9749. return ParseObject.extend.call(ParseObjectSubclass, adjustedClassName, name, protoProps);
  9750. };
  9751. ParseObjectSubclass.createWithoutData = ParseObject.createWithoutData;
  9752. ParseObjectSubclass.className = adjustedClassName;
  9753. ParseObjectSubclass.__super__ = parentProto;
  9754. ParseObjectSubclass.prototype = (0, _create.default)(parentProto, {
  9755. constructor: {
  9756. value: ParseObjectSubclass,
  9757. enumerable: false,
  9758. writable: true,
  9759. configurable: true
  9760. }
  9761. });
  9762. }
  9763. if (protoProps) {
  9764. for (var prop in protoProps) {
  9765. if (prop === 'initialize') {
  9766. var _context9;
  9767. (0, _defineProperty3.default)(ParseObjectSubclass.prototype, '_initializers', {
  9768. value: (0, _concat.default)(_context9 = []).call(_context9, (0, _toConsumableArray2.default)(ParseObjectSubclass.prototype._initializers || []), [protoProps[prop]]),
  9769. enumerable: false,
  9770. writable: true,
  9771. configurable: true
  9772. });
  9773. continue;
  9774. }
  9775. if (prop !== 'className') {
  9776. (0, _defineProperty3.default)(ParseObjectSubclass.prototype, prop, {
  9777. value: protoProps[prop],
  9778. enumerable: false,
  9779. writable: true,
  9780. configurable: true
  9781. });
  9782. }
  9783. }
  9784. }
  9785. if (classProps) {
  9786. for (var _prop in classProps) {
  9787. if (_prop !== 'className') {
  9788. (0, _defineProperty3.default)(ParseObjectSubclass, _prop, {
  9789. value: classProps[_prop],
  9790. enumerable: false,
  9791. writable: true,
  9792. configurable: true
  9793. });
  9794. }
  9795. }
  9796. }
  9797. classMap[adjustedClassName] = ParseObjectSubclass;
  9798. return ParseObjectSubclass;
  9799. }
  9800. /**
  9801. * Enable single instance objects, where any local objects with the same Id
  9802. * share the same attributes, and stay synchronized with each other.
  9803. * This is disabled by default in server environments, since it can lead to
  9804. * security issues.
  9805. *
  9806. * @static
  9807. */
  9808. }, {
  9809. key: "enableSingleInstance",
  9810. value: function () {
  9811. singleInstance = true;
  9812. _CoreManager.default.setObjectStateController(SingleInstanceStateController);
  9813. }
  9814. /**
  9815. * Disable single instance objects, where any local objects with the same Id
  9816. * share the same attributes, and stay synchronized with each other.
  9817. * When disabled, you can have two instances of the same object in memory
  9818. * without them sharing attributes.
  9819. *
  9820. * @static
  9821. */
  9822. }, {
  9823. key: "disableSingleInstance",
  9824. value: function () {
  9825. singleInstance = false;
  9826. _CoreManager.default.setObjectStateController(UniqueInstanceStateController);
  9827. }
  9828. /**
  9829. * Asynchronously stores the objects and every object they point to in the local datastore,
  9830. * recursively, using a default pin name: _default.
  9831. *
  9832. * If those other objects have not been fetched from Parse, they will not be stored.
  9833. * However, if they have changed data, all the changes will be retained.
  9834. *
  9835. * <pre>
  9836. * await Parse.Object.pinAll([...]);
  9837. * </pre>
  9838. *
  9839. * To retrieve object:
  9840. * <code>query.fromLocalDatastore()</code> or <code>query.fromPin()</code>
  9841. *
  9842. * @param {Array} objects A list of <code>Parse.Object</code>.
  9843. * @returns {Promise} A promise that is fulfilled when the pin completes.
  9844. * @static
  9845. */
  9846. }, {
  9847. key: "pinAll",
  9848. value: function (objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
  9849. var localDatastore = _CoreManager.default.getLocalDatastore();
  9850. if (!localDatastore.isEnabled) {
  9851. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  9852. }
  9853. return ParseObject.pinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  9854. }
  9855. /**
  9856. * Asynchronously stores the objects and every object they point to in the local datastore, recursively.
  9857. *
  9858. * If those other objects have not been fetched from Parse, they will not be stored.
  9859. * However, if they have changed data, all the changes will be retained.
  9860. *
  9861. * <pre>
  9862. * await Parse.Object.pinAllWithName(name, [obj1, obj2, ...]);
  9863. * </pre>
  9864. *
  9865. * To retrieve object:
  9866. * <code>query.fromLocalDatastore()</code> or <code>query.fromPinWithName(name)</code>
  9867. *
  9868. * @param {string} name Name of Pin.
  9869. * @param {Array} objects A list of <code>Parse.Object</code>.
  9870. * @returns {Promise} A promise that is fulfilled when the pin completes.
  9871. * @static
  9872. */
  9873. }, {
  9874. key: "pinAllWithName",
  9875. value: function (name /*: string*/, objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
  9876. var localDatastore = _CoreManager.default.getLocalDatastore();
  9877. if (!localDatastore.isEnabled) {
  9878. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  9879. }
  9880. return localDatastore._handlePinAllWithName(name, objects);
  9881. }
  9882. /**
  9883. * Asynchronously removes the objects and every object they point to in the local datastore,
  9884. * recursively, using a default pin name: _default.
  9885. *
  9886. * <pre>
  9887. * await Parse.Object.unPinAll([...]);
  9888. * </pre>
  9889. *
  9890. * @param {Array} objects A list of <code>Parse.Object</code>.
  9891. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9892. * @static
  9893. */
  9894. }, {
  9895. key: "unPinAll",
  9896. value: function (objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
  9897. var localDatastore = _CoreManager.default.getLocalDatastore();
  9898. if (!localDatastore.isEnabled) {
  9899. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  9900. }
  9901. return ParseObject.unPinAllWithName(_LocalDatastoreUtils.DEFAULT_PIN, objects);
  9902. }
  9903. /**
  9904. * Asynchronously removes the objects and every object they point to in the local datastore, recursively.
  9905. *
  9906. * <pre>
  9907. * await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
  9908. * </pre>
  9909. *
  9910. * @param {string} name Name of Pin.
  9911. * @param {Array} objects A list of <code>Parse.Object</code>.
  9912. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9913. * @static
  9914. */
  9915. }, {
  9916. key: "unPinAllWithName",
  9917. value: function (name /*: string*/, objects /*: Array<ParseObject>*/) /*: Promise<void>*/{
  9918. var localDatastore = _CoreManager.default.getLocalDatastore();
  9919. if (!localDatastore.isEnabled) {
  9920. return _promise.default.reject('Parse.enableLocalDatastore() must be called first');
  9921. }
  9922. return localDatastore._handleUnPinAllWithName(name, objects);
  9923. }
  9924. /**
  9925. * Asynchronously removes all objects in the local datastore using a default pin name: _default.
  9926. *
  9927. * <pre>
  9928. * await Parse.Object.unPinAllObjects();
  9929. * </pre>
  9930. *
  9931. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9932. * @static
  9933. */
  9934. }, {
  9935. key: "unPinAllObjects",
  9936. value: function () /*: 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 localDatastore.unPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  9942. }
  9943. /**
  9944. * Asynchronously removes all objects with the specified pin name.
  9945. * Deletes the pin name also.
  9946. *
  9947. * <pre>
  9948. * await Parse.Object.unPinAllObjectsWithName(name);
  9949. * </pre>
  9950. *
  9951. * @param {string} name Name of Pin.
  9952. * @returns {Promise} A promise that is fulfilled when the unPin completes.
  9953. * @static
  9954. */
  9955. }, {
  9956. key: "unPinAllObjectsWithName",
  9957. value: function (name /*: string*/) /*: 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.unPinWithName(_LocalDatastoreUtils.PIN_PREFIX + name);
  9963. }
  9964. }]);
  9965. return ParseObject;
  9966. }();
  9967. var DefaultController = {
  9968. fetch: function (target /*: ParseObject | Array<ParseObject>*/, forceFetch /*: boolean*/, options /*: RequestOptions*/) /*: Promise<Array<void> | ParseObject>*/{
  9969. var localDatastore = _CoreManager.default.getLocalDatastore();
  9970. if ((0, _isArray.default)(target)) {
  9971. if (target.length < 1) {
  9972. return _promise.default.resolve([]);
  9973. }
  9974. var objs = [];
  9975. var ids = [];
  9976. var className = null;
  9977. var results = [];
  9978. var error = null;
  9979. (0, _forEach.default)(target).call(target, function (el) {
  9980. if (error) {
  9981. return;
  9982. }
  9983. if (!className) {
  9984. className = el.className;
  9985. }
  9986. if (className !== el.className) {
  9987. error = new _ParseError.default(_ParseError.default.INVALID_CLASS_NAME, 'All objects should be of the same class');
  9988. }
  9989. if (!el.id) {
  9990. error = new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'All objects must have an ID');
  9991. }
  9992. if (forceFetch || !el.isDataAvailable()) {
  9993. ids.push(el.id);
  9994. objs.push(el);
  9995. }
  9996. results.push(el);
  9997. });
  9998. if (error) {
  9999. return _promise.default.reject(error);
  10000. }
  10001. var query = new _ParseQuery.default(className);
  10002. query.containedIn('objectId', ids);
  10003. if (options && options.include) {
  10004. query.include(options.include);
  10005. }
  10006. query._limit = ids.length;
  10007. return (0, _find.default)(query).call(query, options).then( /*#__PURE__*/function () {
  10008. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(objects) {
  10009. var idMap, i, obj, _i, _obj, id, _i2, _results, object;
  10010. return _regenerator.default.wrap(function (_context10) {
  10011. while (1) switch (_context10.prev = _context10.next) {
  10012. case 0:
  10013. idMap = {};
  10014. (0, _forEach.default)(objects).call(objects, function (o) {
  10015. idMap[o.id] = o;
  10016. });
  10017. i = 0;
  10018. case 3:
  10019. if (!(i < objs.length)) {
  10020. _context10.next = 11;
  10021. break;
  10022. }
  10023. obj = objs[i];
  10024. if (!(!obj || !obj.id || !idMap[obj.id])) {
  10025. _context10.next = 8;
  10026. break;
  10027. }
  10028. if (!forceFetch) {
  10029. _context10.next = 8;
  10030. break;
  10031. }
  10032. return _context10.abrupt("return", _promise.default.reject(new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'All objects must exist on the server.')));
  10033. case 8:
  10034. i++;
  10035. _context10.next = 3;
  10036. break;
  10037. case 11:
  10038. if (!singleInstance) {
  10039. // If single instance objects are disabled, we need to replace the
  10040. for (_i = 0; _i < results.length; _i++) {
  10041. _obj = results[_i];
  10042. if (_obj && _obj.id && idMap[_obj.id]) {
  10043. id = _obj.id;
  10044. _obj._finishFetch(idMap[id].toJSON());
  10045. results[_i] = idMap[id];
  10046. }
  10047. }
  10048. }
  10049. _i2 = 0, _results = results;
  10050. case 13:
  10051. if (!(_i2 < _results.length)) {
  10052. _context10.next = 20;
  10053. break;
  10054. }
  10055. object = _results[_i2];
  10056. _context10.next = 17;
  10057. return localDatastore._updateObjectIfPinned(object);
  10058. case 17:
  10059. _i2++;
  10060. _context10.next = 13;
  10061. break;
  10062. case 20:
  10063. return _context10.abrupt("return", _promise.default.resolve(results));
  10064. case 21:
  10065. case "end":
  10066. return _context10.stop();
  10067. }
  10068. }, _callee6);
  10069. }));
  10070. return function () {
  10071. return _ref.apply(this, arguments);
  10072. };
  10073. }());
  10074. } else if (target instanceof ParseObject) {
  10075. if (!target.id) {
  10076. return _promise.default.reject(new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'Object does not have an ID'));
  10077. }
  10078. var RESTController = _CoreManager.default.getRESTController();
  10079. var params = {};
  10080. if (options && options.include) {
  10081. params.include = options.include.join();
  10082. }
  10083. return RESTController.request('GET', 'classes/' + target.className + '/' + target._getId(), params, options).then( /*#__PURE__*/function () {
  10084. var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(response) {
  10085. return _regenerator.default.wrap(function (_context11) {
  10086. while (1) switch (_context11.prev = _context11.next) {
  10087. case 0:
  10088. target._clearPendingOps();
  10089. target._clearServerData();
  10090. target._finishFetch(response);
  10091. _context11.next = 5;
  10092. return localDatastore._updateObjectIfPinned(target);
  10093. case 5:
  10094. return _context11.abrupt("return", target);
  10095. case 6:
  10096. case "end":
  10097. return _context11.stop();
  10098. }
  10099. }, _callee7);
  10100. }));
  10101. return function () {
  10102. return _ref2.apply(this, arguments);
  10103. };
  10104. }());
  10105. }
  10106. return _promise.default.resolve();
  10107. },
  10108. destroy: function (target /*: ParseObject | Array<ParseObject>*/, options /*: RequestOptions*/) /*: Promise<Array<void> | ParseObject>*/{
  10109. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
  10110. var batchSize, localDatastore, RESTController, batches, deleteCompleted, errors;
  10111. return _regenerator.default.wrap(function (_context14) {
  10112. while (1) switch (_context14.prev = _context14.next) {
  10113. case 0:
  10114. batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  10115. localDatastore = _CoreManager.default.getLocalDatastore();
  10116. RESTController = _CoreManager.default.getRESTController();
  10117. if (!(0, _isArray.default)(target)) {
  10118. _context14.next = 15;
  10119. break;
  10120. }
  10121. if (!(target.length < 1)) {
  10122. _context14.next = 6;
  10123. break;
  10124. }
  10125. return _context14.abrupt("return", _promise.default.resolve([]));
  10126. case 6:
  10127. batches = [[]];
  10128. (0, _forEach.default)(target).call(target, function (obj) {
  10129. if (!obj.id) {
  10130. return;
  10131. }
  10132. batches[batches.length - 1].push(obj);
  10133. if (batches[batches.length - 1].length >= batchSize) {
  10134. batches.push([]);
  10135. }
  10136. });
  10137. if (batches[batches.length - 1].length === 0) {
  10138. // If the last batch is empty, remove it
  10139. batches.pop();
  10140. }
  10141. deleteCompleted = _promise.default.resolve();
  10142. errors = [];
  10143. (0, _forEach.default)(batches).call(batches, function (batch) {
  10144. deleteCompleted = deleteCompleted.then(function () {
  10145. return RESTController.request('POST', 'batch', {
  10146. requests: (0, _map.default)(batch).call(batch, function (obj) {
  10147. return {
  10148. method: 'DELETE',
  10149. path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
  10150. body: {}
  10151. };
  10152. })
  10153. }, options).then(function (results) {
  10154. for (var i = 0; i < results.length; i++) {
  10155. if (results[i] && results[i].hasOwnProperty('error')) {
  10156. var err = new _ParseError.default(results[i].error.code, results[i].error.error);
  10157. err.object = batch[i];
  10158. errors.push(err);
  10159. }
  10160. }
  10161. });
  10162. });
  10163. });
  10164. return _context14.abrupt("return", deleteCompleted.then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
  10165. var aggregate, _iterator3, _step3, object;
  10166. return _regenerator.default.wrap(function (_context12) {
  10167. while (1) switch (_context12.prev = _context12.next) {
  10168. case 0:
  10169. if (!errors.length) {
  10170. _context12.next = 4;
  10171. break;
  10172. }
  10173. aggregate = new _ParseError.default(_ParseError.default.AGGREGATE_ERROR);
  10174. aggregate.errors = errors;
  10175. return _context12.abrupt("return", _promise.default.reject(aggregate));
  10176. case 4:
  10177. _iterator3 = _createForOfIteratorHelper(target);
  10178. _context12.prev = 5;
  10179. _iterator3.s();
  10180. case 7:
  10181. if ((_step3 = _iterator3.n()).done) {
  10182. _context12.next = 13;
  10183. break;
  10184. }
  10185. object = _step3.value;
  10186. _context12.next = 11;
  10187. return localDatastore._destroyObjectIfPinned(object);
  10188. case 11:
  10189. _context12.next = 7;
  10190. break;
  10191. case 13:
  10192. _context12.next = 18;
  10193. break;
  10194. case 15:
  10195. _context12.prev = 15;
  10196. _context12.t0 = _context12["catch"](5);
  10197. _iterator3.e(_context12.t0);
  10198. case 18:
  10199. _context12.prev = 18;
  10200. _iterator3.f();
  10201. return _context12.finish(18);
  10202. case 21:
  10203. return _context12.abrupt("return", _promise.default.resolve(target));
  10204. case 22:
  10205. case "end":
  10206. return _context12.stop();
  10207. }
  10208. }, _callee8, null, [[5, 15, 18, 21]]);
  10209. }))));
  10210. case 15:
  10211. if (!(target instanceof ParseObject)) {
  10212. _context14.next = 17;
  10213. break;
  10214. }
  10215. return _context14.abrupt("return", RESTController.request('DELETE', 'classes/' + target.className + '/' + target._getId(), {}, options).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
  10216. return _regenerator.default.wrap(function (_context13) {
  10217. while (1) switch (_context13.prev = _context13.next) {
  10218. case 0:
  10219. _context13.next = 2;
  10220. return localDatastore._destroyObjectIfPinned(target);
  10221. case 2:
  10222. return _context13.abrupt("return", _promise.default.resolve(target));
  10223. case 3:
  10224. case "end":
  10225. return _context13.stop();
  10226. }
  10227. }, _callee9);
  10228. }))));
  10229. case 17:
  10230. return _context14.abrupt("return", _promise.default.resolve(target));
  10231. case 18:
  10232. case "end":
  10233. return _context14.stop();
  10234. }
  10235. }, _callee10);
  10236. }))();
  10237. },
  10238. save: function (target /*: ParseObject | Array<ParseObject | ParseFile>*/, options /*: RequestOptions*/) {
  10239. var batchSize = options && options.batchSize ? options.batchSize : _CoreManager.default.get('REQUEST_BATCH_SIZE');
  10240. var localDatastore = _CoreManager.default.getLocalDatastore();
  10241. var mapIdForPin = {};
  10242. var RESTController = _CoreManager.default.getRESTController();
  10243. var stateController = _CoreManager.default.getObjectStateController();
  10244. var allowCustomObjectId = _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
  10245. options = options || {};
  10246. options.returnStatus = options.returnStatus || true;
  10247. if ((0, _isArray.default)(target)) {
  10248. if (target.length < 1) {
  10249. return _promise.default.resolve([]);
  10250. }
  10251. var unsaved = (0, _concat.default)(target).call(target);
  10252. for (var i = 0; i < target.length; i++) {
  10253. if (target[i] instanceof ParseObject) {
  10254. unsaved = (0, _concat.default)(unsaved).call(unsaved, (0, _unsavedChildren.default)(target[i], true));
  10255. }
  10256. }
  10257. unsaved = (0, _unique.default)(unsaved);
  10258. var filesSaved /*: Array<ParseFile>*/ = [];
  10259. var pending /*: Array<ParseObject>*/ = [];
  10260. (0, _forEach.default)(unsaved).call(unsaved, function (el) {
  10261. if (el instanceof _ParseFile.default) {
  10262. filesSaved.push(el.save(options));
  10263. } else if (el instanceof ParseObject) {
  10264. pending.push(el);
  10265. }
  10266. });
  10267. return _promise.default.all(filesSaved).then(function () {
  10268. var objectError = null;
  10269. return (0, _promiseUtils.continueWhile)(function () {
  10270. return pending.length > 0;
  10271. }, function () {
  10272. var batch = [];
  10273. var nextPending = [];
  10274. (0, _forEach.default)(pending).call(pending, function (el) {
  10275. if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(el, 'id') && !el.id) {
  10276. throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
  10277. }
  10278. if (batch.length < batchSize && (0, _canBeSerialized.default)(el)) {
  10279. batch.push(el);
  10280. } else {
  10281. nextPending.push(el);
  10282. }
  10283. });
  10284. pending = nextPending;
  10285. if (batch.length < 1) {
  10286. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Tried to save a batch with a cycle.'));
  10287. }
  10288. // Queue up tasks for each object in the batch.
  10289. // When every task is ready, the API request will execute
  10290. var batchReturned = new _promiseUtils.resolvingPromise();
  10291. var batchReady = [];
  10292. var batchTasks = [];
  10293. (0, _forEach.default)(batch).call(batch, function (obj, index) {
  10294. var ready = new _promiseUtils.resolvingPromise();
  10295. batchReady.push(ready);
  10296. var task = function task() {
  10297. ready.resolve();
  10298. return batchReturned.then(function (responses) {
  10299. if (responses[index].hasOwnProperty('success')) {
  10300. var objectId = responses[index].success.objectId;
  10301. var status = responses[index]._status;
  10302. delete responses[index]._status;
  10303. mapIdForPin[objectId] = obj._localId;
  10304. obj._handleSaveResponse(responses[index].success, status);
  10305. } else {
  10306. if (!objectError && responses[index].hasOwnProperty('error')) {
  10307. var serverError = responses[index].error;
  10308. objectError = new _ParseError.default(serverError.code, serverError.error);
  10309. // Cancel the rest of the save
  10310. pending = [];
  10311. }
  10312. obj._handleSaveError();
  10313. }
  10314. });
  10315. };
  10316. stateController.pushPendingState(obj._getStateIdentifier());
  10317. batchTasks.push(stateController.enqueueTask(obj._getStateIdentifier(), task));
  10318. });
  10319. (0, _promiseUtils.when)(batchReady).then(function () {
  10320. // Kick off the batch request
  10321. return RESTController.request('POST', 'batch', {
  10322. requests: (0, _map.default)(batch).call(batch, function (obj) {
  10323. var params = obj._getSaveParams();
  10324. params.path = getServerUrlPath() + params.path;
  10325. return params;
  10326. })
  10327. }, options);
  10328. }).then(batchReturned.resolve, function (error) {
  10329. batchReturned.reject(new _ParseError.default(_ParseError.default.INCORRECT_TYPE, error.message));
  10330. });
  10331. return (0, _promiseUtils.when)(batchTasks);
  10332. }).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
  10333. var _iterator4, _step4, object;
  10334. return _regenerator.default.wrap(function _callee11$(_context15) {
  10335. while (1) switch (_context15.prev = _context15.next) {
  10336. case 0:
  10337. if (!objectError) {
  10338. _context15.next = 2;
  10339. break;
  10340. }
  10341. return _context15.abrupt("return", _promise.default.reject(objectError));
  10342. case 2:
  10343. _iterator4 = _createForOfIteratorHelper(target);
  10344. _context15.prev = 3;
  10345. _iterator4.s();
  10346. case 5:
  10347. if ((_step4 = _iterator4.n()).done) {
  10348. _context15.next = 14;
  10349. break;
  10350. }
  10351. object = _step4.value;
  10352. if (!(object instanceof ParseObject)) {
  10353. _context15.next = 12;
  10354. break;
  10355. }
  10356. _context15.next = 10;
  10357. return localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object);
  10358. case 10:
  10359. _context15.next = 12;
  10360. return localDatastore._updateObjectIfPinned(object);
  10361. case 12:
  10362. _context15.next = 5;
  10363. break;
  10364. case 14:
  10365. _context15.next = 19;
  10366. break;
  10367. case 16:
  10368. _context15.prev = 16;
  10369. _context15.t0 = _context15["catch"](3);
  10370. _iterator4.e(_context15.t0);
  10371. case 19:
  10372. _context15.prev = 19;
  10373. _iterator4.f();
  10374. return _context15.finish(19);
  10375. case 22:
  10376. return _context15.abrupt("return", _promise.default.resolve(target));
  10377. case 23:
  10378. case "end":
  10379. return _context15.stop();
  10380. }
  10381. }, _callee11, null, [[3, 16, 19, 22]]);
  10382. })));
  10383. });
  10384. } else if (target instanceof ParseObject) {
  10385. if (allowCustomObjectId && Object.prototype.hasOwnProperty.call(target, 'id') && !target.id) {
  10386. throw new _ParseError.default(_ParseError.default.MISSING_OBJECT_ID, 'objectId must not be empty or null');
  10387. }
  10388. // generate _localId in case if cascadeSave=false
  10389. target._getId();
  10390. var localId = target._localId;
  10391. // copying target lets Flow guarantee the pointer isn't modified elsewhere
  10392. var targetCopy = target;
  10393. var task = function task() {
  10394. var params = targetCopy._getSaveParams();
  10395. return RESTController.request(params.method, params.path, params.body, options).then(function (response) {
  10396. var status = response._status;
  10397. delete response._status;
  10398. targetCopy._handleSaveResponse(response, status);
  10399. }, function (error) {
  10400. targetCopy._handleSaveError();
  10401. return _promise.default.reject(error);
  10402. });
  10403. };
  10404. stateController.pushPendingState(target._getStateIdentifier());
  10405. return stateController.enqueueTask(target._getStateIdentifier(), task).then( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
  10406. return _regenerator.default.wrap(function _callee12$(_context16) {
  10407. while (1) switch (_context16.prev = _context16.next) {
  10408. case 0:
  10409. _context16.next = 2;
  10410. return localDatastore._updateLocalIdForObject(localId, target);
  10411. case 2:
  10412. _context16.next = 4;
  10413. return localDatastore._updateObjectIfPinned(target);
  10414. case 4:
  10415. return _context16.abrupt("return", target);
  10416. case 5:
  10417. case "end":
  10418. return _context16.stop();
  10419. }
  10420. }, _callee12);
  10421. })), function (error) {
  10422. return _promise.default.reject(error);
  10423. });
  10424. }
  10425. return _promise.default.resolve();
  10426. }
  10427. };
  10428. _CoreManager.default.setObjectController(DefaultController);
  10429. var _default = ParseObject;
  10430. exports.default = _default;
  10431. },{"./CoreManager":4,"./EventuallyQueue":7,"./LocalDatastoreUtils":14,"./ParseACL":18,"./ParseError":21,"./ParseFile":22,"./ParseOp":27,"./ParseQuery":29,"./ParseRelation":30,"./SingleInstanceStateController":37,"./UniqueInstanceStateController":42,"./canBeSerialized":45,"./decode":46,"./encode":47,"./escape":49,"./parseDate":51,"./promiseUtils":52,"./unique":53,"./unsavedChildren":54,"./uuid":55,"@babel/runtime-corejs3/core-js-stable/array/from":56,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/concat":59,"@babel/runtime-corejs3/core-js-stable/instance/filter":62,"@babel/runtime-corejs3/core-js-stable/instance/find":64,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/instance/includes":66,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/instance/map":69,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/create":80,"@babel/runtime-corejs3/core-js-stable/object/define-properties":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/freeze":84,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":86,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":87,"@babel/runtime-corejs3/core-js-stable/object/get-prototype-of":88,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/core-js-stable/symbol":96,"@babel/runtime-corejs3/core-js-stable/weak-map":97,"@babel/runtime-corejs3/core-js/get-iterator-method":100,"@babel/runtime-corejs3/helpers/asyncToGenerator":122,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/toConsumableArray":142,"@babel/runtime-corejs3/helpers/typeof":145,"@babel/runtime-corejs3/regenerator":148}],27:[function(_dereq_,module,exports){
  10432. "use strict";
  10433. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  10434. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  10435. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  10436. _Object$defineProperty(exports, "__esModule", {
  10437. value: true
  10438. });
  10439. exports.UnsetOp = exports.SetOp = exports.RemoveOp = exports.RelationOp = exports.Op = exports.IncrementOp = exports.AddUniqueOp = exports.AddOp = void 0;
  10440. exports.opFromJSON = opFromJSON;
  10441. var _assertThisInitialized2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/assertThisInitialized"));
  10442. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  10443. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  10444. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  10445. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  10446. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  10447. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  10448. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  10449. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  10450. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  10451. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  10452. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  10453. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  10454. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  10455. var _decode = _interopRequireDefault(_dereq_("./decode"));
  10456. var _encode = _interopRequireDefault(_dereq_("./encode"));
  10457. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  10458. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  10459. var _unique = _interopRequireDefault(_dereq_("./unique"));
  10460. function _createSuper(Derived) {
  10461. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  10462. return function () {
  10463. var Super = (0, _getPrototypeOf2.default)(Derived),
  10464. result;
  10465. if (hasNativeReflectConstruct) {
  10466. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  10467. result = _Reflect$construct(Super, arguments, NewTarget);
  10468. } else {
  10469. result = Super.apply(this, arguments);
  10470. }
  10471. return (0, _possibleConstructorReturn2.default)(this, result);
  10472. };
  10473. }
  10474. function _isNativeReflectConstruct() {
  10475. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  10476. if (_Reflect$construct.sham) return false;
  10477. if (typeof Proxy === "function") return true;
  10478. try {
  10479. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  10480. return true;
  10481. } catch (e) {
  10482. return false;
  10483. }
  10484. } /**
  10485. * @flow
  10486. */
  10487. function opFromJSON(json /*: { [key: string]: any }*/) /*: ?Op*/{
  10488. if (!json || !json.__op) {
  10489. return null;
  10490. }
  10491. switch (json.__op) {
  10492. case 'Delete':
  10493. return new UnsetOp();
  10494. case 'Increment':
  10495. return new IncrementOp(json.amount);
  10496. case 'Add':
  10497. return new AddOp((0, _decode.default)(json.objects));
  10498. case 'AddUnique':
  10499. return new AddUniqueOp((0, _decode.default)(json.objects));
  10500. case 'Remove':
  10501. return new RemoveOp((0, _decode.default)(json.objects));
  10502. case 'AddRelation':
  10503. {
  10504. var toAdd = (0, _decode.default)(json.objects);
  10505. if (!(0, _isArray.default)(toAdd)) {
  10506. return new RelationOp([], []);
  10507. }
  10508. return new RelationOp(toAdd, []);
  10509. }
  10510. case 'RemoveRelation':
  10511. {
  10512. var toRemove = (0, _decode.default)(json.objects);
  10513. if (!(0, _isArray.default)(toRemove)) {
  10514. return new RelationOp([], []);
  10515. }
  10516. return new RelationOp([], toRemove);
  10517. }
  10518. case 'Batch':
  10519. {
  10520. var _toAdd = [];
  10521. var _toRemove = [];
  10522. for (var i = 0; i < json.ops.length; i++) {
  10523. if (json.ops[i].__op === 'AddRelation') {
  10524. _toAdd = (0, _concat.default)(_toAdd).call(_toAdd, (0, _decode.default)(json.ops[i].objects));
  10525. } else if (json.ops[i].__op === 'RemoveRelation') {
  10526. _toRemove = (0, _concat.default)(_toRemove).call(_toRemove, (0, _decode.default)(json.ops[i].objects));
  10527. }
  10528. }
  10529. return new RelationOp(_toAdd, _toRemove);
  10530. }
  10531. }
  10532. return null;
  10533. }
  10534. var Op = /*#__PURE__*/function () {
  10535. function Op() {
  10536. (0, _classCallCheck2.default)(this, Op);
  10537. }
  10538. (0, _createClass2.default)(Op, [{
  10539. key: "applyTo",
  10540. value:
  10541. // Empty parent class
  10542. function () /*: mixed*/{} /* eslint-disable-line no-unused-vars */
  10543. }, {
  10544. key: "mergeWith",
  10545. value: function () /*: ?Op*/{} /* eslint-disable-line no-unused-vars */
  10546. }, {
  10547. key: "toJSON",
  10548. value: function () /*: mixed*/{}
  10549. }]);
  10550. return Op;
  10551. }();
  10552. exports.Op = Op;
  10553. var SetOp = /*#__PURE__*/function (_Op) {
  10554. (0, _inherits2.default)(SetOp, _Op);
  10555. var _super = _createSuper(SetOp);
  10556. function SetOp(value /*: mixed*/) {
  10557. var _this;
  10558. (0, _classCallCheck2.default)(this, SetOp);
  10559. _this = _super.call(this);
  10560. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_value", void 0);
  10561. _this._value = value;
  10562. return _this;
  10563. }
  10564. (0, _createClass2.default)(SetOp, [{
  10565. key: "applyTo",
  10566. value: function () /*: mixed*/{
  10567. return this._value;
  10568. }
  10569. }, {
  10570. key: "mergeWith",
  10571. value: function () /*: SetOp*/{
  10572. return new SetOp(this._value);
  10573. }
  10574. }, {
  10575. key: "toJSON",
  10576. value: function (offline /*:: ?: boolean*/) {
  10577. return (0, _encode.default)(this._value, false, true, undefined, offline);
  10578. }
  10579. }]);
  10580. return SetOp;
  10581. }(Op);
  10582. exports.SetOp = SetOp;
  10583. var UnsetOp = /*#__PURE__*/function (_Op2) {
  10584. (0, _inherits2.default)(UnsetOp, _Op2);
  10585. var _super2 = _createSuper(UnsetOp);
  10586. function UnsetOp() {
  10587. (0, _classCallCheck2.default)(this, UnsetOp);
  10588. return _super2.apply(this, arguments);
  10589. }
  10590. (0, _createClass2.default)(UnsetOp, [{
  10591. key: "applyTo",
  10592. value: function () {
  10593. return undefined;
  10594. }
  10595. }, {
  10596. key: "mergeWith",
  10597. value: function () /*: UnsetOp*/{
  10598. return new UnsetOp();
  10599. }
  10600. }, {
  10601. key: "toJSON",
  10602. value: function () /*: { __op: string }*/{
  10603. return {
  10604. __op: 'Delete'
  10605. };
  10606. }
  10607. }]);
  10608. return UnsetOp;
  10609. }(Op);
  10610. exports.UnsetOp = UnsetOp;
  10611. var IncrementOp = /*#__PURE__*/function (_Op3) {
  10612. (0, _inherits2.default)(IncrementOp, _Op3);
  10613. var _super3 = _createSuper(IncrementOp);
  10614. function IncrementOp(amount /*: number*/) {
  10615. var _this2;
  10616. (0, _classCallCheck2.default)(this, IncrementOp);
  10617. _this2 = _super3.call(this);
  10618. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "_amount", void 0);
  10619. if (typeof amount !== 'number') {
  10620. throw new TypeError('Increment Op must be initialized with a numeric amount.');
  10621. }
  10622. _this2._amount = amount;
  10623. return _this2;
  10624. }
  10625. (0, _createClass2.default)(IncrementOp, [{
  10626. key: "applyTo",
  10627. value: function (value /*: ?mixed*/) /*: number*/{
  10628. if (typeof value === 'undefined') {
  10629. return this._amount;
  10630. }
  10631. if (typeof value !== 'number') {
  10632. throw new TypeError('Cannot increment a non-numeric value.');
  10633. }
  10634. return this._amount + value;
  10635. }
  10636. }, {
  10637. key: "mergeWith",
  10638. value: function (previous /*: Op*/) /*: Op*/{
  10639. if (!previous) {
  10640. return this;
  10641. }
  10642. if (previous instanceof SetOp) {
  10643. return new SetOp(this.applyTo(previous._value));
  10644. }
  10645. if (previous instanceof UnsetOp) {
  10646. return new SetOp(this._amount);
  10647. }
  10648. if (previous instanceof IncrementOp) {
  10649. return new IncrementOp(this.applyTo(previous._amount));
  10650. }
  10651. throw new Error('Cannot merge Increment Op with the previous Op');
  10652. }
  10653. }, {
  10654. key: "toJSON",
  10655. value: function () /*: { __op: string, amount: number }*/{
  10656. return {
  10657. __op: 'Increment',
  10658. amount: this._amount
  10659. };
  10660. }
  10661. }]);
  10662. return IncrementOp;
  10663. }(Op);
  10664. exports.IncrementOp = IncrementOp;
  10665. var AddOp = /*#__PURE__*/function (_Op4) {
  10666. (0, _inherits2.default)(AddOp, _Op4);
  10667. var _super4 = _createSuper(AddOp);
  10668. function AddOp(value /*: mixed | Array<mixed>*/) {
  10669. var _this3;
  10670. (0, _classCallCheck2.default)(this, AddOp);
  10671. _this3 = _super4.call(this);
  10672. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this3), "_value", void 0);
  10673. _this3._value = (0, _isArray.default)(value) ? value : [value];
  10674. return _this3;
  10675. }
  10676. (0, _createClass2.default)(AddOp, [{
  10677. key: "applyTo",
  10678. value: function (value /*: mixed*/) /*: Array<mixed>*/{
  10679. if (value == null) {
  10680. return this._value;
  10681. }
  10682. if ((0, _isArray.default)(value)) {
  10683. return (0, _concat.default)(value).call(value, this._value);
  10684. }
  10685. throw new Error('Cannot add elements to a non-array value');
  10686. }
  10687. }, {
  10688. key: "mergeWith",
  10689. value: function (previous /*: Op*/) /*: Op*/{
  10690. if (!previous) {
  10691. return this;
  10692. }
  10693. if (previous instanceof SetOp) {
  10694. return new SetOp(this.applyTo(previous._value));
  10695. }
  10696. if (previous instanceof UnsetOp) {
  10697. return new SetOp(this._value);
  10698. }
  10699. if (previous instanceof AddOp) {
  10700. return new AddOp(this.applyTo(previous._value));
  10701. }
  10702. throw new Error('Cannot merge Add Op with the previous Op');
  10703. }
  10704. }, {
  10705. key: "toJSON",
  10706. value: function () /*: { __op: string, objects: mixed }*/{
  10707. return {
  10708. __op: 'Add',
  10709. objects: (0, _encode.default)(this._value, false, true)
  10710. };
  10711. }
  10712. }]);
  10713. return AddOp;
  10714. }(Op);
  10715. exports.AddOp = AddOp;
  10716. var AddUniqueOp = /*#__PURE__*/function (_Op5) {
  10717. (0, _inherits2.default)(AddUniqueOp, _Op5);
  10718. var _super5 = _createSuper(AddUniqueOp);
  10719. function AddUniqueOp(value /*: mixed | Array<mixed>*/) {
  10720. var _this4;
  10721. (0, _classCallCheck2.default)(this, AddUniqueOp);
  10722. _this4 = _super5.call(this);
  10723. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this4), "_value", void 0);
  10724. _this4._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  10725. return _this4;
  10726. }
  10727. (0, _createClass2.default)(AddUniqueOp, [{
  10728. key: "applyTo",
  10729. value: function (value /*: mixed | Array<mixed>*/) /*: Array<mixed>*/{
  10730. if (value == null) {
  10731. return this._value || [];
  10732. }
  10733. if ((0, _isArray.default)(value)) {
  10734. var _context;
  10735. var toAdd = [];
  10736. (0, _forEach.default)(_context = this._value).call(_context, function (v) {
  10737. if (v instanceof _ParseObject.default) {
  10738. if (!(0, _arrayContainsObject.default)(value, v)) {
  10739. toAdd.push(v);
  10740. }
  10741. } else {
  10742. if ((0, _indexOf.default)(value).call(value, v) < 0) {
  10743. toAdd.push(v);
  10744. }
  10745. }
  10746. });
  10747. return (0, _concat.default)(value).call(value, toAdd);
  10748. }
  10749. throw new Error('Cannot add elements to a non-array value');
  10750. }
  10751. }, {
  10752. key: "mergeWith",
  10753. value: function (previous /*: Op*/) /*: Op*/{
  10754. if (!previous) {
  10755. return this;
  10756. }
  10757. if (previous instanceof SetOp) {
  10758. return new SetOp(this.applyTo(previous._value));
  10759. }
  10760. if (previous instanceof UnsetOp) {
  10761. return new SetOp(this._value);
  10762. }
  10763. if (previous instanceof AddUniqueOp) {
  10764. return new AddUniqueOp(this.applyTo(previous._value));
  10765. }
  10766. throw new Error('Cannot merge AddUnique Op with the previous Op');
  10767. }
  10768. }, {
  10769. key: "toJSON",
  10770. value: function () /*: { __op: string, objects: mixed }*/{
  10771. return {
  10772. __op: 'AddUnique',
  10773. objects: (0, _encode.default)(this._value, false, true)
  10774. };
  10775. }
  10776. }]);
  10777. return AddUniqueOp;
  10778. }(Op);
  10779. exports.AddUniqueOp = AddUniqueOp;
  10780. var RemoveOp = /*#__PURE__*/function (_Op6) {
  10781. (0, _inherits2.default)(RemoveOp, _Op6);
  10782. var _super6 = _createSuper(RemoveOp);
  10783. function RemoveOp(value /*: mixed | Array<mixed>*/) {
  10784. var _this5;
  10785. (0, _classCallCheck2.default)(this, RemoveOp);
  10786. _this5 = _super6.call(this);
  10787. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this5), "_value", void 0);
  10788. _this5._value = (0, _unique.default)((0, _isArray.default)(value) ? value : [value]);
  10789. return _this5;
  10790. }
  10791. (0, _createClass2.default)(RemoveOp, [{
  10792. key: "applyTo",
  10793. value: function (value /*: mixed | Array<mixed>*/) /*: Array<mixed>*/{
  10794. if (value == null) {
  10795. return [];
  10796. }
  10797. if ((0, _isArray.default)(value)) {
  10798. // var i = value.indexOf(this._value);
  10799. var removed = (0, _concat.default)(value).call(value, []);
  10800. for (var i = 0; i < this._value.length; i++) {
  10801. var index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  10802. while (index > -1) {
  10803. (0, _splice.default)(removed).call(removed, index, 1);
  10804. index = (0, _indexOf.default)(removed).call(removed, this._value[i]);
  10805. }
  10806. if (this._value[i] instanceof _ParseObject.default && this._value[i].id) {
  10807. for (var j = 0; j < removed.length; j++) {
  10808. if (removed[j] instanceof _ParseObject.default && this._value[i].id === removed[j].id) {
  10809. (0, _splice.default)(removed).call(removed, j, 1);
  10810. j--;
  10811. }
  10812. }
  10813. }
  10814. }
  10815. return removed;
  10816. }
  10817. throw new Error('Cannot remove elements from a non-array value');
  10818. }
  10819. }, {
  10820. key: "mergeWith",
  10821. value: function (previous /*: Op*/) /*: Op*/{
  10822. if (!previous) {
  10823. return this;
  10824. }
  10825. if (previous instanceof SetOp) {
  10826. return new SetOp(this.applyTo(previous._value));
  10827. }
  10828. if (previous instanceof UnsetOp) {
  10829. return new UnsetOp();
  10830. }
  10831. if (previous instanceof RemoveOp) {
  10832. var _context2;
  10833. var uniques = (0, _concat.default)(_context2 = previous._value).call(_context2, []);
  10834. for (var i = 0; i < this._value.length; i++) {
  10835. if (this._value[i] instanceof _ParseObject.default) {
  10836. if (!(0, _arrayContainsObject.default)(uniques, this._value[i])) {
  10837. uniques.push(this._value[i]);
  10838. }
  10839. } else {
  10840. if ((0, _indexOf.default)(uniques).call(uniques, this._value[i]) < 0) {
  10841. uniques.push(this._value[i]);
  10842. }
  10843. }
  10844. }
  10845. return new RemoveOp(uniques);
  10846. }
  10847. throw new Error('Cannot merge Remove Op with the previous Op');
  10848. }
  10849. }, {
  10850. key: "toJSON",
  10851. value: function () /*: { __op: string, objects: mixed }*/{
  10852. return {
  10853. __op: 'Remove',
  10854. objects: (0, _encode.default)(this._value, false, true)
  10855. };
  10856. }
  10857. }]);
  10858. return RemoveOp;
  10859. }(Op);
  10860. exports.RemoveOp = RemoveOp;
  10861. var RelationOp = /*#__PURE__*/function (_Op7) {
  10862. (0, _inherits2.default)(RelationOp, _Op7);
  10863. var _super7 = _createSuper(RelationOp);
  10864. function RelationOp(adds /*: Array<ParseObject | string>*/, removes /*: Array<ParseObject | string>*/) {
  10865. var _this6;
  10866. (0, _classCallCheck2.default)(this, RelationOp);
  10867. _this6 = _super7.call(this);
  10868. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "_targetClassName", void 0);
  10869. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToAdd", void 0);
  10870. (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this6), "relationsToRemove", void 0);
  10871. _this6._targetClassName = null;
  10872. if ((0, _isArray.default)(adds)) {
  10873. _this6.relationsToAdd = (0, _unique.default)((0, _map.default)(adds).call(adds, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
  10874. }
  10875. if ((0, _isArray.default)(removes)) {
  10876. _this6.relationsToRemove = (0, _unique.default)((0, _map.default)(removes).call(removes, _this6._extractId, (0, _assertThisInitialized2.default)(_this6)));
  10877. }
  10878. return _this6;
  10879. }
  10880. (0, _createClass2.default)(RelationOp, [{
  10881. key: "_extractId",
  10882. value: function (obj /*: string | ParseObject*/) /*: string*/{
  10883. if (typeof obj === 'string') {
  10884. return obj;
  10885. }
  10886. if (!obj.id) {
  10887. throw new Error('You cannot add or remove an unsaved Parse Object from a relation');
  10888. }
  10889. if (!this._targetClassName) {
  10890. this._targetClassName = obj.className;
  10891. }
  10892. if (this._targetClassName !== obj.className) {
  10893. throw new Error('Tried to create a Relation with 2 different object types: ' + this._targetClassName + ' and ' + obj.className + '.');
  10894. }
  10895. return obj.id;
  10896. }
  10897. }, {
  10898. key: "applyTo",
  10899. value: function (value /*: mixed*/, object /*:: ?: { className: string, id: ?string }*/, key /*:: ?: string*/) /*: ?ParseRelation*/{
  10900. if (!value) {
  10901. var _context3;
  10902. if (!object || !key) {
  10903. throw new Error('Cannot apply a RelationOp without either a previous value, or an object and a key');
  10904. }
  10905. var parent = new _ParseObject.default(object.className);
  10906. if (object.id && (0, _indexOf.default)(_context3 = object.id).call(_context3, 'local') === 0) {
  10907. parent._localId = object.id;
  10908. } else if (object.id) {
  10909. parent.id = object.id;
  10910. }
  10911. var relation = new _ParseRelation.default(parent, key);
  10912. relation.targetClassName = this._targetClassName;
  10913. return relation;
  10914. }
  10915. if (value instanceof _ParseRelation.default) {
  10916. if (this._targetClassName) {
  10917. if (value.targetClassName) {
  10918. if (this._targetClassName !== value.targetClassName) {
  10919. throw new Error('Related object must be a ' + value.targetClassName + ', but a ' + this._targetClassName + ' was passed in.');
  10920. }
  10921. } else {
  10922. value.targetClassName = this._targetClassName;
  10923. }
  10924. }
  10925. return value;
  10926. } else {
  10927. throw new Error('Relation cannot be applied to a non-relation field');
  10928. }
  10929. }
  10930. }, {
  10931. key: "mergeWith",
  10932. value: function (previous /*: Op*/) /*: Op*/{
  10933. if (!previous) {
  10934. return this;
  10935. } else if (previous instanceof UnsetOp) {
  10936. throw new Error('You cannot modify a relation after deleting it.');
  10937. } else if (previous instanceof SetOp && previous._value instanceof _ParseRelation.default) {
  10938. return this;
  10939. } else if (previous instanceof RelationOp) {
  10940. var _context4, _context5, _context6, _context7, _context8, _context9;
  10941. if (previous._targetClassName && previous._targetClassName !== this._targetClassName) {
  10942. throw new Error('Related object must be of class ' + previous._targetClassName + ', but ' + (this._targetClassName || 'null') + ' was passed in.');
  10943. }
  10944. var newAdd = (0, _concat.default)(_context4 = previous.relationsToAdd).call(_context4, []);
  10945. (0, _forEach.default)(_context5 = this.relationsToRemove).call(_context5, function (r) {
  10946. var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  10947. if (index > -1) {
  10948. (0, _splice.default)(newAdd).call(newAdd, index, 1);
  10949. }
  10950. });
  10951. (0, _forEach.default)(_context6 = this.relationsToAdd).call(_context6, function (r) {
  10952. var index = (0, _indexOf.default)(newAdd).call(newAdd, r);
  10953. if (index < 0) {
  10954. newAdd.push(r);
  10955. }
  10956. });
  10957. var newRemove = (0, _concat.default)(_context7 = previous.relationsToRemove).call(_context7, []);
  10958. (0, _forEach.default)(_context8 = this.relationsToAdd).call(_context8, function (r) {
  10959. var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  10960. if (index > -1) {
  10961. (0, _splice.default)(newRemove).call(newRemove, index, 1);
  10962. }
  10963. });
  10964. (0, _forEach.default)(_context9 = this.relationsToRemove).call(_context9, function (r) {
  10965. var index = (0, _indexOf.default)(newRemove).call(newRemove, r);
  10966. if (index < 0) {
  10967. newRemove.push(r);
  10968. }
  10969. });
  10970. var newRelation = new RelationOp(newAdd, newRemove);
  10971. newRelation._targetClassName = this._targetClassName;
  10972. return newRelation;
  10973. }
  10974. throw new Error('Cannot merge Relation Op with the previous Op');
  10975. }
  10976. }, {
  10977. key: "toJSON",
  10978. value: function () /*: { __op?: string, objects?: mixed, ops?: mixed }*/{
  10979. var _this7 = this;
  10980. var idToPointer = function (id) {
  10981. return {
  10982. __type: 'Pointer',
  10983. className: _this7._targetClassName,
  10984. objectId: id
  10985. };
  10986. };
  10987. var adds = null;
  10988. var removes = null;
  10989. var pointers = null;
  10990. if (this.relationsToAdd.length > 0) {
  10991. var _context10;
  10992. pointers = (0, _map.default)(_context10 = this.relationsToAdd).call(_context10, idToPointer);
  10993. adds = {
  10994. __op: 'AddRelation',
  10995. objects: pointers
  10996. };
  10997. }
  10998. if (this.relationsToRemove.length > 0) {
  10999. var _context11;
  11000. pointers = (0, _map.default)(_context11 = this.relationsToRemove).call(_context11, idToPointer);
  11001. removes = {
  11002. __op: 'RemoveRelation',
  11003. objects: pointers
  11004. };
  11005. }
  11006. if (adds && removes) {
  11007. return {
  11008. __op: 'Batch',
  11009. ops: [adds, removes]
  11010. };
  11011. }
  11012. return adds || removes || {};
  11013. }
  11014. }]);
  11015. return RelationOp;
  11016. }(Op);
  11017. exports.RelationOp = RelationOp;
  11018. },{"./ParseObject":26,"./ParseRelation":30,"./arrayContainsObject":44,"./decode":46,"./encode":47,"./unique":53,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/concat":59,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/instance/map":69,"@babel/runtime-corejs3/core-js-stable/instance/splice":73,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":92,"@babel/runtime-corejs3/helpers/assertThisInitialized":121,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/getPrototypeOf":128,"@babel/runtime-corejs3/helpers/inherits":129,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":137}],28:[function(_dereq_,module,exports){
  11019. "use strict";
  11020. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11021. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11022. _Object$defineProperty(exports, "__esModule", {
  11023. value: true
  11024. });
  11025. exports.default = void 0;
  11026. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  11027. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  11028. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  11029. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  11030. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  11031. /**
  11032. * @flow
  11033. */
  11034. /**
  11035. * Creates a new Polygon with any of the following forms:<br>
  11036. * <pre>
  11037. * new Polygon([[0,0],[0,1],[1,1],[1,0]])
  11038. * new Polygon([GeoPoint, GeoPoint, GeoPoint])
  11039. * </pre>
  11040. *
  11041. * <p>Represents a coordinates that may be associated
  11042. * with a key in a ParseObject or used as a reference point for geo queries.
  11043. * This allows proximity-based queries on the key.</p>
  11044. *
  11045. * <p>Example:<pre>
  11046. * var polygon = new Parse.Polygon([[0,0],[0,1],[1,1],[1,0]]);
  11047. * var object = new Parse.Object("PlaceObject");
  11048. * object.set("area", polygon);
  11049. * object.save();</pre></p>
  11050. *
  11051. * @alias Parse.Polygon
  11052. */
  11053. var ParsePolygon = /*#__PURE__*/function () {
  11054. /**
  11055. * @param {(number[][] | Parse.GeoPoint[])} coordinates An Array of coordinate pairs
  11056. */
  11057. function ParsePolygon(coordinates /*: Array<Array<number>> | Array<ParseGeoPoint>*/) {
  11058. (0, _classCallCheck2.default)(this, ParsePolygon);
  11059. (0, _defineProperty2.default)(this, "_coordinates", void 0);
  11060. this._coordinates = ParsePolygon._validate(coordinates);
  11061. }
  11062. /**
  11063. * Coordinates value for this Polygon.
  11064. * Throws an exception if not valid type.
  11065. *
  11066. * @property {(number[][] | Parse.GeoPoint[])} coordinates list of coordinates
  11067. * @returns {number[][]}
  11068. */
  11069. (0, _createClass2.default)(ParsePolygon, [{
  11070. key: "coordinates",
  11071. get: function () /*: Array<Array<number>>*/{
  11072. return this._coordinates;
  11073. },
  11074. set: function (coords /*: Array<Array<number>> | Array<ParseGeoPoint>*/) {
  11075. this._coordinates = ParsePolygon._validate(coords);
  11076. }
  11077. /**
  11078. * Returns a JSON representation of the Polygon, suitable for Parse.
  11079. *
  11080. * @returns {object}
  11081. */
  11082. }, {
  11083. key: "toJSON",
  11084. value: function () /*: { __type: string, coordinates: Array<Array<number>> }*/{
  11085. ParsePolygon._validate(this._coordinates);
  11086. return {
  11087. __type: 'Polygon',
  11088. coordinates: this._coordinates
  11089. };
  11090. }
  11091. /**
  11092. * Checks if two polygons are equal
  11093. *
  11094. * @param {(Parse.Polygon | object)} other
  11095. * @returns {boolean}
  11096. */
  11097. }, {
  11098. key: "equals",
  11099. value: function (other /*: mixed*/) /*: boolean*/{
  11100. if (!(other instanceof ParsePolygon) || this.coordinates.length !== other.coordinates.length) {
  11101. return false;
  11102. }
  11103. var isEqual = true;
  11104. for (var i = 1; i < this._coordinates.length; i += 1) {
  11105. if (this._coordinates[i][0] != other.coordinates[i][0] || this._coordinates[i][1] != other.coordinates[i][1]) {
  11106. isEqual = false;
  11107. break;
  11108. }
  11109. }
  11110. return isEqual;
  11111. }
  11112. /**
  11113. *
  11114. * @param {Parse.GeoPoint} point
  11115. * @returns {boolean} Returns if the point is contained in the polygon
  11116. */
  11117. }, {
  11118. key: "containsPoint",
  11119. value: function (point /*: ParseGeoPoint*/) /*: boolean*/{
  11120. var minX = this._coordinates[0][0];
  11121. var maxX = this._coordinates[0][0];
  11122. var minY = this._coordinates[0][1];
  11123. var maxY = this._coordinates[0][1];
  11124. for (var i = 1; i < this._coordinates.length; i += 1) {
  11125. var p = this._coordinates[i];
  11126. minX = Math.min(p[0], minX);
  11127. maxX = Math.max(p[0], maxX);
  11128. minY = Math.min(p[1], minY);
  11129. maxY = Math.max(p[1], maxY);
  11130. }
  11131. var outside = point.latitude < minX || point.latitude > maxX || point.longitude < minY || point.longitude > maxY;
  11132. if (outside) {
  11133. return false;
  11134. }
  11135. var inside = false;
  11136. for (var _i = 0, j = this._coordinates.length - 1; _i < this._coordinates.length; j = _i++) {
  11137. var startX = this._coordinates[_i][0];
  11138. var startY = this._coordinates[_i][1];
  11139. var endX = this._coordinates[j][0];
  11140. var endY = this._coordinates[j][1];
  11141. var intersect = startY > point.longitude != endY > point.longitude && point.latitude < (endX - startX) * (point.longitude - startY) / (endY - startY) + startX;
  11142. if (intersect) {
  11143. inside = !inside;
  11144. }
  11145. }
  11146. return inside;
  11147. }
  11148. /**
  11149. * Validates that the list of coordinates can form a valid polygon
  11150. *
  11151. * @param {Array} coords the list of coordinates to validate as a polygon
  11152. * @throws {TypeError}
  11153. * @returns {number[][]} Array of coordinates if validated.
  11154. */
  11155. }], [{
  11156. key: "_validate",
  11157. value: function (coords /*: Array<Array<number>> | Array<ParseGeoPoint>*/) /*: Array<Array<number>>*/{
  11158. if (!(0, _isArray.default)(coords)) {
  11159. throw new TypeError('Coordinates must be an Array');
  11160. }
  11161. if (coords.length < 3) {
  11162. throw new TypeError('Polygon must have at least 3 GeoPoints or Points');
  11163. }
  11164. var points = [];
  11165. for (var i = 0; i < coords.length; i += 1) {
  11166. var coord = coords[i];
  11167. var geoPoint = void 0;
  11168. if (coord instanceof _ParseGeoPoint.default) {
  11169. geoPoint = coord;
  11170. } else if ((0, _isArray.default)(coord) && coord.length === 2) {
  11171. geoPoint = new _ParseGeoPoint.default(coord[0], coord[1]);
  11172. } else {
  11173. throw new TypeError('Coordinates must be an Array of GeoPoints or Points');
  11174. }
  11175. points.push([geoPoint.latitude, geoPoint.longitude]);
  11176. }
  11177. return points;
  11178. }
  11179. }]);
  11180. return ParsePolygon;
  11181. }();
  11182. var _default = ParsePolygon;
  11183. exports.default = _default;
  11184. },{"./ParseGeoPoint":23,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],29:[function(_dereq_,module,exports){
  11185. "use strict";
  11186. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  11187. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  11188. _Object$defineProperty(exports, "__esModule", {
  11189. value: true
  11190. });
  11191. exports.default = void 0;
  11192. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  11193. var _slicedToArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/slicedToArray"));
  11194. var _toConsumableArray2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/toConsumableArray"));
  11195. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  11196. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  11197. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  11198. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  11199. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  11200. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  11201. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  11202. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  11203. var _slice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/slice"));
  11204. var _map2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  11205. var _filter2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter"));
  11206. var _keys2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  11207. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  11208. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  11209. var _sort = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/sort"));
  11210. var _splice = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/splice"));
  11211. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  11212. var _find = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/find"));
  11213. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  11214. var _entries = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/entries"));
  11215. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  11216. var _encode = _interopRequireDefault(_dereq_("./encode"));
  11217. var _promiseUtils = _dereq_("./promiseUtils");
  11218. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  11219. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  11220. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  11221. var _OfflineQuery = _interopRequireDefault(_dereq_("./OfflineQuery"));
  11222. var _LocalDatastoreUtils = _dereq_("./LocalDatastoreUtils");
  11223. /*
  11224. * @flow
  11225. */
  11226. /*:: import type LiveQuerySubscription from './LiveQuerySubscription';*/
  11227. /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
  11228. /*:: type BatchOptions = FullOptions & { batchSize?: number };*/
  11229. /*:: export type WhereClause = {
  11230. [attr: string]: mixed,
  11231. };*/
  11232. /*:: export type QueryJSON = {
  11233. where: WhereClause,
  11234. watch?: string,
  11235. include?: string,
  11236. excludeKeys?: string,
  11237. keys?: string,
  11238. limit?: number,
  11239. skip?: number,
  11240. order?: string,
  11241. className?: string,
  11242. count?: number,
  11243. hint?: mixed,
  11244. explain?: boolean,
  11245. readPreference?: string,
  11246. includeReadPreference?: string,
  11247. subqueryReadPreference?: string,
  11248. };*/
  11249. /**
  11250. * Converts a string into a regex that matches it.
  11251. * Surrounding with \Q .. \E does this, we just need to escape any \E's in
  11252. * the text separately.
  11253. *
  11254. * @param s
  11255. * @private
  11256. * @returns {string}
  11257. */
  11258. function quote(s /*: string*/) /*: string*/{
  11259. return '\\Q' + s.replace('\\E', '\\E\\\\E\\Q') + '\\E';
  11260. }
  11261. /**
  11262. * Extracts the class name from queries. If not all queries have the same
  11263. * class name an error will be thrown.
  11264. *
  11265. * @param queries
  11266. * @private
  11267. * @returns {string}
  11268. */
  11269. function _getClassNameFromQueries(queries /*: Array<ParseQuery>*/) /*: ?string*/{
  11270. var className = null;
  11271. (0, _forEach.default)(queries).call(queries, function (q) {
  11272. if (!className) {
  11273. className = q.className;
  11274. }
  11275. if (className !== q.className) {
  11276. throw new Error('All queries must be for the same class.');
  11277. }
  11278. });
  11279. return className;
  11280. }
  11281. /*
  11282. * Handles pre-populating the result data of a query with select fields,
  11283. * making sure that the data object contains keys for all objects that have
  11284. * been requested with a select, so that our cached state updates correctly.
  11285. */
  11286. function handleSelectResult(data /*: any*/, select /*: Array<string>*/) {
  11287. var serverDataMask = {};
  11288. (0, _forEach.default)(select).call(select, function (field) {
  11289. var hasSubObjectSelect = (0, _indexOf.default)(field).call(field, '.') !== -1;
  11290. if (!hasSubObjectSelect && !data.hasOwnProperty(field)) {
  11291. // this field was selected, but is missing from the retrieved data
  11292. data[field] = undefined;
  11293. } else if (hasSubObjectSelect) {
  11294. // this field references a sub-object,
  11295. // so we need to walk down the path components
  11296. var pathComponents = field.split('.');
  11297. var _obj = data;
  11298. var serverMask = serverDataMask;
  11299. (0, _forEach.default)(pathComponents).call(pathComponents, function (component, index, arr) {
  11300. // add keys if the expected data is missing
  11301. if (_obj && !_obj.hasOwnProperty(component)) {
  11302. _obj[component] = undefined;
  11303. }
  11304. if (_obj && (0, _typeof2.default)(_obj) === 'object') {
  11305. _obj = _obj[component];
  11306. }
  11307. //add this path component to the server mask so we can fill it in later if needed
  11308. if (index < arr.length - 1) {
  11309. if (!serverMask[component]) {
  11310. serverMask[component] = {};
  11311. }
  11312. serverMask = serverMask[component];
  11313. }
  11314. });
  11315. }
  11316. });
  11317. if ((0, _keys.default)(serverDataMask).length > 0) {
  11318. // When selecting from sub-objects, we don't want to blow away the missing
  11319. // information that we may have retrieved before. We've already added any
  11320. // missing selected keys to sub-objects, but we still need to add in the
  11321. // data for any previously retrieved sub-objects that were not selected.
  11322. var serverData = _CoreManager.default.getObjectStateController().getServerData({
  11323. id: data.objectId,
  11324. className: data.className
  11325. });
  11326. copyMissingDataWithMask(serverData, data, serverDataMask, false);
  11327. }
  11328. }
  11329. function copyMissingDataWithMask(src, dest, mask, copyThisLevel) {
  11330. //copy missing elements at this level
  11331. if (copyThisLevel) {
  11332. for (var _key in src) {
  11333. if (src.hasOwnProperty(_key) && !dest.hasOwnProperty(_key)) {
  11334. dest[_key] = src[_key];
  11335. }
  11336. }
  11337. }
  11338. for (var _key2 in mask) {
  11339. if (dest[_key2] !== undefined && dest[_key2] !== null && src !== undefined && src !== null) {
  11340. //traverse into objects as needed
  11341. copyMissingDataWithMask(src[_key2], dest[_key2], mask[_key2], true);
  11342. }
  11343. }
  11344. }
  11345. function handleOfflineSort(a, b, sorts) {
  11346. var order = sorts[0];
  11347. var operator = (0, _slice.default)(order).call(order, 0, 1);
  11348. var isDescending = operator === '-';
  11349. if (isDescending) {
  11350. order = order.substring(1);
  11351. }
  11352. if (order === '_created_at') {
  11353. order = 'createdAt';
  11354. }
  11355. if (order === '_updated_at') {
  11356. order = 'updatedAt';
  11357. }
  11358. if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(order) || order === 'password') {
  11359. throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, "Invalid Key: ".concat(order));
  11360. }
  11361. var field1 = a.get(order);
  11362. var field2 = b.get(order);
  11363. if (field1 < field2) {
  11364. return isDescending ? 1 : -1;
  11365. }
  11366. if (field1 > field2) {
  11367. return isDescending ? -1 : 1;
  11368. }
  11369. if (sorts.length > 1) {
  11370. var remainingSorts = (0, _slice.default)(sorts).call(sorts, 1);
  11371. return handleOfflineSort(a, b, remainingSorts);
  11372. }
  11373. return 0;
  11374. }
  11375. /**
  11376. * Creates a new parse Parse.Query for the given Parse.Object subclass.
  11377. *
  11378. * <p>Parse.Query defines a query that is used to fetch Parse.Objects. The
  11379. * most common use case is finding all objects that match a query through the
  11380. * <code>find</code> method. for example, this sample code fetches all objects
  11381. * of class <code>myclass</code>. it calls a different function depending on
  11382. * whether the fetch succeeded or not.
  11383. *
  11384. * <pre>
  11385. * var query = new Parse.Query(myclass);
  11386. * query.find().then((results) => {
  11387. * // results is an array of parse.object.
  11388. * }).catch((error) => {
  11389. * // error is an instance of parse.error.
  11390. * });</pre></p>
  11391. *
  11392. * <p>a Parse.Query can also be used to retrieve a single object whose id is
  11393. * known, through the get method. for example, this sample code fetches an
  11394. * object of class <code>myclass</code> and id <code>myid</code>. it calls a
  11395. * different function depending on whether the fetch succeeded or not.
  11396. *
  11397. * <pre>
  11398. * var query = new Parse.Query(myclass);
  11399. * query.get(myid).then((object) => {
  11400. * // object is an instance of parse.object.
  11401. * }).catch((error) => {
  11402. * // error is an instance of parse.error.
  11403. * });</pre></p>
  11404. *
  11405. * <p>a Parse.Query can also be used to count the number of objects that match
  11406. * the query without retrieving all of those objects. for example, this
  11407. * sample code counts the number of objects of the class <code>myclass</code>
  11408. * <pre>
  11409. * var query = new Parse.Query(myclass);
  11410. * query.count().then((number) => {
  11411. * // there are number instances of myclass.
  11412. * }).catch((error) => {
  11413. * // error is an instance of Parse.Error.
  11414. * });</pre></p>
  11415. *
  11416. * @alias Parse.Query
  11417. */
  11418. var ParseQuery = /*#__PURE__*/function () {
  11419. /**
  11420. * @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
  11421. */
  11422. function ParseQuery(objectClass /*: string | ParseObject*/) {
  11423. (0, _classCallCheck2.default)(this, ParseQuery);
  11424. /**
  11425. * @property {string} className
  11426. */
  11427. (0, _defineProperty2.default)(this, "className", void 0);
  11428. (0, _defineProperty2.default)(this, "_where", void 0);
  11429. (0, _defineProperty2.default)(this, "_watch", void 0);
  11430. (0, _defineProperty2.default)(this, "_include", void 0);
  11431. (0, _defineProperty2.default)(this, "_exclude", void 0);
  11432. (0, _defineProperty2.default)(this, "_select", void 0);
  11433. (0, _defineProperty2.default)(this, "_limit", void 0);
  11434. (0, _defineProperty2.default)(this, "_skip", void 0);
  11435. (0, _defineProperty2.default)(this, "_count", void 0);
  11436. (0, _defineProperty2.default)(this, "_order", void 0);
  11437. (0, _defineProperty2.default)(this, "_readPreference", void 0);
  11438. (0, _defineProperty2.default)(this, "_includeReadPreference", void 0);
  11439. (0, _defineProperty2.default)(this, "_subqueryReadPreference", void 0);
  11440. (0, _defineProperty2.default)(this, "_queriesLocalDatastore", void 0);
  11441. (0, _defineProperty2.default)(this, "_localDatastorePinName", void 0);
  11442. (0, _defineProperty2.default)(this, "_extraOptions", void 0);
  11443. (0, _defineProperty2.default)(this, "_hint", void 0);
  11444. (0, _defineProperty2.default)(this, "_explain", void 0);
  11445. (0, _defineProperty2.default)(this, "_xhrRequest", void 0);
  11446. if (typeof objectClass === 'string') {
  11447. if (objectClass === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  11448. this.className = '_User';
  11449. } else {
  11450. this.className = objectClass;
  11451. }
  11452. } else if (objectClass instanceof _ParseObject.default) {
  11453. this.className = objectClass.className;
  11454. } else if (typeof objectClass === 'function') {
  11455. if (typeof objectClass.className === 'string') {
  11456. this.className = objectClass.className;
  11457. } else {
  11458. var _obj2 = new objectClass();
  11459. this.className = _obj2.className;
  11460. }
  11461. } else {
  11462. throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
  11463. }
  11464. this._where = {};
  11465. this._watch = [];
  11466. this._include = [];
  11467. this._exclude = [];
  11468. this._count = false;
  11469. this._limit = -1; // negative limit is not sent in the server request
  11470. this._skip = 0;
  11471. this._readPreference = null;
  11472. this._includeReadPreference = null;
  11473. this._subqueryReadPreference = null;
  11474. this._queriesLocalDatastore = false;
  11475. this._localDatastorePinName = null;
  11476. this._extraOptions = {};
  11477. this._xhrRequest = {
  11478. task: null,
  11479. onchange: function () {}
  11480. };
  11481. }
  11482. /**
  11483. * Adds constraint that at least one of the passed in queries matches.
  11484. *
  11485. * @param {Array} queries
  11486. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11487. */
  11488. (0, _createClass2.default)(ParseQuery, [{
  11489. key: "_orQuery",
  11490. value: function (queries /*: Array<ParseQuery>*/) /*: ParseQuery*/{
  11491. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  11492. return q.toJSON().where;
  11493. });
  11494. this._where.$or = queryJSON;
  11495. return this;
  11496. }
  11497. /**
  11498. * Adds constraint that all of the passed in queries match.
  11499. *
  11500. * @param {Array} queries
  11501. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11502. */
  11503. }, {
  11504. key: "_andQuery",
  11505. value: function (queries /*: Array<ParseQuery>*/) /*: ParseQuery*/{
  11506. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  11507. return q.toJSON().where;
  11508. });
  11509. this._where.$and = queryJSON;
  11510. return this;
  11511. }
  11512. /**
  11513. * Adds constraint that none of the passed in queries match.
  11514. *
  11515. * @param {Array} queries
  11516. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11517. */
  11518. }, {
  11519. key: "_norQuery",
  11520. value: function (queries /*: Array<ParseQuery>*/) /*: ParseQuery*/{
  11521. var queryJSON = (0, _map2.default)(queries).call(queries, function (q) {
  11522. return q.toJSON().where;
  11523. });
  11524. this._where.$nor = queryJSON;
  11525. return this;
  11526. }
  11527. /**
  11528. * Helper for condition queries
  11529. *
  11530. * @param key
  11531. * @param condition
  11532. * @param value
  11533. * @returns {Parse.Query}
  11534. */
  11535. }, {
  11536. key: "_addCondition",
  11537. value: function (key /*: string*/, condition /*: string*/, value /*: mixed*/) /*: ParseQuery*/{
  11538. if (!this._where[key] || typeof this._where[key] === 'string') {
  11539. this._where[key] = {};
  11540. }
  11541. this._where[key][condition] = (0, _encode.default)(value, false, true);
  11542. return this;
  11543. }
  11544. /**
  11545. * Converts string for regular expression at the beginning
  11546. *
  11547. * @param string
  11548. * @returns {string}
  11549. */
  11550. }, {
  11551. key: "_regexStartWith",
  11552. value: function (string /*: string*/) /*: string*/{
  11553. return '^' + quote(string);
  11554. }
  11555. }, {
  11556. key: "_handleOfflineQuery",
  11557. value: function () {
  11558. var _handleOfflineQuery2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(params /*: any*/) {
  11559. var _context,
  11560. _this2 = this;
  11561. var localDatastore, objects, results, keys, alwaysSelectedKeys, sorts, count, limit;
  11562. return _regenerator.default.wrap(function (_context3) {
  11563. while (1) switch (_context3.prev = _context3.next) {
  11564. case 0:
  11565. _OfflineQuery.default.validateQuery(this);
  11566. localDatastore = _CoreManager.default.getLocalDatastore();
  11567. _context3.next = 4;
  11568. return localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
  11569. case 4:
  11570. objects = _context3.sent;
  11571. results = (0, _filter2.default)(_context = (0, _map2.default)(objects).call(objects, function (json, index, arr) {
  11572. var object = _ParseObject.default.fromJSON(json, false);
  11573. if (json._localId && !json.objectId) {
  11574. object._localId = json._localId;
  11575. }
  11576. if (!_OfflineQuery.default.matchesQuery(_this2.className, object, arr, _this2)) {
  11577. return null;
  11578. }
  11579. return object;
  11580. })).call(_context, function (object) {
  11581. return object !== null;
  11582. });
  11583. if ((0, _keys2.default)(params)) {
  11584. keys = (0, _keys2.default)(params).split(',');
  11585. alwaysSelectedKeys = ['className', 'objectId', 'createdAt', 'updatedAt', 'ACL'];
  11586. keys = (0, _concat.default)(keys).call(keys, alwaysSelectedKeys);
  11587. results = (0, _map2.default)(results).call(results, function (object) {
  11588. var _context2;
  11589. var json = object._toFullJSON();
  11590. (0, _forEach.default)(_context2 = (0, _keys.default)(json)).call(_context2, function (key) {
  11591. if (!(0, _includes.default)(keys).call(keys, key)) {
  11592. delete json[key];
  11593. }
  11594. });
  11595. return _ParseObject.default.fromJSON(json, false);
  11596. });
  11597. }
  11598. if (params.order) {
  11599. sorts = params.order.split(',');
  11600. (0, _sort.default)(results).call(results, function (a, b) {
  11601. return handleOfflineSort(a, b, sorts);
  11602. });
  11603. }
  11604. // count total before applying limit/skip
  11605. if (params.count) {
  11606. count = results.length; // total count from response
  11607. }
  11608. if (params.skip) {
  11609. if (params.skip >= results.length) {
  11610. results = [];
  11611. } else {
  11612. results = (0, _splice.default)(results).call(results, params.skip, results.length);
  11613. }
  11614. }
  11615. limit = results.length;
  11616. if (params.limit !== 0 && params.limit < results.length) {
  11617. limit = params.limit;
  11618. }
  11619. results = (0, _splice.default)(results).call(results, 0, limit);
  11620. if (!(typeof count === 'number')) {
  11621. _context3.next = 15;
  11622. break;
  11623. }
  11624. return _context3.abrupt("return", {
  11625. results: results,
  11626. count: count
  11627. });
  11628. case 15:
  11629. return _context3.abrupt("return", results);
  11630. case 16:
  11631. case "end":
  11632. return _context3.stop();
  11633. }
  11634. }, _callee, this);
  11635. }));
  11636. function _handleOfflineQuery() {
  11637. return _handleOfflineQuery2.apply(this, arguments);
  11638. }
  11639. return _handleOfflineQuery;
  11640. }()
  11641. /**
  11642. * Returns a JSON representation of this query.
  11643. *
  11644. * @returns {object} The JSON representation of the query.
  11645. */
  11646. }, {
  11647. key: "toJSON",
  11648. value: function () /*: QueryJSON*/{
  11649. var params /*: QueryJSON*/ = {
  11650. where: this._where
  11651. };
  11652. if (this._watch.length) {
  11653. params.watch = this._watch.join(',');
  11654. }
  11655. if (this._include.length) {
  11656. params.include = this._include.join(',');
  11657. }
  11658. if (this._exclude.length) {
  11659. params.excludeKeys = this._exclude.join(',');
  11660. }
  11661. if (this._select) {
  11662. params.keys = this._select.join(',');
  11663. }
  11664. if (this._count) {
  11665. params.count = 1;
  11666. }
  11667. if (this._limit >= 0) {
  11668. params.limit = this._limit;
  11669. }
  11670. if (this._skip > 0) {
  11671. params.skip = this._skip;
  11672. }
  11673. if (this._order) {
  11674. params.order = this._order.join(',');
  11675. }
  11676. if (this._readPreference) {
  11677. params.readPreference = this._readPreference;
  11678. }
  11679. if (this._includeReadPreference) {
  11680. params.includeReadPreference = this._includeReadPreference;
  11681. }
  11682. if (this._subqueryReadPreference) {
  11683. params.subqueryReadPreference = this._subqueryReadPreference;
  11684. }
  11685. if (this._hint) {
  11686. params.hint = this._hint;
  11687. }
  11688. if (this._explain) {
  11689. params.explain = true;
  11690. }
  11691. for (var _key3 in this._extraOptions) {
  11692. params[_key3] = this._extraOptions[_key3];
  11693. }
  11694. return params;
  11695. }
  11696. /**
  11697. * Return a query with conditions from json, can be useful to send query from server side to client
  11698. * Not static, all query conditions was set before calling this method will be deleted.
  11699. * For example on the server side we have
  11700. * var query = new Parse.Query("className");
  11701. * query.equalTo(key: value);
  11702. * query.limit(100);
  11703. * ... (others queries)
  11704. * Create JSON representation of Query Object
  11705. * var jsonFromServer = query.fromJSON();
  11706. *
  11707. * On client side getting query:
  11708. * var query = new Parse.Query("className");
  11709. * query.fromJSON(jsonFromServer);
  11710. *
  11711. * and continue to query...
  11712. * query.skip(100).find().then(...);
  11713. *
  11714. * @param {QueryJSON} json from Parse.Query.toJSON() method
  11715. * @returns {Parse.Query} Returns the query, so you can chain this call.
  11716. */
  11717. }, {
  11718. key: "withJSON",
  11719. value: function (json /*: QueryJSON*/) /*: ParseQuery*/{
  11720. if (json.where) {
  11721. this._where = json.where;
  11722. }
  11723. if (json.watch) {
  11724. this._watch = json.watch.split(',');
  11725. }
  11726. if (json.include) {
  11727. this._include = json.include.split(',');
  11728. }
  11729. if ((0, _keys2.default)(json)) {
  11730. this._select = (0, _keys2.default)(json).split(',');
  11731. }
  11732. if (json.excludeKeys) {
  11733. this._exclude = json.excludeKeys.split(',');
  11734. }
  11735. if (json.count) {
  11736. this._count = json.count === 1;
  11737. }
  11738. if (json.limit) {
  11739. this._limit = json.limit;
  11740. }
  11741. if (json.skip) {
  11742. this._skip = json.skip;
  11743. }
  11744. if (json.order) {
  11745. this._order = json.order.split(',');
  11746. }
  11747. if (json.readPreference) {
  11748. this._readPreference = json.readPreference;
  11749. }
  11750. if (json.includeReadPreference) {
  11751. this._includeReadPreference = json.includeReadPreference;
  11752. }
  11753. if (json.subqueryReadPreference) {
  11754. this._subqueryReadPreference = json.subqueryReadPreference;
  11755. }
  11756. if (json.hint) {
  11757. this._hint = json.hint;
  11758. }
  11759. if (json.explain) {
  11760. this._explain = !!json.explain;
  11761. }
  11762. for (var _key4 in json) {
  11763. if (json.hasOwnProperty(_key4)) {
  11764. var _context4;
  11765. if ((0, _indexOf.default)(_context4 = ['where', 'include', 'keys', 'count', 'limit', 'skip', 'order', 'readPreference', 'includeReadPreference', 'subqueryReadPreference', 'hint', 'explain']).call(_context4, _key4) === -1) {
  11766. this._extraOptions[_key4] = json[_key4];
  11767. }
  11768. }
  11769. }
  11770. return this;
  11771. }
  11772. /**
  11773. * Static method to restore Parse.Query by json representation
  11774. * Internally calling Parse.Query.withJSON
  11775. *
  11776. * @param {string} className
  11777. * @param {QueryJSON} json from Parse.Query.toJSON() method
  11778. * @returns {Parse.Query} new created query
  11779. */
  11780. }, {
  11781. key: "get",
  11782. value:
  11783. /**
  11784. * Constructs a Parse.Object whose id is already known by fetching data from
  11785. * the server. Unlike the <code>first</code> method, it never returns undefined.
  11786. *
  11787. * @param {string} objectId The id of the object to be fetched.
  11788. * @param {object} options
  11789. * Valid options are:<ul>
  11790. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11791. * be used for this request.
  11792. * <li>sessionToken: A valid session token, used for making a request on
  11793. * behalf of a specific user.
  11794. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  11795. * <li>json: Return raw json without converting to Parse.Object
  11796. * </ul>
  11797. * @returns {Promise} A promise that is resolved with the result when
  11798. * the query completes.
  11799. */
  11800. function (objectId /*: string*/, options /*:: ?: FullOptions*/) /*: Promise<ParseObject>*/{
  11801. this.equalTo('objectId', objectId);
  11802. var firstOptions = {};
  11803. if (options && options.hasOwnProperty('useMasterKey')) {
  11804. firstOptions.useMasterKey = options.useMasterKey;
  11805. }
  11806. if (options && options.hasOwnProperty('sessionToken')) {
  11807. firstOptions.sessionToken = options.sessionToken;
  11808. }
  11809. if (options && options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  11810. firstOptions.context = options.context;
  11811. }
  11812. if (options && options.hasOwnProperty('json')) {
  11813. firstOptions.json = options.json;
  11814. }
  11815. return this.first(firstOptions).then(function (response) {
  11816. if (response) {
  11817. return response;
  11818. }
  11819. var errorObject = new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'Object not found.');
  11820. return _promise.default.reject(errorObject);
  11821. });
  11822. }
  11823. /**
  11824. * Retrieves a list of ParseObjects that satisfy this query.
  11825. *
  11826. * @param {object} options Valid options
  11827. * are:<ul>
  11828. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11829. * be used for this request.
  11830. * <li>sessionToken: A valid session token, used for making a request on
  11831. * behalf of a specific user.
  11832. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  11833. * <li>json: Return raw json without converting to Parse.Object
  11834. * </ul>
  11835. * @returns {Promise} A promise that is resolved with the results when
  11836. * the query completes.
  11837. */
  11838. }, {
  11839. key: "find",
  11840. value: function (options /*:: ?: FullOptions*/) /*: Promise<Array<ParseObject>>*/{
  11841. var _this3 = this;
  11842. options = options || {};
  11843. var findOptions = {};
  11844. if (options.hasOwnProperty('useMasterKey')) {
  11845. findOptions.useMasterKey = options.useMasterKey;
  11846. }
  11847. if (options.hasOwnProperty('sessionToken')) {
  11848. findOptions.sessionToken = options.sessionToken;
  11849. }
  11850. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  11851. findOptions.context = options.context;
  11852. }
  11853. this._setRequestTask(findOptions);
  11854. var controller = _CoreManager.default.getQueryController();
  11855. var select = this._select;
  11856. if (this._queriesLocalDatastore) {
  11857. return this._handleOfflineQuery(this.toJSON());
  11858. }
  11859. return (0, _find.default)(controller).call(controller, this.className, this.toJSON(), findOptions).then(function (response) {
  11860. var _context5;
  11861. // Return generic object when explain is used
  11862. if (_this3._explain) {
  11863. return response.results;
  11864. }
  11865. var results = (0, _map2.default)(_context5 = response.results).call(_context5, function (data) {
  11866. // In cases of relations, the server may send back a className
  11867. // on the top level of the payload
  11868. var override = response.className || _this3.className;
  11869. if (!data.className) {
  11870. data.className = override;
  11871. }
  11872. // Make sure the data object contains keys for all objects that
  11873. // have been requested with a select, so that our cached state
  11874. // updates correctly.
  11875. if (select) {
  11876. handleSelectResult(data, select);
  11877. }
  11878. if (options.json) {
  11879. return data;
  11880. } else {
  11881. return _ParseObject.default.fromJSON(data, !select);
  11882. }
  11883. });
  11884. var count = response.count;
  11885. if (typeof count === 'number') {
  11886. return {
  11887. results: results,
  11888. count: count
  11889. };
  11890. } else {
  11891. return results;
  11892. }
  11893. });
  11894. }
  11895. /**
  11896. * Retrieves a complete list of ParseObjects that satisfy this query.
  11897. * Using `eachBatch` under the hood to fetch all the valid objects.
  11898. *
  11899. * @param {object} options Valid options are:<ul>
  11900. * <li>batchSize: How many objects to yield in each batch (default: 100)
  11901. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  11902. * be used for this request.
  11903. * <li>sessionToken: A valid session token, used for making a request on
  11904. * behalf of a specific user.
  11905. * </ul>
  11906. * @returns {Promise} A promise that is resolved with the results when
  11907. * the query completes.
  11908. */
  11909. }, {
  11910. key: "findAll",
  11911. value: function () {
  11912. var _findAll = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(options /*:: ?: BatchOptions*/) {
  11913. var result;
  11914. return _regenerator.default.wrap(function (_context7) {
  11915. while (1) switch (_context7.prev = _context7.next) {
  11916. case 0:
  11917. result /*: ParseObject[]*/ = [];
  11918. _context7.next = 3;
  11919. return this.eachBatch(function (objects /*: ParseObject[]*/) {
  11920. var _context6;
  11921. result = (0, _concat.default)(_context6 = []).call(_context6, (0, _toConsumableArray2.default)(result), (0, _toConsumableArray2.default)(objects));
  11922. }, options);
  11923. case 3:
  11924. return _context7.abrupt("return", result);
  11925. case 4:
  11926. case "end":
  11927. return _context7.stop();
  11928. }
  11929. }, _callee2, this);
  11930. }));
  11931. function findAll() {
  11932. return _findAll.apply(this, arguments);
  11933. }
  11934. return findAll;
  11935. }()
  11936. /**
  11937. * Counts the number of objects that match this query.
  11938. *
  11939. * @param {object} options
  11940. * Valid options are:<ul>
  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 count when
  11947. * the query completes.
  11948. */
  11949. }, {
  11950. key: "count",
  11951. value: function (options /*:: ?: FullOptions*/) /*: Promise<number>*/{
  11952. options = options || {};
  11953. var findOptions = {};
  11954. if (options.hasOwnProperty('useMasterKey')) {
  11955. findOptions.useMasterKey = options.useMasterKey;
  11956. }
  11957. if (options.hasOwnProperty('sessionToken')) {
  11958. findOptions.sessionToken = options.sessionToken;
  11959. }
  11960. this._setRequestTask(findOptions);
  11961. var controller = _CoreManager.default.getQueryController();
  11962. var params = this.toJSON();
  11963. params.limit = 0;
  11964. params.count = 1;
  11965. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(function (result) {
  11966. return result.count;
  11967. });
  11968. }
  11969. /**
  11970. * Executes a distinct query and returns unique values
  11971. *
  11972. * @param {string} key A field to find distinct values
  11973. * @param {object} options
  11974. * Valid options are:<ul>
  11975. * <li>sessionToken: A valid session token, used for making a request on
  11976. * behalf of a specific user.
  11977. * </ul>
  11978. * @returns {Promise} A promise that is resolved with the query completes.
  11979. */
  11980. }, {
  11981. key: "distinct",
  11982. value: function (key /*: string*/, options /*:: ?: FullOptions*/) /*: Promise<Array<mixed>>*/{
  11983. options = options || {};
  11984. var distinctOptions = {};
  11985. distinctOptions.useMasterKey = true;
  11986. if (options.hasOwnProperty('sessionToken')) {
  11987. distinctOptions.sessionToken = options.sessionToken;
  11988. }
  11989. this._setRequestTask(distinctOptions);
  11990. var controller = _CoreManager.default.getQueryController();
  11991. var params = {
  11992. distinct: key,
  11993. where: this._where,
  11994. hint: this._hint
  11995. };
  11996. return controller.aggregate(this.className, params, distinctOptions).then(function (results) {
  11997. return results.results;
  11998. });
  11999. }
  12000. /**
  12001. * Executes an aggregate query and returns aggregate results
  12002. *
  12003. * @param {(Array|object)} pipeline Array or Object of stages to process query
  12004. * @param {object} options Valid options are:<ul>
  12005. * <li>sessionToken: A valid session token, used for making a request on
  12006. * behalf of a specific user.
  12007. * </ul>
  12008. * @returns {Promise} A promise that is resolved with the query completes.
  12009. */
  12010. }, {
  12011. key: "aggregate",
  12012. value: function (pipeline /*: mixed*/, options /*:: ?: FullOptions*/) /*: Promise<Array<mixed>>*/{
  12013. options = options || {};
  12014. var aggregateOptions = {};
  12015. aggregateOptions.useMasterKey = true;
  12016. if (options.hasOwnProperty('sessionToken')) {
  12017. aggregateOptions.sessionToken = options.sessionToken;
  12018. }
  12019. this._setRequestTask(aggregateOptions);
  12020. var controller = _CoreManager.default.getQueryController();
  12021. if (!(0, _isArray.default)(pipeline) && (0, _typeof2.default)(pipeline) !== 'object') {
  12022. throw new Error('Invalid pipeline must be Array or Object');
  12023. }
  12024. if ((0, _keys.default)(this._where || {}).length) {
  12025. if (!(0, _isArray.default)(pipeline)) {
  12026. pipeline = [pipeline];
  12027. }
  12028. pipeline.unshift({
  12029. $match: this._where
  12030. });
  12031. }
  12032. var params = {
  12033. pipeline: pipeline,
  12034. hint: this._hint,
  12035. explain: this._explain,
  12036. readPreference: this._readPreference
  12037. };
  12038. return controller.aggregate(this.className, params, aggregateOptions).then(function (results) {
  12039. return results.results;
  12040. });
  12041. }
  12042. /**
  12043. * Retrieves at most one Parse.Object that satisfies this query.
  12044. *
  12045. * Returns the object if there is one, otherwise undefined.
  12046. *
  12047. * @param {object} options Valid options are:<ul>
  12048. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12049. * be used for this request.
  12050. * <li>sessionToken: A valid session token, used for making a request on
  12051. * behalf of a specific user.
  12052. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  12053. * <li>json: Return raw json without converting to Parse.Object
  12054. * </ul>
  12055. * @returns {Promise} A promise that is resolved with the object when
  12056. * the query completes.
  12057. */
  12058. }, {
  12059. key: "first",
  12060. value: function (options /*:: ?: FullOptions*/) /*: Promise<ParseObject | void>*/{
  12061. var _this4 = this;
  12062. options = options || {};
  12063. var findOptions = {};
  12064. if (options.hasOwnProperty('useMasterKey')) {
  12065. findOptions.useMasterKey = options.useMasterKey;
  12066. }
  12067. if (options.hasOwnProperty('sessionToken')) {
  12068. findOptions.sessionToken = options.sessionToken;
  12069. }
  12070. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  12071. findOptions.context = options.context;
  12072. }
  12073. this._setRequestTask(findOptions);
  12074. var controller = _CoreManager.default.getQueryController();
  12075. var params = this.toJSON();
  12076. params.limit = 1;
  12077. var select = this._select;
  12078. if (this._queriesLocalDatastore) {
  12079. return this._handleOfflineQuery(params).then(function (objects) {
  12080. if (!objects[0]) {
  12081. return undefined;
  12082. }
  12083. return objects[0];
  12084. });
  12085. }
  12086. return (0, _find.default)(controller).call(controller, this.className, params, findOptions).then(function (response) {
  12087. var objects = response.results;
  12088. if (!objects[0]) {
  12089. return undefined;
  12090. }
  12091. if (!objects[0].className) {
  12092. objects[0].className = _this4.className;
  12093. }
  12094. // Make sure the data object contains keys for all objects that
  12095. // have been requested with a select, so that our cached state
  12096. // updates correctly.
  12097. if (select) {
  12098. handleSelectResult(objects[0], select);
  12099. }
  12100. if (options.json) {
  12101. return objects[0];
  12102. } else {
  12103. return _ParseObject.default.fromJSON(objects[0], !select);
  12104. }
  12105. });
  12106. }
  12107. /**
  12108. * Iterates over objects matching a query, calling a callback for each batch.
  12109. * If the callback returns a promise, the iteration will not continue until
  12110. * that promise has been fulfilled. If the callback returns a rejected
  12111. * promise, then iteration will stop with that error. The items are processed
  12112. * in an unspecified order. The query may not have any sort order, and may
  12113. * not use limit or skip.
  12114. *
  12115. * @param {Function} callback Callback that will be called with each result
  12116. * of the query.
  12117. * @param {object} options Valid options are:<ul>
  12118. * <li>batchSize: How many objects to yield in each batch (default: 100)
  12119. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12120. * be used for this request.
  12121. * <li>sessionToken: A valid session token, used for making a request on
  12122. * behalf of a specific user.
  12123. * <li>context: A dictionary that is accessible in Cloud Code `beforeFind` trigger.
  12124. * </ul>
  12125. * @returns {Promise} A promise that will be fulfilled once the
  12126. * iteration has completed.
  12127. */
  12128. }, {
  12129. key: "eachBatch",
  12130. value: function (callback /*: (objs: Array<ParseObject>) => Promise<*>*/, options /*:: ?: BatchOptions*/) /*: Promise<void>*/{
  12131. var _context8;
  12132. options = options || {};
  12133. if (this._order || this._skip || this._limit >= 0) {
  12134. return _promise.default.reject('Cannot iterate on a query with sort, skip, or limit.');
  12135. }
  12136. var query = new ParseQuery(this.className);
  12137. query._limit = options.batchSize || 100;
  12138. query._include = (0, _map2.default)(_context8 = this._include).call(_context8, function (i) {
  12139. return i;
  12140. });
  12141. if (this._select) {
  12142. var _context9;
  12143. query._select = (0, _map2.default)(_context9 = this._select).call(_context9, function (s) {
  12144. return s;
  12145. });
  12146. }
  12147. query._hint = this._hint;
  12148. query._where = {};
  12149. for (var _attr in this._where) {
  12150. var val = this._where[_attr];
  12151. if ((0, _isArray.default)(val)) {
  12152. query._where[_attr] = (0, _map2.default)(val).call(val, function (v) {
  12153. return v;
  12154. });
  12155. } else if (val && (0, _typeof2.default)(val) === 'object') {
  12156. var conditionMap = {};
  12157. query._where[_attr] = conditionMap;
  12158. for (var cond in val) {
  12159. conditionMap[cond] = val[cond];
  12160. }
  12161. } else {
  12162. query._where[_attr] = val;
  12163. }
  12164. }
  12165. query.ascending('objectId');
  12166. var findOptions = {};
  12167. if (options.hasOwnProperty('useMasterKey')) {
  12168. findOptions.useMasterKey = options.useMasterKey;
  12169. }
  12170. if (options.hasOwnProperty('sessionToken')) {
  12171. findOptions.sessionToken = options.sessionToken;
  12172. }
  12173. if (options.hasOwnProperty('context') && (0, _typeof2.default)(options.context) === 'object') {
  12174. findOptions.context = options.context;
  12175. }
  12176. if (options.hasOwnProperty('json')) {
  12177. findOptions.json = options.json;
  12178. }
  12179. var finished = false;
  12180. var previousResults = [];
  12181. return (0, _promiseUtils.continueWhile)(function () {
  12182. return !finished;
  12183. }, /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  12184. var _yield$Promise$all, _yield$Promise$all2, results;
  12185. return _regenerator.default.wrap(function (_context10) {
  12186. while (1) switch (_context10.prev = _context10.next) {
  12187. case 0:
  12188. _context10.next = 2;
  12189. return _promise.default.all([(0, _find.default)(query).call(query, findOptions), _promise.default.resolve(previousResults.length > 0 && callback(previousResults))]);
  12190. case 2:
  12191. _yield$Promise$all = _context10.sent;
  12192. _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1);
  12193. results = _yield$Promise$all2[0];
  12194. if (!(results.length >= query._limit)) {
  12195. _context10.next = 10;
  12196. break;
  12197. }
  12198. query.greaterThan('objectId', results[results.length - 1].id);
  12199. previousResults = results;
  12200. _context10.next = 17;
  12201. break;
  12202. case 10:
  12203. if (!(results.length > 0)) {
  12204. _context10.next = 16;
  12205. break;
  12206. }
  12207. _context10.next = 13;
  12208. return _promise.default.resolve(callback(results));
  12209. case 13:
  12210. finished = true;
  12211. _context10.next = 17;
  12212. break;
  12213. case 16:
  12214. finished = true;
  12215. case 17:
  12216. case "end":
  12217. return _context10.stop();
  12218. }
  12219. }, _callee3);
  12220. })));
  12221. }
  12222. /**
  12223. * Iterates over each result of a query, calling a callback for each one. If
  12224. * the callback returns a promise, the iteration will not continue until
  12225. * that promise has been fulfilled. If the callback returns a rejected
  12226. * promise, then iteration will stop with that error. The items are
  12227. * processed in an unspecified order. The query may not have any sort order,
  12228. * and may not use limit or skip.
  12229. *
  12230. * @param {Function} callback Callback that will be called with each result
  12231. * of the query.
  12232. * @param {object} options Valid options are:<ul>
  12233. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12234. * be used for this request.
  12235. * <li>sessionToken: A valid session token, used for making a request on
  12236. * behalf of a specific user.
  12237. * <li>json: Return raw json without converting to Parse.Object
  12238. * </ul>
  12239. * @returns {Promise} A promise that will be fulfilled once the
  12240. * iteration has completed.
  12241. */
  12242. }, {
  12243. key: "each",
  12244. value: function (callback /*: (obj: ParseObject) => any*/, options /*:: ?: BatchOptions*/) /*: Promise<void>*/{
  12245. return this.eachBatch(function (results) {
  12246. var callbacksDone = _promise.default.resolve();
  12247. (0, _forEach.default)(results).call(results, function (result) {
  12248. callbacksDone = callbacksDone.then(function () {
  12249. return callback(result);
  12250. });
  12251. });
  12252. return callbacksDone;
  12253. }, options);
  12254. }
  12255. /**
  12256. * Adds a hint to force index selection. (https://docs.mongodb.com/manual/reference/operator/meta/hint/)
  12257. *
  12258. * @param {(string|object)} value String or Object of index that should be used when executing query
  12259. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12260. */
  12261. }, {
  12262. key: "hint",
  12263. value: function (value /*: mixed*/) /*: ParseQuery*/{
  12264. if (typeof value === 'undefined') {
  12265. delete this._hint;
  12266. }
  12267. this._hint = value;
  12268. return this;
  12269. }
  12270. /**
  12271. * Investigates the query execution plan. Useful for optimizing queries. (https://docs.mongodb.com/manual/reference/operator/meta/explain/)
  12272. *
  12273. * @param {boolean} explain Used to toggle the information on the query plan.
  12274. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12275. */
  12276. }, {
  12277. key: "explain",
  12278. value: function () /*: ParseQuery*/{
  12279. var _explain /*: boolean*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  12280. if (typeof _explain !== 'boolean') {
  12281. throw new Error('You can only set explain to a boolean value');
  12282. }
  12283. this._explain = _explain;
  12284. return this;
  12285. }
  12286. /**
  12287. * Iterates over each result of a query, calling a callback for each one. If
  12288. * the callback returns a promise, the iteration will not continue until
  12289. * that promise has been fulfilled. If the callback returns a rejected
  12290. * promise, then iteration will stop with that error. The items are
  12291. * processed in an unspecified order. The query may not have any sort order,
  12292. * and may not use limit or skip.
  12293. *
  12294. * @param {Function} callback Callback <ul>
  12295. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  12296. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  12297. * <li>query: The query map was called upon.</li>
  12298. * </ul>
  12299. * @param {object} options Valid options are:<ul>
  12300. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12301. * be used for this request.
  12302. * <li>sessionToken: A valid session token, used for making a request on
  12303. * behalf of a specific user.
  12304. * </ul>
  12305. * @returns {Promise} A promise that will be fulfilled once the
  12306. * iteration has completed.
  12307. */
  12308. }, {
  12309. key: "map",
  12310. value: function () {
  12311. var _map = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(callback /*: (currentObject: ParseObject, index: number, query: ParseQuery) => any*/, options /*:: ?: BatchOptions*/) {
  12312. var _this5 = this;
  12313. var array, index;
  12314. return _regenerator.default.wrap(function (_context11) {
  12315. while (1) switch (_context11.prev = _context11.next) {
  12316. case 0:
  12317. array = [];
  12318. index = 0;
  12319. _context11.next = 4;
  12320. return this.each(function (object) {
  12321. return _promise.default.resolve(callback(object, index, _this5)).then(function (result) {
  12322. array.push(result);
  12323. index += 1;
  12324. });
  12325. }, options);
  12326. case 4:
  12327. return _context11.abrupt("return", array);
  12328. case 5:
  12329. case "end":
  12330. return _context11.stop();
  12331. }
  12332. }, _callee4, this);
  12333. }));
  12334. function map() {
  12335. return _map.apply(this, arguments);
  12336. }
  12337. return map;
  12338. }()
  12339. /**
  12340. * Iterates over each result of a query, calling a callback for each one. If
  12341. * the callback returns a promise, the iteration will not continue until
  12342. * that promise has been fulfilled. If the callback returns a rejected
  12343. * promise, then iteration will stop with that error. The items are
  12344. * processed in an unspecified order. The query may not have any sort order,
  12345. * and may not use limit or skip.
  12346. *
  12347. * @param {Function} callback Callback <ul>
  12348. * <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>
  12349. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  12350. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  12351. * </ul>
  12352. * @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.
  12353. * @param {object} options Valid options are:<ul>
  12354. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12355. * be used for this request.
  12356. * <li>sessionToken: A valid session token, used for making a request on
  12357. * behalf of a specific user.
  12358. * </ul>
  12359. * @returns {Promise} A promise that will be fulfilled once the
  12360. * iteration has completed.
  12361. */
  12362. }, {
  12363. key: "reduce",
  12364. value: function () {
  12365. var _reduce = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(callback /*: (accumulator: any, currentObject: ParseObject, index: number) => any*/, initialValue /*: any*/, options /*:: ?: BatchOptions*/) {
  12366. var accumulator, index;
  12367. return _regenerator.default.wrap(function (_context12) {
  12368. while (1) switch (_context12.prev = _context12.next) {
  12369. case 0:
  12370. accumulator = initialValue;
  12371. index = 0;
  12372. _context12.next = 4;
  12373. return this.each(function (object) {
  12374. // If no initial value was given, we take the first object from the query
  12375. // as the initial value and don't call the callback with it.
  12376. if (index === 0 && initialValue === undefined) {
  12377. accumulator = object;
  12378. index += 1;
  12379. return;
  12380. }
  12381. return _promise.default.resolve(callback(accumulator, object, index)).then(function (result) {
  12382. accumulator = result;
  12383. index += 1;
  12384. });
  12385. }, options);
  12386. case 4:
  12387. if (!(index === 0 && initialValue === undefined)) {
  12388. _context12.next = 6;
  12389. break;
  12390. }
  12391. throw new TypeError('Reducing empty query result set with no initial value');
  12392. case 6:
  12393. return _context12.abrupt("return", accumulator);
  12394. case 7:
  12395. case "end":
  12396. return _context12.stop();
  12397. }
  12398. }, _callee5, this);
  12399. }));
  12400. function reduce() {
  12401. return _reduce.apply(this, arguments);
  12402. }
  12403. return reduce;
  12404. }()
  12405. /**
  12406. * Iterates over each result of a query, calling a callback for each one. If
  12407. * the callback returns a promise, the iteration will not continue until
  12408. * that promise has been fulfilled. If the callback returns a rejected
  12409. * promise, then iteration will stop with that error. The items are
  12410. * processed in an unspecified order. The query may not have any sort order,
  12411. * and may not use limit or skip.
  12412. *
  12413. * @param {Function} callback Callback <ul>
  12414. * <li>currentObject: The current Parse.Object being processed in the array.</li>
  12415. * <li>index: The index of the current Parse.Object being processed in the array.</li>
  12416. * <li>query: The query filter was called upon.</li>
  12417. * </ul>
  12418. * @param {object} options Valid options are:<ul>
  12419. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  12420. * be used for this request.
  12421. * <li>sessionToken: A valid session token, used for making a request on
  12422. * behalf of a specific user.
  12423. * </ul>
  12424. * @returns {Promise} A promise that will be fulfilled once the
  12425. * iteration has completed.
  12426. */
  12427. }, {
  12428. key: "filter",
  12429. value: function () {
  12430. var _filter = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(callback /*: (currentObject: ParseObject, index: number, query: ParseQuery) => boolean*/, options /*:: ?: BatchOptions*/) {
  12431. var _this6 = this;
  12432. var array, index;
  12433. return _regenerator.default.wrap(function (_context13) {
  12434. while (1) switch (_context13.prev = _context13.next) {
  12435. case 0:
  12436. array = [];
  12437. index = 0;
  12438. _context13.next = 4;
  12439. return this.each(function (object) {
  12440. return _promise.default.resolve(callback(object, index, _this6)).then(function (flag) {
  12441. if (flag) {
  12442. array.push(object);
  12443. }
  12444. index += 1;
  12445. });
  12446. }, options);
  12447. case 4:
  12448. return _context13.abrupt("return", array);
  12449. case 5:
  12450. case "end":
  12451. return _context13.stop();
  12452. }
  12453. }, _callee6, this);
  12454. }));
  12455. function filter() {
  12456. return _filter.apply(this, arguments);
  12457. }
  12458. return filter;
  12459. }()
  12460. /* Query Conditions */
  12461. /**
  12462. * Adds a constraint to the query that requires a particular key's value to
  12463. * be equal to the provided value.
  12464. *
  12465. * @param {string} key The key to check.
  12466. * @param value The value that the Parse.Object must contain.
  12467. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12468. */
  12469. }, {
  12470. key: "equalTo",
  12471. value: function (key /*: string | { [key: string]: any }*/, value /*: ?mixed*/) /*: ParseQuery*/{
  12472. var _this7 = this;
  12473. if (key && (0, _typeof2.default)(key) === 'object') {
  12474. var _context14;
  12475. (0, _forEach.default)(_context14 = (0, _entries.default)(key)).call(_context14, function (_ref2) {
  12476. var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
  12477. k = _ref3[0],
  12478. val = _ref3[1];
  12479. return _this7.equalTo(k, val);
  12480. });
  12481. return this;
  12482. }
  12483. if (typeof value === 'undefined') {
  12484. return this.doesNotExist(key);
  12485. }
  12486. this._where[key] = (0, _encode.default)(value, false, true);
  12487. return this;
  12488. }
  12489. /**
  12490. * Adds a constraint to the query that requires a particular key's value to
  12491. * be not equal to the provided value.
  12492. *
  12493. * @param {string} key The key to check.
  12494. * @param value The value that must not be equalled.
  12495. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12496. */
  12497. }, {
  12498. key: "notEqualTo",
  12499. value: function (key /*: string | { [key: string]: any }*/, value /*: ?mixed*/) /*: ParseQuery*/{
  12500. var _this8 = this;
  12501. if (key && (0, _typeof2.default)(key) === 'object') {
  12502. var _context15;
  12503. (0, _forEach.default)(_context15 = (0, _entries.default)(key)).call(_context15, function (_ref4) {
  12504. var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
  12505. k = _ref5[0],
  12506. val = _ref5[1];
  12507. return _this8.notEqualTo(k, val);
  12508. });
  12509. return this;
  12510. }
  12511. return this._addCondition(key, '$ne', value);
  12512. }
  12513. /**
  12514. * Adds a constraint to the query that requires a particular key's value to
  12515. * be less than the provided value.
  12516. *
  12517. * @param {string} key The key to check.
  12518. * @param value The value that provides an upper bound.
  12519. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12520. */
  12521. }, {
  12522. key: "lessThan",
  12523. value: function (key /*: string*/, value /*: mixed*/) /*: ParseQuery*/{
  12524. return this._addCondition(key, '$lt', value);
  12525. }
  12526. /**
  12527. * Adds a constraint to the query that requires a particular key's value to
  12528. * be greater than the provided value.
  12529. *
  12530. * @param {string} key The key to check.
  12531. * @param value The value that provides an lower bound.
  12532. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12533. */
  12534. }, {
  12535. key: "greaterThan",
  12536. value: function (key /*: string*/, value /*: mixed*/) /*: ParseQuery*/{
  12537. return this._addCondition(key, '$gt', value);
  12538. }
  12539. /**
  12540. * Adds a constraint to the query that requires a particular key's value to
  12541. * be less than or equal to the provided value.
  12542. *
  12543. * @param {string} key The key to check.
  12544. * @param value The value that provides an upper bound.
  12545. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12546. */
  12547. }, {
  12548. key: "lessThanOrEqualTo",
  12549. value: function (key /*: string*/, value /*: mixed*/) /*: ParseQuery*/{
  12550. return this._addCondition(key, '$lte', value);
  12551. }
  12552. /**
  12553. * Adds a constraint to the query that requires a particular key's value to
  12554. * be greater than or equal to the provided value.
  12555. *
  12556. * @param {string} key The key to check.
  12557. * @param {*} value The value that provides an lower bound.
  12558. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12559. */
  12560. }, {
  12561. key: "greaterThanOrEqualTo",
  12562. value: function (key /*: string*/, value /*: mixed*/) /*: ParseQuery*/{
  12563. return this._addCondition(key, '$gte', value);
  12564. }
  12565. /**
  12566. * Adds a constraint to the query that requires a particular key's value to
  12567. * be contained in the provided list of values.
  12568. *
  12569. * @param {string} key The key to check.
  12570. * @param {Array<*>} value The values that will match.
  12571. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12572. */
  12573. }, {
  12574. key: "containedIn",
  12575. value: function (key /*: string*/, value /*: Array<mixed>*/) /*: ParseQuery*/{
  12576. return this._addCondition(key, '$in', value);
  12577. }
  12578. /**
  12579. * Adds a constraint to the query that requires a particular key's value to
  12580. * not be contained in the provided list of values.
  12581. *
  12582. * @param {string} key The key to check.
  12583. * @param {Array<*>} value The values that will not match.
  12584. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12585. */
  12586. }, {
  12587. key: "notContainedIn",
  12588. value: function (key /*: string*/, value /*: Array<mixed>*/) /*: ParseQuery*/{
  12589. return this._addCondition(key, '$nin', value);
  12590. }
  12591. /**
  12592. * Adds a constraint to the query that requires a particular key's value to
  12593. * be contained by the provided list of values. Get objects where all array elements match.
  12594. *
  12595. * @param {string} key The key to check.
  12596. * @param {Array} values The values that will match.
  12597. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12598. */
  12599. }, {
  12600. key: "containedBy",
  12601. value: function (key /*: string*/, values /*: Array<mixed>*/) /*: ParseQuery*/{
  12602. return this._addCondition(key, '$containedBy', values);
  12603. }
  12604. /**
  12605. * Adds a constraint to the query that requires a particular key's value to
  12606. * contain each one of the provided list of values.
  12607. *
  12608. * @param {string} key The key to check. This key's value must be an array.
  12609. * @param {Array} values The values that will match.
  12610. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12611. */
  12612. }, {
  12613. key: "containsAll",
  12614. value: function (key /*: string*/, values /*: Array<mixed>*/) /*: ParseQuery*/{
  12615. return this._addCondition(key, '$all', values);
  12616. }
  12617. /**
  12618. * Adds a constraint to the query that requires a particular key's value to
  12619. * contain each one of the provided list of values starting with given strings.
  12620. *
  12621. * @param {string} key The key to check. This key's value must be an array.
  12622. * @param {Array<string>} values The string values that will match as starting string.
  12623. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12624. */
  12625. }, {
  12626. key: "containsAllStartingWith",
  12627. value: function (key /*: string*/, values /*: Array<string>*/) /*: ParseQuery*/{
  12628. var _this = this;
  12629. if (!(0, _isArray.default)(values)) {
  12630. values = [values];
  12631. }
  12632. var regexObject = (0, _map2.default)(values).call(values, function (value) {
  12633. return {
  12634. $regex: _this._regexStartWith(value)
  12635. };
  12636. });
  12637. return this.containsAll(key, regexObject);
  12638. }
  12639. /**
  12640. * Adds a constraint for finding objects that contain the given key.
  12641. *
  12642. * @param {string} key The key that should exist.
  12643. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12644. */
  12645. }, {
  12646. key: "exists",
  12647. value: function (key /*: string*/) /*: ParseQuery*/{
  12648. return this._addCondition(key, '$exists', true);
  12649. }
  12650. /**
  12651. * Adds a constraint for finding objects that do not contain a given key.
  12652. *
  12653. * @param {string} key The key that should not exist
  12654. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12655. */
  12656. }, {
  12657. key: "doesNotExist",
  12658. value: function (key /*: string*/) /*: ParseQuery*/{
  12659. return this._addCondition(key, '$exists', false);
  12660. }
  12661. /**
  12662. * Adds a regular expression constraint for finding string values that match
  12663. * the provided regular expression.
  12664. * This may be slow for large datasets.
  12665. *
  12666. * @param {string} key The key that the string to match is stored in.
  12667. * @param {RegExp} regex The regular expression pattern to match.
  12668. * @param {string} modifiers The regular expression mode.
  12669. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12670. */
  12671. }, {
  12672. key: "matches",
  12673. value: function (key /*: string*/, regex /*: RegExp*/, modifiers /*: string*/) /*: ParseQuery*/{
  12674. this._addCondition(key, '$regex', regex);
  12675. if (!modifiers) {
  12676. modifiers = '';
  12677. }
  12678. if (regex.ignoreCase) {
  12679. modifiers += 'i';
  12680. }
  12681. if (regex.multiline) {
  12682. modifiers += 'm';
  12683. }
  12684. if (modifiers.length) {
  12685. this._addCondition(key, '$options', modifiers);
  12686. }
  12687. return this;
  12688. }
  12689. /**
  12690. * Adds a constraint that requires that a key's value matches a Parse.Query
  12691. * constraint.
  12692. *
  12693. * @param {string} key The key that the contains the object to match the
  12694. * query.
  12695. * @param {Parse.Query} query The query that should match.
  12696. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12697. */
  12698. }, {
  12699. key: "matchesQuery",
  12700. value: function (key /*: string*/, query /*: ParseQuery*/) /*: ParseQuery*/{
  12701. var queryJSON = query.toJSON();
  12702. queryJSON.className = query.className;
  12703. return this._addCondition(key, '$inQuery', queryJSON);
  12704. }
  12705. /**
  12706. * Adds a constraint that requires that a key's value not matches a
  12707. * Parse.Query constraint.
  12708. *
  12709. * @param {string} key The key that the contains the object to match the
  12710. * query.
  12711. * @param {Parse.Query} query The query that should not match.
  12712. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12713. */
  12714. }, {
  12715. key: "doesNotMatchQuery",
  12716. value: function (key /*: string*/, query /*: ParseQuery*/) /*: ParseQuery*/{
  12717. var queryJSON = query.toJSON();
  12718. queryJSON.className = query.className;
  12719. return this._addCondition(key, '$notInQuery', queryJSON);
  12720. }
  12721. /**
  12722. * Adds a constraint that requires that a key's value matches a value in
  12723. * an object returned by a different Parse.Query.
  12724. *
  12725. * @param {string} key The key that contains the value that is being
  12726. * matched.
  12727. * @param {string} queryKey The key in the objects returned by the query to
  12728. * match against.
  12729. * @param {Parse.Query} query The query to run.
  12730. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12731. */
  12732. }, {
  12733. key: "matchesKeyInQuery",
  12734. value: function (key /*: string*/, queryKey /*: string*/, query /*: ParseQuery*/) /*: ParseQuery*/{
  12735. var queryJSON = query.toJSON();
  12736. queryJSON.className = query.className;
  12737. return this._addCondition(key, '$select', {
  12738. key: queryKey,
  12739. query: queryJSON
  12740. });
  12741. }
  12742. /**
  12743. * Adds a constraint that requires that a key's value not match a value in
  12744. * an object returned by a different Parse.Query.
  12745. *
  12746. * @param {string} key The key that contains the value that is being
  12747. * excluded.
  12748. * @param {string} queryKey The key in the objects returned by the query to
  12749. * match against.
  12750. * @param {Parse.Query} query The query to run.
  12751. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12752. */
  12753. }, {
  12754. key: "doesNotMatchKeyInQuery",
  12755. value: function (key /*: string*/, queryKey /*: string*/, query /*: ParseQuery*/) /*: ParseQuery*/{
  12756. var queryJSON = query.toJSON();
  12757. queryJSON.className = query.className;
  12758. return this._addCondition(key, '$dontSelect', {
  12759. key: queryKey,
  12760. query: queryJSON
  12761. });
  12762. }
  12763. /**
  12764. * Adds a constraint for finding string values that contain a provided
  12765. * string. This may be slow for large datasets.
  12766. *
  12767. * @param {string} key The key that the string to match is stored in.
  12768. * @param {string} substring The substring that the value must contain.
  12769. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12770. */
  12771. }, {
  12772. key: "contains",
  12773. value: function (key /*: string*/, substring /*: string*/) /*: ParseQuery*/{
  12774. if (typeof substring !== 'string') {
  12775. throw new Error('The value being searched for must be a string.');
  12776. }
  12777. return this._addCondition(key, '$regex', quote(substring));
  12778. }
  12779. /**
  12780. * Adds a constraint for finding string values that contain a provided
  12781. * string. This may be slow for large datasets. Requires Parse-Server > 2.5.0
  12782. *
  12783. * In order to sort you must use select and ascending ($score is required)
  12784. * <pre>
  12785. * query.fullText('field', 'term');
  12786. * query.ascending('$score');
  12787. * query.select('$score');
  12788. * </pre>
  12789. *
  12790. * To retrieve the weight / rank
  12791. * <pre>
  12792. * object->get('score');
  12793. * </pre>
  12794. *
  12795. * You can define optionals by providing an object as a third parameter
  12796. * <pre>
  12797. * query.fullText('field', 'term', { language: 'es', diacriticSensitive: true });
  12798. * </pre>
  12799. *
  12800. * @param {string} key The key that the string to match is stored in.
  12801. * @param {string} value The string to search
  12802. * @param {object} options (Optional)
  12803. * @param {string} options.language The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer.
  12804. * @param {boolean} options.caseSensitive A boolean flag to enable or disable case sensitive search.
  12805. * @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search.
  12806. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12807. */
  12808. }, {
  12809. key: "fullText",
  12810. value: function (key /*: string*/, value /*: string*/, options /*: ?Object*/) /*: ParseQuery*/{
  12811. options = options || {};
  12812. if (!key) {
  12813. throw new Error('A key is required.');
  12814. }
  12815. if (!value) {
  12816. throw new Error('A search term is required');
  12817. }
  12818. if (typeof value !== 'string') {
  12819. throw new Error('The value being searched for must be a string.');
  12820. }
  12821. var fullOptions = {};
  12822. fullOptions.$term = value;
  12823. for (var option in options) {
  12824. switch (option) {
  12825. case 'language':
  12826. fullOptions.$language = options[option];
  12827. break;
  12828. case 'caseSensitive':
  12829. fullOptions.$caseSensitive = options[option];
  12830. break;
  12831. case 'diacriticSensitive':
  12832. fullOptions.$diacriticSensitive = options[option];
  12833. break;
  12834. default:
  12835. throw new Error("Unknown option: ".concat(option));
  12836. }
  12837. }
  12838. return this._addCondition(key, '$text', {
  12839. $search: fullOptions
  12840. });
  12841. }
  12842. /**
  12843. * Method to sort the full text search by text score
  12844. *
  12845. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12846. */
  12847. }, {
  12848. key: "sortByTextScore",
  12849. value: function () {
  12850. this.ascending('$score');
  12851. this.select(['$score']);
  12852. return this;
  12853. }
  12854. /**
  12855. * Adds a constraint for finding string values that start with a provided
  12856. * string. This query will use the backend index, so it will be fast even
  12857. * for large datasets.
  12858. *
  12859. * @param {string} key The key that the string to match is stored in.
  12860. * @param {string} prefix The substring that the value must start with.
  12861. * @param {string} modifiers The regular expression mode.
  12862. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12863. */
  12864. }, {
  12865. key: "startsWith",
  12866. value: function (key /*: string*/, prefix /*: string*/, modifiers /*: string*/) /*: ParseQuery*/{
  12867. if (typeof prefix !== 'string') {
  12868. throw new Error('The value being searched for must be a string.');
  12869. }
  12870. return this.matches(key, this._regexStartWith(prefix), modifiers);
  12871. }
  12872. /**
  12873. * Adds a constraint for finding string values that end with a provided
  12874. * string. This will be slow for large datasets.
  12875. *
  12876. * @param {string} key The key that the string to match is stored in.
  12877. * @param {string} suffix The substring that the value must end with.
  12878. * @param {string} modifiers The regular expression mode.
  12879. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12880. */
  12881. }, {
  12882. key: "endsWith",
  12883. value: function (key /*: string*/, suffix /*: string*/, modifiers /*: string*/) /*: ParseQuery*/{
  12884. if (typeof suffix !== 'string') {
  12885. throw new Error('The value being searched for must be a string.');
  12886. }
  12887. return this.matches(key, quote(suffix) + '$', modifiers);
  12888. }
  12889. /**
  12890. * Adds a proximity based constraint for finding objects with key point
  12891. * values near the point given.
  12892. *
  12893. * @param {string} key The key that the Parse.GeoPoint is stored in.
  12894. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  12895. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12896. */
  12897. }, {
  12898. key: "near",
  12899. value: function (key /*: string*/, point /*: ParseGeoPoint*/) /*: ParseQuery*/{
  12900. if (!(point instanceof _ParseGeoPoint.default)) {
  12901. // Try to cast it as a GeoPoint
  12902. point = new _ParseGeoPoint.default(point);
  12903. }
  12904. return this._addCondition(key, '$nearSphere', point);
  12905. }
  12906. /**
  12907. * Adds a proximity based constraint for finding objects with key point
  12908. * values near the point given and within the maximum distance given.
  12909. *
  12910. * @param {string} key The key that the Parse.GeoPoint is stored in.
  12911. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  12912. * @param {number} maxDistance Maximum distance (in radians) of results to return.
  12913. * @param {boolean} sorted A Bool value that is true if results should be
  12914. * sorted by distance ascending, false is no sorting is required,
  12915. * defaults to true.
  12916. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12917. */
  12918. }, {
  12919. key: "withinRadians",
  12920. value: function (key /*: string*/, point /*: ParseGeoPoint*/, maxDistance /*: number*/, sorted /*: boolean*/) /*: ParseQuery*/{
  12921. if (sorted || sorted === undefined) {
  12922. this.near(key, point);
  12923. return this._addCondition(key, '$maxDistance', maxDistance);
  12924. } else {
  12925. return this._addCondition(key, '$geoWithin', {
  12926. $centerSphere: [[point.longitude, point.latitude], maxDistance]
  12927. });
  12928. }
  12929. }
  12930. /**
  12931. * Adds a proximity based constraint for finding objects with key point
  12932. * values near the point given and within the maximum distance given.
  12933. * Radius of earth used is 3958.8 miles.
  12934. *
  12935. * @param {string} key The key that the Parse.GeoPoint is stored in.
  12936. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  12937. * @param {number} maxDistance Maximum distance (in miles) of results to return.
  12938. * @param {boolean} sorted A Bool value that is true if results should be
  12939. * sorted by distance ascending, false is no sorting is required,
  12940. * defaults to true.
  12941. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12942. */
  12943. }, {
  12944. key: "withinMiles",
  12945. value: function (key /*: string*/, point /*: ParseGeoPoint*/, maxDistance /*: number*/, sorted /*: boolean*/) /*: ParseQuery*/{
  12946. return this.withinRadians(key, point, maxDistance / 3958.8, sorted);
  12947. }
  12948. /**
  12949. * Adds a proximity based constraint for finding objects with key point
  12950. * values near the point given and within the maximum distance given.
  12951. * Radius of earth used is 6371.0 kilometers.
  12952. *
  12953. * @param {string} key The key that the Parse.GeoPoint is stored in.
  12954. * @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
  12955. * @param {number} maxDistance Maximum distance (in kilometers) of results to return.
  12956. * @param {boolean} sorted A Bool value that is true if results should be
  12957. * sorted by distance ascending, false is no sorting is required,
  12958. * defaults to true.
  12959. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12960. */
  12961. }, {
  12962. key: "withinKilometers",
  12963. value: function (key /*: string*/, point /*: ParseGeoPoint*/, maxDistance /*: number*/, sorted /*: boolean*/) /*: ParseQuery*/{
  12964. return this.withinRadians(key, point, maxDistance / 6371.0, sorted);
  12965. }
  12966. /**
  12967. * Adds a constraint to the query that requires a particular key's
  12968. * coordinates be contained within a given rectangular geographic bounding
  12969. * box.
  12970. *
  12971. * @param {string} key The key to be constrained.
  12972. * @param {Parse.GeoPoint} southwest
  12973. * The lower-left inclusive corner of the box.
  12974. * @param {Parse.GeoPoint} northeast
  12975. * The upper-right inclusive corner of the box.
  12976. * @returns {Parse.Query} Returns the query, so you can chain this call.
  12977. */
  12978. }, {
  12979. key: "withinGeoBox",
  12980. value: function (key /*: string*/, southwest /*: ParseGeoPoint*/, northeast /*: ParseGeoPoint*/) /*: ParseQuery*/{
  12981. if (!(southwest instanceof _ParseGeoPoint.default)) {
  12982. southwest = new _ParseGeoPoint.default(southwest);
  12983. }
  12984. if (!(northeast instanceof _ParseGeoPoint.default)) {
  12985. northeast = new _ParseGeoPoint.default(northeast);
  12986. }
  12987. this._addCondition(key, '$within', {
  12988. $box: [southwest, northeast]
  12989. });
  12990. return this;
  12991. }
  12992. /**
  12993. * Adds a constraint to the query that requires a particular key's
  12994. * coordinates be contained within and on the bounds of a given polygon.
  12995. * Supports closed and open (last point is connected to first) paths
  12996. *
  12997. * Polygon must have at least 3 points
  12998. *
  12999. * @param {string} key The key to be constrained.
  13000. * @param {Array} points Array of Coordinates / GeoPoints
  13001. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13002. */
  13003. }, {
  13004. key: "withinPolygon",
  13005. value: function (key /*: string*/, points /*: Array<Array<number>>*/) /*: ParseQuery*/{
  13006. return this._addCondition(key, '$geoWithin', {
  13007. $polygon: points
  13008. });
  13009. }
  13010. /**
  13011. * Add a constraint to the query that requires a particular key's
  13012. * coordinates that contains a ParseGeoPoint
  13013. *
  13014. * @param {string} key The key to be constrained.
  13015. * @param {Parse.GeoPoint} point
  13016. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13017. */
  13018. }, {
  13019. key: "polygonContains",
  13020. value: function (key /*: string*/, point /*: ParseGeoPoint*/) /*: ParseQuery*/{
  13021. return this._addCondition(key, '$geoIntersects', {
  13022. $point: point
  13023. });
  13024. }
  13025. /* Query Orderings */
  13026. /**
  13027. * Sorts the results in ascending order by the given key.
  13028. *
  13029. * @param {(string|string[])} keys The key to order by, which is a
  13030. * string of comma separated values, or an Array of keys, or multiple keys.
  13031. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13032. */
  13033. }, {
  13034. key: "ascending",
  13035. value: function () /*: ParseQuery*/{
  13036. this._order = [];
  13037. for (var _len = arguments.length, keys = new Array(_len), _key5 = 0; _key5 < _len; _key5++) {
  13038. keys[_key5] = arguments[_key5];
  13039. }
  13040. return this.addAscending.apply(this, keys);
  13041. }
  13042. /**
  13043. * Sorts the results in ascending order by the given key,
  13044. * but can also add secondary sort descriptors without overwriting _order.
  13045. *
  13046. * @param {(string|string[])} keys The key to order by, which is a
  13047. * string of comma separated values, or an Array of keys, or multiple keys.
  13048. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13049. */
  13050. }, {
  13051. key: "addAscending",
  13052. value: function () /*: ParseQuery*/{
  13053. var _this9 = this;
  13054. if (!this._order) {
  13055. this._order = [];
  13056. }
  13057. for (var _len2 = arguments.length, keys = new Array(_len2), _key6 = 0; _key6 < _len2; _key6++) {
  13058. keys[_key6] = arguments[_key6];
  13059. }
  13060. (0, _forEach.default)(keys).call(keys, function (key) {
  13061. var _context16;
  13062. if ((0, _isArray.default)(key)) {
  13063. key = key.join();
  13064. }
  13065. _this9._order = (0, _concat.default)(_context16 = _this9._order).call(_context16, key.replace(/\s/g, '').split(','));
  13066. });
  13067. return this;
  13068. }
  13069. /**
  13070. * Sorts the results in descending order by the given key.
  13071. *
  13072. * @param {(string|string[])} keys The key to order by, which is a
  13073. * string of comma separated values, or an Array of keys, or multiple keys.
  13074. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13075. */
  13076. }, {
  13077. key: "descending",
  13078. value: function () /*: ParseQuery*/{
  13079. this._order = [];
  13080. for (var _len3 = arguments.length, keys = new Array(_len3), _key7 = 0; _key7 < _len3; _key7++) {
  13081. keys[_key7] = arguments[_key7];
  13082. }
  13083. return this.addDescending.apply(this, keys);
  13084. }
  13085. /**
  13086. * Sorts the results in descending order by the given key,
  13087. * but can also add secondary sort descriptors without overwriting _order.
  13088. *
  13089. * @param {(string|string[])} keys The key to order by, which is a
  13090. * string of comma separated values, or an Array of keys, or multiple keys.
  13091. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13092. */
  13093. }, {
  13094. key: "addDescending",
  13095. value: function () /*: ParseQuery*/{
  13096. var _this10 = this;
  13097. if (!this._order) {
  13098. this._order = [];
  13099. }
  13100. for (var _len4 = arguments.length, keys = new Array(_len4), _key8 = 0; _key8 < _len4; _key8++) {
  13101. keys[_key8] = arguments[_key8];
  13102. }
  13103. (0, _forEach.default)(keys).call(keys, function (key) {
  13104. var _context17, _context18;
  13105. if ((0, _isArray.default)(key)) {
  13106. key = key.join();
  13107. }
  13108. _this10._order = (0, _concat.default)(_context17 = _this10._order).call(_context17, (0, _map2.default)(_context18 = key.replace(/\s/g, '').split(',')).call(_context18, function (k) {
  13109. return '-' + k;
  13110. }));
  13111. });
  13112. return this;
  13113. }
  13114. /* Query Options */
  13115. /**
  13116. * Sets the number of results to skip before returning any results.
  13117. * This is useful for pagination.
  13118. * Default is to skip zero results.
  13119. *
  13120. * @param {number} n the number of results to skip.
  13121. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13122. */
  13123. }, {
  13124. key: "skip",
  13125. value: function (n /*: number*/) /*: ParseQuery*/{
  13126. if (typeof n !== 'number' || n < 0) {
  13127. throw new Error('You can only skip by a positive number');
  13128. }
  13129. this._skip = n;
  13130. return this;
  13131. }
  13132. /**
  13133. * Sets the limit of the number of results to return. The default limit is 100.
  13134. *
  13135. * @param {number} n the number of results to limit to.
  13136. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13137. */
  13138. }, {
  13139. key: "limit",
  13140. value: function (n /*: number*/) /*: ParseQuery*/{
  13141. if (typeof n !== 'number') {
  13142. throw new Error('You can only set the limit to a numeric value');
  13143. }
  13144. this._limit = n;
  13145. return this;
  13146. }
  13147. /**
  13148. * Sets the flag to include with response the total number of objects satisfying this query,
  13149. * despite limits/skip. Might be useful for pagination.
  13150. * Note that result of this query will be wrapped as an object with
  13151. * `results`: holding {ParseObject} array and `count`: integer holding total number
  13152. *
  13153. * @param {boolean} includeCount false - disable, true - enable.
  13154. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13155. */
  13156. }, {
  13157. key: "withCount",
  13158. value: function () /*: ParseQuery*/{
  13159. var includeCount /*: boolean*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  13160. if (typeof includeCount !== 'boolean') {
  13161. throw new Error('You can only set withCount to a boolean value');
  13162. }
  13163. this._count = includeCount;
  13164. return this;
  13165. }
  13166. /**
  13167. * Includes nested Parse.Objects for the provided key. You can use dot
  13168. * notation to specify which fields in the included object are also fetched.
  13169. *
  13170. * You can include all nested Parse.Objects by passing in '*'.
  13171. * Requires Parse Server 3.0.0+
  13172. * <pre>query.include('*');</pre>
  13173. *
  13174. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  13175. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13176. */
  13177. }, {
  13178. key: "include",
  13179. value: function () /*: ParseQuery*/{
  13180. var _this11 = this;
  13181. for (var _len5 = arguments.length, keys = new Array(_len5), _key9 = 0; _key9 < _len5; _key9++) {
  13182. keys[_key9] = arguments[_key9];
  13183. }
  13184. (0, _forEach.default)(keys).call(keys, function (key) {
  13185. if ((0, _isArray.default)(key)) {
  13186. var _context19;
  13187. _this11._include = (0, _concat.default)(_context19 = _this11._include).call(_context19, key);
  13188. } else {
  13189. _this11._include.push(key);
  13190. }
  13191. });
  13192. return this;
  13193. }
  13194. /**
  13195. * Includes all nested Parse.Objects one level deep.
  13196. *
  13197. * Requires Parse Server 3.0.0+
  13198. *
  13199. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13200. */
  13201. }, {
  13202. key: "includeAll",
  13203. value: function () /*: ParseQuery*/{
  13204. return this.include('*');
  13205. }
  13206. /**
  13207. * Restricts the fields of the returned Parse.Objects to include only the
  13208. * provided keys. If this is called multiple times, then all of the keys
  13209. * specified in each of the calls will be included.
  13210. *
  13211. * @param {...string|Array<string>} keys The name(s) of the key(s) to include.
  13212. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13213. */
  13214. }, {
  13215. key: "select",
  13216. value: function () /*: ParseQuery*/{
  13217. var _this12 = this;
  13218. if (!this._select) {
  13219. this._select = [];
  13220. }
  13221. for (var _len6 = arguments.length, keys = new Array(_len6), _key10 = 0; _key10 < _len6; _key10++) {
  13222. keys[_key10] = arguments[_key10];
  13223. }
  13224. (0, _forEach.default)(keys).call(keys, function (key) {
  13225. if ((0, _isArray.default)(key)) {
  13226. var _context20;
  13227. _this12._select = (0, _concat.default)(_context20 = _this12._select).call(_context20, key);
  13228. } else {
  13229. _this12._select.push(key);
  13230. }
  13231. });
  13232. return this;
  13233. }
  13234. /**
  13235. * Restricts the fields of the returned Parse.Objects to all keys except the
  13236. * provided keys. Exclude takes precedence over select and include.
  13237. *
  13238. * Requires Parse Server 3.6.0+
  13239. *
  13240. * @param {...string|Array<string>} keys The name(s) of the key(s) to exclude.
  13241. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13242. */
  13243. }, {
  13244. key: "exclude",
  13245. value: function () /*: ParseQuery*/{
  13246. var _this13 = this;
  13247. for (var _len7 = arguments.length, keys = new Array(_len7), _key11 = 0; _key11 < _len7; _key11++) {
  13248. keys[_key11] = arguments[_key11];
  13249. }
  13250. (0, _forEach.default)(keys).call(keys, function (key) {
  13251. if ((0, _isArray.default)(key)) {
  13252. var _context21;
  13253. _this13._exclude = (0, _concat.default)(_context21 = _this13._exclude).call(_context21, key);
  13254. } else {
  13255. _this13._exclude.push(key);
  13256. }
  13257. });
  13258. return this;
  13259. }
  13260. /**
  13261. * Restricts live query to trigger only for watched fields.
  13262. *
  13263. * Requires Parse Server 6.0.0+
  13264. *
  13265. * @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
  13266. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13267. */
  13268. }, {
  13269. key: "watch",
  13270. value: function () /*: ParseQuery*/{
  13271. var _this14 = this;
  13272. for (var _len8 = arguments.length, keys = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
  13273. keys[_key12] = arguments[_key12];
  13274. }
  13275. (0, _forEach.default)(keys).call(keys, function (key) {
  13276. if ((0, _isArray.default)(key)) {
  13277. var _context22;
  13278. _this14._watch = (0, _concat.default)(_context22 = _this14._watch).call(_context22, key);
  13279. } else {
  13280. _this14._watch.push(key);
  13281. }
  13282. });
  13283. return this;
  13284. }
  13285. /**
  13286. * Changes the read preference that the backend will use when performing the query to the database.
  13287. *
  13288. * @param {string} readPreference The read preference for the main query.
  13289. * @param {string} includeReadPreference The read preference for the queries to include pointers.
  13290. * @param {string} subqueryReadPreference The read preference for the sub queries.
  13291. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13292. */
  13293. }, {
  13294. key: "readPreference",
  13295. value: function (_readPreference /*: string*/, includeReadPreference /*:: ?: string*/, subqueryReadPreference /*:: ?: string*/) /*: ParseQuery*/{
  13296. this._readPreference = _readPreference;
  13297. this._includeReadPreference = includeReadPreference;
  13298. this._subqueryReadPreference = subqueryReadPreference;
  13299. return this;
  13300. }
  13301. /**
  13302. * Subscribe this query to get liveQuery updates
  13303. *
  13304. * @param {string} sessionToken (optional) Defaults to the currentUser
  13305. * @returns {Promise<LiveQuerySubscription>} Returns the liveQuerySubscription, it's an event emitter
  13306. * which can be used to get liveQuery updates.
  13307. */
  13308. }, {
  13309. key: "subscribe",
  13310. value: function () {
  13311. var _subscribe = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(sessionToken /*:: ?: string*/) {
  13312. var currentUser, liveQueryClient, subscription;
  13313. return _regenerator.default.wrap(function (_context23) {
  13314. while (1) switch (_context23.prev = _context23.next) {
  13315. case 0:
  13316. _context23.next = 2;
  13317. return _CoreManager.default.getUserController().currentUserAsync();
  13318. case 2:
  13319. currentUser = _context23.sent;
  13320. if (!sessionToken) {
  13321. sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
  13322. }
  13323. _context23.next = 6;
  13324. return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
  13325. case 6:
  13326. liveQueryClient = _context23.sent;
  13327. if (liveQueryClient.shouldOpen()) {
  13328. liveQueryClient.open();
  13329. }
  13330. subscription = liveQueryClient.subscribe(this, sessionToken);
  13331. return _context23.abrupt("return", subscription.subscribePromise.then(function () {
  13332. return subscription;
  13333. }));
  13334. case 10:
  13335. case "end":
  13336. return _context23.stop();
  13337. }
  13338. }, _callee7, this);
  13339. }));
  13340. function subscribe() {
  13341. return _subscribe.apply(this, arguments);
  13342. }
  13343. return subscribe;
  13344. }()
  13345. /**
  13346. * Constructs a Parse.Query that is the OR of the passed in queries. For
  13347. * example:
  13348. * <pre>var compoundQuery = Parse.Query.or(query1, query2, query3);</pre>
  13349. *
  13350. * will create a compoundQuery that is an or of the query1, query2, and
  13351. * query3.
  13352. *
  13353. * @param {...Parse.Query} queries The list of queries to OR.
  13354. * @static
  13355. * @returns {Parse.Query} The query that is the OR of the passed in queries.
  13356. */
  13357. }, {
  13358. key: "fromNetwork",
  13359. value:
  13360. /**
  13361. * Change the source of this query to the server.
  13362. *
  13363. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13364. */
  13365. function () /*: ParseQuery*/{
  13366. this._queriesLocalDatastore = false;
  13367. this._localDatastorePinName = null;
  13368. return this;
  13369. }
  13370. /**
  13371. * Changes the source of this query to all pinned objects.
  13372. *
  13373. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13374. */
  13375. }, {
  13376. key: "fromLocalDatastore",
  13377. value: function () /*: ParseQuery*/{
  13378. return this.fromPinWithName(null);
  13379. }
  13380. /**
  13381. * Changes the source of this query to the default group of pinned objects.
  13382. *
  13383. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13384. */
  13385. }, {
  13386. key: "fromPin",
  13387. value: function () /*: ParseQuery*/{
  13388. return this.fromPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
  13389. }
  13390. /**
  13391. * Changes the source of this query to a specific group of pinned objects.
  13392. *
  13393. * @param {string} name The name of query source.
  13394. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13395. */
  13396. }, {
  13397. key: "fromPinWithName",
  13398. value: function (name /*:: ?: string*/) /*: ParseQuery*/{
  13399. var localDatastore = _CoreManager.default.getLocalDatastore();
  13400. if (localDatastore.checkIfEnabled()) {
  13401. this._queriesLocalDatastore = true;
  13402. this._localDatastorePinName = name;
  13403. }
  13404. return this;
  13405. }
  13406. /**
  13407. * Cancels the current network request (if any is running).
  13408. *
  13409. * @returns {Parse.Query} Returns the query, so you can chain this call.
  13410. */
  13411. }, {
  13412. key: "cancel",
  13413. value: function () /*: ParseQuery*/{
  13414. var _this15 = this;
  13415. if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
  13416. this._xhrRequest.task._aborted = true;
  13417. this._xhrRequest.task.abort();
  13418. this._xhrRequest.task = null;
  13419. this._xhrRequest.onchange = function () {};
  13420. return this;
  13421. }
  13422. return this._xhrRequest.onchange = function () {
  13423. return _this15.cancel();
  13424. };
  13425. }
  13426. }, {
  13427. key: "_setRequestTask",
  13428. value: function (options) {
  13429. var _this16 = this;
  13430. options.requestTask = function (task) {
  13431. _this16._xhrRequest.task = task;
  13432. _this16._xhrRequest.onchange();
  13433. };
  13434. }
  13435. }], [{
  13436. key: "fromJSON",
  13437. value: function (className /*: string*/, json /*: QueryJSON*/) /*: ParseQuery*/{
  13438. var query = new ParseQuery(className);
  13439. return query.withJSON(json);
  13440. }
  13441. }, {
  13442. key: "or",
  13443. value: function () /*: ParseQuery*/{
  13444. for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
  13445. queries[_key13] = arguments[_key13];
  13446. }
  13447. var className = _getClassNameFromQueries(queries);
  13448. var query = new ParseQuery(className);
  13449. query._orQuery(queries);
  13450. return query;
  13451. }
  13452. /**
  13453. * Constructs a Parse.Query that is the AND of the passed in queries. For
  13454. * example:
  13455. * <pre>var compoundQuery = Parse.Query.and(query1, query2, query3);</pre>
  13456. *
  13457. * will create a compoundQuery that is an and of the query1, query2, and
  13458. * query3.
  13459. *
  13460. * @param {...Parse.Query} queries The list of queries to AND.
  13461. * @static
  13462. * @returns {Parse.Query} The query that is the AND of the passed in queries.
  13463. */
  13464. }, {
  13465. key: "and",
  13466. value: function () /*: ParseQuery*/{
  13467. for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
  13468. queries[_key14] = arguments[_key14];
  13469. }
  13470. var className = _getClassNameFromQueries(queries);
  13471. var query = new ParseQuery(className);
  13472. query._andQuery(queries);
  13473. return query;
  13474. }
  13475. /**
  13476. * Constructs a Parse.Query that is the NOR of the passed in queries. For
  13477. * example:
  13478. * <pre>const compoundQuery = Parse.Query.nor(query1, query2, query3);</pre>
  13479. *
  13480. * will create a compoundQuery that is a nor of the query1, query2, and
  13481. * query3.
  13482. *
  13483. * @param {...Parse.Query} queries The list of queries to NOR.
  13484. * @static
  13485. * @returns {Parse.Query} The query that is the NOR of the passed in queries.
  13486. */
  13487. }, {
  13488. key: "nor",
  13489. value: function () /*: ParseQuery*/{
  13490. for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
  13491. queries[_key15] = arguments[_key15];
  13492. }
  13493. var className = _getClassNameFromQueries(queries);
  13494. var query = new ParseQuery(className);
  13495. query._norQuery(queries);
  13496. return query;
  13497. }
  13498. }]);
  13499. return ParseQuery;
  13500. }();
  13501. var DefaultController = {
  13502. find: function (className /*: string*/, params /*: QueryJSON*/, options /*: RequestOptions*/) /*: Promise<Array<ParseObject>>*/{
  13503. var RESTController = _CoreManager.default.getRESTController();
  13504. return RESTController.request('GET', 'classes/' + className, params, options);
  13505. },
  13506. aggregate: function (className /*: string*/, params /*: any*/, options /*: RequestOptions*/) /*: Promise<Array<mixed>>*/{
  13507. var RESTController = _CoreManager.default.getRESTController();
  13508. return RESTController.request('GET', 'aggregate/' + className, params, options);
  13509. }
  13510. };
  13511. _CoreManager.default.setQueryController(DefaultController);
  13512. var _default = ParseQuery;
  13513. exports.default = _default;
  13514. },{"./CoreManager":4,"./LocalDatastoreUtils":14,"./OfflineQuery":16,"./ParseError":21,"./ParseGeoPoint":23,"./ParseObject":26,"./encode":47,"./promiseUtils":52,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/concat":59,"@babel/runtime-corejs3/core-js-stable/instance/filter":62,"@babel/runtime-corejs3/core-js-stable/instance/find":64,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/instance/includes":66,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/instance/keys":68,"@babel/runtime-corejs3/core-js-stable/instance/map":69,"@babel/runtime-corejs3/core-js-stable/instance/slice":71,"@babel/runtime-corejs3/core-js-stable/instance/sort":72,"@babel/runtime-corejs3/core-js-stable/instance/splice":73,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/entries":83,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/helpers/asyncToGenerator":122,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/slicedToArray":140,"@babel/runtime-corejs3/helpers/toConsumableArray":142,"@babel/runtime-corejs3/helpers/typeof":145,"@babel/runtime-corejs3/regenerator":148}],30:[function(_dereq_,module,exports){
  13515. "use strict";
  13516. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13517. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  13518. _Object$defineProperty(exports, "__esModule", {
  13519. value: true
  13520. });
  13521. exports.default = void 0;
  13522. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  13523. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  13524. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  13525. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  13526. var _ParseOp = _dereq_("./ParseOp");
  13527. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  13528. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  13529. /**
  13530. * @flow
  13531. */
  13532. /**
  13533. * Creates a new Relation for the given parent object and key. This
  13534. * constructor should rarely be used directly, but rather created by
  13535. * Parse.Object.relation.
  13536. *
  13537. * <p>
  13538. * A class that is used to access all of the children of a many-to-many
  13539. * relationship. Each instance of Parse.Relation is associated with a
  13540. * particular parent object and key.
  13541. * </p>
  13542. *
  13543. * @alias Parse.Relation
  13544. */
  13545. var ParseRelation = /*#__PURE__*/function () {
  13546. /**
  13547. * @param {Parse.Object} parent The parent of this relation.
  13548. * @param {string} key The key for this relation on the parent.
  13549. */
  13550. function ParseRelation(parent /*: ?ParseObject*/, key /*: ?string*/) {
  13551. (0, _classCallCheck2.default)(this, ParseRelation);
  13552. (0, _defineProperty2.default)(this, "parent", void 0);
  13553. (0, _defineProperty2.default)(this, "key", void 0);
  13554. (0, _defineProperty2.default)(this, "targetClassName", void 0);
  13555. this.parent = parent;
  13556. this.key = key;
  13557. this.targetClassName = null;
  13558. }
  13559. /*
  13560. * Makes sure that this relation has the right parent and key.
  13561. */
  13562. (0, _createClass2.default)(ParseRelation, [{
  13563. key: "_ensureParentAndKey",
  13564. value: function (parent /*: ParseObject*/, key /*: string*/) {
  13565. this.key = this.key || key;
  13566. if (this.key !== key) {
  13567. throw new Error('Internal Error. Relation retrieved from two different keys.');
  13568. }
  13569. if (this.parent) {
  13570. if (this.parent.className !== parent.className) {
  13571. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  13572. }
  13573. if (this.parent.id) {
  13574. if (this.parent.id !== parent.id) {
  13575. throw new Error('Internal Error. Relation retrieved from two different Objects.');
  13576. }
  13577. } else if (parent.id) {
  13578. this.parent = parent;
  13579. }
  13580. } else {
  13581. this.parent = parent;
  13582. }
  13583. }
  13584. /**
  13585. * Adds a Parse.Object or an array of Parse.Objects to the relation.
  13586. *
  13587. * @param {(Parse.Object|Array)} objects The item or items to add.
  13588. * @returns {Parse.Object} The parent of the relation.
  13589. */
  13590. }, {
  13591. key: "add",
  13592. value: function (objects /*: ParseObject | Array<ParseObject | string>*/) /*: ParseObject*/{
  13593. if (!(0, _isArray.default)(objects)) {
  13594. objects = [objects];
  13595. }
  13596. var change = new _ParseOp.RelationOp(objects, []);
  13597. var parent = this.parent;
  13598. if (!parent) {
  13599. throw new Error('Cannot add to a Relation without a parent');
  13600. }
  13601. if (objects.length === 0) {
  13602. return parent;
  13603. }
  13604. parent.set(this.key, change);
  13605. this.targetClassName = change._targetClassName;
  13606. return parent;
  13607. }
  13608. /**
  13609. * Removes a Parse.Object or an array of Parse.Objects from this relation.
  13610. *
  13611. * @param {(Parse.Object|Array)} objects The item or items to remove.
  13612. */
  13613. }, {
  13614. key: "remove",
  13615. value: function (objects /*: ParseObject | Array<ParseObject | string>*/) {
  13616. if (!(0, _isArray.default)(objects)) {
  13617. objects = [objects];
  13618. }
  13619. var change = new _ParseOp.RelationOp([], objects);
  13620. if (!this.parent) {
  13621. throw new Error('Cannot remove from a Relation without a parent');
  13622. }
  13623. if (objects.length === 0) {
  13624. return;
  13625. }
  13626. this.parent.set(this.key, change);
  13627. this.targetClassName = change._targetClassName;
  13628. }
  13629. /**
  13630. * Returns a JSON version of the object suitable for saving to disk.
  13631. *
  13632. * @returns {object} JSON representation of Relation
  13633. */
  13634. }, {
  13635. key: "toJSON",
  13636. value: function () /*: { __type: 'Relation', className: ?string }*/{
  13637. return {
  13638. __type: 'Relation',
  13639. className: this.targetClassName
  13640. };
  13641. }
  13642. /**
  13643. * Returns a Parse.Query that is limited to objects in this
  13644. * relation.
  13645. *
  13646. * @returns {Parse.Query} Relation Query
  13647. */
  13648. }, {
  13649. key: "query",
  13650. value: function query() /*: ParseQuery*/{
  13651. var query;
  13652. var parent = this.parent;
  13653. if (!parent) {
  13654. throw new Error('Cannot construct a query for a Relation without a parent');
  13655. }
  13656. if (!this.targetClassName) {
  13657. query = new _ParseQuery.default(parent.className);
  13658. query._extraOptions.redirectClassNameForKey = this.key;
  13659. } else {
  13660. query = new _ParseQuery.default(this.targetClassName);
  13661. }
  13662. query._addCondition('$relatedTo', 'object', {
  13663. __type: 'Pointer',
  13664. className: parent.className,
  13665. objectId: parent.id
  13666. });
  13667. query._addCondition('$relatedTo', 'key', this.key);
  13668. return query;
  13669. }
  13670. }]);
  13671. return ParseRelation;
  13672. }();
  13673. var _default = ParseRelation;
  13674. exports.default = _default;
  13675. },{"./ParseObject":26,"./ParseOp":27,"./ParseQuery":29,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],31:[function(_dereq_,module,exports){
  13676. "use strict";
  13677. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  13678. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13679. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  13680. _Object$defineProperty(exports, "__esModule", {
  13681. value: true
  13682. });
  13683. exports.default = void 0;
  13684. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  13685. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  13686. var _get2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/get"));
  13687. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  13688. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  13689. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  13690. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  13691. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  13692. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  13693. function _createSuper(Derived) {
  13694. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  13695. return function () {
  13696. var Super = (0, _getPrototypeOf2.default)(Derived),
  13697. result;
  13698. if (hasNativeReflectConstruct) {
  13699. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  13700. result = _Reflect$construct(Super, arguments, NewTarget);
  13701. } else {
  13702. result = Super.apply(this, arguments);
  13703. }
  13704. return (0, _possibleConstructorReturn2.default)(this, result);
  13705. };
  13706. }
  13707. function _isNativeReflectConstruct() {
  13708. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  13709. if (_Reflect$construct.sham) return false;
  13710. if (typeof Proxy === "function") return true;
  13711. try {
  13712. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  13713. return true;
  13714. } catch (e) {
  13715. return false;
  13716. }
  13717. } /**
  13718. * @flow
  13719. */
  13720. /*:: import type { AttributeMap } from './ObjectStateMutations';*/
  13721. /*:: import type ParseRelation from './ParseRelation';*/
  13722. /**
  13723. * Represents a Role on the Parse server. Roles represent groupings of
  13724. * Users for the purposes of granting permissions (e.g. specifying an ACL
  13725. * for an Object). Roles are specified by their sets of child users and
  13726. * child roles, all of which are granted any permissions that the parent
  13727. * role has.
  13728. *
  13729. * <p>Roles must have a name (which cannot be changed after creation of the
  13730. * role), and must specify an ACL.</p>
  13731. *
  13732. * @alias Parse.Role
  13733. * @augments Parse.Object
  13734. */
  13735. var ParseRole = /*#__PURE__*/function (_ParseObject) {
  13736. (0, _inherits2.default)(ParseRole, _ParseObject);
  13737. var _super = _createSuper(ParseRole);
  13738. /**
  13739. * @param {string} name The name of the Role to create.
  13740. * @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL.
  13741. * A Parse.Role is a local representation of a role persisted to the Parse
  13742. * cloud.
  13743. */
  13744. function ParseRole(name /*: string*/, acl /*: ParseACL*/) {
  13745. var _this;
  13746. (0, _classCallCheck2.default)(this, ParseRole);
  13747. _this = _super.call(this, '_Role');
  13748. if (typeof name === 'string' && acl instanceof _ParseACL.default) {
  13749. _this.setName(name);
  13750. _this.setACL(acl);
  13751. }
  13752. return _this;
  13753. }
  13754. /**
  13755. * Gets the name of the role. You can alternatively call role.get("name")
  13756. *
  13757. * @returns {string} the name of the role.
  13758. */
  13759. (0, _createClass2.default)(ParseRole, [{
  13760. key: "getName",
  13761. value: function () /*: ?string*/{
  13762. var name = this.get('name');
  13763. if (name == null || typeof name === 'string') {
  13764. return name;
  13765. }
  13766. return '';
  13767. }
  13768. /**
  13769. * Sets the name for a role. This value must be set before the role has
  13770. * been saved to the server, and cannot be set once the role has been
  13771. * saved.
  13772. *
  13773. * <p>
  13774. * A role's name can only contain alphanumeric characters, _, -, and
  13775. * spaces.
  13776. * </p>
  13777. *
  13778. * <p>This is equivalent to calling role.set("name", name)</p>
  13779. *
  13780. * @param {string} name The name of the role.
  13781. * @param {object} options Standard options object with success and error
  13782. * callbacks.
  13783. * @returns {(ParseObject|boolean)} true if the set succeeded.
  13784. */
  13785. }, {
  13786. key: "setName",
  13787. value: function (name /*: string*/, options /*:: ?: mixed*/) /*: ParseObject | boolean*/{
  13788. this._validateName(name);
  13789. return this.set('name', name, options);
  13790. }
  13791. /**
  13792. * Gets the Parse.Relation for the Parse.Users that are direct
  13793. * children of this role. These users are granted any privileges that this
  13794. * role has been granted (e.g. read or write access through ACLs). You can
  13795. * add or remove users from the role through this relation.
  13796. *
  13797. * <p>This is equivalent to calling role.relation("users")</p>
  13798. *
  13799. * @returns {Parse.Relation} the relation for the users belonging to this
  13800. * role.
  13801. */
  13802. }, {
  13803. key: "getUsers",
  13804. value: function () /*: ParseRelation*/{
  13805. return this.relation('users');
  13806. }
  13807. /**
  13808. * Gets the Parse.Relation for the Parse.Roles that are direct
  13809. * children of this role. These roles' users are granted any privileges that
  13810. * this role has been granted (e.g. read or write access through ACLs). You
  13811. * can add or remove child roles from this role through this relation.
  13812. *
  13813. * <p>This is equivalent to calling role.relation("roles")</p>
  13814. *
  13815. * @returns {Parse.Relation} the relation for the roles belonging to this
  13816. * role.
  13817. */
  13818. }, {
  13819. key: "getRoles",
  13820. value: function () /*: ParseRelation*/{
  13821. return this.relation('roles');
  13822. }
  13823. }, {
  13824. key: "_validateName",
  13825. value: function (newName) {
  13826. if (typeof newName !== 'string') {
  13827. throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
  13828. }
  13829. if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
  13830. throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
  13831. }
  13832. }
  13833. }, {
  13834. key: "validate",
  13835. value: function (attrs /*: AttributeMap*/, options /*:: ?: mixed*/) /*: ParseError | boolean*/{
  13836. var isInvalid = (0, _get2.default)((0, _getPrototypeOf2.default)(ParseRole.prototype), "validate", this).call(this, attrs, options);
  13837. if (isInvalid) {
  13838. return isInvalid;
  13839. }
  13840. if ('name' in attrs && attrs.name !== this.getName()) {
  13841. var newName = attrs.name;
  13842. if (this.id && this.id !== attrs.objectId) {
  13843. // Check to see if the objectId being set matches this.id
  13844. // This happens during a fetch -- the id is set before calling fetch
  13845. // Let the name be set in this case
  13846. return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
  13847. }
  13848. try {
  13849. this._validateName(newName);
  13850. } catch (e) {
  13851. return e;
  13852. }
  13853. }
  13854. return false;
  13855. }
  13856. }]);
  13857. return ParseRole;
  13858. }(_ParseObject2.default);
  13859. _ParseObject2.default.registerSubclass('_Role', ParseRole);
  13860. var _default = ParseRole;
  13861. exports.default = _default;
  13862. },{"./ParseACL":18,"./ParseError":21,"./ParseObject":26,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/reflect/construct":92,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/get":127,"@babel/runtime-corejs3/helpers/getPrototypeOf":128,"@babel/runtime-corejs3/helpers/inherits":129,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":137}],32:[function(_dereq_,module,exports){
  13863. "use strict";
  13864. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  13865. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  13866. _Object$defineProperty(exports, "__esModule", {
  13867. value: true
  13868. });
  13869. exports.default = void 0;
  13870. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  13871. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  13872. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  13873. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  13874. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  13875. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  13876. var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
  13877. /**
  13878. * @flow
  13879. */
  13880. /*:: import type { PermissionsMap } from './ParseCLP';*/
  13881. var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
  13882. /*:: type FieldOptions = {
  13883. required: boolean,
  13884. defaultValue: mixed,
  13885. };*/
  13886. /**
  13887. * A Parse.Schema object is for handling schema data from Parse.
  13888. * <p>All the schemas methods require MasterKey.
  13889. *
  13890. * When adding fields, you may set required and default values. (Requires Parse Server 3.7.0+)
  13891. *
  13892. * <pre>
  13893. * const options = { required: true, defaultValue: 'hello world' };
  13894. * const schema = new Parse.Schema('MyClass');
  13895. * schema.addString('field', options);
  13896. * schema.addIndex('index_name', { 'field': 1 });
  13897. * schema.save();
  13898. * </pre>
  13899. * </p>
  13900. *
  13901. * @alias Parse.Schema
  13902. */
  13903. var ParseSchema = /*#__PURE__*/function () {
  13904. /**
  13905. * @param {string} className Parse Class string.
  13906. */
  13907. function ParseSchema(className /*: string*/) {
  13908. (0, _classCallCheck2.default)(this, ParseSchema);
  13909. (0, _defineProperty2.default)(this, "className", void 0);
  13910. (0, _defineProperty2.default)(this, "_fields", void 0);
  13911. (0, _defineProperty2.default)(this, "_indexes", void 0);
  13912. (0, _defineProperty2.default)(this, "_clp", void 0);
  13913. if (typeof className === 'string') {
  13914. if (className === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
  13915. this.className = '_User';
  13916. } else {
  13917. this.className = className;
  13918. }
  13919. }
  13920. this._fields = {};
  13921. this._indexes = {};
  13922. }
  13923. /**
  13924. * Static method to get all schemas
  13925. *
  13926. * @returns {Promise} A promise that is resolved with the result when
  13927. * the query completes.
  13928. */
  13929. (0, _createClass2.default)(ParseSchema, [{
  13930. key: "get",
  13931. value:
  13932. /**
  13933. * Get the Schema from Parse
  13934. *
  13935. * @returns {Promise} A promise that is resolved with the result when
  13936. * the query completes.
  13937. */
  13938. function () {
  13939. this.assertClassName();
  13940. var controller = _CoreManager.default.getSchemaController();
  13941. return controller.get(this.className).then(function (response) {
  13942. if (!response) {
  13943. throw new Error('Schema not found.');
  13944. }
  13945. return response;
  13946. });
  13947. }
  13948. /**
  13949. * Create a new Schema on Parse
  13950. *
  13951. * @returns {Promise} A promise that is resolved with the result when
  13952. * the query completes.
  13953. */
  13954. }, {
  13955. key: "save",
  13956. value: function () {
  13957. this.assertClassName();
  13958. var controller = _CoreManager.default.getSchemaController();
  13959. var params = {
  13960. className: this.className,
  13961. fields: this._fields,
  13962. indexes: this._indexes,
  13963. classLevelPermissions: this._clp
  13964. };
  13965. return controller.create(this.className, params);
  13966. }
  13967. /**
  13968. * Update a Schema on Parse
  13969. *
  13970. * @returns {Promise} A promise that is resolved with the result when
  13971. * the query completes.
  13972. */
  13973. }, {
  13974. key: "update",
  13975. value: function () {
  13976. this.assertClassName();
  13977. var controller = _CoreManager.default.getSchemaController();
  13978. var params = {
  13979. className: this.className,
  13980. fields: this._fields,
  13981. indexes: this._indexes,
  13982. classLevelPermissions: this._clp
  13983. };
  13984. this._fields = {};
  13985. this._indexes = {};
  13986. return controller.update(this.className, params);
  13987. }
  13988. /**
  13989. * Removing a Schema from Parse
  13990. * Can only be used on Schema without objects
  13991. *
  13992. * @returns {Promise} A promise that is resolved with the result when
  13993. * the query completes.
  13994. */
  13995. }, {
  13996. key: "delete",
  13997. value: function () {
  13998. this.assertClassName();
  13999. var controller = _CoreManager.default.getSchemaController();
  14000. return controller.delete(this.className);
  14001. }
  14002. /**
  14003. * Removes all objects from a Schema (class) in Parse.
  14004. * EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
  14005. *
  14006. * @returns {Promise} A promise that is resolved with the result when
  14007. * the query completes.
  14008. */
  14009. }, {
  14010. key: "purge",
  14011. value: function () {
  14012. this.assertClassName();
  14013. var controller = _CoreManager.default.getSchemaController();
  14014. return controller.purge(this.className);
  14015. }
  14016. /**
  14017. * Assert if ClassName has been filled
  14018. *
  14019. * @private
  14020. */
  14021. }, {
  14022. key: "assertClassName",
  14023. value: function () {
  14024. if (!this.className) {
  14025. throw new Error('You must set a Class Name before making any request.');
  14026. }
  14027. }
  14028. /**
  14029. * Sets Class Level Permissions when creating / updating a Schema.
  14030. * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed
  14031. *
  14032. * @param {object | Parse.CLP} clp Class Level Permissions
  14033. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14034. */
  14035. }, {
  14036. key: "setCLP",
  14037. value: function (clp /*: PermissionsMap | ParseCLP*/) {
  14038. if (clp instanceof _ParseCLP.default) {
  14039. this._clp = clp.toJSON();
  14040. } else {
  14041. this._clp = clp;
  14042. }
  14043. return this;
  14044. }
  14045. /**
  14046. * Adding a Field to Create / Update a Schema
  14047. *
  14048. * @param {string} name Name of the field that will be created on Parse
  14049. * @param {string} type Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation)
  14050. * @param {object} options
  14051. * Valid options are:<ul>
  14052. * <li>required: If field is not set, save operation fails (Requires Parse Server 3.7.0+)
  14053. * <li>defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+)
  14054. * <li>targetClass: Required if type is Pointer or Parse.Relation
  14055. * </ul>
  14056. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14057. */
  14058. }, {
  14059. key: "addField",
  14060. value: function (name /*: string*/, type /*: string*/) {
  14061. var options /*: FieldOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  14062. type = type || 'String';
  14063. if (!name) {
  14064. throw new Error('field name may not be null.');
  14065. }
  14066. if ((0, _indexOf.default)(FIELD_TYPES).call(FIELD_TYPES, type) === -1) {
  14067. throw new Error("".concat(type, " is not a valid type."));
  14068. }
  14069. if (type === 'Pointer') {
  14070. return this.addPointer(name, options.targetClass, options);
  14071. }
  14072. if (type === 'Relation') {
  14073. return this.addRelation(name, options.targetClass, options);
  14074. }
  14075. var fieldOptions = {
  14076. type: type
  14077. };
  14078. if (typeof options.required === 'boolean') {
  14079. fieldOptions.required = options.required;
  14080. }
  14081. if (options.defaultValue !== undefined) {
  14082. fieldOptions.defaultValue = options.defaultValue;
  14083. }
  14084. if (type === 'Date') {
  14085. if (options && options.defaultValue) {
  14086. fieldOptions.defaultValue = {
  14087. __type: 'Date',
  14088. iso: new Date(options.defaultValue)
  14089. };
  14090. }
  14091. }
  14092. this._fields[name] = fieldOptions;
  14093. return this;
  14094. }
  14095. /**
  14096. * Adding an Index to Create / Update a Schema
  14097. *
  14098. * @param {string} name Name of the index
  14099. * @param {object} index { field: value }
  14100. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14101. *
  14102. * <pre>
  14103. * schema.addIndex('index_name', { 'field': 1 });
  14104. * </pre>
  14105. */
  14106. }, {
  14107. key: "addIndex",
  14108. value: function (name /*: string*/, index /*: any*/) {
  14109. if (!name) {
  14110. throw new Error('index name may not be null.');
  14111. }
  14112. if (!index) {
  14113. throw new Error('index may not be null.');
  14114. }
  14115. this._indexes[name] = index;
  14116. return this;
  14117. }
  14118. /**
  14119. * Adding String Field
  14120. *
  14121. * @param {string} name Name of the field that will be created on Parse
  14122. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14123. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14124. */
  14125. }, {
  14126. key: "addString",
  14127. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14128. return this.addField(name, 'String', options);
  14129. }
  14130. /**
  14131. * Adding Number Field
  14132. *
  14133. * @param {string} name Name of the field that will be created on Parse
  14134. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14135. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14136. */
  14137. }, {
  14138. key: "addNumber",
  14139. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14140. return this.addField(name, 'Number', options);
  14141. }
  14142. /**
  14143. * Adding Boolean Field
  14144. *
  14145. * @param {string} name Name of the field that will be created on Parse
  14146. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14147. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14148. */
  14149. }, {
  14150. key: "addBoolean",
  14151. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14152. return this.addField(name, 'Boolean', options);
  14153. }
  14154. /**
  14155. * Adding Date Field
  14156. *
  14157. * @param {string} name Name of the field that will be created on Parse
  14158. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14159. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14160. */
  14161. }, {
  14162. key: "addDate",
  14163. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14164. return this.addField(name, 'Date', options);
  14165. }
  14166. /**
  14167. * Adding File Field
  14168. *
  14169. * @param {string} name Name of the field that will be created on Parse
  14170. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14171. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14172. */
  14173. }, {
  14174. key: "addFile",
  14175. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14176. return this.addField(name, 'File', options);
  14177. }
  14178. /**
  14179. * Adding GeoPoint Field
  14180. *
  14181. * @param {string} name Name of the field that will be created on Parse
  14182. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14183. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14184. */
  14185. }, {
  14186. key: "addGeoPoint",
  14187. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14188. return this.addField(name, 'GeoPoint', options);
  14189. }
  14190. /**
  14191. * Adding Polygon Field
  14192. *
  14193. * @param {string} name Name of the field that will be created on Parse
  14194. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14195. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14196. */
  14197. }, {
  14198. key: "addPolygon",
  14199. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14200. return this.addField(name, 'Polygon', options);
  14201. }
  14202. /**
  14203. * Adding Array Field
  14204. *
  14205. * @param {string} name Name of the field that will be created on Parse
  14206. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14207. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14208. */
  14209. }, {
  14210. key: "addArray",
  14211. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14212. return this.addField(name, 'Array', options);
  14213. }
  14214. /**
  14215. * Adding Object Field
  14216. *
  14217. * @param {string} name Name of the field that will be created on Parse
  14218. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14219. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14220. */
  14221. }, {
  14222. key: "addObject",
  14223. value: function (name /*: string*/, options /*: FieldOptions*/) {
  14224. return this.addField(name, 'Object', options);
  14225. }
  14226. /**
  14227. * Adding Pointer Field
  14228. *
  14229. * @param {string} name Name of the field that will be created on Parse
  14230. * @param {string} targetClass Name of the target Pointer Class
  14231. * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
  14232. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14233. */
  14234. }, {
  14235. key: "addPointer",
  14236. value: function (name /*: string*/, targetClass /*: string*/) {
  14237. var options /*: FieldOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  14238. if (!name) {
  14239. throw new Error('field name may not be null.');
  14240. }
  14241. if (!targetClass) {
  14242. throw new Error('You need to set the targetClass of the Pointer.');
  14243. }
  14244. var fieldOptions = {
  14245. type: 'Pointer',
  14246. targetClass: targetClass
  14247. };
  14248. if (typeof options.required === 'boolean') {
  14249. fieldOptions.required = options.required;
  14250. }
  14251. if (options.defaultValue !== undefined) {
  14252. fieldOptions.defaultValue = options.defaultValue;
  14253. if (options.defaultValue instanceof _ParseObject.default) {
  14254. fieldOptions.defaultValue = options.defaultValue.toPointer();
  14255. }
  14256. }
  14257. this._fields[name] = fieldOptions;
  14258. return this;
  14259. }
  14260. /**
  14261. * Adding Relation Field
  14262. *
  14263. * @param {string} name Name of the field that will be created on Parse
  14264. * @param {string} targetClass Name of the target Pointer Class
  14265. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14266. */
  14267. }, {
  14268. key: "addRelation",
  14269. value: function (name /*: string*/, targetClass /*: string*/) {
  14270. if (!name) {
  14271. throw new Error('field name may not be null.');
  14272. }
  14273. if (!targetClass) {
  14274. throw new Error('You need to set the targetClass of the Relation.');
  14275. }
  14276. this._fields[name] = {
  14277. type: 'Relation',
  14278. targetClass: targetClass
  14279. };
  14280. return this;
  14281. }
  14282. /**
  14283. * Deleting a Field to Update on a Schema
  14284. *
  14285. * @param {string} name Name of the field
  14286. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14287. */
  14288. }, {
  14289. key: "deleteField",
  14290. value: function (name /*: string*/) {
  14291. this._fields[name] = {
  14292. __op: 'Delete'
  14293. };
  14294. return this;
  14295. }
  14296. /**
  14297. * Deleting an Index to Update on a Schema
  14298. *
  14299. * @param {string} name Name of the field
  14300. * @returns {Parse.Schema} Returns the schema, so you can chain this call.
  14301. */
  14302. }, {
  14303. key: "deleteIndex",
  14304. value: function (name /*: string*/) {
  14305. this._indexes[name] = {
  14306. __op: 'Delete'
  14307. };
  14308. return this;
  14309. }
  14310. }], [{
  14311. key: "all",
  14312. value: function () {
  14313. var controller = _CoreManager.default.getSchemaController();
  14314. return controller.get('').then(function (response) {
  14315. if (response.results.length === 0) {
  14316. throw new Error('Schema not found.');
  14317. }
  14318. return response.results;
  14319. });
  14320. }
  14321. }]);
  14322. return ParseSchema;
  14323. }();
  14324. var DefaultController = {
  14325. send: function (className /*: string*/, method /*: string*/) /*: Promise*/{
  14326. var params /*: any*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  14327. var RESTController = _CoreManager.default.getRESTController();
  14328. return RESTController.request(method, "schemas/".concat(className), params, {
  14329. useMasterKey: true
  14330. });
  14331. },
  14332. get: function (className /*: string*/) /*: Promise*/{
  14333. return this.send(className, 'GET');
  14334. },
  14335. create: function (className /*: string*/, params /*: any*/) /*: Promise*/{
  14336. return this.send(className, 'POST', params);
  14337. },
  14338. update: function (className /*: string*/, params /*: any*/) /*: Promise*/{
  14339. return this.send(className, 'PUT', params);
  14340. },
  14341. delete: function (className /*: string*/) /*: Promise*/{
  14342. return this.send(className, 'DELETE');
  14343. },
  14344. purge: function (className /*: string*/) /*: Promise*/{
  14345. var RESTController = _CoreManager.default.getRESTController();
  14346. return RESTController.request('DELETE', "purge/".concat(className), {}, {
  14347. useMasterKey: true
  14348. });
  14349. }
  14350. };
  14351. _CoreManager.default.setSchemaController(DefaultController);
  14352. var _default = ParseSchema;
  14353. exports.default = _default;
  14354. },{"./CoreManager":4,"./ParseCLP":19,"./ParseObject":26,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],33:[function(_dereq_,module,exports){
  14355. "use strict";
  14356. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  14357. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14358. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14359. _Object$defineProperty(exports, "__esModule", {
  14360. value: true
  14361. });
  14362. exports.default = void 0;
  14363. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  14364. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  14365. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  14366. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  14367. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  14368. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  14369. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  14370. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14371. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  14372. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  14373. var _ParseUser = _interopRequireDefault(_dereq_("./ParseUser"));
  14374. function _createSuper(Derived) {
  14375. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  14376. return function () {
  14377. var Super = (0, _getPrototypeOf2.default)(Derived),
  14378. result;
  14379. if (hasNativeReflectConstruct) {
  14380. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  14381. result = _Reflect$construct(Super, arguments, NewTarget);
  14382. } else {
  14383. result = Super.apply(this, arguments);
  14384. }
  14385. return (0, _possibleConstructorReturn2.default)(this, result);
  14386. };
  14387. }
  14388. function _isNativeReflectConstruct() {
  14389. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  14390. if (_Reflect$construct.sham) return false;
  14391. if (typeof Proxy === "function") return true;
  14392. try {
  14393. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  14394. return true;
  14395. } catch (e) {
  14396. return false;
  14397. }
  14398. } /**
  14399. * @flow
  14400. */
  14401. /*:: import type { AttributeMap } from './ObjectStateMutations';*/
  14402. /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
  14403. /**
  14404. * <p>A Parse.Session object is a local representation of a revocable session.
  14405. * This class is a subclass of a Parse.Object, and retains the same
  14406. * functionality of a Parse.Object.</p>
  14407. *
  14408. * @alias Parse.Session
  14409. * @augments Parse.Object
  14410. */
  14411. var ParseSession = /*#__PURE__*/function (_ParseObject) {
  14412. (0, _inherits2.default)(ParseSession, _ParseObject);
  14413. var _super = _createSuper(ParseSession);
  14414. /**
  14415. * @param {object} attributes The initial set of data to store in the user.
  14416. */
  14417. function ParseSession(attributes /*: ?AttributeMap*/) {
  14418. var _this;
  14419. (0, _classCallCheck2.default)(this, ParseSession);
  14420. _this = _super.call(this, '_Session');
  14421. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  14422. if (!_this.set(attributes || {})) {
  14423. throw new Error("Can't create an invalid Session");
  14424. }
  14425. }
  14426. return _this;
  14427. }
  14428. /**
  14429. * Returns the session token string.
  14430. *
  14431. * @returns {string}
  14432. */
  14433. (0, _createClass2.default)(ParseSession, [{
  14434. key: "getSessionToken",
  14435. value: function () /*: string*/{
  14436. var token = this.get('sessionToken');
  14437. if (typeof token === 'string') {
  14438. return token;
  14439. }
  14440. return '';
  14441. }
  14442. }], [{
  14443. key: "readOnlyAttributes",
  14444. value: function () {
  14445. return ['createdWith', 'expiresAt', 'installationId', 'restricted', 'sessionToken', 'user'];
  14446. }
  14447. /**
  14448. * Retrieves the Session object for the currently logged in session.
  14449. *
  14450. * @param {object} options useMasterKey
  14451. * @static
  14452. * @returns {Promise} A promise that is resolved with the Parse.Session
  14453. * object after it has been fetched. If there is no current user, the
  14454. * promise will be rejected.
  14455. */
  14456. }, {
  14457. key: "current",
  14458. value: function (options /*: FullOptions*/) {
  14459. options = options || {};
  14460. var controller = _CoreManager.default.getSessionController();
  14461. var sessionOptions = {};
  14462. if (options.hasOwnProperty('useMasterKey')) {
  14463. sessionOptions.useMasterKey = options.useMasterKey;
  14464. }
  14465. return _ParseUser.default.currentAsync().then(function (user) {
  14466. if (!user) {
  14467. return _promise.default.reject('There is no current user.');
  14468. }
  14469. sessionOptions.sessionToken = user.getSessionToken();
  14470. return controller.getSession(sessionOptions);
  14471. });
  14472. }
  14473. /**
  14474. * Determines whether the current session token is revocable.
  14475. * This method is useful for migrating Express.js or Node.js web apps to
  14476. * use revocable sessions. If you are migrating an app that uses the Parse
  14477. * SDK in the browser only, please use Parse.User.enableRevocableSession()
  14478. * instead, so that sessions can be automatically upgraded.
  14479. *
  14480. * @static
  14481. * @returns {boolean}
  14482. */
  14483. }, {
  14484. key: "isCurrentSessionRevocable",
  14485. value: function () /*: boolean*/{
  14486. var currentUser = _ParseUser.default.current();
  14487. if (currentUser) {
  14488. return (0, _isRevocableSession.default)(currentUser.getSessionToken() || '');
  14489. }
  14490. return false;
  14491. }
  14492. }]);
  14493. return ParseSession;
  14494. }(_ParseObject2.default);
  14495. _ParseObject2.default.registerSubclass('_Session', ParseSession);
  14496. var DefaultController = {
  14497. getSession: function (options /*: RequestOptions*/) /*: Promise<ParseSession>*/{
  14498. var RESTController = _CoreManager.default.getRESTController();
  14499. var session = new ParseSession();
  14500. return RESTController.request('GET', 'sessions/me', {}, options).then(function (sessionData) {
  14501. session._finishFetch(sessionData);
  14502. session._setExisted(true);
  14503. return session;
  14504. });
  14505. }
  14506. };
  14507. _CoreManager.default.setSessionController(DefaultController);
  14508. var _default = ParseSession;
  14509. exports.default = _default;
  14510. },{"./CoreManager":4,"./ParseObject":26,"./ParseUser":34,"./isRevocableSession":50,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/core-js-stable/reflect/construct":92,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/getPrototypeOf":128,"@babel/runtime-corejs3/helpers/inherits":129,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":137,"@babel/runtime-corejs3/helpers/typeof":145}],34:[function(_dereq_,module,exports){
  14511. "use strict";
  14512. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js-stable/reflect/construct");
  14513. var _Object$defineProperty2 = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  14514. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  14515. _Object$defineProperty2(exports, "__esModule", {
  14516. value: true
  14517. });
  14518. exports.default = void 0;
  14519. var _regenerator = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/regenerator"));
  14520. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  14521. var _defineProperty = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property"));
  14522. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  14523. var _asyncToGenerator2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/asyncToGenerator"));
  14524. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  14525. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  14526. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  14527. var _get2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/get"));
  14528. var _inherits2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/inherits"));
  14529. var _possibleConstructorReturn2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
  14530. var _getPrototypeOf2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/getPrototypeOf"));
  14531. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  14532. var _isRevocableSession = _interopRequireDefault(_dereq_("./isRevocableSession"));
  14533. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  14534. var _ParseObject2 = _interopRequireDefault(_dereq_("./ParseObject"));
  14535. var _ParseSession = _interopRequireDefault(_dereq_("./ParseSession"));
  14536. var _Storage = _interopRequireDefault(_dereq_("./Storage"));
  14537. function _createSuper(Derived) {
  14538. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  14539. return function () {
  14540. var Super = (0, _getPrototypeOf2.default)(Derived),
  14541. result;
  14542. if (hasNativeReflectConstruct) {
  14543. var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
  14544. result = _Reflect$construct(Super, arguments, NewTarget);
  14545. } else {
  14546. result = Super.apply(this, arguments);
  14547. }
  14548. return (0, _possibleConstructorReturn2.default)(this, result);
  14549. };
  14550. }
  14551. function _isNativeReflectConstruct() {
  14552. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  14553. if (_Reflect$construct.sham) return false;
  14554. if (typeof Proxy === "function") return true;
  14555. try {
  14556. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  14557. return true;
  14558. } catch (e) {
  14559. return false;
  14560. }
  14561. } /**
  14562. * @flow
  14563. */
  14564. /*:: import type { AttributeMap } from './ObjectStateMutations';*/
  14565. /*:: import type { RequestOptions, FullOptions } from './RESTController';*/
  14566. /*:: export type AuthData = ?{ [key: string]: mixed };*/
  14567. var CURRENT_USER_KEY = 'currentUser';
  14568. var canUseCurrentUser = !_CoreManager.default.get('IS_NODE');
  14569. var currentUserCacheMatchesDisk = false;
  14570. var currentUserCache = null;
  14571. var authProviders = {};
  14572. /**
  14573. * <p>A Parse.User object is a local representation of a user persisted to the
  14574. * Parse cloud. This class is a subclass of a Parse.Object, and retains the
  14575. * same functionality of a Parse.Object, but also extends it with various
  14576. * user specific methods, like authentication, signing up, and validation of
  14577. * uniqueness.</p>
  14578. *
  14579. * @alias Parse.User
  14580. * @augments Parse.Object
  14581. */
  14582. var ParseUser = /*#__PURE__*/function (_ParseObject) {
  14583. (0, _inherits2.default)(ParseUser, _ParseObject);
  14584. var _super = _createSuper(ParseUser);
  14585. /**
  14586. * @param {object} attributes The initial set of data to store in the user.
  14587. */
  14588. function ParseUser(attributes /*: ?AttributeMap*/) {
  14589. var _this;
  14590. (0, _classCallCheck2.default)(this, ParseUser);
  14591. _this = _super.call(this, '_User');
  14592. if (attributes && (0, _typeof2.default)(attributes) === 'object') {
  14593. if (!_this.set(attributes || {})) {
  14594. throw new Error("Can't create an invalid Parse User");
  14595. }
  14596. }
  14597. return _this;
  14598. }
  14599. /**
  14600. * Request a revocable session token to replace the older style of token.
  14601. *
  14602. * @param {object} options
  14603. * @returns {Promise} A promise that is resolved when the replacement
  14604. * token has been fetched.
  14605. */
  14606. (0, _createClass2.default)(ParseUser, [{
  14607. key: "_upgradeToRevocableSession",
  14608. value: function (options /*: RequestOptions*/) /*: Promise<void>*/{
  14609. options = options || {};
  14610. var upgradeOptions = {};
  14611. if (options.hasOwnProperty('useMasterKey')) {
  14612. upgradeOptions.useMasterKey = options.useMasterKey;
  14613. }
  14614. var controller = _CoreManager.default.getUserController();
  14615. return controller.upgradeToRevocableSession(this, upgradeOptions);
  14616. }
  14617. /**
  14618. * 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
  14619. * your users to sign up or log into your application using their existing identities.
  14620. * Since 2.9.0
  14621. *
  14622. * @see {@link https://docs.parseplatform.org/js/guide/#linking-users Linking Users}
  14623. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  14624. * @param {object} options
  14625. * <ul>
  14626. * <li>If provider is string, options is {@link http://docs.parseplatform.org/parse-server/guide/#supported-3rd-party-authentications authData}
  14627. * <li>If provider is AuthProvider, options is saveOpts
  14628. * </ul>
  14629. * @param {object} saveOpts useMasterKey / sessionToken
  14630. * @returns {Promise} A promise that is fulfilled with the user is linked
  14631. */
  14632. }, {
  14633. key: "linkWith",
  14634. value: function (provider /*: any*/, options /*: { authData?: AuthData }*/) /*: Promise<ParseUser>*/{
  14635. var _this2 = this;
  14636. var saveOpts /*:: ?: FullOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  14637. saveOpts.sessionToken = saveOpts.sessionToken || this.getSessionToken() || '';
  14638. var authType;
  14639. if (typeof provider === 'string') {
  14640. authType = provider;
  14641. if (authProviders[provider]) {
  14642. provider = authProviders[provider];
  14643. } else {
  14644. var authProvider = {
  14645. restoreAuthentication: function () {
  14646. return true;
  14647. },
  14648. getAuthType: function () {
  14649. return authType;
  14650. }
  14651. };
  14652. authProviders[authProvider.getAuthType()] = authProvider;
  14653. provider = authProvider;
  14654. }
  14655. } else {
  14656. authType = provider.getAuthType();
  14657. }
  14658. if (options && options.hasOwnProperty('authData')) {
  14659. var authData = this.get('authData') || {};
  14660. if ((0, _typeof2.default)(authData) !== 'object') {
  14661. throw new Error('Invalid type: authData field should be an object');
  14662. }
  14663. authData[authType] = options.authData;
  14664. var controller = _CoreManager.default.getUserController();
  14665. return controller.linkWith(this, authData, saveOpts);
  14666. } else {
  14667. return new _promise.default(function (resolve, reject) {
  14668. provider.authenticate({
  14669. success: function (provider, result) {
  14670. var opts = {};
  14671. opts.authData = result;
  14672. _this2.linkWith(provider, opts, saveOpts).then(function () {
  14673. resolve(_this2);
  14674. }, function (error) {
  14675. reject(error);
  14676. });
  14677. },
  14678. error: function (provider, _error) {
  14679. reject(_error);
  14680. }
  14681. });
  14682. });
  14683. }
  14684. }
  14685. /**
  14686. * @param provider
  14687. * @param options
  14688. * @param saveOpts
  14689. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  14690. * @returns {Promise}
  14691. */
  14692. }, {
  14693. key: "_linkWith",
  14694. value: function (provider /*: any*/, options /*: { authData?: AuthData }*/) /*: Promise<ParseUser>*/{
  14695. var saveOpts /*:: ?: FullOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  14696. return this.linkWith(provider, options, saveOpts);
  14697. }
  14698. /**
  14699. * Synchronizes auth data for a provider (e.g. puts the access token in the
  14700. * right place to be used by the Facebook SDK).
  14701. *
  14702. * @param provider
  14703. */
  14704. }, {
  14705. key: "_synchronizeAuthData",
  14706. value: function (provider /*: string*/) {
  14707. if (!this.isCurrent() || !provider) {
  14708. return;
  14709. }
  14710. var authType;
  14711. if (typeof provider === 'string') {
  14712. authType = provider;
  14713. provider = authProviders[authType];
  14714. } else {
  14715. authType = provider.getAuthType();
  14716. }
  14717. var authData = this.get('authData');
  14718. if (!provider || !authData || (0, _typeof2.default)(authData) !== 'object') {
  14719. return;
  14720. }
  14721. var success = provider.restoreAuthentication(authData[authType]);
  14722. if (!success) {
  14723. this._unlinkFrom(provider);
  14724. }
  14725. }
  14726. /**
  14727. * Synchronizes authData for all providers.
  14728. */
  14729. }, {
  14730. key: "_synchronizeAllAuthData",
  14731. value: function () {
  14732. var authData = this.get('authData');
  14733. if ((0, _typeof2.default)(authData) !== 'object') {
  14734. return;
  14735. }
  14736. for (var _key in authData) {
  14737. this._synchronizeAuthData(_key);
  14738. }
  14739. }
  14740. /**
  14741. * Removes null values from authData (which exist temporarily for unlinking)
  14742. */
  14743. }, {
  14744. key: "_cleanupAuthData",
  14745. value: function () {
  14746. if (!this.isCurrent()) {
  14747. return;
  14748. }
  14749. var authData = this.get('authData');
  14750. if ((0, _typeof2.default)(authData) !== 'object') {
  14751. return;
  14752. }
  14753. for (var _key2 in authData) {
  14754. if (!authData[_key2]) {
  14755. delete authData[_key2];
  14756. }
  14757. }
  14758. }
  14759. /**
  14760. * Unlinks a user from a service.
  14761. *
  14762. * @param {string | AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  14763. * @param {object} options MasterKey / SessionToken
  14764. * @returns {Promise} A promise that is fulfilled when the unlinking
  14765. * finishes.
  14766. */
  14767. }, {
  14768. key: "_unlinkFrom",
  14769. value: function (provider /*: any*/, options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
  14770. var _this3 = this;
  14771. return this.linkWith(provider, {
  14772. authData: null
  14773. }, options).then(function () {
  14774. _this3._synchronizeAuthData(provider);
  14775. return _promise.default.resolve(_this3);
  14776. });
  14777. }
  14778. /**
  14779. * Checks whether a user is linked to a service.
  14780. *
  14781. * @param {object} provider service to link to
  14782. * @returns {boolean} true if link was successful
  14783. */
  14784. }, {
  14785. key: "_isLinked",
  14786. value: function (provider /*: any*/) /*: boolean*/{
  14787. var authType;
  14788. if (typeof provider === 'string') {
  14789. authType = provider;
  14790. } else {
  14791. authType = provider.getAuthType();
  14792. }
  14793. var authData = this.get('authData') || {};
  14794. if ((0, _typeof2.default)(authData) !== 'object') {
  14795. return false;
  14796. }
  14797. return !!authData[authType];
  14798. }
  14799. /**
  14800. * Deauthenticates all providers.
  14801. */
  14802. }, {
  14803. key: "_logOutWithAll",
  14804. value: function () {
  14805. var authData = this.get('authData');
  14806. if ((0, _typeof2.default)(authData) !== 'object') {
  14807. return;
  14808. }
  14809. for (var _key3 in authData) {
  14810. this._logOutWith(_key3);
  14811. }
  14812. }
  14813. /**
  14814. * Deauthenticates a single provider (e.g. removing access tokens from the
  14815. * Facebook SDK).
  14816. *
  14817. * @param {object} provider service to logout of
  14818. */
  14819. }, {
  14820. key: "_logOutWith",
  14821. value: function (provider /*: any*/) {
  14822. if (!this.isCurrent()) {
  14823. return;
  14824. }
  14825. if (typeof provider === 'string') {
  14826. provider = authProviders[provider];
  14827. }
  14828. if (provider && provider.deauthenticate) {
  14829. provider.deauthenticate();
  14830. }
  14831. }
  14832. /**
  14833. * Class instance method used to maintain specific keys when a fetch occurs.
  14834. * Used to ensure that the session token is not lost.
  14835. *
  14836. * @returns {object} sessionToken
  14837. */
  14838. }, {
  14839. key: "_preserveFieldsOnFetch",
  14840. value: function () /*: AttributeMap*/{
  14841. return {
  14842. sessionToken: this.get('sessionToken')
  14843. };
  14844. }
  14845. /**
  14846. * Returns true if <code>current</code> would return this user.
  14847. *
  14848. * @returns {boolean} true if user is cached on disk
  14849. */
  14850. }, {
  14851. key: "isCurrent",
  14852. value: function () /*: boolean*/{
  14853. var current = ParseUser.current();
  14854. return !!current && current.id === this.id;
  14855. }
  14856. /**
  14857. * Returns true if <code>current</code> would return this user.
  14858. *
  14859. * @returns {Promise<boolean>} true if user is cached on disk
  14860. */
  14861. }, {
  14862. key: "isCurrentAsync",
  14863. value: function () {
  14864. var _isCurrentAsync = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  14865. var current;
  14866. return _regenerator.default.wrap(function (_context) {
  14867. while (1) switch (_context.prev = _context.next) {
  14868. case 0:
  14869. _context.next = 2;
  14870. return ParseUser.currentAsync();
  14871. case 2:
  14872. current = _context.sent;
  14873. return _context.abrupt("return", !!current && current.id === this.id);
  14874. case 4:
  14875. case "end":
  14876. return _context.stop();
  14877. }
  14878. }, _callee, this);
  14879. }));
  14880. function isCurrentAsync() {
  14881. return _isCurrentAsync.apply(this, arguments);
  14882. }
  14883. return isCurrentAsync;
  14884. }()
  14885. /**
  14886. * Returns get("username").
  14887. *
  14888. * @returns {string}
  14889. */
  14890. }, {
  14891. key: "getUsername",
  14892. value: function () /*: ?string*/{
  14893. var username = this.get('username');
  14894. if (username == null || typeof username === 'string') {
  14895. return username;
  14896. }
  14897. return '';
  14898. }
  14899. /**
  14900. * Calls set("username", username, options) and returns the result.
  14901. *
  14902. * @param {string} username
  14903. */
  14904. }, {
  14905. key: "setUsername",
  14906. value: function (username /*: string*/) {
  14907. // Strip anonymity
  14908. var authData = this.get('authData');
  14909. if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
  14910. // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
  14911. authData.anonymous = null;
  14912. }
  14913. this.set('username', username);
  14914. }
  14915. /**
  14916. * Calls set("password", password, options) and returns the result.
  14917. *
  14918. * @param {string} password User's Password
  14919. */
  14920. }, {
  14921. key: "setPassword",
  14922. value: function (password /*: string*/) {
  14923. this.set('password', password);
  14924. }
  14925. /**
  14926. * Returns get("email").
  14927. *
  14928. * @returns {string} User's Email
  14929. */
  14930. }, {
  14931. key: "getEmail",
  14932. value: function () /*: ?string*/{
  14933. var email = this.get('email');
  14934. if (email == null || typeof email === 'string') {
  14935. return email;
  14936. }
  14937. return '';
  14938. }
  14939. /**
  14940. * Calls set("email", email) and returns the result.
  14941. *
  14942. * @param {string} email
  14943. * @returns {boolean}
  14944. */
  14945. }, {
  14946. key: "setEmail",
  14947. value: function (email /*: string*/) {
  14948. return this.set('email', email);
  14949. }
  14950. /**
  14951. * Returns the session token for this user, if the user has been logged in,
  14952. * or if it is the result of a query with the master key. Otherwise, returns
  14953. * undefined.
  14954. *
  14955. * @returns {string} the session token, or undefined
  14956. */
  14957. }, {
  14958. key: "getSessionToken",
  14959. value: function () /*: ?string*/{
  14960. var token = this.get('sessionToken');
  14961. if (token == null || typeof token === 'string') {
  14962. return token;
  14963. }
  14964. return '';
  14965. }
  14966. /**
  14967. * Checks whether this user is the current user and has been authenticated.
  14968. *
  14969. * @returns {boolean} whether this user is the current user and is logged in.
  14970. */
  14971. }, {
  14972. key: "authenticated",
  14973. value: function () /*: boolean*/{
  14974. var current = ParseUser.current();
  14975. return !!this.get('sessionToken') && !!current && current.id === this.id;
  14976. }
  14977. /**
  14978. * Signs up a new user. You should call this instead of save for
  14979. * new Parse.Users. This will create a new Parse.User on the server, and
  14980. * also persist the session on disk so that you can access the user using
  14981. * <code>current</code>.
  14982. *
  14983. * <p>A username and password must be set before calling signUp.</p>
  14984. *
  14985. * @param {object} attrs Extra fields to set on the new user, or null.
  14986. * @param {object} options
  14987. * @returns {Promise} A promise that is fulfilled when the signup
  14988. * finishes.
  14989. */
  14990. }, {
  14991. key: "signUp",
  14992. value: function (attrs /*: AttributeMap*/, options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
  14993. options = options || {};
  14994. var signupOptions = {};
  14995. if (options.hasOwnProperty('useMasterKey')) {
  14996. signupOptions.useMasterKey = options.useMasterKey;
  14997. }
  14998. if (options.hasOwnProperty('installationId')) {
  14999. signupOptions.installationId = options.installationId;
  15000. }
  15001. if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
  15002. signupOptions.context = options.context;
  15003. }
  15004. var controller = _CoreManager.default.getUserController();
  15005. return controller.signUp(this, attrs, signupOptions);
  15006. }
  15007. /**
  15008. * Logs in a Parse.User. On success, this saves the session to disk,
  15009. * so you can retrieve the currently logged in user using
  15010. * <code>current</code>.
  15011. *
  15012. * <p>A username and password must be set before calling logIn.</p>
  15013. *
  15014. * @param {object} options
  15015. * @returns {Promise} A promise that is fulfilled with the user when
  15016. * the login is complete.
  15017. */
  15018. }, {
  15019. key: "logIn",
  15020. value: function (options /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
  15021. options = options || {};
  15022. var loginOptions = {
  15023. usePost: true
  15024. };
  15025. if (options.hasOwnProperty('useMasterKey')) {
  15026. loginOptions.useMasterKey = options.useMasterKey;
  15027. }
  15028. if (options.hasOwnProperty('installationId')) {
  15029. loginOptions.installationId = options.installationId;
  15030. }
  15031. if (options.hasOwnProperty('usePost')) {
  15032. loginOptions.usePost = options.usePost;
  15033. }
  15034. var controller = _CoreManager.default.getUserController();
  15035. return controller.logIn(this, loginOptions);
  15036. }
  15037. /**
  15038. * Wrap the default save behavior with functionality to save to local
  15039. * storage if this is current user.
  15040. *
  15041. * @param {...any} args
  15042. * @returns {Promise}
  15043. */
  15044. }, {
  15045. key: "save",
  15046. value: function () {
  15047. var _save = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
  15048. var _len,
  15049. args,
  15050. _key4,
  15051. current,
  15052. _args2 = arguments;
  15053. return _regenerator.default.wrap(function (_context2) {
  15054. while (1) switch (_context2.prev = _context2.next) {
  15055. case 0:
  15056. for (_len = _args2.length, args = new Array(_len), _key4 = 0; _key4 < _len; _key4++) {
  15057. args[_key4] = _args2[_key4];
  15058. }
  15059. _context2.next = 3;
  15060. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "save", this).apply(this, args);
  15061. case 3:
  15062. _context2.next = 5;
  15063. return this.isCurrentAsync();
  15064. case 5:
  15065. current = _context2.sent;
  15066. if (!current) {
  15067. _context2.next = 8;
  15068. break;
  15069. }
  15070. return _context2.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
  15071. case 8:
  15072. return _context2.abrupt("return", this);
  15073. case 9:
  15074. case "end":
  15075. return _context2.stop();
  15076. }
  15077. }, _callee2, this);
  15078. }));
  15079. function save() {
  15080. return _save.apply(this, arguments);
  15081. }
  15082. return save;
  15083. }()
  15084. /**
  15085. * Wrap the default destroy behavior with functionality that logs out
  15086. * the current user when it is destroyed
  15087. *
  15088. * @param {...any} args
  15089. * @returns {Parse.User}
  15090. */
  15091. }, {
  15092. key: "destroy",
  15093. value: function () {
  15094. var _destroy = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
  15095. var _len2,
  15096. args,
  15097. _key5,
  15098. current,
  15099. _args3 = arguments;
  15100. return _regenerator.default.wrap(function (_context3) {
  15101. while (1) switch (_context3.prev = _context3.next) {
  15102. case 0:
  15103. for (_len2 = _args3.length, args = new Array(_len2), _key5 = 0; _key5 < _len2; _key5++) {
  15104. args[_key5] = _args3[_key5];
  15105. }
  15106. _context3.next = 3;
  15107. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "destroy", this).apply(this, args);
  15108. case 3:
  15109. _context3.next = 5;
  15110. return this.isCurrentAsync();
  15111. case 5:
  15112. current = _context3.sent;
  15113. if (!current) {
  15114. _context3.next = 8;
  15115. break;
  15116. }
  15117. return _context3.abrupt("return", _CoreManager.default.getUserController().removeUserFromDisk());
  15118. case 8:
  15119. return _context3.abrupt("return", this);
  15120. case 9:
  15121. case "end":
  15122. return _context3.stop();
  15123. }
  15124. }, _callee3, this);
  15125. }));
  15126. function destroy() {
  15127. return _destroy.apply(this, arguments);
  15128. }
  15129. return destroy;
  15130. }()
  15131. /**
  15132. * Wrap the default fetch behavior with functionality to save to local
  15133. * storage if this is current user.
  15134. *
  15135. * @param {...any} args
  15136. * @returns {Parse.User}
  15137. */
  15138. }, {
  15139. key: "fetch",
  15140. value: function () {
  15141. var _fetch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
  15142. var _len3,
  15143. args,
  15144. _key6,
  15145. current,
  15146. _args4 = arguments;
  15147. return _regenerator.default.wrap(function (_context4) {
  15148. while (1) switch (_context4.prev = _context4.next) {
  15149. case 0:
  15150. for (_len3 = _args4.length, args = new Array(_len3), _key6 = 0; _key6 < _len3; _key6++) {
  15151. args[_key6] = _args4[_key6];
  15152. }
  15153. _context4.next = 3;
  15154. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetch", this).apply(this, args);
  15155. case 3:
  15156. _context4.next = 5;
  15157. return this.isCurrentAsync();
  15158. case 5:
  15159. current = _context4.sent;
  15160. if (!current) {
  15161. _context4.next = 8;
  15162. break;
  15163. }
  15164. return _context4.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
  15165. case 8:
  15166. return _context4.abrupt("return", this);
  15167. case 9:
  15168. case "end":
  15169. return _context4.stop();
  15170. }
  15171. }, _callee4, this);
  15172. }));
  15173. function fetch() {
  15174. return _fetch.apply(this, arguments);
  15175. }
  15176. return fetch;
  15177. }()
  15178. /**
  15179. * Wrap the default fetchWithInclude behavior with functionality to save to local
  15180. * storage if this is current user.
  15181. *
  15182. * @param {...any} args
  15183. * @returns {Parse.User}
  15184. */
  15185. }, {
  15186. key: "fetchWithInclude",
  15187. value: function () {
  15188. var _fetchWithInclude = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
  15189. var _len4,
  15190. args,
  15191. _key7,
  15192. current,
  15193. _args5 = arguments;
  15194. return _regenerator.default.wrap(function (_context5) {
  15195. while (1) switch (_context5.prev = _context5.next) {
  15196. case 0:
  15197. for (_len4 = _args5.length, args = new Array(_len4), _key7 = 0; _key7 < _len4; _key7++) {
  15198. args[_key7] = _args5[_key7];
  15199. }
  15200. _context5.next = 3;
  15201. return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseUser.prototype), "fetchWithInclude", this).apply(this, args);
  15202. case 3:
  15203. _context5.next = 5;
  15204. return this.isCurrentAsync();
  15205. case 5:
  15206. current = _context5.sent;
  15207. if (!current) {
  15208. _context5.next = 8;
  15209. break;
  15210. }
  15211. return _context5.abrupt("return", _CoreManager.default.getUserController().updateUserOnDisk(this));
  15212. case 8:
  15213. return _context5.abrupt("return", this);
  15214. case 9:
  15215. case "end":
  15216. return _context5.stop();
  15217. }
  15218. }, _callee5, this);
  15219. }));
  15220. function fetchWithInclude() {
  15221. return _fetchWithInclude.apply(this, arguments);
  15222. }
  15223. return fetchWithInclude;
  15224. }()
  15225. /**
  15226. * Verify whether a given password is the password of the current user.
  15227. *
  15228. * @param {string} password A password to be verified
  15229. * @param {object} options
  15230. * @returns {Promise} A promise that is fulfilled with a user
  15231. * when the password is correct.
  15232. */
  15233. }, {
  15234. key: "verifyPassword",
  15235. value: function (password /*: string*/, options /*:: ?: RequestOptions*/) /*: Promise<ParseUser>*/{
  15236. var username = this.getUsername() || '';
  15237. return ParseUser.verifyPassword(username, password, options);
  15238. }
  15239. }], [{
  15240. key: "readOnlyAttributes",
  15241. value: function () {
  15242. return ['sessionToken'];
  15243. }
  15244. /**
  15245. * Adds functionality to the existing Parse.User class.
  15246. *
  15247. * @param {object} protoProps A set of properties to add to the prototype
  15248. * @param {object} classProps A set of static properties to add to the class
  15249. * @static
  15250. * @returns {Parse.User} The newly extended Parse.User class
  15251. */
  15252. }, {
  15253. key: "extend",
  15254. value: function (protoProps /*: { [prop: string]: any }*/, classProps /*: { [prop: string]: any }*/) {
  15255. if (protoProps) {
  15256. for (var _prop in protoProps) {
  15257. if (_prop !== 'className') {
  15258. (0, _defineProperty.default)(ParseUser.prototype, _prop, {
  15259. value: protoProps[_prop],
  15260. enumerable: false,
  15261. writable: true,
  15262. configurable: true
  15263. });
  15264. }
  15265. }
  15266. }
  15267. if (classProps) {
  15268. for (var _prop2 in classProps) {
  15269. if (_prop2 !== 'className') {
  15270. (0, _defineProperty.default)(ParseUser, _prop2, {
  15271. value: classProps[_prop2],
  15272. enumerable: false,
  15273. writable: true,
  15274. configurable: true
  15275. });
  15276. }
  15277. }
  15278. }
  15279. return ParseUser;
  15280. }
  15281. /**
  15282. * Retrieves the currently logged in ParseUser with a valid session,
  15283. * either from memory or localStorage, if necessary.
  15284. *
  15285. * @static
  15286. * @returns {Parse.Object} The currently logged in Parse.User.
  15287. */
  15288. }, {
  15289. key: "current",
  15290. value: function () /*: ?ParseUser*/{
  15291. if (!canUseCurrentUser) {
  15292. return null;
  15293. }
  15294. var controller = _CoreManager.default.getUserController();
  15295. return controller.currentUser();
  15296. }
  15297. /**
  15298. * Retrieves the currently logged in ParseUser from asynchronous Storage.
  15299. *
  15300. * @static
  15301. * @returns {Promise} A Promise that is resolved with the currently
  15302. * logged in Parse User
  15303. */
  15304. }, {
  15305. key: "currentAsync",
  15306. value: function () /*: Promise<?ParseUser>*/{
  15307. if (!canUseCurrentUser) {
  15308. return _promise.default.resolve(null);
  15309. }
  15310. var controller = _CoreManager.default.getUserController();
  15311. return controller.currentUserAsync();
  15312. }
  15313. /**
  15314. * Signs up a new user with a username (or email) and password.
  15315. * This will create a new Parse.User on the server, and also persist the
  15316. * session in localStorage so that you can access the user using
  15317. * {@link #current}.
  15318. *
  15319. * @param {string} username The username (or email) to sign up with.
  15320. * @param {string} password The password to sign up with.
  15321. * @param {object} attrs Extra fields to set on the new user.
  15322. * @param {object} options
  15323. * @static
  15324. * @returns {Promise} A promise that is fulfilled with the user when
  15325. * the signup completes.
  15326. */
  15327. }, {
  15328. key: "signUp",
  15329. value: function (username /*: string*/, password /*: string*/, attrs /*: AttributeMap*/, options /*:: ?: FullOptions*/) {
  15330. attrs = attrs || {};
  15331. attrs.username = username;
  15332. attrs.password = password;
  15333. var user = new this(attrs);
  15334. return user.signUp({}, options);
  15335. }
  15336. /**
  15337. * Logs in a user with a username (or email) and password. On success, this
  15338. * saves the session to disk, so you can retrieve the currently logged in
  15339. * user using <code>current</code>.
  15340. *
  15341. * @param {string} username The username (or email) to log in with.
  15342. * @param {string} password The password to log in with.
  15343. * @param {object} options
  15344. * @static
  15345. * @returns {Promise} A promise that is fulfilled with the user when
  15346. * the login completes.
  15347. */
  15348. }, {
  15349. key: "logIn",
  15350. value: function (username /*: string*/, password /*: string*/, options /*:: ?: FullOptions*/) {
  15351. if (typeof username !== 'string') {
  15352. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  15353. } else if (typeof password !== 'string') {
  15354. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  15355. }
  15356. var user = new this();
  15357. user._finishFetch({
  15358. username: username,
  15359. password: password
  15360. });
  15361. return user.logIn(options);
  15362. }
  15363. /**
  15364. * Logs in a user with an objectId. On success, this saves the session
  15365. * to disk, so you can retrieve the currently logged in user using
  15366. * <code>current</code>.
  15367. *
  15368. * @param {string} userId The objectId for the user.
  15369. * @static
  15370. * @returns {Promise} A promise that is fulfilled with the user when
  15371. * the login completes.
  15372. */
  15373. }, {
  15374. key: "loginAs",
  15375. value: function (userId /*: string*/) {
  15376. if (!userId) {
  15377. throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
  15378. }
  15379. var controller = _CoreManager.default.getUserController();
  15380. var user = new this();
  15381. return controller.loginAs(user, userId);
  15382. }
  15383. /**
  15384. * Logs in a user with a session token. On success, this saves the session
  15385. * to disk, so you can retrieve the currently logged in user using
  15386. * <code>current</code>.
  15387. *
  15388. * @param {string} sessionToken The sessionToken to log in with.
  15389. * @param {object} options
  15390. * @static
  15391. * @returns {Promise} A promise that is fulfilled with the user when
  15392. * the login completes.
  15393. */
  15394. }, {
  15395. key: "become",
  15396. value: function (sessionToken /*: string*/, options /*:: ?: RequestOptions*/) {
  15397. if (!canUseCurrentUser) {
  15398. throw new Error('It is not memory-safe to become a user in a server environment');
  15399. }
  15400. options = options || {};
  15401. var becomeOptions /*: RequestOptions*/ = {
  15402. sessionToken: sessionToken
  15403. };
  15404. if (options.hasOwnProperty('useMasterKey')) {
  15405. becomeOptions.useMasterKey = options.useMasterKey;
  15406. }
  15407. var controller = _CoreManager.default.getUserController();
  15408. var user = new this();
  15409. return controller.become(user, becomeOptions);
  15410. }
  15411. /**
  15412. * Retrieves a user with a session token.
  15413. *
  15414. * @param {string} sessionToken The sessionToken to get user with.
  15415. * @param {object} options
  15416. * @static
  15417. * @returns {Promise} A promise that is fulfilled with the user is fetched.
  15418. */
  15419. }, {
  15420. key: "me",
  15421. value: function (sessionToken /*: string*/) {
  15422. var options /*:: ?: RequestOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  15423. var controller = _CoreManager.default.getUserController();
  15424. var meOptions /*: RequestOptions*/ = {
  15425. sessionToken: sessionToken
  15426. };
  15427. if (options.useMasterKey) {
  15428. meOptions.useMasterKey = options.useMasterKey;
  15429. }
  15430. var user = new this();
  15431. return controller.me(user, meOptions);
  15432. }
  15433. /**
  15434. * Logs in a user with a session token. On success, this saves the session
  15435. * to disk, so you can retrieve the currently logged in user using
  15436. * <code>current</code>. If there is no session token the user will not logged in.
  15437. *
  15438. * @param {object} userJSON The JSON map of the User's data
  15439. * @static
  15440. * @returns {Promise} A promise that is fulfilled with the user when
  15441. * the login completes.
  15442. */
  15443. }, {
  15444. key: "hydrate",
  15445. value: function (userJSON /*: AttributeMap*/) {
  15446. var controller = _CoreManager.default.getUserController();
  15447. var user = new this();
  15448. return controller.hydrate(user, userJSON);
  15449. }
  15450. /**
  15451. * Static version of {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith}
  15452. *
  15453. * @param provider
  15454. * @param options
  15455. * @param saveOpts
  15456. * @static
  15457. * @returns {Promise}
  15458. */
  15459. }, {
  15460. key: "logInWith",
  15461. value: function (provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*:: ?: FullOptions*/) /*: Promise<ParseUser>*/{
  15462. var user = new this();
  15463. return user.linkWith(provider, options, saveOpts);
  15464. }
  15465. /**
  15466. * Logs out the currently logged in user session. This will remove the
  15467. * session from disk, log out of linked services, and future calls to
  15468. * <code>current</code> will return <code>null</code>.
  15469. *
  15470. * @param {object} options
  15471. * @static
  15472. * @returns {Promise} A promise that is resolved when the session is
  15473. * destroyed on the server.
  15474. */
  15475. }, {
  15476. key: "logOut",
  15477. value: function () {
  15478. var options /*: RequestOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  15479. var controller = _CoreManager.default.getUserController();
  15480. return controller.logOut(options);
  15481. }
  15482. /**
  15483. * Requests a password reset email to be sent to the specified email address
  15484. * associated with the user account. This email allows the user to securely
  15485. * reset their password on the Parse site.
  15486. *
  15487. * @param {string} email The email address associated with the user that
  15488. * forgot their password.
  15489. * @param {object} options
  15490. * @static
  15491. * @returns {Promise}
  15492. */
  15493. }, {
  15494. key: "requestPasswordReset",
  15495. value: function (email /*: string*/, options /*:: ?: RequestOptions*/) {
  15496. options = options || {};
  15497. var requestOptions = {};
  15498. if (options.hasOwnProperty('useMasterKey')) {
  15499. requestOptions.useMasterKey = options.useMasterKey;
  15500. }
  15501. var controller = _CoreManager.default.getUserController();
  15502. return controller.requestPasswordReset(email, requestOptions);
  15503. }
  15504. /**
  15505. * Request an email verification.
  15506. *
  15507. * @param {string} email The email address associated with the user that
  15508. * needs to verify their email.
  15509. * @param {object} options
  15510. * @static
  15511. * @returns {Promise}
  15512. */
  15513. }, {
  15514. key: "requestEmailVerification",
  15515. value: function (email /*: string*/, options /*:: ?: RequestOptions*/) {
  15516. options = options || {};
  15517. var requestOptions = {};
  15518. if (options.hasOwnProperty('useMasterKey')) {
  15519. requestOptions.useMasterKey = options.useMasterKey;
  15520. }
  15521. var controller = _CoreManager.default.getUserController();
  15522. return controller.requestEmailVerification(email, requestOptions);
  15523. }
  15524. /**
  15525. * Verify whether a given password is the password of the current user.
  15526. *
  15527. * @param {string} username A username to be used for identificaiton
  15528. * @param {string} password A password to be verified
  15529. * @param {object} options
  15530. * @static
  15531. * @returns {Promise} A promise that is fulfilled with a user
  15532. * when the password is correct.
  15533. */
  15534. }, {
  15535. key: "verifyPassword",
  15536. value: function (username /*: string*/, password /*: string*/, options /*:: ?: RequestOptions*/) {
  15537. if (typeof username !== 'string') {
  15538. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
  15539. }
  15540. if (typeof password !== 'string') {
  15541. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
  15542. }
  15543. options = options || {};
  15544. var verificationOption = {};
  15545. if (options.hasOwnProperty('useMasterKey')) {
  15546. verificationOption.useMasterKey = options.useMasterKey;
  15547. }
  15548. var controller = _CoreManager.default.getUserController();
  15549. return controller.verifyPassword(username, password, verificationOption);
  15550. }
  15551. /**
  15552. * Allow someone to define a custom User class without className
  15553. * being rewritten to _User. The default behavior is to rewrite
  15554. * User to _User for legacy reasons. This allows developers to
  15555. * override that behavior.
  15556. *
  15557. * @param {boolean} isAllowed Whether or not to allow custom User class
  15558. * @static
  15559. */
  15560. }, {
  15561. key: "allowCustomUserClass",
  15562. value: function (isAllowed /*: boolean*/) {
  15563. _CoreManager.default.set('PERFORM_USER_REWRITE', !isAllowed);
  15564. }
  15565. /**
  15566. * Allows a legacy application to start using revocable sessions. If the
  15567. * current session token is not revocable, a request will be made for a new,
  15568. * revocable session.
  15569. * It is not necessary to call this method from cloud code unless you are
  15570. * handling user signup or login from the server side. In a cloud code call,
  15571. * this function will not attempt to upgrade the current token.
  15572. *
  15573. * @param {object} options
  15574. * @static
  15575. * @returns {Promise} A promise that is resolved when the process has
  15576. * completed. If a replacement session token is requested, the promise
  15577. * will be resolved after a new token has been fetched.
  15578. */
  15579. }, {
  15580. key: "enableRevocableSession",
  15581. value: function (options /*:: ?: RequestOptions*/) {
  15582. options = options || {};
  15583. _CoreManager.default.set('FORCE_REVOCABLE_SESSION', true);
  15584. if (canUseCurrentUser) {
  15585. var current = ParseUser.current();
  15586. if (current) {
  15587. return current._upgradeToRevocableSession(options);
  15588. }
  15589. }
  15590. return _promise.default.resolve();
  15591. }
  15592. /**
  15593. * Enables the use of become or the current user in a server
  15594. * environment. These features are disabled by default, since they depend on
  15595. * global objects that are not memory-safe for most servers.
  15596. *
  15597. * @static
  15598. */
  15599. }, {
  15600. key: "enableUnsafeCurrentUser",
  15601. value: function () {
  15602. canUseCurrentUser = true;
  15603. }
  15604. /**
  15605. * Disables the use of become or the current user in any environment.
  15606. * These features are disabled on servers by default, since they depend on
  15607. * global objects that are not memory-safe for most servers.
  15608. *
  15609. * @static
  15610. */
  15611. }, {
  15612. key: "disableUnsafeCurrentUser",
  15613. value: function () {
  15614. canUseCurrentUser = false;
  15615. }
  15616. /**
  15617. * When registering users with {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#linkWith linkWith} a basic auth provider
  15618. * is automatically created for you.
  15619. *
  15620. * For advanced authentication, you can register an Auth provider to
  15621. * implement custom authentication, deauthentication.
  15622. *
  15623. * @param provider
  15624. * @see {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
  15625. * @see {@link https://docs.parseplatform.org/js/guide/#custom-authentication-module Custom Authentication Module}
  15626. * @static
  15627. */
  15628. }, {
  15629. key: "_registerAuthenticationProvider",
  15630. value: function (provider /*: any*/) {
  15631. authProviders[provider.getAuthType()] = provider;
  15632. // Synchronize the current user with the auth provider.
  15633. ParseUser.currentAsync().then(function (current) {
  15634. if (current) {
  15635. current._synchronizeAuthData(provider.getAuthType());
  15636. }
  15637. });
  15638. }
  15639. /**
  15640. * @param provider
  15641. * @param options
  15642. * @param saveOpts
  15643. * @deprecated since 2.9.0 see {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.User.html#logInWith logInWith}
  15644. * @static
  15645. * @returns {Promise}
  15646. */
  15647. }, {
  15648. key: "_logInWith",
  15649. value: function (provider /*: any*/, options /*: { authData?: AuthData }*/, saveOpts /*:: ?: FullOptions*/) {
  15650. var user = new this();
  15651. return user.linkWith(provider, options, saveOpts);
  15652. }
  15653. }, {
  15654. key: "_clearCache",
  15655. value: function () {
  15656. currentUserCache = null;
  15657. currentUserCacheMatchesDisk = false;
  15658. }
  15659. }, {
  15660. key: "_setCurrentUserCache",
  15661. value: function (user /*: ParseUser*/) {
  15662. currentUserCache = user;
  15663. }
  15664. }]);
  15665. return ParseUser;
  15666. }(_ParseObject2.default);
  15667. _ParseObject2.default.registerSubclass('_User', ParseUser);
  15668. var DefaultController = {
  15669. updateUserOnDisk: function (user) {
  15670. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  15671. var json = user.toJSON();
  15672. delete json.password;
  15673. json.className = '_User';
  15674. var userData = (0, _stringify.default)(json);
  15675. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  15676. var crypto = _CoreManager.default.getCryptoController();
  15677. userData = crypto.encrypt(json, _CoreManager.default.get('ENCRYPTED_KEY'));
  15678. }
  15679. return _Storage.default.setItemAsync(path, userData).then(function () {
  15680. return user;
  15681. });
  15682. },
  15683. removeUserFromDisk: function () {
  15684. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  15685. currentUserCacheMatchesDisk = true;
  15686. currentUserCache = null;
  15687. return _Storage.default.removeItemAsync(path);
  15688. },
  15689. setCurrentUser: function (user) {
  15690. currentUserCache = user;
  15691. user._cleanupAuthData();
  15692. user._synchronizeAllAuthData();
  15693. return DefaultController.updateUserOnDisk(user);
  15694. },
  15695. currentUser: function () /*: ?ParseUser*/{
  15696. if (currentUserCache) {
  15697. return currentUserCache;
  15698. }
  15699. if (currentUserCacheMatchesDisk) {
  15700. return null;
  15701. }
  15702. if (_Storage.default.async()) {
  15703. throw new Error('Cannot call currentUser() when using a platform with an async ' + 'storage system. Call currentUserAsync() instead.');
  15704. }
  15705. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  15706. var userData = _Storage.default.getItem(path);
  15707. currentUserCacheMatchesDisk = true;
  15708. if (!userData) {
  15709. currentUserCache = null;
  15710. return null;
  15711. }
  15712. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  15713. var crypto = _CoreManager.default.getCryptoController();
  15714. userData = crypto.decrypt(userData, _CoreManager.default.get('ENCRYPTED_KEY'));
  15715. }
  15716. userData = JSON.parse(userData);
  15717. if (!userData.className) {
  15718. userData.className = '_User';
  15719. }
  15720. if (userData._id) {
  15721. if (userData.objectId !== userData._id) {
  15722. userData.objectId = userData._id;
  15723. }
  15724. delete userData._id;
  15725. }
  15726. if (userData._sessionToken) {
  15727. userData.sessionToken = userData._sessionToken;
  15728. delete userData._sessionToken;
  15729. }
  15730. var current = _ParseObject2.default.fromJSON(userData);
  15731. currentUserCache = current;
  15732. current._synchronizeAllAuthData();
  15733. return current;
  15734. },
  15735. currentUserAsync: function () /*: Promise<?ParseUser>*/{
  15736. if (currentUserCache) {
  15737. return _promise.default.resolve(currentUserCache);
  15738. }
  15739. if (currentUserCacheMatchesDisk) {
  15740. return _promise.default.resolve(null);
  15741. }
  15742. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  15743. return _Storage.default.getItemAsync(path).then(function (userData) {
  15744. currentUserCacheMatchesDisk = true;
  15745. if (!userData) {
  15746. currentUserCache = null;
  15747. return _promise.default.resolve(null);
  15748. }
  15749. if (_CoreManager.default.get('ENCRYPTED_USER')) {
  15750. var crypto = _CoreManager.default.getCryptoController();
  15751. userData = crypto.decrypt(userData.toString(), _CoreManager.default.get('ENCRYPTED_KEY'));
  15752. }
  15753. userData = JSON.parse(userData);
  15754. if (!userData.className) {
  15755. userData.className = '_User';
  15756. }
  15757. if (userData._id) {
  15758. if (userData.objectId !== userData._id) {
  15759. userData.objectId = userData._id;
  15760. }
  15761. delete userData._id;
  15762. }
  15763. if (userData._sessionToken) {
  15764. userData.sessionToken = userData._sessionToken;
  15765. delete userData._sessionToken;
  15766. }
  15767. var current = _ParseObject2.default.fromJSON(userData);
  15768. currentUserCache = current;
  15769. current._synchronizeAllAuthData();
  15770. return _promise.default.resolve(current);
  15771. });
  15772. },
  15773. signUp: function (user /*: ParseUser*/, attrs /*: AttributeMap*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
  15774. var username = attrs && attrs.username || user.get('username');
  15775. var password = attrs && attrs.password || user.get('password');
  15776. if (!username || !username.length) {
  15777. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty username.'));
  15778. }
  15779. if (!password || !password.length) {
  15780. return _promise.default.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Cannot sign up user with an empty password.'));
  15781. }
  15782. return user.save(attrs, options).then(function () {
  15783. // Clear the password field
  15784. user._finishFetch({
  15785. password: undefined
  15786. });
  15787. if (canUseCurrentUser) {
  15788. return DefaultController.setCurrentUser(user);
  15789. }
  15790. return user;
  15791. });
  15792. },
  15793. logIn: function (user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
  15794. var RESTController = _CoreManager.default.getRESTController();
  15795. var stateController = _CoreManager.default.getObjectStateController();
  15796. var auth = {
  15797. username: user.get('username'),
  15798. password: user.get('password')
  15799. };
  15800. return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(function (response) {
  15801. user._migrateId(response.objectId);
  15802. user._setExisted(true);
  15803. stateController.setPendingOp(user._getStateIdentifier(), 'username', undefined);
  15804. stateController.setPendingOp(user._getStateIdentifier(), 'password', undefined);
  15805. response.password = undefined;
  15806. user._finishFetch(response);
  15807. if (!canUseCurrentUser) {
  15808. // We can't set the current user, so just return the one we logged in
  15809. return _promise.default.resolve(user);
  15810. }
  15811. return DefaultController.setCurrentUser(user);
  15812. });
  15813. },
  15814. loginAs: function (user /*: ParseUser*/, userId /*: string*/) /*: Promise<ParseUser>*/{
  15815. var RESTController = _CoreManager.default.getRESTController();
  15816. return RESTController.request('POST', 'loginAs', {
  15817. userId: userId
  15818. }, {
  15819. useMasterKey: true
  15820. }).then(function (response) {
  15821. user._finishFetch(response);
  15822. user._setExisted(true);
  15823. if (!canUseCurrentUser) {
  15824. return _promise.default.resolve(user);
  15825. }
  15826. return DefaultController.setCurrentUser(user);
  15827. });
  15828. },
  15829. become: function (user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
  15830. var RESTController = _CoreManager.default.getRESTController();
  15831. return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
  15832. user._finishFetch(response);
  15833. user._setExisted(true);
  15834. return DefaultController.setCurrentUser(user);
  15835. });
  15836. },
  15837. hydrate: function (user /*: ParseUser*/, userJSON /*: AttributeMap*/) /*: Promise<ParseUser>*/{
  15838. user._finishFetch(userJSON);
  15839. user._setExisted(true);
  15840. if (userJSON.sessionToken && canUseCurrentUser) {
  15841. return DefaultController.setCurrentUser(user);
  15842. } else {
  15843. return _promise.default.resolve(user);
  15844. }
  15845. },
  15846. me: function (user /*: ParseUser*/, options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
  15847. var RESTController = _CoreManager.default.getRESTController();
  15848. return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
  15849. user._finishFetch(response);
  15850. user._setExisted(true);
  15851. return user;
  15852. });
  15853. },
  15854. logOut: function (options /*: RequestOptions*/) /*: Promise<ParseUser>*/{
  15855. var RESTController = _CoreManager.default.getRESTController();
  15856. if (options.sessionToken) {
  15857. return RESTController.request('POST', 'logout', {}, options);
  15858. }
  15859. return DefaultController.currentUserAsync().then(function (currentUser) {
  15860. var path = _Storage.default.generatePath(CURRENT_USER_KEY);
  15861. var promise = _Storage.default.removeItemAsync(path);
  15862. if (currentUser !== null) {
  15863. var currentSession = currentUser.getSessionToken();
  15864. if (currentSession && (0, _isRevocableSession.default)(currentSession)) {
  15865. promise = promise.then(function () {
  15866. return RESTController.request('POST', 'logout', {}, {
  15867. sessionToken: currentSession
  15868. });
  15869. });
  15870. }
  15871. currentUser._logOutWithAll();
  15872. currentUser._finishFetch({
  15873. sessionToken: undefined
  15874. });
  15875. }
  15876. currentUserCacheMatchesDisk = true;
  15877. currentUserCache = null;
  15878. return promise;
  15879. });
  15880. },
  15881. requestPasswordReset: function (email /*: string*/, options /*: RequestOptions*/) {
  15882. var RESTController = _CoreManager.default.getRESTController();
  15883. return RESTController.request('POST', 'requestPasswordReset', {
  15884. email: email
  15885. }, options);
  15886. },
  15887. upgradeToRevocableSession: function (user /*: ParseUser*/, options /*: RequestOptions*/) {
  15888. return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
  15889. var token, RESTController, result, session, current;
  15890. return _regenerator.default.wrap(function (_context6) {
  15891. while (1) switch (_context6.prev = _context6.next) {
  15892. case 0:
  15893. token = user.getSessionToken();
  15894. if (token) {
  15895. _context6.next = 3;
  15896. break;
  15897. }
  15898. return _context6.abrupt("return", _promise.default.reject(new _ParseError.default(_ParseError.default.SESSION_MISSING, 'Cannot upgrade a user with no session token')));
  15899. case 3:
  15900. options.sessionToken = token;
  15901. RESTController = _CoreManager.default.getRESTController();
  15902. _context6.next = 7;
  15903. return RESTController.request('POST', 'upgradeToRevocableSession', {}, options);
  15904. case 7:
  15905. result = _context6.sent;
  15906. session = new _ParseSession.default();
  15907. session._finishFetch(result);
  15908. user._finishFetch({
  15909. sessionToken: session.getSessionToken()
  15910. });
  15911. _context6.next = 13;
  15912. return user.isCurrentAsync();
  15913. case 13:
  15914. current = _context6.sent;
  15915. if (!current) {
  15916. _context6.next = 16;
  15917. break;
  15918. }
  15919. return _context6.abrupt("return", DefaultController.setCurrentUser(user));
  15920. case 16:
  15921. return _context6.abrupt("return", _promise.default.resolve(user));
  15922. case 17:
  15923. case "end":
  15924. return _context6.stop();
  15925. }
  15926. }, _callee6);
  15927. }))();
  15928. },
  15929. linkWith: function (user /*: ParseUser*/, authData /*: AuthData*/, options /*: FullOptions*/) {
  15930. return user.save({
  15931. authData: authData
  15932. }, options).then(function () {
  15933. if (canUseCurrentUser) {
  15934. return DefaultController.setCurrentUser(user);
  15935. }
  15936. return user;
  15937. });
  15938. },
  15939. verifyPassword: function (username /*: string*/, password /*: string*/, options /*: RequestOptions*/) {
  15940. var RESTController = _CoreManager.default.getRESTController();
  15941. return RESTController.request('GET', 'verifyPassword', {
  15942. username: username,
  15943. password: password
  15944. }, options);
  15945. },
  15946. requestEmailVerification: function (email /*: string*/, options /*: RequestOptions*/) {
  15947. var RESTController = _CoreManager.default.getRESTController();
  15948. return RESTController.request('POST', 'verificationEmailRequest', {
  15949. email: email
  15950. }, options);
  15951. }
  15952. };
  15953. _CoreManager.default.setUserController(DefaultController);
  15954. var _default = ParseUser;
  15955. exports.default = _default;
  15956. },{"./CoreManager":4,"./ParseError":21,"./ParseObject":26,"./ParseSession":33,"./Storage":39,"./isRevocableSession":50,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/core-js-stable/reflect/construct":92,"@babel/runtime-corejs3/helpers/asyncToGenerator":122,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/get":127,"@babel/runtime-corejs3/helpers/getPrototypeOf":128,"@babel/runtime-corejs3/helpers/inherits":129,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/possibleConstructorReturn":137,"@babel/runtime-corejs3/helpers/typeof":145,"@babel/runtime-corejs3/regenerator":148}],35:[function(_dereq_,module,exports){
  15957. "use strict";
  15958. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  15959. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  15960. _Object$defineProperty(exports, "__esModule", {
  15961. value: true
  15962. });
  15963. exports.getPushStatus = getPushStatus;
  15964. exports.send = send;
  15965. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  15966. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  15967. var _ParseQuery = _interopRequireDefault(_dereq_("./ParseQuery"));
  15968. /**
  15969. * @flow
  15970. */
  15971. /*:: import type { WhereClause } from './ParseQuery';*/
  15972. /*:: import type { FullOptions } from './RESTController';*/
  15973. /*:: export type PushData = {
  15974. where?: WhereClause | ParseQuery,
  15975. push_time?: Date | string,
  15976. expiration_time?: Date | string,
  15977. expiration_interval?: number,
  15978. };*/
  15979. /**
  15980. * Contains functions to deal with Push in Parse.
  15981. *
  15982. * @class Parse.Push
  15983. * @static
  15984. * @hideconstructor
  15985. */
  15986. /**
  15987. * Sends a push notification.
  15988. * **Available in Cloud Code only.**
  15989. *
  15990. * See {@link https://docs.parseplatform.org/js/guide/#push-notifications Push Notification Guide}
  15991. *
  15992. * @function send
  15993. * @name Parse.Push.send
  15994. * @param {object} data - The data of the push notification. Valid fields
  15995. * are:
  15996. * <ol>
  15997. * <li>channels - An Array of channels to push to.</li>
  15998. * <li>push_time - A Date object for when to send the push.</li>
  15999. * <li>expiration_time - A Date object for when to expire
  16000. * the push.</li>
  16001. * <li>expiration_interval - The seconds from now to expire the push.</li>
  16002. * <li>where - A Parse.Query over Parse.Installation that is used to match
  16003. * a set of installations to push to.</li>
  16004. * <li>data - The data to send as part of the push.</li>
  16005. * <ol>
  16006. * @param {object} options Valid options
  16007. * are:<ul>
  16008. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  16009. * be used for this request.
  16010. * </ul>
  16011. * @returns {Promise} A promise that is fulfilled when the push request
  16012. * completes.
  16013. */
  16014. function send(data /*: PushData*/) /*: Promise*/{
  16015. var options /*:: ?: FullOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  16016. if (data.where && data.where instanceof _ParseQuery.default) {
  16017. data.where = data.where.toJSON().where;
  16018. }
  16019. if (data.push_time && (0, _typeof2.default)(data.push_time) === 'object') {
  16020. data.push_time = data.push_time.toJSON();
  16021. }
  16022. if (data.expiration_time && (0, _typeof2.default)(data.expiration_time) === 'object') {
  16023. data.expiration_time = data.expiration_time.toJSON();
  16024. }
  16025. if (data.expiration_time && data.expiration_interval) {
  16026. throw new Error('expiration_time and expiration_interval cannot both be set.');
  16027. }
  16028. var pushOptions = {
  16029. useMasterKey: true
  16030. };
  16031. if (options.hasOwnProperty('useMasterKey')) {
  16032. pushOptions.useMasterKey = options.useMasterKey;
  16033. }
  16034. return _CoreManager.default.getPushController().send(data, pushOptions);
  16035. }
  16036. /**
  16037. * Gets push status by Id
  16038. *
  16039. * @function getPushStatus
  16040. * @name Parse.Push.getPushStatus
  16041. * @param {string} pushStatusId The Id of Push Status.
  16042. * @param {object} options Valid options
  16043. * are:<ul>
  16044. * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
  16045. * be used for this request.
  16046. * </ul>
  16047. * @returns {Parse.Object} Status of Push.
  16048. */
  16049. function getPushStatus(pushStatusId /*: string*/) /*: Promise<string>*/{
  16050. var options /*:: ?: FullOptions*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  16051. var pushOptions = {
  16052. useMasterKey: true
  16053. };
  16054. if (options.hasOwnProperty('useMasterKey')) {
  16055. pushOptions.useMasterKey = options.useMasterKey;
  16056. }
  16057. var query = new _ParseQuery.default('_PushStatus');
  16058. return query.get(pushStatusId, pushOptions);
  16059. }
  16060. var DefaultController = {
  16061. send: function (data /*: PushData*/, options /*:: ?: FullOptions*/) {
  16062. return _CoreManager.default.getRESTController().request('POST', 'push', data, options);
  16063. }
  16064. };
  16065. _CoreManager.default.setPushController(DefaultController);
  16066. },{"./CoreManager":4,"./ParseQuery":29,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],36:[function(_dereq_,module,exports){
  16067. (function (process){(function (){
  16068. "use strict";
  16069. var _Object$keys = _dereq_("@babel/runtime-corejs3/core-js-stable/object/keys");
  16070. var _Object$getOwnPropertySymbols = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
  16071. var _filterInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/filter");
  16072. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  16073. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each");
  16074. var _Object$getOwnPropertyDescriptors = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
  16075. var _Object$defineProperties = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-properties");
  16076. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  16077. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16078. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  16079. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  16080. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  16081. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  16082. var _includes = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/includes"));
  16083. var _setTimeout2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/set-timeout"));
  16084. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  16085. var _ParseError = _interopRequireDefault(_dereq_("./ParseError"));
  16086. var _promiseUtils = _dereq_("./promiseUtils");
  16087. function ownKeys(object, enumerableOnly) {
  16088. var keys = _Object$keys(object);
  16089. if (_Object$getOwnPropertySymbols) {
  16090. var symbols = _Object$getOwnPropertySymbols(object);
  16091. enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
  16092. return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
  16093. })), keys.push.apply(keys, symbols);
  16094. }
  16095. return keys;
  16096. }
  16097. function _objectSpread(target) {
  16098. for (var i = 1; i < arguments.length; i++) {
  16099. var _context4, _context5;
  16100. var source = null != arguments[i] ? arguments[i] : {};
  16101. i % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(source), !0)).call(_context4, function (key) {
  16102. (0, _defineProperty2.default)(target, key, source[key]);
  16103. }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context5 = ownKeys(Object(source))).call(_context5, function (key) {
  16104. _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
  16105. });
  16106. }
  16107. return target;
  16108. }
  16109. /**
  16110. * @flow
  16111. */
  16112. /* global XMLHttpRequest, XDomainRequest */
  16113. var uuidv4 = _dereq_('./uuid');
  16114. /*:: export type RequestOptions = {
  16115. useMasterKey?: boolean,
  16116. sessionToken?: string,
  16117. installationId?: string,
  16118. returnStatus?: boolean,
  16119. batchSize?: number,
  16120. include?: any,
  16121. progress?: any,
  16122. context?: any,
  16123. usePost?: boolean,
  16124. };*/
  16125. /*:: export type FullOptions = {
  16126. success?: any,
  16127. error?: any,
  16128. useMasterKey?: boolean,
  16129. sessionToken?: string,
  16130. installationId?: string,
  16131. progress?: any,
  16132. usePost?: boolean,
  16133. };*/
  16134. var XHR = null;
  16135. if (typeof XMLHttpRequest !== 'undefined') {
  16136. XHR = XMLHttpRequest;
  16137. }
  16138. XHR = _dereq_('./Xhr.weapp');
  16139. var useXDomainRequest = false;
  16140. if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
  16141. useXDomainRequest = true;
  16142. }
  16143. function ajaxIE9(method /*: string*/, url /*: string*/, data /*: any*/, headers /*:: ?: any*/, options /*:: ?: FullOptions*/) {
  16144. return new _promise.default(function (resolve, reject) {
  16145. var xdr = new XDomainRequest();
  16146. xdr.onload = function () {
  16147. var response;
  16148. try {
  16149. response = JSON.parse(xdr.responseText);
  16150. } catch (e) {
  16151. reject(e);
  16152. }
  16153. if (response) {
  16154. resolve({
  16155. response: response
  16156. });
  16157. }
  16158. };
  16159. xdr.onerror = xdr.ontimeout = function () {
  16160. // Let's fake a real error message.
  16161. var fakeResponse = {
  16162. responseText: (0, _stringify.default)({
  16163. code: _ParseError.default.X_DOMAIN_REQUEST,
  16164. error: "IE's XDomainRequest does not supply error info."
  16165. })
  16166. };
  16167. reject(fakeResponse);
  16168. };
  16169. xdr.onprogress = function () {
  16170. if (options && typeof options.progress === 'function') {
  16171. options.progress(xdr.responseText);
  16172. }
  16173. };
  16174. xdr.open(method, url);
  16175. xdr.send(data);
  16176. if (options && typeof options.requestTask === 'function') {
  16177. options.requestTask(xdr);
  16178. }
  16179. });
  16180. }
  16181. var RESTController = {
  16182. ajax: function (method /*: string*/, url /*: string*/, data /*: any*/, headers /*:: ?: any*/, options /*:: ?: FullOptions*/) {
  16183. var _context;
  16184. if (useXDomainRequest) {
  16185. return ajaxIE9(method, url, data, headers, options);
  16186. }
  16187. var promise = (0, _promiseUtils.resolvingPromise)();
  16188. var isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && (0, _includes.default)(_context = ['POST', 'PUT']).call(_context, method);
  16189. var requestId = isIdempotent ? uuidv4() : '';
  16190. var attempts = 0;
  16191. (function dispatch() {
  16192. if (XHR == null) {
  16193. throw new Error('Cannot make a request: No definition of XMLHttpRequest was found.');
  16194. }
  16195. var handled = false;
  16196. var xhr = new XHR();
  16197. xhr.onreadystatechange = function () {
  16198. if (xhr.readyState !== 4 || handled || xhr._aborted) {
  16199. return;
  16200. }
  16201. handled = true;
  16202. if (xhr.status >= 200 && xhr.status < 300) {
  16203. var response;
  16204. try {
  16205. response = JSON.parse(xhr.responseText);
  16206. if (typeof xhr.getResponseHeader === 'function') {
  16207. var _context2, _context3;
  16208. if ((0, _includes.default)(_context2 = xhr.getAllResponseHeaders() || '').call(_context2, 'x-parse-job-status-id: ')) {
  16209. response = xhr.getResponseHeader('x-parse-job-status-id');
  16210. }
  16211. if ((0, _includes.default)(_context3 = xhr.getAllResponseHeaders() || '').call(_context3, 'x-parse-push-status-id: ')) {
  16212. response = xhr.getResponseHeader('x-parse-push-status-id');
  16213. }
  16214. }
  16215. } catch (e) {
  16216. promise.reject(e.toString());
  16217. }
  16218. if (response) {
  16219. promise.resolve({
  16220. response: response,
  16221. status: xhr.status,
  16222. xhr: xhr
  16223. });
  16224. }
  16225. } else if (xhr.status >= 500 || xhr.status === 0) {
  16226. // retry on 5XX or node-xmlhttprequest error
  16227. if (++attempts < _CoreManager.default.get('REQUEST_ATTEMPT_LIMIT')) {
  16228. // Exponentially-growing random delay
  16229. var delay = Math.round(Math.random() * 125 * Math.pow(2, attempts));
  16230. (0, _setTimeout2.default)(dispatch, delay);
  16231. } else if (xhr.status === 0) {
  16232. promise.reject('Unable to connect to the Parse API');
  16233. } else {
  16234. // After the retry limit is reached, fail
  16235. promise.reject(xhr);
  16236. }
  16237. } else {
  16238. promise.reject(xhr);
  16239. }
  16240. };
  16241. headers = headers || {};
  16242. if (typeof headers['Content-Type'] !== 'string') {
  16243. headers['Content-Type'] = 'text/plain'; // Avoid pre-flight
  16244. }
  16245. if (_CoreManager.default.get('IS_NODE')) {
  16246. headers['User-Agent'] = 'Parse/' + _CoreManager.default.get('VERSION') + ' (NodeJS ' + process.versions.node + ')';
  16247. }
  16248. if (isIdempotent) {
  16249. headers['X-Parse-Request-Id'] = requestId;
  16250. }
  16251. if (_CoreManager.default.get('SERVER_AUTH_TYPE') && _CoreManager.default.get('SERVER_AUTH_TOKEN')) {
  16252. headers['Authorization'] = _CoreManager.default.get('SERVER_AUTH_TYPE') + ' ' + _CoreManager.default.get('SERVER_AUTH_TOKEN');
  16253. }
  16254. var customHeaders = _CoreManager.default.get('REQUEST_HEADERS');
  16255. for (var key in customHeaders) {
  16256. headers[key] = customHeaders[key];
  16257. }
  16258. if (options && typeof options.progress === 'function') {
  16259. var handleProgress = function handleProgress(type, event) {
  16260. if (event.lengthComputable) {
  16261. options.progress(event.loaded / event.total, event.loaded, event.total, {
  16262. type: type
  16263. });
  16264. } else {
  16265. options.progress(null, null, null, {
  16266. type: type
  16267. });
  16268. }
  16269. };
  16270. xhr.onprogress = function (event) {
  16271. handleProgress('download', event);
  16272. };
  16273. if (xhr.upload) {
  16274. xhr.upload.onprogress = function (event) {
  16275. handleProgress('upload', event);
  16276. };
  16277. }
  16278. }
  16279. xhr.open(method, url, true);
  16280. for (var h in headers) {
  16281. xhr.setRequestHeader(h, headers[h]);
  16282. }
  16283. xhr.onabort = function () {
  16284. promise.resolve({
  16285. response: {
  16286. results: []
  16287. },
  16288. status: 0,
  16289. xhr: xhr
  16290. });
  16291. };
  16292. xhr.send(data);
  16293. if (options && typeof options.requestTask === 'function') {
  16294. options.requestTask(xhr);
  16295. }
  16296. })();
  16297. return promise;
  16298. },
  16299. request: function request(method /*: string*/, path /*: string*/, data /*: mixed*/, options /*:: ?: RequestOptions*/) {
  16300. options = options || {};
  16301. var url = _CoreManager.default.get('SERVER_URL');
  16302. if (url[url.length - 1] !== '/') {
  16303. url += '/';
  16304. }
  16305. url += path;
  16306. var payload = {};
  16307. if (data && (0, _typeof2.default)(data) === 'object') {
  16308. for (var k in data) {
  16309. payload[k] = data[k];
  16310. }
  16311. }
  16312. // Add context
  16313. var context = options.context;
  16314. if (context !== undefined) {
  16315. payload._context = context;
  16316. }
  16317. if (method !== 'POST') {
  16318. payload._method = method;
  16319. method = 'POST';
  16320. }
  16321. payload._ApplicationId = _CoreManager.default.get('APPLICATION_ID');
  16322. var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
  16323. if (jsKey) {
  16324. payload._JavaScriptKey = jsKey;
  16325. }
  16326. payload._ClientVersion = _CoreManager.default.get('VERSION');
  16327. var useMasterKey = options.useMasterKey;
  16328. if (typeof useMasterKey === 'undefined') {
  16329. useMasterKey = _CoreManager.default.get('USE_MASTER_KEY');
  16330. }
  16331. if (useMasterKey) {
  16332. if (_CoreManager.default.get('MASTER_KEY')) {
  16333. delete payload._JavaScriptKey;
  16334. payload._MasterKey = _CoreManager.default.get('MASTER_KEY');
  16335. } else {
  16336. throw new Error('Cannot use the Master Key, it has not been provided.');
  16337. }
  16338. }
  16339. if (_CoreManager.default.get('FORCE_REVOCABLE_SESSION')) {
  16340. payload._RevocableSession = '1';
  16341. }
  16342. var installationId = options.installationId;
  16343. var installationIdPromise;
  16344. if (installationId && typeof installationId === 'string') {
  16345. installationIdPromise = _promise.default.resolve(installationId);
  16346. } else {
  16347. var installationController = _CoreManager.default.getInstallationController();
  16348. installationIdPromise = installationController.currentInstallationId();
  16349. }
  16350. return installationIdPromise.then(function (iid) {
  16351. payload._InstallationId = iid;
  16352. var userController = _CoreManager.default.getUserController();
  16353. if (options && typeof options.sessionToken === 'string') {
  16354. return _promise.default.resolve(options.sessionToken);
  16355. } else if (userController) {
  16356. return userController.currentUserAsync().then(function (user) {
  16357. if (user) {
  16358. return _promise.default.resolve(user.getSessionToken());
  16359. }
  16360. return _promise.default.resolve(null);
  16361. });
  16362. }
  16363. return _promise.default.resolve(null);
  16364. }).then(function (token) {
  16365. if (token) {
  16366. payload._SessionToken = token;
  16367. }
  16368. var payloadString = (0, _stringify.default)(payload);
  16369. return RESTController.ajax(method, url, payloadString, {}, options).then(function (_ref) {
  16370. var response = _ref.response,
  16371. status = _ref.status;
  16372. if (options.returnStatus) {
  16373. return _objectSpread(_objectSpread({}, response), {}, {
  16374. _status: status
  16375. });
  16376. } else {
  16377. return response;
  16378. }
  16379. });
  16380. }).catch(RESTController.handleError);
  16381. },
  16382. handleError: function handleError(response) {
  16383. // Transform the error into an instance of ParseError by trying to parse
  16384. // the error string as JSON
  16385. var error;
  16386. if (response && response.responseText) {
  16387. try {
  16388. var errorJSON = JSON.parse(response.responseText);
  16389. error = new _ParseError.default(errorJSON.code, errorJSON.error);
  16390. } catch (e) {
  16391. // If we fail to parse the error text, that's okay.
  16392. error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Received an error with invalid JSON from Parse: ' + response.responseText);
  16393. }
  16394. } else {
  16395. var message = response.message ? response.message : response;
  16396. error = new _ParseError.default(_ParseError.default.CONNECTION_FAILED, 'XMLHttpRequest failed: ' + (0, _stringify.default)(message));
  16397. }
  16398. return _promise.default.reject(error);
  16399. },
  16400. _setXHR: function _setXHR(xhr /*: any*/) {
  16401. XHR = xhr;
  16402. },
  16403. _getXHR: function _getXHR() {
  16404. return XHR;
  16405. }
  16406. };
  16407. module.exports = RESTController;
  16408. }).call(this)}).call(this,_dereq_('_process'))
  16409. },{"./CoreManager":4,"./ParseError":21,"./Xhr.weapp":43,"./promiseUtils":52,"./uuid":55,"@babel/runtime-corejs3/core-js-stable/instance/filter":62,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/instance/includes":66,"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/core-js-stable/object/define-properties":81,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors":86,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols":87,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/core-js-stable/set-timeout":94,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145,"_process":149}],37:[function(_dereq_,module,exports){
  16410. "use strict";
  16411. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  16412. var _WeakMap = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  16413. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  16414. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  16415. _Object$defineProperty(exports, "__esModule", {
  16416. value: true
  16417. });
  16418. exports.clearAllState = clearAllState;
  16419. exports.commitServerChanges = commitServerChanges;
  16420. exports.duplicateState = duplicateState;
  16421. exports.enqueueTask = enqueueTask;
  16422. exports.estimateAttribute = estimateAttribute;
  16423. exports.estimateAttributes = estimateAttributes;
  16424. exports.getObjectCache = getObjectCache;
  16425. exports.getPendingOps = getPendingOps;
  16426. exports.getServerData = getServerData;
  16427. exports.getState = getState;
  16428. exports.initializeState = initializeState;
  16429. exports.mergeFirstPendingState = mergeFirstPendingState;
  16430. exports.popPendingState = popPendingState;
  16431. exports.pushPendingState = pushPendingState;
  16432. exports.removeState = removeState;
  16433. exports.setPendingOp = setPendingOp;
  16434. exports.setServerData = setServerData;
  16435. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  16436. function _getRequireWildcardCache(nodeInterop) {
  16437. if (typeof _WeakMap !== "function") return null;
  16438. var cacheBabelInterop = new _WeakMap();
  16439. var cacheNodeInterop = new _WeakMap();
  16440. return (_getRequireWildcardCache = function (nodeInterop) {
  16441. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  16442. })(nodeInterop);
  16443. }
  16444. function _interopRequireWildcard(obj, nodeInterop) {
  16445. if (!nodeInterop && obj && obj.__esModule) {
  16446. return obj;
  16447. }
  16448. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  16449. return {
  16450. default: obj
  16451. };
  16452. }
  16453. var cache = _getRequireWildcardCache(nodeInterop);
  16454. if (cache && cache.has(obj)) {
  16455. return cache.get(obj);
  16456. }
  16457. var newObj = {};
  16458. for (var key in obj) {
  16459. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  16460. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  16461. if (desc && (desc.get || desc.set)) {
  16462. _Object$defineProperty(newObj, key, desc);
  16463. } else {
  16464. newObj[key] = obj[key];
  16465. }
  16466. }
  16467. }
  16468. newObj.default = obj;
  16469. if (cache) {
  16470. cache.set(obj, newObj);
  16471. }
  16472. return newObj;
  16473. }
  16474. /**
  16475. * @flow
  16476. */
  16477. /*:: import type { Op } from './ParseOp';*/
  16478. /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
  16479. /*:: type ObjectIdentifier = {
  16480. className: string,
  16481. id: string,
  16482. };*/
  16483. var objectState
  16484. /*: {
  16485. [className: string]: {
  16486. [id: string]: State,
  16487. },
  16488. }*/ = {};
  16489. function getState(obj /*: ObjectIdentifier*/) /*: ?State*/{
  16490. var classData = objectState[obj.className];
  16491. if (classData) {
  16492. return classData[obj.id] || null;
  16493. }
  16494. return null;
  16495. }
  16496. function initializeState(obj /*: ObjectIdentifier*/, initial /*:: ?: State*/) /*: State*/{
  16497. var state = getState(obj);
  16498. if (state) {
  16499. return state;
  16500. }
  16501. if (!objectState[obj.className]) {
  16502. objectState[obj.className] = {};
  16503. }
  16504. if (!initial) {
  16505. initial = ObjectStateMutations.defaultState();
  16506. }
  16507. state = objectState[obj.className][obj.id] = initial;
  16508. return state;
  16509. }
  16510. function removeState(obj /*: ObjectIdentifier*/) /*: ?State*/{
  16511. var state = getState(obj);
  16512. if (state === null) {
  16513. return null;
  16514. }
  16515. delete objectState[obj.className][obj.id];
  16516. return state;
  16517. }
  16518. function getServerData(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
  16519. var state = getState(obj);
  16520. if (state) {
  16521. return state.serverData;
  16522. }
  16523. return {};
  16524. }
  16525. function setServerData(obj /*: ObjectIdentifier*/, attributes /*: AttributeMap*/) {
  16526. var serverData = initializeState(obj).serverData;
  16527. ObjectStateMutations.setServerData(serverData, attributes);
  16528. }
  16529. function getPendingOps(obj /*: ObjectIdentifier*/) /*: Array<OpsMap>*/{
  16530. var state = getState(obj);
  16531. if (state) {
  16532. return state.pendingOps;
  16533. }
  16534. return [{}];
  16535. }
  16536. function setPendingOp(obj /*: ObjectIdentifier*/, attr /*: string*/, op /*: ?Op*/) {
  16537. var pendingOps = initializeState(obj).pendingOps;
  16538. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  16539. }
  16540. function pushPendingState(obj /*: ObjectIdentifier*/) {
  16541. var pendingOps = initializeState(obj).pendingOps;
  16542. ObjectStateMutations.pushPendingState(pendingOps);
  16543. }
  16544. function popPendingState(obj /*: ObjectIdentifier*/) /*: OpsMap*/{
  16545. var pendingOps = initializeState(obj).pendingOps;
  16546. return ObjectStateMutations.popPendingState(pendingOps);
  16547. }
  16548. function mergeFirstPendingState(obj /*: ObjectIdentifier*/) {
  16549. var pendingOps = getPendingOps(obj);
  16550. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  16551. }
  16552. function getObjectCache(obj /*: ObjectIdentifier*/) /*: ObjectCache*/{
  16553. var state = getState(obj);
  16554. if (state) {
  16555. return state.objectCache;
  16556. }
  16557. return {};
  16558. }
  16559. function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*: mixed*/{
  16560. var serverData = getServerData(obj);
  16561. var pendingOps = getPendingOps(obj);
  16562. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
  16563. }
  16564. function estimateAttributes(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
  16565. var serverData = getServerData(obj);
  16566. var pendingOps = getPendingOps(obj);
  16567. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
  16568. }
  16569. function commitServerChanges(obj /*: ObjectIdentifier*/, changes /*: AttributeMap*/) {
  16570. var state = initializeState(obj);
  16571. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  16572. }
  16573. function enqueueTask(obj /*: ObjectIdentifier*/, task /*: () => Promise*/) /*: Promise*/{
  16574. var state = initializeState(obj);
  16575. return state.tasks.enqueue(task);
  16576. }
  16577. function clearAllState() {
  16578. objectState = {};
  16579. }
  16580. function duplicateState(source /*: { id: string }*/, dest /*: { id: string }*/) {
  16581. dest.id = source.id;
  16582. }
  16583. },{"./ObjectStateMutations":15,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/weak-map":97,"@babel/runtime-corejs3/helpers/typeof":145}],38:[function(_dereq_,module,exports){
  16584. "use strict";
  16585. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16586. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  16587. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  16588. module.exports = /*#__PURE__*/function () {
  16589. function SocketWeapp(serverURL) {
  16590. var _this = this;
  16591. (0, _classCallCheck2.default)(this, SocketWeapp);
  16592. this.onopen = function () {};
  16593. this.onmessage = function () {};
  16594. this.onclose = function () {};
  16595. this.onerror = function () {};
  16596. wx.onSocketOpen(function () {
  16597. _this.onopen();
  16598. });
  16599. wx.onSocketMessage(function (msg) {
  16600. _this.onmessage(msg);
  16601. });
  16602. wx.onSocketClose(function (event) {
  16603. _this.onclose(event);
  16604. });
  16605. wx.onSocketError(function (error) {
  16606. _this.onerror(error);
  16607. });
  16608. wx.connectSocket({
  16609. url: serverURL
  16610. });
  16611. }
  16612. (0, _createClass2.default)(SocketWeapp, [{
  16613. key: "send",
  16614. value: function (data) {
  16615. wx.sendSocketMessage({
  16616. data: data
  16617. });
  16618. }
  16619. }, {
  16620. key: "close",
  16621. value: function () {
  16622. wx.closeSocket();
  16623. }
  16624. }]);
  16625. return SocketWeapp;
  16626. }();
  16627. },{"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],39:[function(_dereq_,module,exports){
  16628. "use strict";
  16629. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16630. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  16631. var _CoreManager = _interopRequireDefault(_dereq_("./CoreManager"));
  16632. /**
  16633. * @flow
  16634. */
  16635. var Storage = {
  16636. async: function () /*: boolean*/{
  16637. var controller = _CoreManager.default.getStorageController();
  16638. return !!controller.async;
  16639. },
  16640. getItem: function (path /*: string*/) /*: ?string*/{
  16641. var controller = _CoreManager.default.getStorageController();
  16642. if (controller.async === 1) {
  16643. throw new Error('Synchronous storage is not supported by the current storage controller');
  16644. }
  16645. return controller.getItem(path);
  16646. },
  16647. getItemAsync: function (path /*: string*/) /*: Promise<string>*/{
  16648. var controller = _CoreManager.default.getStorageController();
  16649. if (controller.async === 1) {
  16650. return controller.getItemAsync(path);
  16651. }
  16652. return _promise.default.resolve(controller.getItem(path));
  16653. },
  16654. setItem: function (path /*: string*/, value /*: string*/) /*: void*/{
  16655. var controller = _CoreManager.default.getStorageController();
  16656. if (controller.async === 1) {
  16657. throw new Error('Synchronous storage is not supported by the current storage controller');
  16658. }
  16659. return controller.setItem(path, value);
  16660. },
  16661. setItemAsync: function (path /*: string*/, value /*: string*/) /*: Promise<void>*/{
  16662. var controller = _CoreManager.default.getStorageController();
  16663. if (controller.async === 1) {
  16664. return controller.setItemAsync(path, value);
  16665. }
  16666. return _promise.default.resolve(controller.setItem(path, value));
  16667. },
  16668. removeItem: function (path /*: string*/) /*: void*/{
  16669. var controller = _CoreManager.default.getStorageController();
  16670. if (controller.async === 1) {
  16671. throw new Error('Synchronous storage is not supported by the current storage controller');
  16672. }
  16673. return controller.removeItem(path);
  16674. },
  16675. removeItemAsync: function (path /*: string*/) /*: Promise<void>*/{
  16676. var controller = _CoreManager.default.getStorageController();
  16677. if (controller.async === 1) {
  16678. return controller.removeItemAsync(path);
  16679. }
  16680. return _promise.default.resolve(controller.removeItem(path));
  16681. },
  16682. getAllKeys: function () /*: Array<string>*/{
  16683. var controller = _CoreManager.default.getStorageController();
  16684. if (controller.async === 1) {
  16685. throw new Error('Synchronous storage is not supported by the current storage controller');
  16686. }
  16687. return controller.getAllKeys();
  16688. },
  16689. getAllKeysAsync: function () /*: Promise<Array<string>>*/{
  16690. var controller = _CoreManager.default.getStorageController();
  16691. if (controller.async === 1) {
  16692. return controller.getAllKeysAsync();
  16693. }
  16694. return _promise.default.resolve(controller.getAllKeys());
  16695. },
  16696. generatePath: function (path /*: string*/) /*: string*/{
  16697. if (!_CoreManager.default.get('APPLICATION_ID')) {
  16698. throw new Error('You need to call Parse.initialize before using Parse.');
  16699. }
  16700. if (typeof path !== 'string') {
  16701. throw new Error('Tried to get a Storage path that was not a String.');
  16702. }
  16703. if (path[0] === '/') {
  16704. path = path.substr(1);
  16705. }
  16706. return 'Parse/' + _CoreManager.default.get('APPLICATION_ID') + '/' + path;
  16707. },
  16708. _clear: function () {
  16709. var controller = _CoreManager.default.getStorageController();
  16710. if (controller.hasOwnProperty('clear')) {
  16711. controller.clear();
  16712. }
  16713. }
  16714. };
  16715. module.exports = Storage;
  16716. _CoreManager.default.setStorageController(_dereq_('./StorageController.weapp'));
  16717. },{"./CoreManager":4,"./StorageController.weapp":40,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],40:[function(_dereq_,module,exports){
  16718. "use strict";
  16719. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16720. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  16721. /**
  16722. * @flow
  16723. * @private
  16724. */
  16725. var StorageController = {
  16726. async: 0,
  16727. getItem: function (path /*: string*/) /*: ?string*/{
  16728. return wx.getStorageSync(path);
  16729. },
  16730. setItem: function (path /*: string*/, value /*: string*/) {
  16731. try {
  16732. wx.setStorageSync(path, value);
  16733. } catch (e) {
  16734. // Quota exceeded
  16735. }
  16736. },
  16737. removeItem: function (path /*: string*/) {
  16738. wx.removeStorageSync(path);
  16739. },
  16740. getAllKeys: function () {
  16741. var res = wx.getStorageInfoSync();
  16742. return (0, _keys.default)(res);
  16743. },
  16744. clear: function () {
  16745. wx.clearStorageSync();
  16746. }
  16747. };
  16748. module.exports = StorageController;
  16749. },{"@babel/runtime-corejs3/core-js-stable/instance/keys":68,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],41:[function(_dereq_,module,exports){
  16750. "use strict";
  16751. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16752. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  16753. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  16754. var _defineProperty2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/defineProperty"));
  16755. var _promiseUtils = _dereq_("./promiseUtils");
  16756. /**
  16757. * @flow
  16758. */
  16759. /*:: type Task = {
  16760. task: () => Promise,
  16761. _completion: Promise,
  16762. };*/
  16763. var TaskQueue = /*#__PURE__*/function () {
  16764. function TaskQueue() {
  16765. (0, _classCallCheck2.default)(this, TaskQueue);
  16766. (0, _defineProperty2.default)(this, "queue", void 0);
  16767. this.queue = [];
  16768. }
  16769. (0, _createClass2.default)(TaskQueue, [{
  16770. key: "enqueue",
  16771. value: function (task /*: () => Promise*/) /*: Promise*/{
  16772. var _this = this;
  16773. var taskComplete = new _promiseUtils.resolvingPromise();
  16774. this.queue.push({
  16775. task: task,
  16776. _completion: taskComplete
  16777. });
  16778. if (this.queue.length === 1) {
  16779. task().then(function () {
  16780. _this._dequeue();
  16781. taskComplete.resolve();
  16782. }, function (error) {
  16783. _this._dequeue();
  16784. taskComplete.reject(error);
  16785. });
  16786. }
  16787. return taskComplete;
  16788. }
  16789. }, {
  16790. key: "_dequeue",
  16791. value: function () {
  16792. var _this2 = this;
  16793. this.queue.shift();
  16794. if (this.queue.length) {
  16795. var next = this.queue[0];
  16796. next.task().then(function () {
  16797. _this2._dequeue();
  16798. next._completion.resolve();
  16799. }, function (error) {
  16800. _this2._dequeue();
  16801. next._completion.reject(error);
  16802. });
  16803. }
  16804. }
  16805. }]);
  16806. return TaskQueue;
  16807. }();
  16808. module.exports = TaskQueue;
  16809. },{"./promiseUtils":52,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/defineProperty":126,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],42:[function(_dereq_,module,exports){
  16810. "use strict";
  16811. var _typeof = _dereq_("@babel/runtime-corejs3/helpers/typeof");
  16812. var _WeakMap2 = _dereq_("@babel/runtime-corejs3/core-js-stable/weak-map");
  16813. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  16814. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
  16815. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16816. _Object$defineProperty(exports, "__esModule", {
  16817. value: true
  16818. });
  16819. exports.clearAllState = clearAllState;
  16820. exports.commitServerChanges = commitServerChanges;
  16821. exports.duplicateState = duplicateState;
  16822. exports.enqueueTask = enqueueTask;
  16823. exports.estimateAttribute = estimateAttribute;
  16824. exports.estimateAttributes = estimateAttributes;
  16825. exports.getObjectCache = getObjectCache;
  16826. exports.getPendingOps = getPendingOps;
  16827. exports.getServerData = getServerData;
  16828. exports.getState = getState;
  16829. exports.initializeState = initializeState;
  16830. exports.mergeFirstPendingState = mergeFirstPendingState;
  16831. exports.popPendingState = popPendingState;
  16832. exports.pushPendingState = pushPendingState;
  16833. exports.removeState = removeState;
  16834. exports.setPendingOp = setPendingOp;
  16835. exports.setServerData = setServerData;
  16836. var _weakMap = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/weak-map"));
  16837. var ObjectStateMutations = _interopRequireWildcard(_dereq_("./ObjectStateMutations"));
  16838. var _TaskQueue = _interopRequireDefault(_dereq_("./TaskQueue"));
  16839. function _getRequireWildcardCache(nodeInterop) {
  16840. if (typeof _WeakMap2 !== "function") return null;
  16841. var cacheBabelInterop = new _WeakMap2();
  16842. var cacheNodeInterop = new _WeakMap2();
  16843. return (_getRequireWildcardCache = function (nodeInterop) {
  16844. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  16845. })(nodeInterop);
  16846. }
  16847. function _interopRequireWildcard(obj, nodeInterop) {
  16848. if (!nodeInterop && obj && obj.__esModule) {
  16849. return obj;
  16850. }
  16851. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  16852. return {
  16853. default: obj
  16854. };
  16855. }
  16856. var cache = _getRequireWildcardCache(nodeInterop);
  16857. if (cache && cache.has(obj)) {
  16858. return cache.get(obj);
  16859. }
  16860. var newObj = {};
  16861. for (var key in obj) {
  16862. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  16863. var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
  16864. if (desc && (desc.get || desc.set)) {
  16865. _Object$defineProperty(newObj, key, desc);
  16866. } else {
  16867. newObj[key] = obj[key];
  16868. }
  16869. }
  16870. }
  16871. newObj.default = obj;
  16872. if (cache) {
  16873. cache.set(obj, newObj);
  16874. }
  16875. return newObj;
  16876. }
  16877. /**
  16878. * @flow
  16879. */
  16880. /*:: import type { Op } from './ParseOp';*/
  16881. /*:: import type ParseObject from './ParseObject';*/
  16882. /*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
  16883. var objectState = new _weakMap.default();
  16884. function getState(obj /*: ParseObject*/) /*: ?State*/{
  16885. var classData = objectState.get(obj);
  16886. return classData || null;
  16887. }
  16888. function initializeState(obj /*: ParseObject*/, initial /*:: ?: State*/) /*: State*/{
  16889. var state = getState(obj);
  16890. if (state) {
  16891. return state;
  16892. }
  16893. if (!initial) {
  16894. initial = {
  16895. serverData: {},
  16896. pendingOps: [{}],
  16897. objectCache: {},
  16898. tasks: new _TaskQueue.default(),
  16899. existed: false
  16900. };
  16901. }
  16902. state = initial;
  16903. objectState.set(obj, state);
  16904. return state;
  16905. }
  16906. function removeState(obj /*: ParseObject*/) /*: ?State*/{
  16907. var state = getState(obj);
  16908. if (state === null) {
  16909. return null;
  16910. }
  16911. objectState.delete(obj);
  16912. return state;
  16913. }
  16914. function getServerData(obj /*: ParseObject*/) /*: AttributeMap*/{
  16915. var state = getState(obj);
  16916. if (state) {
  16917. return state.serverData;
  16918. }
  16919. return {};
  16920. }
  16921. function setServerData(obj /*: ParseObject*/, attributes /*: AttributeMap*/) {
  16922. var serverData = initializeState(obj).serverData;
  16923. ObjectStateMutations.setServerData(serverData, attributes);
  16924. }
  16925. function getPendingOps(obj /*: ParseObject*/) /*: Array<OpsMap>*/{
  16926. var state = getState(obj);
  16927. if (state) {
  16928. return state.pendingOps;
  16929. }
  16930. return [{}];
  16931. }
  16932. function setPendingOp(obj /*: ParseObject*/, attr /*: string*/, op /*: ?Op*/) {
  16933. var pendingOps = initializeState(obj).pendingOps;
  16934. ObjectStateMutations.setPendingOp(pendingOps, attr, op);
  16935. }
  16936. function pushPendingState(obj /*: ParseObject*/) {
  16937. var pendingOps = initializeState(obj).pendingOps;
  16938. ObjectStateMutations.pushPendingState(pendingOps);
  16939. }
  16940. function popPendingState(obj /*: ParseObject*/) /*: OpsMap*/{
  16941. var pendingOps = initializeState(obj).pendingOps;
  16942. return ObjectStateMutations.popPendingState(pendingOps);
  16943. }
  16944. function mergeFirstPendingState(obj /*: ParseObject*/) {
  16945. var pendingOps = getPendingOps(obj);
  16946. ObjectStateMutations.mergeFirstPendingState(pendingOps);
  16947. }
  16948. function getObjectCache(obj /*: ParseObject*/) /*: ObjectCache*/{
  16949. var state = getState(obj);
  16950. if (state) {
  16951. return state.objectCache;
  16952. }
  16953. return {};
  16954. }
  16955. function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
  16956. var serverData = getServerData(obj);
  16957. var pendingOps = getPendingOps(obj);
  16958. return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
  16959. }
  16960. function estimateAttributes(obj /*: ParseObject*/) /*: AttributeMap*/{
  16961. var serverData = getServerData(obj);
  16962. var pendingOps = getPendingOps(obj);
  16963. return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
  16964. }
  16965. function commitServerChanges(obj /*: ParseObject*/, changes /*: AttributeMap*/) {
  16966. var state = initializeState(obj);
  16967. ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
  16968. }
  16969. function enqueueTask(obj /*: ParseObject*/, task /*: () => Promise*/) /*: Promise*/{
  16970. var state = initializeState(obj);
  16971. return state.tasks.enqueue(task);
  16972. }
  16973. function duplicateState(source /*: ParseObject*/, dest /*: ParseObject*/) /*: void*/{
  16974. var oldState = initializeState(source);
  16975. var newState = initializeState(dest);
  16976. for (var key in oldState.serverData) {
  16977. newState.serverData[key] = oldState.serverData[key];
  16978. }
  16979. for (var index = 0; index < oldState.pendingOps.length; index++) {
  16980. for (var _key in oldState.pendingOps[index]) {
  16981. newState.pendingOps[index][_key] = oldState.pendingOps[index][_key];
  16982. }
  16983. }
  16984. for (var _key2 in oldState.objectCache) {
  16985. newState.objectCache[_key2] = oldState.objectCache[_key2];
  16986. }
  16987. newState.existed = oldState.existed;
  16988. }
  16989. function clearAllState() {
  16990. objectState = new _weakMap.default();
  16991. }
  16992. },{"./ObjectStateMutations":15,"./TaskQueue":41,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor":85,"@babel/runtime-corejs3/core-js-stable/weak-map":97,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],43:[function(_dereq_,module,exports){
  16993. "use strict";
  16994. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  16995. var _stringify = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  16996. var _classCallCheck2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/classCallCheck"));
  16997. var _createClass2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/createClass"));
  16998. module.exports = /*#__PURE__*/function () {
  16999. function XhrWeapp() {
  17000. (0, _classCallCheck2.default)(this, XhrWeapp);
  17001. this.UNSENT = 0;
  17002. this.OPENED = 1;
  17003. this.HEADERS_RECEIVED = 2;
  17004. this.LOADING = 3;
  17005. this.DONE = 4;
  17006. this.header = {};
  17007. this.readyState = this.DONE;
  17008. this.status = 0;
  17009. this.response = '';
  17010. this.responseType = '';
  17011. this.responseText = '';
  17012. this.responseHeader = {};
  17013. this.method = '';
  17014. this.url = '';
  17015. this.onabort = function () {};
  17016. this.onprogress = function () {};
  17017. this.onerror = function () {};
  17018. this.onreadystatechange = function () {};
  17019. this.requestTask = null;
  17020. }
  17021. (0, _createClass2.default)(XhrWeapp, [{
  17022. key: "getAllResponseHeaders",
  17023. value: function () {
  17024. var header = '';
  17025. for (var key in this.responseHeader) {
  17026. header += key + ':' + this.getResponseHeader(key) + '\r\n';
  17027. }
  17028. return header;
  17029. }
  17030. }, {
  17031. key: "getResponseHeader",
  17032. value: function (key) {
  17033. return this.responseHeader[key];
  17034. }
  17035. }, {
  17036. key: "setRequestHeader",
  17037. value: function (key, value) {
  17038. this.header[key] = value;
  17039. }
  17040. }, {
  17041. key: "open",
  17042. value: function (method, url) {
  17043. this.method = method;
  17044. this.url = url;
  17045. }
  17046. }, {
  17047. key: "abort",
  17048. value: function () {
  17049. if (!this.requestTask) {
  17050. return;
  17051. }
  17052. this.requestTask.abort();
  17053. this.status = 0;
  17054. this.response = undefined;
  17055. this.onabort();
  17056. this.onreadystatechange();
  17057. }
  17058. }, {
  17059. key: "send",
  17060. value: function (data) {
  17061. var _this = this;
  17062. this.requestTask = wx.request({
  17063. url: this.url,
  17064. method: this.method,
  17065. data: data,
  17066. header: this.header,
  17067. responseType: this.responseType,
  17068. success: function (res) {
  17069. _this.status = res.statusCode;
  17070. _this.response = res.data;
  17071. _this.responseHeader = res.header;
  17072. _this.responseText = (0, _stringify.default)(res.data);
  17073. _this.requestTask = null;
  17074. _this.onreadystatechange();
  17075. },
  17076. fail: function (err) {
  17077. _this.requestTask = null;
  17078. _this.onerror(err);
  17079. }
  17080. });
  17081. this.requestTask.onProgressUpdate(function (res) {
  17082. var event = {
  17083. lengthComputable: res.totalBytesExpectedToWrite !== 0,
  17084. loaded: res.totalBytesWritten,
  17085. total: res.totalBytesExpectedToWrite
  17086. };
  17087. _this.onprogress(event);
  17088. });
  17089. }
  17090. }]);
  17091. return XhrWeapp;
  17092. }();
  17093. },{"@babel/runtime-corejs3/core-js-stable/json/stringify":76,"@babel/runtime-corejs3/helpers/classCallCheck":123,"@babel/runtime-corejs3/helpers/createClass":125,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],44:[function(_dereq_,module,exports){
  17094. "use strict";
  17095. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17096. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17097. _Object$defineProperty(exports, "__esModule", {
  17098. value: true
  17099. });
  17100. exports.default = arrayContainsObject;
  17101. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  17102. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17103. /**
  17104. * @flow
  17105. */
  17106. function arrayContainsObject(array /*: Array<any>*/, object /*: ParseObject*/) /*: boolean*/{
  17107. if ((0, _indexOf.default)(array).call(array, object) > -1) {
  17108. return true;
  17109. }
  17110. for (var i = 0; i < array.length; i++) {
  17111. if (array[i] instanceof _ParseObject.default && array[i].className === object.className && array[i]._getId() === object._getId()) {
  17112. return true;
  17113. }
  17114. }
  17115. return false;
  17116. }
  17117. },{"./ParseObject":26,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],45:[function(_dereq_,module,exports){
  17118. "use strict";
  17119. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17120. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17121. _Object$defineProperty(exports, "__esModule", {
  17122. value: true
  17123. });
  17124. exports.default = canBeSerialized;
  17125. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17126. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  17127. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  17128. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17129. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  17130. /**
  17131. * @flow
  17132. */
  17133. function canBeSerialized(obj /*: ParseObject*/) /*: boolean*/{
  17134. if (!(obj instanceof _ParseObject.default)) {
  17135. return true;
  17136. }
  17137. var attributes = obj.attributes;
  17138. for (var attr in attributes) {
  17139. var val = attributes[attr];
  17140. if (!canBeSerializedHelper(val)) {
  17141. return false;
  17142. }
  17143. }
  17144. return true;
  17145. }
  17146. function canBeSerializedHelper(value /*: any*/) /*: boolean*/{
  17147. if ((0, _typeof2.default)(value) !== 'object') {
  17148. return true;
  17149. }
  17150. if (value instanceof _ParseRelation.default) {
  17151. return true;
  17152. }
  17153. if (value instanceof _ParseObject.default) {
  17154. return !!value.id;
  17155. }
  17156. if (value instanceof _ParseFile.default) {
  17157. if (value.url()) {
  17158. return true;
  17159. }
  17160. return false;
  17161. }
  17162. if ((0, _isArray.default)(value)) {
  17163. for (var i = 0; i < value.length; i++) {
  17164. if (!canBeSerializedHelper(value[i])) {
  17165. return false;
  17166. }
  17167. }
  17168. return true;
  17169. }
  17170. for (var k in value) {
  17171. if (!canBeSerializedHelper(value[k])) {
  17172. return false;
  17173. }
  17174. }
  17175. return true;
  17176. }
  17177. },{"./ParseFile":22,"./ParseObject":26,"./ParseRelation":30,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],46:[function(_dereq_,module,exports){
  17178. "use strict";
  17179. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17180. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17181. _Object$defineProperty(exports, "__esModule", {
  17182. value: true
  17183. });
  17184. exports.default = decode;
  17185. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17186. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  17187. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  17188. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  17189. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  17190. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  17191. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  17192. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17193. var _ParseOp = _dereq_("./ParseOp");
  17194. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  17195. /**
  17196. * @flow
  17197. */
  17198. // eslint-disable-line no-unused-vars
  17199. function decode(value /*: any*/) /*: any*/{
  17200. if (value === null || (0, _typeof2.default)(value) !== 'object' || value instanceof Date) {
  17201. return value;
  17202. }
  17203. if ((0, _isArray.default)(value)) {
  17204. var dup = [];
  17205. (0, _forEach.default)(value).call(value, function (v, i) {
  17206. dup[i] = decode(v);
  17207. });
  17208. return dup;
  17209. }
  17210. if (typeof value.__op === 'string') {
  17211. return (0, _ParseOp.opFromJSON)(value);
  17212. }
  17213. if (value.__type === 'Pointer' && value.className) {
  17214. return _ParseObject.default.fromJSON(value);
  17215. }
  17216. if (value.__type === 'Object' && value.className) {
  17217. return _ParseObject.default.fromJSON(value);
  17218. }
  17219. if (value.__type === 'Relation') {
  17220. // The parent and key fields will be populated by the parent
  17221. var relation = new _ParseRelation.default(null, null);
  17222. relation.targetClassName = value.className;
  17223. return relation;
  17224. }
  17225. if (value.__type === 'Date') {
  17226. return new Date(value.iso);
  17227. }
  17228. if (value.__type === 'File') {
  17229. return _ParseFile.default.fromJSON(value);
  17230. }
  17231. if (value.__type === 'GeoPoint') {
  17232. return new _ParseGeoPoint.default({
  17233. latitude: value.latitude,
  17234. longitude: value.longitude
  17235. });
  17236. }
  17237. if (value.__type === 'Polygon') {
  17238. return new _ParsePolygon.default(value.coordinates);
  17239. }
  17240. var copy = {};
  17241. for (var k in value) {
  17242. copy[k] = decode(value[k]);
  17243. }
  17244. return copy;
  17245. }
  17246. },{"./ParseACL":18,"./ParseFile":22,"./ParseGeoPoint":23,"./ParseObject":26,"./ParseOp":27,"./ParsePolygon":28,"./ParseRelation":30,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],47:[function(_dereq_,module,exports){
  17247. "use strict";
  17248. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17249. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17250. _Object$defineProperty(exports, "__esModule", {
  17251. value: true
  17252. });
  17253. exports.default = _default;
  17254. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  17255. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  17256. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  17257. var _startsWith = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
  17258. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  17259. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17260. var _map = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/map"));
  17261. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  17262. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  17263. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  17264. var _ParsePolygon = _interopRequireDefault(_dereq_("./ParsePolygon"));
  17265. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17266. var _ParseOp = _dereq_("./ParseOp");
  17267. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  17268. /**
  17269. * @flow
  17270. */
  17271. function encode(value /*: mixed*/, disallowObjects /*: boolean*/, forcePointers /*: boolean*/, seen /*: Array<mixed>*/, offline /*: boolean*/) /*: any*/{
  17272. if (value instanceof _ParseObject.default) {
  17273. if (disallowObjects) {
  17274. throw new Error('Parse Objects not allowed here');
  17275. }
  17276. var seenEntry = value.id ? value.className + ':' + value.id : value;
  17277. if (forcePointers || !seen || (0, _indexOf.default)(seen).call(seen, seenEntry) > -1 || value.dirty() || (0, _keys.default)(value._getServerData()).length < 1) {
  17278. var _context;
  17279. if (offline && (0, _startsWith.default)(_context = value._getId()).call(_context, 'local')) {
  17280. return value.toOfflinePointer();
  17281. }
  17282. return value.toPointer();
  17283. }
  17284. seen = (0, _concat.default)(seen).call(seen, seenEntry);
  17285. return value._toFullJSON(seen, offline);
  17286. }
  17287. if (value instanceof _ParseOp.Op || value instanceof _ParseACL.default || value instanceof _ParseGeoPoint.default || value instanceof _ParsePolygon.default || value instanceof _ParseRelation.default) {
  17288. return value.toJSON();
  17289. }
  17290. if (value instanceof _ParseFile.default) {
  17291. if (!value.url()) {
  17292. throw new Error('Tried to encode an unsaved file.');
  17293. }
  17294. return value.toJSON();
  17295. }
  17296. if (Object.prototype.toString.call(value) === '[object Date]') {
  17297. if (isNaN(value)) {
  17298. throw new Error('Tried to encode an invalid date.');
  17299. }
  17300. return {
  17301. __type: 'Date',
  17302. iso: value /*: any*/.toJSON()
  17303. };
  17304. }
  17305. if (Object.prototype.toString.call(value) === '[object RegExp]' && typeof value.source === 'string') {
  17306. return value.source;
  17307. }
  17308. if ((0, _isArray.default)(value)) {
  17309. return (0, _map.default)(value).call(value, function (v) {
  17310. return encode(v, disallowObjects, forcePointers, seen, offline);
  17311. });
  17312. }
  17313. if (value && (0, _typeof2.default)(value) === 'object') {
  17314. var output = {};
  17315. for (var k in value) {
  17316. output[k] = encode(value[k], disallowObjects, forcePointers, seen, offline);
  17317. }
  17318. return output;
  17319. }
  17320. return value;
  17321. }
  17322. function _default(value /*: mixed*/, disallowObjects /*:: ?: boolean*/, forcePointers /*:: ?: boolean*/, seen /*:: ?: Array<mixed>*/, offline /*:: ?: boolean*/) /*: any*/{
  17323. return encode(value, !!disallowObjects, !!forcePointers, seen || [], offline);
  17324. }
  17325. },{"./ParseACL":18,"./ParseFile":22,"./ParseGeoPoint":23,"./ParseObject":26,"./ParseOp":27,"./ParsePolygon":28,"./ParseRelation":30,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/concat":59,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/instance/map":69,"@babel/runtime-corejs3/core-js-stable/instance/starts-with":74,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],48:[function(_dereq_,module,exports){
  17326. "use strict";
  17327. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17328. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17329. _Object$defineProperty(exports, "__esModule", {
  17330. value: true
  17331. });
  17332. exports.default = equals;
  17333. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17334. var _keys = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/object/keys"));
  17335. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  17336. var _ParseACL = _interopRequireDefault(_dereq_("./ParseACL"));
  17337. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  17338. var _ParseGeoPoint = _interopRequireDefault(_dereq_("./ParseGeoPoint"));
  17339. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17340. function equals(a, b) {
  17341. var toString = Object.prototype.toString;
  17342. if (toString.call(a) === '[object Date]' || toString.call(b) === '[object Date]') {
  17343. var dateA = new Date(a);
  17344. var dateB = new Date(b);
  17345. return +dateA === +dateB;
  17346. }
  17347. if ((0, _typeof2.default)(a) !== (0, _typeof2.default)(b)) {
  17348. return false;
  17349. }
  17350. if (!a || (0, _typeof2.default)(a) !== 'object') {
  17351. // a is a primitive
  17352. return a === b;
  17353. }
  17354. if ((0, _isArray.default)(a) || (0, _isArray.default)(b)) {
  17355. if (!(0, _isArray.default)(a) || !(0, _isArray.default)(b)) {
  17356. return false;
  17357. }
  17358. if (a.length !== b.length) {
  17359. return false;
  17360. }
  17361. for (var i = a.length; i--;) {
  17362. if (!equals(a[i], b[i])) {
  17363. return false;
  17364. }
  17365. }
  17366. return true;
  17367. }
  17368. if (a instanceof _ParseACL.default || a instanceof _ParseFile.default || a instanceof _ParseGeoPoint.default || a instanceof _ParseObject.default) {
  17369. return a.equals(b);
  17370. }
  17371. if (b instanceof _ParseObject.default) {
  17372. if (a.__type === 'Object' || a.__type === 'Pointer') {
  17373. return a.objectId === b.id && a.className === b.className;
  17374. }
  17375. }
  17376. if ((0, _keys.default)(a).length !== (0, _keys.default)(b).length) {
  17377. return false;
  17378. }
  17379. for (var k in a) {
  17380. if (!equals(a[k], b[k])) {
  17381. return false;
  17382. }
  17383. }
  17384. return true;
  17385. }
  17386. },{"./ParseACL":18,"./ParseFile":22,"./ParseGeoPoint":23,"./ParseObject":26,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/object/keys":89,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],49:[function(_dereq_,module,exports){
  17387. "use strict";
  17388. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17389. _Object$defineProperty(exports, "__esModule", {
  17390. value: true
  17391. });
  17392. exports.default = escape;
  17393. /*
  17394. * @flow
  17395. */
  17396. var encoded = {
  17397. '&': '&amp;',
  17398. '<': '&lt;',
  17399. '>': '&gt;',
  17400. '/': '&#x2F;',
  17401. "'": '&#x27;',
  17402. '"': '&quot;'
  17403. };
  17404. function escape(str /*: string*/) /*: string*/{
  17405. return str.replace(/[&<>\/'"]/g, function (char) {
  17406. return encoded[char];
  17407. });
  17408. }
  17409. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":82}],50:[function(_dereq_,module,exports){
  17410. "use strict";
  17411. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17412. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17413. _Object$defineProperty(exports, "__esModule", {
  17414. value: true
  17415. });
  17416. exports.default = isRevocableSession;
  17417. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  17418. /**
  17419. * @flow
  17420. */
  17421. function isRevocableSession(token /*: string*/) /*: boolean*/{
  17422. return (0, _indexOf.default)(token).call(token, 'r:') > -1;
  17423. }
  17424. },{"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],51:[function(_dereq_,module,exports){
  17425. "use strict";
  17426. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17427. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17428. _Object$defineProperty(exports, "__esModule", {
  17429. value: true
  17430. });
  17431. exports.default = parseDate;
  17432. var _parseInt2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/parse-int"));
  17433. /**
  17434. * @flow
  17435. */
  17436. function parseDate(iso8601 /*: string*/) /*: ?Date*/{
  17437. 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$');
  17438. var match = regexp.exec(iso8601);
  17439. if (!match) {
  17440. return null;
  17441. }
  17442. var year = (0, _parseInt2.default)(match[1]) || 0;
  17443. var month = ((0, _parseInt2.default)(match[2]) || 1) - 1;
  17444. var day = (0, _parseInt2.default)(match[3]) || 0;
  17445. var hour = (0, _parseInt2.default)(match[4]) || 0;
  17446. var minute = (0, _parseInt2.default)(match[5]) || 0;
  17447. var second = (0, _parseInt2.default)(match[6]) || 0;
  17448. var milli = (0, _parseInt2.default)(match[8]) || 0;
  17449. return new Date(Date.UTC(year, month, day, hour, minute, second, milli));
  17450. }
  17451. },{"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/parse-int":90,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],52:[function(_dereq_,module,exports){
  17452. "use strict";
  17453. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17454. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17455. _Object$defineProperty(exports, "__esModule", {
  17456. value: true
  17457. });
  17458. exports.continueWhile = continueWhile;
  17459. exports.resolvingPromise = resolvingPromise;
  17460. exports.when = when;
  17461. var _promise = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/promise"));
  17462. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17463. // Create Deferred Promise
  17464. function resolvingPromise() {
  17465. var res;
  17466. var rej;
  17467. var promise = new _promise.default(function (resolve, reject) {
  17468. res = resolve;
  17469. rej = reject;
  17470. });
  17471. promise.resolve = res;
  17472. promise.reject = rej;
  17473. return promise;
  17474. }
  17475. function when(promises) {
  17476. var objects;
  17477. var arrayArgument = (0, _isArray.default)(promises);
  17478. if (arrayArgument) {
  17479. objects = promises;
  17480. } else {
  17481. objects = arguments;
  17482. }
  17483. var total = objects.length;
  17484. var hadError = false;
  17485. var results = [];
  17486. var returnValue = arrayArgument ? [results] : results;
  17487. var errors = [];
  17488. results.length = objects.length;
  17489. errors.length = objects.length;
  17490. if (total === 0) {
  17491. return _promise.default.resolve(returnValue);
  17492. }
  17493. var promise = new resolvingPromise();
  17494. var resolveOne = function () {
  17495. total--;
  17496. if (total <= 0) {
  17497. if (hadError) {
  17498. promise.reject(errors);
  17499. } else {
  17500. promise.resolve(returnValue);
  17501. }
  17502. }
  17503. };
  17504. var chain = function (object, index) {
  17505. if (object && typeof object.then === 'function') {
  17506. object.then(function (result) {
  17507. results[index] = result;
  17508. resolveOne();
  17509. }, function (error) {
  17510. errors[index] = error;
  17511. hadError = true;
  17512. resolveOne();
  17513. });
  17514. } else {
  17515. results[index] = object;
  17516. resolveOne();
  17517. }
  17518. };
  17519. for (var i = 0; i < objects.length; i++) {
  17520. chain(objects[i], i);
  17521. }
  17522. return promise;
  17523. }
  17524. function continueWhile(test, emitter) {
  17525. if (test()) {
  17526. return emitter().then(function () {
  17527. return continueWhile(test, emitter);
  17528. });
  17529. }
  17530. return _promise.default.resolve();
  17531. }
  17532. },{"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/core-js-stable/promise":91,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],53:[function(_dereq_,module,exports){
  17533. "use strict";
  17534. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17535. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17536. _Object$defineProperty(exports, "__esModule", {
  17537. value: true
  17538. });
  17539. exports.default = unique;
  17540. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  17541. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  17542. var _arrayContainsObject = _interopRequireDefault(_dereq_("./arrayContainsObject"));
  17543. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17544. /**
  17545. * @flow
  17546. */
  17547. function unique /*:: <T>*/(arr /*: Array<T>*/) /*: Array<T>*/{
  17548. var uniques = [];
  17549. (0, _forEach.default)(arr).call(arr, function (value) {
  17550. if (value instanceof _ParseObject.default) {
  17551. if (!(0, _arrayContainsObject.default)(uniques, value)) {
  17552. uniques.push(value);
  17553. }
  17554. } else {
  17555. if ((0, _indexOf.default)(uniques).call(uniques, value) < 0) {
  17556. uniques.push(value);
  17557. }
  17558. }
  17559. });
  17560. return uniques;
  17561. }
  17562. },{"./ParseObject":26,"./arrayContainsObject":44,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":130}],54:[function(_dereq_,module,exports){
  17563. "use strict";
  17564. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
  17565. var _interopRequireDefault = _dereq_("@babel/runtime-corejs3/helpers/interopRequireDefault");
  17566. _Object$defineProperty(exports, "__esModule", {
  17567. value: true
  17568. });
  17569. exports.default = unsavedChildren;
  17570. var _concat = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  17571. var _indexOf = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
  17572. var _isArray = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/array/is-array"));
  17573. var _forEach = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  17574. var _typeof2 = _interopRequireDefault(_dereq_("@babel/runtime-corejs3/helpers/typeof"));
  17575. var _ParseFile = _interopRequireDefault(_dereq_("./ParseFile"));
  17576. var _ParseObject = _interopRequireDefault(_dereq_("./ParseObject"));
  17577. var _ParseRelation = _interopRequireDefault(_dereq_("./ParseRelation"));
  17578. /**
  17579. * @flow
  17580. */
  17581. /*:: type EncounterMap = {
  17582. objects: { [identifier: string]: ParseObject | boolean },
  17583. files: Array<ParseFile>,
  17584. };*/
  17585. /**
  17586. * Return an array of unsaved children, which are either Parse Objects or Files.
  17587. * If it encounters any dirty Objects without Ids, it will throw an exception.
  17588. *
  17589. * @param {Parse.Object} obj
  17590. * @param {boolean} allowDeepUnsaved
  17591. * @returns {Array}
  17592. */
  17593. function unsavedChildren(obj /*: ParseObject*/, allowDeepUnsaved /*:: ?: boolean*/) /*: Array<ParseFile | ParseObject>*/{
  17594. var encountered = {
  17595. objects: {},
  17596. files: []
  17597. };
  17598. var identifier = obj.className + ':' + obj._getId();
  17599. encountered.objects[identifier] = obj.dirty() ? obj : true;
  17600. var attributes = obj.attributes;
  17601. for (var attr in attributes) {
  17602. if ((0, _typeof2.default)(attributes[attr]) === 'object') {
  17603. traverse(attributes[attr], encountered, false, !!allowDeepUnsaved);
  17604. }
  17605. }
  17606. var unsaved = [];
  17607. for (var id in encountered.objects) {
  17608. if (id !== identifier && encountered.objects[id] !== true) {
  17609. unsaved.push(encountered.objects[id]);
  17610. }
  17611. }
  17612. return (0, _concat.default)(unsaved).call(unsaved, encountered.files);
  17613. }
  17614. function traverse(obj /*: ParseObject*/, encountered /*: EncounterMap*/, shouldThrow /*: boolean*/, allowDeepUnsaved /*: boolean*/) {
  17615. if (obj instanceof _ParseObject.default) {
  17616. if (!obj.id && shouldThrow) {
  17617. throw new Error('Cannot create a pointer to an unsaved Object.');
  17618. }
  17619. var _identifier = obj.className + ':' + obj._getId();
  17620. if (!encountered.objects[_identifier]) {
  17621. encountered.objects[_identifier] = obj.dirty() ? obj : true;
  17622. var attributes = obj.attributes;
  17623. for (var attr in attributes) {
  17624. if ((0, _typeof2.default)(attributes[attr]) === 'object') {
  17625. traverse(attributes[attr], encountered, !allowDeepUnsaved, allowDeepUnsaved);
  17626. }
  17627. }
  17628. }
  17629. return;
  17630. }
  17631. if (obj instanceof _ParseFile.default) {
  17632. var _context;
  17633. if (!obj.url() && (0, _indexOf.default)(_context = encountered.files).call(_context, obj) < 0) {
  17634. encountered.files.push(obj);
  17635. }
  17636. return;
  17637. }
  17638. if (obj instanceof _ParseRelation.default) {
  17639. return;
  17640. }
  17641. if ((0, _isArray.default)(obj)) {
  17642. (0, _forEach.default)(obj).call(obj, function (el) {
  17643. if ((0, _typeof2.default)(el) === 'object') {
  17644. traverse(el, encountered, shouldThrow, allowDeepUnsaved);
  17645. }
  17646. });
  17647. }
  17648. for (var k in obj) {
  17649. if ((0, _typeof2.default)(obj[k]) === 'object') {
  17650. traverse(obj[k], encountered, shouldThrow, allowDeepUnsaved);
  17651. }
  17652. }
  17653. }
  17654. },{"./ParseFile":22,"./ParseObject":26,"./ParseRelation":30,"@babel/runtime-corejs3/core-js-stable/array/is-array":57,"@babel/runtime-corejs3/core-js-stable/instance/concat":59,"@babel/runtime-corejs3/core-js-stable/instance/for-each":65,"@babel/runtime-corejs3/core-js-stable/instance/index-of":67,"@babel/runtime-corejs3/core-js-stable/object/define-property":82,"@babel/runtime-corejs3/helpers/interopRequireDefault":130,"@babel/runtime-corejs3/helpers/typeof":145}],55:[function(_dereq_,module,exports){
  17655. "use strict";
  17656. var uuid = null;
  17657. uuid = function () {
  17658. var s = [];
  17659. var hexDigits = '0123456789abcdef';
  17660. for (var i = 0; i < 36; i++) {
  17661. s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  17662. }
  17663. s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
  17664. s[19] = hexDigits.substr(s[19] & 0x3 | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  17665. s[8] = s[13] = s[18] = s[23] = '-';
  17666. return s.join('');
  17667. };
  17668. var _require, v4;
  17669. module.exports = uuid;
  17670. },{}],56:[function(_dereq_,module,exports){
  17671. module.exports = _dereq_("core-js-pure/stable/array/from");
  17672. },{"core-js-pure/stable/array/from":560}],57:[function(_dereq_,module,exports){
  17673. module.exports = _dereq_("core-js-pure/stable/array/is-array");
  17674. },{"core-js-pure/stable/array/is-array":561}],58:[function(_dereq_,module,exports){
  17675. module.exports = _dereq_("core-js-pure/stable/instance/bind");
  17676. },{"core-js-pure/stable/instance/bind":567}],59:[function(_dereq_,module,exports){
  17677. module.exports = _dereq_("core-js-pure/stable/instance/concat");
  17678. },{"core-js-pure/stable/instance/concat":568}],60:[function(_dereq_,module,exports){
  17679. module.exports = _dereq_("core-js-pure/stable/instance/entries");
  17680. },{"core-js-pure/stable/instance/entries":569}],61:[function(_dereq_,module,exports){
  17681. module.exports = _dereq_("core-js-pure/stable/instance/every");
  17682. },{"core-js-pure/stable/instance/every":570}],62:[function(_dereq_,module,exports){
  17683. module.exports = _dereq_("core-js-pure/stable/instance/filter");
  17684. },{"core-js-pure/stable/instance/filter":571}],63:[function(_dereq_,module,exports){
  17685. module.exports = _dereq_("core-js-pure/stable/instance/find-index");
  17686. },{"core-js-pure/stable/instance/find-index":572}],64:[function(_dereq_,module,exports){
  17687. module.exports = _dereq_("core-js-pure/stable/instance/find");
  17688. },{"core-js-pure/stable/instance/find":573}],65:[function(_dereq_,module,exports){
  17689. module.exports = _dereq_("core-js-pure/stable/instance/for-each");
  17690. },{"core-js-pure/stable/instance/for-each":574}],66:[function(_dereq_,module,exports){
  17691. module.exports = _dereq_("core-js-pure/stable/instance/includes");
  17692. },{"core-js-pure/stable/instance/includes":575}],67:[function(_dereq_,module,exports){
  17693. module.exports = _dereq_("core-js-pure/stable/instance/index-of");
  17694. },{"core-js-pure/stable/instance/index-of":576}],68:[function(_dereq_,module,exports){
  17695. module.exports = _dereq_("core-js-pure/stable/instance/keys");
  17696. },{"core-js-pure/stable/instance/keys":577}],69:[function(_dereq_,module,exports){
  17697. module.exports = _dereq_("core-js-pure/stable/instance/map");
  17698. },{"core-js-pure/stable/instance/map":578}],70:[function(_dereq_,module,exports){
  17699. module.exports = _dereq_("core-js-pure/stable/instance/reduce");
  17700. },{"core-js-pure/stable/instance/reduce":579}],71:[function(_dereq_,module,exports){
  17701. module.exports = _dereq_("core-js-pure/stable/instance/slice");
  17702. },{"core-js-pure/stable/instance/slice":581}],72:[function(_dereq_,module,exports){
  17703. module.exports = _dereq_("core-js-pure/stable/instance/sort");
  17704. },{"core-js-pure/stable/instance/sort":582}],73:[function(_dereq_,module,exports){
  17705. module.exports = _dereq_("core-js-pure/stable/instance/splice");
  17706. },{"core-js-pure/stable/instance/splice":583}],74:[function(_dereq_,module,exports){
  17707. module.exports = _dereq_("core-js-pure/stable/instance/starts-with");
  17708. },{"core-js-pure/stable/instance/starts-with":584}],75:[function(_dereq_,module,exports){
  17709. module.exports = _dereq_("core-js-pure/stable/instance/values");
  17710. },{"core-js-pure/stable/instance/values":585}],76:[function(_dereq_,module,exports){
  17711. module.exports = _dereq_("core-js-pure/stable/json/stringify");
  17712. },{"core-js-pure/stable/json/stringify":586}],77:[function(_dereq_,module,exports){
  17713. module.exports = _dereq_("core-js-pure/stable/map");
  17714. },{"core-js-pure/stable/map":587}],78:[function(_dereq_,module,exports){
  17715. module.exports = _dereq_("core-js-pure/stable/number/is-integer");
  17716. },{"core-js-pure/stable/number/is-integer":588}],79:[function(_dereq_,module,exports){
  17717. module.exports = _dereq_("core-js-pure/stable/object/assign");
  17718. },{"core-js-pure/stable/object/assign":589}],80:[function(_dereq_,module,exports){
  17719. module.exports = _dereq_("core-js-pure/stable/object/create");
  17720. },{"core-js-pure/stable/object/create":590}],81:[function(_dereq_,module,exports){
  17721. module.exports = _dereq_("core-js-pure/stable/object/define-properties");
  17722. },{"core-js-pure/stable/object/define-properties":591}],82:[function(_dereq_,module,exports){
  17723. module.exports = _dereq_("core-js-pure/stable/object/define-property");
  17724. },{"core-js-pure/stable/object/define-property":592}],83:[function(_dereq_,module,exports){
  17725. module.exports = _dereq_("core-js-pure/stable/object/entries");
  17726. },{"core-js-pure/stable/object/entries":593}],84:[function(_dereq_,module,exports){
  17727. module.exports = _dereq_("core-js-pure/stable/object/freeze");
  17728. },{"core-js-pure/stable/object/freeze":594}],85:[function(_dereq_,module,exports){
  17729. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptor");
  17730. },{"core-js-pure/stable/object/get-own-property-descriptor":595}],86:[function(_dereq_,module,exports){
  17731. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-descriptors");
  17732. },{"core-js-pure/stable/object/get-own-property-descriptors":596}],87:[function(_dereq_,module,exports){
  17733. module.exports = _dereq_("core-js-pure/stable/object/get-own-property-symbols");
  17734. },{"core-js-pure/stable/object/get-own-property-symbols":597}],88:[function(_dereq_,module,exports){
  17735. module.exports = _dereq_("core-js-pure/stable/object/get-prototype-of");
  17736. },{"core-js-pure/stable/object/get-prototype-of":598}],89:[function(_dereq_,module,exports){
  17737. module.exports = _dereq_("core-js-pure/stable/object/keys");
  17738. },{"core-js-pure/stable/object/keys":599}],90:[function(_dereq_,module,exports){
  17739. module.exports = _dereq_("core-js-pure/stable/parse-int");
  17740. },{"core-js-pure/stable/parse-int":601}],91:[function(_dereq_,module,exports){
  17741. module.exports = _dereq_("core-js-pure/stable/promise");
  17742. },{"core-js-pure/stable/promise":602}],92:[function(_dereq_,module,exports){
  17743. module.exports = _dereq_("core-js-pure/stable/reflect/construct");
  17744. },{"core-js-pure/stable/reflect/construct":603}],93:[function(_dereq_,module,exports){
  17745. module.exports = _dereq_("core-js-pure/stable/set-interval");
  17746. },{"core-js-pure/stable/set-interval":605}],94:[function(_dereq_,module,exports){
  17747. module.exports = _dereq_("core-js-pure/stable/set-timeout");
  17748. },{"core-js-pure/stable/set-timeout":606}],95:[function(_dereq_,module,exports){
  17749. module.exports = _dereq_("core-js-pure/stable/set");
  17750. },{"core-js-pure/stable/set":607}],96:[function(_dereq_,module,exports){
  17751. module.exports = _dereq_("core-js-pure/stable/symbol");
  17752. },{"core-js-pure/stable/symbol":608}],97:[function(_dereq_,module,exports){
  17753. module.exports = _dereq_("core-js-pure/stable/weak-map");
  17754. },{"core-js-pure/stable/weak-map":611}],98:[function(_dereq_,module,exports){
  17755. module.exports = _dereq_("core-js-pure/features/array/from");
  17756. },{"core-js-pure/features/array/from":232}],99:[function(_dereq_,module,exports){
  17757. module.exports = _dereq_("core-js-pure/features/array/is-array");
  17758. },{"core-js-pure/features/array/is-array":233}],100:[function(_dereq_,module,exports){
  17759. module.exports = _dereq_("core-js-pure/features/get-iterator-method");
  17760. },{"core-js-pure/features/get-iterator-method":234}],101:[function(_dereq_,module,exports){
  17761. module.exports = _dereq_("core-js-pure/features/instance/bind");
  17762. },{"core-js-pure/features/instance/bind":235}],102:[function(_dereq_,module,exports){
  17763. module.exports = _dereq_("core-js-pure/features/instance/for-each");
  17764. },{"core-js-pure/features/instance/for-each":236}],103:[function(_dereq_,module,exports){
  17765. module.exports = _dereq_("core-js-pure/features/instance/index-of");
  17766. },{"core-js-pure/features/instance/index-of":237}],104:[function(_dereq_,module,exports){
  17767. module.exports = _dereq_("core-js-pure/features/instance/reverse");
  17768. },{"core-js-pure/features/instance/reverse":238}],105:[function(_dereq_,module,exports){
  17769. module.exports = _dereq_("core-js-pure/features/instance/slice");
  17770. },{"core-js-pure/features/instance/slice":239}],106:[function(_dereq_,module,exports){
  17771. module.exports = _dereq_("core-js-pure/features/map");
  17772. },{"core-js-pure/features/map":240}],107:[function(_dereq_,module,exports){
  17773. module.exports = _dereq_("core-js-pure/features/object/create");
  17774. },{"core-js-pure/features/object/create":241}],108:[function(_dereq_,module,exports){
  17775. module.exports = _dereq_("core-js-pure/features/object/define-property");
  17776. },{"core-js-pure/features/object/define-property":242}],109:[function(_dereq_,module,exports){
  17777. module.exports = _dereq_("core-js-pure/features/object/get-own-property-descriptor");
  17778. },{"core-js-pure/features/object/get-own-property-descriptor":243}],110:[function(_dereq_,module,exports){
  17779. module.exports = _dereq_("core-js-pure/features/object/get-prototype-of");
  17780. },{"core-js-pure/features/object/get-prototype-of":244}],111:[function(_dereq_,module,exports){
  17781. module.exports = _dereq_("core-js-pure/features/object/set-prototype-of");
  17782. },{"core-js-pure/features/object/set-prototype-of":245}],112:[function(_dereq_,module,exports){
  17783. module.exports = _dereq_("core-js-pure/features/promise");
  17784. },{"core-js-pure/features/promise":246}],113:[function(_dereq_,module,exports){
  17785. module.exports = _dereq_("core-js-pure/features/reflect/construct");
  17786. },{"core-js-pure/features/reflect/construct":247}],114:[function(_dereq_,module,exports){
  17787. module.exports = _dereq_("core-js-pure/features/reflect/get");
  17788. },{"core-js-pure/features/reflect/get":248}],115:[function(_dereq_,module,exports){
  17789. module.exports = _dereq_("core-js-pure/features/symbol");
  17790. },{"core-js-pure/features/symbol":249}],116:[function(_dereq_,module,exports){
  17791. module.exports = _dereq_("core-js-pure/features/symbol/iterator");
  17792. },{"core-js-pure/features/symbol/iterator":250}],117:[function(_dereq_,module,exports){
  17793. module.exports = _dereq_("core-js-pure/features/symbol/to-primitive");
  17794. },{"core-js-pure/features/symbol/to-primitive":251}],118:[function(_dereq_,module,exports){
  17795. function _arrayLikeToArray(arr, len) {
  17796. if (len == null || len > arr.length) len = arr.length;
  17797. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  17798. return arr2;
  17799. }
  17800. module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17801. },{}],119:[function(_dereq_,module,exports){
  17802. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js/array/is-array");
  17803. function _arrayWithHoles(arr) {
  17804. if (_Array$isArray(arr)) return arr;
  17805. }
  17806. module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17807. },{"@babel/runtime-corejs3/core-js/array/is-array":99}],120:[function(_dereq_,module,exports){
  17808. var _Array$isArray = _dereq_("@babel/runtime-corejs3/core-js/array/is-array");
  17809. var arrayLikeToArray = _dereq_("./arrayLikeToArray.js");
  17810. function _arrayWithoutHoles(arr) {
  17811. if (_Array$isArray(arr)) return arrayLikeToArray(arr);
  17812. }
  17813. module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17814. },{"./arrayLikeToArray.js":118,"@babel/runtime-corejs3/core-js/array/is-array":99}],121:[function(_dereq_,module,exports){
  17815. function _assertThisInitialized(self) {
  17816. if (self === void 0) {
  17817. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  17818. }
  17819. return self;
  17820. }
  17821. module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17822. },{}],122:[function(_dereq_,module,exports){
  17823. var _Promise = _dereq_("@babel/runtime-corejs3/core-js/promise");
  17824. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  17825. try {
  17826. var info = gen[key](arg);
  17827. var value = info.value;
  17828. } catch (error) {
  17829. reject(error);
  17830. return;
  17831. }
  17832. if (info.done) {
  17833. resolve(value);
  17834. } else {
  17835. _Promise.resolve(value).then(_next, _throw);
  17836. }
  17837. }
  17838. function _asyncToGenerator(fn) {
  17839. return function () {
  17840. var self = this,
  17841. args = arguments;
  17842. return new _Promise(function (resolve, reject) {
  17843. var gen = fn.apply(self, args);
  17844. function _next(value) {
  17845. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  17846. }
  17847. function _throw(err) {
  17848. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  17849. }
  17850. _next(undefined);
  17851. });
  17852. };
  17853. }
  17854. module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17855. },{"@babel/runtime-corejs3/core-js/promise":112}],123:[function(_dereq_,module,exports){
  17856. function _classCallCheck(instance, Constructor) {
  17857. if (!(instance instanceof Constructor)) {
  17858. throw new TypeError("Cannot call a class as a function");
  17859. }
  17860. }
  17861. module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17862. },{}],124:[function(_dereq_,module,exports){
  17863. var _bindInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/bind");
  17864. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js/reflect/construct");
  17865. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  17866. var isNativeReflectConstruct = _dereq_("./isNativeReflectConstruct.js");
  17867. function _construct(Parent, args, Class) {
  17868. if (isNativeReflectConstruct()) {
  17869. var _context;
  17870. module.exports = _construct = _bindInstanceProperty(_context = _Reflect$construct).call(_context), module.exports.__esModule = true, module.exports["default"] = module.exports;
  17871. } else {
  17872. module.exports = _construct = function _construct(Parent, args, Class) {
  17873. var a = [null];
  17874. a.push.apply(a, args);
  17875. var Constructor = _bindInstanceProperty(Function).apply(Parent, a);
  17876. var instance = new Constructor();
  17877. if (Class) setPrototypeOf(instance, Class.prototype);
  17878. return instance;
  17879. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17880. }
  17881. return _construct.apply(null, arguments);
  17882. }
  17883. module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17884. },{"./isNativeReflectConstruct.js":132,"./setPrototypeOf.js":139,"@babel/runtime-corejs3/core-js/instance/bind":101,"@babel/runtime-corejs3/core-js/reflect/construct":113}],125:[function(_dereq_,module,exports){
  17885. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  17886. var toPropertyKey = _dereq_("./toPropertyKey.js");
  17887. function _defineProperties(target, props) {
  17888. for (var i = 0; i < props.length; i++) {
  17889. var descriptor = props[i];
  17890. descriptor.enumerable = descriptor.enumerable || false;
  17891. descriptor.configurable = true;
  17892. if ("value" in descriptor) descriptor.writable = true;
  17893. _Object$defineProperty(target, toPropertyKey(descriptor.key), descriptor);
  17894. }
  17895. }
  17896. function _createClass(Constructor, protoProps, staticProps) {
  17897. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  17898. if (staticProps) _defineProperties(Constructor, staticProps);
  17899. _Object$defineProperty(Constructor, "prototype", {
  17900. writable: false
  17901. });
  17902. return Constructor;
  17903. }
  17904. module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17905. },{"./toPropertyKey.js":144,"@babel/runtime-corejs3/core-js/object/define-property":108}],126:[function(_dereq_,module,exports){
  17906. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  17907. var toPropertyKey = _dereq_("./toPropertyKey.js");
  17908. function _defineProperty(obj, key, value) {
  17909. key = toPropertyKey(key);
  17910. if (key in obj) {
  17911. _Object$defineProperty(obj, key, {
  17912. value: value,
  17913. enumerable: true,
  17914. configurable: true,
  17915. writable: true
  17916. });
  17917. } else {
  17918. obj[key] = value;
  17919. }
  17920. return obj;
  17921. }
  17922. module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17923. },{"./toPropertyKey.js":144,"@babel/runtime-corejs3/core-js/object/define-property":108}],127:[function(_dereq_,module,exports){
  17924. var _Reflect$get = _dereq_("@babel/runtime-corejs3/core-js/reflect/get");
  17925. var _bindInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/bind");
  17926. var _Object$getOwnPropertyDescriptor = _dereq_("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor");
  17927. var superPropBase = _dereq_("./superPropBase.js");
  17928. function _get() {
  17929. if (typeof Reflect !== "undefined" && _Reflect$get) {
  17930. var _context;
  17931. module.exports = _get = _bindInstanceProperty(_context = _Reflect$get).call(_context), module.exports.__esModule = true, module.exports["default"] = module.exports;
  17932. } else {
  17933. module.exports = _get = function _get(target, property, receiver) {
  17934. var base = superPropBase(target, property);
  17935. if (!base) return;
  17936. var desc = _Object$getOwnPropertyDescriptor(base, property);
  17937. if (desc.get) {
  17938. return desc.get.call(arguments.length < 3 ? target : receiver);
  17939. }
  17940. return desc.value;
  17941. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17942. }
  17943. return _get.apply(this, arguments);
  17944. }
  17945. module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17946. },{"./superPropBase.js":141,"@babel/runtime-corejs3/core-js/instance/bind":101,"@babel/runtime-corejs3/core-js/object/get-own-property-descriptor":109,"@babel/runtime-corejs3/core-js/reflect/get":114}],128:[function(_dereq_,module,exports){
  17947. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
  17948. var _bindInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/bind");
  17949. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/get-prototype-of");
  17950. function _getPrototypeOf(o) {
  17951. var _context;
  17952. module.exports = _getPrototypeOf = _Object$setPrototypeOf ? _bindInstanceProperty(_context = _Object$getPrototypeOf).call(_context) : function _getPrototypeOf(o) {
  17953. return o.__proto__ || _Object$getPrototypeOf(o);
  17954. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17955. return _getPrototypeOf(o);
  17956. }
  17957. module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17958. },{"@babel/runtime-corejs3/core-js/instance/bind":101,"@babel/runtime-corejs3/core-js/object/get-prototype-of":110,"@babel/runtime-corejs3/core-js/object/set-prototype-of":111}],129:[function(_dereq_,module,exports){
  17959. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
  17960. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  17961. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  17962. function _inherits(subClass, superClass) {
  17963. if (typeof superClass !== "function" && superClass !== null) {
  17964. throw new TypeError("Super expression must either be null or a function");
  17965. }
  17966. subClass.prototype = _Object$create(superClass && superClass.prototype, {
  17967. constructor: {
  17968. value: subClass,
  17969. writable: true,
  17970. configurable: true
  17971. }
  17972. });
  17973. _Object$defineProperty(subClass, "prototype", {
  17974. writable: false
  17975. });
  17976. if (superClass) setPrototypeOf(subClass, superClass);
  17977. }
  17978. module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17979. },{"./setPrototypeOf.js":139,"@babel/runtime-corejs3/core-js/object/create":107,"@babel/runtime-corejs3/core-js/object/define-property":108}],130:[function(_dereq_,module,exports){
  17980. function _interopRequireDefault(obj) {
  17981. return obj && obj.__esModule ? obj : {
  17982. "default": obj
  17983. };
  17984. }
  17985. module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17986. },{}],131:[function(_dereq_,module,exports){
  17987. var _indexOfInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/index-of");
  17988. function _isNativeFunction(fn) {
  17989. var _context;
  17990. return _indexOfInstanceProperty(_context = Function.toString.call(fn)).call(_context, "[native code]") !== -1;
  17991. }
  17992. module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17993. },{"@babel/runtime-corejs3/core-js/instance/index-of":103}],132:[function(_dereq_,module,exports){
  17994. var _Reflect$construct = _dereq_("@babel/runtime-corejs3/core-js/reflect/construct");
  17995. function _isNativeReflectConstruct() {
  17996. if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
  17997. if (_Reflect$construct.sham) return false;
  17998. if (typeof Proxy === "function") return true;
  17999. try {
  18000. Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
  18001. return true;
  18002. } catch (e) {
  18003. return false;
  18004. }
  18005. }
  18006. module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18007. },{"@babel/runtime-corejs3/core-js/reflect/construct":113}],133:[function(_dereq_,module,exports){
  18008. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  18009. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  18010. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js/array/from");
  18011. function _iterableToArray(iter) {
  18012. if (typeof _Symbol !== "undefined" && _getIteratorMethod(iter) != null || iter["@@iterator"] != null) return _Array$from(iter);
  18013. }
  18014. module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18015. },{"@babel/runtime-corejs3/core-js/array/from":98,"@babel/runtime-corejs3/core-js/get-iterator-method":100,"@babel/runtime-corejs3/core-js/symbol":115}],134:[function(_dereq_,module,exports){
  18016. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  18017. var _getIteratorMethod = _dereq_("@babel/runtime-corejs3/core-js/get-iterator-method");
  18018. function _iterableToArrayLimit(arr, i) {
  18019. var _i = null == arr ? null : "undefined" != typeof _Symbol && _getIteratorMethod(arr) || arr["@@iterator"];
  18020. if (null != _i) {
  18021. var _s,
  18022. _e,
  18023. _x,
  18024. _r,
  18025. _arr = [],
  18026. _n = !0,
  18027. _d = !1;
  18028. try {
  18029. if (_x = (_i = _i.call(arr)).next, 0 === i) {
  18030. if (Object(_i) !== _i) return;
  18031. _n = !1;
  18032. } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
  18033. } catch (err) {
  18034. _d = !0, _e = err;
  18035. } finally {
  18036. try {
  18037. if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
  18038. } finally {
  18039. if (_d) throw _e;
  18040. }
  18041. }
  18042. return _arr;
  18043. }
  18044. }
  18045. module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18046. },{"@babel/runtime-corejs3/core-js/get-iterator-method":100,"@babel/runtime-corejs3/core-js/symbol":115}],135:[function(_dereq_,module,exports){
  18047. function _nonIterableRest() {
  18048. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  18049. }
  18050. module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18051. },{}],136:[function(_dereq_,module,exports){
  18052. function _nonIterableSpread() {
  18053. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  18054. }
  18055. module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18056. },{}],137:[function(_dereq_,module,exports){
  18057. var _typeof = _dereq_("./typeof.js")["default"];
  18058. var assertThisInitialized = _dereq_("./assertThisInitialized.js");
  18059. function _possibleConstructorReturn(self, call) {
  18060. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  18061. return call;
  18062. } else if (call !== void 0) {
  18063. throw new TypeError("Derived constructors may only return object or undefined");
  18064. }
  18065. return assertThisInitialized(self);
  18066. }
  18067. module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18068. },{"./assertThisInitialized.js":121,"./typeof.js":145}],138:[function(_dereq_,module,exports){
  18069. var _typeof = _dereq_("./typeof.js")["default"];
  18070. var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js/object/define-property");
  18071. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  18072. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
  18073. var _Object$getPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/get-prototype-of");
  18074. var _forEachInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/for-each");
  18075. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
  18076. var _Promise = _dereq_("@babel/runtime-corejs3/core-js/promise");
  18077. var _reverseInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/reverse");
  18078. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/slice");
  18079. function _regeneratorRuntime() {
  18080. "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  18081. module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
  18082. return exports;
  18083. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18084. var exports = {},
  18085. Op = Object.prototype,
  18086. hasOwn = Op.hasOwnProperty,
  18087. defineProperty = _Object$defineProperty || function (obj, key, desc) {
  18088. obj[key] = desc.value;
  18089. },
  18090. $Symbol = "function" == typeof _Symbol ? _Symbol : {},
  18091. iteratorSymbol = $Symbol.iterator || "@@iterator",
  18092. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  18093. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  18094. function define(obj, key, value) {
  18095. return _Object$defineProperty(obj, key, {
  18096. value: value,
  18097. enumerable: !0,
  18098. configurable: !0,
  18099. writable: !0
  18100. }), obj[key];
  18101. }
  18102. try {
  18103. define({}, "");
  18104. } catch (err) {
  18105. define = function define(obj, key, value) {
  18106. return obj[key] = value;
  18107. };
  18108. }
  18109. function wrap(innerFn, outerFn, self, tryLocsList) {
  18110. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  18111. generator = _Object$create(protoGenerator.prototype),
  18112. context = new Context(tryLocsList || []);
  18113. return defineProperty(generator, "_invoke", {
  18114. value: makeInvokeMethod(innerFn, self, context)
  18115. }), generator;
  18116. }
  18117. function tryCatch(fn, obj, arg) {
  18118. try {
  18119. return {
  18120. type: "normal",
  18121. arg: fn.call(obj, arg)
  18122. };
  18123. } catch (err) {
  18124. return {
  18125. type: "throw",
  18126. arg: err
  18127. };
  18128. }
  18129. }
  18130. exports.wrap = wrap;
  18131. var ContinueSentinel = {};
  18132. function Generator() {}
  18133. function GeneratorFunction() {}
  18134. function GeneratorFunctionPrototype() {}
  18135. var IteratorPrototype = {};
  18136. define(IteratorPrototype, iteratorSymbol, function () {
  18137. return this;
  18138. });
  18139. var getProto = _Object$getPrototypeOf,
  18140. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  18141. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  18142. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype);
  18143. function defineIteratorMethods(prototype) {
  18144. var _context;
  18145. _forEachInstanceProperty(_context = ["next", "throw", "return"]).call(_context, function (method) {
  18146. define(prototype, method, function (arg) {
  18147. return this._invoke(method, arg);
  18148. });
  18149. });
  18150. }
  18151. function AsyncIterator(generator, PromiseImpl) {
  18152. function invoke(method, arg, resolve, reject) {
  18153. var record = tryCatch(generator[method], generator, arg);
  18154. if ("throw" !== record.type) {
  18155. var result = record.arg,
  18156. value = result.value;
  18157. return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  18158. invoke("next", value, resolve, reject);
  18159. }, function (err) {
  18160. invoke("throw", err, resolve, reject);
  18161. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  18162. result.value = unwrapped, resolve(result);
  18163. }, function (error) {
  18164. return invoke("throw", error, resolve, reject);
  18165. });
  18166. }
  18167. reject(record.arg);
  18168. }
  18169. var previousPromise;
  18170. defineProperty(this, "_invoke", {
  18171. value: function value(method, arg) {
  18172. function callInvokeWithMethodAndArg() {
  18173. return new PromiseImpl(function (resolve, reject) {
  18174. invoke(method, arg, resolve, reject);
  18175. });
  18176. }
  18177. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  18178. }
  18179. });
  18180. }
  18181. function makeInvokeMethod(innerFn, self, context) {
  18182. var state = "suspendedStart";
  18183. return function (method, arg) {
  18184. if ("executing" === state) throw new Error("Generator is already running");
  18185. if ("completed" === state) {
  18186. if ("throw" === method) throw arg;
  18187. return doneResult();
  18188. }
  18189. for (context.method = method, context.arg = arg;;) {
  18190. var delegate = context.delegate;
  18191. if (delegate) {
  18192. var delegateResult = maybeInvokeDelegate(delegate, context);
  18193. if (delegateResult) {
  18194. if (delegateResult === ContinueSentinel) continue;
  18195. return delegateResult;
  18196. }
  18197. }
  18198. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  18199. if ("suspendedStart" === state) throw state = "completed", context.arg;
  18200. context.dispatchException(context.arg);
  18201. } else "return" === context.method && context.abrupt("return", context.arg);
  18202. state = "executing";
  18203. var record = tryCatch(innerFn, self, context);
  18204. if ("normal" === record.type) {
  18205. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  18206. return {
  18207. value: record.arg,
  18208. done: context.done
  18209. };
  18210. }
  18211. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  18212. }
  18213. };
  18214. }
  18215. function maybeInvokeDelegate(delegate, context) {
  18216. var methodName = context.method,
  18217. method = delegate.iterator[methodName];
  18218. 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;
  18219. var record = tryCatch(method, delegate.iterator, context.arg);
  18220. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  18221. var info = record.arg;
  18222. 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);
  18223. }
  18224. function pushTryEntry(locs) {
  18225. var entry = {
  18226. tryLoc: locs[0]
  18227. };
  18228. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  18229. }
  18230. function resetTryEntry(entry) {
  18231. var record = entry.completion || {};
  18232. record.type = "normal", delete record.arg, entry.completion = record;
  18233. }
  18234. function Context(tryLocsList) {
  18235. this.tryEntries = [{
  18236. tryLoc: "root"
  18237. }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
  18238. }
  18239. function values(iterable) {
  18240. if (iterable) {
  18241. var iteratorMethod = iterable[iteratorSymbol];
  18242. if (iteratorMethod) return iteratorMethod.call(iterable);
  18243. if ("function" == typeof iterable.next) return iterable;
  18244. if (!isNaN(iterable.length)) {
  18245. var i = -1,
  18246. next = function next() {
  18247. for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  18248. return next.value = undefined, next.done = !0, next;
  18249. };
  18250. return next.next = next;
  18251. }
  18252. }
  18253. return {
  18254. next: doneResult
  18255. };
  18256. }
  18257. function doneResult() {
  18258. return {
  18259. value: undefined,
  18260. done: !0
  18261. };
  18262. }
  18263. return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
  18264. value: GeneratorFunctionPrototype,
  18265. configurable: !0
  18266. }), defineProperty(GeneratorFunctionPrototype, "constructor", {
  18267. value: GeneratorFunction,
  18268. configurable: !0
  18269. }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  18270. var ctor = "function" == typeof genFun && genFun.constructor;
  18271. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  18272. }, exports.mark = function (genFun) {
  18273. return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun;
  18274. }, exports.awrap = function (arg) {
  18275. return {
  18276. __await: arg
  18277. };
  18278. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  18279. return this;
  18280. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  18281. void 0 === PromiseImpl && (PromiseImpl = _Promise);
  18282. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  18283. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  18284. return result.done ? result.value : iter.next();
  18285. });
  18286. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  18287. return this;
  18288. }), define(Gp, "toString", function () {
  18289. return "[object Generator]";
  18290. }), exports.keys = function (val) {
  18291. var object = Object(val),
  18292. keys = [];
  18293. for (var key in object) keys.push(key);
  18294. return _reverseInstanceProperty(keys).call(keys), function next() {
  18295. for (; keys.length;) {
  18296. var key = keys.pop();
  18297. if (key in object) return next.value = key, next.done = !1, next;
  18298. }
  18299. return next.done = !0, next;
  18300. };
  18301. }, exports.values = values, Context.prototype = {
  18302. constructor: Context,
  18303. reset: function reset(skipTempReset) {
  18304. var _context2;
  18305. 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);
  18306. },
  18307. stop: function stop() {
  18308. this.done = !0;
  18309. var rootRecord = this.tryEntries[0].completion;
  18310. if ("throw" === rootRecord.type) throw rootRecord.arg;
  18311. return this.rval;
  18312. },
  18313. dispatchException: function dispatchException(exception) {
  18314. if (this.done) throw exception;
  18315. var context = this;
  18316. function handle(loc, caught) {
  18317. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  18318. }
  18319. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18320. var entry = this.tryEntries[i],
  18321. record = entry.completion;
  18322. if ("root" === entry.tryLoc) return handle("end");
  18323. if (entry.tryLoc <= this.prev) {
  18324. var hasCatch = hasOwn.call(entry, "catchLoc"),
  18325. hasFinally = hasOwn.call(entry, "finallyLoc");
  18326. if (hasCatch && hasFinally) {
  18327. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  18328. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  18329. } else if (hasCatch) {
  18330. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  18331. } else {
  18332. if (!hasFinally) throw new Error("try statement without catch or finally");
  18333. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  18334. }
  18335. }
  18336. }
  18337. },
  18338. abrupt: function abrupt(type, arg) {
  18339. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18340. var entry = this.tryEntries[i];
  18341. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  18342. var finallyEntry = entry;
  18343. break;
  18344. }
  18345. }
  18346. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  18347. var record = finallyEntry ? finallyEntry.completion : {};
  18348. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  18349. },
  18350. complete: function complete(record, afterLoc) {
  18351. if ("throw" === record.type) throw record.arg;
  18352. 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;
  18353. },
  18354. finish: function finish(finallyLoc) {
  18355. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18356. var entry = this.tryEntries[i];
  18357. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  18358. }
  18359. },
  18360. "catch": function _catch(tryLoc) {
  18361. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  18362. var entry = this.tryEntries[i];
  18363. if (entry.tryLoc === tryLoc) {
  18364. var record = entry.completion;
  18365. if ("throw" === record.type) {
  18366. var thrown = record.arg;
  18367. resetTryEntry(entry);
  18368. }
  18369. return thrown;
  18370. }
  18371. }
  18372. throw new Error("illegal catch attempt");
  18373. },
  18374. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  18375. return this.delegate = {
  18376. iterator: values(iterable),
  18377. resultName: resultName,
  18378. nextLoc: nextLoc
  18379. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  18380. }
  18381. }, exports;
  18382. }
  18383. module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18384. },{"./typeof.js":145,"@babel/runtime-corejs3/core-js/instance/for-each":102,"@babel/runtime-corejs3/core-js/instance/reverse":104,"@babel/runtime-corejs3/core-js/instance/slice":105,"@babel/runtime-corejs3/core-js/object/create":107,"@babel/runtime-corejs3/core-js/object/define-property":108,"@babel/runtime-corejs3/core-js/object/get-prototype-of":110,"@babel/runtime-corejs3/core-js/object/set-prototype-of":111,"@babel/runtime-corejs3/core-js/promise":112,"@babel/runtime-corejs3/core-js/symbol":115}],139:[function(_dereq_,module,exports){
  18385. var _Object$setPrototypeOf = _dereq_("@babel/runtime-corejs3/core-js/object/set-prototype-of");
  18386. var _bindInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/bind");
  18387. function _setPrototypeOf(o, p) {
  18388. var _context;
  18389. module.exports = _setPrototypeOf = _Object$setPrototypeOf ? _bindInstanceProperty(_context = _Object$setPrototypeOf).call(_context) : function _setPrototypeOf(o, p) {
  18390. o.__proto__ = p;
  18391. return o;
  18392. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18393. return _setPrototypeOf(o, p);
  18394. }
  18395. module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18396. },{"@babel/runtime-corejs3/core-js/instance/bind":101,"@babel/runtime-corejs3/core-js/object/set-prototype-of":111}],140:[function(_dereq_,module,exports){
  18397. var arrayWithHoles = _dereq_("./arrayWithHoles.js");
  18398. var iterableToArrayLimit = _dereq_("./iterableToArrayLimit.js");
  18399. var unsupportedIterableToArray = _dereq_("./unsupportedIterableToArray.js");
  18400. var nonIterableRest = _dereq_("./nonIterableRest.js");
  18401. function _slicedToArray(arr, i) {
  18402. return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
  18403. }
  18404. module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18405. },{"./arrayWithHoles.js":119,"./iterableToArrayLimit.js":134,"./nonIterableRest.js":135,"./unsupportedIterableToArray.js":146}],141:[function(_dereq_,module,exports){
  18406. var getPrototypeOf = _dereq_("./getPrototypeOf.js");
  18407. function _superPropBase(object, property) {
  18408. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  18409. object = getPrototypeOf(object);
  18410. if (object === null) break;
  18411. }
  18412. return object;
  18413. }
  18414. module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18415. },{"./getPrototypeOf.js":128}],142:[function(_dereq_,module,exports){
  18416. var arrayWithoutHoles = _dereq_("./arrayWithoutHoles.js");
  18417. var iterableToArray = _dereq_("./iterableToArray.js");
  18418. var unsupportedIterableToArray = _dereq_("./unsupportedIterableToArray.js");
  18419. var nonIterableSpread = _dereq_("./nonIterableSpread.js");
  18420. function _toConsumableArray(arr) {
  18421. return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
  18422. }
  18423. module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18424. },{"./arrayWithoutHoles.js":120,"./iterableToArray.js":133,"./nonIterableSpread.js":136,"./unsupportedIterableToArray.js":146}],143:[function(_dereq_,module,exports){
  18425. var _Symbol$toPrimitive = _dereq_("@babel/runtime-corejs3/core-js/symbol/to-primitive");
  18426. var _typeof = _dereq_("./typeof.js")["default"];
  18427. function _toPrimitive(input, hint) {
  18428. if (_typeof(input) !== "object" || input === null) return input;
  18429. var prim = input[_Symbol$toPrimitive];
  18430. if (prim !== undefined) {
  18431. var res = prim.call(input, hint || "default");
  18432. if (_typeof(res) !== "object") return res;
  18433. throw new TypeError("@@toPrimitive must return a primitive value.");
  18434. }
  18435. return (hint === "string" ? String : Number)(input);
  18436. }
  18437. module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18438. },{"./typeof.js":145,"@babel/runtime-corejs3/core-js/symbol/to-primitive":117}],144:[function(_dereq_,module,exports){
  18439. var _typeof = _dereq_("./typeof.js")["default"];
  18440. var toPrimitive = _dereq_("./toPrimitive.js");
  18441. function _toPropertyKey(arg) {
  18442. var key = toPrimitive(arg, "string");
  18443. return _typeof(key) === "symbol" ? key : String(key);
  18444. }
  18445. module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18446. },{"./toPrimitive.js":143,"./typeof.js":145}],145:[function(_dereq_,module,exports){
  18447. var _Symbol = _dereq_("@babel/runtime-corejs3/core-js/symbol");
  18448. var _Symbol$iterator = _dereq_("@babel/runtime-corejs3/core-js/symbol/iterator");
  18449. function _typeof(obj) {
  18450. "@babel/helpers - typeof";
  18451. return (module.exports = _typeof = "function" == typeof _Symbol && "symbol" == typeof _Symbol$iterator ? function (obj) {
  18452. return typeof obj;
  18453. } : function (obj) {
  18454. return obj && "function" == typeof _Symbol && obj.constructor === _Symbol && obj !== _Symbol.prototype ? "symbol" : typeof obj;
  18455. }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
  18456. }
  18457. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18458. },{"@babel/runtime-corejs3/core-js/symbol":115,"@babel/runtime-corejs3/core-js/symbol/iterator":116}],146:[function(_dereq_,module,exports){
  18459. var _sliceInstanceProperty = _dereq_("@babel/runtime-corejs3/core-js/instance/slice");
  18460. var _Array$from = _dereq_("@babel/runtime-corejs3/core-js/array/from");
  18461. var arrayLikeToArray = _dereq_("./arrayLikeToArray.js");
  18462. function _unsupportedIterableToArray(o, minLen) {
  18463. var _context;
  18464. if (!o) return;
  18465. if (typeof o === "string") return arrayLikeToArray(o, minLen);
  18466. var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1);
  18467. if (n === "Object" && o.constructor) n = o.constructor.name;
  18468. if (n === "Map" || n === "Set") return _Array$from(o);
  18469. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
  18470. }
  18471. module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18472. },{"./arrayLikeToArray.js":118,"@babel/runtime-corejs3/core-js/array/from":98,"@babel/runtime-corejs3/core-js/instance/slice":105}],147:[function(_dereq_,module,exports){
  18473. var _Map = _dereq_("@babel/runtime-corejs3/core-js/map");
  18474. var _Object$create = _dereq_("@babel/runtime-corejs3/core-js/object/create");
  18475. var getPrototypeOf = _dereq_("./getPrototypeOf.js");
  18476. var setPrototypeOf = _dereq_("./setPrototypeOf.js");
  18477. var isNativeFunction = _dereq_("./isNativeFunction.js");
  18478. var construct = _dereq_("./construct.js");
  18479. function _wrapNativeSuper(Class) {
  18480. var _cache = typeof _Map === "function" ? new _Map() : undefined;
  18481. module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) {
  18482. if (Class === null || !isNativeFunction(Class)) return Class;
  18483. if (typeof Class !== "function") {
  18484. throw new TypeError("Super expression must either be null or a function");
  18485. }
  18486. if (typeof _cache !== "undefined") {
  18487. if (_cache.has(Class)) return _cache.get(Class);
  18488. _cache.set(Class, Wrapper);
  18489. }
  18490. function Wrapper() {
  18491. return construct(Class, arguments, getPrototypeOf(this).constructor);
  18492. }
  18493. Wrapper.prototype = _Object$create(Class.prototype, {
  18494. constructor: {
  18495. value: Wrapper,
  18496. enumerable: false,
  18497. writable: true,
  18498. configurable: true
  18499. }
  18500. });
  18501. return setPrototypeOf(Wrapper, Class);
  18502. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18503. return _wrapNativeSuper(Class);
  18504. }
  18505. module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18506. },{"./construct.js":124,"./getPrototypeOf.js":128,"./isNativeFunction.js":131,"./setPrototypeOf.js":139,"@babel/runtime-corejs3/core-js/map":106,"@babel/runtime-corejs3/core-js/object/create":107}],148:[function(_dereq_,module,exports){
  18507. // TODO(Babel 8): Remove this file.
  18508. var runtime = _dereq_("../helpers/regeneratorRuntime")();
  18509. module.exports = runtime;
  18510. // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
  18511. try {
  18512. regeneratorRuntime = runtime;
  18513. } catch (accidentalStrictMode) {
  18514. if (typeof globalThis === "object") {
  18515. globalThis.regeneratorRuntime = runtime;
  18516. } else {
  18517. Function("r", "regeneratorRuntime = r")(runtime);
  18518. }
  18519. }
  18520. },{"../helpers/regeneratorRuntime":138}],149:[function(_dereq_,module,exports){
  18521. },{}],150:[function(_dereq_,module,exports){
  18522. var parent = _dereq_('../../stable/array/from');
  18523. module.exports = parent;
  18524. },{"../../stable/array/from":560}],151:[function(_dereq_,module,exports){
  18525. var parent = _dereq_('../../stable/array/is-array');
  18526. module.exports = parent;
  18527. },{"../../stable/array/is-array":561}],152:[function(_dereq_,module,exports){
  18528. var parent = _dereq_('../stable/get-iterator-method');
  18529. module.exports = parent;
  18530. },{"../stable/get-iterator-method":566}],153:[function(_dereq_,module,exports){
  18531. var parent = _dereq_('../../stable/instance/bind');
  18532. module.exports = parent;
  18533. },{"../../stable/instance/bind":567}],154:[function(_dereq_,module,exports){
  18534. var parent = _dereq_('../../stable/instance/for-each');
  18535. module.exports = parent;
  18536. },{"../../stable/instance/for-each":574}],155:[function(_dereq_,module,exports){
  18537. var parent = _dereq_('../../stable/instance/index-of');
  18538. module.exports = parent;
  18539. },{"../../stable/instance/index-of":576}],156:[function(_dereq_,module,exports){
  18540. var parent = _dereq_('../../stable/instance/reverse');
  18541. module.exports = parent;
  18542. },{"../../stable/instance/reverse":580}],157:[function(_dereq_,module,exports){
  18543. var parent = _dereq_('../../stable/instance/slice');
  18544. module.exports = parent;
  18545. },{"../../stable/instance/slice":581}],158:[function(_dereq_,module,exports){
  18546. var parent = _dereq_('../../stable/map');
  18547. module.exports = parent;
  18548. },{"../../stable/map":587}],159:[function(_dereq_,module,exports){
  18549. var parent = _dereq_('../../stable/object/create');
  18550. module.exports = parent;
  18551. },{"../../stable/object/create":590}],160:[function(_dereq_,module,exports){
  18552. var parent = _dereq_('../../stable/object/define-property');
  18553. module.exports = parent;
  18554. },{"../../stable/object/define-property":592}],161:[function(_dereq_,module,exports){
  18555. var parent = _dereq_('../../stable/object/get-own-property-descriptor');
  18556. module.exports = parent;
  18557. },{"../../stable/object/get-own-property-descriptor":595}],162:[function(_dereq_,module,exports){
  18558. var parent = _dereq_('../../stable/object/get-prototype-of');
  18559. module.exports = parent;
  18560. },{"../../stable/object/get-prototype-of":598}],163:[function(_dereq_,module,exports){
  18561. var parent = _dereq_('../../stable/object/set-prototype-of');
  18562. module.exports = parent;
  18563. },{"../../stable/object/set-prototype-of":600}],164:[function(_dereq_,module,exports){
  18564. var parent = _dereq_('../../stable/promise');
  18565. module.exports = parent;
  18566. },{"../../stable/promise":602}],165:[function(_dereq_,module,exports){
  18567. var parent = _dereq_('../../stable/reflect/construct');
  18568. module.exports = parent;
  18569. },{"../../stable/reflect/construct":603}],166:[function(_dereq_,module,exports){
  18570. var parent = _dereq_('../../stable/reflect/get');
  18571. module.exports = parent;
  18572. },{"../../stable/reflect/get":604}],167:[function(_dereq_,module,exports){
  18573. var parent = _dereq_('../../stable/symbol');
  18574. module.exports = parent;
  18575. },{"../../stable/symbol":608}],168:[function(_dereq_,module,exports){
  18576. var parent = _dereq_('../../stable/symbol/iterator');
  18577. module.exports = parent;
  18578. },{"../../stable/symbol/iterator":609}],169:[function(_dereq_,module,exports){
  18579. var parent = _dereq_('../../stable/symbol/to-primitive');
  18580. module.exports = parent;
  18581. },{"../../stable/symbol/to-primitive":610}],170:[function(_dereq_,module,exports){
  18582. _dereq_('../../modules/es.string.iterator');
  18583. _dereq_('../../modules/es.array.from');
  18584. var path = _dereq_('../../internals/path');
  18585. module.exports = path.Array.from;
  18586. },{"../../internals/path":404,"../../modules/es.array.from":453,"../../modules/es.string.iterator":502}],171:[function(_dereq_,module,exports){
  18587. _dereq_('../../modules/es.array.is-array');
  18588. var path = _dereq_('../../internals/path');
  18589. module.exports = path.Array.isArray;
  18590. },{"../../internals/path":404,"../../modules/es.array.is-array":456}],172:[function(_dereq_,module,exports){
  18591. _dereq_('../../../modules/es.array.concat');
  18592. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18593. module.exports = entryVirtual('Array').concat;
  18594. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.concat":447}],173:[function(_dereq_,module,exports){
  18595. _dereq_('../../../modules/es.array.iterator');
  18596. _dereq_('../../../modules/es.object.to-string');
  18597. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18598. module.exports = entryVirtual('Array').entries;
  18599. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.iterator":457,"../../../modules/es.object.to-string":484}],174:[function(_dereq_,module,exports){
  18600. _dereq_('../../../modules/es.array.every');
  18601. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18602. module.exports = entryVirtual('Array').every;
  18603. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.every":448}],175:[function(_dereq_,module,exports){
  18604. _dereq_('../../../modules/es.array.filter');
  18605. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18606. module.exports = entryVirtual('Array').filter;
  18607. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.filter":449}],176:[function(_dereq_,module,exports){
  18608. _dereq_('../../../modules/es.array.find-index');
  18609. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18610. module.exports = entryVirtual('Array').findIndex;
  18611. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.find-index":450}],177:[function(_dereq_,module,exports){
  18612. _dereq_('../../../modules/es.array.find');
  18613. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18614. module.exports = entryVirtual('Array').find;
  18615. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.find":451}],178:[function(_dereq_,module,exports){
  18616. _dereq_('../../../modules/es.array.for-each');
  18617. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18618. module.exports = entryVirtual('Array').forEach;
  18619. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.for-each":452}],179:[function(_dereq_,module,exports){
  18620. _dereq_('../../../modules/es.array.includes');
  18621. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18622. module.exports = entryVirtual('Array').includes;
  18623. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.includes":454}],180:[function(_dereq_,module,exports){
  18624. _dereq_('../../../modules/es.array.index-of');
  18625. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18626. module.exports = entryVirtual('Array').indexOf;
  18627. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.index-of":455}],181:[function(_dereq_,module,exports){
  18628. _dereq_('../../../modules/es.array.iterator');
  18629. _dereq_('../../../modules/es.object.to-string');
  18630. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18631. module.exports = entryVirtual('Array').keys;
  18632. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.iterator":457,"../../../modules/es.object.to-string":484}],182:[function(_dereq_,module,exports){
  18633. _dereq_('../../../modules/es.array.map');
  18634. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18635. module.exports = entryVirtual('Array').map;
  18636. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.map":458}],183:[function(_dereq_,module,exports){
  18637. _dereq_('../../../modules/es.array.reduce');
  18638. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18639. module.exports = entryVirtual('Array').reduce;
  18640. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.reduce":459}],184:[function(_dereq_,module,exports){
  18641. _dereq_('../../../modules/es.array.reverse');
  18642. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18643. module.exports = entryVirtual('Array').reverse;
  18644. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.reverse":460}],185:[function(_dereq_,module,exports){
  18645. _dereq_('../../../modules/es.array.slice');
  18646. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18647. module.exports = entryVirtual('Array').slice;
  18648. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.slice":461}],186:[function(_dereq_,module,exports){
  18649. _dereq_('../../../modules/es.array.sort');
  18650. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18651. module.exports = entryVirtual('Array').sort;
  18652. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.sort":462}],187:[function(_dereq_,module,exports){
  18653. _dereq_('../../../modules/es.array.splice');
  18654. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18655. module.exports = entryVirtual('Array').splice;
  18656. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.splice":463}],188:[function(_dereq_,module,exports){
  18657. _dereq_('../../../modules/es.array.iterator');
  18658. _dereq_('../../../modules/es.object.to-string');
  18659. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18660. module.exports = entryVirtual('Array').values;
  18661. },{"../../../internals/entry-virtual":328,"../../../modules/es.array.iterator":457,"../../../modules/es.object.to-string":484}],189:[function(_dereq_,module,exports){
  18662. _dereq_('../../../modules/es.function.bind');
  18663. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18664. module.exports = entryVirtual('Function').bind;
  18665. },{"../../../internals/entry-virtual":328,"../../../modules/es.function.bind":465}],190:[function(_dereq_,module,exports){
  18666. _dereq_('../modules/es.array.iterator');
  18667. _dereq_('../modules/es.string.iterator');
  18668. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  18669. module.exports = getIteratorMethod;
  18670. },{"../internals/get-iterator-method":343,"../modules/es.array.iterator":457,"../modules/es.string.iterator":502}],191:[function(_dereq_,module,exports){
  18671. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18672. var method = _dereq_('../function/virtual/bind');
  18673. var FunctionPrototype = Function.prototype;
  18674. module.exports = function (it) {
  18675. var own = it.bind;
  18676. return it === FunctionPrototype || (isPrototypeOf(FunctionPrototype, it) && own === FunctionPrototype.bind) ? method : own;
  18677. };
  18678. },{"../../internals/object-is-prototype-of":395,"../function/virtual/bind":189}],192:[function(_dereq_,module,exports){
  18679. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18680. var method = _dereq_('../array/virtual/concat');
  18681. var ArrayPrototype = Array.prototype;
  18682. module.exports = function (it) {
  18683. var own = it.concat;
  18684. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.concat) ? method : own;
  18685. };
  18686. },{"../../internals/object-is-prototype-of":395,"../array/virtual/concat":172}],193:[function(_dereq_,module,exports){
  18687. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18688. var method = _dereq_('../array/virtual/every');
  18689. var ArrayPrototype = Array.prototype;
  18690. module.exports = function (it) {
  18691. var own = it.every;
  18692. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.every) ? method : own;
  18693. };
  18694. },{"../../internals/object-is-prototype-of":395,"../array/virtual/every":174}],194:[function(_dereq_,module,exports){
  18695. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18696. var method = _dereq_('../array/virtual/filter');
  18697. var ArrayPrototype = Array.prototype;
  18698. module.exports = function (it) {
  18699. var own = it.filter;
  18700. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.filter) ? method : own;
  18701. };
  18702. },{"../../internals/object-is-prototype-of":395,"../array/virtual/filter":175}],195:[function(_dereq_,module,exports){
  18703. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18704. var method = _dereq_('../array/virtual/find-index');
  18705. var ArrayPrototype = Array.prototype;
  18706. module.exports = function (it) {
  18707. var own = it.findIndex;
  18708. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.findIndex) ? method : own;
  18709. };
  18710. },{"../../internals/object-is-prototype-of":395,"../array/virtual/find-index":176}],196:[function(_dereq_,module,exports){
  18711. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18712. var method = _dereq_('../array/virtual/find');
  18713. var ArrayPrototype = Array.prototype;
  18714. module.exports = function (it) {
  18715. var own = it.find;
  18716. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.find) ? method : own;
  18717. };
  18718. },{"../../internals/object-is-prototype-of":395,"../array/virtual/find":177}],197:[function(_dereq_,module,exports){
  18719. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18720. var arrayMethod = _dereq_('../array/virtual/includes');
  18721. var stringMethod = _dereq_('../string/virtual/includes');
  18722. var ArrayPrototype = Array.prototype;
  18723. var StringPrototype = String.prototype;
  18724. module.exports = function (it) {
  18725. var own = it.includes;
  18726. if (it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.includes)) return arrayMethod;
  18727. if (typeof it == 'string' || it === StringPrototype || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.includes)) {
  18728. return stringMethod;
  18729. } return own;
  18730. };
  18731. },{"../../internals/object-is-prototype-of":395,"../array/virtual/includes":179,"../string/virtual/includes":226}],198:[function(_dereq_,module,exports){
  18732. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18733. var method = _dereq_('../array/virtual/index-of');
  18734. var ArrayPrototype = Array.prototype;
  18735. module.exports = function (it) {
  18736. var own = it.indexOf;
  18737. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.indexOf) ? method : own;
  18738. };
  18739. },{"../../internals/object-is-prototype-of":395,"../array/virtual/index-of":180}],199:[function(_dereq_,module,exports){
  18740. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18741. var method = _dereq_('../array/virtual/map');
  18742. var ArrayPrototype = Array.prototype;
  18743. module.exports = function (it) {
  18744. var own = it.map;
  18745. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.map) ? method : own;
  18746. };
  18747. },{"../../internals/object-is-prototype-of":395,"../array/virtual/map":182}],200:[function(_dereq_,module,exports){
  18748. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18749. var method = _dereq_('../array/virtual/reduce');
  18750. var ArrayPrototype = Array.prototype;
  18751. module.exports = function (it) {
  18752. var own = it.reduce;
  18753. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reduce) ? method : own;
  18754. };
  18755. },{"../../internals/object-is-prototype-of":395,"../array/virtual/reduce":183}],201:[function(_dereq_,module,exports){
  18756. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18757. var method = _dereq_('../array/virtual/reverse');
  18758. var ArrayPrototype = Array.prototype;
  18759. module.exports = function (it) {
  18760. var own = it.reverse;
  18761. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.reverse) ? method : own;
  18762. };
  18763. },{"../../internals/object-is-prototype-of":395,"../array/virtual/reverse":184}],202:[function(_dereq_,module,exports){
  18764. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18765. var method = _dereq_('../array/virtual/slice');
  18766. var ArrayPrototype = Array.prototype;
  18767. module.exports = function (it) {
  18768. var own = it.slice;
  18769. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.slice) ? method : own;
  18770. };
  18771. },{"../../internals/object-is-prototype-of":395,"../array/virtual/slice":185}],203:[function(_dereq_,module,exports){
  18772. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18773. var method = _dereq_('../array/virtual/sort');
  18774. var ArrayPrototype = Array.prototype;
  18775. module.exports = function (it) {
  18776. var own = it.sort;
  18777. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.sort) ? method : own;
  18778. };
  18779. },{"../../internals/object-is-prototype-of":395,"../array/virtual/sort":186}],204:[function(_dereq_,module,exports){
  18780. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18781. var method = _dereq_('../array/virtual/splice');
  18782. var ArrayPrototype = Array.prototype;
  18783. module.exports = function (it) {
  18784. var own = it.splice;
  18785. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.splice) ? method : own;
  18786. };
  18787. },{"../../internals/object-is-prototype-of":395,"../array/virtual/splice":187}],205:[function(_dereq_,module,exports){
  18788. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  18789. var method = _dereq_('../string/virtual/starts-with');
  18790. var StringPrototype = String.prototype;
  18791. module.exports = function (it) {
  18792. var own = it.startsWith;
  18793. return typeof it == 'string' || it === StringPrototype
  18794. || (isPrototypeOf(StringPrototype, it) && own === StringPrototype.startsWith) ? method : own;
  18795. };
  18796. },{"../../internals/object-is-prototype-of":395,"../string/virtual/starts-with":227}],206:[function(_dereq_,module,exports){
  18797. _dereq_('../../modules/es.json.stringify');
  18798. var path = _dereq_('../../internals/path');
  18799. var apply = _dereq_('../../internals/function-apply');
  18800. // eslint-disable-next-line es-x/no-json -- safe
  18801. if (!path.JSON) path.JSON = { stringify: JSON.stringify };
  18802. // eslint-disable-next-line no-unused-vars -- required for `.length`
  18803. module.exports = function stringify(it, replacer, space) {
  18804. return apply(path.JSON.stringify, null, arguments);
  18805. };
  18806. },{"../../internals/function-apply":335,"../../internals/path":404,"../../modules/es.json.stringify":466}],207:[function(_dereq_,module,exports){
  18807. _dereq_('../../modules/es.array.iterator');
  18808. _dereq_('../../modules/es.map');
  18809. _dereq_('../../modules/es.object.to-string');
  18810. _dereq_('../../modules/es.string.iterator');
  18811. var path = _dereq_('../../internals/path');
  18812. module.exports = path.Map;
  18813. },{"../../internals/path":404,"../../modules/es.array.iterator":457,"../../modules/es.map":469,"../../modules/es.object.to-string":484,"../../modules/es.string.iterator":502}],208:[function(_dereq_,module,exports){
  18814. _dereq_('../../modules/es.number.is-integer');
  18815. var path = _dereq_('../../internals/path');
  18816. module.exports = path.Number.isInteger;
  18817. },{"../../internals/path":404,"../../modules/es.number.is-integer":471}],209:[function(_dereq_,module,exports){
  18818. _dereq_('../../modules/es.object.assign');
  18819. var path = _dereq_('../../internals/path');
  18820. module.exports = path.Object.assign;
  18821. },{"../../internals/path":404,"../../modules/es.object.assign":472}],210:[function(_dereq_,module,exports){
  18822. _dereq_('../../modules/es.object.create');
  18823. var path = _dereq_('../../internals/path');
  18824. var Object = path.Object;
  18825. module.exports = function create(P, D) {
  18826. return Object.create(P, D);
  18827. };
  18828. },{"../../internals/path":404,"../../modules/es.object.create":473}],211:[function(_dereq_,module,exports){
  18829. _dereq_('../../modules/es.object.define-properties');
  18830. var path = _dereq_('../../internals/path');
  18831. var Object = path.Object;
  18832. var defineProperties = module.exports = function defineProperties(T, D) {
  18833. return Object.defineProperties(T, D);
  18834. };
  18835. if (Object.defineProperties.sham) defineProperties.sham = true;
  18836. },{"../../internals/path":404,"../../modules/es.object.define-properties":474}],212:[function(_dereq_,module,exports){
  18837. _dereq_('../../modules/es.object.define-property');
  18838. var path = _dereq_('../../internals/path');
  18839. var Object = path.Object;
  18840. var defineProperty = module.exports = function defineProperty(it, key, desc) {
  18841. return Object.defineProperty(it, key, desc);
  18842. };
  18843. if (Object.defineProperty.sham) defineProperty.sham = true;
  18844. },{"../../internals/path":404,"../../modules/es.object.define-property":475}],213:[function(_dereq_,module,exports){
  18845. _dereq_('../../modules/es.object.entries');
  18846. var path = _dereq_('../../internals/path');
  18847. module.exports = path.Object.entries;
  18848. },{"../../internals/path":404,"../../modules/es.object.entries":476}],214:[function(_dereq_,module,exports){
  18849. _dereq_('../../modules/es.object.freeze');
  18850. var path = _dereq_('../../internals/path');
  18851. module.exports = path.Object.freeze;
  18852. },{"../../internals/path":404,"../../modules/es.object.freeze":477}],215:[function(_dereq_,module,exports){
  18853. _dereq_('../../modules/es.object.get-own-property-descriptor');
  18854. var path = _dereq_('../../internals/path');
  18855. var Object = path.Object;
  18856. var getOwnPropertyDescriptor = module.exports = function getOwnPropertyDescriptor(it, key) {
  18857. return Object.getOwnPropertyDescriptor(it, key);
  18858. };
  18859. if (Object.getOwnPropertyDescriptor.sham) getOwnPropertyDescriptor.sham = true;
  18860. },{"../../internals/path":404,"../../modules/es.object.get-own-property-descriptor":478}],216:[function(_dereq_,module,exports){
  18861. _dereq_('../../modules/es.object.get-own-property-descriptors');
  18862. var path = _dereq_('../../internals/path');
  18863. module.exports = path.Object.getOwnPropertyDescriptors;
  18864. },{"../../internals/path":404,"../../modules/es.object.get-own-property-descriptors":479}],217:[function(_dereq_,module,exports){
  18865. _dereq_('../../modules/es.symbol');
  18866. var path = _dereq_('../../internals/path');
  18867. module.exports = path.Object.getOwnPropertySymbols;
  18868. },{"../../internals/path":404,"../../modules/es.symbol":511}],218:[function(_dereq_,module,exports){
  18869. _dereq_('../../modules/es.object.get-prototype-of');
  18870. var path = _dereq_('../../internals/path');
  18871. module.exports = path.Object.getPrototypeOf;
  18872. },{"../../internals/path":404,"../../modules/es.object.get-prototype-of":481}],219:[function(_dereq_,module,exports){
  18873. _dereq_('../../modules/es.object.keys');
  18874. var path = _dereq_('../../internals/path');
  18875. module.exports = path.Object.keys;
  18876. },{"../../internals/path":404,"../../modules/es.object.keys":482}],220:[function(_dereq_,module,exports){
  18877. _dereq_('../../modules/es.object.set-prototype-of');
  18878. var path = _dereq_('../../internals/path');
  18879. module.exports = path.Object.setPrototypeOf;
  18880. },{"../../internals/path":404,"../../modules/es.object.set-prototype-of":483}],221:[function(_dereq_,module,exports){
  18881. _dereq_('../modules/es.parse-int');
  18882. var path = _dereq_('../internals/path');
  18883. module.exports = path.parseInt;
  18884. },{"../internals/path":404,"../modules/es.parse-int":485}],222:[function(_dereq_,module,exports){
  18885. _dereq_('../../modules/es.aggregate-error');
  18886. _dereq_('../../modules/es.array.iterator');
  18887. _dereq_('../../modules/es.object.to-string');
  18888. _dereq_('../../modules/es.promise');
  18889. _dereq_('../../modules/es.promise.all-settled');
  18890. _dereq_('../../modules/es.promise.any');
  18891. _dereq_('../../modules/es.promise.finally');
  18892. _dereq_('../../modules/es.string.iterator');
  18893. var path = _dereq_('../../internals/path');
  18894. module.exports = path.Promise;
  18895. },{"../../internals/path":404,"../../modules/es.aggregate-error":446,"../../modules/es.array.iterator":457,"../../modules/es.object.to-string":484,"../../modules/es.promise":492,"../../modules/es.promise.all-settled":486,"../../modules/es.promise.any":488,"../../modules/es.promise.finally":491,"../../modules/es.string.iterator":502}],223:[function(_dereq_,module,exports){
  18896. _dereq_('../../modules/es.reflect.construct');
  18897. var path = _dereq_('../../internals/path');
  18898. module.exports = path.Reflect.construct;
  18899. },{"../../internals/path":404,"../../modules/es.reflect.construct":496}],224:[function(_dereq_,module,exports){
  18900. _dereq_('../../modules/es.reflect.get');
  18901. var path = _dereq_('../../internals/path');
  18902. module.exports = path.Reflect.get;
  18903. },{"../../internals/path":404,"../../modules/es.reflect.get":497}],225:[function(_dereq_,module,exports){
  18904. _dereq_('../../modules/es.array.iterator');
  18905. _dereq_('../../modules/es.object.to-string');
  18906. _dereq_('../../modules/es.set');
  18907. _dereq_('../../modules/es.string.iterator');
  18908. var path = _dereq_('../../internals/path');
  18909. module.exports = path.Set;
  18910. },{"../../internals/path":404,"../../modules/es.array.iterator":457,"../../modules/es.object.to-string":484,"../../modules/es.set":500,"../../modules/es.string.iterator":502}],226:[function(_dereq_,module,exports){
  18911. _dereq_('../../../modules/es.string.includes');
  18912. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18913. module.exports = entryVirtual('String').includes;
  18914. },{"../../../internals/entry-virtual":328,"../../../modules/es.string.includes":501}],227:[function(_dereq_,module,exports){
  18915. _dereq_('../../../modules/es.string.starts-with');
  18916. var entryVirtual = _dereq_('../../../internals/entry-virtual');
  18917. module.exports = entryVirtual('String').startsWith;
  18918. },{"../../../internals/entry-virtual":328,"../../../modules/es.string.starts-with":503}],228:[function(_dereq_,module,exports){
  18919. _dereq_('../../modules/es.array.concat');
  18920. _dereq_('../../modules/es.object.to-string');
  18921. _dereq_('../../modules/es.symbol');
  18922. _dereq_('../../modules/es.symbol.async-iterator');
  18923. _dereq_('../../modules/es.symbol.description');
  18924. _dereq_('../../modules/es.symbol.has-instance');
  18925. _dereq_('../../modules/es.symbol.is-concat-spreadable');
  18926. _dereq_('../../modules/es.symbol.iterator');
  18927. _dereq_('../../modules/es.symbol.match');
  18928. _dereq_('../../modules/es.symbol.match-all');
  18929. _dereq_('../../modules/es.symbol.replace');
  18930. _dereq_('../../modules/es.symbol.search');
  18931. _dereq_('../../modules/es.symbol.species');
  18932. _dereq_('../../modules/es.symbol.split');
  18933. _dereq_('../../modules/es.symbol.to-primitive');
  18934. _dereq_('../../modules/es.symbol.to-string-tag');
  18935. _dereq_('../../modules/es.symbol.unscopables');
  18936. _dereq_('../../modules/es.json.to-string-tag');
  18937. _dereq_('../../modules/es.math.to-string-tag');
  18938. _dereq_('../../modules/es.reflect.to-string-tag');
  18939. var path = _dereq_('../../internals/path');
  18940. module.exports = path.Symbol;
  18941. },{"../../internals/path":404,"../../modules/es.array.concat":447,"../../modules/es.json.to-string-tag":467,"../../modules/es.math.to-string-tag":470,"../../modules/es.object.to-string":484,"../../modules/es.reflect.to-string-tag":498,"../../modules/es.symbol":511,"../../modules/es.symbol.async-iterator":504,"../../modules/es.symbol.description":506,"../../modules/es.symbol.has-instance":508,"../../modules/es.symbol.is-concat-spreadable":509,"../../modules/es.symbol.iterator":510,"../../modules/es.symbol.match":514,"../../modules/es.symbol.match-all":513,"../../modules/es.symbol.replace":515,"../../modules/es.symbol.search":516,"../../modules/es.symbol.species":517,"../../modules/es.symbol.split":518,"../../modules/es.symbol.to-primitive":519,"../../modules/es.symbol.to-string-tag":520,"../../modules/es.symbol.unscopables":521}],229:[function(_dereq_,module,exports){
  18942. _dereq_('../../modules/es.array.iterator');
  18943. _dereq_('../../modules/es.object.to-string');
  18944. _dereq_('../../modules/es.string.iterator');
  18945. _dereq_('../../modules/es.symbol.iterator');
  18946. var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
  18947. module.exports = WrappedWellKnownSymbolModule.f('iterator');
  18948. },{"../../internals/well-known-symbol-wrapped":442,"../../modules/es.array.iterator":457,"../../modules/es.object.to-string":484,"../../modules/es.string.iterator":502,"../../modules/es.symbol.iterator":510}],230:[function(_dereq_,module,exports){
  18949. _dereq_('../../modules/es.date.to-primitive');
  18950. _dereq_('../../modules/es.symbol.to-primitive');
  18951. var WrappedWellKnownSymbolModule = _dereq_('../../internals/well-known-symbol-wrapped');
  18952. module.exports = WrappedWellKnownSymbolModule.f('toPrimitive');
  18953. },{"../../internals/well-known-symbol-wrapped":442,"../../modules/es.date.to-primitive":464,"../../modules/es.symbol.to-primitive":519}],231:[function(_dereq_,module,exports){
  18954. _dereq_('../../modules/es.array.iterator');
  18955. _dereq_('../../modules/es.object.to-string');
  18956. _dereq_('../../modules/es.weak-map');
  18957. var path = _dereq_('../../internals/path');
  18958. module.exports = path.WeakMap;
  18959. },{"../../internals/path":404,"../../modules/es.array.iterator":457,"../../modules/es.object.to-string":484,"../../modules/es.weak-map":523}],232:[function(_dereq_,module,exports){
  18960. module.exports = _dereq_('../../full/array/from');
  18961. },{"../../full/array/from":252}],233:[function(_dereq_,module,exports){
  18962. module.exports = _dereq_('../../full/array/is-array');
  18963. },{"../../full/array/is-array":253}],234:[function(_dereq_,module,exports){
  18964. module.exports = _dereq_('../full/get-iterator-method');
  18965. },{"../full/get-iterator-method":254}],235:[function(_dereq_,module,exports){
  18966. module.exports = _dereq_('../../full/instance/bind');
  18967. },{"../../full/instance/bind":255}],236:[function(_dereq_,module,exports){
  18968. module.exports = _dereq_('../../full/instance/for-each');
  18969. },{"../../full/instance/for-each":256}],237:[function(_dereq_,module,exports){
  18970. module.exports = _dereq_('../../full/instance/index-of');
  18971. },{"../../full/instance/index-of":257}],238:[function(_dereq_,module,exports){
  18972. module.exports = _dereq_('../../full/instance/reverse');
  18973. },{"../../full/instance/reverse":258}],239:[function(_dereq_,module,exports){
  18974. module.exports = _dereq_('../../full/instance/slice');
  18975. },{"../../full/instance/slice":259}],240:[function(_dereq_,module,exports){
  18976. module.exports = _dereq_('../../full/map');
  18977. },{"../../full/map":260}],241:[function(_dereq_,module,exports){
  18978. module.exports = _dereq_('../../full/object/create');
  18979. },{"../../full/object/create":261}],242:[function(_dereq_,module,exports){
  18980. module.exports = _dereq_('../../full/object/define-property');
  18981. },{"../../full/object/define-property":262}],243:[function(_dereq_,module,exports){
  18982. module.exports = _dereq_('../../full/object/get-own-property-descriptor');
  18983. },{"../../full/object/get-own-property-descriptor":263}],244:[function(_dereq_,module,exports){
  18984. module.exports = _dereq_('../../full/object/get-prototype-of');
  18985. },{"../../full/object/get-prototype-of":264}],245:[function(_dereq_,module,exports){
  18986. module.exports = _dereq_('../../full/object/set-prototype-of');
  18987. },{"../../full/object/set-prototype-of":265}],246:[function(_dereq_,module,exports){
  18988. module.exports = _dereq_('../../full/promise');
  18989. },{"../../full/promise":266}],247:[function(_dereq_,module,exports){
  18990. module.exports = _dereq_('../../full/reflect/construct');
  18991. },{"../../full/reflect/construct":267}],248:[function(_dereq_,module,exports){
  18992. module.exports = _dereq_('../../full/reflect/get');
  18993. },{"../../full/reflect/get":268}],249:[function(_dereq_,module,exports){
  18994. module.exports = _dereq_('../../full/symbol');
  18995. },{"../../full/symbol":269}],250:[function(_dereq_,module,exports){
  18996. module.exports = _dereq_('../../full/symbol/iterator');
  18997. },{"../../full/symbol/iterator":270}],251:[function(_dereq_,module,exports){
  18998. module.exports = _dereq_('../../full/symbol/to-primitive');
  18999. },{"../../full/symbol/to-primitive":271}],252:[function(_dereq_,module,exports){
  19000. var parent = _dereq_('../../actual/array/from');
  19001. module.exports = parent;
  19002. },{"../../actual/array/from":150}],253:[function(_dereq_,module,exports){
  19003. var parent = _dereq_('../../actual/array/is-array');
  19004. module.exports = parent;
  19005. },{"../../actual/array/is-array":151}],254:[function(_dereq_,module,exports){
  19006. var parent = _dereq_('../actual/get-iterator-method');
  19007. module.exports = parent;
  19008. },{"../actual/get-iterator-method":152}],255:[function(_dereq_,module,exports){
  19009. var parent = _dereq_('../../actual/instance/bind');
  19010. module.exports = parent;
  19011. },{"../../actual/instance/bind":153}],256:[function(_dereq_,module,exports){
  19012. var parent = _dereq_('../../actual/instance/for-each');
  19013. module.exports = parent;
  19014. },{"../../actual/instance/for-each":154}],257:[function(_dereq_,module,exports){
  19015. var parent = _dereq_('../../actual/instance/index-of');
  19016. module.exports = parent;
  19017. },{"../../actual/instance/index-of":155}],258:[function(_dereq_,module,exports){
  19018. var parent = _dereq_('../../actual/instance/reverse');
  19019. module.exports = parent;
  19020. },{"../../actual/instance/reverse":156}],259:[function(_dereq_,module,exports){
  19021. var parent = _dereq_('../../actual/instance/slice');
  19022. module.exports = parent;
  19023. },{"../../actual/instance/slice":157}],260:[function(_dereq_,module,exports){
  19024. var parent = _dereq_('../../actual/map');
  19025. _dereq_('../../modules/esnext.map.from');
  19026. _dereq_('../../modules/esnext.map.of');
  19027. _dereq_('../../modules/esnext.map.delete-all');
  19028. _dereq_('../../modules/esnext.map.emplace');
  19029. _dereq_('../../modules/esnext.map.every');
  19030. _dereq_('../../modules/esnext.map.filter');
  19031. _dereq_('../../modules/esnext.map.find');
  19032. _dereq_('../../modules/esnext.map.find-key');
  19033. _dereq_('../../modules/esnext.map.group-by');
  19034. _dereq_('../../modules/esnext.map.includes');
  19035. _dereq_('../../modules/esnext.map.key-by');
  19036. _dereq_('../../modules/esnext.map.key-of');
  19037. _dereq_('../../modules/esnext.map.map-keys');
  19038. _dereq_('../../modules/esnext.map.map-values');
  19039. _dereq_('../../modules/esnext.map.merge');
  19040. _dereq_('../../modules/esnext.map.reduce');
  19041. _dereq_('../../modules/esnext.map.some');
  19042. _dereq_('../../modules/esnext.map.update');
  19043. // TODO: remove from `core-js@4`
  19044. _dereq_('../../modules/esnext.map.upsert');
  19045. // TODO: remove from `core-js@4`
  19046. _dereq_('../../modules/esnext.map.update-or-insert');
  19047. module.exports = parent;
  19048. },{"../../actual/map":158,"../../modules/esnext.map.delete-all":525,"../../modules/esnext.map.emplace":526,"../../modules/esnext.map.every":527,"../../modules/esnext.map.filter":528,"../../modules/esnext.map.find":530,"../../modules/esnext.map.find-key":529,"../../modules/esnext.map.from":531,"../../modules/esnext.map.group-by":532,"../../modules/esnext.map.includes":533,"../../modules/esnext.map.key-by":534,"../../modules/esnext.map.key-of":535,"../../modules/esnext.map.map-keys":536,"../../modules/esnext.map.map-values":537,"../../modules/esnext.map.merge":538,"../../modules/esnext.map.of":539,"../../modules/esnext.map.reduce":540,"../../modules/esnext.map.some":541,"../../modules/esnext.map.update":543,"../../modules/esnext.map.update-or-insert":542,"../../modules/esnext.map.upsert":544}],261:[function(_dereq_,module,exports){
  19049. var parent = _dereq_('../../actual/object/create');
  19050. module.exports = parent;
  19051. },{"../../actual/object/create":159}],262:[function(_dereq_,module,exports){
  19052. var parent = _dereq_('../../actual/object/define-property');
  19053. module.exports = parent;
  19054. },{"../../actual/object/define-property":160}],263:[function(_dereq_,module,exports){
  19055. var parent = _dereq_('../../actual/object/get-own-property-descriptor');
  19056. module.exports = parent;
  19057. },{"../../actual/object/get-own-property-descriptor":161}],264:[function(_dereq_,module,exports){
  19058. var parent = _dereq_('../../actual/object/get-prototype-of');
  19059. module.exports = parent;
  19060. },{"../../actual/object/get-prototype-of":162}],265:[function(_dereq_,module,exports){
  19061. var parent = _dereq_('../../actual/object/set-prototype-of');
  19062. module.exports = parent;
  19063. },{"../../actual/object/set-prototype-of":163}],266:[function(_dereq_,module,exports){
  19064. var parent = _dereq_('../../actual/promise');
  19065. _dereq_('../../modules/esnext.aggregate-error');
  19066. // TODO: Remove from `core-js@4`
  19067. _dereq_('../../modules/esnext.promise.all-settled');
  19068. _dereq_('../../modules/esnext.promise.try');
  19069. _dereq_('../../modules/esnext.promise.any');
  19070. module.exports = parent;
  19071. },{"../../actual/promise":164,"../../modules/esnext.aggregate-error":524,"../../modules/esnext.promise.all-settled":545,"../../modules/esnext.promise.any":546,"../../modules/esnext.promise.try":547}],267:[function(_dereq_,module,exports){
  19072. var parent = _dereq_('../../actual/reflect/construct');
  19073. module.exports = parent;
  19074. },{"../../actual/reflect/construct":165}],268:[function(_dereq_,module,exports){
  19075. var parent = _dereq_('../../actual/reflect/get');
  19076. module.exports = parent;
  19077. },{"../../actual/reflect/get":166}],269:[function(_dereq_,module,exports){
  19078. var parent = _dereq_('../../actual/symbol');
  19079. _dereq_('../../modules/esnext.symbol.async-dispose');
  19080. _dereq_('../../modules/esnext.symbol.dispose');
  19081. _dereq_('../../modules/esnext.symbol.matcher');
  19082. _dereq_('../../modules/esnext.symbol.metadata-key');
  19083. _dereq_('../../modules/esnext.symbol.observable');
  19084. // TODO: Remove from `core-js@4`
  19085. _dereq_('../../modules/esnext.symbol.metadata');
  19086. _dereq_('../../modules/esnext.symbol.pattern-match');
  19087. _dereq_('../../modules/esnext.symbol.replace-all');
  19088. module.exports = parent;
  19089. },{"../../actual/symbol":167,"../../modules/esnext.symbol.async-dispose":548,"../../modules/esnext.symbol.dispose":549,"../../modules/esnext.symbol.matcher":550,"../../modules/esnext.symbol.metadata":552,"../../modules/esnext.symbol.metadata-key":551,"../../modules/esnext.symbol.observable":553,"../../modules/esnext.symbol.pattern-match":554,"../../modules/esnext.symbol.replace-all":555}],270:[function(_dereq_,module,exports){
  19090. var parent = _dereq_('../../actual/symbol/iterator');
  19091. module.exports = parent;
  19092. },{"../../actual/symbol/iterator":168}],271:[function(_dereq_,module,exports){
  19093. var parent = _dereq_('../../actual/symbol/to-primitive');
  19094. module.exports = parent;
  19095. },{"../../actual/symbol/to-primitive":169}],272:[function(_dereq_,module,exports){
  19096. var isCallable = _dereq_('../internals/is-callable');
  19097. var tryToString = _dereq_('../internals/try-to-string');
  19098. var $TypeError = TypeError;
  19099. // `Assert: IsCallable(argument) is true`
  19100. module.exports = function (argument) {
  19101. if (isCallable(argument)) return argument;
  19102. throw $TypeError(tryToString(argument) + ' is not a function');
  19103. };
  19104. },{"../internals/is-callable":360,"../internals/try-to-string":435}],273:[function(_dereq_,module,exports){
  19105. var isConstructor = _dereq_('../internals/is-constructor');
  19106. var tryToString = _dereq_('../internals/try-to-string');
  19107. var $TypeError = TypeError;
  19108. // `Assert: IsConstructor(argument) is true`
  19109. module.exports = function (argument) {
  19110. if (isConstructor(argument)) return argument;
  19111. throw $TypeError(tryToString(argument) + ' is not a constructor');
  19112. };
  19113. },{"../internals/is-constructor":361,"../internals/try-to-string":435}],274:[function(_dereq_,module,exports){
  19114. var isCallable = _dereq_('../internals/is-callable');
  19115. var $String = String;
  19116. var $TypeError = TypeError;
  19117. module.exports = function (argument) {
  19118. if (typeof argument == 'object' || isCallable(argument)) return argument;
  19119. throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
  19120. };
  19121. },{"../internals/is-callable":360}],275:[function(_dereq_,module,exports){
  19122. module.exports = function () { /* empty */ };
  19123. },{}],276:[function(_dereq_,module,exports){
  19124. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  19125. var $TypeError = TypeError;
  19126. module.exports = function (it, Prototype) {
  19127. if (isPrototypeOf(Prototype, it)) return it;
  19128. throw $TypeError('Incorrect invocation');
  19129. };
  19130. },{"../internals/object-is-prototype-of":395}],277:[function(_dereq_,module,exports){
  19131. var isObject = _dereq_('../internals/is-object');
  19132. var $String = String;
  19133. var $TypeError = TypeError;
  19134. // `Assert: Type(argument) is Object`
  19135. module.exports = function (argument) {
  19136. if (isObject(argument)) return argument;
  19137. throw $TypeError($String(argument) + ' is not an object');
  19138. };
  19139. },{"../internals/is-object":366}],278:[function(_dereq_,module,exports){
  19140. // FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it
  19141. var fails = _dereq_('../internals/fails');
  19142. module.exports = fails(function () {
  19143. if (typeof ArrayBuffer == 'function') {
  19144. var buffer = new ArrayBuffer(8);
  19145. // eslint-disable-next-line es-x/no-object-isextensible, es-x/no-object-defineproperty -- safe
  19146. if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', { value: 8 });
  19147. }
  19148. });
  19149. },{"../internals/fails":333}],279:[function(_dereq_,module,exports){
  19150. 'use strict';
  19151. var $forEach = _dereq_('../internals/array-iteration').forEach;
  19152. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  19153. var STRICT_METHOD = arrayMethodIsStrict('forEach');
  19154. // `Array.prototype.forEach` method implementation
  19155. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  19156. module.exports = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {
  19157. return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19158. // eslint-disable-next-line es-x/no-array-prototype-foreach -- safe
  19159. } : [].forEach;
  19160. },{"../internals/array-iteration":282,"../internals/array-method-is-strict":284}],280:[function(_dereq_,module,exports){
  19161. 'use strict';
  19162. var bind = _dereq_('../internals/function-bind-context');
  19163. var call = _dereq_('../internals/function-call');
  19164. var toObject = _dereq_('../internals/to-object');
  19165. var callWithSafeIterationClosing = _dereq_('../internals/call-with-safe-iteration-closing');
  19166. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  19167. var isConstructor = _dereq_('../internals/is-constructor');
  19168. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19169. var createProperty = _dereq_('../internals/create-property');
  19170. var getIterator = _dereq_('../internals/get-iterator');
  19171. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  19172. var $Array = Array;
  19173. // `Array.from` method implementation
  19174. // https://tc39.es/ecma262/#sec-array.from
  19175. module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  19176. var O = toObject(arrayLike);
  19177. var IS_CONSTRUCTOR = isConstructor(this);
  19178. var argumentsLength = arguments.length;
  19179. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  19180. var mapping = mapfn !== undefined;
  19181. if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
  19182. var iteratorMethod = getIteratorMethod(O);
  19183. var index = 0;
  19184. var length, result, step, iterator, next, value;
  19185. // if the target is not iterable or it's an array with the default iterator - use a simple case
  19186. if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) {
  19187. iterator = getIterator(O, iteratorMethod);
  19188. next = iterator.next;
  19189. result = IS_CONSTRUCTOR ? new this() : [];
  19190. for (;!(step = call(next, iterator)).done; index++) {
  19191. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
  19192. createProperty(result, index, value);
  19193. }
  19194. } else {
  19195. length = lengthOfArrayLike(O);
  19196. result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
  19197. for (;length > index; index++) {
  19198. value = mapping ? mapfn(O[index], index) : O[index];
  19199. createProperty(result, index, value);
  19200. }
  19201. }
  19202. result.length = index;
  19203. return result;
  19204. };
  19205. },{"../internals/call-with-safe-iteration-closing":292,"../internals/create-property":308,"../internals/function-bind-context":336,"../internals/function-call":339,"../internals/get-iterator":344,"../internals/get-iterator-method":343,"../internals/is-array-iterator-method":358,"../internals/is-constructor":361,"../internals/length-of-array-like":376,"../internals/to-object":430}],281:[function(_dereq_,module,exports){
  19206. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  19207. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  19208. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19209. // `Array.prototype.{ indexOf, includes }` methods implementation
  19210. var createMethod = function (IS_INCLUDES) {
  19211. return function ($this, el, fromIndex) {
  19212. var O = toIndexedObject($this);
  19213. var length = lengthOfArrayLike(O);
  19214. var index = toAbsoluteIndex(fromIndex, length);
  19215. var value;
  19216. // Array#includes uses SameValueZero equality algorithm
  19217. // eslint-disable-next-line no-self-compare -- NaN check
  19218. if (IS_INCLUDES && el != el) while (length > index) {
  19219. value = O[index++];
  19220. // eslint-disable-next-line no-self-compare -- NaN check
  19221. if (value != value) return true;
  19222. // Array#indexOf ignores holes, Array#includes - not
  19223. } else for (;length > index; index++) {
  19224. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  19225. } return !IS_INCLUDES && -1;
  19226. };
  19227. };
  19228. module.exports = {
  19229. // `Array.prototype.includes` method
  19230. // https://tc39.es/ecma262/#sec-array.prototype.includes
  19231. includes: createMethod(true),
  19232. // `Array.prototype.indexOf` method
  19233. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  19234. indexOf: createMethod(false)
  19235. };
  19236. },{"../internals/length-of-array-like":376,"../internals/to-absolute-index":426,"../internals/to-indexed-object":427}],282:[function(_dereq_,module,exports){
  19237. var bind = _dereq_('../internals/function-bind-context');
  19238. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19239. var IndexedObject = _dereq_('../internals/indexed-object');
  19240. var toObject = _dereq_('../internals/to-object');
  19241. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19242. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  19243. var push = uncurryThis([].push);
  19244. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
  19245. var createMethod = function (TYPE) {
  19246. var IS_MAP = TYPE == 1;
  19247. var IS_FILTER = TYPE == 2;
  19248. var IS_SOME = TYPE == 3;
  19249. var IS_EVERY = TYPE == 4;
  19250. var IS_FIND_INDEX = TYPE == 6;
  19251. var IS_FILTER_REJECT = TYPE == 7;
  19252. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  19253. return function ($this, callbackfn, that, specificCreate) {
  19254. var O = toObject($this);
  19255. var self = IndexedObject(O);
  19256. var boundFunction = bind(callbackfn, that);
  19257. var length = lengthOfArrayLike(self);
  19258. var index = 0;
  19259. var create = specificCreate || arraySpeciesCreate;
  19260. var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
  19261. var value, result;
  19262. for (;length > index; index++) if (NO_HOLES || index in self) {
  19263. value = self[index];
  19264. result = boundFunction(value, index, O);
  19265. if (TYPE) {
  19266. if (IS_MAP) target[index] = result; // map
  19267. else if (result) switch (TYPE) {
  19268. case 3: return true; // some
  19269. case 5: return value; // find
  19270. case 6: return index; // findIndex
  19271. case 2: push(target, value); // filter
  19272. } else switch (TYPE) {
  19273. case 4: return false; // every
  19274. case 7: push(target, value); // filterReject
  19275. }
  19276. }
  19277. }
  19278. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  19279. };
  19280. };
  19281. module.exports = {
  19282. // `Array.prototype.forEach` method
  19283. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  19284. forEach: createMethod(0),
  19285. // `Array.prototype.map` method
  19286. // https://tc39.es/ecma262/#sec-array.prototype.map
  19287. map: createMethod(1),
  19288. // `Array.prototype.filter` method
  19289. // https://tc39.es/ecma262/#sec-array.prototype.filter
  19290. filter: createMethod(2),
  19291. // `Array.prototype.some` method
  19292. // https://tc39.es/ecma262/#sec-array.prototype.some
  19293. some: createMethod(3),
  19294. // `Array.prototype.every` method
  19295. // https://tc39.es/ecma262/#sec-array.prototype.every
  19296. every: createMethod(4),
  19297. // `Array.prototype.find` method
  19298. // https://tc39.es/ecma262/#sec-array.prototype.find
  19299. find: createMethod(5),
  19300. // `Array.prototype.findIndex` method
  19301. // https://tc39.es/ecma262/#sec-array.prototype.findIndex
  19302. findIndex: createMethod(6),
  19303. // `Array.prototype.filterReject` method
  19304. // https://github.com/tc39/proposal-array-filtering
  19305. filterReject: createMethod(7)
  19306. };
  19307. },{"../internals/array-species-create":291,"../internals/function-bind-context":336,"../internals/function-uncurry-this":341,"../internals/indexed-object":353,"../internals/length-of-array-like":376,"../internals/to-object":430}],283:[function(_dereq_,module,exports){
  19308. var fails = _dereq_('../internals/fails');
  19309. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19310. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  19311. var SPECIES = wellKnownSymbol('species');
  19312. module.exports = function (METHOD_NAME) {
  19313. // We can't use this feature detection in V8 since it causes
  19314. // deoptimization and serious performance degradation
  19315. // https://github.com/zloirock/core-js/issues/677
  19316. return V8_VERSION >= 51 || !fails(function () {
  19317. var array = [];
  19318. var constructor = array.constructor = {};
  19319. constructor[SPECIES] = function () {
  19320. return { foo: 1 };
  19321. };
  19322. return array[METHOD_NAME](Boolean).foo !== 1;
  19323. });
  19324. };
  19325. },{"../internals/engine-v8-version":326,"../internals/fails":333,"../internals/well-known-symbol":443}],284:[function(_dereq_,module,exports){
  19326. 'use strict';
  19327. var fails = _dereq_('../internals/fails');
  19328. module.exports = function (METHOD_NAME, argument) {
  19329. var method = [][METHOD_NAME];
  19330. return !!method && fails(function () {
  19331. // eslint-disable-next-line no-useless-call -- required for testing
  19332. method.call(null, argument || function () { return 1; }, 1);
  19333. });
  19334. };
  19335. },{"../internals/fails":333}],285:[function(_dereq_,module,exports){
  19336. var aCallable = _dereq_('../internals/a-callable');
  19337. var toObject = _dereq_('../internals/to-object');
  19338. var IndexedObject = _dereq_('../internals/indexed-object');
  19339. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19340. var $TypeError = TypeError;
  19341. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  19342. var createMethod = function (IS_RIGHT) {
  19343. return function (that, callbackfn, argumentsLength, memo) {
  19344. aCallable(callbackfn);
  19345. var O = toObject(that);
  19346. var self = IndexedObject(O);
  19347. var length = lengthOfArrayLike(O);
  19348. var index = IS_RIGHT ? length - 1 : 0;
  19349. var i = IS_RIGHT ? -1 : 1;
  19350. if (argumentsLength < 2) while (true) {
  19351. if (index in self) {
  19352. memo = self[index];
  19353. index += i;
  19354. break;
  19355. }
  19356. index += i;
  19357. if (IS_RIGHT ? index < 0 : length <= index) {
  19358. throw $TypeError('Reduce of empty array with no initial value');
  19359. }
  19360. }
  19361. for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
  19362. memo = callbackfn(memo, self[index], index, O);
  19363. }
  19364. return memo;
  19365. };
  19366. };
  19367. module.exports = {
  19368. // `Array.prototype.reduce` method
  19369. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  19370. left: createMethod(false),
  19371. // `Array.prototype.reduceRight` method
  19372. // https://tc39.es/ecma262/#sec-array.prototype.reduceright
  19373. right: createMethod(true)
  19374. };
  19375. },{"../internals/a-callable":272,"../internals/indexed-object":353,"../internals/length-of-array-like":376,"../internals/to-object":430}],286:[function(_dereq_,module,exports){
  19376. 'use strict';
  19377. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19378. var isArray = _dereq_('../internals/is-array');
  19379. var $TypeError = TypeError;
  19380. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  19381. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  19382. // Safari < 13 does not throw an error in this case
  19383. var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () {
  19384. // makes no sense without proper strict mode support
  19385. if (this !== undefined) return true;
  19386. try {
  19387. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  19388. Object.defineProperty([], 'length', { writable: false }).length = 1;
  19389. } catch (error) {
  19390. return error instanceof TypeError;
  19391. }
  19392. }();
  19393. module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
  19394. if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
  19395. throw $TypeError('Cannot set read only .length');
  19396. } return O.length = length;
  19397. } : function (O, length) {
  19398. return O.length = length;
  19399. };
  19400. },{"../internals/descriptors":313,"../internals/is-array":359}],287:[function(_dereq_,module,exports){
  19401. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  19402. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  19403. var createProperty = _dereq_('../internals/create-property');
  19404. var $Array = Array;
  19405. var max = Math.max;
  19406. module.exports = function (O, start, end) {
  19407. var length = lengthOfArrayLike(O);
  19408. var k = toAbsoluteIndex(start, length);
  19409. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  19410. var result = $Array(max(fin - k, 0));
  19411. for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
  19412. result.length = n;
  19413. return result;
  19414. };
  19415. },{"../internals/create-property":308,"../internals/length-of-array-like":376,"../internals/to-absolute-index":426}],288:[function(_dereq_,module,exports){
  19416. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19417. module.exports = uncurryThis([].slice);
  19418. },{"../internals/function-uncurry-this":341}],289:[function(_dereq_,module,exports){
  19419. var arraySlice = _dereq_('../internals/array-slice-simple');
  19420. var floor = Math.floor;
  19421. var mergeSort = function (array, comparefn) {
  19422. var length = array.length;
  19423. var middle = floor(length / 2);
  19424. return length < 8 ? insertionSort(array, comparefn) : merge(
  19425. array,
  19426. mergeSort(arraySlice(array, 0, middle), comparefn),
  19427. mergeSort(arraySlice(array, middle), comparefn),
  19428. comparefn
  19429. );
  19430. };
  19431. var insertionSort = function (array, comparefn) {
  19432. var length = array.length;
  19433. var i = 1;
  19434. var element, j;
  19435. while (i < length) {
  19436. j = i;
  19437. element = array[i];
  19438. while (j && comparefn(array[j - 1], element) > 0) {
  19439. array[j] = array[--j];
  19440. }
  19441. if (j !== i++) array[j] = element;
  19442. } return array;
  19443. };
  19444. var merge = function (array, left, right, comparefn) {
  19445. var llength = left.length;
  19446. var rlength = right.length;
  19447. var lindex = 0;
  19448. var rindex = 0;
  19449. while (lindex < llength || rindex < rlength) {
  19450. array[lindex + rindex] = (lindex < llength && rindex < rlength)
  19451. ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
  19452. : lindex < llength ? left[lindex++] : right[rindex++];
  19453. } return array;
  19454. };
  19455. module.exports = mergeSort;
  19456. },{"../internals/array-slice-simple":287}],290:[function(_dereq_,module,exports){
  19457. var isArray = _dereq_('../internals/is-array');
  19458. var isConstructor = _dereq_('../internals/is-constructor');
  19459. var isObject = _dereq_('../internals/is-object');
  19460. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19461. var SPECIES = wellKnownSymbol('species');
  19462. var $Array = Array;
  19463. // a part of `ArraySpeciesCreate` abstract operation
  19464. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  19465. module.exports = function (originalArray) {
  19466. var C;
  19467. if (isArray(originalArray)) {
  19468. C = originalArray.constructor;
  19469. // cross-realm fallback
  19470. if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined;
  19471. else if (isObject(C)) {
  19472. C = C[SPECIES];
  19473. if (C === null) C = undefined;
  19474. }
  19475. } return C === undefined ? $Array : C;
  19476. };
  19477. },{"../internals/is-array":359,"../internals/is-constructor":361,"../internals/is-object":366,"../internals/well-known-symbol":443}],291:[function(_dereq_,module,exports){
  19478. var arraySpeciesConstructor = _dereq_('../internals/array-species-constructor');
  19479. // `ArraySpeciesCreate` abstract operation
  19480. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  19481. module.exports = function (originalArray, length) {
  19482. return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
  19483. };
  19484. },{"../internals/array-species-constructor":290}],292:[function(_dereq_,module,exports){
  19485. var anObject = _dereq_('../internals/an-object');
  19486. var iteratorClose = _dereq_('../internals/iterator-close');
  19487. // call something on iterator step with safe closing on error
  19488. module.exports = function (iterator, fn, value, ENTRIES) {
  19489. try {
  19490. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  19491. } catch (error) {
  19492. iteratorClose(iterator, 'throw', error);
  19493. }
  19494. };
  19495. },{"../internals/an-object":277,"../internals/iterator-close":371}],293:[function(_dereq_,module,exports){
  19496. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19497. var ITERATOR = wellKnownSymbol('iterator');
  19498. var SAFE_CLOSING = false;
  19499. try {
  19500. var called = 0;
  19501. var iteratorWithReturn = {
  19502. next: function () {
  19503. return { done: !!called++ };
  19504. },
  19505. 'return': function () {
  19506. SAFE_CLOSING = true;
  19507. }
  19508. };
  19509. iteratorWithReturn[ITERATOR] = function () {
  19510. return this;
  19511. };
  19512. // eslint-disable-next-line es-x/no-array-from, no-throw-literal -- required for testing
  19513. Array.from(iteratorWithReturn, function () { throw 2; });
  19514. } catch (error) { /* empty */ }
  19515. module.exports = function (exec, SKIP_CLOSING) {
  19516. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  19517. var ITERATION_SUPPORT = false;
  19518. try {
  19519. var object = {};
  19520. object[ITERATOR] = function () {
  19521. return {
  19522. next: function () {
  19523. return { done: ITERATION_SUPPORT = true };
  19524. }
  19525. };
  19526. };
  19527. exec(object);
  19528. } catch (error) { /* empty */ }
  19529. return ITERATION_SUPPORT;
  19530. };
  19531. },{"../internals/well-known-symbol":443}],294:[function(_dereq_,module,exports){
  19532. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19533. var toString = uncurryThis({}.toString);
  19534. var stringSlice = uncurryThis(''.slice);
  19535. module.exports = function (it) {
  19536. return stringSlice(toString(it), 8, -1);
  19537. };
  19538. },{"../internals/function-uncurry-this":341}],295:[function(_dereq_,module,exports){
  19539. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  19540. var isCallable = _dereq_('../internals/is-callable');
  19541. var classofRaw = _dereq_('../internals/classof-raw');
  19542. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  19543. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  19544. var $Object = Object;
  19545. // ES3 wrong here
  19546. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  19547. // fallback for IE11 Script Access Denied error
  19548. var tryGet = function (it, key) {
  19549. try {
  19550. return it[key];
  19551. } catch (error) { /* empty */ }
  19552. };
  19553. // getting tag from ES6+ `Object.prototype.toString`
  19554. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  19555. var O, tag, result;
  19556. return it === undefined ? 'Undefined' : it === null ? 'Null'
  19557. // @@toStringTag case
  19558. : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
  19559. // builtinTag case
  19560. : CORRECT_ARGUMENTS ? classofRaw(O)
  19561. // ES3 arguments fallback
  19562. : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  19563. };
  19564. },{"../internals/classof-raw":294,"../internals/is-callable":360,"../internals/to-string-tag-support":433,"../internals/well-known-symbol":443}],296:[function(_dereq_,module,exports){
  19565. 'use strict';
  19566. var call = _dereq_('../internals/function-call');
  19567. var aCallable = _dereq_('../internals/a-callable');
  19568. var anObject = _dereq_('../internals/an-object');
  19569. // https://github.com/tc39/collection-methods
  19570. module.exports = function deleteAll(/* ...elements */) {
  19571. var collection = anObject(this);
  19572. var remover = aCallable(collection['delete']);
  19573. var allDeleted = true;
  19574. var wasDeleted;
  19575. for (var k = 0, len = arguments.length; k < len; k++) {
  19576. wasDeleted = call(remover, collection, arguments[k]);
  19577. allDeleted = allDeleted && wasDeleted;
  19578. }
  19579. return !!allDeleted;
  19580. };
  19581. },{"../internals/a-callable":272,"../internals/an-object":277,"../internals/function-call":339}],297:[function(_dereq_,module,exports){
  19582. 'use strict';
  19583. // https://tc39.github.io/proposal-setmap-offrom/
  19584. var bind = _dereq_('../internals/function-bind-context');
  19585. var call = _dereq_('../internals/function-call');
  19586. var aCallable = _dereq_('../internals/a-callable');
  19587. var aConstructor = _dereq_('../internals/a-constructor');
  19588. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  19589. var iterate = _dereq_('../internals/iterate');
  19590. var push = [].push;
  19591. module.exports = function from(source /* , mapFn, thisArg */) {
  19592. var length = arguments.length;
  19593. var mapFn = length > 1 ? arguments[1] : undefined;
  19594. var mapping, array, n, boundFunction;
  19595. aConstructor(this);
  19596. mapping = mapFn !== undefined;
  19597. if (mapping) aCallable(mapFn);
  19598. if (isNullOrUndefined(source)) return new this();
  19599. array = [];
  19600. if (mapping) {
  19601. n = 0;
  19602. boundFunction = bind(mapFn, length > 2 ? arguments[2] : undefined);
  19603. iterate(source, function (nextItem) {
  19604. call(push, array, boundFunction(nextItem, n++));
  19605. });
  19606. } else {
  19607. iterate(source, push, { that: array });
  19608. }
  19609. return new this(array);
  19610. };
  19611. },{"../internals/a-callable":272,"../internals/a-constructor":273,"../internals/function-bind-context":336,"../internals/function-call":339,"../internals/is-null-or-undefined":365,"../internals/iterate":370}],298:[function(_dereq_,module,exports){
  19612. 'use strict';
  19613. var arraySlice = _dereq_('../internals/array-slice');
  19614. // https://tc39.github.io/proposal-setmap-offrom/
  19615. module.exports = function of() {
  19616. return new this(arraySlice(arguments));
  19617. };
  19618. },{"../internals/array-slice":288}],299:[function(_dereq_,module,exports){
  19619. 'use strict';
  19620. var defineProperty = _dereq_('../internals/object-define-property').f;
  19621. var create = _dereq_('../internals/object-create');
  19622. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  19623. var bind = _dereq_('../internals/function-bind-context');
  19624. var anInstance = _dereq_('../internals/an-instance');
  19625. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  19626. var iterate = _dereq_('../internals/iterate');
  19627. var defineIterator = _dereq_('../internals/iterator-define');
  19628. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  19629. var setSpecies = _dereq_('../internals/set-species');
  19630. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19631. var fastKey = _dereq_('../internals/internal-metadata').fastKey;
  19632. var InternalStateModule = _dereq_('../internals/internal-state');
  19633. var setInternalState = InternalStateModule.set;
  19634. var internalStateGetterFor = InternalStateModule.getterFor;
  19635. module.exports = {
  19636. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  19637. var Constructor = wrapper(function (that, iterable) {
  19638. anInstance(that, Prototype);
  19639. setInternalState(that, {
  19640. type: CONSTRUCTOR_NAME,
  19641. index: create(null),
  19642. first: undefined,
  19643. last: undefined,
  19644. size: 0
  19645. });
  19646. if (!DESCRIPTORS) that.size = 0;
  19647. if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  19648. });
  19649. var Prototype = Constructor.prototype;
  19650. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  19651. var define = function (that, key, value) {
  19652. var state = getInternalState(that);
  19653. var entry = getEntry(that, key);
  19654. var previous, index;
  19655. // change existing entry
  19656. if (entry) {
  19657. entry.value = value;
  19658. // create new entry
  19659. } else {
  19660. state.last = entry = {
  19661. index: index = fastKey(key, true),
  19662. key: key,
  19663. value: value,
  19664. previous: previous = state.last,
  19665. next: undefined,
  19666. removed: false
  19667. };
  19668. if (!state.first) state.first = entry;
  19669. if (previous) previous.next = entry;
  19670. if (DESCRIPTORS) state.size++;
  19671. else that.size++;
  19672. // add to index
  19673. if (index !== 'F') state.index[index] = entry;
  19674. } return that;
  19675. };
  19676. var getEntry = function (that, key) {
  19677. var state = getInternalState(that);
  19678. // fast case
  19679. var index = fastKey(key);
  19680. var entry;
  19681. if (index !== 'F') return state.index[index];
  19682. // frozen object case
  19683. for (entry = state.first; entry; entry = entry.next) {
  19684. if (entry.key == key) return entry;
  19685. }
  19686. };
  19687. defineBuiltIns(Prototype, {
  19688. // `{ Map, Set }.prototype.clear()` methods
  19689. // https://tc39.es/ecma262/#sec-map.prototype.clear
  19690. // https://tc39.es/ecma262/#sec-set.prototype.clear
  19691. clear: function clear() {
  19692. var that = this;
  19693. var state = getInternalState(that);
  19694. var data = state.index;
  19695. var entry = state.first;
  19696. while (entry) {
  19697. entry.removed = true;
  19698. if (entry.previous) entry.previous = entry.previous.next = undefined;
  19699. delete data[entry.index];
  19700. entry = entry.next;
  19701. }
  19702. state.first = state.last = undefined;
  19703. if (DESCRIPTORS) state.size = 0;
  19704. else that.size = 0;
  19705. },
  19706. // `{ Map, Set }.prototype.delete(key)` methods
  19707. // https://tc39.es/ecma262/#sec-map.prototype.delete
  19708. // https://tc39.es/ecma262/#sec-set.prototype.delete
  19709. 'delete': function (key) {
  19710. var that = this;
  19711. var state = getInternalState(that);
  19712. var entry = getEntry(that, key);
  19713. if (entry) {
  19714. var next = entry.next;
  19715. var prev = entry.previous;
  19716. delete state.index[entry.index];
  19717. entry.removed = true;
  19718. if (prev) prev.next = next;
  19719. if (next) next.previous = prev;
  19720. if (state.first == entry) state.first = next;
  19721. if (state.last == entry) state.last = prev;
  19722. if (DESCRIPTORS) state.size--;
  19723. else that.size--;
  19724. } return !!entry;
  19725. },
  19726. // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods
  19727. // https://tc39.es/ecma262/#sec-map.prototype.foreach
  19728. // https://tc39.es/ecma262/#sec-set.prototype.foreach
  19729. forEach: function forEach(callbackfn /* , that = undefined */) {
  19730. var state = getInternalState(this);
  19731. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19732. var entry;
  19733. while (entry = entry ? entry.next : state.first) {
  19734. boundFunction(entry.value, entry.key, this);
  19735. // revert to the last existing entry
  19736. while (entry && entry.removed) entry = entry.previous;
  19737. }
  19738. },
  19739. // `{ Map, Set}.prototype.has(key)` methods
  19740. // https://tc39.es/ecma262/#sec-map.prototype.has
  19741. // https://tc39.es/ecma262/#sec-set.prototype.has
  19742. has: function has(key) {
  19743. return !!getEntry(this, key);
  19744. }
  19745. });
  19746. defineBuiltIns(Prototype, IS_MAP ? {
  19747. // `Map.prototype.get(key)` method
  19748. // https://tc39.es/ecma262/#sec-map.prototype.get
  19749. get: function get(key) {
  19750. var entry = getEntry(this, key);
  19751. return entry && entry.value;
  19752. },
  19753. // `Map.prototype.set(key, value)` method
  19754. // https://tc39.es/ecma262/#sec-map.prototype.set
  19755. set: function set(key, value) {
  19756. return define(this, key === 0 ? 0 : key, value);
  19757. }
  19758. } : {
  19759. // `Set.prototype.add(value)` method
  19760. // https://tc39.es/ecma262/#sec-set.prototype.add
  19761. add: function add(value) {
  19762. return define(this, value = value === 0 ? 0 : value, value);
  19763. }
  19764. });
  19765. if (DESCRIPTORS) defineProperty(Prototype, 'size', {
  19766. get: function () {
  19767. return getInternalState(this).size;
  19768. }
  19769. });
  19770. return Constructor;
  19771. },
  19772. setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
  19773. var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
  19774. var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
  19775. var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);
  19776. // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods
  19777. // https://tc39.es/ecma262/#sec-map.prototype.entries
  19778. // https://tc39.es/ecma262/#sec-map.prototype.keys
  19779. // https://tc39.es/ecma262/#sec-map.prototype.values
  19780. // https://tc39.es/ecma262/#sec-map.prototype-@@iterator
  19781. // https://tc39.es/ecma262/#sec-set.prototype.entries
  19782. // https://tc39.es/ecma262/#sec-set.prototype.keys
  19783. // https://tc39.es/ecma262/#sec-set.prototype.values
  19784. // https://tc39.es/ecma262/#sec-set.prototype-@@iterator
  19785. defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
  19786. setInternalState(this, {
  19787. type: ITERATOR_NAME,
  19788. target: iterated,
  19789. state: getInternalCollectionState(iterated),
  19790. kind: kind,
  19791. last: undefined
  19792. });
  19793. }, function () {
  19794. var state = getInternalIteratorState(this);
  19795. var kind = state.kind;
  19796. var entry = state.last;
  19797. // revert to the last existing entry
  19798. while (entry && entry.removed) entry = entry.previous;
  19799. // get next entry
  19800. if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
  19801. // or finish the iteration
  19802. state.target = undefined;
  19803. return createIterResultObject(undefined, true);
  19804. }
  19805. // return step by kind
  19806. if (kind == 'keys') return createIterResultObject(entry.key, false);
  19807. if (kind == 'values') return createIterResultObject(entry.value, false);
  19808. return createIterResultObject([entry.key, entry.value], false);
  19809. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  19810. // `{ Map, Set }.prototype[@@species]` accessors
  19811. // https://tc39.es/ecma262/#sec-get-map-@@species
  19812. // https://tc39.es/ecma262/#sec-get-set-@@species
  19813. setSpecies(CONSTRUCTOR_NAME);
  19814. }
  19815. };
  19816. },{"../internals/an-instance":276,"../internals/create-iter-result-object":305,"../internals/define-built-ins":310,"../internals/descriptors":313,"../internals/function-bind-context":336,"../internals/internal-metadata":356,"../internals/internal-state":357,"../internals/is-null-or-undefined":365,"../internals/iterate":370,"../internals/iterator-define":373,"../internals/object-create":386,"../internals/object-define-property":388,"../internals/set-species":414}],300:[function(_dereq_,module,exports){
  19817. 'use strict';
  19818. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  19819. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  19820. var getWeakData = _dereq_('../internals/internal-metadata').getWeakData;
  19821. var anInstance = _dereq_('../internals/an-instance');
  19822. var anObject = _dereq_('../internals/an-object');
  19823. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  19824. var isObject = _dereq_('../internals/is-object');
  19825. var iterate = _dereq_('../internals/iterate');
  19826. var ArrayIterationModule = _dereq_('../internals/array-iteration');
  19827. var hasOwn = _dereq_('../internals/has-own-property');
  19828. var InternalStateModule = _dereq_('../internals/internal-state');
  19829. var setInternalState = InternalStateModule.set;
  19830. var internalStateGetterFor = InternalStateModule.getterFor;
  19831. var find = ArrayIterationModule.find;
  19832. var findIndex = ArrayIterationModule.findIndex;
  19833. var splice = uncurryThis([].splice);
  19834. var id = 0;
  19835. // fallback for uncaught frozen keys
  19836. var uncaughtFrozenStore = function (store) {
  19837. return store.frozen || (store.frozen = new UncaughtFrozenStore());
  19838. };
  19839. var UncaughtFrozenStore = function () {
  19840. this.entries = [];
  19841. };
  19842. var findUncaughtFrozen = function (store, key) {
  19843. return find(store.entries, function (it) {
  19844. return it[0] === key;
  19845. });
  19846. };
  19847. UncaughtFrozenStore.prototype = {
  19848. get: function (key) {
  19849. var entry = findUncaughtFrozen(this, key);
  19850. if (entry) return entry[1];
  19851. },
  19852. has: function (key) {
  19853. return !!findUncaughtFrozen(this, key);
  19854. },
  19855. set: function (key, value) {
  19856. var entry = findUncaughtFrozen(this, key);
  19857. if (entry) entry[1] = value;
  19858. else this.entries.push([key, value]);
  19859. },
  19860. 'delete': function (key) {
  19861. var index = findIndex(this.entries, function (it) {
  19862. return it[0] === key;
  19863. });
  19864. if (~index) splice(this.entries, index, 1);
  19865. return !!~index;
  19866. }
  19867. };
  19868. module.exports = {
  19869. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  19870. var Constructor = wrapper(function (that, iterable) {
  19871. anInstance(that, Prototype);
  19872. setInternalState(that, {
  19873. type: CONSTRUCTOR_NAME,
  19874. id: id++,
  19875. frozen: undefined
  19876. });
  19877. if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  19878. });
  19879. var Prototype = Constructor.prototype;
  19880. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  19881. var define = function (that, key, value) {
  19882. var state = getInternalState(that);
  19883. var data = getWeakData(anObject(key), true);
  19884. if (data === true) uncaughtFrozenStore(state).set(key, value);
  19885. else data[state.id] = value;
  19886. return that;
  19887. };
  19888. defineBuiltIns(Prototype, {
  19889. // `{ WeakMap, WeakSet }.prototype.delete(key)` methods
  19890. // https://tc39.es/ecma262/#sec-weakmap.prototype.delete
  19891. // https://tc39.es/ecma262/#sec-weakset.prototype.delete
  19892. 'delete': function (key) {
  19893. var state = getInternalState(this);
  19894. if (!isObject(key)) return false;
  19895. var data = getWeakData(key);
  19896. if (data === true) return uncaughtFrozenStore(state)['delete'](key);
  19897. return data && hasOwn(data, state.id) && delete data[state.id];
  19898. },
  19899. // `{ WeakMap, WeakSet }.prototype.has(key)` methods
  19900. // https://tc39.es/ecma262/#sec-weakmap.prototype.has
  19901. // https://tc39.es/ecma262/#sec-weakset.prototype.has
  19902. has: function has(key) {
  19903. var state = getInternalState(this);
  19904. if (!isObject(key)) return false;
  19905. var data = getWeakData(key);
  19906. if (data === true) return uncaughtFrozenStore(state).has(key);
  19907. return data && hasOwn(data, state.id);
  19908. }
  19909. });
  19910. defineBuiltIns(Prototype, IS_MAP ? {
  19911. // `WeakMap.prototype.get(key)` method
  19912. // https://tc39.es/ecma262/#sec-weakmap.prototype.get
  19913. get: function get(key) {
  19914. var state = getInternalState(this);
  19915. if (isObject(key)) {
  19916. var data = getWeakData(key);
  19917. if (data === true) return uncaughtFrozenStore(state).get(key);
  19918. return data ? data[state.id] : undefined;
  19919. }
  19920. },
  19921. // `WeakMap.prototype.set(key, value)` method
  19922. // https://tc39.es/ecma262/#sec-weakmap.prototype.set
  19923. set: function set(key, value) {
  19924. return define(this, key, value);
  19925. }
  19926. } : {
  19927. // `WeakSet.prototype.add(value)` method
  19928. // https://tc39.es/ecma262/#sec-weakset.prototype.add
  19929. add: function add(value) {
  19930. return define(this, value, true);
  19931. }
  19932. });
  19933. return Constructor;
  19934. }
  19935. };
  19936. },{"../internals/an-instance":276,"../internals/an-object":277,"../internals/array-iteration":282,"../internals/define-built-ins":310,"../internals/function-uncurry-this":341,"../internals/has-own-property":348,"../internals/internal-metadata":356,"../internals/internal-state":357,"../internals/is-null-or-undefined":365,"../internals/is-object":366,"../internals/iterate":370}],301:[function(_dereq_,module,exports){
  19937. 'use strict';
  19938. var $ = _dereq_('../internals/export');
  19939. var global = _dereq_('../internals/global');
  19940. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  19941. var fails = _dereq_('../internals/fails');
  19942. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  19943. var iterate = _dereq_('../internals/iterate');
  19944. var anInstance = _dereq_('../internals/an-instance');
  19945. var isCallable = _dereq_('../internals/is-callable');
  19946. var isObject = _dereq_('../internals/is-object');
  19947. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  19948. var defineProperty = _dereq_('../internals/object-define-property').f;
  19949. var forEach = _dereq_('../internals/array-iteration').forEach;
  19950. var DESCRIPTORS = _dereq_('../internals/descriptors');
  19951. var InternalStateModule = _dereq_('../internals/internal-state');
  19952. var setInternalState = InternalStateModule.set;
  19953. var internalStateGetterFor = InternalStateModule.getterFor;
  19954. module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
  19955. var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
  19956. var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
  19957. var ADDER = IS_MAP ? 'set' : 'add';
  19958. var NativeConstructor = global[CONSTRUCTOR_NAME];
  19959. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  19960. var exported = {};
  19961. var Constructor;
  19962. if (!DESCRIPTORS || !isCallable(NativeConstructor)
  19963. || !(IS_WEAK || NativePrototype.forEach && !fails(function () { new NativeConstructor().entries().next(); }))
  19964. ) {
  19965. // create collection constructor
  19966. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  19967. InternalMetadataModule.enable();
  19968. } else {
  19969. Constructor = wrapper(function (target, iterable) {
  19970. setInternalState(anInstance(target, Prototype), {
  19971. type: CONSTRUCTOR_NAME,
  19972. collection: new NativeConstructor()
  19973. });
  19974. if (iterable != undefined) iterate(iterable, target[ADDER], { that: target, AS_ENTRIES: IS_MAP });
  19975. });
  19976. var Prototype = Constructor.prototype;
  19977. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  19978. forEach(['add', 'clear', 'delete', 'forEach', 'get', 'has', 'set', 'keys', 'values', 'entries'], function (KEY) {
  19979. var IS_ADDER = KEY == 'add' || KEY == 'set';
  19980. if (KEY in NativePrototype && !(IS_WEAK && KEY == 'clear')) {
  19981. createNonEnumerableProperty(Prototype, KEY, function (a, b) {
  19982. var collection = getInternalState(this).collection;
  19983. if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
  19984. var result = collection[KEY](a === 0 ? 0 : a, b);
  19985. return IS_ADDER ? this : result;
  19986. });
  19987. }
  19988. });
  19989. IS_WEAK || defineProperty(Prototype, 'size', {
  19990. configurable: true,
  19991. get: function () {
  19992. return getInternalState(this).collection.size;
  19993. }
  19994. });
  19995. }
  19996. setToStringTag(Constructor, CONSTRUCTOR_NAME, false, true);
  19997. exported[CONSTRUCTOR_NAME] = Constructor;
  19998. $({ global: true, forced: true }, exported);
  19999. if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  20000. return Constructor;
  20001. };
  20002. },{"../internals/an-instance":276,"../internals/array-iteration":282,"../internals/create-non-enumerable-property":306,"../internals/descriptors":313,"../internals/export":332,"../internals/fails":333,"../internals/global":347,"../internals/internal-metadata":356,"../internals/internal-state":357,"../internals/is-callable":360,"../internals/is-object":366,"../internals/iterate":370,"../internals/object-define-property":388,"../internals/set-to-string-tag":415}],302:[function(_dereq_,module,exports){
  20003. var hasOwn = _dereq_('../internals/has-own-property');
  20004. var ownKeys = _dereq_('../internals/own-keys');
  20005. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  20006. var definePropertyModule = _dereq_('../internals/object-define-property');
  20007. module.exports = function (target, source, exceptions) {
  20008. var keys = ownKeys(source);
  20009. var defineProperty = definePropertyModule.f;
  20010. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  20011. for (var i = 0; i < keys.length; i++) {
  20012. var key = keys[i];
  20013. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  20014. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  20015. }
  20016. }
  20017. };
  20018. },{"../internals/has-own-property":348,"../internals/object-define-property":388,"../internals/object-get-own-property-descriptor":389,"../internals/own-keys":403}],303:[function(_dereq_,module,exports){
  20019. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20020. var MATCH = wellKnownSymbol('match');
  20021. module.exports = function (METHOD_NAME) {
  20022. var regexp = /./;
  20023. try {
  20024. '/./'[METHOD_NAME](regexp);
  20025. } catch (error1) {
  20026. try {
  20027. regexp[MATCH] = false;
  20028. return '/./'[METHOD_NAME](regexp);
  20029. } catch (error2) { /* empty */ }
  20030. } return false;
  20031. };
  20032. },{"../internals/well-known-symbol":443}],304:[function(_dereq_,module,exports){
  20033. var fails = _dereq_('../internals/fails');
  20034. module.exports = !fails(function () {
  20035. function F() { /* empty */ }
  20036. F.prototype.constructor = null;
  20037. // eslint-disable-next-line es-x/no-object-getprototypeof -- required for testing
  20038. return Object.getPrototypeOf(new F()) !== F.prototype;
  20039. });
  20040. },{"../internals/fails":333}],305:[function(_dereq_,module,exports){
  20041. // `CreateIterResultObject` abstract operation
  20042. // https://tc39.es/ecma262/#sec-createiterresultobject
  20043. module.exports = function (value, done) {
  20044. return { value: value, done: done };
  20045. };
  20046. },{}],306:[function(_dereq_,module,exports){
  20047. var DESCRIPTORS = _dereq_('../internals/descriptors');
  20048. var definePropertyModule = _dereq_('../internals/object-define-property');
  20049. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  20050. module.exports = DESCRIPTORS ? function (object, key, value) {
  20051. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  20052. } : function (object, key, value) {
  20053. object[key] = value;
  20054. return object;
  20055. };
  20056. },{"../internals/create-property-descriptor":307,"../internals/descriptors":313,"../internals/object-define-property":388}],307:[function(_dereq_,module,exports){
  20057. module.exports = function (bitmap, value) {
  20058. return {
  20059. enumerable: !(bitmap & 1),
  20060. configurable: !(bitmap & 2),
  20061. writable: !(bitmap & 4),
  20062. value: value
  20063. };
  20064. };
  20065. },{}],308:[function(_dereq_,module,exports){
  20066. 'use strict';
  20067. var toPropertyKey = _dereq_('../internals/to-property-key');
  20068. var definePropertyModule = _dereq_('../internals/object-define-property');
  20069. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  20070. module.exports = function (object, key, value) {
  20071. var propertyKey = toPropertyKey(key);
  20072. if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  20073. else object[propertyKey] = value;
  20074. };
  20075. },{"../internals/create-property-descriptor":307,"../internals/object-define-property":388,"../internals/to-property-key":432}],309:[function(_dereq_,module,exports){
  20076. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  20077. module.exports = function (target, key, value, options) {
  20078. if (options && options.enumerable) target[key] = value;
  20079. else createNonEnumerableProperty(target, key, value);
  20080. return target;
  20081. };
  20082. },{"../internals/create-non-enumerable-property":306}],310:[function(_dereq_,module,exports){
  20083. var defineBuiltIn = _dereq_('../internals/define-built-in');
  20084. module.exports = function (target, src, options) {
  20085. for (var key in src) {
  20086. if (options && options.unsafe && target[key]) target[key] = src[key];
  20087. else defineBuiltIn(target, key, src[key], options);
  20088. } return target;
  20089. };
  20090. },{"../internals/define-built-in":309}],311:[function(_dereq_,module,exports){
  20091. var global = _dereq_('../internals/global');
  20092. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  20093. var defineProperty = Object.defineProperty;
  20094. module.exports = function (key, value) {
  20095. try {
  20096. defineProperty(global, key, { value: value, configurable: true, writable: true });
  20097. } catch (error) {
  20098. global[key] = value;
  20099. } return value;
  20100. };
  20101. },{"../internals/global":347}],312:[function(_dereq_,module,exports){
  20102. 'use strict';
  20103. var tryToString = _dereq_('../internals/try-to-string');
  20104. var $TypeError = TypeError;
  20105. module.exports = function (O, P) {
  20106. if (!delete O[P]) throw $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O));
  20107. };
  20108. },{"../internals/try-to-string":435}],313:[function(_dereq_,module,exports){
  20109. var fails = _dereq_('../internals/fails');
  20110. // Detect IE8's incomplete defineProperty implementation
  20111. module.exports = !fails(function () {
  20112. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  20113. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  20114. });
  20115. },{"../internals/fails":333}],314:[function(_dereq_,module,exports){
  20116. var global = _dereq_('../internals/global');
  20117. var isObject = _dereq_('../internals/is-object');
  20118. var document = global.document;
  20119. // typeof document.createElement is 'object' in old IE
  20120. var EXISTS = isObject(document) && isObject(document.createElement);
  20121. module.exports = function (it) {
  20122. return EXISTS ? document.createElement(it) : {};
  20123. };
  20124. },{"../internals/global":347,"../internals/is-object":366}],315:[function(_dereq_,module,exports){
  20125. var $TypeError = TypeError;
  20126. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
  20127. module.exports = function (it) {
  20128. if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded');
  20129. return it;
  20130. };
  20131. },{}],316:[function(_dereq_,module,exports){
  20132. // iterable DOM collections
  20133. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  20134. module.exports = {
  20135. CSSRuleList: 0,
  20136. CSSStyleDeclaration: 0,
  20137. CSSValueList: 0,
  20138. ClientRectList: 0,
  20139. DOMRectList: 0,
  20140. DOMStringList: 0,
  20141. DOMTokenList: 1,
  20142. DataTransferItemList: 0,
  20143. FileList: 0,
  20144. HTMLAllCollection: 0,
  20145. HTMLCollection: 0,
  20146. HTMLFormElement: 0,
  20147. HTMLSelectElement: 0,
  20148. MediaList: 0,
  20149. MimeTypeArray: 0,
  20150. NamedNodeMap: 0,
  20151. NodeList: 1,
  20152. PaintRequestList: 0,
  20153. Plugin: 0,
  20154. PluginArray: 0,
  20155. SVGLengthList: 0,
  20156. SVGNumberList: 0,
  20157. SVGPathSegList: 0,
  20158. SVGPointList: 0,
  20159. SVGStringList: 0,
  20160. SVGTransformList: 0,
  20161. SourceBufferList: 0,
  20162. StyleSheetList: 0,
  20163. TextTrackCueList: 0,
  20164. TextTrackList: 0,
  20165. TouchList: 0
  20166. };
  20167. },{}],317:[function(_dereq_,module,exports){
  20168. var userAgent = _dereq_('../internals/engine-user-agent');
  20169. var firefox = userAgent.match(/firefox\/(\d+)/i);
  20170. module.exports = !!firefox && +firefox[1];
  20171. },{"../internals/engine-user-agent":325}],318:[function(_dereq_,module,exports){
  20172. var IS_DENO = _dereq_('../internals/engine-is-deno');
  20173. var IS_NODE = _dereq_('../internals/engine-is-node');
  20174. module.exports = !IS_DENO && !IS_NODE
  20175. && typeof window == 'object'
  20176. && typeof document == 'object';
  20177. },{"../internals/engine-is-deno":319,"../internals/engine-is-node":323}],319:[function(_dereq_,module,exports){
  20178. /* global Deno -- Deno case */
  20179. module.exports = typeof Deno == 'object' && Deno && typeof Deno.version == 'object';
  20180. },{}],320:[function(_dereq_,module,exports){
  20181. var UA = _dereq_('../internals/engine-user-agent');
  20182. module.exports = /MSIE|Trident/.test(UA);
  20183. },{"../internals/engine-user-agent":325}],321:[function(_dereq_,module,exports){
  20184. var userAgent = _dereq_('../internals/engine-user-agent');
  20185. var global = _dereq_('../internals/global');
  20186. module.exports = /ipad|iphone|ipod/i.test(userAgent) && global.Pebble !== undefined;
  20187. },{"../internals/engine-user-agent":325,"../internals/global":347}],322:[function(_dereq_,module,exports){
  20188. var userAgent = _dereq_('../internals/engine-user-agent');
  20189. module.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
  20190. },{"../internals/engine-user-agent":325}],323:[function(_dereq_,module,exports){
  20191. var classof = _dereq_('../internals/classof-raw');
  20192. var global = _dereq_('../internals/global');
  20193. module.exports = classof(global.process) == 'process';
  20194. },{"../internals/classof-raw":294,"../internals/global":347}],324:[function(_dereq_,module,exports){
  20195. var userAgent = _dereq_('../internals/engine-user-agent');
  20196. module.exports = /web0s(?!.*chrome)/i.test(userAgent);
  20197. },{"../internals/engine-user-agent":325}],325:[function(_dereq_,module,exports){
  20198. var getBuiltIn = _dereq_('../internals/get-built-in');
  20199. module.exports = getBuiltIn('navigator', 'userAgent') || '';
  20200. },{"../internals/get-built-in":342}],326:[function(_dereq_,module,exports){
  20201. var global = _dereq_('../internals/global');
  20202. var userAgent = _dereq_('../internals/engine-user-agent');
  20203. var process = global.process;
  20204. var Deno = global.Deno;
  20205. var versions = process && process.versions || Deno && Deno.version;
  20206. var v8 = versions && versions.v8;
  20207. var match, version;
  20208. if (v8) {
  20209. match = v8.split('.');
  20210. // in old Chrome, versions of V8 isn't V8 = Chrome / 10
  20211. // but their correct versions are not interesting for us
  20212. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  20213. }
  20214. // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
  20215. // so check `userAgent` even if `.v8` exists, but 0
  20216. if (!version && userAgent) {
  20217. match = userAgent.match(/Edge\/(\d+)/);
  20218. if (!match || match[1] >= 74) {
  20219. match = userAgent.match(/Chrome\/(\d+)/);
  20220. if (match) version = +match[1];
  20221. }
  20222. }
  20223. module.exports = version;
  20224. },{"../internals/engine-user-agent":325,"../internals/global":347}],327:[function(_dereq_,module,exports){
  20225. var userAgent = _dereq_('../internals/engine-user-agent');
  20226. var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
  20227. module.exports = !!webkit && +webkit[1];
  20228. },{"../internals/engine-user-agent":325}],328:[function(_dereq_,module,exports){
  20229. var path = _dereq_('../internals/path');
  20230. module.exports = function (CONSTRUCTOR) {
  20231. return path[CONSTRUCTOR + 'Prototype'];
  20232. };
  20233. },{"../internals/path":404}],329:[function(_dereq_,module,exports){
  20234. // IE8- don't enum bug keys
  20235. module.exports = [
  20236. 'constructor',
  20237. 'hasOwnProperty',
  20238. 'isPrototypeOf',
  20239. 'propertyIsEnumerable',
  20240. 'toLocaleString',
  20241. 'toString',
  20242. 'valueOf'
  20243. ];
  20244. },{}],330:[function(_dereq_,module,exports){
  20245. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20246. var $Error = Error;
  20247. var replace = uncurryThis(''.replace);
  20248. var TEST = (function (arg) { return String($Error(arg).stack); })('zxcasd');
  20249. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  20250. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  20251. module.exports = function (stack, dropEntries) {
  20252. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
  20253. while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  20254. } return stack;
  20255. };
  20256. },{"../internals/function-uncurry-this":341}],331:[function(_dereq_,module,exports){
  20257. var fails = _dereq_('../internals/fails');
  20258. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  20259. module.exports = !fails(function () {
  20260. var error = Error('a');
  20261. if (!('stack' in error)) return true;
  20262. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  20263. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  20264. return error.stack !== 7;
  20265. });
  20266. },{"../internals/create-property-descriptor":307,"../internals/fails":333}],332:[function(_dereq_,module,exports){
  20267. 'use strict';
  20268. var global = _dereq_('../internals/global');
  20269. var apply = _dereq_('../internals/function-apply');
  20270. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20271. var isCallable = _dereq_('../internals/is-callable');
  20272. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  20273. var isForced = _dereq_('../internals/is-forced');
  20274. var path = _dereq_('../internals/path');
  20275. var bind = _dereq_('../internals/function-bind-context');
  20276. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  20277. var hasOwn = _dereq_('../internals/has-own-property');
  20278. var wrapConstructor = function (NativeConstructor) {
  20279. var Wrapper = function (a, b, c) {
  20280. if (this instanceof Wrapper) {
  20281. switch (arguments.length) {
  20282. case 0: return new NativeConstructor();
  20283. case 1: return new NativeConstructor(a);
  20284. case 2: return new NativeConstructor(a, b);
  20285. } return new NativeConstructor(a, b, c);
  20286. } return apply(NativeConstructor, this, arguments);
  20287. };
  20288. Wrapper.prototype = NativeConstructor.prototype;
  20289. return Wrapper;
  20290. };
  20291. /*
  20292. options.target - name of the target object
  20293. options.global - target is the global object
  20294. options.stat - export as static methods of target
  20295. options.proto - export as prototype methods of target
  20296. options.real - real prototype method for the `pure` version
  20297. options.forced - export even if the native feature is available
  20298. options.bind - bind methods to the target, required for the `pure` version
  20299. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  20300. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  20301. options.sham - add a flag to not completely full polyfills
  20302. options.enumerable - export as enumerable property
  20303. options.dontCallGetSet - prevent calling a getter on target
  20304. options.name - the .name of the function if it does not match the key
  20305. */
  20306. module.exports = function (options, source) {
  20307. var TARGET = options.target;
  20308. var GLOBAL = options.global;
  20309. var STATIC = options.stat;
  20310. var PROTO = options.proto;
  20311. var nativeSource = GLOBAL ? global : STATIC ? global[TARGET] : (global[TARGET] || {}).prototype;
  20312. var target = GLOBAL ? path : path[TARGET] || createNonEnumerableProperty(path, TARGET, {})[TARGET];
  20313. var targetPrototype = target.prototype;
  20314. var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
  20315. var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
  20316. for (key in source) {
  20317. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  20318. // contains in native
  20319. USE_NATIVE = !FORCED && nativeSource && hasOwn(nativeSource, key);
  20320. targetProperty = target[key];
  20321. if (USE_NATIVE) if (options.dontCallGetSet) {
  20322. descriptor = getOwnPropertyDescriptor(nativeSource, key);
  20323. nativeProperty = descriptor && descriptor.value;
  20324. } else nativeProperty = nativeSource[key];
  20325. // export native or implementation
  20326. sourceProperty = (USE_NATIVE && nativeProperty) ? nativeProperty : source[key];
  20327. if (USE_NATIVE && typeof targetProperty == typeof sourceProperty) continue;
  20328. // bind timers to global for call from export context
  20329. if (options.bind && USE_NATIVE) resultProperty = bind(sourceProperty, global);
  20330. // wrap global constructors for prevent changs in this version
  20331. else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty);
  20332. // make static versions for prototype methods
  20333. else if (PROTO && isCallable(sourceProperty)) resultProperty = uncurryThis(sourceProperty);
  20334. // default case
  20335. else resultProperty = sourceProperty;
  20336. // add a flag to not completely full polyfills
  20337. if (options.sham || (sourceProperty && sourceProperty.sham) || (targetProperty && targetProperty.sham)) {
  20338. createNonEnumerableProperty(resultProperty, 'sham', true);
  20339. }
  20340. createNonEnumerableProperty(target, key, resultProperty);
  20341. if (PROTO) {
  20342. VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
  20343. if (!hasOwn(path, VIRTUAL_PROTOTYPE)) {
  20344. createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
  20345. }
  20346. // export virtual prototype methods
  20347. createNonEnumerableProperty(path[VIRTUAL_PROTOTYPE], key, sourceProperty);
  20348. // export real prototype methods
  20349. if (options.real && targetPrototype && !targetPrototype[key]) {
  20350. createNonEnumerableProperty(targetPrototype, key, sourceProperty);
  20351. }
  20352. }
  20353. }
  20354. };
  20355. },{"../internals/create-non-enumerable-property":306,"../internals/function-apply":335,"../internals/function-bind-context":336,"../internals/function-uncurry-this":341,"../internals/global":347,"../internals/has-own-property":348,"../internals/is-callable":360,"../internals/is-forced":363,"../internals/object-get-own-property-descriptor":389,"../internals/path":404}],333:[function(_dereq_,module,exports){
  20356. module.exports = function (exec) {
  20357. try {
  20358. return !!exec();
  20359. } catch (error) {
  20360. return true;
  20361. }
  20362. };
  20363. },{}],334:[function(_dereq_,module,exports){
  20364. var fails = _dereq_('../internals/fails');
  20365. module.exports = !fails(function () {
  20366. // eslint-disable-next-line es-x/no-object-isextensible, es-x/no-object-preventextensions -- required for testing
  20367. return Object.isExtensible(Object.preventExtensions({}));
  20368. });
  20369. },{"../internals/fails":333}],335:[function(_dereq_,module,exports){
  20370. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  20371. var FunctionPrototype = Function.prototype;
  20372. var apply = FunctionPrototype.apply;
  20373. var call = FunctionPrototype.call;
  20374. // eslint-disable-next-line es-x/no-reflect -- safe
  20375. module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
  20376. return call.apply(apply, arguments);
  20377. });
  20378. },{"../internals/function-bind-native":337}],336:[function(_dereq_,module,exports){
  20379. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20380. var aCallable = _dereq_('../internals/a-callable');
  20381. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  20382. var bind = uncurryThis(uncurryThis.bind);
  20383. // optional / simple context binding
  20384. module.exports = function (fn, that) {
  20385. aCallable(fn);
  20386. return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
  20387. return fn.apply(that, arguments);
  20388. };
  20389. };
  20390. },{"../internals/a-callable":272,"../internals/function-bind-native":337,"../internals/function-uncurry-this":341}],337:[function(_dereq_,module,exports){
  20391. var fails = _dereq_('../internals/fails');
  20392. module.exports = !fails(function () {
  20393. // eslint-disable-next-line es-x/no-function-prototype-bind -- safe
  20394. var test = (function () { /* empty */ }).bind();
  20395. // eslint-disable-next-line no-prototype-builtins -- safe
  20396. return typeof test != 'function' || test.hasOwnProperty('prototype');
  20397. });
  20398. },{"../internals/fails":333}],338:[function(_dereq_,module,exports){
  20399. 'use strict';
  20400. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20401. var aCallable = _dereq_('../internals/a-callable');
  20402. var isObject = _dereq_('../internals/is-object');
  20403. var hasOwn = _dereq_('../internals/has-own-property');
  20404. var arraySlice = _dereq_('../internals/array-slice');
  20405. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  20406. var $Function = Function;
  20407. var concat = uncurryThis([].concat);
  20408. var join = uncurryThis([].join);
  20409. var factories = {};
  20410. var construct = function (C, argsLength, args) {
  20411. if (!hasOwn(factories, argsLength)) {
  20412. for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
  20413. factories[argsLength] = $Function('C,a', 'return new C(' + join(list, ',') + ')');
  20414. } return factories[argsLength](C, args);
  20415. };
  20416. // `Function.prototype.bind` method implementation
  20417. // https://tc39.es/ecma262/#sec-function.prototype.bind
  20418. module.exports = NATIVE_BIND ? $Function.bind : function bind(that /* , ...args */) {
  20419. var F = aCallable(this);
  20420. var Prototype = F.prototype;
  20421. var partArgs = arraySlice(arguments, 1);
  20422. var boundFunction = function bound(/* args... */) {
  20423. var args = concat(partArgs, arraySlice(arguments));
  20424. return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
  20425. };
  20426. if (isObject(Prototype)) boundFunction.prototype = Prototype;
  20427. return boundFunction;
  20428. };
  20429. },{"../internals/a-callable":272,"../internals/array-slice":288,"../internals/function-bind-native":337,"../internals/function-uncurry-this":341,"../internals/has-own-property":348,"../internals/is-object":366}],339:[function(_dereq_,module,exports){
  20430. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  20431. var call = Function.prototype.call;
  20432. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  20433. return call.apply(call, arguments);
  20434. };
  20435. },{"../internals/function-bind-native":337}],340:[function(_dereq_,module,exports){
  20436. var DESCRIPTORS = _dereq_('../internals/descriptors');
  20437. var hasOwn = _dereq_('../internals/has-own-property');
  20438. var FunctionPrototype = Function.prototype;
  20439. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  20440. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  20441. var EXISTS = hasOwn(FunctionPrototype, 'name');
  20442. // additional protection from minified / mangled / dropped function names
  20443. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  20444. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
  20445. module.exports = {
  20446. EXISTS: EXISTS,
  20447. PROPER: PROPER,
  20448. CONFIGURABLE: CONFIGURABLE
  20449. };
  20450. },{"../internals/descriptors":313,"../internals/has-own-property":348}],341:[function(_dereq_,module,exports){
  20451. var NATIVE_BIND = _dereq_('../internals/function-bind-native');
  20452. var FunctionPrototype = Function.prototype;
  20453. var bind = FunctionPrototype.bind;
  20454. var call = FunctionPrototype.call;
  20455. var uncurryThis = NATIVE_BIND && bind.bind(call, call);
  20456. module.exports = NATIVE_BIND ? function (fn) {
  20457. return fn && uncurryThis(fn);
  20458. } : function (fn) {
  20459. return fn && function () {
  20460. return call.apply(fn, arguments);
  20461. };
  20462. };
  20463. },{"../internals/function-bind-native":337}],342:[function(_dereq_,module,exports){
  20464. var path = _dereq_('../internals/path');
  20465. var global = _dereq_('../internals/global');
  20466. var isCallable = _dereq_('../internals/is-callable');
  20467. var aFunction = function (variable) {
  20468. return isCallable(variable) ? variable : undefined;
  20469. };
  20470. module.exports = function (namespace, method) {
  20471. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])
  20472. : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
  20473. };
  20474. },{"../internals/global":347,"../internals/is-callable":360,"../internals/path":404}],343:[function(_dereq_,module,exports){
  20475. var classof = _dereq_('../internals/classof');
  20476. var getMethod = _dereq_('../internals/get-method');
  20477. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  20478. var Iterators = _dereq_('../internals/iterators');
  20479. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20480. var ITERATOR = wellKnownSymbol('iterator');
  20481. module.exports = function (it) {
  20482. if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR)
  20483. || getMethod(it, '@@iterator')
  20484. || Iterators[classof(it)];
  20485. };
  20486. },{"../internals/classof":295,"../internals/get-method":346,"../internals/is-null-or-undefined":365,"../internals/iterators":375,"../internals/well-known-symbol":443}],344:[function(_dereq_,module,exports){
  20487. var call = _dereq_('../internals/function-call');
  20488. var aCallable = _dereq_('../internals/a-callable');
  20489. var anObject = _dereq_('../internals/an-object');
  20490. var tryToString = _dereq_('../internals/try-to-string');
  20491. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  20492. var $TypeError = TypeError;
  20493. module.exports = function (argument, usingIterator) {
  20494. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
  20495. if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
  20496. throw $TypeError(tryToString(argument) + ' is not iterable');
  20497. };
  20498. },{"../internals/a-callable":272,"../internals/an-object":277,"../internals/function-call":339,"../internals/get-iterator-method":343,"../internals/try-to-string":435}],345:[function(_dereq_,module,exports){
  20499. var getIterator = _dereq_('../internals/get-iterator');
  20500. module.exports = getIterator;
  20501. },{"../internals/get-iterator":344}],346:[function(_dereq_,module,exports){
  20502. var aCallable = _dereq_('../internals/a-callable');
  20503. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  20504. // `GetMethod` abstract operation
  20505. // https://tc39.es/ecma262/#sec-getmethod
  20506. module.exports = function (V, P) {
  20507. var func = V[P];
  20508. return isNullOrUndefined(func) ? undefined : aCallable(func);
  20509. };
  20510. },{"../internals/a-callable":272,"../internals/is-null-or-undefined":365}],347:[function(_dereq_,module,exports){
  20511. (function (global){(function (){
  20512. var check = function (it) {
  20513. return it && it.Math == Math && it;
  20514. };
  20515. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  20516. module.exports =
  20517. // eslint-disable-next-line es-x/no-global-this -- safe
  20518. check(typeof globalThis == 'object' && globalThis) ||
  20519. check(typeof window == 'object' && window) ||
  20520. // eslint-disable-next-line no-restricted-globals -- safe
  20521. check(typeof self == 'object' && self) ||
  20522. check(typeof global == 'object' && global) ||
  20523. // eslint-disable-next-line no-new-func -- fallback
  20524. (function () { return this; })() || Function('return this')();
  20525. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  20526. },{}],348:[function(_dereq_,module,exports){
  20527. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20528. var toObject = _dereq_('../internals/to-object');
  20529. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  20530. // `HasOwnProperty` abstract operation
  20531. // https://tc39.es/ecma262/#sec-hasownproperty
  20532. // eslint-disable-next-line es-x/no-object-hasown -- safe
  20533. module.exports = Object.hasOwn || function hasOwn(it, key) {
  20534. return hasOwnProperty(toObject(it), key);
  20535. };
  20536. },{"../internals/function-uncurry-this":341,"../internals/to-object":430}],349:[function(_dereq_,module,exports){
  20537. module.exports = {};
  20538. },{}],350:[function(_dereq_,module,exports){
  20539. var global = _dereq_('../internals/global');
  20540. module.exports = function (a, b) {
  20541. var console = global.console;
  20542. if (console && console.error) {
  20543. arguments.length == 1 ? console.error(a) : console.error(a, b);
  20544. }
  20545. };
  20546. },{"../internals/global":347}],351:[function(_dereq_,module,exports){
  20547. var getBuiltIn = _dereq_('../internals/get-built-in');
  20548. module.exports = getBuiltIn('document', 'documentElement');
  20549. },{"../internals/get-built-in":342}],352:[function(_dereq_,module,exports){
  20550. var DESCRIPTORS = _dereq_('../internals/descriptors');
  20551. var fails = _dereq_('../internals/fails');
  20552. var createElement = _dereq_('../internals/document-create-element');
  20553. // Thanks to IE8 for its funny defineProperty
  20554. module.exports = !DESCRIPTORS && !fails(function () {
  20555. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  20556. return Object.defineProperty(createElement('div'), 'a', {
  20557. get: function () { return 7; }
  20558. }).a != 7;
  20559. });
  20560. },{"../internals/descriptors":313,"../internals/document-create-element":314,"../internals/fails":333}],353:[function(_dereq_,module,exports){
  20561. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20562. var fails = _dereq_('../internals/fails');
  20563. var classof = _dereq_('../internals/classof-raw');
  20564. var $Object = Object;
  20565. var split = uncurryThis(''.split);
  20566. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  20567. module.exports = fails(function () {
  20568. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  20569. // eslint-disable-next-line no-prototype-builtins -- safe
  20570. return !$Object('z').propertyIsEnumerable(0);
  20571. }) ? function (it) {
  20572. return classof(it) == 'String' ? split(it, '') : $Object(it);
  20573. } : $Object;
  20574. },{"../internals/classof-raw":294,"../internals/fails":333,"../internals/function-uncurry-this":341}],354:[function(_dereq_,module,exports){
  20575. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20576. var isCallable = _dereq_('../internals/is-callable');
  20577. var store = _dereq_('../internals/shared-store');
  20578. var functionToString = uncurryThis(Function.toString);
  20579. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  20580. if (!isCallable(store.inspectSource)) {
  20581. store.inspectSource = function (it) {
  20582. return functionToString(it);
  20583. };
  20584. }
  20585. module.exports = store.inspectSource;
  20586. },{"../internals/function-uncurry-this":341,"../internals/is-callable":360,"../internals/shared-store":417}],355:[function(_dereq_,module,exports){
  20587. var isObject = _dereq_('../internals/is-object');
  20588. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  20589. // `InstallErrorCause` abstract operation
  20590. // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
  20591. module.exports = function (O, options) {
  20592. if (isObject(options) && 'cause' in options) {
  20593. createNonEnumerableProperty(O, 'cause', options.cause);
  20594. }
  20595. };
  20596. },{"../internals/create-non-enumerable-property":306,"../internals/is-object":366}],356:[function(_dereq_,module,exports){
  20597. var $ = _dereq_('../internals/export');
  20598. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20599. var hiddenKeys = _dereq_('../internals/hidden-keys');
  20600. var isObject = _dereq_('../internals/is-object');
  20601. var hasOwn = _dereq_('../internals/has-own-property');
  20602. var defineProperty = _dereq_('../internals/object-define-property').f;
  20603. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  20604. var getOwnPropertyNamesExternalModule = _dereq_('../internals/object-get-own-property-names-external');
  20605. var isExtensible = _dereq_('../internals/object-is-extensible');
  20606. var uid = _dereq_('../internals/uid');
  20607. var FREEZING = _dereq_('../internals/freezing');
  20608. var REQUIRED = false;
  20609. var METADATA = uid('meta');
  20610. var id = 0;
  20611. var setMetadata = function (it) {
  20612. defineProperty(it, METADATA, { value: {
  20613. objectID: 'O' + id++, // object ID
  20614. weakData: {} // weak collections IDs
  20615. } });
  20616. };
  20617. var fastKey = function (it, create) {
  20618. // return a primitive with prefix
  20619. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  20620. if (!hasOwn(it, METADATA)) {
  20621. // can't set metadata to uncaught frozen object
  20622. if (!isExtensible(it)) return 'F';
  20623. // not necessary to add metadata
  20624. if (!create) return 'E';
  20625. // add missing metadata
  20626. setMetadata(it);
  20627. // return object ID
  20628. } return it[METADATA].objectID;
  20629. };
  20630. var getWeakData = function (it, create) {
  20631. if (!hasOwn(it, METADATA)) {
  20632. // can't set metadata to uncaught frozen object
  20633. if (!isExtensible(it)) return true;
  20634. // not necessary to add metadata
  20635. if (!create) return false;
  20636. // add missing metadata
  20637. setMetadata(it);
  20638. // return the store of weak collections IDs
  20639. } return it[METADATA].weakData;
  20640. };
  20641. // add metadata on freeze-family methods calling
  20642. var onFreeze = function (it) {
  20643. if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it);
  20644. return it;
  20645. };
  20646. var enable = function () {
  20647. meta.enable = function () { /* empty */ };
  20648. REQUIRED = true;
  20649. var getOwnPropertyNames = getOwnPropertyNamesModule.f;
  20650. var splice = uncurryThis([].splice);
  20651. var test = {};
  20652. test[METADATA] = 1;
  20653. // prevent exposing of metadata key
  20654. if (getOwnPropertyNames(test).length) {
  20655. getOwnPropertyNamesModule.f = function (it) {
  20656. var result = getOwnPropertyNames(it);
  20657. for (var i = 0, length = result.length; i < length; i++) {
  20658. if (result[i] === METADATA) {
  20659. splice(result, i, 1);
  20660. break;
  20661. }
  20662. } return result;
  20663. };
  20664. $({ target: 'Object', stat: true, forced: true }, {
  20665. getOwnPropertyNames: getOwnPropertyNamesExternalModule.f
  20666. });
  20667. }
  20668. };
  20669. var meta = module.exports = {
  20670. enable: enable,
  20671. fastKey: fastKey,
  20672. getWeakData: getWeakData,
  20673. onFreeze: onFreeze
  20674. };
  20675. hiddenKeys[METADATA] = true;
  20676. },{"../internals/export":332,"../internals/freezing":334,"../internals/function-uncurry-this":341,"../internals/has-own-property":348,"../internals/hidden-keys":349,"../internals/is-object":366,"../internals/object-define-property":388,"../internals/object-get-own-property-names":391,"../internals/object-get-own-property-names-external":390,"../internals/object-is-extensible":394,"../internals/uid":436}],357:[function(_dereq_,module,exports){
  20677. var NATIVE_WEAK_MAP = _dereq_('../internals/weak-map-basic-detection');
  20678. var global = _dereq_('../internals/global');
  20679. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20680. var isObject = _dereq_('../internals/is-object');
  20681. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  20682. var hasOwn = _dereq_('../internals/has-own-property');
  20683. var shared = _dereq_('../internals/shared-store');
  20684. var sharedKey = _dereq_('../internals/shared-key');
  20685. var hiddenKeys = _dereq_('../internals/hidden-keys');
  20686. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  20687. var TypeError = global.TypeError;
  20688. var WeakMap = global.WeakMap;
  20689. var set, get, has;
  20690. var enforce = function (it) {
  20691. return has(it) ? get(it) : set(it, {});
  20692. };
  20693. var getterFor = function (TYPE) {
  20694. return function (it) {
  20695. var state;
  20696. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  20697. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  20698. } return state;
  20699. };
  20700. };
  20701. if (NATIVE_WEAK_MAP || shared.state) {
  20702. var store = shared.state || (shared.state = new WeakMap());
  20703. var wmget = uncurryThis(store.get);
  20704. var wmhas = uncurryThis(store.has);
  20705. var wmset = uncurryThis(store.set);
  20706. set = function (it, metadata) {
  20707. if (wmhas(store, it)) throw TypeError(OBJECT_ALREADY_INITIALIZED);
  20708. metadata.facade = it;
  20709. wmset(store, it, metadata);
  20710. return metadata;
  20711. };
  20712. get = function (it) {
  20713. return wmget(store, it) || {};
  20714. };
  20715. has = function (it) {
  20716. return wmhas(store, it);
  20717. };
  20718. } else {
  20719. var STATE = sharedKey('state');
  20720. hiddenKeys[STATE] = true;
  20721. set = function (it, metadata) {
  20722. if (hasOwn(it, STATE)) throw TypeError(OBJECT_ALREADY_INITIALIZED);
  20723. metadata.facade = it;
  20724. createNonEnumerableProperty(it, STATE, metadata);
  20725. return metadata;
  20726. };
  20727. get = function (it) {
  20728. return hasOwn(it, STATE) ? it[STATE] : {};
  20729. };
  20730. has = function (it) {
  20731. return hasOwn(it, STATE);
  20732. };
  20733. }
  20734. module.exports = {
  20735. set: set,
  20736. get: get,
  20737. has: has,
  20738. enforce: enforce,
  20739. getterFor: getterFor
  20740. };
  20741. },{"../internals/create-non-enumerable-property":306,"../internals/function-uncurry-this":341,"../internals/global":347,"../internals/has-own-property":348,"../internals/hidden-keys":349,"../internals/is-object":366,"../internals/shared-key":416,"../internals/shared-store":417,"../internals/weak-map-basic-detection":440}],358:[function(_dereq_,module,exports){
  20742. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20743. var Iterators = _dereq_('../internals/iterators');
  20744. var ITERATOR = wellKnownSymbol('iterator');
  20745. var ArrayPrototype = Array.prototype;
  20746. // check on default Array iterator
  20747. module.exports = function (it) {
  20748. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  20749. };
  20750. },{"../internals/iterators":375,"../internals/well-known-symbol":443}],359:[function(_dereq_,module,exports){
  20751. var classof = _dereq_('../internals/classof-raw');
  20752. // `IsArray` abstract operation
  20753. // https://tc39.es/ecma262/#sec-isarray
  20754. // eslint-disable-next-line es-x/no-array-isarray -- safe
  20755. module.exports = Array.isArray || function isArray(argument) {
  20756. return classof(argument) == 'Array';
  20757. };
  20758. },{"../internals/classof-raw":294}],360:[function(_dereq_,module,exports){
  20759. // `IsCallable` abstract operation
  20760. // https://tc39.es/ecma262/#sec-iscallable
  20761. module.exports = function (argument) {
  20762. return typeof argument == 'function';
  20763. };
  20764. },{}],361:[function(_dereq_,module,exports){
  20765. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  20766. var fails = _dereq_('../internals/fails');
  20767. var isCallable = _dereq_('../internals/is-callable');
  20768. var classof = _dereq_('../internals/classof');
  20769. var getBuiltIn = _dereq_('../internals/get-built-in');
  20770. var inspectSource = _dereq_('../internals/inspect-source');
  20771. var noop = function () { /* empty */ };
  20772. var empty = [];
  20773. var construct = getBuiltIn('Reflect', 'construct');
  20774. var constructorRegExp = /^\s*(?:class|function)\b/;
  20775. var exec = uncurryThis(constructorRegExp.exec);
  20776. var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
  20777. var isConstructorModern = function isConstructor(argument) {
  20778. if (!isCallable(argument)) return false;
  20779. try {
  20780. construct(noop, empty, argument);
  20781. return true;
  20782. } catch (error) {
  20783. return false;
  20784. }
  20785. };
  20786. var isConstructorLegacy = function isConstructor(argument) {
  20787. if (!isCallable(argument)) return false;
  20788. switch (classof(argument)) {
  20789. case 'AsyncFunction':
  20790. case 'GeneratorFunction':
  20791. case 'AsyncGeneratorFunction': return false;
  20792. }
  20793. try {
  20794. // we can't check .prototype since constructors produced by .bind haven't it
  20795. // `Function#toString` throws on some built-it function in some legacy engines
  20796. // (for example, `DOMQuad` and similar in FF41-)
  20797. return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
  20798. } catch (error) {
  20799. return true;
  20800. }
  20801. };
  20802. isConstructorLegacy.sham = true;
  20803. // `IsConstructor` abstract operation
  20804. // https://tc39.es/ecma262/#sec-isconstructor
  20805. module.exports = !construct || fails(function () {
  20806. var called;
  20807. return isConstructorModern(isConstructorModern.call)
  20808. || !isConstructorModern(Object)
  20809. || !isConstructorModern(function () { called = true; })
  20810. || called;
  20811. }) ? isConstructorLegacy : isConstructorModern;
  20812. },{"../internals/classof":295,"../internals/fails":333,"../internals/function-uncurry-this":341,"../internals/get-built-in":342,"../internals/inspect-source":354,"../internals/is-callable":360}],362:[function(_dereq_,module,exports){
  20813. var hasOwn = _dereq_('../internals/has-own-property');
  20814. module.exports = function (descriptor) {
  20815. return descriptor !== undefined && (hasOwn(descriptor, 'value') || hasOwn(descriptor, 'writable'));
  20816. };
  20817. },{"../internals/has-own-property":348}],363:[function(_dereq_,module,exports){
  20818. var fails = _dereq_('../internals/fails');
  20819. var isCallable = _dereq_('../internals/is-callable');
  20820. var replacement = /#|\.prototype\./;
  20821. var isForced = function (feature, detection) {
  20822. var value = data[normalize(feature)];
  20823. return value == POLYFILL ? true
  20824. : value == NATIVE ? false
  20825. : isCallable(detection) ? fails(detection)
  20826. : !!detection;
  20827. };
  20828. var normalize = isForced.normalize = function (string) {
  20829. return String(string).replace(replacement, '.').toLowerCase();
  20830. };
  20831. var data = isForced.data = {};
  20832. var NATIVE = isForced.NATIVE = 'N';
  20833. var POLYFILL = isForced.POLYFILL = 'P';
  20834. module.exports = isForced;
  20835. },{"../internals/fails":333,"../internals/is-callable":360}],364:[function(_dereq_,module,exports){
  20836. var isObject = _dereq_('../internals/is-object');
  20837. var floor = Math.floor;
  20838. // `IsIntegralNumber` abstract operation
  20839. // https://tc39.es/ecma262/#sec-isintegralnumber
  20840. // eslint-disable-next-line es-x/no-number-isinteger -- safe
  20841. module.exports = Number.isInteger || function isInteger(it) {
  20842. return !isObject(it) && isFinite(it) && floor(it) === it;
  20843. };
  20844. },{"../internals/is-object":366}],365:[function(_dereq_,module,exports){
  20845. // we can't use just `it == null` since of `document.all` special case
  20846. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
  20847. module.exports = function (it) {
  20848. return it === null || it === undefined;
  20849. };
  20850. },{}],366:[function(_dereq_,module,exports){
  20851. var isCallable = _dereq_('../internals/is-callable');
  20852. var documentAll = typeof document == 'object' && document.all;
  20853. // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
  20854. var SPECIAL_DOCUMENT_ALL = typeof documentAll == 'undefined' && documentAll !== undefined;
  20855. module.exports = SPECIAL_DOCUMENT_ALL ? function (it) {
  20856. return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll;
  20857. } : function (it) {
  20858. return typeof it == 'object' ? it !== null : isCallable(it);
  20859. };
  20860. },{"../internals/is-callable":360}],367:[function(_dereq_,module,exports){
  20861. module.exports = true;
  20862. },{}],368:[function(_dereq_,module,exports){
  20863. var isObject = _dereq_('../internals/is-object');
  20864. var classof = _dereq_('../internals/classof-raw');
  20865. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20866. var MATCH = wellKnownSymbol('match');
  20867. // `IsRegExp` abstract operation
  20868. // https://tc39.es/ecma262/#sec-isregexp
  20869. module.exports = function (it) {
  20870. var isRegExp;
  20871. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
  20872. };
  20873. },{"../internals/classof-raw":294,"../internals/is-object":366,"../internals/well-known-symbol":443}],369:[function(_dereq_,module,exports){
  20874. var getBuiltIn = _dereq_('../internals/get-built-in');
  20875. var isCallable = _dereq_('../internals/is-callable');
  20876. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  20877. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  20878. var $Object = Object;
  20879. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  20880. return typeof it == 'symbol';
  20881. } : function (it) {
  20882. var $Symbol = getBuiltIn('Symbol');
  20883. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  20884. };
  20885. },{"../internals/get-built-in":342,"../internals/is-callable":360,"../internals/object-is-prototype-of":395,"../internals/use-symbol-as-uid":437}],370:[function(_dereq_,module,exports){
  20886. var bind = _dereq_('../internals/function-bind-context');
  20887. var call = _dereq_('../internals/function-call');
  20888. var anObject = _dereq_('../internals/an-object');
  20889. var tryToString = _dereq_('../internals/try-to-string');
  20890. var isArrayIteratorMethod = _dereq_('../internals/is-array-iterator-method');
  20891. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  20892. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  20893. var getIterator = _dereq_('../internals/get-iterator');
  20894. var getIteratorMethod = _dereq_('../internals/get-iterator-method');
  20895. var iteratorClose = _dereq_('../internals/iterator-close');
  20896. var $TypeError = TypeError;
  20897. var Result = function (stopped, result) {
  20898. this.stopped = stopped;
  20899. this.result = result;
  20900. };
  20901. var ResultPrototype = Result.prototype;
  20902. module.exports = function (iterable, unboundFunction, options) {
  20903. var that = options && options.that;
  20904. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  20905. var IS_RECORD = !!(options && options.IS_RECORD);
  20906. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  20907. var INTERRUPTED = !!(options && options.INTERRUPTED);
  20908. var fn = bind(unboundFunction, that);
  20909. var iterator, iterFn, index, length, result, next, step;
  20910. var stop = function (condition) {
  20911. if (iterator) iteratorClose(iterator, 'normal', condition);
  20912. return new Result(true, condition);
  20913. };
  20914. var callFn = function (value) {
  20915. if (AS_ENTRIES) {
  20916. anObject(value);
  20917. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  20918. } return INTERRUPTED ? fn(value, stop) : fn(value);
  20919. };
  20920. if (IS_RECORD) {
  20921. iterator = iterable.iterator;
  20922. } else if (IS_ITERATOR) {
  20923. iterator = iterable;
  20924. } else {
  20925. iterFn = getIteratorMethod(iterable);
  20926. if (!iterFn) throw $TypeError(tryToString(iterable) + ' is not iterable');
  20927. // optimisation for array iterators
  20928. if (isArrayIteratorMethod(iterFn)) {
  20929. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  20930. result = callFn(iterable[index]);
  20931. if (result && isPrototypeOf(ResultPrototype, result)) return result;
  20932. } return new Result(false);
  20933. }
  20934. iterator = getIterator(iterable, iterFn);
  20935. }
  20936. next = IS_RECORD ? iterable.next : iterator.next;
  20937. while (!(step = call(next, iterator)).done) {
  20938. try {
  20939. result = callFn(step.value);
  20940. } catch (error) {
  20941. iteratorClose(iterator, 'throw', error);
  20942. }
  20943. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
  20944. } return new Result(false);
  20945. };
  20946. },{"../internals/an-object":277,"../internals/function-bind-context":336,"../internals/function-call":339,"../internals/get-iterator":344,"../internals/get-iterator-method":343,"../internals/is-array-iterator-method":358,"../internals/iterator-close":371,"../internals/length-of-array-like":376,"../internals/object-is-prototype-of":395,"../internals/try-to-string":435}],371:[function(_dereq_,module,exports){
  20947. var call = _dereq_('../internals/function-call');
  20948. var anObject = _dereq_('../internals/an-object');
  20949. var getMethod = _dereq_('../internals/get-method');
  20950. module.exports = function (iterator, kind, value) {
  20951. var innerResult, innerError;
  20952. anObject(iterator);
  20953. try {
  20954. innerResult = getMethod(iterator, 'return');
  20955. if (!innerResult) {
  20956. if (kind === 'throw') throw value;
  20957. return value;
  20958. }
  20959. innerResult = call(innerResult, iterator);
  20960. } catch (error) {
  20961. innerError = true;
  20962. innerResult = error;
  20963. }
  20964. if (kind === 'throw') throw value;
  20965. if (innerError) throw innerResult;
  20966. anObject(innerResult);
  20967. return value;
  20968. };
  20969. },{"../internals/an-object":277,"../internals/function-call":339,"../internals/get-method":346}],372:[function(_dereq_,module,exports){
  20970. 'use strict';
  20971. var IteratorPrototype = _dereq_('../internals/iterators-core').IteratorPrototype;
  20972. var create = _dereq_('../internals/object-create');
  20973. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  20974. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  20975. var Iterators = _dereq_('../internals/iterators');
  20976. var returnThis = function () { return this; };
  20977. module.exports = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
  20978. var TO_STRING_TAG = NAME + ' Iterator';
  20979. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
  20980. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  20981. Iterators[TO_STRING_TAG] = returnThis;
  20982. return IteratorConstructor;
  20983. };
  20984. },{"../internals/create-property-descriptor":307,"../internals/iterators":375,"../internals/iterators-core":374,"../internals/object-create":386,"../internals/set-to-string-tag":415}],373:[function(_dereq_,module,exports){
  20985. 'use strict';
  20986. var $ = _dereq_('../internals/export');
  20987. var call = _dereq_('../internals/function-call');
  20988. var IS_PURE = _dereq_('../internals/is-pure');
  20989. var FunctionName = _dereq_('../internals/function-name');
  20990. var isCallable = _dereq_('../internals/is-callable');
  20991. var createIteratorConstructor = _dereq_('../internals/iterator-create-constructor');
  20992. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  20993. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  20994. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  20995. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  20996. var defineBuiltIn = _dereq_('../internals/define-built-in');
  20997. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  20998. var Iterators = _dereq_('../internals/iterators');
  20999. var IteratorsCore = _dereq_('../internals/iterators-core');
  21000. var PROPER_FUNCTION_NAME = FunctionName.PROPER;
  21001. var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
  21002. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  21003. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  21004. var ITERATOR = wellKnownSymbol('iterator');
  21005. var KEYS = 'keys';
  21006. var VALUES = 'values';
  21007. var ENTRIES = 'entries';
  21008. var returnThis = function () { return this; };
  21009. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  21010. createIteratorConstructor(IteratorConstructor, NAME, next);
  21011. var getIterationMethod = function (KIND) {
  21012. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  21013. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
  21014. switch (KIND) {
  21015. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  21016. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  21017. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  21018. } return function () { return new IteratorConstructor(this); };
  21019. };
  21020. var TO_STRING_TAG = NAME + ' Iterator';
  21021. var INCORRECT_VALUES_NAME = false;
  21022. var IterablePrototype = Iterable.prototype;
  21023. var nativeIterator = IterablePrototype[ITERATOR]
  21024. || IterablePrototype['@@iterator']
  21025. || DEFAULT && IterablePrototype[DEFAULT];
  21026. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  21027. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  21028. var CurrentIteratorPrototype, methods, KEY;
  21029. // fix native
  21030. if (anyNativeIterator) {
  21031. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  21032. if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  21033. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  21034. if (setPrototypeOf) {
  21035. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  21036. } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
  21037. defineBuiltIn(CurrentIteratorPrototype, ITERATOR, returnThis);
  21038. }
  21039. }
  21040. // Set @@toStringTag to native iterators
  21041. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  21042. if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
  21043. }
  21044. }
  21045. // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
  21046. if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  21047. if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) {
  21048. createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
  21049. } else {
  21050. INCORRECT_VALUES_NAME = true;
  21051. defaultIterator = function values() { return call(nativeIterator, this); };
  21052. }
  21053. }
  21054. // export additional methods
  21055. if (DEFAULT) {
  21056. methods = {
  21057. values: getIterationMethod(VALUES),
  21058. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  21059. entries: getIterationMethod(ENTRIES)
  21060. };
  21061. if (FORCED) for (KEY in methods) {
  21062. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  21063. defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
  21064. }
  21065. } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
  21066. }
  21067. // define iterator
  21068. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  21069. defineBuiltIn(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });
  21070. }
  21071. Iterators[NAME] = defaultIterator;
  21072. return methods;
  21073. };
  21074. },{"../internals/create-non-enumerable-property":306,"../internals/define-built-in":309,"../internals/export":332,"../internals/function-call":339,"../internals/function-name":340,"../internals/is-callable":360,"../internals/is-pure":367,"../internals/iterator-create-constructor":372,"../internals/iterators":375,"../internals/iterators-core":374,"../internals/object-get-prototype-of":393,"../internals/object-set-prototype-of":399,"../internals/set-to-string-tag":415,"../internals/well-known-symbol":443}],374:[function(_dereq_,module,exports){
  21075. 'use strict';
  21076. var fails = _dereq_('../internals/fails');
  21077. var isCallable = _dereq_('../internals/is-callable');
  21078. var isObject = _dereq_('../internals/is-object');
  21079. var create = _dereq_('../internals/object-create');
  21080. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  21081. var defineBuiltIn = _dereq_('../internals/define-built-in');
  21082. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  21083. var IS_PURE = _dereq_('../internals/is-pure');
  21084. var ITERATOR = wellKnownSymbol('iterator');
  21085. var BUGGY_SAFARI_ITERATORS = false;
  21086. // `%IteratorPrototype%` object
  21087. // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
  21088. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  21089. /* eslint-disable es-x/no-array-prototype-keys -- safe */
  21090. if ([].keys) {
  21091. arrayIterator = [].keys();
  21092. // Safari 8 has buggy iterators w/o `next`
  21093. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  21094. else {
  21095. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  21096. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  21097. }
  21098. }
  21099. var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () {
  21100. var test = {};
  21101. // FF44- legacy iterators case
  21102. return IteratorPrototype[ITERATOR].call(test) !== test;
  21103. });
  21104. if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
  21105. else if (IS_PURE) IteratorPrototype = create(IteratorPrototype);
  21106. // `%IteratorPrototype%[@@iterator]()` method
  21107. // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
  21108. if (!isCallable(IteratorPrototype[ITERATOR])) {
  21109. defineBuiltIn(IteratorPrototype, ITERATOR, function () {
  21110. return this;
  21111. });
  21112. }
  21113. module.exports = {
  21114. IteratorPrototype: IteratorPrototype,
  21115. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  21116. };
  21117. },{"../internals/define-built-in":309,"../internals/fails":333,"../internals/is-callable":360,"../internals/is-object":366,"../internals/is-pure":367,"../internals/object-create":386,"../internals/object-get-prototype-of":393,"../internals/well-known-symbol":443}],375:[function(_dereq_,module,exports){
  21118. arguments[4][349][0].apply(exports,arguments)
  21119. },{"dup":349}],376:[function(_dereq_,module,exports){
  21120. var toLength = _dereq_('../internals/to-length');
  21121. // `LengthOfArrayLike` abstract operation
  21122. // https://tc39.es/ecma262/#sec-lengthofarraylike
  21123. module.exports = function (obj) {
  21124. return toLength(obj.length);
  21125. };
  21126. },{"../internals/to-length":429}],377:[function(_dereq_,module,exports){
  21127. 'use strict';
  21128. var call = _dereq_('../internals/function-call');
  21129. var aCallable = _dereq_('../internals/a-callable');
  21130. var anObject = _dereq_('../internals/an-object');
  21131. // `Map.prototype.emplace` method
  21132. // https://github.com/thumbsupep/proposal-upsert
  21133. module.exports = function emplace(key, handler) {
  21134. var map = anObject(this);
  21135. var get = aCallable(map.get);
  21136. var has = aCallable(map.has);
  21137. var set = aCallable(map.set);
  21138. var value, inserted;
  21139. if (call(has, map, key)) {
  21140. value = call(get, map, key);
  21141. if ('update' in handler) {
  21142. value = handler.update(value, key, map);
  21143. call(set, map, key, value);
  21144. } return value;
  21145. }
  21146. inserted = handler.insert(key, map);
  21147. call(set, map, key, inserted);
  21148. return inserted;
  21149. };
  21150. },{"../internals/a-callable":272,"../internals/an-object":277,"../internals/function-call":339}],378:[function(_dereq_,module,exports){
  21151. 'use strict';
  21152. var call = _dereq_('../internals/function-call');
  21153. var aCallable = _dereq_('../internals/a-callable');
  21154. var isCallable = _dereq_('../internals/is-callable');
  21155. var anObject = _dereq_('../internals/an-object');
  21156. var $TypeError = TypeError;
  21157. // `Map.prototype.upsert` method
  21158. // https://github.com/thumbsupep/proposal-upsert
  21159. module.exports = function upsert(key, updateFn /* , insertFn */) {
  21160. var map = anObject(this);
  21161. var get = aCallable(map.get);
  21162. var has = aCallable(map.has);
  21163. var set = aCallable(map.set);
  21164. var insertFn = arguments.length > 2 ? arguments[2] : undefined;
  21165. var value;
  21166. if (!isCallable(updateFn) && !isCallable(insertFn)) {
  21167. throw $TypeError('At least one callback required');
  21168. }
  21169. if (call(has, map, key)) {
  21170. value = call(get, map, key);
  21171. if (isCallable(updateFn)) {
  21172. value = updateFn(value);
  21173. call(set, map, key, value);
  21174. }
  21175. } else if (isCallable(insertFn)) {
  21176. value = insertFn();
  21177. call(set, map, key, value);
  21178. } return value;
  21179. };
  21180. },{"../internals/a-callable":272,"../internals/an-object":277,"../internals/function-call":339,"../internals/is-callable":360}],379:[function(_dereq_,module,exports){
  21181. var ceil = Math.ceil;
  21182. var floor = Math.floor;
  21183. // `Math.trunc` method
  21184. // https://tc39.es/ecma262/#sec-math.trunc
  21185. // eslint-disable-next-line es-x/no-math-trunc -- safe
  21186. module.exports = Math.trunc || function trunc(x) {
  21187. var n = +x;
  21188. return (n > 0 ? floor : ceil)(n);
  21189. };
  21190. },{}],380:[function(_dereq_,module,exports){
  21191. var global = _dereq_('../internals/global');
  21192. var bind = _dereq_('../internals/function-bind-context');
  21193. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  21194. var macrotask = _dereq_('../internals/task').set;
  21195. var IS_IOS = _dereq_('../internals/engine-is-ios');
  21196. var IS_IOS_PEBBLE = _dereq_('../internals/engine-is-ios-pebble');
  21197. var IS_WEBOS_WEBKIT = _dereq_('../internals/engine-is-webos-webkit');
  21198. var IS_NODE = _dereq_('../internals/engine-is-node');
  21199. var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
  21200. var document = global.document;
  21201. var process = global.process;
  21202. var Promise = global.Promise;
  21203. // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
  21204. var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
  21205. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  21206. var flush, head, last, notify, toggle, node, promise, then;
  21207. // modern engines have queueMicrotask method
  21208. if (!queueMicrotask) {
  21209. flush = function () {
  21210. var parent, fn;
  21211. if (IS_NODE && (parent = process.domain)) parent.exit();
  21212. while (head) {
  21213. fn = head.fn;
  21214. head = head.next;
  21215. try {
  21216. fn();
  21217. } catch (error) {
  21218. if (head) notify();
  21219. else last = undefined;
  21220. throw error;
  21221. }
  21222. } last = undefined;
  21223. if (parent) parent.enter();
  21224. };
  21225. // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
  21226. // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
  21227. if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {
  21228. toggle = true;
  21229. node = document.createTextNode('');
  21230. new MutationObserver(flush).observe(node, { characterData: true });
  21231. notify = function () {
  21232. node.data = toggle = !toggle;
  21233. };
  21234. // environments with maybe non-completely correct, but existent Promise
  21235. } else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) {
  21236. // Promise.resolve without an argument throws an error in LG WebOS 2
  21237. promise = Promise.resolve(undefined);
  21238. // workaround of WebKit ~ iOS Safari 10.1 bug
  21239. promise.constructor = Promise;
  21240. then = bind(promise.then, promise);
  21241. notify = function () {
  21242. then(flush);
  21243. };
  21244. // Node.js without promises
  21245. } else if (IS_NODE) {
  21246. notify = function () {
  21247. process.nextTick(flush);
  21248. };
  21249. // for other environments - macrotask based on:
  21250. // - setImmediate
  21251. // - MessageChannel
  21252. // - window.postMessage
  21253. // - onreadystatechange
  21254. // - setTimeout
  21255. } else {
  21256. // strange IE + webpack dev server bug - use .bind(global)
  21257. macrotask = bind(macrotask, global);
  21258. notify = function () {
  21259. macrotask(flush);
  21260. };
  21261. }
  21262. }
  21263. module.exports = queueMicrotask || function (fn) {
  21264. var task = { fn: fn, next: undefined };
  21265. if (last) last.next = task;
  21266. if (!head) {
  21267. head = task;
  21268. notify();
  21269. } last = task;
  21270. };
  21271. },{"../internals/engine-is-ios":322,"../internals/engine-is-ios-pebble":321,"../internals/engine-is-node":323,"../internals/engine-is-webos-webkit":324,"../internals/function-bind-context":336,"../internals/global":347,"../internals/object-get-own-property-descriptor":389,"../internals/task":425}],381:[function(_dereq_,module,exports){
  21272. 'use strict';
  21273. var aCallable = _dereq_('../internals/a-callable');
  21274. var $TypeError = TypeError;
  21275. var PromiseCapability = function (C) {
  21276. var resolve, reject;
  21277. this.promise = new C(function ($$resolve, $$reject) {
  21278. if (resolve !== undefined || reject !== undefined) throw $TypeError('Bad Promise constructor');
  21279. resolve = $$resolve;
  21280. reject = $$reject;
  21281. });
  21282. this.resolve = aCallable(resolve);
  21283. this.reject = aCallable(reject);
  21284. };
  21285. // `NewPromiseCapability` abstract operation
  21286. // https://tc39.es/ecma262/#sec-newpromisecapability
  21287. module.exports.f = function (C) {
  21288. return new PromiseCapability(C);
  21289. };
  21290. },{"../internals/a-callable":272}],382:[function(_dereq_,module,exports){
  21291. var toString = _dereq_('../internals/to-string');
  21292. module.exports = function (argument, $default) {
  21293. return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
  21294. };
  21295. },{"../internals/to-string":434}],383:[function(_dereq_,module,exports){
  21296. var isRegExp = _dereq_('../internals/is-regexp');
  21297. var $TypeError = TypeError;
  21298. module.exports = function (it) {
  21299. if (isRegExp(it)) {
  21300. throw $TypeError("The method doesn't accept regular expressions");
  21301. } return it;
  21302. };
  21303. },{"../internals/is-regexp":368}],384:[function(_dereq_,module,exports){
  21304. var global = _dereq_('../internals/global');
  21305. var fails = _dereq_('../internals/fails');
  21306. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21307. var toString = _dereq_('../internals/to-string');
  21308. var trim = _dereq_('../internals/string-trim').trim;
  21309. var whitespaces = _dereq_('../internals/whitespaces');
  21310. var $parseInt = global.parseInt;
  21311. var Symbol = global.Symbol;
  21312. var ITERATOR = Symbol && Symbol.iterator;
  21313. var hex = /^[+-]?0x/i;
  21314. var exec = uncurryThis(hex.exec);
  21315. var FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22
  21316. // MS Edge 18- broken with boxed symbols
  21317. || (ITERATOR && !fails(function () { $parseInt(Object(ITERATOR)); }));
  21318. // `parseInt` method
  21319. // https://tc39.es/ecma262/#sec-parseint-string-radix
  21320. module.exports = FORCED ? function parseInt(string, radix) {
  21321. var S = trim(toString(string));
  21322. return $parseInt(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10));
  21323. } : $parseInt;
  21324. },{"../internals/fails":333,"../internals/function-uncurry-this":341,"../internals/global":347,"../internals/string-trim":421,"../internals/to-string":434,"../internals/whitespaces":444}],385:[function(_dereq_,module,exports){
  21325. 'use strict';
  21326. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21327. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21328. var call = _dereq_('../internals/function-call');
  21329. var fails = _dereq_('../internals/fails');
  21330. var objectKeys = _dereq_('../internals/object-keys');
  21331. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  21332. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  21333. var toObject = _dereq_('../internals/to-object');
  21334. var IndexedObject = _dereq_('../internals/indexed-object');
  21335. // eslint-disable-next-line es-x/no-object-assign -- safe
  21336. var $assign = Object.assign;
  21337. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  21338. var defineProperty = Object.defineProperty;
  21339. var concat = uncurryThis([].concat);
  21340. // `Object.assign` method
  21341. // https://tc39.es/ecma262/#sec-object.assign
  21342. module.exports = !$assign || fails(function () {
  21343. // should have correct order of operations (Edge bug)
  21344. if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
  21345. enumerable: true,
  21346. get: function () {
  21347. defineProperty(this, 'b', {
  21348. value: 3,
  21349. enumerable: false
  21350. });
  21351. }
  21352. }), { b: 2 })).b !== 1) return true;
  21353. // should work with symbols and should have deterministic property order (V8 bug)
  21354. var A = {};
  21355. var B = {};
  21356. // eslint-disable-next-line es-x/no-symbol -- safe
  21357. var symbol = Symbol();
  21358. var alphabet = 'abcdefghijklmnopqrst';
  21359. A[symbol] = 7;
  21360. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  21361. return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet;
  21362. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
  21363. var T = toObject(target);
  21364. var argumentsLength = arguments.length;
  21365. var index = 1;
  21366. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  21367. var propertyIsEnumerable = propertyIsEnumerableModule.f;
  21368. while (argumentsLength > index) {
  21369. var S = IndexedObject(arguments[index++]);
  21370. var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
  21371. var length = keys.length;
  21372. var j = 0;
  21373. var key;
  21374. while (length > j) {
  21375. key = keys[j++];
  21376. if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
  21377. }
  21378. } return T;
  21379. } : $assign;
  21380. },{"../internals/descriptors":313,"../internals/fails":333,"../internals/function-call":339,"../internals/function-uncurry-this":341,"../internals/indexed-object":353,"../internals/object-get-own-property-symbols":392,"../internals/object-keys":397,"../internals/object-property-is-enumerable":398,"../internals/to-object":430}],386:[function(_dereq_,module,exports){
  21381. /* global ActiveXObject -- old IE, WSH */
  21382. var anObject = _dereq_('../internals/an-object');
  21383. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  21384. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  21385. var hiddenKeys = _dereq_('../internals/hidden-keys');
  21386. var html = _dereq_('../internals/html');
  21387. var documentCreateElement = _dereq_('../internals/document-create-element');
  21388. var sharedKey = _dereq_('../internals/shared-key');
  21389. var GT = '>';
  21390. var LT = '<';
  21391. var PROTOTYPE = 'prototype';
  21392. var SCRIPT = 'script';
  21393. var IE_PROTO = sharedKey('IE_PROTO');
  21394. var EmptyConstructor = function () { /* empty */ };
  21395. var scriptTag = function (content) {
  21396. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  21397. };
  21398. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  21399. var NullProtoObjectViaActiveX = function (activeXDocument) {
  21400. activeXDocument.write(scriptTag(''));
  21401. activeXDocument.close();
  21402. var temp = activeXDocument.parentWindow.Object;
  21403. activeXDocument = null; // avoid memory leak
  21404. return temp;
  21405. };
  21406. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  21407. var NullProtoObjectViaIFrame = function () {
  21408. // Thrash, waste and sodomy: IE GC bug
  21409. var iframe = documentCreateElement('iframe');
  21410. var JS = 'java' + SCRIPT + ':';
  21411. var iframeDocument;
  21412. iframe.style.display = 'none';
  21413. html.appendChild(iframe);
  21414. // https://github.com/zloirock/core-js/issues/475
  21415. iframe.src = String(JS);
  21416. iframeDocument = iframe.contentWindow.document;
  21417. iframeDocument.open();
  21418. iframeDocument.write(scriptTag('document.F=Object'));
  21419. iframeDocument.close();
  21420. return iframeDocument.F;
  21421. };
  21422. // Check for document.domain and active x support
  21423. // No need to use active x approach when document.domain is not set
  21424. // see https://github.com/es-shims/es5-shim/issues/150
  21425. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  21426. // avoid IE GC bug
  21427. var activeXDocument;
  21428. var NullProtoObject = function () {
  21429. try {
  21430. activeXDocument = new ActiveXObject('htmlfile');
  21431. } catch (error) { /* ignore */ }
  21432. NullProtoObject = typeof document != 'undefined'
  21433. ? document.domain && activeXDocument
  21434. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  21435. : NullProtoObjectViaIFrame()
  21436. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  21437. var length = enumBugKeys.length;
  21438. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  21439. return NullProtoObject();
  21440. };
  21441. hiddenKeys[IE_PROTO] = true;
  21442. // `Object.create` method
  21443. // https://tc39.es/ecma262/#sec-object.create
  21444. // eslint-disable-next-line es-x/no-object-create -- safe
  21445. module.exports = Object.create || function create(O, Properties) {
  21446. var result;
  21447. if (O !== null) {
  21448. EmptyConstructor[PROTOTYPE] = anObject(O);
  21449. result = new EmptyConstructor();
  21450. EmptyConstructor[PROTOTYPE] = null;
  21451. // add "__proto__" for Object.getPrototypeOf polyfill
  21452. result[IE_PROTO] = O;
  21453. } else result = NullProtoObject();
  21454. return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
  21455. };
  21456. },{"../internals/an-object":277,"../internals/document-create-element":314,"../internals/enum-bug-keys":329,"../internals/hidden-keys":349,"../internals/html":351,"../internals/object-define-properties":387,"../internals/shared-key":416}],387:[function(_dereq_,module,exports){
  21457. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21458. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  21459. var definePropertyModule = _dereq_('../internals/object-define-property');
  21460. var anObject = _dereq_('../internals/an-object');
  21461. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  21462. var objectKeys = _dereq_('../internals/object-keys');
  21463. // `Object.defineProperties` method
  21464. // https://tc39.es/ecma262/#sec-object.defineproperties
  21465. // eslint-disable-next-line es-x/no-object-defineproperties -- safe
  21466. exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
  21467. anObject(O);
  21468. var props = toIndexedObject(Properties);
  21469. var keys = objectKeys(Properties);
  21470. var length = keys.length;
  21471. var index = 0;
  21472. var key;
  21473. while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
  21474. return O;
  21475. };
  21476. },{"../internals/an-object":277,"../internals/descriptors":313,"../internals/object-define-property":388,"../internals/object-keys":397,"../internals/to-indexed-object":427,"../internals/v8-prototype-define-bug":438}],388:[function(_dereq_,module,exports){
  21477. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21478. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  21479. var V8_PROTOTYPE_DEFINE_BUG = _dereq_('../internals/v8-prototype-define-bug');
  21480. var anObject = _dereq_('../internals/an-object');
  21481. var toPropertyKey = _dereq_('../internals/to-property-key');
  21482. var $TypeError = TypeError;
  21483. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  21484. var $defineProperty = Object.defineProperty;
  21485. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  21486. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  21487. var ENUMERABLE = 'enumerable';
  21488. var CONFIGURABLE = 'configurable';
  21489. var WRITABLE = 'writable';
  21490. // `Object.defineProperty` method
  21491. // https://tc39.es/ecma262/#sec-object.defineproperty
  21492. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  21493. anObject(O);
  21494. P = toPropertyKey(P);
  21495. anObject(Attributes);
  21496. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  21497. var current = $getOwnPropertyDescriptor(O, P);
  21498. if (current && current[WRITABLE]) {
  21499. O[P] = Attributes.value;
  21500. Attributes = {
  21501. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  21502. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  21503. writable: false
  21504. };
  21505. }
  21506. } return $defineProperty(O, P, Attributes);
  21507. } : $defineProperty : function defineProperty(O, P, Attributes) {
  21508. anObject(O);
  21509. P = toPropertyKey(P);
  21510. anObject(Attributes);
  21511. if (IE8_DOM_DEFINE) try {
  21512. return $defineProperty(O, P, Attributes);
  21513. } catch (error) { /* empty */ }
  21514. if ('get' in Attributes || 'set' in Attributes) throw $TypeError('Accessors not supported');
  21515. if ('value' in Attributes) O[P] = Attributes.value;
  21516. return O;
  21517. };
  21518. },{"../internals/an-object":277,"../internals/descriptors":313,"../internals/ie8-dom-define":352,"../internals/to-property-key":432,"../internals/v8-prototype-define-bug":438}],389:[function(_dereq_,module,exports){
  21519. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21520. var call = _dereq_('../internals/function-call');
  21521. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  21522. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  21523. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  21524. var toPropertyKey = _dereq_('../internals/to-property-key');
  21525. var hasOwn = _dereq_('../internals/has-own-property');
  21526. var IE8_DOM_DEFINE = _dereq_('../internals/ie8-dom-define');
  21527. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  21528. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  21529. // `Object.getOwnPropertyDescriptor` method
  21530. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  21531. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  21532. O = toIndexedObject(O);
  21533. P = toPropertyKey(P);
  21534. if (IE8_DOM_DEFINE) try {
  21535. return $getOwnPropertyDescriptor(O, P);
  21536. } catch (error) { /* empty */ }
  21537. if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  21538. };
  21539. },{"../internals/create-property-descriptor":307,"../internals/descriptors":313,"../internals/function-call":339,"../internals/has-own-property":348,"../internals/ie8-dom-define":352,"../internals/object-property-is-enumerable":398,"../internals/to-indexed-object":427,"../internals/to-property-key":432}],390:[function(_dereq_,module,exports){
  21540. /* eslint-disable es-x/no-object-getownpropertynames -- safe */
  21541. var classof = _dereq_('../internals/classof-raw');
  21542. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  21543. var $getOwnPropertyNames = _dereq_('../internals/object-get-own-property-names').f;
  21544. var arraySlice = _dereq_('../internals/array-slice-simple');
  21545. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  21546. ? Object.getOwnPropertyNames(window) : [];
  21547. var getWindowNames = function (it) {
  21548. try {
  21549. return $getOwnPropertyNames(it);
  21550. } catch (error) {
  21551. return arraySlice(windowNames);
  21552. }
  21553. };
  21554. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  21555. module.exports.f = function getOwnPropertyNames(it) {
  21556. return windowNames && classof(it) == 'Window'
  21557. ? getWindowNames(it)
  21558. : $getOwnPropertyNames(toIndexedObject(it));
  21559. };
  21560. },{"../internals/array-slice-simple":287,"../internals/classof-raw":294,"../internals/object-get-own-property-names":391,"../internals/to-indexed-object":427}],391:[function(_dereq_,module,exports){
  21561. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  21562. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  21563. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  21564. // `Object.getOwnPropertyNames` method
  21565. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  21566. // eslint-disable-next-line es-x/no-object-getownpropertynames -- safe
  21567. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  21568. return internalObjectKeys(O, hiddenKeys);
  21569. };
  21570. },{"../internals/enum-bug-keys":329,"../internals/object-keys-internal":396}],392:[function(_dereq_,module,exports){
  21571. // eslint-disable-next-line es-x/no-object-getownpropertysymbols -- safe
  21572. exports.f = Object.getOwnPropertySymbols;
  21573. },{}],393:[function(_dereq_,module,exports){
  21574. var hasOwn = _dereq_('../internals/has-own-property');
  21575. var isCallable = _dereq_('../internals/is-callable');
  21576. var toObject = _dereq_('../internals/to-object');
  21577. var sharedKey = _dereq_('../internals/shared-key');
  21578. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  21579. var IE_PROTO = sharedKey('IE_PROTO');
  21580. var $Object = Object;
  21581. var ObjectPrototype = $Object.prototype;
  21582. // `Object.getPrototypeOf` method
  21583. // https://tc39.es/ecma262/#sec-object.getprototypeof
  21584. // eslint-disable-next-line es-x/no-object-getprototypeof -- safe
  21585. module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
  21586. var object = toObject(O);
  21587. if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
  21588. var constructor = object.constructor;
  21589. if (isCallable(constructor) && object instanceof constructor) {
  21590. return constructor.prototype;
  21591. } return object instanceof $Object ? ObjectPrototype : null;
  21592. };
  21593. },{"../internals/correct-prototype-getter":304,"../internals/has-own-property":348,"../internals/is-callable":360,"../internals/shared-key":416,"../internals/to-object":430}],394:[function(_dereq_,module,exports){
  21594. var fails = _dereq_('../internals/fails');
  21595. var isObject = _dereq_('../internals/is-object');
  21596. var classof = _dereq_('../internals/classof-raw');
  21597. var ARRAY_BUFFER_NON_EXTENSIBLE = _dereq_('../internals/array-buffer-non-extensible');
  21598. // eslint-disable-next-line es-x/no-object-isextensible -- safe
  21599. var $isExtensible = Object.isExtensible;
  21600. var FAILS_ON_PRIMITIVES = fails(function () { $isExtensible(1); });
  21601. // `Object.isExtensible` method
  21602. // https://tc39.es/ecma262/#sec-object.isextensible
  21603. module.exports = (FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE) ? function isExtensible(it) {
  21604. if (!isObject(it)) return false;
  21605. if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return false;
  21606. return $isExtensible ? $isExtensible(it) : true;
  21607. } : $isExtensible;
  21608. },{"../internals/array-buffer-non-extensible":278,"../internals/classof-raw":294,"../internals/fails":333,"../internals/is-object":366}],395:[function(_dereq_,module,exports){
  21609. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21610. module.exports = uncurryThis({}.isPrototypeOf);
  21611. },{"../internals/function-uncurry-this":341}],396:[function(_dereq_,module,exports){
  21612. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21613. var hasOwn = _dereq_('../internals/has-own-property');
  21614. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  21615. var indexOf = _dereq_('../internals/array-includes').indexOf;
  21616. var hiddenKeys = _dereq_('../internals/hidden-keys');
  21617. var push = uncurryThis([].push);
  21618. module.exports = function (object, names) {
  21619. var O = toIndexedObject(object);
  21620. var i = 0;
  21621. var result = [];
  21622. var key;
  21623. for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  21624. // Don't enum bug & hidden keys
  21625. while (names.length > i) if (hasOwn(O, key = names[i++])) {
  21626. ~indexOf(result, key) || push(result, key);
  21627. }
  21628. return result;
  21629. };
  21630. },{"../internals/array-includes":281,"../internals/function-uncurry-this":341,"../internals/has-own-property":348,"../internals/hidden-keys":349,"../internals/to-indexed-object":427}],397:[function(_dereq_,module,exports){
  21631. var internalObjectKeys = _dereq_('../internals/object-keys-internal');
  21632. var enumBugKeys = _dereq_('../internals/enum-bug-keys');
  21633. // `Object.keys` method
  21634. // https://tc39.es/ecma262/#sec-object.keys
  21635. // eslint-disable-next-line es-x/no-object-keys -- safe
  21636. module.exports = Object.keys || function keys(O) {
  21637. return internalObjectKeys(O, enumBugKeys);
  21638. };
  21639. },{"../internals/enum-bug-keys":329,"../internals/object-keys-internal":396}],398:[function(_dereq_,module,exports){
  21640. 'use strict';
  21641. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  21642. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  21643. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  21644. // Nashorn ~ JDK8 bug
  21645. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  21646. // `Object.prototype.propertyIsEnumerable` method implementation
  21647. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  21648. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  21649. var descriptor = getOwnPropertyDescriptor(this, V);
  21650. return !!descriptor && descriptor.enumerable;
  21651. } : $propertyIsEnumerable;
  21652. },{}],399:[function(_dereq_,module,exports){
  21653. /* eslint-disable no-proto -- safe */
  21654. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21655. var anObject = _dereq_('../internals/an-object');
  21656. var aPossiblePrototype = _dereq_('../internals/a-possible-prototype');
  21657. // `Object.setPrototypeOf` method
  21658. // https://tc39.es/ecma262/#sec-object.setprototypeof
  21659. // Works with __proto__ only. Old v8 can't work with null proto objects.
  21660. // eslint-disable-next-line es-x/no-object-setprototypeof -- safe
  21661. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  21662. var CORRECT_SETTER = false;
  21663. var test = {};
  21664. var setter;
  21665. try {
  21666. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  21667. setter = uncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
  21668. setter(test, []);
  21669. CORRECT_SETTER = test instanceof Array;
  21670. } catch (error) { /* empty */ }
  21671. return function setPrototypeOf(O, proto) {
  21672. anObject(O);
  21673. aPossiblePrototype(proto);
  21674. if (CORRECT_SETTER) setter(O, proto);
  21675. else O.__proto__ = proto;
  21676. return O;
  21677. };
  21678. }() : undefined);
  21679. },{"../internals/a-possible-prototype":274,"../internals/an-object":277,"../internals/function-uncurry-this":341}],400:[function(_dereq_,module,exports){
  21680. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21681. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21682. var objectKeys = _dereq_('../internals/object-keys');
  21683. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  21684. var $propertyIsEnumerable = _dereq_('../internals/object-property-is-enumerable').f;
  21685. var propertyIsEnumerable = uncurryThis($propertyIsEnumerable);
  21686. var push = uncurryThis([].push);
  21687. // `Object.{ entries, values }` methods implementation
  21688. var createMethod = function (TO_ENTRIES) {
  21689. return function (it) {
  21690. var O = toIndexedObject(it);
  21691. var keys = objectKeys(O);
  21692. var length = keys.length;
  21693. var i = 0;
  21694. var result = [];
  21695. var key;
  21696. while (length > i) {
  21697. key = keys[i++];
  21698. if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
  21699. push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
  21700. }
  21701. }
  21702. return result;
  21703. };
  21704. };
  21705. module.exports = {
  21706. // `Object.entries` method
  21707. // https://tc39.es/ecma262/#sec-object.entries
  21708. entries: createMethod(true),
  21709. // `Object.values` method
  21710. // https://tc39.es/ecma262/#sec-object.values
  21711. values: createMethod(false)
  21712. };
  21713. },{"../internals/descriptors":313,"../internals/function-uncurry-this":341,"../internals/object-keys":397,"../internals/object-property-is-enumerable":398,"../internals/to-indexed-object":427}],401:[function(_dereq_,module,exports){
  21714. 'use strict';
  21715. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  21716. var classof = _dereq_('../internals/classof');
  21717. // `Object.prototype.toString` method implementation
  21718. // https://tc39.es/ecma262/#sec-object.prototype.tostring
  21719. module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
  21720. return '[object ' + classof(this) + ']';
  21721. };
  21722. },{"../internals/classof":295,"../internals/to-string-tag-support":433}],402:[function(_dereq_,module,exports){
  21723. var call = _dereq_('../internals/function-call');
  21724. var isCallable = _dereq_('../internals/is-callable');
  21725. var isObject = _dereq_('../internals/is-object');
  21726. var $TypeError = TypeError;
  21727. // `OrdinaryToPrimitive` abstract operation
  21728. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  21729. module.exports = function (input, pref) {
  21730. var fn, val;
  21731. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  21732. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
  21733. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
  21734. throw $TypeError("Can't convert object to primitive value");
  21735. };
  21736. },{"../internals/function-call":339,"../internals/is-callable":360,"../internals/is-object":366}],403:[function(_dereq_,module,exports){
  21737. var getBuiltIn = _dereq_('../internals/get-built-in');
  21738. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21739. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  21740. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  21741. var anObject = _dereq_('../internals/an-object');
  21742. var concat = uncurryThis([].concat);
  21743. // all object keys, includes non-enumerable and symbols
  21744. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  21745. var keys = getOwnPropertyNamesModule.f(anObject(it));
  21746. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  21747. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  21748. };
  21749. },{"../internals/an-object":277,"../internals/function-uncurry-this":341,"../internals/get-built-in":342,"../internals/object-get-own-property-names":391,"../internals/object-get-own-property-symbols":392}],404:[function(_dereq_,module,exports){
  21750. arguments[4][349][0].apply(exports,arguments)
  21751. },{"dup":349}],405:[function(_dereq_,module,exports){
  21752. module.exports = function (exec) {
  21753. try {
  21754. return { error: false, value: exec() };
  21755. } catch (error) {
  21756. return { error: true, value: error };
  21757. }
  21758. };
  21759. },{}],406:[function(_dereq_,module,exports){
  21760. var global = _dereq_('../internals/global');
  21761. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  21762. var isCallable = _dereq_('../internals/is-callable');
  21763. var isForced = _dereq_('../internals/is-forced');
  21764. var inspectSource = _dereq_('../internals/inspect-source');
  21765. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  21766. var IS_BROWSER = _dereq_('../internals/engine-is-browser');
  21767. var IS_DENO = _dereq_('../internals/engine-is-deno');
  21768. var IS_PURE = _dereq_('../internals/is-pure');
  21769. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  21770. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  21771. var SPECIES = wellKnownSymbol('species');
  21772. var SUBCLASSING = false;
  21773. var NATIVE_PROMISE_REJECTION_EVENT = isCallable(global.PromiseRejectionEvent);
  21774. var FORCED_PROMISE_CONSTRUCTOR = isForced('Promise', function () {
  21775. var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(NativePromiseConstructor);
  21776. var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(NativePromiseConstructor);
  21777. // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  21778. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  21779. // We can't detect it synchronously, so just check versions
  21780. if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
  21781. // We need Promise#{ catch, finally } in the pure version for preventing prototype pollution
  21782. if (IS_PURE && !(NativePromisePrototype['catch'] && NativePromisePrototype['finally'])) return true;
  21783. // We can't use @@species feature detection in V8 since it causes
  21784. // deoptimization and performance degradation
  21785. // https://github.com/zloirock/core-js/issues/679
  21786. if (!V8_VERSION || V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) {
  21787. // Detect correctness of subclassing with @@species support
  21788. var promise = new NativePromiseConstructor(function (resolve) { resolve(1); });
  21789. var FakePromise = function (exec) {
  21790. exec(function () { /* empty */ }, function () { /* empty */ });
  21791. };
  21792. var constructor = promise.constructor = {};
  21793. constructor[SPECIES] = FakePromise;
  21794. SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
  21795. if (!SUBCLASSING) return true;
  21796. // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  21797. } return !GLOBAL_CORE_JS_PROMISE && (IS_BROWSER || IS_DENO) && !NATIVE_PROMISE_REJECTION_EVENT;
  21798. });
  21799. module.exports = {
  21800. CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR,
  21801. REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT,
  21802. SUBCLASSING: SUBCLASSING
  21803. };
  21804. },{"../internals/engine-is-browser":318,"../internals/engine-is-deno":319,"../internals/engine-v8-version":326,"../internals/global":347,"../internals/inspect-source":354,"../internals/is-callable":360,"../internals/is-forced":363,"../internals/is-pure":367,"../internals/promise-native-constructor":407,"../internals/well-known-symbol":443}],407:[function(_dereq_,module,exports){
  21805. var global = _dereq_('../internals/global');
  21806. module.exports = global.Promise;
  21807. },{"../internals/global":347}],408:[function(_dereq_,module,exports){
  21808. var anObject = _dereq_('../internals/an-object');
  21809. var isObject = _dereq_('../internals/is-object');
  21810. var newPromiseCapability = _dereq_('../internals/new-promise-capability');
  21811. module.exports = function (C, x) {
  21812. anObject(C);
  21813. if (isObject(x) && x.constructor === C) return x;
  21814. var promiseCapability = newPromiseCapability.f(C);
  21815. var resolve = promiseCapability.resolve;
  21816. resolve(x);
  21817. return promiseCapability.promise;
  21818. };
  21819. },{"../internals/an-object":277,"../internals/is-object":366,"../internals/new-promise-capability":381}],409:[function(_dereq_,module,exports){
  21820. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  21821. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  21822. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  21823. module.exports = FORCED_PROMISE_CONSTRUCTOR || !checkCorrectnessOfIteration(function (iterable) {
  21824. NativePromiseConstructor.all(iterable).then(undefined, function () { /* empty */ });
  21825. });
  21826. },{"../internals/check-correctness-of-iteration":293,"../internals/promise-constructor-detection":406,"../internals/promise-native-constructor":407}],410:[function(_dereq_,module,exports){
  21827. var Queue = function () {
  21828. this.head = null;
  21829. this.tail = null;
  21830. };
  21831. Queue.prototype = {
  21832. add: function (item) {
  21833. var entry = { item: item, next: null };
  21834. if (this.head) this.tail.next = entry;
  21835. else this.head = entry;
  21836. this.tail = entry;
  21837. },
  21838. get: function () {
  21839. var entry = this.head;
  21840. if (entry) {
  21841. this.head = entry.next;
  21842. if (this.tail === entry) this.tail = null;
  21843. return entry.item;
  21844. }
  21845. }
  21846. };
  21847. module.exports = Queue;
  21848. },{}],411:[function(_dereq_,module,exports){
  21849. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  21850. var $TypeError = TypeError;
  21851. // `RequireObjectCoercible` abstract operation
  21852. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  21853. module.exports = function (it) {
  21854. if (isNullOrUndefined(it)) throw $TypeError("Can't call method on " + it);
  21855. return it;
  21856. };
  21857. },{"../internals/is-null-or-undefined":365}],412:[function(_dereq_,module,exports){
  21858. // `SameValueZero` abstract operation
  21859. // https://tc39.es/ecma262/#sec-samevaluezero
  21860. module.exports = function (x, y) {
  21861. // eslint-disable-next-line no-self-compare -- NaN check
  21862. return x === y || x != x && y != y;
  21863. };
  21864. },{}],413:[function(_dereq_,module,exports){
  21865. var global = _dereq_('../internals/global');
  21866. var apply = _dereq_('../internals/function-apply');
  21867. var isCallable = _dereq_('../internals/is-callable');
  21868. var userAgent = _dereq_('../internals/engine-user-agent');
  21869. var arraySlice = _dereq_('../internals/array-slice');
  21870. var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
  21871. var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
  21872. var Function = global.Function;
  21873. var wrap = function (scheduler) {
  21874. return MSIE ? function (handler, timeout /* , ...arguments */) {
  21875. var boundArgs = validateArgumentsLength(arguments.length, 1) > 2;
  21876. var fn = isCallable(handler) ? handler : Function(handler);
  21877. var args = boundArgs ? arraySlice(arguments, 2) : undefined;
  21878. return scheduler(boundArgs ? function () {
  21879. apply(fn, this, args);
  21880. } : fn, timeout);
  21881. } : scheduler;
  21882. };
  21883. // ie9- setTimeout & setInterval additional parameters fix
  21884. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
  21885. module.exports = {
  21886. // `setTimeout` method
  21887. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
  21888. setTimeout: wrap(global.setTimeout),
  21889. // `setInterval` method
  21890. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
  21891. setInterval: wrap(global.setInterval)
  21892. };
  21893. },{"../internals/array-slice":288,"../internals/engine-user-agent":325,"../internals/function-apply":335,"../internals/global":347,"../internals/is-callable":360,"../internals/validate-arguments-length":439}],414:[function(_dereq_,module,exports){
  21894. 'use strict';
  21895. var getBuiltIn = _dereq_('../internals/get-built-in');
  21896. var definePropertyModule = _dereq_('../internals/object-define-property');
  21897. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  21898. var DESCRIPTORS = _dereq_('../internals/descriptors');
  21899. var SPECIES = wellKnownSymbol('species');
  21900. module.exports = function (CONSTRUCTOR_NAME) {
  21901. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  21902. var defineProperty = definePropertyModule.f;
  21903. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  21904. defineProperty(Constructor, SPECIES, {
  21905. configurable: true,
  21906. get: function () { return this; }
  21907. });
  21908. }
  21909. };
  21910. },{"../internals/descriptors":313,"../internals/get-built-in":342,"../internals/object-define-property":388,"../internals/well-known-symbol":443}],415:[function(_dereq_,module,exports){
  21911. var TO_STRING_TAG_SUPPORT = _dereq_('../internals/to-string-tag-support');
  21912. var defineProperty = _dereq_('../internals/object-define-property').f;
  21913. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  21914. var hasOwn = _dereq_('../internals/has-own-property');
  21915. var toString = _dereq_('../internals/object-to-string');
  21916. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  21917. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  21918. module.exports = function (it, TAG, STATIC, SET_METHOD) {
  21919. if (it) {
  21920. var target = STATIC ? it : it.prototype;
  21921. if (!hasOwn(target, TO_STRING_TAG)) {
  21922. defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });
  21923. }
  21924. if (SET_METHOD && !TO_STRING_TAG_SUPPORT) {
  21925. createNonEnumerableProperty(target, 'toString', toString);
  21926. }
  21927. }
  21928. };
  21929. },{"../internals/create-non-enumerable-property":306,"../internals/has-own-property":348,"../internals/object-define-property":388,"../internals/object-to-string":401,"../internals/to-string-tag-support":433,"../internals/well-known-symbol":443}],416:[function(_dereq_,module,exports){
  21930. var shared = _dereq_('../internals/shared');
  21931. var uid = _dereq_('../internals/uid');
  21932. var keys = shared('keys');
  21933. module.exports = function (key) {
  21934. return keys[key] || (keys[key] = uid(key));
  21935. };
  21936. },{"../internals/shared":418,"../internals/uid":436}],417:[function(_dereq_,module,exports){
  21937. var global = _dereq_('../internals/global');
  21938. var defineGlobalProperty = _dereq_('../internals/define-global-property');
  21939. var SHARED = '__core-js_shared__';
  21940. var store = global[SHARED] || defineGlobalProperty(SHARED, {});
  21941. module.exports = store;
  21942. },{"../internals/define-global-property":311,"../internals/global":347}],418:[function(_dereq_,module,exports){
  21943. var IS_PURE = _dereq_('../internals/is-pure');
  21944. var store = _dereq_('../internals/shared-store');
  21945. (module.exports = function (key, value) {
  21946. return store[key] || (store[key] = value !== undefined ? value : {});
  21947. })('versions', []).push({
  21948. version: '3.25.1',
  21949. mode: IS_PURE ? 'pure' : 'global',
  21950. copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
  21951. license: 'https://github.com/zloirock/core-js/blob/v3.25.1/LICENSE',
  21952. source: 'https://github.com/zloirock/core-js'
  21953. });
  21954. },{"../internals/is-pure":367,"../internals/shared-store":417}],419:[function(_dereq_,module,exports){
  21955. var anObject = _dereq_('../internals/an-object');
  21956. var aConstructor = _dereq_('../internals/a-constructor');
  21957. var isNullOrUndefined = _dereq_('../internals/is-null-or-undefined');
  21958. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  21959. var SPECIES = wellKnownSymbol('species');
  21960. // `SpeciesConstructor` abstract operation
  21961. // https://tc39.es/ecma262/#sec-speciesconstructor
  21962. module.exports = function (O, defaultConstructor) {
  21963. var C = anObject(O).constructor;
  21964. var S;
  21965. return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES]) ? defaultConstructor : aConstructor(S);
  21966. };
  21967. },{"../internals/a-constructor":273,"../internals/an-object":277,"../internals/is-null-or-undefined":365,"../internals/well-known-symbol":443}],420:[function(_dereq_,module,exports){
  21968. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  21969. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  21970. var toString = _dereq_('../internals/to-string');
  21971. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  21972. var charAt = uncurryThis(''.charAt);
  21973. var charCodeAt = uncurryThis(''.charCodeAt);
  21974. var stringSlice = uncurryThis(''.slice);
  21975. var createMethod = function (CONVERT_TO_STRING) {
  21976. return function ($this, pos) {
  21977. var S = toString(requireObjectCoercible($this));
  21978. var position = toIntegerOrInfinity(pos);
  21979. var size = S.length;
  21980. var first, second;
  21981. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  21982. first = charCodeAt(S, position);
  21983. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  21984. || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
  21985. ? CONVERT_TO_STRING
  21986. ? charAt(S, position)
  21987. : first
  21988. : CONVERT_TO_STRING
  21989. ? stringSlice(S, position, position + 2)
  21990. : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  21991. };
  21992. };
  21993. module.exports = {
  21994. // `String.prototype.codePointAt` method
  21995. // https://tc39.es/ecma262/#sec-string.prototype.codepointat
  21996. codeAt: createMethod(false),
  21997. // `String.prototype.at` method
  21998. // https://github.com/mathiasbynens/String.prototype.at
  21999. charAt: createMethod(true)
  22000. };
  22001. },{"../internals/function-uncurry-this":341,"../internals/require-object-coercible":411,"../internals/to-integer-or-infinity":428,"../internals/to-string":434}],421:[function(_dereq_,module,exports){
  22002. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  22003. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  22004. var toString = _dereq_('../internals/to-string');
  22005. var whitespaces = _dereq_('../internals/whitespaces');
  22006. var replace = uncurryThis(''.replace);
  22007. var whitespace = '[' + whitespaces + ']';
  22008. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  22009. var rtrim = RegExp(whitespace + whitespace + '*$');
  22010. // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
  22011. var createMethod = function (TYPE) {
  22012. return function ($this) {
  22013. var string = toString(requireObjectCoercible($this));
  22014. if (TYPE & 1) string = replace(string, ltrim, '');
  22015. if (TYPE & 2) string = replace(string, rtrim, '');
  22016. return string;
  22017. };
  22018. };
  22019. module.exports = {
  22020. // `String.prototype.{ trimLeft, trimStart }` methods
  22021. // https://tc39.es/ecma262/#sec-string.prototype.trimstart
  22022. start: createMethod(1),
  22023. // `String.prototype.{ trimRight, trimEnd }` methods
  22024. // https://tc39.es/ecma262/#sec-string.prototype.trimend
  22025. end: createMethod(2),
  22026. // `String.prototype.trim` method
  22027. // https://tc39.es/ecma262/#sec-string.prototype.trim
  22028. trim: createMethod(3)
  22029. };
  22030. },{"../internals/function-uncurry-this":341,"../internals/require-object-coercible":411,"../internals/to-string":434,"../internals/whitespaces":444}],422:[function(_dereq_,module,exports){
  22031. /* eslint-disable es-x/no-symbol -- required for testing */
  22032. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  22033. var fails = _dereq_('../internals/fails');
  22034. // eslint-disable-next-line es-x/no-object-getownpropertysymbols -- required for testing
  22035. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  22036. var symbol = Symbol();
  22037. // Chrome 38 Symbol has incorrect toString conversion
  22038. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  22039. return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
  22040. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  22041. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  22042. });
  22043. },{"../internals/engine-v8-version":326,"../internals/fails":333}],423:[function(_dereq_,module,exports){
  22044. var call = _dereq_('../internals/function-call');
  22045. var getBuiltIn = _dereq_('../internals/get-built-in');
  22046. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22047. var defineBuiltIn = _dereq_('../internals/define-built-in');
  22048. module.exports = function () {
  22049. var Symbol = getBuiltIn('Symbol');
  22050. var SymbolPrototype = Symbol && Symbol.prototype;
  22051. var valueOf = SymbolPrototype && SymbolPrototype.valueOf;
  22052. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  22053. if (SymbolPrototype && !SymbolPrototype[TO_PRIMITIVE]) {
  22054. // `Symbol.prototype[@@toPrimitive]` method
  22055. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  22056. // eslint-disable-next-line no-unused-vars -- required for .length
  22057. defineBuiltIn(SymbolPrototype, TO_PRIMITIVE, function (hint) {
  22058. return call(valueOf, this);
  22059. }, { arity: 1 });
  22060. }
  22061. };
  22062. },{"../internals/define-built-in":309,"../internals/function-call":339,"../internals/get-built-in":342,"../internals/well-known-symbol":443}],424:[function(_dereq_,module,exports){
  22063. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  22064. /* eslint-disable es-x/no-symbol -- safe */
  22065. module.exports = NATIVE_SYMBOL && !!Symbol['for'] && !!Symbol.keyFor;
  22066. },{"../internals/symbol-constructor-detection":422}],425:[function(_dereq_,module,exports){
  22067. var global = _dereq_('../internals/global');
  22068. var apply = _dereq_('../internals/function-apply');
  22069. var bind = _dereq_('../internals/function-bind-context');
  22070. var isCallable = _dereq_('../internals/is-callable');
  22071. var hasOwn = _dereq_('../internals/has-own-property');
  22072. var fails = _dereq_('../internals/fails');
  22073. var html = _dereq_('../internals/html');
  22074. var arraySlice = _dereq_('../internals/array-slice');
  22075. var createElement = _dereq_('../internals/document-create-element');
  22076. var validateArgumentsLength = _dereq_('../internals/validate-arguments-length');
  22077. var IS_IOS = _dereq_('../internals/engine-is-ios');
  22078. var IS_NODE = _dereq_('../internals/engine-is-node');
  22079. var set = global.setImmediate;
  22080. var clear = global.clearImmediate;
  22081. var process = global.process;
  22082. var Dispatch = global.Dispatch;
  22083. var Function = global.Function;
  22084. var MessageChannel = global.MessageChannel;
  22085. var String = global.String;
  22086. var counter = 0;
  22087. var queue = {};
  22088. var ONREADYSTATECHANGE = 'onreadystatechange';
  22089. var location, defer, channel, port;
  22090. try {
  22091. // Deno throws a ReferenceError on `location` access without `--location` flag
  22092. location = global.location;
  22093. } catch (error) { /* empty */ }
  22094. var run = function (id) {
  22095. if (hasOwn(queue, id)) {
  22096. var fn = queue[id];
  22097. delete queue[id];
  22098. fn();
  22099. }
  22100. };
  22101. var runner = function (id) {
  22102. return function () {
  22103. run(id);
  22104. };
  22105. };
  22106. var listener = function (event) {
  22107. run(event.data);
  22108. };
  22109. var post = function (id) {
  22110. // old engines have not location.origin
  22111. global.postMessage(String(id), location.protocol + '//' + location.host);
  22112. };
  22113. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  22114. if (!set || !clear) {
  22115. set = function setImmediate(handler) {
  22116. validateArgumentsLength(arguments.length, 1);
  22117. var fn = isCallable(handler) ? handler : Function(handler);
  22118. var args = arraySlice(arguments, 1);
  22119. queue[++counter] = function () {
  22120. apply(fn, undefined, args);
  22121. };
  22122. defer(counter);
  22123. return counter;
  22124. };
  22125. clear = function clearImmediate(id) {
  22126. delete queue[id];
  22127. };
  22128. // Node.js 0.8-
  22129. if (IS_NODE) {
  22130. defer = function (id) {
  22131. process.nextTick(runner(id));
  22132. };
  22133. // Sphere (JS game engine) Dispatch API
  22134. } else if (Dispatch && Dispatch.now) {
  22135. defer = function (id) {
  22136. Dispatch.now(runner(id));
  22137. };
  22138. // Browsers with MessageChannel, includes WebWorkers
  22139. // except iOS - https://github.com/zloirock/core-js/issues/624
  22140. } else if (MessageChannel && !IS_IOS) {
  22141. channel = new MessageChannel();
  22142. port = channel.port2;
  22143. channel.port1.onmessage = listener;
  22144. defer = bind(port.postMessage, port);
  22145. // Browsers with postMessage, skip WebWorkers
  22146. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  22147. } else if (
  22148. global.addEventListener &&
  22149. isCallable(global.postMessage) &&
  22150. !global.importScripts &&
  22151. location && location.protocol !== 'file:' &&
  22152. !fails(post)
  22153. ) {
  22154. defer = post;
  22155. global.addEventListener('message', listener, false);
  22156. // IE8-
  22157. } else if (ONREADYSTATECHANGE in createElement('script')) {
  22158. defer = function (id) {
  22159. html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
  22160. html.removeChild(this);
  22161. run(id);
  22162. };
  22163. };
  22164. // Rest old browsers
  22165. } else {
  22166. defer = function (id) {
  22167. setTimeout(runner(id), 0);
  22168. };
  22169. }
  22170. }
  22171. module.exports = {
  22172. set: set,
  22173. clear: clear
  22174. };
  22175. },{"../internals/array-slice":288,"../internals/document-create-element":314,"../internals/engine-is-ios":322,"../internals/engine-is-node":323,"../internals/fails":333,"../internals/function-apply":335,"../internals/function-bind-context":336,"../internals/global":347,"../internals/has-own-property":348,"../internals/html":351,"../internals/is-callable":360,"../internals/validate-arguments-length":439}],426:[function(_dereq_,module,exports){
  22176. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  22177. var max = Math.max;
  22178. var min = Math.min;
  22179. // Helper for a popular repeating case of the spec:
  22180. // Let integer be ? ToInteger(index).
  22181. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  22182. module.exports = function (index, length) {
  22183. var integer = toIntegerOrInfinity(index);
  22184. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  22185. };
  22186. },{"../internals/to-integer-or-infinity":428}],427:[function(_dereq_,module,exports){
  22187. // toObject with fallback for non-array-like ES3 strings
  22188. var IndexedObject = _dereq_('../internals/indexed-object');
  22189. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  22190. module.exports = function (it) {
  22191. return IndexedObject(requireObjectCoercible(it));
  22192. };
  22193. },{"../internals/indexed-object":353,"../internals/require-object-coercible":411}],428:[function(_dereq_,module,exports){
  22194. var trunc = _dereq_('../internals/math-trunc');
  22195. // `ToIntegerOrInfinity` abstract operation
  22196. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  22197. module.exports = function (argument) {
  22198. var number = +argument;
  22199. // eslint-disable-next-line no-self-compare -- NaN check
  22200. return number !== number || number === 0 ? 0 : trunc(number);
  22201. };
  22202. },{"../internals/math-trunc":379}],429:[function(_dereq_,module,exports){
  22203. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  22204. var min = Math.min;
  22205. // `ToLength` abstract operation
  22206. // https://tc39.es/ecma262/#sec-tolength
  22207. module.exports = function (argument) {
  22208. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  22209. };
  22210. },{"../internals/to-integer-or-infinity":428}],430:[function(_dereq_,module,exports){
  22211. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  22212. var $Object = Object;
  22213. // `ToObject` abstract operation
  22214. // https://tc39.es/ecma262/#sec-toobject
  22215. module.exports = function (argument) {
  22216. return $Object(requireObjectCoercible(argument));
  22217. };
  22218. },{"../internals/require-object-coercible":411}],431:[function(_dereq_,module,exports){
  22219. var call = _dereq_('../internals/function-call');
  22220. var isObject = _dereq_('../internals/is-object');
  22221. var isSymbol = _dereq_('../internals/is-symbol');
  22222. var getMethod = _dereq_('../internals/get-method');
  22223. var ordinaryToPrimitive = _dereq_('../internals/ordinary-to-primitive');
  22224. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22225. var $TypeError = TypeError;
  22226. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  22227. // `ToPrimitive` abstract operation
  22228. // https://tc39.es/ecma262/#sec-toprimitive
  22229. module.exports = function (input, pref) {
  22230. if (!isObject(input) || isSymbol(input)) return input;
  22231. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  22232. var result;
  22233. if (exoticToPrim) {
  22234. if (pref === undefined) pref = 'default';
  22235. result = call(exoticToPrim, input, pref);
  22236. if (!isObject(result) || isSymbol(result)) return result;
  22237. throw $TypeError("Can't convert object to primitive value");
  22238. }
  22239. if (pref === undefined) pref = 'number';
  22240. return ordinaryToPrimitive(input, pref);
  22241. };
  22242. },{"../internals/function-call":339,"../internals/get-method":346,"../internals/is-object":366,"../internals/is-symbol":369,"../internals/ordinary-to-primitive":402,"../internals/well-known-symbol":443}],432:[function(_dereq_,module,exports){
  22243. var toPrimitive = _dereq_('../internals/to-primitive');
  22244. var isSymbol = _dereq_('../internals/is-symbol');
  22245. // `ToPropertyKey` abstract operation
  22246. // https://tc39.es/ecma262/#sec-topropertykey
  22247. module.exports = function (argument) {
  22248. var key = toPrimitive(argument, 'string');
  22249. return isSymbol(key) ? key : key + '';
  22250. };
  22251. },{"../internals/is-symbol":369,"../internals/to-primitive":431}],433:[function(_dereq_,module,exports){
  22252. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22253. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  22254. var test = {};
  22255. test[TO_STRING_TAG] = 'z';
  22256. module.exports = String(test) === '[object z]';
  22257. },{"../internals/well-known-symbol":443}],434:[function(_dereq_,module,exports){
  22258. var classof = _dereq_('../internals/classof');
  22259. var $String = String;
  22260. module.exports = function (argument) {
  22261. if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
  22262. return $String(argument);
  22263. };
  22264. },{"../internals/classof":295}],435:[function(_dereq_,module,exports){
  22265. var $String = String;
  22266. module.exports = function (argument) {
  22267. try {
  22268. return $String(argument);
  22269. } catch (error) {
  22270. return 'Object';
  22271. }
  22272. };
  22273. },{}],436:[function(_dereq_,module,exports){
  22274. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  22275. var id = 0;
  22276. var postfix = Math.random();
  22277. var toString = uncurryThis(1.0.toString);
  22278. module.exports = function (key) {
  22279. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  22280. };
  22281. },{"../internals/function-uncurry-this":341}],437:[function(_dereq_,module,exports){
  22282. /* eslint-disable es-x/no-symbol -- required for testing */
  22283. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  22284. module.exports = NATIVE_SYMBOL
  22285. && !Symbol.sham
  22286. && typeof Symbol.iterator == 'symbol';
  22287. },{"../internals/symbol-constructor-detection":422}],438:[function(_dereq_,module,exports){
  22288. var DESCRIPTORS = _dereq_('../internals/descriptors');
  22289. var fails = _dereq_('../internals/fails');
  22290. // V8 ~ Chrome 36-
  22291. // https://bugs.chromium.org/p/v8/issues/detail?id=3334
  22292. module.exports = DESCRIPTORS && fails(function () {
  22293. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  22294. return Object.defineProperty(function () { /* empty */ }, 'prototype', {
  22295. value: 42,
  22296. writable: false
  22297. }).prototype != 42;
  22298. });
  22299. },{"../internals/descriptors":313,"../internals/fails":333}],439:[function(_dereq_,module,exports){
  22300. var $TypeError = TypeError;
  22301. module.exports = function (passed, required) {
  22302. if (passed < required) throw $TypeError('Not enough arguments');
  22303. return passed;
  22304. };
  22305. },{}],440:[function(_dereq_,module,exports){
  22306. var global = _dereq_('../internals/global');
  22307. var isCallable = _dereq_('../internals/is-callable');
  22308. var WeakMap = global.WeakMap;
  22309. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  22310. },{"../internals/global":347,"../internals/is-callable":360}],441:[function(_dereq_,module,exports){
  22311. var path = _dereq_('../internals/path');
  22312. var hasOwn = _dereq_('../internals/has-own-property');
  22313. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  22314. var defineProperty = _dereq_('../internals/object-define-property').f;
  22315. module.exports = function (NAME) {
  22316. var Symbol = path.Symbol || (path.Symbol = {});
  22317. if (!hasOwn(Symbol, NAME)) defineProperty(Symbol, NAME, {
  22318. value: wrappedWellKnownSymbolModule.f(NAME)
  22319. });
  22320. };
  22321. },{"../internals/has-own-property":348,"../internals/object-define-property":388,"../internals/path":404,"../internals/well-known-symbol-wrapped":442}],442:[function(_dereq_,module,exports){
  22322. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22323. exports.f = wellKnownSymbol;
  22324. },{"../internals/well-known-symbol":443}],443:[function(_dereq_,module,exports){
  22325. var global = _dereq_('../internals/global');
  22326. var shared = _dereq_('../internals/shared');
  22327. var hasOwn = _dereq_('../internals/has-own-property');
  22328. var uid = _dereq_('../internals/uid');
  22329. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  22330. var USE_SYMBOL_AS_UID = _dereq_('../internals/use-symbol-as-uid');
  22331. var WellKnownSymbolsStore = shared('wks');
  22332. var Symbol = global.Symbol;
  22333. var symbolFor = Symbol && Symbol['for'];
  22334. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
  22335. module.exports = function (name) {
  22336. if (!hasOwn(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
  22337. var description = 'Symbol.' + name;
  22338. if (NATIVE_SYMBOL && hasOwn(Symbol, name)) {
  22339. WellKnownSymbolsStore[name] = Symbol[name];
  22340. } else if (USE_SYMBOL_AS_UID && symbolFor) {
  22341. WellKnownSymbolsStore[name] = symbolFor(description);
  22342. } else {
  22343. WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
  22344. }
  22345. } return WellKnownSymbolsStore[name];
  22346. };
  22347. },{"../internals/global":347,"../internals/has-own-property":348,"../internals/shared":418,"../internals/symbol-constructor-detection":422,"../internals/uid":436,"../internals/use-symbol-as-uid":437}],444:[function(_dereq_,module,exports){
  22348. // a string of all valid unicode whitespaces
  22349. module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
  22350. '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  22351. },{}],445:[function(_dereq_,module,exports){
  22352. 'use strict';
  22353. var $ = _dereq_('../internals/export');
  22354. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  22355. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  22356. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  22357. var copyConstructorProperties = _dereq_('../internals/copy-constructor-properties');
  22358. var create = _dereq_('../internals/object-create');
  22359. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  22360. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  22361. var clearErrorStack = _dereq_('../internals/error-stack-clear');
  22362. var installErrorCause = _dereq_('../internals/install-error-cause');
  22363. var iterate = _dereq_('../internals/iterate');
  22364. var normalizeStringArgument = _dereq_('../internals/normalize-string-argument');
  22365. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22366. var ERROR_STACK_INSTALLABLE = _dereq_('../internals/error-stack-installable');
  22367. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  22368. var $Error = Error;
  22369. var push = [].push;
  22370. var $AggregateError = function AggregateError(errors, message /* , options */) {
  22371. var options = arguments.length > 2 ? arguments[2] : undefined;
  22372. var isInstance = isPrototypeOf(AggregateErrorPrototype, this);
  22373. var that;
  22374. if (setPrototypeOf) {
  22375. that = setPrototypeOf($Error(), isInstance ? getPrototypeOf(this) : AggregateErrorPrototype);
  22376. } else {
  22377. that = isInstance ? this : create(AggregateErrorPrototype);
  22378. createNonEnumerableProperty(that, TO_STRING_TAG, 'Error');
  22379. }
  22380. if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message));
  22381. if (ERROR_STACK_INSTALLABLE) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1));
  22382. installErrorCause(that, options);
  22383. var errorsArray = [];
  22384. iterate(errors, push, { that: errorsArray });
  22385. createNonEnumerableProperty(that, 'errors', errorsArray);
  22386. return that;
  22387. };
  22388. if (setPrototypeOf) setPrototypeOf($AggregateError, $Error);
  22389. else copyConstructorProperties($AggregateError, $Error, { name: true });
  22390. var AggregateErrorPrototype = $AggregateError.prototype = create($Error.prototype, {
  22391. constructor: createPropertyDescriptor(1, $AggregateError),
  22392. message: createPropertyDescriptor(1, ''),
  22393. name: createPropertyDescriptor(1, 'AggregateError')
  22394. });
  22395. // `AggregateError` constructor
  22396. // https://tc39.es/ecma262/#sec-aggregate-error-constructor
  22397. $({ global: true, constructor: true, arity: 2 }, {
  22398. AggregateError: $AggregateError
  22399. });
  22400. },{"../internals/copy-constructor-properties":302,"../internals/create-non-enumerable-property":306,"../internals/create-property-descriptor":307,"../internals/error-stack-clear":330,"../internals/error-stack-installable":331,"../internals/export":332,"../internals/install-error-cause":355,"../internals/iterate":370,"../internals/normalize-string-argument":382,"../internals/object-create":386,"../internals/object-get-prototype-of":393,"../internals/object-is-prototype-of":395,"../internals/object-set-prototype-of":399,"../internals/well-known-symbol":443}],446:[function(_dereq_,module,exports){
  22401. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  22402. _dereq_('../modules/es.aggregate-error.constructor');
  22403. },{"../modules/es.aggregate-error.constructor":445}],447:[function(_dereq_,module,exports){
  22404. 'use strict';
  22405. var $ = _dereq_('../internals/export');
  22406. var fails = _dereq_('../internals/fails');
  22407. var isArray = _dereq_('../internals/is-array');
  22408. var isObject = _dereq_('../internals/is-object');
  22409. var toObject = _dereq_('../internals/to-object');
  22410. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  22411. var doesNotExceedSafeInteger = _dereq_('../internals/does-not-exceed-safe-integer');
  22412. var createProperty = _dereq_('../internals/create-property');
  22413. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  22414. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  22415. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22416. var V8_VERSION = _dereq_('../internals/engine-v8-version');
  22417. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  22418. // We can't use this feature detection in V8 since it causes
  22419. // deoptimization and serious performance degradation
  22420. // https://github.com/zloirock/core-js/issues/679
  22421. var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
  22422. var array = [];
  22423. array[IS_CONCAT_SPREADABLE] = false;
  22424. return array.concat()[0] !== array;
  22425. });
  22426. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  22427. var isConcatSpreadable = function (O) {
  22428. if (!isObject(O)) return false;
  22429. var spreadable = O[IS_CONCAT_SPREADABLE];
  22430. return spreadable !== undefined ? !!spreadable : isArray(O);
  22431. };
  22432. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  22433. // `Array.prototype.concat` method
  22434. // https://tc39.es/ecma262/#sec-array.prototype.concat
  22435. // with adding support of @@isConcatSpreadable and @@species
  22436. $({ target: 'Array', proto: true, arity: 1, forced: FORCED }, {
  22437. // eslint-disable-next-line no-unused-vars -- required for `.length`
  22438. concat: function concat(arg) {
  22439. var O = toObject(this);
  22440. var A = arraySpeciesCreate(O, 0);
  22441. var n = 0;
  22442. var i, k, length, len, E;
  22443. for (i = -1, length = arguments.length; i < length; i++) {
  22444. E = i === -1 ? O : arguments[i];
  22445. if (isConcatSpreadable(E)) {
  22446. len = lengthOfArrayLike(E);
  22447. doesNotExceedSafeInteger(n + len);
  22448. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  22449. } else {
  22450. doesNotExceedSafeInteger(n + 1);
  22451. createProperty(A, n++, E);
  22452. }
  22453. }
  22454. A.length = n;
  22455. return A;
  22456. }
  22457. });
  22458. },{"../internals/array-method-has-species-support":283,"../internals/array-species-create":291,"../internals/create-property":308,"../internals/does-not-exceed-safe-integer":315,"../internals/engine-v8-version":326,"../internals/export":332,"../internals/fails":333,"../internals/is-array":359,"../internals/is-object":366,"../internals/length-of-array-like":376,"../internals/to-object":430,"../internals/well-known-symbol":443}],448:[function(_dereq_,module,exports){
  22459. 'use strict';
  22460. var $ = _dereq_('../internals/export');
  22461. var $every = _dereq_('../internals/array-iteration').every;
  22462. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  22463. var STRICT_METHOD = arrayMethodIsStrict('every');
  22464. // `Array.prototype.every` method
  22465. // https://tc39.es/ecma262/#sec-array.prototype.every
  22466. $({ target: 'Array', proto: true, forced: !STRICT_METHOD }, {
  22467. every: function every(callbackfn /* , thisArg */) {
  22468. return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  22469. }
  22470. });
  22471. },{"../internals/array-iteration":282,"../internals/array-method-is-strict":284,"../internals/export":332}],449:[function(_dereq_,module,exports){
  22472. 'use strict';
  22473. var $ = _dereq_('../internals/export');
  22474. var $filter = _dereq_('../internals/array-iteration').filter;
  22475. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  22476. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
  22477. // `Array.prototype.filter` method
  22478. // https://tc39.es/ecma262/#sec-array.prototype.filter
  22479. // with adding support of @@species
  22480. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  22481. filter: function filter(callbackfn /* , thisArg */) {
  22482. return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  22483. }
  22484. });
  22485. },{"../internals/array-iteration":282,"../internals/array-method-has-species-support":283,"../internals/export":332}],450:[function(_dereq_,module,exports){
  22486. 'use strict';
  22487. var $ = _dereq_('../internals/export');
  22488. var $findIndex = _dereq_('../internals/array-iteration').findIndex;
  22489. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  22490. var FIND_INDEX = 'findIndex';
  22491. var SKIPS_HOLES = true;
  22492. // Shouldn't skip holes
  22493. if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; });
  22494. // `Array.prototype.findIndex` method
  22495. // https://tc39.es/ecma262/#sec-array.prototype.findindex
  22496. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  22497. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  22498. return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  22499. }
  22500. });
  22501. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  22502. addToUnscopables(FIND_INDEX);
  22503. },{"../internals/add-to-unscopables":275,"../internals/array-iteration":282,"../internals/export":332}],451:[function(_dereq_,module,exports){
  22504. 'use strict';
  22505. var $ = _dereq_('../internals/export');
  22506. var $find = _dereq_('../internals/array-iteration').find;
  22507. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  22508. var FIND = 'find';
  22509. var SKIPS_HOLES = true;
  22510. // Shouldn't skip holes
  22511. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  22512. // `Array.prototype.find` method
  22513. // https://tc39.es/ecma262/#sec-array.prototype.find
  22514. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  22515. find: function find(callbackfn /* , that = undefined */) {
  22516. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  22517. }
  22518. });
  22519. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  22520. addToUnscopables(FIND);
  22521. },{"../internals/add-to-unscopables":275,"../internals/array-iteration":282,"../internals/export":332}],452:[function(_dereq_,module,exports){
  22522. 'use strict';
  22523. var $ = _dereq_('../internals/export');
  22524. var forEach = _dereq_('../internals/array-for-each');
  22525. // `Array.prototype.forEach` method
  22526. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  22527. // eslint-disable-next-line es-x/no-array-prototype-foreach -- safe
  22528. $({ target: 'Array', proto: true, forced: [].forEach != forEach }, {
  22529. forEach: forEach
  22530. });
  22531. },{"../internals/array-for-each":279,"../internals/export":332}],453:[function(_dereq_,module,exports){
  22532. var $ = _dereq_('../internals/export');
  22533. var from = _dereq_('../internals/array-from');
  22534. var checkCorrectnessOfIteration = _dereq_('../internals/check-correctness-of-iteration');
  22535. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  22536. // eslint-disable-next-line es-x/no-array-from -- required for testing
  22537. Array.from(iterable);
  22538. });
  22539. // `Array.from` method
  22540. // https://tc39.es/ecma262/#sec-array.from
  22541. $({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
  22542. from: from
  22543. });
  22544. },{"../internals/array-from":280,"../internals/check-correctness-of-iteration":293,"../internals/export":332}],454:[function(_dereq_,module,exports){
  22545. 'use strict';
  22546. var $ = _dereq_('../internals/export');
  22547. var $includes = _dereq_('../internals/array-includes').includes;
  22548. var fails = _dereq_('../internals/fails');
  22549. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  22550. // FF99+ bug
  22551. var BROKEN_ON_SPARSE = fails(function () {
  22552. return !Array(1).includes();
  22553. });
  22554. // `Array.prototype.includes` method
  22555. // https://tc39.es/ecma262/#sec-array.prototype.includes
  22556. $({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
  22557. includes: function includes(el /* , fromIndex = 0 */) {
  22558. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  22559. }
  22560. });
  22561. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  22562. addToUnscopables('includes');
  22563. },{"../internals/add-to-unscopables":275,"../internals/array-includes":281,"../internals/export":332,"../internals/fails":333}],455:[function(_dereq_,module,exports){
  22564. 'use strict';
  22565. /* eslint-disable es-x/no-array-prototype-indexof -- required for testing */
  22566. var $ = _dereq_('../internals/export');
  22567. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  22568. var $indexOf = _dereq_('../internals/array-includes').indexOf;
  22569. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  22570. var nativeIndexOf = uncurryThis([].indexOf);
  22571. var NEGATIVE_ZERO = !!nativeIndexOf && 1 / nativeIndexOf([1], 1, -0) < 0;
  22572. var STRICT_METHOD = arrayMethodIsStrict('indexOf');
  22573. // `Array.prototype.indexOf` method
  22574. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  22575. $({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD }, {
  22576. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  22577. var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
  22578. return NEGATIVE_ZERO
  22579. // convert -0 to +0
  22580. ? nativeIndexOf(this, searchElement, fromIndex) || 0
  22581. : $indexOf(this, searchElement, fromIndex);
  22582. }
  22583. });
  22584. },{"../internals/array-includes":281,"../internals/array-method-is-strict":284,"../internals/export":332,"../internals/function-uncurry-this":341}],456:[function(_dereq_,module,exports){
  22585. var $ = _dereq_('../internals/export');
  22586. var isArray = _dereq_('../internals/is-array');
  22587. // `Array.isArray` method
  22588. // https://tc39.es/ecma262/#sec-array.isarray
  22589. $({ target: 'Array', stat: true }, {
  22590. isArray: isArray
  22591. });
  22592. },{"../internals/export":332,"../internals/is-array":359}],457:[function(_dereq_,module,exports){
  22593. 'use strict';
  22594. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  22595. var addToUnscopables = _dereq_('../internals/add-to-unscopables');
  22596. var Iterators = _dereq_('../internals/iterators');
  22597. var InternalStateModule = _dereq_('../internals/internal-state');
  22598. var defineProperty = _dereq_('../internals/object-define-property').f;
  22599. var defineIterator = _dereq_('../internals/iterator-define');
  22600. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  22601. var IS_PURE = _dereq_('../internals/is-pure');
  22602. var DESCRIPTORS = _dereq_('../internals/descriptors');
  22603. var ARRAY_ITERATOR = 'Array Iterator';
  22604. var setInternalState = InternalStateModule.set;
  22605. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  22606. // `Array.prototype.entries` method
  22607. // https://tc39.es/ecma262/#sec-array.prototype.entries
  22608. // `Array.prototype.keys` method
  22609. // https://tc39.es/ecma262/#sec-array.prototype.keys
  22610. // `Array.prototype.values` method
  22611. // https://tc39.es/ecma262/#sec-array.prototype.values
  22612. // `Array.prototype[@@iterator]` method
  22613. // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
  22614. // `CreateArrayIterator` internal method
  22615. // https://tc39.es/ecma262/#sec-createarrayiterator
  22616. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  22617. setInternalState(this, {
  22618. type: ARRAY_ITERATOR,
  22619. target: toIndexedObject(iterated), // target
  22620. index: 0, // next index
  22621. kind: kind // kind
  22622. });
  22623. // `%ArrayIteratorPrototype%.next` method
  22624. // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
  22625. }, function () {
  22626. var state = getInternalState(this);
  22627. var target = state.target;
  22628. var kind = state.kind;
  22629. var index = state.index++;
  22630. if (!target || index >= target.length) {
  22631. state.target = undefined;
  22632. return createIterResultObject(undefined, true);
  22633. }
  22634. if (kind == 'keys') return createIterResultObject(index, false);
  22635. if (kind == 'values') return createIterResultObject(target[index], false);
  22636. return createIterResultObject([index, target[index]], false);
  22637. }, 'values');
  22638. // argumentsList[@@iterator] is %ArrayProto_values%
  22639. // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
  22640. // https://tc39.es/ecma262/#sec-createmappedargumentsobject
  22641. var values = Iterators.Arguments = Iterators.Array;
  22642. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  22643. addToUnscopables('keys');
  22644. addToUnscopables('values');
  22645. addToUnscopables('entries');
  22646. // V8 ~ Chrome 45- bug
  22647. if (!IS_PURE && DESCRIPTORS && values.name !== 'values') try {
  22648. defineProperty(values, 'name', { value: 'values' });
  22649. } catch (error) { /* empty */ }
  22650. },{"../internals/add-to-unscopables":275,"../internals/create-iter-result-object":305,"../internals/descriptors":313,"../internals/internal-state":357,"../internals/is-pure":367,"../internals/iterator-define":373,"../internals/iterators":375,"../internals/object-define-property":388,"../internals/to-indexed-object":427}],458:[function(_dereq_,module,exports){
  22651. 'use strict';
  22652. var $ = _dereq_('../internals/export');
  22653. var $map = _dereq_('../internals/array-iteration').map;
  22654. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  22655. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');
  22656. // `Array.prototype.map` method
  22657. // https://tc39.es/ecma262/#sec-array.prototype.map
  22658. // with adding support of @@species
  22659. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  22660. map: function map(callbackfn /* , thisArg */) {
  22661. return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  22662. }
  22663. });
  22664. },{"../internals/array-iteration":282,"../internals/array-method-has-species-support":283,"../internals/export":332}],459:[function(_dereq_,module,exports){
  22665. 'use strict';
  22666. var $ = _dereq_('../internals/export');
  22667. var $reduce = _dereq_('../internals/array-reduce').left;
  22668. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  22669. var CHROME_VERSION = _dereq_('../internals/engine-v8-version');
  22670. var IS_NODE = _dereq_('../internals/engine-is-node');
  22671. var STRICT_METHOD = arrayMethodIsStrict('reduce');
  22672. // Chrome 80-82 has a critical bug
  22673. // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
  22674. var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
  22675. // `Array.prototype.reduce` method
  22676. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  22677. $({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
  22678. reduce: function reduce(callbackfn /* , initialValue */) {
  22679. var length = arguments.length;
  22680. return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
  22681. }
  22682. });
  22683. },{"../internals/array-method-is-strict":284,"../internals/array-reduce":285,"../internals/engine-is-node":323,"../internals/engine-v8-version":326,"../internals/export":332}],460:[function(_dereq_,module,exports){
  22684. 'use strict';
  22685. var $ = _dereq_('../internals/export');
  22686. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  22687. var isArray = _dereq_('../internals/is-array');
  22688. var nativeReverse = uncurryThis([].reverse);
  22689. var test = [1, 2];
  22690. // `Array.prototype.reverse` method
  22691. // https://tc39.es/ecma262/#sec-array.prototype.reverse
  22692. // fix for Safari 12.0 bug
  22693. // https://bugs.webkit.org/show_bug.cgi?id=188794
  22694. $({ target: 'Array', proto: true, forced: String(test) === String(test.reverse()) }, {
  22695. reverse: function reverse() {
  22696. // eslint-disable-next-line no-self-assign -- dirty hack
  22697. if (isArray(this)) this.length = this.length;
  22698. return nativeReverse(this);
  22699. }
  22700. });
  22701. },{"../internals/export":332,"../internals/function-uncurry-this":341,"../internals/is-array":359}],461:[function(_dereq_,module,exports){
  22702. 'use strict';
  22703. var $ = _dereq_('../internals/export');
  22704. var isArray = _dereq_('../internals/is-array');
  22705. var isConstructor = _dereq_('../internals/is-constructor');
  22706. var isObject = _dereq_('../internals/is-object');
  22707. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  22708. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  22709. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  22710. var createProperty = _dereq_('../internals/create-property');
  22711. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  22712. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  22713. var nativeSlice = _dereq_('../internals/array-slice');
  22714. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
  22715. var SPECIES = wellKnownSymbol('species');
  22716. var $Array = Array;
  22717. var max = Math.max;
  22718. // `Array.prototype.slice` method
  22719. // https://tc39.es/ecma262/#sec-array.prototype.slice
  22720. // fallback for not array-like ES3 strings and DOM objects
  22721. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  22722. slice: function slice(start, end) {
  22723. var O = toIndexedObject(this);
  22724. var length = lengthOfArrayLike(O);
  22725. var k = toAbsoluteIndex(start, length);
  22726. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  22727. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  22728. var Constructor, result, n;
  22729. if (isArray(O)) {
  22730. Constructor = O.constructor;
  22731. // cross-realm fallback
  22732. if (isConstructor(Constructor) && (Constructor === $Array || isArray(Constructor.prototype))) {
  22733. Constructor = undefined;
  22734. } else if (isObject(Constructor)) {
  22735. Constructor = Constructor[SPECIES];
  22736. if (Constructor === null) Constructor = undefined;
  22737. }
  22738. if (Constructor === $Array || Constructor === undefined) {
  22739. return nativeSlice(O, k, fin);
  22740. }
  22741. }
  22742. result = new (Constructor === undefined ? $Array : Constructor)(max(fin - k, 0));
  22743. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  22744. result.length = n;
  22745. return result;
  22746. }
  22747. });
  22748. },{"../internals/array-method-has-species-support":283,"../internals/array-slice":288,"../internals/create-property":308,"../internals/export":332,"../internals/is-array":359,"../internals/is-constructor":361,"../internals/is-object":366,"../internals/length-of-array-like":376,"../internals/to-absolute-index":426,"../internals/to-indexed-object":427,"../internals/well-known-symbol":443}],462:[function(_dereq_,module,exports){
  22749. 'use strict';
  22750. var $ = _dereq_('../internals/export');
  22751. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  22752. var aCallable = _dereq_('../internals/a-callable');
  22753. var toObject = _dereq_('../internals/to-object');
  22754. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  22755. var deletePropertyOrThrow = _dereq_('../internals/delete-property-or-throw');
  22756. var toString = _dereq_('../internals/to-string');
  22757. var fails = _dereq_('../internals/fails');
  22758. var internalSort = _dereq_('../internals/array-sort');
  22759. var arrayMethodIsStrict = _dereq_('../internals/array-method-is-strict');
  22760. var FF = _dereq_('../internals/engine-ff-version');
  22761. var IE_OR_EDGE = _dereq_('../internals/engine-is-ie-or-edge');
  22762. var V8 = _dereq_('../internals/engine-v8-version');
  22763. var WEBKIT = _dereq_('../internals/engine-webkit-version');
  22764. var test = [];
  22765. var nativeSort = uncurryThis(test.sort);
  22766. var push = uncurryThis(test.push);
  22767. // IE8-
  22768. var FAILS_ON_UNDEFINED = fails(function () {
  22769. test.sort(undefined);
  22770. });
  22771. // V8 bug
  22772. var FAILS_ON_NULL = fails(function () {
  22773. test.sort(null);
  22774. });
  22775. // Old WebKit
  22776. var STRICT_METHOD = arrayMethodIsStrict('sort');
  22777. var STABLE_SORT = !fails(function () {
  22778. // feature detection can be too slow, so check engines versions
  22779. if (V8) return V8 < 70;
  22780. if (FF && FF > 3) return;
  22781. if (IE_OR_EDGE) return true;
  22782. if (WEBKIT) return WEBKIT < 603;
  22783. var result = '';
  22784. var code, chr, value, index;
  22785. // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
  22786. for (code = 65; code < 76; code++) {
  22787. chr = String.fromCharCode(code);
  22788. switch (code) {
  22789. case 66: case 69: case 70: case 72: value = 3; break;
  22790. case 68: case 71: value = 4; break;
  22791. default: value = 2;
  22792. }
  22793. for (index = 0; index < 47; index++) {
  22794. test.push({ k: chr + index, v: value });
  22795. }
  22796. }
  22797. test.sort(function (a, b) { return b.v - a.v; });
  22798. for (index = 0; index < test.length; index++) {
  22799. chr = test[index].k.charAt(0);
  22800. if (result.charAt(result.length - 1) !== chr) result += chr;
  22801. }
  22802. return result !== 'DGBEFHACIJK';
  22803. });
  22804. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
  22805. var getSortCompare = function (comparefn) {
  22806. return function (x, y) {
  22807. if (y === undefined) return -1;
  22808. if (x === undefined) return 1;
  22809. if (comparefn !== undefined) return +comparefn(x, y) || 0;
  22810. return toString(x) > toString(y) ? 1 : -1;
  22811. };
  22812. };
  22813. // `Array.prototype.sort` method
  22814. // https://tc39.es/ecma262/#sec-array.prototype.sort
  22815. $({ target: 'Array', proto: true, forced: FORCED }, {
  22816. sort: function sort(comparefn) {
  22817. if (comparefn !== undefined) aCallable(comparefn);
  22818. var array = toObject(this);
  22819. if (STABLE_SORT) return comparefn === undefined ? nativeSort(array) : nativeSort(array, comparefn);
  22820. var items = [];
  22821. var arrayLength = lengthOfArrayLike(array);
  22822. var itemsLength, index;
  22823. for (index = 0; index < arrayLength; index++) {
  22824. if (index in array) push(items, array[index]);
  22825. }
  22826. internalSort(items, getSortCompare(comparefn));
  22827. itemsLength = lengthOfArrayLike(items);
  22828. index = 0;
  22829. while (index < itemsLength) array[index] = items[index++];
  22830. while (index < arrayLength) deletePropertyOrThrow(array, index++);
  22831. return array;
  22832. }
  22833. });
  22834. },{"../internals/a-callable":272,"../internals/array-method-is-strict":284,"../internals/array-sort":289,"../internals/delete-property-or-throw":312,"../internals/engine-ff-version":317,"../internals/engine-is-ie-or-edge":320,"../internals/engine-v8-version":326,"../internals/engine-webkit-version":327,"../internals/export":332,"../internals/fails":333,"../internals/function-uncurry-this":341,"../internals/length-of-array-like":376,"../internals/to-object":430,"../internals/to-string":434}],463:[function(_dereq_,module,exports){
  22835. 'use strict';
  22836. var $ = _dereq_('../internals/export');
  22837. var toObject = _dereq_('../internals/to-object');
  22838. var toAbsoluteIndex = _dereq_('../internals/to-absolute-index');
  22839. var toIntegerOrInfinity = _dereq_('../internals/to-integer-or-infinity');
  22840. var lengthOfArrayLike = _dereq_('../internals/length-of-array-like');
  22841. var setArrayLength = _dereq_('../internals/array-set-length');
  22842. var doesNotExceedSafeInteger = _dereq_('../internals/does-not-exceed-safe-integer');
  22843. var arraySpeciesCreate = _dereq_('../internals/array-species-create');
  22844. var createProperty = _dereq_('../internals/create-property');
  22845. var deletePropertyOrThrow = _dereq_('../internals/delete-property-or-throw');
  22846. var arrayMethodHasSpeciesSupport = _dereq_('../internals/array-method-has-species-support');
  22847. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
  22848. var max = Math.max;
  22849. var min = Math.min;
  22850. // `Array.prototype.splice` method
  22851. // https://tc39.es/ecma262/#sec-array.prototype.splice
  22852. // with adding support of @@species
  22853. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  22854. splice: function splice(start, deleteCount /* , ...items */) {
  22855. var O = toObject(this);
  22856. var len = lengthOfArrayLike(O);
  22857. var actualStart = toAbsoluteIndex(start, len);
  22858. var argumentsLength = arguments.length;
  22859. var insertCount, actualDeleteCount, A, k, from, to;
  22860. if (argumentsLength === 0) {
  22861. insertCount = actualDeleteCount = 0;
  22862. } else if (argumentsLength === 1) {
  22863. insertCount = 0;
  22864. actualDeleteCount = len - actualStart;
  22865. } else {
  22866. insertCount = argumentsLength - 2;
  22867. actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
  22868. }
  22869. doesNotExceedSafeInteger(len + insertCount - actualDeleteCount);
  22870. A = arraySpeciesCreate(O, actualDeleteCount);
  22871. for (k = 0; k < actualDeleteCount; k++) {
  22872. from = actualStart + k;
  22873. if (from in O) createProperty(A, k, O[from]);
  22874. }
  22875. A.length = actualDeleteCount;
  22876. if (insertCount < actualDeleteCount) {
  22877. for (k = actualStart; k < len - actualDeleteCount; k++) {
  22878. from = k + actualDeleteCount;
  22879. to = k + insertCount;
  22880. if (from in O) O[to] = O[from];
  22881. else deletePropertyOrThrow(O, to);
  22882. }
  22883. for (k = len; k > len - actualDeleteCount + insertCount; k--) deletePropertyOrThrow(O, k - 1);
  22884. } else if (insertCount > actualDeleteCount) {
  22885. for (k = len - actualDeleteCount; k > actualStart; k--) {
  22886. from = k + actualDeleteCount - 1;
  22887. to = k + insertCount - 1;
  22888. if (from in O) O[to] = O[from];
  22889. else deletePropertyOrThrow(O, to);
  22890. }
  22891. }
  22892. for (k = 0; k < insertCount; k++) {
  22893. O[k + actualStart] = arguments[k + 2];
  22894. }
  22895. setArrayLength(O, len - actualDeleteCount + insertCount);
  22896. return A;
  22897. }
  22898. });
  22899. },{"../internals/array-method-has-species-support":283,"../internals/array-set-length":286,"../internals/array-species-create":291,"../internals/create-property":308,"../internals/delete-property-or-throw":312,"../internals/does-not-exceed-safe-integer":315,"../internals/export":332,"../internals/length-of-array-like":376,"../internals/to-absolute-index":426,"../internals/to-integer-or-infinity":428,"../internals/to-object":430}],464:[function(_dereq_,module,exports){
  22900. // empty
  22901. },{}],465:[function(_dereq_,module,exports){
  22902. // TODO: Remove from `core-js@4`
  22903. var $ = _dereq_('../internals/export');
  22904. var bind = _dereq_('../internals/function-bind');
  22905. // `Function.prototype.bind` method
  22906. // https://tc39.es/ecma262/#sec-function.prototype.bind
  22907. $({ target: 'Function', proto: true, forced: Function.bind !== bind }, {
  22908. bind: bind
  22909. });
  22910. },{"../internals/export":332,"../internals/function-bind":338}],466:[function(_dereq_,module,exports){
  22911. var $ = _dereq_('../internals/export');
  22912. var getBuiltIn = _dereq_('../internals/get-built-in');
  22913. var apply = _dereq_('../internals/function-apply');
  22914. var call = _dereq_('../internals/function-call');
  22915. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  22916. var fails = _dereq_('../internals/fails');
  22917. var isArray = _dereq_('../internals/is-array');
  22918. var isCallable = _dereq_('../internals/is-callable');
  22919. var isObject = _dereq_('../internals/is-object');
  22920. var isSymbol = _dereq_('../internals/is-symbol');
  22921. var arraySlice = _dereq_('../internals/array-slice');
  22922. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  22923. var $stringify = getBuiltIn('JSON', 'stringify');
  22924. var exec = uncurryThis(/./.exec);
  22925. var charAt = uncurryThis(''.charAt);
  22926. var charCodeAt = uncurryThis(''.charCodeAt);
  22927. var replace = uncurryThis(''.replace);
  22928. var numberToString = uncurryThis(1.0.toString);
  22929. var tester = /[\uD800-\uDFFF]/g;
  22930. var low = /^[\uD800-\uDBFF]$/;
  22931. var hi = /^[\uDC00-\uDFFF]$/;
  22932. var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () {
  22933. var symbol = getBuiltIn('Symbol')();
  22934. // MS Edge converts symbol values to JSON as {}
  22935. return $stringify([symbol]) != '[null]'
  22936. // WebKit converts symbol values to JSON as null
  22937. || $stringify({ a: symbol }) != '{}'
  22938. // V8 throws on boxed symbols
  22939. || $stringify(Object(symbol)) != '{}';
  22940. });
  22941. // https://github.com/tc39/proposal-well-formed-stringify
  22942. var ILL_FORMED_UNICODE = fails(function () {
  22943. return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"'
  22944. || $stringify('\uDEAD') !== '"\\udead"';
  22945. });
  22946. var stringifyWithSymbolsFix = function (it, replacer) {
  22947. var args = arraySlice(arguments);
  22948. var $replacer = replacer;
  22949. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  22950. if (!isArray(replacer)) replacer = function (key, value) {
  22951. if (isCallable($replacer)) value = call($replacer, this, key, value);
  22952. if (!isSymbol(value)) return value;
  22953. };
  22954. args[1] = replacer;
  22955. return apply($stringify, null, args);
  22956. };
  22957. var fixIllFormed = function (match, offset, string) {
  22958. var prev = charAt(string, offset - 1);
  22959. var next = charAt(string, offset + 1);
  22960. if ((exec(low, match) && !exec(hi, next)) || (exec(hi, match) && !exec(low, prev))) {
  22961. return '\\u' + numberToString(charCodeAt(match, 0), 16);
  22962. } return match;
  22963. };
  22964. if ($stringify) {
  22965. // `JSON.stringify` method
  22966. // https://tc39.es/ecma262/#sec-json.stringify
  22967. $({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, {
  22968. // eslint-disable-next-line no-unused-vars -- required for `.length`
  22969. stringify: function stringify(it, replacer, space) {
  22970. var args = arraySlice(arguments);
  22971. var result = apply(WRONG_SYMBOLS_CONVERSION ? stringifyWithSymbolsFix : $stringify, null, args);
  22972. return ILL_FORMED_UNICODE && typeof result == 'string' ? replace(result, tester, fixIllFormed) : result;
  22973. }
  22974. });
  22975. }
  22976. },{"../internals/array-slice":288,"../internals/export":332,"../internals/fails":333,"../internals/function-apply":335,"../internals/function-call":339,"../internals/function-uncurry-this":341,"../internals/get-built-in":342,"../internals/is-array":359,"../internals/is-callable":360,"../internals/is-object":366,"../internals/is-symbol":369,"../internals/symbol-constructor-detection":422}],467:[function(_dereq_,module,exports){
  22977. var global = _dereq_('../internals/global');
  22978. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  22979. // JSON[@@toStringTag] property
  22980. // https://tc39.es/ecma262/#sec-json-@@tostringtag
  22981. setToStringTag(global.JSON, 'JSON', true);
  22982. },{"../internals/global":347,"../internals/set-to-string-tag":415}],468:[function(_dereq_,module,exports){
  22983. 'use strict';
  22984. var collection = _dereq_('../internals/collection');
  22985. var collectionStrong = _dereq_('../internals/collection-strong');
  22986. // `Map` constructor
  22987. // https://tc39.es/ecma262/#sec-map-objects
  22988. collection('Map', function (init) {
  22989. return function Map() { return init(this, arguments.length ? arguments[0] : undefined); };
  22990. }, collectionStrong);
  22991. },{"../internals/collection":301,"../internals/collection-strong":299}],469:[function(_dereq_,module,exports){
  22992. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  22993. _dereq_('../modules/es.map.constructor');
  22994. },{"../modules/es.map.constructor":468}],470:[function(_dereq_,module,exports){
  22995. arguments[4][464][0].apply(exports,arguments)
  22996. },{"dup":464}],471:[function(_dereq_,module,exports){
  22997. var $ = _dereq_('../internals/export');
  22998. var isIntegralNumber = _dereq_('../internals/is-integral-number');
  22999. // `Number.isInteger` method
  23000. // https://tc39.es/ecma262/#sec-number.isinteger
  23001. $({ target: 'Number', stat: true }, {
  23002. isInteger: isIntegralNumber
  23003. });
  23004. },{"../internals/export":332,"../internals/is-integral-number":364}],472:[function(_dereq_,module,exports){
  23005. var $ = _dereq_('../internals/export');
  23006. var assign = _dereq_('../internals/object-assign');
  23007. // `Object.assign` method
  23008. // https://tc39.es/ecma262/#sec-object.assign
  23009. // eslint-disable-next-line es-x/no-object-assign -- required for testing
  23010. $({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
  23011. assign: assign
  23012. });
  23013. },{"../internals/export":332,"../internals/object-assign":385}],473:[function(_dereq_,module,exports){
  23014. // TODO: Remove from `core-js@4`
  23015. var $ = _dereq_('../internals/export');
  23016. var DESCRIPTORS = _dereq_('../internals/descriptors');
  23017. var create = _dereq_('../internals/object-create');
  23018. // `Object.create` method
  23019. // https://tc39.es/ecma262/#sec-object.create
  23020. $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
  23021. create: create
  23022. });
  23023. },{"../internals/descriptors":313,"../internals/export":332,"../internals/object-create":386}],474:[function(_dereq_,module,exports){
  23024. var $ = _dereq_('../internals/export');
  23025. var DESCRIPTORS = _dereq_('../internals/descriptors');
  23026. var defineProperties = _dereq_('../internals/object-define-properties').f;
  23027. // `Object.defineProperties` method
  23028. // https://tc39.es/ecma262/#sec-object.defineproperties
  23029. // eslint-disable-next-line es-x/no-object-defineproperties -- safe
  23030. $({ target: 'Object', stat: true, forced: Object.defineProperties !== defineProperties, sham: !DESCRIPTORS }, {
  23031. defineProperties: defineProperties
  23032. });
  23033. },{"../internals/descriptors":313,"../internals/export":332,"../internals/object-define-properties":387}],475:[function(_dereq_,module,exports){
  23034. var $ = _dereq_('../internals/export');
  23035. var DESCRIPTORS = _dereq_('../internals/descriptors');
  23036. var defineProperty = _dereq_('../internals/object-define-property').f;
  23037. // `Object.defineProperty` method
  23038. // https://tc39.es/ecma262/#sec-object.defineproperty
  23039. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  23040. $({ target: 'Object', stat: true, forced: Object.defineProperty !== defineProperty, sham: !DESCRIPTORS }, {
  23041. defineProperty: defineProperty
  23042. });
  23043. },{"../internals/descriptors":313,"../internals/export":332,"../internals/object-define-property":388}],476:[function(_dereq_,module,exports){
  23044. var $ = _dereq_('../internals/export');
  23045. var $entries = _dereq_('../internals/object-to-array').entries;
  23046. // `Object.entries` method
  23047. // https://tc39.es/ecma262/#sec-object.entries
  23048. $({ target: 'Object', stat: true }, {
  23049. entries: function entries(O) {
  23050. return $entries(O);
  23051. }
  23052. });
  23053. },{"../internals/export":332,"../internals/object-to-array":400}],477:[function(_dereq_,module,exports){
  23054. var $ = _dereq_('../internals/export');
  23055. var FREEZING = _dereq_('../internals/freezing');
  23056. var fails = _dereq_('../internals/fails');
  23057. var isObject = _dereq_('../internals/is-object');
  23058. var onFreeze = _dereq_('../internals/internal-metadata').onFreeze;
  23059. // eslint-disable-next-line es-x/no-object-freeze -- safe
  23060. var $freeze = Object.freeze;
  23061. var FAILS_ON_PRIMITIVES = fails(function () { $freeze(1); });
  23062. // `Object.freeze` method
  23063. // https://tc39.es/ecma262/#sec-object.freeze
  23064. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, {
  23065. freeze: function freeze(it) {
  23066. return $freeze && isObject(it) ? $freeze(onFreeze(it)) : it;
  23067. }
  23068. });
  23069. },{"../internals/export":332,"../internals/fails":333,"../internals/freezing":334,"../internals/internal-metadata":356,"../internals/is-object":366}],478:[function(_dereq_,module,exports){
  23070. var $ = _dereq_('../internals/export');
  23071. var fails = _dereq_('../internals/fails');
  23072. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  23073. var nativeGetOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  23074. var DESCRIPTORS = _dereq_('../internals/descriptors');
  23075. var FAILS_ON_PRIMITIVES = fails(function () { nativeGetOwnPropertyDescriptor(1); });
  23076. var FORCED = !DESCRIPTORS || FAILS_ON_PRIMITIVES;
  23077. // `Object.getOwnPropertyDescriptor` method
  23078. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  23079. $({ target: 'Object', stat: true, forced: FORCED, sham: !DESCRIPTORS }, {
  23080. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
  23081. return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key);
  23082. }
  23083. });
  23084. },{"../internals/descriptors":313,"../internals/export":332,"../internals/fails":333,"../internals/object-get-own-property-descriptor":389,"../internals/to-indexed-object":427}],479:[function(_dereq_,module,exports){
  23085. var $ = _dereq_('../internals/export');
  23086. var DESCRIPTORS = _dereq_('../internals/descriptors');
  23087. var ownKeys = _dereq_('../internals/own-keys');
  23088. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  23089. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  23090. var createProperty = _dereq_('../internals/create-property');
  23091. // `Object.getOwnPropertyDescriptors` method
  23092. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  23093. $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, {
  23094. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  23095. var O = toIndexedObject(object);
  23096. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  23097. var keys = ownKeys(O);
  23098. var result = {};
  23099. var index = 0;
  23100. var key, descriptor;
  23101. while (keys.length > index) {
  23102. descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
  23103. if (descriptor !== undefined) createProperty(result, key, descriptor);
  23104. }
  23105. return result;
  23106. }
  23107. });
  23108. },{"../internals/create-property":308,"../internals/descriptors":313,"../internals/export":332,"../internals/object-get-own-property-descriptor":389,"../internals/own-keys":403,"../internals/to-indexed-object":427}],480:[function(_dereq_,module,exports){
  23109. var $ = _dereq_('../internals/export');
  23110. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  23111. var fails = _dereq_('../internals/fails');
  23112. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  23113. var toObject = _dereq_('../internals/to-object');
  23114. // V8 ~ Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
  23115. // https://bugs.chromium.org/p/v8/issues/detail?id=3443
  23116. var FORCED = !NATIVE_SYMBOL || fails(function () { getOwnPropertySymbolsModule.f(1); });
  23117. // `Object.getOwnPropertySymbols` method
  23118. // https://tc39.es/ecma262/#sec-object.getownpropertysymbols
  23119. $({ target: 'Object', stat: true, forced: FORCED }, {
  23120. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  23121. var $getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  23122. return $getOwnPropertySymbols ? $getOwnPropertySymbols(toObject(it)) : [];
  23123. }
  23124. });
  23125. },{"../internals/export":332,"../internals/fails":333,"../internals/object-get-own-property-symbols":392,"../internals/symbol-constructor-detection":422,"../internals/to-object":430}],481:[function(_dereq_,module,exports){
  23126. var $ = _dereq_('../internals/export');
  23127. var fails = _dereq_('../internals/fails');
  23128. var toObject = _dereq_('../internals/to-object');
  23129. var nativeGetPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  23130. var CORRECT_PROTOTYPE_GETTER = _dereq_('../internals/correct-prototype-getter');
  23131. var FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });
  23132. // `Object.getPrototypeOf` method
  23133. // https://tc39.es/ecma262/#sec-object.getprototypeof
  23134. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {
  23135. getPrototypeOf: function getPrototypeOf(it) {
  23136. return nativeGetPrototypeOf(toObject(it));
  23137. }
  23138. });
  23139. },{"../internals/correct-prototype-getter":304,"../internals/export":332,"../internals/fails":333,"../internals/object-get-prototype-of":393,"../internals/to-object":430}],482:[function(_dereq_,module,exports){
  23140. var $ = _dereq_('../internals/export');
  23141. var toObject = _dereq_('../internals/to-object');
  23142. var nativeKeys = _dereq_('../internals/object-keys');
  23143. var fails = _dereq_('../internals/fails');
  23144. var FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });
  23145. // `Object.keys` method
  23146. // https://tc39.es/ecma262/#sec-object.keys
  23147. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  23148. keys: function keys(it) {
  23149. return nativeKeys(toObject(it));
  23150. }
  23151. });
  23152. },{"../internals/export":332,"../internals/fails":333,"../internals/object-keys":397,"../internals/to-object":430}],483:[function(_dereq_,module,exports){
  23153. var $ = _dereq_('../internals/export');
  23154. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  23155. // `Object.setPrototypeOf` method
  23156. // https://tc39.es/ecma262/#sec-object.setprototypeof
  23157. $({ target: 'Object', stat: true }, {
  23158. setPrototypeOf: setPrototypeOf
  23159. });
  23160. },{"../internals/export":332,"../internals/object-set-prototype-of":399}],484:[function(_dereq_,module,exports){
  23161. arguments[4][464][0].apply(exports,arguments)
  23162. },{"dup":464}],485:[function(_dereq_,module,exports){
  23163. var $ = _dereq_('../internals/export');
  23164. var $parseInt = _dereq_('../internals/number-parse-int');
  23165. // `parseInt` method
  23166. // https://tc39.es/ecma262/#sec-parseint-string-radix
  23167. $({ global: true, forced: parseInt != $parseInt }, {
  23168. parseInt: $parseInt
  23169. });
  23170. },{"../internals/export":332,"../internals/number-parse-int":384}],486:[function(_dereq_,module,exports){
  23171. 'use strict';
  23172. var $ = _dereq_('../internals/export');
  23173. var call = _dereq_('../internals/function-call');
  23174. var aCallable = _dereq_('../internals/a-callable');
  23175. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23176. var perform = _dereq_('../internals/perform');
  23177. var iterate = _dereq_('../internals/iterate');
  23178. // `Promise.allSettled` method
  23179. // https://tc39.es/ecma262/#sec-promise.allsettled
  23180. $({ target: 'Promise', stat: true }, {
  23181. allSettled: function allSettled(iterable) {
  23182. var C = this;
  23183. var capability = newPromiseCapabilityModule.f(C);
  23184. var resolve = capability.resolve;
  23185. var reject = capability.reject;
  23186. var result = perform(function () {
  23187. var promiseResolve = aCallable(C.resolve);
  23188. var values = [];
  23189. var counter = 0;
  23190. var remaining = 1;
  23191. iterate(iterable, function (promise) {
  23192. var index = counter++;
  23193. var alreadyCalled = false;
  23194. remaining++;
  23195. call(promiseResolve, C, promise).then(function (value) {
  23196. if (alreadyCalled) return;
  23197. alreadyCalled = true;
  23198. values[index] = { status: 'fulfilled', value: value };
  23199. --remaining || resolve(values);
  23200. }, function (error) {
  23201. if (alreadyCalled) return;
  23202. alreadyCalled = true;
  23203. values[index] = { status: 'rejected', reason: error };
  23204. --remaining || resolve(values);
  23205. });
  23206. });
  23207. --remaining || resolve(values);
  23208. });
  23209. if (result.error) reject(result.value);
  23210. return capability.promise;
  23211. }
  23212. });
  23213. },{"../internals/a-callable":272,"../internals/export":332,"../internals/function-call":339,"../internals/iterate":370,"../internals/new-promise-capability":381,"../internals/perform":405}],487:[function(_dereq_,module,exports){
  23214. 'use strict';
  23215. var $ = _dereq_('../internals/export');
  23216. var call = _dereq_('../internals/function-call');
  23217. var aCallable = _dereq_('../internals/a-callable');
  23218. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23219. var perform = _dereq_('../internals/perform');
  23220. var iterate = _dereq_('../internals/iterate');
  23221. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  23222. // `Promise.all` method
  23223. // https://tc39.es/ecma262/#sec-promise.all
  23224. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  23225. all: function all(iterable) {
  23226. var C = this;
  23227. var capability = newPromiseCapabilityModule.f(C);
  23228. var resolve = capability.resolve;
  23229. var reject = capability.reject;
  23230. var result = perform(function () {
  23231. var $promiseResolve = aCallable(C.resolve);
  23232. var values = [];
  23233. var counter = 0;
  23234. var remaining = 1;
  23235. iterate(iterable, function (promise) {
  23236. var index = counter++;
  23237. var alreadyCalled = false;
  23238. remaining++;
  23239. call($promiseResolve, C, promise).then(function (value) {
  23240. if (alreadyCalled) return;
  23241. alreadyCalled = true;
  23242. values[index] = value;
  23243. --remaining || resolve(values);
  23244. }, reject);
  23245. });
  23246. --remaining || resolve(values);
  23247. });
  23248. if (result.error) reject(result.value);
  23249. return capability.promise;
  23250. }
  23251. });
  23252. },{"../internals/a-callable":272,"../internals/export":332,"../internals/function-call":339,"../internals/iterate":370,"../internals/new-promise-capability":381,"../internals/perform":405,"../internals/promise-statics-incorrect-iteration":409}],488:[function(_dereq_,module,exports){
  23253. 'use strict';
  23254. var $ = _dereq_('../internals/export');
  23255. var call = _dereq_('../internals/function-call');
  23256. var aCallable = _dereq_('../internals/a-callable');
  23257. var getBuiltIn = _dereq_('../internals/get-built-in');
  23258. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23259. var perform = _dereq_('../internals/perform');
  23260. var iterate = _dereq_('../internals/iterate');
  23261. var PROMISE_ANY_ERROR = 'No one promise resolved';
  23262. // `Promise.any` method
  23263. // https://tc39.es/ecma262/#sec-promise.any
  23264. $({ target: 'Promise', stat: true }, {
  23265. any: function any(iterable) {
  23266. var C = this;
  23267. var AggregateError = getBuiltIn('AggregateError');
  23268. var capability = newPromiseCapabilityModule.f(C);
  23269. var resolve = capability.resolve;
  23270. var reject = capability.reject;
  23271. var result = perform(function () {
  23272. var promiseResolve = aCallable(C.resolve);
  23273. var errors = [];
  23274. var counter = 0;
  23275. var remaining = 1;
  23276. var alreadyResolved = false;
  23277. iterate(iterable, function (promise) {
  23278. var index = counter++;
  23279. var alreadyRejected = false;
  23280. remaining++;
  23281. call(promiseResolve, C, promise).then(function (value) {
  23282. if (alreadyRejected || alreadyResolved) return;
  23283. alreadyResolved = true;
  23284. resolve(value);
  23285. }, function (error) {
  23286. if (alreadyRejected || alreadyResolved) return;
  23287. alreadyRejected = true;
  23288. errors[index] = error;
  23289. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  23290. });
  23291. });
  23292. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  23293. });
  23294. if (result.error) reject(result.value);
  23295. return capability.promise;
  23296. }
  23297. });
  23298. },{"../internals/a-callable":272,"../internals/export":332,"../internals/function-call":339,"../internals/get-built-in":342,"../internals/iterate":370,"../internals/new-promise-capability":381,"../internals/perform":405}],489:[function(_dereq_,module,exports){
  23299. 'use strict';
  23300. var $ = _dereq_('../internals/export');
  23301. var IS_PURE = _dereq_('../internals/is-pure');
  23302. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  23303. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  23304. var getBuiltIn = _dereq_('../internals/get-built-in');
  23305. var isCallable = _dereq_('../internals/is-callable');
  23306. var defineBuiltIn = _dereq_('../internals/define-built-in');
  23307. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  23308. // `Promise.prototype.catch` method
  23309. // https://tc39.es/ecma262/#sec-promise.prototype.catch
  23310. $({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR, real: true }, {
  23311. 'catch': function (onRejected) {
  23312. return this.then(undefined, onRejected);
  23313. }
  23314. });
  23315. // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
  23316. if (!IS_PURE && isCallable(NativePromiseConstructor)) {
  23317. var method = getBuiltIn('Promise').prototype['catch'];
  23318. if (NativePromisePrototype['catch'] !== method) {
  23319. defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true });
  23320. }
  23321. }
  23322. },{"../internals/define-built-in":309,"../internals/export":332,"../internals/get-built-in":342,"../internals/is-callable":360,"../internals/is-pure":367,"../internals/promise-constructor-detection":406,"../internals/promise-native-constructor":407}],490:[function(_dereq_,module,exports){
  23323. 'use strict';
  23324. var $ = _dereq_('../internals/export');
  23325. var IS_PURE = _dereq_('../internals/is-pure');
  23326. var IS_NODE = _dereq_('../internals/engine-is-node');
  23327. var global = _dereq_('../internals/global');
  23328. var call = _dereq_('../internals/function-call');
  23329. var defineBuiltIn = _dereq_('../internals/define-built-in');
  23330. var setPrototypeOf = _dereq_('../internals/object-set-prototype-of');
  23331. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  23332. var setSpecies = _dereq_('../internals/set-species');
  23333. var aCallable = _dereq_('../internals/a-callable');
  23334. var isCallable = _dereq_('../internals/is-callable');
  23335. var isObject = _dereq_('../internals/is-object');
  23336. var anInstance = _dereq_('../internals/an-instance');
  23337. var speciesConstructor = _dereq_('../internals/species-constructor');
  23338. var task = _dereq_('../internals/task').set;
  23339. var microtask = _dereq_('../internals/microtask');
  23340. var hostReportErrors = _dereq_('../internals/host-report-errors');
  23341. var perform = _dereq_('../internals/perform');
  23342. var Queue = _dereq_('../internals/queue');
  23343. var InternalStateModule = _dereq_('../internals/internal-state');
  23344. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  23345. var PromiseConstructorDetection = _dereq_('../internals/promise-constructor-detection');
  23346. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23347. var PROMISE = 'Promise';
  23348. var FORCED_PROMISE_CONSTRUCTOR = PromiseConstructorDetection.CONSTRUCTOR;
  23349. var NATIVE_PROMISE_REJECTION_EVENT = PromiseConstructorDetection.REJECTION_EVENT;
  23350. var NATIVE_PROMISE_SUBCLASSING = PromiseConstructorDetection.SUBCLASSING;
  23351. var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
  23352. var setInternalState = InternalStateModule.set;
  23353. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  23354. var PromiseConstructor = NativePromiseConstructor;
  23355. var PromisePrototype = NativePromisePrototype;
  23356. var TypeError = global.TypeError;
  23357. var document = global.document;
  23358. var process = global.process;
  23359. var newPromiseCapability = newPromiseCapabilityModule.f;
  23360. var newGenericPromiseCapability = newPromiseCapability;
  23361. var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
  23362. var UNHANDLED_REJECTION = 'unhandledrejection';
  23363. var REJECTION_HANDLED = 'rejectionhandled';
  23364. var PENDING = 0;
  23365. var FULFILLED = 1;
  23366. var REJECTED = 2;
  23367. var HANDLED = 1;
  23368. var UNHANDLED = 2;
  23369. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  23370. // helpers
  23371. var isThenable = function (it) {
  23372. var then;
  23373. return isObject(it) && isCallable(then = it.then) ? then : false;
  23374. };
  23375. var callReaction = function (reaction, state) {
  23376. var value = state.value;
  23377. var ok = state.state == FULFILLED;
  23378. var handler = ok ? reaction.ok : reaction.fail;
  23379. var resolve = reaction.resolve;
  23380. var reject = reaction.reject;
  23381. var domain = reaction.domain;
  23382. var result, then, exited;
  23383. try {
  23384. if (handler) {
  23385. if (!ok) {
  23386. if (state.rejection === UNHANDLED) onHandleUnhandled(state);
  23387. state.rejection = HANDLED;
  23388. }
  23389. if (handler === true) result = value;
  23390. else {
  23391. if (domain) domain.enter();
  23392. result = handler(value); // can throw
  23393. if (domain) {
  23394. domain.exit();
  23395. exited = true;
  23396. }
  23397. }
  23398. if (result === reaction.promise) {
  23399. reject(TypeError('Promise-chain cycle'));
  23400. } else if (then = isThenable(result)) {
  23401. call(then, result, resolve, reject);
  23402. } else resolve(result);
  23403. } else reject(value);
  23404. } catch (error) {
  23405. if (domain && !exited) domain.exit();
  23406. reject(error);
  23407. }
  23408. };
  23409. var notify = function (state, isReject) {
  23410. if (state.notified) return;
  23411. state.notified = true;
  23412. microtask(function () {
  23413. var reactions = state.reactions;
  23414. var reaction;
  23415. while (reaction = reactions.get()) {
  23416. callReaction(reaction, state);
  23417. }
  23418. state.notified = false;
  23419. if (isReject && !state.rejection) onUnhandled(state);
  23420. });
  23421. };
  23422. var dispatchEvent = function (name, promise, reason) {
  23423. var event, handler;
  23424. if (DISPATCH_EVENT) {
  23425. event = document.createEvent('Event');
  23426. event.promise = promise;
  23427. event.reason = reason;
  23428. event.initEvent(name, false, true);
  23429. global.dispatchEvent(event);
  23430. } else event = { promise: promise, reason: reason };
  23431. if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = global['on' + name])) handler(event);
  23432. else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
  23433. };
  23434. var onUnhandled = function (state) {
  23435. call(task, global, function () {
  23436. var promise = state.facade;
  23437. var value = state.value;
  23438. var IS_UNHANDLED = isUnhandled(state);
  23439. var result;
  23440. if (IS_UNHANDLED) {
  23441. result = perform(function () {
  23442. if (IS_NODE) {
  23443. process.emit('unhandledRejection', value, promise);
  23444. } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
  23445. });
  23446. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  23447. state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
  23448. if (result.error) throw result.value;
  23449. }
  23450. });
  23451. };
  23452. var isUnhandled = function (state) {
  23453. return state.rejection !== HANDLED && !state.parent;
  23454. };
  23455. var onHandleUnhandled = function (state) {
  23456. call(task, global, function () {
  23457. var promise = state.facade;
  23458. if (IS_NODE) {
  23459. process.emit('rejectionHandled', promise);
  23460. } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
  23461. });
  23462. };
  23463. var bind = function (fn, state, unwrap) {
  23464. return function (value) {
  23465. fn(state, value, unwrap);
  23466. };
  23467. };
  23468. var internalReject = function (state, value, unwrap) {
  23469. if (state.done) return;
  23470. state.done = true;
  23471. if (unwrap) state = unwrap;
  23472. state.value = value;
  23473. state.state = REJECTED;
  23474. notify(state, true);
  23475. };
  23476. var internalResolve = function (state, value, unwrap) {
  23477. if (state.done) return;
  23478. state.done = true;
  23479. if (unwrap) state = unwrap;
  23480. try {
  23481. if (state.facade === value) throw TypeError("Promise can't be resolved itself");
  23482. var then = isThenable(value);
  23483. if (then) {
  23484. microtask(function () {
  23485. var wrapper = { done: false };
  23486. try {
  23487. call(then, value,
  23488. bind(internalResolve, wrapper, state),
  23489. bind(internalReject, wrapper, state)
  23490. );
  23491. } catch (error) {
  23492. internalReject(wrapper, error, state);
  23493. }
  23494. });
  23495. } else {
  23496. state.value = value;
  23497. state.state = FULFILLED;
  23498. notify(state, false);
  23499. }
  23500. } catch (error) {
  23501. internalReject({ done: false }, error, state);
  23502. }
  23503. };
  23504. // constructor polyfill
  23505. if (FORCED_PROMISE_CONSTRUCTOR) {
  23506. // 25.4.3.1 Promise(executor)
  23507. PromiseConstructor = function Promise(executor) {
  23508. anInstance(this, PromisePrototype);
  23509. aCallable(executor);
  23510. call(Internal, this);
  23511. var state = getInternalPromiseState(this);
  23512. try {
  23513. executor(bind(internalResolve, state), bind(internalReject, state));
  23514. } catch (error) {
  23515. internalReject(state, error);
  23516. }
  23517. };
  23518. PromisePrototype = PromiseConstructor.prototype;
  23519. // eslint-disable-next-line no-unused-vars -- required for `.length`
  23520. Internal = function Promise(executor) {
  23521. setInternalState(this, {
  23522. type: PROMISE,
  23523. done: false,
  23524. notified: false,
  23525. parent: false,
  23526. reactions: new Queue(),
  23527. rejection: false,
  23528. state: PENDING,
  23529. value: undefined
  23530. });
  23531. };
  23532. // `Promise.prototype.then` method
  23533. // https://tc39.es/ecma262/#sec-promise.prototype.then
  23534. Internal.prototype = defineBuiltIn(PromisePrototype, 'then', function then(onFulfilled, onRejected) {
  23535. var state = getInternalPromiseState(this);
  23536. var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
  23537. state.parent = true;
  23538. reaction.ok = isCallable(onFulfilled) ? onFulfilled : true;
  23539. reaction.fail = isCallable(onRejected) && onRejected;
  23540. reaction.domain = IS_NODE ? process.domain : undefined;
  23541. if (state.state == PENDING) state.reactions.add(reaction);
  23542. else microtask(function () {
  23543. callReaction(reaction, state);
  23544. });
  23545. return reaction.promise;
  23546. });
  23547. OwnPromiseCapability = function () {
  23548. var promise = new Internal();
  23549. var state = getInternalPromiseState(promise);
  23550. this.promise = promise;
  23551. this.resolve = bind(internalResolve, state);
  23552. this.reject = bind(internalReject, state);
  23553. };
  23554. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  23555. return C === PromiseConstructor || C === PromiseWrapper
  23556. ? new OwnPromiseCapability(C)
  23557. : newGenericPromiseCapability(C);
  23558. };
  23559. if (!IS_PURE && isCallable(NativePromiseConstructor) && NativePromisePrototype !== Object.prototype) {
  23560. nativeThen = NativePromisePrototype.then;
  23561. if (!NATIVE_PROMISE_SUBCLASSING) {
  23562. // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
  23563. defineBuiltIn(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {
  23564. var that = this;
  23565. return new PromiseConstructor(function (resolve, reject) {
  23566. call(nativeThen, that, resolve, reject);
  23567. }).then(onFulfilled, onRejected);
  23568. // https://github.com/zloirock/core-js/issues/640
  23569. }, { unsafe: true });
  23570. }
  23571. // make `.constructor === Promise` work for native promise-based APIs
  23572. try {
  23573. delete NativePromisePrototype.constructor;
  23574. } catch (error) { /* empty */ }
  23575. // make `instanceof Promise` work for native promise-based APIs
  23576. if (setPrototypeOf) {
  23577. setPrototypeOf(NativePromisePrototype, PromisePrototype);
  23578. }
  23579. }
  23580. }
  23581. $({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
  23582. Promise: PromiseConstructor
  23583. });
  23584. setToStringTag(PromiseConstructor, PROMISE, false, true);
  23585. setSpecies(PROMISE);
  23586. },{"../internals/a-callable":272,"../internals/an-instance":276,"../internals/define-built-in":309,"../internals/engine-is-node":323,"../internals/export":332,"../internals/function-call":339,"../internals/global":347,"../internals/host-report-errors":350,"../internals/internal-state":357,"../internals/is-callable":360,"../internals/is-object":366,"../internals/is-pure":367,"../internals/microtask":380,"../internals/new-promise-capability":381,"../internals/object-set-prototype-of":399,"../internals/perform":405,"../internals/promise-constructor-detection":406,"../internals/promise-native-constructor":407,"../internals/queue":410,"../internals/set-species":414,"../internals/set-to-string-tag":415,"../internals/species-constructor":419,"../internals/task":425}],491:[function(_dereq_,module,exports){
  23587. 'use strict';
  23588. var $ = _dereq_('../internals/export');
  23589. var IS_PURE = _dereq_('../internals/is-pure');
  23590. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  23591. var fails = _dereq_('../internals/fails');
  23592. var getBuiltIn = _dereq_('../internals/get-built-in');
  23593. var isCallable = _dereq_('../internals/is-callable');
  23594. var speciesConstructor = _dereq_('../internals/species-constructor');
  23595. var promiseResolve = _dereq_('../internals/promise-resolve');
  23596. var defineBuiltIn = _dereq_('../internals/define-built-in');
  23597. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  23598. // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
  23599. var NON_GENERIC = !!NativePromiseConstructor && fails(function () {
  23600. // eslint-disable-next-line unicorn/no-thenable -- required for testing
  23601. NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
  23602. });
  23603. // `Promise.prototype.finally` method
  23604. // https://tc39.es/ecma262/#sec-promise.prototype.finally
  23605. $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
  23606. 'finally': function (onFinally) {
  23607. var C = speciesConstructor(this, getBuiltIn('Promise'));
  23608. var isFunction = isCallable(onFinally);
  23609. return this.then(
  23610. isFunction ? function (x) {
  23611. return promiseResolve(C, onFinally()).then(function () { return x; });
  23612. } : onFinally,
  23613. isFunction ? function (e) {
  23614. return promiseResolve(C, onFinally()).then(function () { throw e; });
  23615. } : onFinally
  23616. );
  23617. }
  23618. });
  23619. // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
  23620. if (!IS_PURE && isCallable(NativePromiseConstructor)) {
  23621. var method = getBuiltIn('Promise').prototype['finally'];
  23622. if (NativePromisePrototype['finally'] !== method) {
  23623. defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true });
  23624. }
  23625. }
  23626. },{"../internals/define-built-in":309,"../internals/export":332,"../internals/fails":333,"../internals/get-built-in":342,"../internals/is-callable":360,"../internals/is-pure":367,"../internals/promise-native-constructor":407,"../internals/promise-resolve":408,"../internals/species-constructor":419}],492:[function(_dereq_,module,exports){
  23627. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  23628. _dereq_('../modules/es.promise.constructor');
  23629. _dereq_('../modules/es.promise.all');
  23630. _dereq_('../modules/es.promise.catch');
  23631. _dereq_('../modules/es.promise.race');
  23632. _dereq_('../modules/es.promise.reject');
  23633. _dereq_('../modules/es.promise.resolve');
  23634. },{"../modules/es.promise.all":487,"../modules/es.promise.catch":489,"../modules/es.promise.constructor":490,"../modules/es.promise.race":493,"../modules/es.promise.reject":494,"../modules/es.promise.resolve":495}],493:[function(_dereq_,module,exports){
  23635. 'use strict';
  23636. var $ = _dereq_('../internals/export');
  23637. var call = _dereq_('../internals/function-call');
  23638. var aCallable = _dereq_('../internals/a-callable');
  23639. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23640. var perform = _dereq_('../internals/perform');
  23641. var iterate = _dereq_('../internals/iterate');
  23642. var PROMISE_STATICS_INCORRECT_ITERATION = _dereq_('../internals/promise-statics-incorrect-iteration');
  23643. // `Promise.race` method
  23644. // https://tc39.es/ecma262/#sec-promise.race
  23645. $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
  23646. race: function race(iterable) {
  23647. var C = this;
  23648. var capability = newPromiseCapabilityModule.f(C);
  23649. var reject = capability.reject;
  23650. var result = perform(function () {
  23651. var $promiseResolve = aCallable(C.resolve);
  23652. iterate(iterable, function (promise) {
  23653. call($promiseResolve, C, promise).then(capability.resolve, reject);
  23654. });
  23655. });
  23656. if (result.error) reject(result.value);
  23657. return capability.promise;
  23658. }
  23659. });
  23660. },{"../internals/a-callable":272,"../internals/export":332,"../internals/function-call":339,"../internals/iterate":370,"../internals/new-promise-capability":381,"../internals/perform":405,"../internals/promise-statics-incorrect-iteration":409}],494:[function(_dereq_,module,exports){
  23661. 'use strict';
  23662. var $ = _dereq_('../internals/export');
  23663. var call = _dereq_('../internals/function-call');
  23664. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  23665. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  23666. // `Promise.reject` method
  23667. // https://tc39.es/ecma262/#sec-promise.reject
  23668. $({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
  23669. reject: function reject(r) {
  23670. var capability = newPromiseCapabilityModule.f(this);
  23671. call(capability.reject, undefined, r);
  23672. return capability.promise;
  23673. }
  23674. });
  23675. },{"../internals/export":332,"../internals/function-call":339,"../internals/new-promise-capability":381,"../internals/promise-constructor-detection":406}],495:[function(_dereq_,module,exports){
  23676. 'use strict';
  23677. var $ = _dereq_('../internals/export');
  23678. var getBuiltIn = _dereq_('../internals/get-built-in');
  23679. var IS_PURE = _dereq_('../internals/is-pure');
  23680. var NativePromiseConstructor = _dereq_('../internals/promise-native-constructor');
  23681. var FORCED_PROMISE_CONSTRUCTOR = _dereq_('../internals/promise-constructor-detection').CONSTRUCTOR;
  23682. var promiseResolve = _dereq_('../internals/promise-resolve');
  23683. var PromiseConstructorWrapper = getBuiltIn('Promise');
  23684. var CHECK_WRAPPER = IS_PURE && !FORCED_PROMISE_CONSTRUCTOR;
  23685. // `Promise.resolve` method
  23686. // https://tc39.es/ecma262/#sec-promise.resolve
  23687. $({ target: 'Promise', stat: true, forced: IS_PURE || FORCED_PROMISE_CONSTRUCTOR }, {
  23688. resolve: function resolve(x) {
  23689. return promiseResolve(CHECK_WRAPPER && this === PromiseConstructorWrapper ? NativePromiseConstructor : this, x);
  23690. }
  23691. });
  23692. },{"../internals/export":332,"../internals/get-built-in":342,"../internals/is-pure":367,"../internals/promise-constructor-detection":406,"../internals/promise-native-constructor":407,"../internals/promise-resolve":408}],496:[function(_dereq_,module,exports){
  23693. var $ = _dereq_('../internals/export');
  23694. var getBuiltIn = _dereq_('../internals/get-built-in');
  23695. var apply = _dereq_('../internals/function-apply');
  23696. var bind = _dereq_('../internals/function-bind');
  23697. var aConstructor = _dereq_('../internals/a-constructor');
  23698. var anObject = _dereq_('../internals/an-object');
  23699. var isObject = _dereq_('../internals/is-object');
  23700. var create = _dereq_('../internals/object-create');
  23701. var fails = _dereq_('../internals/fails');
  23702. var nativeConstruct = getBuiltIn('Reflect', 'construct');
  23703. var ObjectPrototype = Object.prototype;
  23704. var push = [].push;
  23705. // `Reflect.construct` method
  23706. // https://tc39.es/ecma262/#sec-reflect.construct
  23707. // MS Edge supports only 2 arguments and argumentsList argument is optional
  23708. // FF Nightly sets third argument as `new.target`, but does not create `this` from it
  23709. var NEW_TARGET_BUG = fails(function () {
  23710. function F() { /* empty */ }
  23711. return !(nativeConstruct(function () { /* empty */ }, [], F) instanceof F);
  23712. });
  23713. var ARGS_BUG = !fails(function () {
  23714. nativeConstruct(function () { /* empty */ });
  23715. });
  23716. var FORCED = NEW_TARGET_BUG || ARGS_BUG;
  23717. $({ target: 'Reflect', stat: true, forced: FORCED, sham: FORCED }, {
  23718. construct: function construct(Target, args /* , newTarget */) {
  23719. aConstructor(Target);
  23720. anObject(args);
  23721. var newTarget = arguments.length < 3 ? Target : aConstructor(arguments[2]);
  23722. if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);
  23723. if (Target == newTarget) {
  23724. // w/o altered newTarget, optimization for 0-4 arguments
  23725. switch (args.length) {
  23726. case 0: return new Target();
  23727. case 1: return new Target(args[0]);
  23728. case 2: return new Target(args[0], args[1]);
  23729. case 3: return new Target(args[0], args[1], args[2]);
  23730. case 4: return new Target(args[0], args[1], args[2], args[3]);
  23731. }
  23732. // w/o altered newTarget, lot of arguments case
  23733. var $args = [null];
  23734. apply(push, $args, args);
  23735. return new (apply(bind, Target, $args))();
  23736. }
  23737. // with altered newTarget, not support built-in constructors
  23738. var proto = newTarget.prototype;
  23739. var instance = create(isObject(proto) ? proto : ObjectPrototype);
  23740. var result = apply(Target, instance, args);
  23741. return isObject(result) ? result : instance;
  23742. }
  23743. });
  23744. },{"../internals/a-constructor":273,"../internals/an-object":277,"../internals/export":332,"../internals/fails":333,"../internals/function-apply":335,"../internals/function-bind":338,"../internals/get-built-in":342,"../internals/is-object":366,"../internals/object-create":386}],497:[function(_dereq_,module,exports){
  23745. var $ = _dereq_('../internals/export');
  23746. var call = _dereq_('../internals/function-call');
  23747. var isObject = _dereq_('../internals/is-object');
  23748. var anObject = _dereq_('../internals/an-object');
  23749. var isDataDescriptor = _dereq_('../internals/is-data-descriptor');
  23750. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  23751. var getPrototypeOf = _dereq_('../internals/object-get-prototype-of');
  23752. // `Reflect.get` method
  23753. // https://tc39.es/ecma262/#sec-reflect.get
  23754. function get(target, propertyKey /* , receiver */) {
  23755. var receiver = arguments.length < 3 ? target : arguments[2];
  23756. var descriptor, prototype;
  23757. if (anObject(target) === receiver) return target[propertyKey];
  23758. descriptor = getOwnPropertyDescriptorModule.f(target, propertyKey);
  23759. if (descriptor) return isDataDescriptor(descriptor)
  23760. ? descriptor.value
  23761. : descriptor.get === undefined ? undefined : call(descriptor.get, receiver);
  23762. if (isObject(prototype = getPrototypeOf(target))) return get(prototype, propertyKey, receiver);
  23763. }
  23764. $({ target: 'Reflect', stat: true }, {
  23765. get: get
  23766. });
  23767. },{"../internals/an-object":277,"../internals/export":332,"../internals/function-call":339,"../internals/is-data-descriptor":362,"../internals/is-object":366,"../internals/object-get-own-property-descriptor":389,"../internals/object-get-prototype-of":393}],498:[function(_dereq_,module,exports){
  23768. arguments[4][464][0].apply(exports,arguments)
  23769. },{"dup":464}],499:[function(_dereq_,module,exports){
  23770. 'use strict';
  23771. var collection = _dereq_('../internals/collection');
  23772. var collectionStrong = _dereq_('../internals/collection-strong');
  23773. // `Set` constructor
  23774. // https://tc39.es/ecma262/#sec-set-objects
  23775. collection('Set', function (init) {
  23776. return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };
  23777. }, collectionStrong);
  23778. },{"../internals/collection":301,"../internals/collection-strong":299}],500:[function(_dereq_,module,exports){
  23779. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  23780. _dereq_('../modules/es.set.constructor');
  23781. },{"../modules/es.set.constructor":499}],501:[function(_dereq_,module,exports){
  23782. 'use strict';
  23783. var $ = _dereq_('../internals/export');
  23784. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  23785. var notARegExp = _dereq_('../internals/not-a-regexp');
  23786. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  23787. var toString = _dereq_('../internals/to-string');
  23788. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  23789. var stringIndexOf = uncurryThis(''.indexOf);
  23790. // `String.prototype.includes` method
  23791. // https://tc39.es/ecma262/#sec-string.prototype.includes
  23792. $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
  23793. includes: function includes(searchString /* , position = 0 */) {
  23794. return !!~stringIndexOf(
  23795. toString(requireObjectCoercible(this)),
  23796. toString(notARegExp(searchString)),
  23797. arguments.length > 1 ? arguments[1] : undefined
  23798. );
  23799. }
  23800. });
  23801. },{"../internals/correct-is-regexp-logic":303,"../internals/export":332,"../internals/function-uncurry-this":341,"../internals/not-a-regexp":383,"../internals/require-object-coercible":411,"../internals/to-string":434}],502:[function(_dereq_,module,exports){
  23802. 'use strict';
  23803. var charAt = _dereq_('../internals/string-multibyte').charAt;
  23804. var toString = _dereq_('../internals/to-string');
  23805. var InternalStateModule = _dereq_('../internals/internal-state');
  23806. var defineIterator = _dereq_('../internals/iterator-define');
  23807. var createIterResultObject = _dereq_('../internals/create-iter-result-object');
  23808. var STRING_ITERATOR = 'String Iterator';
  23809. var setInternalState = InternalStateModule.set;
  23810. var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
  23811. // `String.prototype[@@iterator]` method
  23812. // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
  23813. defineIterator(String, 'String', function (iterated) {
  23814. setInternalState(this, {
  23815. type: STRING_ITERATOR,
  23816. string: toString(iterated),
  23817. index: 0
  23818. });
  23819. // `%StringIteratorPrototype%.next` method
  23820. // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
  23821. }, function next() {
  23822. var state = getInternalState(this);
  23823. var string = state.string;
  23824. var index = state.index;
  23825. var point;
  23826. if (index >= string.length) return createIterResultObject(undefined, true);
  23827. point = charAt(string, index);
  23828. state.index += point.length;
  23829. return createIterResultObject(point, false);
  23830. });
  23831. },{"../internals/create-iter-result-object":305,"../internals/internal-state":357,"../internals/iterator-define":373,"../internals/string-multibyte":420,"../internals/to-string":434}],503:[function(_dereq_,module,exports){
  23832. 'use strict';
  23833. var $ = _dereq_('../internals/export');
  23834. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  23835. var getOwnPropertyDescriptor = _dereq_('../internals/object-get-own-property-descriptor').f;
  23836. var toLength = _dereq_('../internals/to-length');
  23837. var toString = _dereq_('../internals/to-string');
  23838. var notARegExp = _dereq_('../internals/not-a-regexp');
  23839. var requireObjectCoercible = _dereq_('../internals/require-object-coercible');
  23840. var correctIsRegExpLogic = _dereq_('../internals/correct-is-regexp-logic');
  23841. var IS_PURE = _dereq_('../internals/is-pure');
  23842. // eslint-disable-next-line es-x/no-string-prototype-startswith -- safe
  23843. var nativeStartsWith = uncurryThis(''.startsWith);
  23844. var stringSlice = uncurryThis(''.slice);
  23845. var min = Math.min;
  23846. var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');
  23847. // https://github.com/zloirock/core-js/pull/702
  23848. var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
  23849. var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
  23850. return descriptor && !descriptor.writable;
  23851. }();
  23852. // `String.prototype.startsWith` method
  23853. // https://tc39.es/ecma262/#sec-string.prototype.startswith
  23854. $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
  23855. startsWith: function startsWith(searchString /* , position = 0 */) {
  23856. var that = toString(requireObjectCoercible(this));
  23857. notARegExp(searchString);
  23858. var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  23859. var search = toString(searchString);
  23860. return nativeStartsWith
  23861. ? nativeStartsWith(that, search, index)
  23862. : stringSlice(that, index, index + search.length) === search;
  23863. }
  23864. });
  23865. },{"../internals/correct-is-regexp-logic":303,"../internals/export":332,"../internals/function-uncurry-this":341,"../internals/is-pure":367,"../internals/not-a-regexp":383,"../internals/object-get-own-property-descriptor":389,"../internals/require-object-coercible":411,"../internals/to-length":429,"../internals/to-string":434}],504:[function(_dereq_,module,exports){
  23866. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  23867. // `Symbol.asyncIterator` well-known symbol
  23868. // https://tc39.es/ecma262/#sec-symbol.asynciterator
  23869. defineWellKnownSymbol('asyncIterator');
  23870. },{"../internals/well-known-symbol-define":441}],505:[function(_dereq_,module,exports){
  23871. 'use strict';
  23872. var $ = _dereq_('../internals/export');
  23873. var global = _dereq_('../internals/global');
  23874. var call = _dereq_('../internals/function-call');
  23875. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  23876. var IS_PURE = _dereq_('../internals/is-pure');
  23877. var DESCRIPTORS = _dereq_('../internals/descriptors');
  23878. var NATIVE_SYMBOL = _dereq_('../internals/symbol-constructor-detection');
  23879. var fails = _dereq_('../internals/fails');
  23880. var hasOwn = _dereq_('../internals/has-own-property');
  23881. var isPrototypeOf = _dereq_('../internals/object-is-prototype-of');
  23882. var anObject = _dereq_('../internals/an-object');
  23883. var toIndexedObject = _dereq_('../internals/to-indexed-object');
  23884. var toPropertyKey = _dereq_('../internals/to-property-key');
  23885. var $toString = _dereq_('../internals/to-string');
  23886. var createPropertyDescriptor = _dereq_('../internals/create-property-descriptor');
  23887. var nativeObjectCreate = _dereq_('../internals/object-create');
  23888. var objectKeys = _dereq_('../internals/object-keys');
  23889. var getOwnPropertyNamesModule = _dereq_('../internals/object-get-own-property-names');
  23890. var getOwnPropertyNamesExternal = _dereq_('../internals/object-get-own-property-names-external');
  23891. var getOwnPropertySymbolsModule = _dereq_('../internals/object-get-own-property-symbols');
  23892. var getOwnPropertyDescriptorModule = _dereq_('../internals/object-get-own-property-descriptor');
  23893. var definePropertyModule = _dereq_('../internals/object-define-property');
  23894. var definePropertiesModule = _dereq_('../internals/object-define-properties');
  23895. var propertyIsEnumerableModule = _dereq_('../internals/object-property-is-enumerable');
  23896. var defineBuiltIn = _dereq_('../internals/define-built-in');
  23897. var shared = _dereq_('../internals/shared');
  23898. var sharedKey = _dereq_('../internals/shared-key');
  23899. var hiddenKeys = _dereq_('../internals/hidden-keys');
  23900. var uid = _dereq_('../internals/uid');
  23901. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  23902. var wrappedWellKnownSymbolModule = _dereq_('../internals/well-known-symbol-wrapped');
  23903. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  23904. var defineSymbolToPrimitive = _dereq_('../internals/symbol-define-to-primitive');
  23905. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  23906. var InternalStateModule = _dereq_('../internals/internal-state');
  23907. var $forEach = _dereq_('../internals/array-iteration').forEach;
  23908. var HIDDEN = sharedKey('hidden');
  23909. var SYMBOL = 'Symbol';
  23910. var PROTOTYPE = 'prototype';
  23911. var setInternalState = InternalStateModule.set;
  23912. var getInternalState = InternalStateModule.getterFor(SYMBOL);
  23913. var ObjectPrototype = Object[PROTOTYPE];
  23914. var $Symbol = global.Symbol;
  23915. var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE];
  23916. var TypeError = global.TypeError;
  23917. var QObject = global.QObject;
  23918. var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  23919. var nativeDefineProperty = definePropertyModule.f;
  23920. var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
  23921. var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
  23922. var push = uncurryThis([].push);
  23923. var AllSymbols = shared('symbols');
  23924. var ObjectPrototypeSymbols = shared('op-symbols');
  23925. var WellKnownSymbolsStore = shared('wks');
  23926. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  23927. var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  23928. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  23929. var setSymbolDescriptor = DESCRIPTORS && fails(function () {
  23930. return nativeObjectCreate(nativeDefineProperty({}, 'a', {
  23931. get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }
  23932. })).a != 7;
  23933. }) ? function (O, P, Attributes) {
  23934. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
  23935. if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
  23936. nativeDefineProperty(O, P, Attributes);
  23937. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  23938. nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
  23939. }
  23940. } : nativeDefineProperty;
  23941. var wrap = function (tag, description) {
  23942. var symbol = AllSymbols[tag] = nativeObjectCreate(SymbolPrototype);
  23943. setInternalState(symbol, {
  23944. type: SYMBOL,
  23945. tag: tag,
  23946. description: description
  23947. });
  23948. if (!DESCRIPTORS) symbol.description = description;
  23949. return symbol;
  23950. };
  23951. var $defineProperty = function defineProperty(O, P, Attributes) {
  23952. if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  23953. anObject(O);
  23954. var key = toPropertyKey(P);
  23955. anObject(Attributes);
  23956. if (hasOwn(AllSymbols, key)) {
  23957. if (!Attributes.enumerable) {
  23958. if (!hasOwn(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
  23959. O[HIDDEN][key] = true;
  23960. } else {
  23961. if (hasOwn(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
  23962. Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  23963. } return setSymbolDescriptor(O, key, Attributes);
  23964. } return nativeDefineProperty(O, key, Attributes);
  23965. };
  23966. var $defineProperties = function defineProperties(O, Properties) {
  23967. anObject(O);
  23968. var properties = toIndexedObject(Properties);
  23969. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  23970. $forEach(keys, function (key) {
  23971. if (!DESCRIPTORS || call($propertyIsEnumerable, properties, key)) $defineProperty(O, key, properties[key]);
  23972. });
  23973. return O;
  23974. };
  23975. var $create = function create(O, Properties) {
  23976. return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
  23977. };
  23978. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  23979. var P = toPropertyKey(V);
  23980. var enumerable = call(nativePropertyIsEnumerable, this, P);
  23981. if (this === ObjectPrototype && hasOwn(AllSymbols, P) && !hasOwn(ObjectPrototypeSymbols, P)) return false;
  23982. return enumerable || !hasOwn(this, P) || !hasOwn(AllSymbols, P) || hasOwn(this, HIDDEN) && this[HIDDEN][P]
  23983. ? enumerable : true;
  23984. };
  23985. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  23986. var it = toIndexedObject(O);
  23987. var key = toPropertyKey(P);
  23988. if (it === ObjectPrototype && hasOwn(AllSymbols, key) && !hasOwn(ObjectPrototypeSymbols, key)) return;
  23989. var descriptor = nativeGetOwnPropertyDescriptor(it, key);
  23990. if (descriptor && hasOwn(AllSymbols, key) && !(hasOwn(it, HIDDEN) && it[HIDDEN][key])) {
  23991. descriptor.enumerable = true;
  23992. }
  23993. return descriptor;
  23994. };
  23995. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  23996. var names = nativeGetOwnPropertyNames(toIndexedObject(O));
  23997. var result = [];
  23998. $forEach(names, function (key) {
  23999. if (!hasOwn(AllSymbols, key) && !hasOwn(hiddenKeys, key)) push(result, key);
  24000. });
  24001. return result;
  24002. };
  24003. var $getOwnPropertySymbols = function (O) {
  24004. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  24005. var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  24006. var result = [];
  24007. $forEach(names, function (key) {
  24008. if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) {
  24009. push(result, AllSymbols[key]);
  24010. }
  24011. });
  24012. return result;
  24013. };
  24014. // `Symbol` constructor
  24015. // https://tc39.es/ecma262/#sec-symbol-constructor
  24016. if (!NATIVE_SYMBOL) {
  24017. $Symbol = function Symbol() {
  24018. if (isPrototypeOf(SymbolPrototype, this)) throw TypeError('Symbol is not a constructor');
  24019. var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);
  24020. var tag = uid(description);
  24021. var setter = function (value) {
  24022. if (this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value);
  24023. if (hasOwn(this, HIDDEN) && hasOwn(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  24024. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  24025. };
  24026. if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
  24027. return wrap(tag, description);
  24028. };
  24029. SymbolPrototype = $Symbol[PROTOTYPE];
  24030. defineBuiltIn(SymbolPrototype, 'toString', function toString() {
  24031. return getInternalState(this).tag;
  24032. });
  24033. defineBuiltIn($Symbol, 'withoutSetter', function (description) {
  24034. return wrap(uid(description), description);
  24035. });
  24036. propertyIsEnumerableModule.f = $propertyIsEnumerable;
  24037. definePropertyModule.f = $defineProperty;
  24038. definePropertiesModule.f = $defineProperties;
  24039. getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
  24040. getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  24041. getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
  24042. wrappedWellKnownSymbolModule.f = function (name) {
  24043. return wrap(wellKnownSymbol(name), name);
  24044. };
  24045. if (DESCRIPTORS) {
  24046. // https://github.com/tc39/proposal-Symbol-description
  24047. nativeDefineProperty(SymbolPrototype, 'description', {
  24048. configurable: true,
  24049. get: function description() {
  24050. return getInternalState(this).description;
  24051. }
  24052. });
  24053. if (!IS_PURE) {
  24054. defineBuiltIn(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  24055. }
  24056. }
  24057. }
  24058. $({ global: true, constructor: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {
  24059. Symbol: $Symbol
  24060. });
  24061. $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
  24062. defineWellKnownSymbol(name);
  24063. });
  24064. $({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {
  24065. useSetter: function () { USE_SETTER = true; },
  24066. useSimple: function () { USE_SETTER = false; }
  24067. });
  24068. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {
  24069. // `Object.create` method
  24070. // https://tc39.es/ecma262/#sec-object.create
  24071. create: $create,
  24072. // `Object.defineProperty` method
  24073. // https://tc39.es/ecma262/#sec-object.defineproperty
  24074. defineProperty: $defineProperty,
  24075. // `Object.defineProperties` method
  24076. // https://tc39.es/ecma262/#sec-object.defineproperties
  24077. defineProperties: $defineProperties,
  24078. // `Object.getOwnPropertyDescriptor` method
  24079. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  24080. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  24081. });
  24082. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {
  24083. // `Object.getOwnPropertyNames` method
  24084. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  24085. getOwnPropertyNames: $getOwnPropertyNames
  24086. });
  24087. // `Symbol.prototype[@@toPrimitive]` method
  24088. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  24089. defineSymbolToPrimitive();
  24090. // `Symbol.prototype[@@toStringTag]` property
  24091. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  24092. setToStringTag($Symbol, SYMBOL);
  24093. hiddenKeys[HIDDEN] = true;
  24094. },{"../internals/an-object":277,"../internals/array-iteration":282,"../internals/create-property-descriptor":307,"../internals/define-built-in":309,"../internals/descriptors":313,"../internals/export":332,"../internals/fails":333,"../internals/function-call":339,"../internals/function-uncurry-this":341,"../internals/global":347,"../internals/has-own-property":348,"../internals/hidden-keys":349,"../internals/internal-state":357,"../internals/is-pure":367,"../internals/object-create":386,"../internals/object-define-properties":387,"../internals/object-define-property":388,"../internals/object-get-own-property-descriptor":389,"../internals/object-get-own-property-names":391,"../internals/object-get-own-property-names-external":390,"../internals/object-get-own-property-symbols":392,"../internals/object-is-prototype-of":395,"../internals/object-keys":397,"../internals/object-property-is-enumerable":398,"../internals/set-to-string-tag":415,"../internals/shared":418,"../internals/shared-key":416,"../internals/symbol-constructor-detection":422,"../internals/symbol-define-to-primitive":423,"../internals/to-indexed-object":427,"../internals/to-property-key":432,"../internals/to-string":434,"../internals/uid":436,"../internals/well-known-symbol":443,"../internals/well-known-symbol-define":441,"../internals/well-known-symbol-wrapped":442}],506:[function(_dereq_,module,exports){
  24095. arguments[4][464][0].apply(exports,arguments)
  24096. },{"dup":464}],507:[function(_dereq_,module,exports){
  24097. var $ = _dereq_('../internals/export');
  24098. var getBuiltIn = _dereq_('../internals/get-built-in');
  24099. var hasOwn = _dereq_('../internals/has-own-property');
  24100. var toString = _dereq_('../internals/to-string');
  24101. var shared = _dereq_('../internals/shared');
  24102. var NATIVE_SYMBOL_REGISTRY = _dereq_('../internals/symbol-registry-detection');
  24103. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  24104. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  24105. // `Symbol.for` method
  24106. // https://tc39.es/ecma262/#sec-symbol.for
  24107. $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, {
  24108. 'for': function (key) {
  24109. var string = toString(key);
  24110. if (hasOwn(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
  24111. var symbol = getBuiltIn('Symbol')(string);
  24112. StringToSymbolRegistry[string] = symbol;
  24113. SymbolToStringRegistry[symbol] = string;
  24114. return symbol;
  24115. }
  24116. });
  24117. },{"../internals/export":332,"../internals/get-built-in":342,"../internals/has-own-property":348,"../internals/shared":418,"../internals/symbol-registry-detection":424,"../internals/to-string":434}],508:[function(_dereq_,module,exports){
  24118. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24119. // `Symbol.hasInstance` well-known symbol
  24120. // https://tc39.es/ecma262/#sec-symbol.hasinstance
  24121. defineWellKnownSymbol('hasInstance');
  24122. },{"../internals/well-known-symbol-define":441}],509:[function(_dereq_,module,exports){
  24123. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24124. // `Symbol.isConcatSpreadable` well-known symbol
  24125. // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
  24126. defineWellKnownSymbol('isConcatSpreadable');
  24127. },{"../internals/well-known-symbol-define":441}],510:[function(_dereq_,module,exports){
  24128. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24129. // `Symbol.iterator` well-known symbol
  24130. // https://tc39.es/ecma262/#sec-symbol.iterator
  24131. defineWellKnownSymbol('iterator');
  24132. },{"../internals/well-known-symbol-define":441}],511:[function(_dereq_,module,exports){
  24133. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  24134. _dereq_('../modules/es.symbol.constructor');
  24135. _dereq_('../modules/es.symbol.for');
  24136. _dereq_('../modules/es.symbol.key-for');
  24137. _dereq_('../modules/es.json.stringify');
  24138. _dereq_('../modules/es.object.get-own-property-symbols');
  24139. },{"../modules/es.json.stringify":466,"../modules/es.object.get-own-property-symbols":480,"../modules/es.symbol.constructor":505,"../modules/es.symbol.for":507,"../modules/es.symbol.key-for":512}],512:[function(_dereq_,module,exports){
  24140. var $ = _dereq_('../internals/export');
  24141. var hasOwn = _dereq_('../internals/has-own-property');
  24142. var isSymbol = _dereq_('../internals/is-symbol');
  24143. var tryToString = _dereq_('../internals/try-to-string');
  24144. var shared = _dereq_('../internals/shared');
  24145. var NATIVE_SYMBOL_REGISTRY = _dereq_('../internals/symbol-registry-detection');
  24146. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  24147. // `Symbol.keyFor` method
  24148. // https://tc39.es/ecma262/#sec-symbol.keyfor
  24149. $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, {
  24150. keyFor: function keyFor(sym) {
  24151. if (!isSymbol(sym)) throw TypeError(tryToString(sym) + ' is not a symbol');
  24152. if (hasOwn(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
  24153. }
  24154. });
  24155. },{"../internals/export":332,"../internals/has-own-property":348,"../internals/is-symbol":369,"../internals/shared":418,"../internals/symbol-registry-detection":424,"../internals/try-to-string":435}],513:[function(_dereq_,module,exports){
  24156. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24157. // `Symbol.matchAll` well-known symbol
  24158. // https://tc39.es/ecma262/#sec-symbol.matchall
  24159. defineWellKnownSymbol('matchAll');
  24160. },{"../internals/well-known-symbol-define":441}],514:[function(_dereq_,module,exports){
  24161. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24162. // `Symbol.match` well-known symbol
  24163. // https://tc39.es/ecma262/#sec-symbol.match
  24164. defineWellKnownSymbol('match');
  24165. },{"../internals/well-known-symbol-define":441}],515:[function(_dereq_,module,exports){
  24166. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24167. // `Symbol.replace` well-known symbol
  24168. // https://tc39.es/ecma262/#sec-symbol.replace
  24169. defineWellKnownSymbol('replace');
  24170. },{"../internals/well-known-symbol-define":441}],516:[function(_dereq_,module,exports){
  24171. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24172. // `Symbol.search` well-known symbol
  24173. // https://tc39.es/ecma262/#sec-symbol.search
  24174. defineWellKnownSymbol('search');
  24175. },{"../internals/well-known-symbol-define":441}],517:[function(_dereq_,module,exports){
  24176. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24177. // `Symbol.species` well-known symbol
  24178. // https://tc39.es/ecma262/#sec-symbol.species
  24179. defineWellKnownSymbol('species');
  24180. },{"../internals/well-known-symbol-define":441}],518:[function(_dereq_,module,exports){
  24181. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24182. // `Symbol.split` well-known symbol
  24183. // https://tc39.es/ecma262/#sec-symbol.split
  24184. defineWellKnownSymbol('split');
  24185. },{"../internals/well-known-symbol-define":441}],519:[function(_dereq_,module,exports){
  24186. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24187. var defineSymbolToPrimitive = _dereq_('../internals/symbol-define-to-primitive');
  24188. // `Symbol.toPrimitive` well-known symbol
  24189. // https://tc39.es/ecma262/#sec-symbol.toprimitive
  24190. defineWellKnownSymbol('toPrimitive');
  24191. // `Symbol.prototype[@@toPrimitive]` method
  24192. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  24193. defineSymbolToPrimitive();
  24194. },{"../internals/symbol-define-to-primitive":423,"../internals/well-known-symbol-define":441}],520:[function(_dereq_,module,exports){
  24195. var getBuiltIn = _dereq_('../internals/get-built-in');
  24196. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24197. var setToStringTag = _dereq_('../internals/set-to-string-tag');
  24198. // `Symbol.toStringTag` well-known symbol
  24199. // https://tc39.es/ecma262/#sec-symbol.tostringtag
  24200. defineWellKnownSymbol('toStringTag');
  24201. // `Symbol.prototype[@@toStringTag]` property
  24202. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  24203. setToStringTag(getBuiltIn('Symbol'), 'Symbol');
  24204. },{"../internals/get-built-in":342,"../internals/set-to-string-tag":415,"../internals/well-known-symbol-define":441}],521:[function(_dereq_,module,exports){
  24205. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24206. // `Symbol.unscopables` well-known symbol
  24207. // https://tc39.es/ecma262/#sec-symbol.unscopables
  24208. defineWellKnownSymbol('unscopables');
  24209. },{"../internals/well-known-symbol-define":441}],522:[function(_dereq_,module,exports){
  24210. 'use strict';
  24211. var global = _dereq_('../internals/global');
  24212. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  24213. var defineBuiltIns = _dereq_('../internals/define-built-ins');
  24214. var InternalMetadataModule = _dereq_('../internals/internal-metadata');
  24215. var collection = _dereq_('../internals/collection');
  24216. var collectionWeak = _dereq_('../internals/collection-weak');
  24217. var isObject = _dereq_('../internals/is-object');
  24218. var isExtensible = _dereq_('../internals/object-is-extensible');
  24219. var enforceInternalState = _dereq_('../internals/internal-state').enforce;
  24220. var NATIVE_WEAK_MAP = _dereq_('../internals/weak-map-basic-detection');
  24221. var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
  24222. var InternalWeakMap;
  24223. var wrapper = function (init) {
  24224. return function WeakMap() {
  24225. return init(this, arguments.length ? arguments[0] : undefined);
  24226. };
  24227. };
  24228. // `WeakMap` constructor
  24229. // https://tc39.es/ecma262/#sec-weakmap-constructor
  24230. var $WeakMap = collection('WeakMap', wrapper, collectionWeak);
  24231. // IE11 WeakMap frozen keys fix
  24232. // We can't use feature detection because it crash some old IE builds
  24233. // https://github.com/zloirock/core-js/issues/485
  24234. if (NATIVE_WEAK_MAP && IS_IE11) {
  24235. InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
  24236. InternalMetadataModule.enable();
  24237. var WeakMapPrototype = $WeakMap.prototype;
  24238. var nativeDelete = uncurryThis(WeakMapPrototype['delete']);
  24239. var nativeHas = uncurryThis(WeakMapPrototype.has);
  24240. var nativeGet = uncurryThis(WeakMapPrototype.get);
  24241. var nativeSet = uncurryThis(WeakMapPrototype.set);
  24242. defineBuiltIns(WeakMapPrototype, {
  24243. 'delete': function (key) {
  24244. if (isObject(key) && !isExtensible(key)) {
  24245. var state = enforceInternalState(this);
  24246. if (!state.frozen) state.frozen = new InternalWeakMap();
  24247. return nativeDelete(this, key) || state.frozen['delete'](key);
  24248. } return nativeDelete(this, key);
  24249. },
  24250. has: function has(key) {
  24251. if (isObject(key) && !isExtensible(key)) {
  24252. var state = enforceInternalState(this);
  24253. if (!state.frozen) state.frozen = new InternalWeakMap();
  24254. return nativeHas(this, key) || state.frozen.has(key);
  24255. } return nativeHas(this, key);
  24256. },
  24257. get: function get(key) {
  24258. if (isObject(key) && !isExtensible(key)) {
  24259. var state = enforceInternalState(this);
  24260. if (!state.frozen) state.frozen = new InternalWeakMap();
  24261. return nativeHas(this, key) ? nativeGet(this, key) : state.frozen.get(key);
  24262. } return nativeGet(this, key);
  24263. },
  24264. set: function set(key, value) {
  24265. if (isObject(key) && !isExtensible(key)) {
  24266. var state = enforceInternalState(this);
  24267. if (!state.frozen) state.frozen = new InternalWeakMap();
  24268. nativeHas(this, key) ? nativeSet(this, key, value) : state.frozen.set(key, value);
  24269. } else nativeSet(this, key, value);
  24270. return this;
  24271. }
  24272. });
  24273. }
  24274. },{"../internals/collection":301,"../internals/collection-weak":300,"../internals/define-built-ins":310,"../internals/function-uncurry-this":341,"../internals/global":347,"../internals/internal-metadata":356,"../internals/internal-state":357,"../internals/is-object":366,"../internals/object-is-extensible":394,"../internals/weak-map-basic-detection":440}],523:[function(_dereq_,module,exports){
  24275. // TODO: Remove this module from `core-js@4` since it's replaced to module below
  24276. _dereq_('../modules/es.weak-map.constructor');
  24277. },{"../modules/es.weak-map.constructor":522}],524:[function(_dereq_,module,exports){
  24278. // TODO: Remove from `core-js@4`
  24279. _dereq_('../modules/es.aggregate-error');
  24280. },{"../modules/es.aggregate-error":446}],525:[function(_dereq_,module,exports){
  24281. 'use strict';
  24282. var $ = _dereq_('../internals/export');
  24283. var deleteAll = _dereq_('../internals/collection-delete-all');
  24284. // `Map.prototype.deleteAll` method
  24285. // https://github.com/tc39/proposal-collection-methods
  24286. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24287. deleteAll: deleteAll
  24288. });
  24289. },{"../internals/collection-delete-all":296,"../internals/export":332}],526:[function(_dereq_,module,exports){
  24290. 'use strict';
  24291. var $ = _dereq_('../internals/export');
  24292. var emplace = _dereq_('../internals/map-emplace');
  24293. // `Map.prototype.emplace` method
  24294. // https://github.com/thumbsupep/proposal-upsert
  24295. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24296. emplace: emplace
  24297. });
  24298. },{"../internals/export":332,"../internals/map-emplace":377}],527:[function(_dereq_,module,exports){
  24299. 'use strict';
  24300. var $ = _dereq_('../internals/export');
  24301. var anObject = _dereq_('../internals/an-object');
  24302. var bind = _dereq_('../internals/function-bind-context');
  24303. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24304. var iterate = _dereq_('../internals/iterate');
  24305. // `Map.prototype.every` method
  24306. // https://github.com/tc39/proposal-collection-methods
  24307. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24308. every: function every(callbackfn /* , thisArg */) {
  24309. var map = anObject(this);
  24310. var iterator = getMapIterator(map);
  24311. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24312. return !iterate(iterator, function (key, value, stop) {
  24313. if (!boundFunction(value, key, map)) return stop();
  24314. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  24315. }
  24316. });
  24317. },{"../internals/an-object":277,"../internals/export":332,"../internals/function-bind-context":336,"../internals/get-map-iterator":345,"../internals/iterate":370}],528:[function(_dereq_,module,exports){
  24318. 'use strict';
  24319. var $ = _dereq_('../internals/export');
  24320. var getBuiltIn = _dereq_('../internals/get-built-in');
  24321. var bind = _dereq_('../internals/function-bind-context');
  24322. var call = _dereq_('../internals/function-call');
  24323. var aCallable = _dereq_('../internals/a-callable');
  24324. var anObject = _dereq_('../internals/an-object');
  24325. var speciesConstructor = _dereq_('../internals/species-constructor');
  24326. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24327. var iterate = _dereq_('../internals/iterate');
  24328. // `Map.prototype.filter` method
  24329. // https://github.com/tc39/proposal-collection-methods
  24330. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24331. filter: function filter(callbackfn /* , thisArg */) {
  24332. var map = anObject(this);
  24333. var iterator = getMapIterator(map);
  24334. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24335. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  24336. var setter = aCallable(newMap.set);
  24337. iterate(iterator, function (key, value) {
  24338. if (boundFunction(value, key, map)) call(setter, newMap, key, value);
  24339. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  24340. return newMap;
  24341. }
  24342. });
  24343. },{"../internals/a-callable":272,"../internals/an-object":277,"../internals/export":332,"../internals/function-bind-context":336,"../internals/function-call":339,"../internals/get-built-in":342,"../internals/get-map-iterator":345,"../internals/iterate":370,"../internals/species-constructor":419}],529:[function(_dereq_,module,exports){
  24344. 'use strict';
  24345. var $ = _dereq_('../internals/export');
  24346. var anObject = _dereq_('../internals/an-object');
  24347. var bind = _dereq_('../internals/function-bind-context');
  24348. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24349. var iterate = _dereq_('../internals/iterate');
  24350. // `Map.prototype.findKey` method
  24351. // https://github.com/tc39/proposal-collection-methods
  24352. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24353. findKey: function findKey(callbackfn /* , thisArg */) {
  24354. var map = anObject(this);
  24355. var iterator = getMapIterator(map);
  24356. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24357. return iterate(iterator, function (key, value, stop) {
  24358. if (boundFunction(value, key, map)) return stop(key);
  24359. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  24360. }
  24361. });
  24362. },{"../internals/an-object":277,"../internals/export":332,"../internals/function-bind-context":336,"../internals/get-map-iterator":345,"../internals/iterate":370}],530:[function(_dereq_,module,exports){
  24363. 'use strict';
  24364. var $ = _dereq_('../internals/export');
  24365. var anObject = _dereq_('../internals/an-object');
  24366. var bind = _dereq_('../internals/function-bind-context');
  24367. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24368. var iterate = _dereq_('../internals/iterate');
  24369. // `Map.prototype.find` method
  24370. // https://github.com/tc39/proposal-collection-methods
  24371. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24372. find: function find(callbackfn /* , thisArg */) {
  24373. var map = anObject(this);
  24374. var iterator = getMapIterator(map);
  24375. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24376. return iterate(iterator, function (key, value, stop) {
  24377. if (boundFunction(value, key, map)) return stop(value);
  24378. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  24379. }
  24380. });
  24381. },{"../internals/an-object":277,"../internals/export":332,"../internals/function-bind-context":336,"../internals/get-map-iterator":345,"../internals/iterate":370}],531:[function(_dereq_,module,exports){
  24382. var $ = _dereq_('../internals/export');
  24383. var from = _dereq_('../internals/collection-from');
  24384. // `Map.from` method
  24385. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
  24386. $({ target: 'Map', stat: true, forced: true }, {
  24387. from: from
  24388. });
  24389. },{"../internals/collection-from":297,"../internals/export":332}],532:[function(_dereq_,module,exports){
  24390. 'use strict';
  24391. var $ = _dereq_('../internals/export');
  24392. var call = _dereq_('../internals/function-call');
  24393. var uncurryThis = _dereq_('../internals/function-uncurry-this');
  24394. var aCallable = _dereq_('../internals/a-callable');
  24395. var getIterator = _dereq_('../internals/get-iterator');
  24396. var iterate = _dereq_('../internals/iterate');
  24397. var push = uncurryThis([].push);
  24398. // `Map.groupBy` method
  24399. // https://github.com/tc39/proposal-collection-methods
  24400. $({ target: 'Map', stat: true, forced: true }, {
  24401. groupBy: function groupBy(iterable, keyDerivative) {
  24402. aCallable(keyDerivative);
  24403. var iterator = getIterator(iterable);
  24404. var newMap = new this();
  24405. var has = aCallable(newMap.has);
  24406. var get = aCallable(newMap.get);
  24407. var set = aCallable(newMap.set);
  24408. iterate(iterator, function (element) {
  24409. var derivedKey = keyDerivative(element);
  24410. if (!call(has, newMap, derivedKey)) call(set, newMap, derivedKey, [element]);
  24411. else push(call(get, newMap, derivedKey), element);
  24412. }, { IS_ITERATOR: true });
  24413. return newMap;
  24414. }
  24415. });
  24416. },{"../internals/a-callable":272,"../internals/export":332,"../internals/function-call":339,"../internals/function-uncurry-this":341,"../internals/get-iterator":344,"../internals/iterate":370}],533:[function(_dereq_,module,exports){
  24417. 'use strict';
  24418. var $ = _dereq_('../internals/export');
  24419. var anObject = _dereq_('../internals/an-object');
  24420. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24421. var sameValueZero = _dereq_('../internals/same-value-zero');
  24422. var iterate = _dereq_('../internals/iterate');
  24423. // `Map.prototype.includes` method
  24424. // https://github.com/tc39/proposal-collection-methods
  24425. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24426. includes: function includes(searchElement) {
  24427. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  24428. if (sameValueZero(value, searchElement)) return stop();
  24429. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  24430. }
  24431. });
  24432. },{"../internals/an-object":277,"../internals/export":332,"../internals/get-map-iterator":345,"../internals/iterate":370,"../internals/same-value-zero":412}],534:[function(_dereq_,module,exports){
  24433. 'use strict';
  24434. var $ = _dereq_('../internals/export');
  24435. var call = _dereq_('../internals/function-call');
  24436. var iterate = _dereq_('../internals/iterate');
  24437. var aCallable = _dereq_('../internals/a-callable');
  24438. // `Map.keyBy` method
  24439. // https://github.com/tc39/proposal-collection-methods
  24440. $({ target: 'Map', stat: true, forced: true }, {
  24441. keyBy: function keyBy(iterable, keyDerivative) {
  24442. var newMap = new this();
  24443. aCallable(keyDerivative);
  24444. var setter = aCallable(newMap.set);
  24445. iterate(iterable, function (element) {
  24446. call(setter, newMap, keyDerivative(element), element);
  24447. });
  24448. return newMap;
  24449. }
  24450. });
  24451. },{"../internals/a-callable":272,"../internals/export":332,"../internals/function-call":339,"../internals/iterate":370}],535:[function(_dereq_,module,exports){
  24452. 'use strict';
  24453. var $ = _dereq_('../internals/export');
  24454. var anObject = _dereq_('../internals/an-object');
  24455. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24456. var iterate = _dereq_('../internals/iterate');
  24457. // `Map.prototype.keyOf` method
  24458. // https://github.com/tc39/proposal-collection-methods
  24459. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24460. keyOf: function keyOf(searchElement) {
  24461. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  24462. if (value === searchElement) return stop(key);
  24463. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  24464. }
  24465. });
  24466. },{"../internals/an-object":277,"../internals/export":332,"../internals/get-map-iterator":345,"../internals/iterate":370}],536:[function(_dereq_,module,exports){
  24467. 'use strict';
  24468. var $ = _dereq_('../internals/export');
  24469. var getBuiltIn = _dereq_('../internals/get-built-in');
  24470. var bind = _dereq_('../internals/function-bind-context');
  24471. var call = _dereq_('../internals/function-call');
  24472. var aCallable = _dereq_('../internals/a-callable');
  24473. var anObject = _dereq_('../internals/an-object');
  24474. var speciesConstructor = _dereq_('../internals/species-constructor');
  24475. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24476. var iterate = _dereq_('../internals/iterate');
  24477. // `Map.prototype.mapKeys` method
  24478. // https://github.com/tc39/proposal-collection-methods
  24479. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24480. mapKeys: function mapKeys(callbackfn /* , thisArg */) {
  24481. var map = anObject(this);
  24482. var iterator = getMapIterator(map);
  24483. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24484. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  24485. var setter = aCallable(newMap.set);
  24486. iterate(iterator, function (key, value) {
  24487. call(setter, newMap, boundFunction(value, key, map), value);
  24488. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  24489. return newMap;
  24490. }
  24491. });
  24492. },{"../internals/a-callable":272,"../internals/an-object":277,"../internals/export":332,"../internals/function-bind-context":336,"../internals/function-call":339,"../internals/get-built-in":342,"../internals/get-map-iterator":345,"../internals/iterate":370,"../internals/species-constructor":419}],537:[function(_dereq_,module,exports){
  24493. 'use strict';
  24494. var $ = _dereq_('../internals/export');
  24495. var getBuiltIn = _dereq_('../internals/get-built-in');
  24496. var bind = _dereq_('../internals/function-bind-context');
  24497. var call = _dereq_('../internals/function-call');
  24498. var aCallable = _dereq_('../internals/a-callable');
  24499. var anObject = _dereq_('../internals/an-object');
  24500. var speciesConstructor = _dereq_('../internals/species-constructor');
  24501. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24502. var iterate = _dereq_('../internals/iterate');
  24503. // `Map.prototype.mapValues` method
  24504. // https://github.com/tc39/proposal-collection-methods
  24505. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24506. mapValues: function mapValues(callbackfn /* , thisArg */) {
  24507. var map = anObject(this);
  24508. var iterator = getMapIterator(map);
  24509. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24510. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  24511. var setter = aCallable(newMap.set);
  24512. iterate(iterator, function (key, value) {
  24513. call(setter, newMap, key, boundFunction(value, key, map));
  24514. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  24515. return newMap;
  24516. }
  24517. });
  24518. },{"../internals/a-callable":272,"../internals/an-object":277,"../internals/export":332,"../internals/function-bind-context":336,"../internals/function-call":339,"../internals/get-built-in":342,"../internals/get-map-iterator":345,"../internals/iterate":370,"../internals/species-constructor":419}],538:[function(_dereq_,module,exports){
  24519. 'use strict';
  24520. var $ = _dereq_('../internals/export');
  24521. var aCallable = _dereq_('../internals/a-callable');
  24522. var anObject = _dereq_('../internals/an-object');
  24523. var iterate = _dereq_('../internals/iterate');
  24524. // `Map.prototype.merge` method
  24525. // https://github.com/tc39/proposal-collection-methods
  24526. $({ target: 'Map', proto: true, real: true, arity: 1, forced: true }, {
  24527. // eslint-disable-next-line no-unused-vars -- required for `.length`
  24528. merge: function merge(iterable /* ...iterables */) {
  24529. var map = anObject(this);
  24530. var setter = aCallable(map.set);
  24531. var argumentsLength = arguments.length;
  24532. var i = 0;
  24533. while (i < argumentsLength) {
  24534. iterate(arguments[i++], setter, { that: map, AS_ENTRIES: true });
  24535. }
  24536. return map;
  24537. }
  24538. });
  24539. },{"../internals/a-callable":272,"../internals/an-object":277,"../internals/export":332,"../internals/iterate":370}],539:[function(_dereq_,module,exports){
  24540. var $ = _dereq_('../internals/export');
  24541. var of = _dereq_('../internals/collection-of');
  24542. // `Map.of` method
  24543. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
  24544. $({ target: 'Map', stat: true, forced: true }, {
  24545. of: of
  24546. });
  24547. },{"../internals/collection-of":298,"../internals/export":332}],540:[function(_dereq_,module,exports){
  24548. 'use strict';
  24549. var $ = _dereq_('../internals/export');
  24550. var anObject = _dereq_('../internals/an-object');
  24551. var aCallable = _dereq_('../internals/a-callable');
  24552. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24553. var iterate = _dereq_('../internals/iterate');
  24554. var $TypeError = TypeError;
  24555. // `Map.prototype.reduce` method
  24556. // https://github.com/tc39/proposal-collection-methods
  24557. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24558. reduce: function reduce(callbackfn /* , initialValue */) {
  24559. var map = anObject(this);
  24560. var iterator = getMapIterator(map);
  24561. var noInitial = arguments.length < 2;
  24562. var accumulator = noInitial ? undefined : arguments[1];
  24563. aCallable(callbackfn);
  24564. iterate(iterator, function (key, value) {
  24565. if (noInitial) {
  24566. noInitial = false;
  24567. accumulator = value;
  24568. } else {
  24569. accumulator = callbackfn(accumulator, value, key, map);
  24570. }
  24571. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  24572. if (noInitial) throw $TypeError('Reduce of empty map with no initial value');
  24573. return accumulator;
  24574. }
  24575. });
  24576. },{"../internals/a-callable":272,"../internals/an-object":277,"../internals/export":332,"../internals/get-map-iterator":345,"../internals/iterate":370}],541:[function(_dereq_,module,exports){
  24577. 'use strict';
  24578. var $ = _dereq_('../internals/export');
  24579. var anObject = _dereq_('../internals/an-object');
  24580. var bind = _dereq_('../internals/function-bind-context');
  24581. var getMapIterator = _dereq_('../internals/get-map-iterator');
  24582. var iterate = _dereq_('../internals/iterate');
  24583. // `Set.prototype.some` method
  24584. // https://github.com/tc39/proposal-collection-methods
  24585. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24586. some: function some(callbackfn /* , thisArg */) {
  24587. var map = anObject(this);
  24588. var iterator = getMapIterator(map);
  24589. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  24590. return iterate(iterator, function (key, value, stop) {
  24591. if (boundFunction(value, key, map)) return stop();
  24592. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  24593. }
  24594. });
  24595. },{"../internals/an-object":277,"../internals/export":332,"../internals/function-bind-context":336,"../internals/get-map-iterator":345,"../internals/iterate":370}],542:[function(_dereq_,module,exports){
  24596. 'use strict';
  24597. // TODO: remove from `core-js@4`
  24598. var $ = _dereq_('../internals/export');
  24599. var upsert = _dereq_('../internals/map-upsert');
  24600. // `Map.prototype.updateOrInsert` method (replaced by `Map.prototype.emplace`)
  24601. // https://github.com/thumbsupep/proposal-upsert
  24602. $({ target: 'Map', proto: true, real: true, name: 'upsert', forced: true }, {
  24603. updateOrInsert: upsert
  24604. });
  24605. },{"../internals/export":332,"../internals/map-upsert":378}],543:[function(_dereq_,module,exports){
  24606. 'use strict';
  24607. var $ = _dereq_('../internals/export');
  24608. var call = _dereq_('../internals/function-call');
  24609. var anObject = _dereq_('../internals/an-object');
  24610. var aCallable = _dereq_('../internals/a-callable');
  24611. var $TypeError = TypeError;
  24612. // `Set.prototype.update` method
  24613. // https://github.com/tc39/proposal-collection-methods
  24614. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24615. update: function update(key, callback /* , thunk */) {
  24616. var map = anObject(this);
  24617. var get = aCallable(map.get);
  24618. var has = aCallable(map.has);
  24619. var set = aCallable(map.set);
  24620. var length = arguments.length;
  24621. aCallable(callback);
  24622. var isPresentInMap = call(has, map, key);
  24623. if (!isPresentInMap && length < 3) {
  24624. throw $TypeError('Updating absent value');
  24625. }
  24626. var value = isPresentInMap ? call(get, map, key) : aCallable(length > 2 ? arguments[2] : undefined)(key, map);
  24627. call(set, map, key, callback(value, key, map));
  24628. return map;
  24629. }
  24630. });
  24631. },{"../internals/a-callable":272,"../internals/an-object":277,"../internals/export":332,"../internals/function-call":339}],544:[function(_dereq_,module,exports){
  24632. 'use strict';
  24633. // TODO: remove from `core-js@4`
  24634. var $ = _dereq_('../internals/export');
  24635. var upsert = _dereq_('../internals/map-upsert');
  24636. // `Map.prototype.upsert` method (replaced by `Map.prototype.emplace`)
  24637. // https://github.com/thumbsupep/proposal-upsert
  24638. $({ target: 'Map', proto: true, real: true, forced: true }, {
  24639. upsert: upsert
  24640. });
  24641. },{"../internals/export":332,"../internals/map-upsert":378}],545:[function(_dereq_,module,exports){
  24642. // TODO: Remove from `core-js@4`
  24643. _dereq_('../modules/es.promise.all-settled.js');
  24644. },{"../modules/es.promise.all-settled.js":486}],546:[function(_dereq_,module,exports){
  24645. // TODO: Remove from `core-js@4`
  24646. _dereq_('../modules/es.promise.any');
  24647. },{"../modules/es.promise.any":488}],547:[function(_dereq_,module,exports){
  24648. 'use strict';
  24649. // TODO: Remove from `core-js@4`
  24650. var $ = _dereq_('../internals/export');
  24651. var newPromiseCapabilityModule = _dereq_('../internals/new-promise-capability');
  24652. var perform = _dereq_('../internals/perform');
  24653. // `Promise.try` method
  24654. // https://github.com/tc39/proposal-promise-try
  24655. $({ target: 'Promise', stat: true, forced: true }, {
  24656. 'try': function (callbackfn) {
  24657. var promiseCapability = newPromiseCapabilityModule.f(this);
  24658. var result = perform(callbackfn);
  24659. (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);
  24660. return promiseCapability.promise;
  24661. }
  24662. });
  24663. },{"../internals/export":332,"../internals/new-promise-capability":381,"../internals/perform":405}],548:[function(_dereq_,module,exports){
  24664. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24665. // `Symbol.asyncDispose` well-known symbol
  24666. // https://github.com/tc39/proposal-using-statement
  24667. defineWellKnownSymbol('asyncDispose');
  24668. },{"../internals/well-known-symbol-define":441}],549:[function(_dereq_,module,exports){
  24669. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24670. // `Symbol.dispose` well-known symbol
  24671. // https://github.com/tc39/proposal-using-statement
  24672. defineWellKnownSymbol('dispose');
  24673. },{"../internals/well-known-symbol-define":441}],550:[function(_dereq_,module,exports){
  24674. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24675. // `Symbol.matcher` well-known symbol
  24676. // https://github.com/tc39/proposal-pattern-matching
  24677. defineWellKnownSymbol('matcher');
  24678. },{"../internals/well-known-symbol-define":441}],551:[function(_dereq_,module,exports){
  24679. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24680. // `Symbol.metadataKey` well-known symbol
  24681. // https://github.com/tc39/proposal-decorator-metadata
  24682. defineWellKnownSymbol('metadataKey');
  24683. },{"../internals/well-known-symbol-define":441}],552:[function(_dereq_,module,exports){
  24684. // TODO: Remove from `core-js@4`
  24685. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24686. // `Symbol.metadata` well-known symbol
  24687. // https://github.com/tc39/proposal-decorators
  24688. defineWellKnownSymbol('metadata');
  24689. },{"../internals/well-known-symbol-define":441}],553:[function(_dereq_,module,exports){
  24690. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24691. // `Symbol.observable` well-known symbol
  24692. // https://github.com/tc39/proposal-observable
  24693. defineWellKnownSymbol('observable');
  24694. },{"../internals/well-known-symbol-define":441}],554:[function(_dereq_,module,exports){
  24695. // TODO: remove from `core-js@4`
  24696. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24697. // `Symbol.patternMatch` well-known symbol
  24698. // https://github.com/tc39/proposal-pattern-matching
  24699. defineWellKnownSymbol('patternMatch');
  24700. },{"../internals/well-known-symbol-define":441}],555:[function(_dereq_,module,exports){
  24701. // TODO: remove from `core-js@4`
  24702. var defineWellKnownSymbol = _dereq_('../internals/well-known-symbol-define');
  24703. defineWellKnownSymbol('replaceAll');
  24704. },{"../internals/well-known-symbol-define":441}],556:[function(_dereq_,module,exports){
  24705. _dereq_('../modules/es.array.iterator');
  24706. var DOMIterables = _dereq_('../internals/dom-iterables');
  24707. var global = _dereq_('../internals/global');
  24708. var classof = _dereq_('../internals/classof');
  24709. var createNonEnumerableProperty = _dereq_('../internals/create-non-enumerable-property');
  24710. var Iterators = _dereq_('../internals/iterators');
  24711. var wellKnownSymbol = _dereq_('../internals/well-known-symbol');
  24712. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  24713. for (var COLLECTION_NAME in DOMIterables) {
  24714. var Collection = global[COLLECTION_NAME];
  24715. var CollectionPrototype = Collection && Collection.prototype;
  24716. if (CollectionPrototype && classof(CollectionPrototype) !== TO_STRING_TAG) {
  24717. createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
  24718. }
  24719. Iterators[COLLECTION_NAME] = Iterators.Array;
  24720. }
  24721. },{"../internals/classof":295,"../internals/create-non-enumerable-property":306,"../internals/dom-iterables":316,"../internals/global":347,"../internals/iterators":375,"../internals/well-known-symbol":443,"../modules/es.array.iterator":457}],557:[function(_dereq_,module,exports){
  24722. var $ = _dereq_('../internals/export');
  24723. var global = _dereq_('../internals/global');
  24724. var setInterval = _dereq_('../internals/schedulers-fix').setInterval;
  24725. // ie9- setInterval additional parameters fix
  24726. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
  24727. $({ global: true, bind: true, forced: global.setInterval !== setInterval }, {
  24728. setInterval: setInterval
  24729. });
  24730. },{"../internals/export":332,"../internals/global":347,"../internals/schedulers-fix":413}],558:[function(_dereq_,module,exports){
  24731. var $ = _dereq_('../internals/export');
  24732. var global = _dereq_('../internals/global');
  24733. var setTimeout = _dereq_('../internals/schedulers-fix').setTimeout;
  24734. // ie9- setTimeout additional parameters fix
  24735. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
  24736. $({ global: true, bind: true, forced: global.setTimeout !== setTimeout }, {
  24737. setTimeout: setTimeout
  24738. });
  24739. },{"../internals/export":332,"../internals/global":347,"../internals/schedulers-fix":413}],559:[function(_dereq_,module,exports){
  24740. // TODO: Remove this module from `core-js@4` since it's split to modules listed below
  24741. _dereq_('../modules/web.set-interval');
  24742. _dereq_('../modules/web.set-timeout');
  24743. },{"../modules/web.set-interval":557,"../modules/web.set-timeout":558}],560:[function(_dereq_,module,exports){
  24744. var parent = _dereq_('../../es/array/from');
  24745. module.exports = parent;
  24746. },{"../../es/array/from":170}],561:[function(_dereq_,module,exports){
  24747. var parent = _dereq_('../../es/array/is-array');
  24748. module.exports = parent;
  24749. },{"../../es/array/is-array":171}],562:[function(_dereq_,module,exports){
  24750. var parent = _dereq_('../../../es/array/virtual/entries');
  24751. module.exports = parent;
  24752. },{"../../../es/array/virtual/entries":173}],563:[function(_dereq_,module,exports){
  24753. var parent = _dereq_('../../../es/array/virtual/for-each');
  24754. module.exports = parent;
  24755. },{"../../../es/array/virtual/for-each":178}],564:[function(_dereq_,module,exports){
  24756. var parent = _dereq_('../../../es/array/virtual/keys');
  24757. module.exports = parent;
  24758. },{"../../../es/array/virtual/keys":181}],565:[function(_dereq_,module,exports){
  24759. var parent = _dereq_('../../../es/array/virtual/values');
  24760. module.exports = parent;
  24761. },{"../../../es/array/virtual/values":188}],566:[function(_dereq_,module,exports){
  24762. var parent = _dereq_('../es/get-iterator-method');
  24763. _dereq_('../modules/web.dom-collections.iterator');
  24764. module.exports = parent;
  24765. },{"../es/get-iterator-method":190,"../modules/web.dom-collections.iterator":556}],567:[function(_dereq_,module,exports){
  24766. var parent = _dereq_('../../es/instance/bind');
  24767. module.exports = parent;
  24768. },{"../../es/instance/bind":191}],568:[function(_dereq_,module,exports){
  24769. var parent = _dereq_('../../es/instance/concat');
  24770. module.exports = parent;
  24771. },{"../../es/instance/concat":192}],569:[function(_dereq_,module,exports){
  24772. _dereq_('../../modules/web.dom-collections.iterator');
  24773. var classof = _dereq_('../../internals/classof');
  24774. var hasOwn = _dereq_('../../internals/has-own-property');
  24775. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  24776. var method = _dereq_('../array/virtual/entries');
  24777. var ArrayPrototype = Array.prototype;
  24778. var DOMIterables = {
  24779. DOMTokenList: true,
  24780. NodeList: true
  24781. };
  24782. module.exports = function (it) {
  24783. var own = it.entries;
  24784. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.entries)
  24785. || hasOwn(DOMIterables, classof(it)) ? method : own;
  24786. };
  24787. },{"../../internals/classof":295,"../../internals/has-own-property":348,"../../internals/object-is-prototype-of":395,"../../modules/web.dom-collections.iterator":556,"../array/virtual/entries":562}],570:[function(_dereq_,module,exports){
  24788. var parent = _dereq_('../../es/instance/every');
  24789. module.exports = parent;
  24790. },{"../../es/instance/every":193}],571:[function(_dereq_,module,exports){
  24791. var parent = _dereq_('../../es/instance/filter');
  24792. module.exports = parent;
  24793. },{"../../es/instance/filter":194}],572:[function(_dereq_,module,exports){
  24794. var parent = _dereq_('../../es/instance/find-index');
  24795. module.exports = parent;
  24796. },{"../../es/instance/find-index":195}],573:[function(_dereq_,module,exports){
  24797. var parent = _dereq_('../../es/instance/find');
  24798. module.exports = parent;
  24799. },{"../../es/instance/find":196}],574:[function(_dereq_,module,exports){
  24800. _dereq_('../../modules/web.dom-collections.iterator');
  24801. var classof = _dereq_('../../internals/classof');
  24802. var hasOwn = _dereq_('../../internals/has-own-property');
  24803. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  24804. var method = _dereq_('../array/virtual/for-each');
  24805. var ArrayPrototype = Array.prototype;
  24806. var DOMIterables = {
  24807. DOMTokenList: true,
  24808. NodeList: true
  24809. };
  24810. module.exports = function (it) {
  24811. var own = it.forEach;
  24812. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.forEach)
  24813. || hasOwn(DOMIterables, classof(it)) ? method : own;
  24814. };
  24815. },{"../../internals/classof":295,"../../internals/has-own-property":348,"../../internals/object-is-prototype-of":395,"../../modules/web.dom-collections.iterator":556,"../array/virtual/for-each":563}],575:[function(_dereq_,module,exports){
  24816. var parent = _dereq_('../../es/instance/includes');
  24817. module.exports = parent;
  24818. },{"../../es/instance/includes":197}],576:[function(_dereq_,module,exports){
  24819. var parent = _dereq_('../../es/instance/index-of');
  24820. module.exports = parent;
  24821. },{"../../es/instance/index-of":198}],577:[function(_dereq_,module,exports){
  24822. _dereq_('../../modules/web.dom-collections.iterator');
  24823. var classof = _dereq_('../../internals/classof');
  24824. var hasOwn = _dereq_('../../internals/has-own-property');
  24825. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  24826. var method = _dereq_('../array/virtual/keys');
  24827. var ArrayPrototype = Array.prototype;
  24828. var DOMIterables = {
  24829. DOMTokenList: true,
  24830. NodeList: true
  24831. };
  24832. module.exports = function (it) {
  24833. var own = it.keys;
  24834. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.keys)
  24835. || hasOwn(DOMIterables, classof(it)) ? method : own;
  24836. };
  24837. },{"../../internals/classof":295,"../../internals/has-own-property":348,"../../internals/object-is-prototype-of":395,"../../modules/web.dom-collections.iterator":556,"../array/virtual/keys":564}],578:[function(_dereq_,module,exports){
  24838. var parent = _dereq_('../../es/instance/map');
  24839. module.exports = parent;
  24840. },{"../../es/instance/map":199}],579:[function(_dereq_,module,exports){
  24841. var parent = _dereq_('../../es/instance/reduce');
  24842. module.exports = parent;
  24843. },{"../../es/instance/reduce":200}],580:[function(_dereq_,module,exports){
  24844. var parent = _dereq_('../../es/instance/reverse');
  24845. module.exports = parent;
  24846. },{"../../es/instance/reverse":201}],581:[function(_dereq_,module,exports){
  24847. var parent = _dereq_('../../es/instance/slice');
  24848. module.exports = parent;
  24849. },{"../../es/instance/slice":202}],582:[function(_dereq_,module,exports){
  24850. var parent = _dereq_('../../es/instance/sort');
  24851. module.exports = parent;
  24852. },{"../../es/instance/sort":203}],583:[function(_dereq_,module,exports){
  24853. var parent = _dereq_('../../es/instance/splice');
  24854. module.exports = parent;
  24855. },{"../../es/instance/splice":204}],584:[function(_dereq_,module,exports){
  24856. var parent = _dereq_('../../es/instance/starts-with');
  24857. module.exports = parent;
  24858. },{"../../es/instance/starts-with":205}],585:[function(_dereq_,module,exports){
  24859. _dereq_('../../modules/web.dom-collections.iterator');
  24860. var classof = _dereq_('../../internals/classof');
  24861. var hasOwn = _dereq_('../../internals/has-own-property');
  24862. var isPrototypeOf = _dereq_('../../internals/object-is-prototype-of');
  24863. var method = _dereq_('../array/virtual/values');
  24864. var ArrayPrototype = Array.prototype;
  24865. var DOMIterables = {
  24866. DOMTokenList: true,
  24867. NodeList: true
  24868. };
  24869. module.exports = function (it) {
  24870. var own = it.values;
  24871. return it === ArrayPrototype || (isPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.values)
  24872. || hasOwn(DOMIterables, classof(it)) ? method : own;
  24873. };
  24874. },{"../../internals/classof":295,"../../internals/has-own-property":348,"../../internals/object-is-prototype-of":395,"../../modules/web.dom-collections.iterator":556,"../array/virtual/values":565}],586:[function(_dereq_,module,exports){
  24875. var parent = _dereq_('../../es/json/stringify');
  24876. module.exports = parent;
  24877. },{"../../es/json/stringify":206}],587:[function(_dereq_,module,exports){
  24878. var parent = _dereq_('../../es/map');
  24879. _dereq_('../../modules/web.dom-collections.iterator');
  24880. module.exports = parent;
  24881. },{"../../es/map":207,"../../modules/web.dom-collections.iterator":556}],588:[function(_dereq_,module,exports){
  24882. var parent = _dereq_('../../es/number/is-integer');
  24883. module.exports = parent;
  24884. },{"../../es/number/is-integer":208}],589:[function(_dereq_,module,exports){
  24885. var parent = _dereq_('../../es/object/assign');
  24886. module.exports = parent;
  24887. },{"../../es/object/assign":209}],590:[function(_dereq_,module,exports){
  24888. var parent = _dereq_('../../es/object/create');
  24889. module.exports = parent;
  24890. },{"../../es/object/create":210}],591:[function(_dereq_,module,exports){
  24891. var parent = _dereq_('../../es/object/define-properties');
  24892. module.exports = parent;
  24893. },{"../../es/object/define-properties":211}],592:[function(_dereq_,module,exports){
  24894. var parent = _dereq_('../../es/object/define-property');
  24895. module.exports = parent;
  24896. },{"../../es/object/define-property":212}],593:[function(_dereq_,module,exports){
  24897. var parent = _dereq_('../../es/object/entries');
  24898. module.exports = parent;
  24899. },{"../../es/object/entries":213}],594:[function(_dereq_,module,exports){
  24900. var parent = _dereq_('../../es/object/freeze');
  24901. module.exports = parent;
  24902. },{"../../es/object/freeze":214}],595:[function(_dereq_,module,exports){
  24903. var parent = _dereq_('../../es/object/get-own-property-descriptor');
  24904. module.exports = parent;
  24905. },{"../../es/object/get-own-property-descriptor":215}],596:[function(_dereq_,module,exports){
  24906. var parent = _dereq_('../../es/object/get-own-property-descriptors');
  24907. module.exports = parent;
  24908. },{"../../es/object/get-own-property-descriptors":216}],597:[function(_dereq_,module,exports){
  24909. var parent = _dereq_('../../es/object/get-own-property-symbols');
  24910. module.exports = parent;
  24911. },{"../../es/object/get-own-property-symbols":217}],598:[function(_dereq_,module,exports){
  24912. var parent = _dereq_('../../es/object/get-prototype-of');
  24913. module.exports = parent;
  24914. },{"../../es/object/get-prototype-of":218}],599:[function(_dereq_,module,exports){
  24915. var parent = _dereq_('../../es/object/keys');
  24916. module.exports = parent;
  24917. },{"../../es/object/keys":219}],600:[function(_dereq_,module,exports){
  24918. var parent = _dereq_('../../es/object/set-prototype-of');
  24919. module.exports = parent;
  24920. },{"../../es/object/set-prototype-of":220}],601:[function(_dereq_,module,exports){
  24921. var parent = _dereq_('../es/parse-int');
  24922. module.exports = parent;
  24923. },{"../es/parse-int":221}],602:[function(_dereq_,module,exports){
  24924. var parent = _dereq_('../../es/promise');
  24925. _dereq_('../../modules/web.dom-collections.iterator');
  24926. module.exports = parent;
  24927. },{"../../es/promise":222,"../../modules/web.dom-collections.iterator":556}],603:[function(_dereq_,module,exports){
  24928. var parent = _dereq_('../../es/reflect/construct');
  24929. module.exports = parent;
  24930. },{"../../es/reflect/construct":223}],604:[function(_dereq_,module,exports){
  24931. var parent = _dereq_('../../es/reflect/get');
  24932. module.exports = parent;
  24933. },{"../../es/reflect/get":224}],605:[function(_dereq_,module,exports){
  24934. _dereq_('../modules/web.timers');
  24935. var path = _dereq_('../internals/path');
  24936. module.exports = path.setInterval;
  24937. },{"../internals/path":404,"../modules/web.timers":559}],606:[function(_dereq_,module,exports){
  24938. _dereq_('../modules/web.timers');
  24939. var path = _dereq_('../internals/path');
  24940. module.exports = path.setTimeout;
  24941. },{"../internals/path":404,"../modules/web.timers":559}],607:[function(_dereq_,module,exports){
  24942. var parent = _dereq_('../../es/set');
  24943. _dereq_('../../modules/web.dom-collections.iterator');
  24944. module.exports = parent;
  24945. },{"../../es/set":225,"../../modules/web.dom-collections.iterator":556}],608:[function(_dereq_,module,exports){
  24946. var parent = _dereq_('../../es/symbol');
  24947. _dereq_('../../modules/web.dom-collections.iterator');
  24948. module.exports = parent;
  24949. },{"../../es/symbol":228,"../../modules/web.dom-collections.iterator":556}],609:[function(_dereq_,module,exports){
  24950. var parent = _dereq_('../../es/symbol/iterator');
  24951. _dereq_('../../modules/web.dom-collections.iterator');
  24952. module.exports = parent;
  24953. },{"../../es/symbol/iterator":229,"../../modules/web.dom-collections.iterator":556}],610:[function(_dereq_,module,exports){
  24954. var parent = _dereq_('../../es/symbol/to-primitive');
  24955. module.exports = parent;
  24956. },{"../../es/symbol/to-primitive":230}],611:[function(_dereq_,module,exports){
  24957. var parent = _dereq_('../../es/weak-map');
  24958. _dereq_('../../modules/web.dom-collections.iterator');
  24959. module.exports = parent;
  24960. },{"../../es/weak-map":231,"../../modules/web.dom-collections.iterator":556}],612:[function(_dereq_,module,exports){
  24961. ;(function (root, factory, undef) {
  24962. if (typeof exports === "object") {
  24963. // CommonJS
  24964. module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
  24965. }
  24966. else if (typeof define === "function" && define.amd) {
  24967. // AMD
  24968. define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  24969. }
  24970. else {
  24971. // Global (browser)
  24972. factory(root.CryptoJS);
  24973. }
  24974. }(this, function (CryptoJS) {
  24975. (function () {
  24976. // Shortcuts
  24977. var C = CryptoJS;
  24978. var C_lib = C.lib;
  24979. var BlockCipher = C_lib.BlockCipher;
  24980. var C_algo = C.algo;
  24981. // Lookup tables
  24982. var SBOX = [];
  24983. var INV_SBOX = [];
  24984. var SUB_MIX_0 = [];
  24985. var SUB_MIX_1 = [];
  24986. var SUB_MIX_2 = [];
  24987. var SUB_MIX_3 = [];
  24988. var INV_SUB_MIX_0 = [];
  24989. var INV_SUB_MIX_1 = [];
  24990. var INV_SUB_MIX_2 = [];
  24991. var INV_SUB_MIX_3 = [];
  24992. // Compute lookup tables
  24993. (function () {
  24994. // Compute double table
  24995. var d = [];
  24996. for (var i = 0; i < 256; i++) {
  24997. if (i < 128) {
  24998. d[i] = i << 1;
  24999. } else {
  25000. d[i] = (i << 1) ^ 0x11b;
  25001. }
  25002. }
  25003. // Walk GF(2^8)
  25004. var x = 0;
  25005. var xi = 0;
  25006. for (var i = 0; i < 256; i++) {
  25007. // Compute sbox
  25008. var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  25009. sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  25010. SBOX[x] = sx;
  25011. INV_SBOX[sx] = x;
  25012. // Compute multiplication
  25013. var x2 = d[x];
  25014. var x4 = d[x2];
  25015. var x8 = d[x4];
  25016. // Compute sub bytes, mix columns tables
  25017. var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  25018. SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  25019. SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  25020. SUB_MIX_2[x] = (t << 8) | (t >>> 24);
  25021. SUB_MIX_3[x] = t;
  25022. // Compute inv sub bytes, inv mix columns tables
  25023. var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  25024. INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  25025. INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  25026. INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
  25027. INV_SUB_MIX_3[sx] = t;
  25028. // Compute next counter
  25029. if (!x) {
  25030. x = xi = 1;
  25031. } else {
  25032. x = x2 ^ d[d[d[x8 ^ x2]]];
  25033. xi ^= d[d[xi]];
  25034. }
  25035. }
  25036. }());
  25037. // Precomputed Rcon lookup
  25038. var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  25039. /**
  25040. * AES block cipher algorithm.
  25041. */
  25042. var AES = C_algo.AES = BlockCipher.extend({
  25043. _doReset: function () {
  25044. var t;
  25045. // Skip reset of nRounds has been set before and key did not change
  25046. if (this._nRounds && this._keyPriorReset === this._key) {
  25047. return;
  25048. }
  25049. // Shortcuts
  25050. var key = this._keyPriorReset = this._key;
  25051. var keyWords = key.words;
  25052. var keySize = key.sigBytes / 4;
  25053. // Compute number of rounds
  25054. var nRounds = this._nRounds = keySize + 6;
  25055. // Compute number of key schedule rows
  25056. var ksRows = (nRounds + 1) * 4;
  25057. // Compute key schedule
  25058. var keySchedule = this._keySchedule = [];
  25059. for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  25060. if (ksRow < keySize) {
  25061. keySchedule[ksRow] = keyWords[ksRow];
  25062. } else {
  25063. t = keySchedule[ksRow - 1];
  25064. if (!(ksRow % keySize)) {
  25065. // Rot word
  25066. t = (t << 8) | (t >>> 24);
  25067. // Sub word
  25068. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  25069. // Mix Rcon
  25070. t ^= RCON[(ksRow / keySize) | 0] << 24;
  25071. } else if (keySize > 6 && ksRow % keySize == 4) {
  25072. // Sub word
  25073. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  25074. }
  25075. keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  25076. }
  25077. }
  25078. // Compute inv key schedule
  25079. var invKeySchedule = this._invKeySchedule = [];
  25080. for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  25081. var ksRow = ksRows - invKsRow;
  25082. if (invKsRow % 4) {
  25083. var t = keySchedule[ksRow];
  25084. } else {
  25085. var t = keySchedule[ksRow - 4];
  25086. }
  25087. if (invKsRow < 4 || ksRow <= 4) {
  25088. invKeySchedule[invKsRow] = t;
  25089. } else {
  25090. invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  25091. INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  25092. }
  25093. }
  25094. },
  25095. encryptBlock: function (M, offset) {
  25096. this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  25097. },
  25098. decryptBlock: function (M, offset) {
  25099. // Swap 2nd and 4th rows
  25100. var t = M[offset + 1];
  25101. M[offset + 1] = M[offset + 3];
  25102. M[offset + 3] = t;
  25103. this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  25104. // Inv swap 2nd and 4th rows
  25105. var t = M[offset + 1];
  25106. M[offset + 1] = M[offset + 3];
  25107. M[offset + 3] = t;
  25108. },
  25109. _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  25110. // Shortcut
  25111. var nRounds = this._nRounds;
  25112. // Get input, add round key
  25113. var s0 = M[offset] ^ keySchedule[0];
  25114. var s1 = M[offset + 1] ^ keySchedule[1];
  25115. var s2 = M[offset + 2] ^ keySchedule[2];
  25116. var s3 = M[offset + 3] ^ keySchedule[3];
  25117. // Key schedule row counter
  25118. var ksRow = 4;
  25119. // Rounds
  25120. for (var round = 1; round < nRounds; round++) {
  25121. // Shift rows, sub bytes, mix columns, add round key
  25122. 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++];
  25123. 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++];
  25124. 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++];
  25125. 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++];
  25126. // Update state
  25127. s0 = t0;
  25128. s1 = t1;
  25129. s2 = t2;
  25130. s3 = t3;
  25131. }
  25132. // Shift rows, sub bytes, add round key
  25133. var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  25134. var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  25135. var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  25136. var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  25137. // Set output
  25138. M[offset] = t0;
  25139. M[offset + 1] = t1;
  25140. M[offset + 2] = t2;
  25141. M[offset + 3] = t3;
  25142. },
  25143. keySize: 256/32
  25144. });
  25145. /**
  25146. * Shortcut functions to the cipher's object interface.
  25147. *
  25148. * @example
  25149. *
  25150. * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  25151. * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  25152. */
  25153. C.AES = BlockCipher._createHelper(AES);
  25154. }());
  25155. return CryptoJS.AES;
  25156. }));
  25157. },{"./cipher-core":613,"./core":614,"./enc-base64":615,"./evpkdf":617,"./md5":619}],613:[function(_dereq_,module,exports){
  25158. ;(function (root, factory, undef) {
  25159. if (typeof exports === "object") {
  25160. // CommonJS
  25161. module.exports = exports = factory(_dereq_("./core"), _dereq_("./evpkdf"));
  25162. }
  25163. else if (typeof define === "function" && define.amd) {
  25164. // AMD
  25165. define(["./core", "./evpkdf"], factory);
  25166. }
  25167. else {
  25168. // Global (browser)
  25169. factory(root.CryptoJS);
  25170. }
  25171. }(this, function (CryptoJS) {
  25172. /**
  25173. * Cipher core components.
  25174. */
  25175. CryptoJS.lib.Cipher || (function (undefined) {
  25176. // Shortcuts
  25177. var C = CryptoJS;
  25178. var C_lib = C.lib;
  25179. var Base = C_lib.Base;
  25180. var WordArray = C_lib.WordArray;
  25181. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  25182. var C_enc = C.enc;
  25183. var Utf8 = C_enc.Utf8;
  25184. var Base64 = C_enc.Base64;
  25185. var C_algo = C.algo;
  25186. var EvpKDF = C_algo.EvpKDF;
  25187. /**
  25188. * Abstract base cipher template.
  25189. *
  25190. * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  25191. * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  25192. * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  25193. * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  25194. */
  25195. var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  25196. /**
  25197. * Configuration options.
  25198. *
  25199. * @property {WordArray} iv The IV to use for this operation.
  25200. */
  25201. cfg: Base.extend(),
  25202. /**
  25203. * Creates this cipher in encryption mode.
  25204. *
  25205. * @param {WordArray} key The key.
  25206. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25207. *
  25208. * @return {Cipher} A cipher instance.
  25209. *
  25210. * @static
  25211. *
  25212. * @example
  25213. *
  25214. * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  25215. */
  25216. createEncryptor: function (key, cfg) {
  25217. return this.create(this._ENC_XFORM_MODE, key, cfg);
  25218. },
  25219. /**
  25220. * Creates this cipher in decryption mode.
  25221. *
  25222. * @param {WordArray} key The key.
  25223. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25224. *
  25225. * @return {Cipher} A cipher instance.
  25226. *
  25227. * @static
  25228. *
  25229. * @example
  25230. *
  25231. * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  25232. */
  25233. createDecryptor: function (key, cfg) {
  25234. return this.create(this._DEC_XFORM_MODE, key, cfg);
  25235. },
  25236. /**
  25237. * Initializes a newly created cipher.
  25238. *
  25239. * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  25240. * @param {WordArray} key The key.
  25241. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25242. *
  25243. * @example
  25244. *
  25245. * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  25246. */
  25247. init: function (xformMode, key, cfg) {
  25248. // Apply config defaults
  25249. this.cfg = this.cfg.extend(cfg);
  25250. // Store transform mode and key
  25251. this._xformMode = xformMode;
  25252. this._key = key;
  25253. // Set initial values
  25254. this.reset();
  25255. },
  25256. /**
  25257. * Resets this cipher to its initial state.
  25258. *
  25259. * @example
  25260. *
  25261. * cipher.reset();
  25262. */
  25263. reset: function () {
  25264. // Reset data buffer
  25265. BufferedBlockAlgorithm.reset.call(this);
  25266. // Perform concrete-cipher logic
  25267. this._doReset();
  25268. },
  25269. /**
  25270. * Adds data to be encrypted or decrypted.
  25271. *
  25272. * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  25273. *
  25274. * @return {WordArray} The data after processing.
  25275. *
  25276. * @example
  25277. *
  25278. * var encrypted = cipher.process('data');
  25279. * var encrypted = cipher.process(wordArray);
  25280. */
  25281. process: function (dataUpdate) {
  25282. // Append
  25283. this._append(dataUpdate);
  25284. // Process available blocks
  25285. return this._process();
  25286. },
  25287. /**
  25288. * Finalizes the encryption or decryption process.
  25289. * Note that the finalize operation is effectively a destructive, read-once operation.
  25290. *
  25291. * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  25292. *
  25293. * @return {WordArray} The data after final processing.
  25294. *
  25295. * @example
  25296. *
  25297. * var encrypted = cipher.finalize();
  25298. * var encrypted = cipher.finalize('data');
  25299. * var encrypted = cipher.finalize(wordArray);
  25300. */
  25301. finalize: function (dataUpdate) {
  25302. // Final data update
  25303. if (dataUpdate) {
  25304. this._append(dataUpdate);
  25305. }
  25306. // Perform concrete-cipher logic
  25307. var finalProcessedData = this._doFinalize();
  25308. return finalProcessedData;
  25309. },
  25310. keySize: 128/32,
  25311. ivSize: 128/32,
  25312. _ENC_XFORM_MODE: 1,
  25313. _DEC_XFORM_MODE: 2,
  25314. /**
  25315. * Creates shortcut functions to a cipher's object interface.
  25316. *
  25317. * @param {Cipher} cipher The cipher to create a helper for.
  25318. *
  25319. * @return {Object} An object with encrypt and decrypt shortcut functions.
  25320. *
  25321. * @static
  25322. *
  25323. * @example
  25324. *
  25325. * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  25326. */
  25327. _createHelper: (function () {
  25328. function selectCipherStrategy(key) {
  25329. if (typeof key == 'string') {
  25330. return PasswordBasedCipher;
  25331. } else {
  25332. return SerializableCipher;
  25333. }
  25334. }
  25335. return function (cipher) {
  25336. return {
  25337. encrypt: function (message, key, cfg) {
  25338. return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  25339. },
  25340. decrypt: function (ciphertext, key, cfg) {
  25341. return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  25342. }
  25343. };
  25344. };
  25345. }())
  25346. });
  25347. /**
  25348. * Abstract base stream cipher template.
  25349. *
  25350. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  25351. */
  25352. var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  25353. _doFinalize: function () {
  25354. // Process partial blocks
  25355. var finalProcessedBlocks = this._process(!!'flush');
  25356. return finalProcessedBlocks;
  25357. },
  25358. blockSize: 1
  25359. });
  25360. /**
  25361. * Mode namespace.
  25362. */
  25363. var C_mode = C.mode = {};
  25364. /**
  25365. * Abstract base block cipher mode template.
  25366. */
  25367. var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  25368. /**
  25369. * Creates this mode for encryption.
  25370. *
  25371. * @param {Cipher} cipher A block cipher instance.
  25372. * @param {Array} iv The IV words.
  25373. *
  25374. * @static
  25375. *
  25376. * @example
  25377. *
  25378. * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  25379. */
  25380. createEncryptor: function (cipher, iv) {
  25381. return this.Encryptor.create(cipher, iv);
  25382. },
  25383. /**
  25384. * Creates this mode for decryption.
  25385. *
  25386. * @param {Cipher} cipher A block cipher instance.
  25387. * @param {Array} iv The IV words.
  25388. *
  25389. * @static
  25390. *
  25391. * @example
  25392. *
  25393. * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  25394. */
  25395. createDecryptor: function (cipher, iv) {
  25396. return this.Decryptor.create(cipher, iv);
  25397. },
  25398. /**
  25399. * Initializes a newly created mode.
  25400. *
  25401. * @param {Cipher} cipher A block cipher instance.
  25402. * @param {Array} iv The IV words.
  25403. *
  25404. * @example
  25405. *
  25406. * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  25407. */
  25408. init: function (cipher, iv) {
  25409. this._cipher = cipher;
  25410. this._iv = iv;
  25411. }
  25412. });
  25413. /**
  25414. * Cipher Block Chaining mode.
  25415. */
  25416. var CBC = C_mode.CBC = (function () {
  25417. /**
  25418. * Abstract base CBC mode.
  25419. */
  25420. var CBC = BlockCipherMode.extend();
  25421. /**
  25422. * CBC encryptor.
  25423. */
  25424. CBC.Encryptor = CBC.extend({
  25425. /**
  25426. * Processes the data block at offset.
  25427. *
  25428. * @param {Array} words The data words to operate on.
  25429. * @param {number} offset The offset where the block starts.
  25430. *
  25431. * @example
  25432. *
  25433. * mode.processBlock(data.words, offset);
  25434. */
  25435. processBlock: function (words, offset) {
  25436. // Shortcuts
  25437. var cipher = this._cipher;
  25438. var blockSize = cipher.blockSize;
  25439. // XOR and encrypt
  25440. xorBlock.call(this, words, offset, blockSize);
  25441. cipher.encryptBlock(words, offset);
  25442. // Remember this block to use with next block
  25443. this._prevBlock = words.slice(offset, offset + blockSize);
  25444. }
  25445. });
  25446. /**
  25447. * CBC decryptor.
  25448. */
  25449. CBC.Decryptor = CBC.extend({
  25450. /**
  25451. * Processes the data block at offset.
  25452. *
  25453. * @param {Array} words The data words to operate on.
  25454. * @param {number} offset The offset where the block starts.
  25455. *
  25456. * @example
  25457. *
  25458. * mode.processBlock(data.words, offset);
  25459. */
  25460. processBlock: function (words, offset) {
  25461. // Shortcuts
  25462. var cipher = this._cipher;
  25463. var blockSize = cipher.blockSize;
  25464. // Remember this block to use with next block
  25465. var thisBlock = words.slice(offset, offset + blockSize);
  25466. // Decrypt and XOR
  25467. cipher.decryptBlock(words, offset);
  25468. xorBlock.call(this, words, offset, blockSize);
  25469. // This block becomes the previous block
  25470. this._prevBlock = thisBlock;
  25471. }
  25472. });
  25473. function xorBlock(words, offset, blockSize) {
  25474. var block;
  25475. // Shortcut
  25476. var iv = this._iv;
  25477. // Choose mixing block
  25478. if (iv) {
  25479. block = iv;
  25480. // Remove IV for subsequent blocks
  25481. this._iv = undefined;
  25482. } else {
  25483. block = this._prevBlock;
  25484. }
  25485. // XOR blocks
  25486. for (var i = 0; i < blockSize; i++) {
  25487. words[offset + i] ^= block[i];
  25488. }
  25489. }
  25490. return CBC;
  25491. }());
  25492. /**
  25493. * Padding namespace.
  25494. */
  25495. var C_pad = C.pad = {};
  25496. /**
  25497. * PKCS #5/7 padding strategy.
  25498. */
  25499. var Pkcs7 = C_pad.Pkcs7 = {
  25500. /**
  25501. * Pads data using the algorithm defined in PKCS #5/7.
  25502. *
  25503. * @param {WordArray} data The data to pad.
  25504. * @param {number} blockSize The multiple that the data should be padded to.
  25505. *
  25506. * @static
  25507. *
  25508. * @example
  25509. *
  25510. * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  25511. */
  25512. pad: function (data, blockSize) {
  25513. // Shortcut
  25514. var blockSizeBytes = blockSize * 4;
  25515. // Count padding bytes
  25516. var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  25517. // Create padding word
  25518. var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  25519. // Create padding
  25520. var paddingWords = [];
  25521. for (var i = 0; i < nPaddingBytes; i += 4) {
  25522. paddingWords.push(paddingWord);
  25523. }
  25524. var padding = WordArray.create(paddingWords, nPaddingBytes);
  25525. // Add padding
  25526. data.concat(padding);
  25527. },
  25528. /**
  25529. * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  25530. *
  25531. * @param {WordArray} data The data to unpad.
  25532. *
  25533. * @static
  25534. *
  25535. * @example
  25536. *
  25537. * CryptoJS.pad.Pkcs7.unpad(wordArray);
  25538. */
  25539. unpad: function (data) {
  25540. // Get number of padding bytes from last byte
  25541. var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  25542. // Remove padding
  25543. data.sigBytes -= nPaddingBytes;
  25544. }
  25545. };
  25546. /**
  25547. * Abstract base block cipher template.
  25548. *
  25549. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  25550. */
  25551. var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  25552. /**
  25553. * Configuration options.
  25554. *
  25555. * @property {Mode} mode The block mode to use. Default: CBC
  25556. * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  25557. */
  25558. cfg: Cipher.cfg.extend({
  25559. mode: CBC,
  25560. padding: Pkcs7
  25561. }),
  25562. reset: function () {
  25563. var modeCreator;
  25564. // Reset cipher
  25565. Cipher.reset.call(this);
  25566. // Shortcuts
  25567. var cfg = this.cfg;
  25568. var iv = cfg.iv;
  25569. var mode = cfg.mode;
  25570. // Reset block mode
  25571. if (this._xformMode == this._ENC_XFORM_MODE) {
  25572. modeCreator = mode.createEncryptor;
  25573. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  25574. modeCreator = mode.createDecryptor;
  25575. // Keep at least one block in the buffer for unpadding
  25576. this._minBufferSize = 1;
  25577. }
  25578. if (this._mode && this._mode.__creator == modeCreator) {
  25579. this._mode.init(this, iv && iv.words);
  25580. } else {
  25581. this._mode = modeCreator.call(mode, this, iv && iv.words);
  25582. this._mode.__creator = modeCreator;
  25583. }
  25584. },
  25585. _doProcessBlock: function (words, offset) {
  25586. this._mode.processBlock(words, offset);
  25587. },
  25588. _doFinalize: function () {
  25589. var finalProcessedBlocks;
  25590. // Shortcut
  25591. var padding = this.cfg.padding;
  25592. // Finalize
  25593. if (this._xformMode == this._ENC_XFORM_MODE) {
  25594. // Pad data
  25595. padding.pad(this._data, this.blockSize);
  25596. // Process final blocks
  25597. finalProcessedBlocks = this._process(!!'flush');
  25598. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  25599. // Process final blocks
  25600. finalProcessedBlocks = this._process(!!'flush');
  25601. // Unpad data
  25602. padding.unpad(finalProcessedBlocks);
  25603. }
  25604. return finalProcessedBlocks;
  25605. },
  25606. blockSize: 128/32
  25607. });
  25608. /**
  25609. * A collection of cipher parameters.
  25610. *
  25611. * @property {WordArray} ciphertext The raw ciphertext.
  25612. * @property {WordArray} key The key to this ciphertext.
  25613. * @property {WordArray} iv The IV used in the ciphering operation.
  25614. * @property {WordArray} salt The salt used with a key derivation function.
  25615. * @property {Cipher} algorithm The cipher algorithm.
  25616. * @property {Mode} mode The block mode used in the ciphering operation.
  25617. * @property {Padding} padding The padding scheme used in the ciphering operation.
  25618. * @property {number} blockSize The block size of the cipher.
  25619. * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  25620. */
  25621. var CipherParams = C_lib.CipherParams = Base.extend({
  25622. /**
  25623. * Initializes a newly created cipher params object.
  25624. *
  25625. * @param {Object} cipherParams An object with any of the possible cipher parameters.
  25626. *
  25627. * @example
  25628. *
  25629. * var cipherParams = CryptoJS.lib.CipherParams.create({
  25630. * ciphertext: ciphertextWordArray,
  25631. * key: keyWordArray,
  25632. * iv: ivWordArray,
  25633. * salt: saltWordArray,
  25634. * algorithm: CryptoJS.algo.AES,
  25635. * mode: CryptoJS.mode.CBC,
  25636. * padding: CryptoJS.pad.PKCS7,
  25637. * blockSize: 4,
  25638. * formatter: CryptoJS.format.OpenSSL
  25639. * });
  25640. */
  25641. init: function (cipherParams) {
  25642. this.mixIn(cipherParams);
  25643. },
  25644. /**
  25645. * Converts this cipher params object to a string.
  25646. *
  25647. * @param {Format} formatter (Optional) The formatting strategy to use.
  25648. *
  25649. * @return {string} The stringified cipher params.
  25650. *
  25651. * @throws Error If neither the formatter nor the default formatter is set.
  25652. *
  25653. * @example
  25654. *
  25655. * var string = cipherParams + '';
  25656. * var string = cipherParams.toString();
  25657. * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  25658. */
  25659. toString: function (formatter) {
  25660. return (formatter || this.formatter).stringify(this);
  25661. }
  25662. });
  25663. /**
  25664. * Format namespace.
  25665. */
  25666. var C_format = C.format = {};
  25667. /**
  25668. * OpenSSL formatting strategy.
  25669. */
  25670. var OpenSSLFormatter = C_format.OpenSSL = {
  25671. /**
  25672. * Converts a cipher params object to an OpenSSL-compatible string.
  25673. *
  25674. * @param {CipherParams} cipherParams The cipher params object.
  25675. *
  25676. * @return {string} The OpenSSL-compatible string.
  25677. *
  25678. * @static
  25679. *
  25680. * @example
  25681. *
  25682. * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  25683. */
  25684. stringify: function (cipherParams) {
  25685. var wordArray;
  25686. // Shortcuts
  25687. var ciphertext = cipherParams.ciphertext;
  25688. var salt = cipherParams.salt;
  25689. // Format
  25690. if (salt) {
  25691. wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  25692. } else {
  25693. wordArray = ciphertext;
  25694. }
  25695. return wordArray.toString(Base64);
  25696. },
  25697. /**
  25698. * Converts an OpenSSL-compatible string to a cipher params object.
  25699. *
  25700. * @param {string} openSSLStr The OpenSSL-compatible string.
  25701. *
  25702. * @return {CipherParams} The cipher params object.
  25703. *
  25704. * @static
  25705. *
  25706. * @example
  25707. *
  25708. * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  25709. */
  25710. parse: function (openSSLStr) {
  25711. var salt;
  25712. // Parse base64
  25713. var ciphertext = Base64.parse(openSSLStr);
  25714. // Shortcut
  25715. var ciphertextWords = ciphertext.words;
  25716. // Test for salt
  25717. if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  25718. // Extract salt
  25719. salt = WordArray.create(ciphertextWords.slice(2, 4));
  25720. // Remove salt from ciphertext
  25721. ciphertextWords.splice(0, 4);
  25722. ciphertext.sigBytes -= 16;
  25723. }
  25724. return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  25725. }
  25726. };
  25727. /**
  25728. * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  25729. */
  25730. var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  25731. /**
  25732. * Configuration options.
  25733. *
  25734. * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  25735. */
  25736. cfg: Base.extend({
  25737. format: OpenSSLFormatter
  25738. }),
  25739. /**
  25740. * Encrypts a message.
  25741. *
  25742. * @param {Cipher} cipher The cipher algorithm to use.
  25743. * @param {WordArray|string} message The message to encrypt.
  25744. * @param {WordArray} key The key.
  25745. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25746. *
  25747. * @return {CipherParams} A cipher params object.
  25748. *
  25749. * @static
  25750. *
  25751. * @example
  25752. *
  25753. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  25754. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  25755. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  25756. */
  25757. encrypt: function (cipher, message, key, cfg) {
  25758. // Apply config defaults
  25759. cfg = this.cfg.extend(cfg);
  25760. // Encrypt
  25761. var encryptor = cipher.createEncryptor(key, cfg);
  25762. var ciphertext = encryptor.finalize(message);
  25763. // Shortcut
  25764. var cipherCfg = encryptor.cfg;
  25765. // Create and return serializable cipher params
  25766. return CipherParams.create({
  25767. ciphertext: ciphertext,
  25768. key: key,
  25769. iv: cipherCfg.iv,
  25770. algorithm: cipher,
  25771. mode: cipherCfg.mode,
  25772. padding: cipherCfg.padding,
  25773. blockSize: cipher.blockSize,
  25774. formatter: cfg.format
  25775. });
  25776. },
  25777. /**
  25778. * Decrypts serialized ciphertext.
  25779. *
  25780. * @param {Cipher} cipher The cipher algorithm to use.
  25781. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  25782. * @param {WordArray} key The key.
  25783. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25784. *
  25785. * @return {WordArray} The plaintext.
  25786. *
  25787. * @static
  25788. *
  25789. * @example
  25790. *
  25791. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  25792. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  25793. */
  25794. decrypt: function (cipher, ciphertext, key, cfg) {
  25795. // Apply config defaults
  25796. cfg = this.cfg.extend(cfg);
  25797. // Convert string to CipherParams
  25798. ciphertext = this._parse(ciphertext, cfg.format);
  25799. // Decrypt
  25800. var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  25801. return plaintext;
  25802. },
  25803. /**
  25804. * Converts serialized ciphertext to CipherParams,
  25805. * else assumed CipherParams already and returns ciphertext unchanged.
  25806. *
  25807. * @param {CipherParams|string} ciphertext The ciphertext.
  25808. * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  25809. *
  25810. * @return {CipherParams} The unserialized ciphertext.
  25811. *
  25812. * @static
  25813. *
  25814. * @example
  25815. *
  25816. * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  25817. */
  25818. _parse: function (ciphertext, format) {
  25819. if (typeof ciphertext == 'string') {
  25820. return format.parse(ciphertext, this);
  25821. } else {
  25822. return ciphertext;
  25823. }
  25824. }
  25825. });
  25826. /**
  25827. * Key derivation function namespace.
  25828. */
  25829. var C_kdf = C.kdf = {};
  25830. /**
  25831. * OpenSSL key derivation function.
  25832. */
  25833. var OpenSSLKdf = C_kdf.OpenSSL = {
  25834. /**
  25835. * Derives a key and IV from a password.
  25836. *
  25837. * @param {string} password The password to derive from.
  25838. * @param {number} keySize The size in words of the key to generate.
  25839. * @param {number} ivSize The size in words of the IV to generate.
  25840. * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  25841. *
  25842. * @return {CipherParams} A cipher params object with the key, IV, and salt.
  25843. *
  25844. * @static
  25845. *
  25846. * @example
  25847. *
  25848. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  25849. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  25850. */
  25851. execute: function (password, keySize, ivSize, salt) {
  25852. // Generate random salt
  25853. if (!salt) {
  25854. salt = WordArray.random(64/8);
  25855. }
  25856. // Derive key and IV
  25857. var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  25858. // Separate key and IV
  25859. var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  25860. key.sigBytes = keySize * 4;
  25861. // Return params
  25862. return CipherParams.create({ key: key, iv: iv, salt: salt });
  25863. }
  25864. };
  25865. /**
  25866. * A serializable cipher wrapper that derives the key from a password,
  25867. * and returns ciphertext as a serializable cipher params object.
  25868. */
  25869. var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  25870. /**
  25871. * Configuration options.
  25872. *
  25873. * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  25874. */
  25875. cfg: SerializableCipher.cfg.extend({
  25876. kdf: OpenSSLKdf
  25877. }),
  25878. /**
  25879. * Encrypts a message using a password.
  25880. *
  25881. * @param {Cipher} cipher The cipher algorithm to use.
  25882. * @param {WordArray|string} message The message to encrypt.
  25883. * @param {string} password The password.
  25884. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25885. *
  25886. * @return {CipherParams} A cipher params object.
  25887. *
  25888. * @static
  25889. *
  25890. * @example
  25891. *
  25892. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  25893. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  25894. */
  25895. encrypt: function (cipher, message, password, cfg) {
  25896. // Apply config defaults
  25897. cfg = this.cfg.extend(cfg);
  25898. // Derive key and other params
  25899. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  25900. // Add IV to config
  25901. cfg.iv = derivedParams.iv;
  25902. // Encrypt
  25903. var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  25904. // Mix in derived params
  25905. ciphertext.mixIn(derivedParams);
  25906. return ciphertext;
  25907. },
  25908. /**
  25909. * Decrypts serialized ciphertext using a password.
  25910. *
  25911. * @param {Cipher} cipher The cipher algorithm to use.
  25912. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  25913. * @param {string} password The password.
  25914. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  25915. *
  25916. * @return {WordArray} The plaintext.
  25917. *
  25918. * @static
  25919. *
  25920. * @example
  25921. *
  25922. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  25923. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  25924. */
  25925. decrypt: function (cipher, ciphertext, password, cfg) {
  25926. // Apply config defaults
  25927. cfg = this.cfg.extend(cfg);
  25928. // Convert string to CipherParams
  25929. ciphertext = this._parse(ciphertext, cfg.format);
  25930. // Derive key and other params
  25931. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  25932. // Add IV to config
  25933. cfg.iv = derivedParams.iv;
  25934. // Decrypt
  25935. var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  25936. return plaintext;
  25937. }
  25938. });
  25939. }());
  25940. }));
  25941. },{"./core":614,"./evpkdf":617}],614:[function(_dereq_,module,exports){
  25942. (function (global){(function (){
  25943. ;(function (root, factory) {
  25944. if (typeof exports === "object") {
  25945. // CommonJS
  25946. module.exports = exports = factory();
  25947. }
  25948. else if (typeof define === "function" && define.amd) {
  25949. // AMD
  25950. define([], factory);
  25951. }
  25952. else {
  25953. // Global (browser)
  25954. root.CryptoJS = factory();
  25955. }
  25956. }(this, function () {
  25957. /*globals window, global, require*/
  25958. /**
  25959. * CryptoJS core components.
  25960. */
  25961. var CryptoJS = CryptoJS || (function (Math, undefined) {
  25962. var crypto;
  25963. // Native crypto from window (Browser)
  25964. if (typeof window !== 'undefined' && window.crypto) {
  25965. crypto = window.crypto;
  25966. }
  25967. // Native crypto in web worker (Browser)
  25968. if (typeof self !== 'undefined' && self.crypto) {
  25969. crypto = self.crypto;
  25970. }
  25971. // Native crypto from worker
  25972. if (typeof globalThis !== 'undefined' && globalThis.crypto) {
  25973. crypto = globalThis.crypto;
  25974. }
  25975. // Native (experimental IE 11) crypto from window (Browser)
  25976. if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
  25977. crypto = window.msCrypto;
  25978. }
  25979. // Native crypto from global (NodeJS)
  25980. if (!crypto && typeof global !== 'undefined' && global.crypto) {
  25981. crypto = global.crypto;
  25982. }
  25983. // Native crypto import via require (NodeJS)
  25984. if (!crypto && typeof _dereq_ === 'function') {
  25985. try {
  25986. crypto = _dereq_('crypto');
  25987. } catch (err) {}
  25988. }
  25989. /*
  25990. * Cryptographically secure pseudorandom number generator
  25991. *
  25992. * As Math.random() is cryptographically not safe to use
  25993. */
  25994. var cryptoSecureRandomInt = function () {
  25995. if (crypto) {
  25996. // Use getRandomValues method (Browser)
  25997. if (typeof crypto.getRandomValues === 'function') {
  25998. try {
  25999. return crypto.getRandomValues(new Uint32Array(1))[0];
  26000. } catch (err) {}
  26001. }
  26002. // Use randomBytes method (NodeJS)
  26003. if (typeof crypto.randomBytes === 'function') {
  26004. try {
  26005. return crypto.randomBytes(4).readInt32LE();
  26006. } catch (err) {}
  26007. }
  26008. }
  26009. throw new Error('Native crypto module could not be used to get secure random number.');
  26010. };
  26011. /*
  26012. * Local polyfill of Object.create
  26013. */
  26014. var create = Object.create || (function () {
  26015. function F() {}
  26016. return function (obj) {
  26017. var subtype;
  26018. F.prototype = obj;
  26019. subtype = new F();
  26020. F.prototype = null;
  26021. return subtype;
  26022. };
  26023. }());
  26024. /**
  26025. * CryptoJS namespace.
  26026. */
  26027. var C = {};
  26028. /**
  26029. * Library namespace.
  26030. */
  26031. var C_lib = C.lib = {};
  26032. /**
  26033. * Base object for prototypal inheritance.
  26034. */
  26035. var Base = C_lib.Base = (function () {
  26036. return {
  26037. /**
  26038. * Creates a new object that inherits from this object.
  26039. *
  26040. * @param {Object} overrides Properties to copy into the new object.
  26041. *
  26042. * @return {Object} The new object.
  26043. *
  26044. * @static
  26045. *
  26046. * @example
  26047. *
  26048. * var MyType = CryptoJS.lib.Base.extend({
  26049. * field: 'value',
  26050. *
  26051. * method: function () {
  26052. * }
  26053. * });
  26054. */
  26055. extend: function (overrides) {
  26056. // Spawn
  26057. var subtype = create(this);
  26058. // Augment
  26059. if (overrides) {
  26060. subtype.mixIn(overrides);
  26061. }
  26062. // Create default initializer
  26063. if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  26064. subtype.init = function () {
  26065. subtype.$super.init.apply(this, arguments);
  26066. };
  26067. }
  26068. // Initializer's prototype is the subtype object
  26069. subtype.init.prototype = subtype;
  26070. // Reference supertype
  26071. subtype.$super = this;
  26072. return subtype;
  26073. },
  26074. /**
  26075. * Extends this object and runs the init method.
  26076. * Arguments to create() will be passed to init().
  26077. *
  26078. * @return {Object} The new object.
  26079. *
  26080. * @static
  26081. *
  26082. * @example
  26083. *
  26084. * var instance = MyType.create();
  26085. */
  26086. create: function () {
  26087. var instance = this.extend();
  26088. instance.init.apply(instance, arguments);
  26089. return instance;
  26090. },
  26091. /**
  26092. * Initializes a newly created object.
  26093. * Override this method to add some logic when your objects are created.
  26094. *
  26095. * @example
  26096. *
  26097. * var MyType = CryptoJS.lib.Base.extend({
  26098. * init: function () {
  26099. * // ...
  26100. * }
  26101. * });
  26102. */
  26103. init: function () {
  26104. },
  26105. /**
  26106. * Copies properties into this object.
  26107. *
  26108. * @param {Object} properties The properties to mix in.
  26109. *
  26110. * @example
  26111. *
  26112. * MyType.mixIn({
  26113. * field: 'value'
  26114. * });
  26115. */
  26116. mixIn: function (properties) {
  26117. for (var propertyName in properties) {
  26118. if (properties.hasOwnProperty(propertyName)) {
  26119. this[propertyName] = properties[propertyName];
  26120. }
  26121. }
  26122. // IE won't copy toString using the loop above
  26123. if (properties.hasOwnProperty('toString')) {
  26124. this.toString = properties.toString;
  26125. }
  26126. },
  26127. /**
  26128. * Creates a copy of this object.
  26129. *
  26130. * @return {Object} The clone.
  26131. *
  26132. * @example
  26133. *
  26134. * var clone = instance.clone();
  26135. */
  26136. clone: function () {
  26137. return this.init.prototype.extend(this);
  26138. }
  26139. };
  26140. }());
  26141. /**
  26142. * An array of 32-bit words.
  26143. *
  26144. * @property {Array} words The array of 32-bit words.
  26145. * @property {number} sigBytes The number of significant bytes in this word array.
  26146. */
  26147. var WordArray = C_lib.WordArray = Base.extend({
  26148. /**
  26149. * Initializes a newly created word array.
  26150. *
  26151. * @param {Array} words (Optional) An array of 32-bit words.
  26152. * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  26153. *
  26154. * @example
  26155. *
  26156. * var wordArray = CryptoJS.lib.WordArray.create();
  26157. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  26158. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  26159. */
  26160. init: function (words, sigBytes) {
  26161. words = this.words = words || [];
  26162. if (sigBytes != undefined) {
  26163. this.sigBytes = sigBytes;
  26164. } else {
  26165. this.sigBytes = words.length * 4;
  26166. }
  26167. },
  26168. /**
  26169. * Converts this word array to a string.
  26170. *
  26171. * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  26172. *
  26173. * @return {string} The stringified word array.
  26174. *
  26175. * @example
  26176. *
  26177. * var string = wordArray + '';
  26178. * var string = wordArray.toString();
  26179. * var string = wordArray.toString(CryptoJS.enc.Utf8);
  26180. */
  26181. toString: function (encoder) {
  26182. return (encoder || Hex).stringify(this);
  26183. },
  26184. /**
  26185. * Concatenates a word array to this word array.
  26186. *
  26187. * @param {WordArray} wordArray The word array to append.
  26188. *
  26189. * @return {WordArray} This word array.
  26190. *
  26191. * @example
  26192. *
  26193. * wordArray1.concat(wordArray2);
  26194. */
  26195. concat: function (wordArray) {
  26196. // Shortcuts
  26197. var thisWords = this.words;
  26198. var thatWords = wordArray.words;
  26199. var thisSigBytes = this.sigBytes;
  26200. var thatSigBytes = wordArray.sigBytes;
  26201. // Clamp excess bits
  26202. this.clamp();
  26203. // Concat
  26204. if (thisSigBytes % 4) {
  26205. // Copy one byte at a time
  26206. for (var i = 0; i < thatSigBytes; i++) {
  26207. var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  26208. thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  26209. }
  26210. } else {
  26211. // Copy one word at a time
  26212. for (var j = 0; j < thatSigBytes; j += 4) {
  26213. thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
  26214. }
  26215. }
  26216. this.sigBytes += thatSigBytes;
  26217. // Chainable
  26218. return this;
  26219. },
  26220. /**
  26221. * Removes insignificant bits.
  26222. *
  26223. * @example
  26224. *
  26225. * wordArray.clamp();
  26226. */
  26227. clamp: function () {
  26228. // Shortcuts
  26229. var words = this.words;
  26230. var sigBytes = this.sigBytes;
  26231. // Clamp
  26232. words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  26233. words.length = Math.ceil(sigBytes / 4);
  26234. },
  26235. /**
  26236. * Creates a copy of this word array.
  26237. *
  26238. * @return {WordArray} The clone.
  26239. *
  26240. * @example
  26241. *
  26242. * var clone = wordArray.clone();
  26243. */
  26244. clone: function () {
  26245. var clone = Base.clone.call(this);
  26246. clone.words = this.words.slice(0);
  26247. return clone;
  26248. },
  26249. /**
  26250. * Creates a word array filled with random bytes.
  26251. *
  26252. * @param {number} nBytes The number of random bytes to generate.
  26253. *
  26254. * @return {WordArray} The random word array.
  26255. *
  26256. * @static
  26257. *
  26258. * @example
  26259. *
  26260. * var wordArray = CryptoJS.lib.WordArray.random(16);
  26261. */
  26262. random: function (nBytes) {
  26263. var words = [];
  26264. for (var i = 0; i < nBytes; i += 4) {
  26265. words.push(cryptoSecureRandomInt());
  26266. }
  26267. return new WordArray.init(words, nBytes);
  26268. }
  26269. });
  26270. /**
  26271. * Encoder namespace.
  26272. */
  26273. var C_enc = C.enc = {};
  26274. /**
  26275. * Hex encoding strategy.
  26276. */
  26277. var Hex = C_enc.Hex = {
  26278. /**
  26279. * Converts a word array to a hex string.
  26280. *
  26281. * @param {WordArray} wordArray The word array.
  26282. *
  26283. * @return {string} The hex string.
  26284. *
  26285. * @static
  26286. *
  26287. * @example
  26288. *
  26289. * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  26290. */
  26291. stringify: function (wordArray) {
  26292. // Shortcuts
  26293. var words = wordArray.words;
  26294. var sigBytes = wordArray.sigBytes;
  26295. // Convert
  26296. var hexChars = [];
  26297. for (var i = 0; i < sigBytes; i++) {
  26298. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  26299. hexChars.push((bite >>> 4).toString(16));
  26300. hexChars.push((bite & 0x0f).toString(16));
  26301. }
  26302. return hexChars.join('');
  26303. },
  26304. /**
  26305. * Converts a hex string to a word array.
  26306. *
  26307. * @param {string} hexStr The hex string.
  26308. *
  26309. * @return {WordArray} The word array.
  26310. *
  26311. * @static
  26312. *
  26313. * @example
  26314. *
  26315. * var wordArray = CryptoJS.enc.Hex.parse(hexString);
  26316. */
  26317. parse: function (hexStr) {
  26318. // Shortcut
  26319. var hexStrLength = hexStr.length;
  26320. // Convert
  26321. var words = [];
  26322. for (var i = 0; i < hexStrLength; i += 2) {
  26323. words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  26324. }
  26325. return new WordArray.init(words, hexStrLength / 2);
  26326. }
  26327. };
  26328. /**
  26329. * Latin1 encoding strategy.
  26330. */
  26331. var Latin1 = C_enc.Latin1 = {
  26332. /**
  26333. * Converts a word array to a Latin1 string.
  26334. *
  26335. * @param {WordArray} wordArray The word array.
  26336. *
  26337. * @return {string} The Latin1 string.
  26338. *
  26339. * @static
  26340. *
  26341. * @example
  26342. *
  26343. * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  26344. */
  26345. stringify: function (wordArray) {
  26346. // Shortcuts
  26347. var words = wordArray.words;
  26348. var sigBytes = wordArray.sigBytes;
  26349. // Convert
  26350. var latin1Chars = [];
  26351. for (var i = 0; i < sigBytes; i++) {
  26352. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  26353. latin1Chars.push(String.fromCharCode(bite));
  26354. }
  26355. return latin1Chars.join('');
  26356. },
  26357. /**
  26358. * Converts a Latin1 string to a word array.
  26359. *
  26360. * @param {string} latin1Str The Latin1 string.
  26361. *
  26362. * @return {WordArray} The word array.
  26363. *
  26364. * @static
  26365. *
  26366. * @example
  26367. *
  26368. * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  26369. */
  26370. parse: function (latin1Str) {
  26371. // Shortcut
  26372. var latin1StrLength = latin1Str.length;
  26373. // Convert
  26374. var words = [];
  26375. for (var i = 0; i < latin1StrLength; i++) {
  26376. words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  26377. }
  26378. return new WordArray.init(words, latin1StrLength);
  26379. }
  26380. };
  26381. /**
  26382. * UTF-8 encoding strategy.
  26383. */
  26384. var Utf8 = C_enc.Utf8 = {
  26385. /**
  26386. * Converts a word array to a UTF-8 string.
  26387. *
  26388. * @param {WordArray} wordArray The word array.
  26389. *
  26390. * @return {string} The UTF-8 string.
  26391. *
  26392. * @static
  26393. *
  26394. * @example
  26395. *
  26396. * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  26397. */
  26398. stringify: function (wordArray) {
  26399. try {
  26400. return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  26401. } catch (e) {
  26402. throw new Error('Malformed UTF-8 data');
  26403. }
  26404. },
  26405. /**
  26406. * Converts a UTF-8 string to a word array.
  26407. *
  26408. * @param {string} utf8Str The UTF-8 string.
  26409. *
  26410. * @return {WordArray} The word array.
  26411. *
  26412. * @static
  26413. *
  26414. * @example
  26415. *
  26416. * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  26417. */
  26418. parse: function (utf8Str) {
  26419. return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  26420. }
  26421. };
  26422. /**
  26423. * Abstract buffered block algorithm template.
  26424. *
  26425. * The property blockSize must be implemented in a concrete subtype.
  26426. *
  26427. * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  26428. */
  26429. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  26430. /**
  26431. * Resets this block algorithm's data buffer to its initial state.
  26432. *
  26433. * @example
  26434. *
  26435. * bufferedBlockAlgorithm.reset();
  26436. */
  26437. reset: function () {
  26438. // Initial values
  26439. this._data = new WordArray.init();
  26440. this._nDataBytes = 0;
  26441. },
  26442. /**
  26443. * Adds new data to this block algorithm's buffer.
  26444. *
  26445. * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  26446. *
  26447. * @example
  26448. *
  26449. * bufferedBlockAlgorithm._append('data');
  26450. * bufferedBlockAlgorithm._append(wordArray);
  26451. */
  26452. _append: function (data) {
  26453. // Convert string to WordArray, else assume WordArray already
  26454. if (typeof data == 'string') {
  26455. data = Utf8.parse(data);
  26456. }
  26457. // Append
  26458. this._data.concat(data);
  26459. this._nDataBytes += data.sigBytes;
  26460. },
  26461. /**
  26462. * Processes available data blocks.
  26463. *
  26464. * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  26465. *
  26466. * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  26467. *
  26468. * @return {WordArray} The processed data.
  26469. *
  26470. * @example
  26471. *
  26472. * var processedData = bufferedBlockAlgorithm._process();
  26473. * var processedData = bufferedBlockAlgorithm._process(!!'flush');
  26474. */
  26475. _process: function (doFlush) {
  26476. var processedWords;
  26477. // Shortcuts
  26478. var data = this._data;
  26479. var dataWords = data.words;
  26480. var dataSigBytes = data.sigBytes;
  26481. var blockSize = this.blockSize;
  26482. var blockSizeBytes = blockSize * 4;
  26483. // Count blocks ready
  26484. var nBlocksReady = dataSigBytes / blockSizeBytes;
  26485. if (doFlush) {
  26486. // Round up to include partial blocks
  26487. nBlocksReady = Math.ceil(nBlocksReady);
  26488. } else {
  26489. // Round down to include only full blocks,
  26490. // less the number of blocks that must remain in the buffer
  26491. nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  26492. }
  26493. // Count words ready
  26494. var nWordsReady = nBlocksReady * blockSize;
  26495. // Count bytes ready
  26496. var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  26497. // Process blocks
  26498. if (nWordsReady) {
  26499. for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  26500. // Perform concrete-algorithm logic
  26501. this._doProcessBlock(dataWords, offset);
  26502. }
  26503. // Remove processed words
  26504. processedWords = dataWords.splice(0, nWordsReady);
  26505. data.sigBytes -= nBytesReady;
  26506. }
  26507. // Return processed words
  26508. return new WordArray.init(processedWords, nBytesReady);
  26509. },
  26510. /**
  26511. * Creates a copy of this object.
  26512. *
  26513. * @return {Object} The clone.
  26514. *
  26515. * @example
  26516. *
  26517. * var clone = bufferedBlockAlgorithm.clone();
  26518. */
  26519. clone: function () {
  26520. var clone = Base.clone.call(this);
  26521. clone._data = this._data.clone();
  26522. return clone;
  26523. },
  26524. _minBufferSize: 0
  26525. });
  26526. /**
  26527. * Abstract hasher template.
  26528. *
  26529. * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  26530. */
  26531. var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  26532. /**
  26533. * Configuration options.
  26534. */
  26535. cfg: Base.extend(),
  26536. /**
  26537. * Initializes a newly created hasher.
  26538. *
  26539. * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  26540. *
  26541. * @example
  26542. *
  26543. * var hasher = CryptoJS.algo.SHA256.create();
  26544. */
  26545. init: function (cfg) {
  26546. // Apply config defaults
  26547. this.cfg = this.cfg.extend(cfg);
  26548. // Set initial values
  26549. this.reset();
  26550. },
  26551. /**
  26552. * Resets this hasher to its initial state.
  26553. *
  26554. * @example
  26555. *
  26556. * hasher.reset();
  26557. */
  26558. reset: function () {
  26559. // Reset data buffer
  26560. BufferedBlockAlgorithm.reset.call(this);
  26561. // Perform concrete-hasher logic
  26562. this._doReset();
  26563. },
  26564. /**
  26565. * Updates this hasher with a message.
  26566. *
  26567. * @param {WordArray|string} messageUpdate The message to append.
  26568. *
  26569. * @return {Hasher} This hasher.
  26570. *
  26571. * @example
  26572. *
  26573. * hasher.update('message');
  26574. * hasher.update(wordArray);
  26575. */
  26576. update: function (messageUpdate) {
  26577. // Append
  26578. this._append(messageUpdate);
  26579. // Update the hash
  26580. this._process();
  26581. // Chainable
  26582. return this;
  26583. },
  26584. /**
  26585. * Finalizes the hash computation.
  26586. * Note that the finalize operation is effectively a destructive, read-once operation.
  26587. *
  26588. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  26589. *
  26590. * @return {WordArray} The hash.
  26591. *
  26592. * @example
  26593. *
  26594. * var hash = hasher.finalize();
  26595. * var hash = hasher.finalize('message');
  26596. * var hash = hasher.finalize(wordArray);
  26597. */
  26598. finalize: function (messageUpdate) {
  26599. // Final message update
  26600. if (messageUpdate) {
  26601. this._append(messageUpdate);
  26602. }
  26603. // Perform concrete-hasher logic
  26604. var hash = this._doFinalize();
  26605. return hash;
  26606. },
  26607. blockSize: 512/32,
  26608. /**
  26609. * Creates a shortcut function to a hasher's object interface.
  26610. *
  26611. * @param {Hasher} hasher The hasher to create a helper for.
  26612. *
  26613. * @return {Function} The shortcut function.
  26614. *
  26615. * @static
  26616. *
  26617. * @example
  26618. *
  26619. * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  26620. */
  26621. _createHelper: function (hasher) {
  26622. return function (message, cfg) {
  26623. return new hasher.init(cfg).finalize(message);
  26624. };
  26625. },
  26626. /**
  26627. * Creates a shortcut function to the HMAC's object interface.
  26628. *
  26629. * @param {Hasher} hasher The hasher to use in this HMAC helper.
  26630. *
  26631. * @return {Function} The shortcut function.
  26632. *
  26633. * @static
  26634. *
  26635. * @example
  26636. *
  26637. * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  26638. */
  26639. _createHmacHelper: function (hasher) {
  26640. return function (message, key) {
  26641. return new C_algo.HMAC.init(hasher, key).finalize(message);
  26642. };
  26643. }
  26644. });
  26645. /**
  26646. * Algorithm namespace.
  26647. */
  26648. var C_algo = C.algo = {};
  26649. return C;
  26650. }(Math));
  26651. return CryptoJS;
  26652. }));
  26653. }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  26654. },{"crypto":undefined}],615:[function(_dereq_,module,exports){
  26655. ;(function (root, factory) {
  26656. if (typeof exports === "object") {
  26657. // CommonJS
  26658. module.exports = exports = factory(_dereq_("./core"));
  26659. }
  26660. else if (typeof define === "function" && define.amd) {
  26661. // AMD
  26662. define(["./core"], factory);
  26663. }
  26664. else {
  26665. // Global (browser)
  26666. factory(root.CryptoJS);
  26667. }
  26668. }(this, function (CryptoJS) {
  26669. (function () {
  26670. // Shortcuts
  26671. var C = CryptoJS;
  26672. var C_lib = C.lib;
  26673. var WordArray = C_lib.WordArray;
  26674. var C_enc = C.enc;
  26675. /**
  26676. * Base64 encoding strategy.
  26677. */
  26678. var Base64 = C_enc.Base64 = {
  26679. /**
  26680. * Converts a word array to a Base64 string.
  26681. *
  26682. * @param {WordArray} wordArray The word array.
  26683. *
  26684. * @return {string} The Base64 string.
  26685. *
  26686. * @static
  26687. *
  26688. * @example
  26689. *
  26690. * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  26691. */
  26692. stringify: function (wordArray) {
  26693. // Shortcuts
  26694. var words = wordArray.words;
  26695. var sigBytes = wordArray.sigBytes;
  26696. var map = this._map;
  26697. // Clamp excess bits
  26698. wordArray.clamp();
  26699. // Convert
  26700. var base64Chars = [];
  26701. for (var i = 0; i < sigBytes; i += 3) {
  26702. var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  26703. var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  26704. var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  26705. var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  26706. for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  26707. base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  26708. }
  26709. }
  26710. // Add padding
  26711. var paddingChar = map.charAt(64);
  26712. if (paddingChar) {
  26713. while (base64Chars.length % 4) {
  26714. base64Chars.push(paddingChar);
  26715. }
  26716. }
  26717. return base64Chars.join('');
  26718. },
  26719. /**
  26720. * Converts a Base64 string to a word array.
  26721. *
  26722. * @param {string} base64Str The Base64 string.
  26723. *
  26724. * @return {WordArray} The word array.
  26725. *
  26726. * @static
  26727. *
  26728. * @example
  26729. *
  26730. * var wordArray = CryptoJS.enc.Base64.parse(base64String);
  26731. */
  26732. parse: function (base64Str) {
  26733. // Shortcuts
  26734. var base64StrLength = base64Str.length;
  26735. var map = this._map;
  26736. var reverseMap = this._reverseMap;
  26737. if (!reverseMap) {
  26738. reverseMap = this._reverseMap = [];
  26739. for (var j = 0; j < map.length; j++) {
  26740. reverseMap[map.charCodeAt(j)] = j;
  26741. }
  26742. }
  26743. // Ignore padding
  26744. var paddingChar = map.charAt(64);
  26745. if (paddingChar) {
  26746. var paddingIndex = base64Str.indexOf(paddingChar);
  26747. if (paddingIndex !== -1) {
  26748. base64StrLength = paddingIndex;
  26749. }
  26750. }
  26751. // Convert
  26752. return parseLoop(base64Str, base64StrLength, reverseMap);
  26753. },
  26754. _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  26755. };
  26756. function parseLoop(base64Str, base64StrLength, reverseMap) {
  26757. var words = [];
  26758. var nBytes = 0;
  26759. for (var i = 0; i < base64StrLength; i++) {
  26760. if (i % 4) {
  26761. var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  26762. var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  26763. var bitsCombined = bits1 | bits2;
  26764. words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
  26765. nBytes++;
  26766. }
  26767. }
  26768. return WordArray.create(words, nBytes);
  26769. }
  26770. }());
  26771. return CryptoJS.enc.Base64;
  26772. }));
  26773. },{"./core":614}],616:[function(_dereq_,module,exports){
  26774. ;(function (root, factory) {
  26775. if (typeof exports === "object") {
  26776. // CommonJS
  26777. module.exports = exports = factory(_dereq_("./core"));
  26778. }
  26779. else if (typeof define === "function" && define.amd) {
  26780. // AMD
  26781. define(["./core"], factory);
  26782. }
  26783. else {
  26784. // Global (browser)
  26785. factory(root.CryptoJS);
  26786. }
  26787. }(this, function (CryptoJS) {
  26788. return CryptoJS.enc.Utf8;
  26789. }));
  26790. },{"./core":614}],617:[function(_dereq_,module,exports){
  26791. ;(function (root, factory, undef) {
  26792. if (typeof exports === "object") {
  26793. // CommonJS
  26794. module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
  26795. }
  26796. else if (typeof define === "function" && define.amd) {
  26797. // AMD
  26798. define(["./core", "./sha1", "./hmac"], factory);
  26799. }
  26800. else {
  26801. // Global (browser)
  26802. factory(root.CryptoJS);
  26803. }
  26804. }(this, function (CryptoJS) {
  26805. (function () {
  26806. // Shortcuts
  26807. var C = CryptoJS;
  26808. var C_lib = C.lib;
  26809. var Base = C_lib.Base;
  26810. var WordArray = C_lib.WordArray;
  26811. var C_algo = C.algo;
  26812. var MD5 = C_algo.MD5;
  26813. /**
  26814. * This key derivation function is meant to conform with EVP_BytesToKey.
  26815. * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  26816. */
  26817. var EvpKDF = C_algo.EvpKDF = Base.extend({
  26818. /**
  26819. * Configuration options.
  26820. *
  26821. * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  26822. * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  26823. * @property {number} iterations The number of iterations to perform. Default: 1
  26824. */
  26825. cfg: Base.extend({
  26826. keySize: 128/32,
  26827. hasher: MD5,
  26828. iterations: 1
  26829. }),
  26830. /**
  26831. * Initializes a newly created key derivation function.
  26832. *
  26833. * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  26834. *
  26835. * @example
  26836. *
  26837. * var kdf = CryptoJS.algo.EvpKDF.create();
  26838. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  26839. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  26840. */
  26841. init: function (cfg) {
  26842. this.cfg = this.cfg.extend(cfg);
  26843. },
  26844. /**
  26845. * Derives a key from a password.
  26846. *
  26847. * @param {WordArray|string} password The password.
  26848. * @param {WordArray|string} salt A salt.
  26849. *
  26850. * @return {WordArray} The derived key.
  26851. *
  26852. * @example
  26853. *
  26854. * var key = kdf.compute(password, salt);
  26855. */
  26856. compute: function (password, salt) {
  26857. var block;
  26858. // Shortcut
  26859. var cfg = this.cfg;
  26860. // Init hasher
  26861. var hasher = cfg.hasher.create();
  26862. // Initial values
  26863. var derivedKey = WordArray.create();
  26864. // Shortcuts
  26865. var derivedKeyWords = derivedKey.words;
  26866. var keySize = cfg.keySize;
  26867. var iterations = cfg.iterations;
  26868. // Generate key
  26869. while (derivedKeyWords.length < keySize) {
  26870. if (block) {
  26871. hasher.update(block);
  26872. }
  26873. block = hasher.update(password).finalize(salt);
  26874. hasher.reset();
  26875. // Iterations
  26876. for (var i = 1; i < iterations; i++) {
  26877. block = hasher.finalize(block);
  26878. hasher.reset();
  26879. }
  26880. derivedKey.concat(block);
  26881. }
  26882. derivedKey.sigBytes = keySize * 4;
  26883. return derivedKey;
  26884. }
  26885. });
  26886. /**
  26887. * Derives a key from a password.
  26888. *
  26889. * @param {WordArray|string} password The password.
  26890. * @param {WordArray|string} salt A salt.
  26891. * @param {Object} cfg (Optional) The configuration options to use for this computation.
  26892. *
  26893. * @return {WordArray} The derived key.
  26894. *
  26895. * @static
  26896. *
  26897. * @example
  26898. *
  26899. * var key = CryptoJS.EvpKDF(password, salt);
  26900. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  26901. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  26902. */
  26903. C.EvpKDF = function (password, salt, cfg) {
  26904. return EvpKDF.create(cfg).compute(password, salt);
  26905. };
  26906. }());
  26907. return CryptoJS.EvpKDF;
  26908. }));
  26909. },{"./core":614,"./hmac":618,"./sha1":620}],618:[function(_dereq_,module,exports){
  26910. ;(function (root, factory) {
  26911. if (typeof exports === "object") {
  26912. // CommonJS
  26913. module.exports = exports = factory(_dereq_("./core"));
  26914. }
  26915. else if (typeof define === "function" && define.amd) {
  26916. // AMD
  26917. define(["./core"], factory);
  26918. }
  26919. else {
  26920. // Global (browser)
  26921. factory(root.CryptoJS);
  26922. }
  26923. }(this, function (CryptoJS) {
  26924. (function () {
  26925. // Shortcuts
  26926. var C = CryptoJS;
  26927. var C_lib = C.lib;
  26928. var Base = C_lib.Base;
  26929. var C_enc = C.enc;
  26930. var Utf8 = C_enc.Utf8;
  26931. var C_algo = C.algo;
  26932. /**
  26933. * HMAC algorithm.
  26934. */
  26935. var HMAC = C_algo.HMAC = Base.extend({
  26936. /**
  26937. * Initializes a newly created HMAC.
  26938. *
  26939. * @param {Hasher} hasher The hash algorithm to use.
  26940. * @param {WordArray|string} key The secret key.
  26941. *
  26942. * @example
  26943. *
  26944. * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  26945. */
  26946. init: function (hasher, key) {
  26947. // Init hasher
  26948. hasher = this._hasher = new hasher.init();
  26949. // Convert string to WordArray, else assume WordArray already
  26950. if (typeof key == 'string') {
  26951. key = Utf8.parse(key);
  26952. }
  26953. // Shortcuts
  26954. var hasherBlockSize = hasher.blockSize;
  26955. var hasherBlockSizeBytes = hasherBlockSize * 4;
  26956. // Allow arbitrary length keys
  26957. if (key.sigBytes > hasherBlockSizeBytes) {
  26958. key = hasher.finalize(key);
  26959. }
  26960. // Clamp excess bits
  26961. key.clamp();
  26962. // Clone key for inner and outer pads
  26963. var oKey = this._oKey = key.clone();
  26964. var iKey = this._iKey = key.clone();
  26965. // Shortcuts
  26966. var oKeyWords = oKey.words;
  26967. var iKeyWords = iKey.words;
  26968. // XOR keys with pad constants
  26969. for (var i = 0; i < hasherBlockSize; i++) {
  26970. oKeyWords[i] ^= 0x5c5c5c5c;
  26971. iKeyWords[i] ^= 0x36363636;
  26972. }
  26973. oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  26974. // Set initial values
  26975. this.reset();
  26976. },
  26977. /**
  26978. * Resets this HMAC to its initial state.
  26979. *
  26980. * @example
  26981. *
  26982. * hmacHasher.reset();
  26983. */
  26984. reset: function () {
  26985. // Shortcut
  26986. var hasher = this._hasher;
  26987. // Reset
  26988. hasher.reset();
  26989. hasher.update(this._iKey);
  26990. },
  26991. /**
  26992. * Updates this HMAC with a message.
  26993. *
  26994. * @param {WordArray|string} messageUpdate The message to append.
  26995. *
  26996. * @return {HMAC} This HMAC instance.
  26997. *
  26998. * @example
  26999. *
  27000. * hmacHasher.update('message');
  27001. * hmacHasher.update(wordArray);
  27002. */
  27003. update: function (messageUpdate) {
  27004. this._hasher.update(messageUpdate);
  27005. // Chainable
  27006. return this;
  27007. },
  27008. /**
  27009. * Finalizes the HMAC computation.
  27010. * Note that the finalize operation is effectively a destructive, read-once operation.
  27011. *
  27012. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  27013. *
  27014. * @return {WordArray} The HMAC.
  27015. *
  27016. * @example
  27017. *
  27018. * var hmac = hmacHasher.finalize();
  27019. * var hmac = hmacHasher.finalize('message');
  27020. * var hmac = hmacHasher.finalize(wordArray);
  27021. */
  27022. finalize: function (messageUpdate) {
  27023. // Shortcut
  27024. var hasher = this._hasher;
  27025. // Compute HMAC
  27026. var innerHash = hasher.finalize(messageUpdate);
  27027. hasher.reset();
  27028. var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  27029. return hmac;
  27030. }
  27031. });
  27032. }());
  27033. }));
  27034. },{"./core":614}],619:[function(_dereq_,module,exports){
  27035. ;(function (root, factory) {
  27036. if (typeof exports === "object") {
  27037. // CommonJS
  27038. module.exports = exports = factory(_dereq_("./core"));
  27039. }
  27040. else if (typeof define === "function" && define.amd) {
  27041. // AMD
  27042. define(["./core"], factory);
  27043. }
  27044. else {
  27045. // Global (browser)
  27046. factory(root.CryptoJS);
  27047. }
  27048. }(this, function (CryptoJS) {
  27049. (function (Math) {
  27050. // Shortcuts
  27051. var C = CryptoJS;
  27052. var C_lib = C.lib;
  27053. var WordArray = C_lib.WordArray;
  27054. var Hasher = C_lib.Hasher;
  27055. var C_algo = C.algo;
  27056. // Constants table
  27057. var T = [];
  27058. // Compute constants
  27059. (function () {
  27060. for (var i = 0; i < 64; i++) {
  27061. T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  27062. }
  27063. }());
  27064. /**
  27065. * MD5 hash algorithm.
  27066. */
  27067. var MD5 = C_algo.MD5 = Hasher.extend({
  27068. _doReset: function () {
  27069. this._hash = new WordArray.init([
  27070. 0x67452301, 0xefcdab89,
  27071. 0x98badcfe, 0x10325476
  27072. ]);
  27073. },
  27074. _doProcessBlock: function (M, offset) {
  27075. // Swap endian
  27076. for (var i = 0; i < 16; i++) {
  27077. // Shortcuts
  27078. var offset_i = offset + i;
  27079. var M_offset_i = M[offset_i];
  27080. M[offset_i] = (
  27081. (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  27082. (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  27083. );
  27084. }
  27085. // Shortcuts
  27086. var H = this._hash.words;
  27087. var M_offset_0 = M[offset + 0];
  27088. var M_offset_1 = M[offset + 1];
  27089. var M_offset_2 = M[offset + 2];
  27090. var M_offset_3 = M[offset + 3];
  27091. var M_offset_4 = M[offset + 4];
  27092. var M_offset_5 = M[offset + 5];
  27093. var M_offset_6 = M[offset + 6];
  27094. var M_offset_7 = M[offset + 7];
  27095. var M_offset_8 = M[offset + 8];
  27096. var M_offset_9 = M[offset + 9];
  27097. var M_offset_10 = M[offset + 10];
  27098. var M_offset_11 = M[offset + 11];
  27099. var M_offset_12 = M[offset + 12];
  27100. var M_offset_13 = M[offset + 13];
  27101. var M_offset_14 = M[offset + 14];
  27102. var M_offset_15 = M[offset + 15];
  27103. // Working varialbes
  27104. var a = H[0];
  27105. var b = H[1];
  27106. var c = H[2];
  27107. var d = H[3];
  27108. // Computation
  27109. a = FF(a, b, c, d, M_offset_0, 7, T[0]);
  27110. d = FF(d, a, b, c, M_offset_1, 12, T[1]);
  27111. c = FF(c, d, a, b, M_offset_2, 17, T[2]);
  27112. b = FF(b, c, d, a, M_offset_3, 22, T[3]);
  27113. a = FF(a, b, c, d, M_offset_4, 7, T[4]);
  27114. d = FF(d, a, b, c, M_offset_5, 12, T[5]);
  27115. c = FF(c, d, a, b, M_offset_6, 17, T[6]);
  27116. b = FF(b, c, d, a, M_offset_7, 22, T[7]);
  27117. a = FF(a, b, c, d, M_offset_8, 7, T[8]);
  27118. d = FF(d, a, b, c, M_offset_9, 12, T[9]);
  27119. c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  27120. b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  27121. a = FF(a, b, c, d, M_offset_12, 7, T[12]);
  27122. d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  27123. c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  27124. b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  27125. a = GG(a, b, c, d, M_offset_1, 5, T[16]);
  27126. d = GG(d, a, b, c, M_offset_6, 9, T[17]);
  27127. c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  27128. b = GG(b, c, d, a, M_offset_0, 20, T[19]);
  27129. a = GG(a, b, c, d, M_offset_5, 5, T[20]);
  27130. d = GG(d, a, b, c, M_offset_10, 9, T[21]);
  27131. c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  27132. b = GG(b, c, d, a, M_offset_4, 20, T[23]);
  27133. a = GG(a, b, c, d, M_offset_9, 5, T[24]);
  27134. d = GG(d, a, b, c, M_offset_14, 9, T[25]);
  27135. c = GG(c, d, a, b, M_offset_3, 14, T[26]);
  27136. b = GG(b, c, d, a, M_offset_8, 20, T[27]);
  27137. a = GG(a, b, c, d, M_offset_13, 5, T[28]);
  27138. d = GG(d, a, b, c, M_offset_2, 9, T[29]);
  27139. c = GG(c, d, a, b, M_offset_7, 14, T[30]);
  27140. b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  27141. a = HH(a, b, c, d, M_offset_5, 4, T[32]);
  27142. d = HH(d, a, b, c, M_offset_8, 11, T[33]);
  27143. c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  27144. b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  27145. a = HH(a, b, c, d, M_offset_1, 4, T[36]);
  27146. d = HH(d, a, b, c, M_offset_4, 11, T[37]);
  27147. c = HH(c, d, a, b, M_offset_7, 16, T[38]);
  27148. b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  27149. a = HH(a, b, c, d, M_offset_13, 4, T[40]);
  27150. d = HH(d, a, b, c, M_offset_0, 11, T[41]);
  27151. c = HH(c, d, a, b, M_offset_3, 16, T[42]);
  27152. b = HH(b, c, d, a, M_offset_6, 23, T[43]);
  27153. a = HH(a, b, c, d, M_offset_9, 4, T[44]);
  27154. d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  27155. c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  27156. b = HH(b, c, d, a, M_offset_2, 23, T[47]);
  27157. a = II(a, b, c, d, M_offset_0, 6, T[48]);
  27158. d = II(d, a, b, c, M_offset_7, 10, T[49]);
  27159. c = II(c, d, a, b, M_offset_14, 15, T[50]);
  27160. b = II(b, c, d, a, M_offset_5, 21, T[51]);
  27161. a = II(a, b, c, d, M_offset_12, 6, T[52]);
  27162. d = II(d, a, b, c, M_offset_3, 10, T[53]);
  27163. c = II(c, d, a, b, M_offset_10, 15, T[54]);
  27164. b = II(b, c, d, a, M_offset_1, 21, T[55]);
  27165. a = II(a, b, c, d, M_offset_8, 6, T[56]);
  27166. d = II(d, a, b, c, M_offset_15, 10, T[57]);
  27167. c = II(c, d, a, b, M_offset_6, 15, T[58]);
  27168. b = II(b, c, d, a, M_offset_13, 21, T[59]);
  27169. a = II(a, b, c, d, M_offset_4, 6, T[60]);
  27170. d = II(d, a, b, c, M_offset_11, 10, T[61]);
  27171. c = II(c, d, a, b, M_offset_2, 15, T[62]);
  27172. b = II(b, c, d, a, M_offset_9, 21, T[63]);
  27173. // Intermediate hash value
  27174. H[0] = (H[0] + a) | 0;
  27175. H[1] = (H[1] + b) | 0;
  27176. H[2] = (H[2] + c) | 0;
  27177. H[3] = (H[3] + d) | 0;
  27178. },
  27179. _doFinalize: function () {
  27180. // Shortcuts
  27181. var data = this._data;
  27182. var dataWords = data.words;
  27183. var nBitsTotal = this._nDataBytes * 8;
  27184. var nBitsLeft = data.sigBytes * 8;
  27185. // Add padding
  27186. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  27187. var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  27188. var nBitsTotalL = nBitsTotal;
  27189. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  27190. (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  27191. (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
  27192. );
  27193. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  27194. (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  27195. (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
  27196. );
  27197. data.sigBytes = (dataWords.length + 1) * 4;
  27198. // Hash final blocks
  27199. this._process();
  27200. // Shortcuts
  27201. var hash = this._hash;
  27202. var H = hash.words;
  27203. // Swap endian
  27204. for (var i = 0; i < 4; i++) {
  27205. // Shortcut
  27206. var H_i = H[i];
  27207. H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  27208. (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
  27209. }
  27210. // Return final computed hash
  27211. return hash;
  27212. },
  27213. clone: function () {
  27214. var clone = Hasher.clone.call(this);
  27215. clone._hash = this._hash.clone();
  27216. return clone;
  27217. }
  27218. });
  27219. function FF(a, b, c, d, x, s, t) {
  27220. var n = a + ((b & c) | (~b & d)) + x + t;
  27221. return ((n << s) | (n >>> (32 - s))) + b;
  27222. }
  27223. function GG(a, b, c, d, x, s, t) {
  27224. var n = a + ((b & d) | (c & ~d)) + x + t;
  27225. return ((n << s) | (n >>> (32 - s))) + b;
  27226. }
  27227. function HH(a, b, c, d, x, s, t) {
  27228. var n = a + (b ^ c ^ d) + x + t;
  27229. return ((n << s) | (n >>> (32 - s))) + b;
  27230. }
  27231. function II(a, b, c, d, x, s, t) {
  27232. var n = a + (c ^ (b | ~d)) + x + t;
  27233. return ((n << s) | (n >>> (32 - s))) + b;
  27234. }
  27235. /**
  27236. * Shortcut function to the hasher's object interface.
  27237. *
  27238. * @param {WordArray|string} message The message to hash.
  27239. *
  27240. * @return {WordArray} The hash.
  27241. *
  27242. * @static
  27243. *
  27244. * @example
  27245. *
  27246. * var hash = CryptoJS.MD5('message');
  27247. * var hash = CryptoJS.MD5(wordArray);
  27248. */
  27249. C.MD5 = Hasher._createHelper(MD5);
  27250. /**
  27251. * Shortcut function to the HMAC's object interface.
  27252. *
  27253. * @param {WordArray|string} message The message to hash.
  27254. * @param {WordArray|string} key The secret key.
  27255. *
  27256. * @return {WordArray} The HMAC.
  27257. *
  27258. * @static
  27259. *
  27260. * @example
  27261. *
  27262. * var hmac = CryptoJS.HmacMD5(message, key);
  27263. */
  27264. C.HmacMD5 = Hasher._createHmacHelper(MD5);
  27265. }(Math));
  27266. return CryptoJS.MD5;
  27267. }));
  27268. },{"./core":614}],620:[function(_dereq_,module,exports){
  27269. ;(function (root, factory) {
  27270. if (typeof exports === "object") {
  27271. // CommonJS
  27272. module.exports = exports = factory(_dereq_("./core"));
  27273. }
  27274. else if (typeof define === "function" && define.amd) {
  27275. // AMD
  27276. define(["./core"], factory);
  27277. }
  27278. else {
  27279. // Global (browser)
  27280. factory(root.CryptoJS);
  27281. }
  27282. }(this, function (CryptoJS) {
  27283. (function () {
  27284. // Shortcuts
  27285. var C = CryptoJS;
  27286. var C_lib = C.lib;
  27287. var WordArray = C_lib.WordArray;
  27288. var Hasher = C_lib.Hasher;
  27289. var C_algo = C.algo;
  27290. // Reusable object
  27291. var W = [];
  27292. /**
  27293. * SHA-1 hash algorithm.
  27294. */
  27295. var SHA1 = C_algo.SHA1 = Hasher.extend({
  27296. _doReset: function () {
  27297. this._hash = new WordArray.init([
  27298. 0x67452301, 0xefcdab89,
  27299. 0x98badcfe, 0x10325476,
  27300. 0xc3d2e1f0
  27301. ]);
  27302. },
  27303. _doProcessBlock: function (M, offset) {
  27304. // Shortcut
  27305. var H = this._hash.words;
  27306. // Working variables
  27307. var a = H[0];
  27308. var b = H[1];
  27309. var c = H[2];
  27310. var d = H[3];
  27311. var e = H[4];
  27312. // Computation
  27313. for (var i = 0; i < 80; i++) {
  27314. if (i < 16) {
  27315. W[i] = M[offset + i] | 0;
  27316. } else {
  27317. var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
  27318. W[i] = (n << 1) | (n >>> 31);
  27319. }
  27320. var t = ((a << 5) | (a >>> 27)) + e + W[i];
  27321. if (i < 20) {
  27322. t += ((b & c) | (~b & d)) + 0x5a827999;
  27323. } else if (i < 40) {
  27324. t += (b ^ c ^ d) + 0x6ed9eba1;
  27325. } else if (i < 60) {
  27326. t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
  27327. } else /* if (i < 80) */ {
  27328. t += (b ^ c ^ d) - 0x359d3e2a;
  27329. }
  27330. e = d;
  27331. d = c;
  27332. c = (b << 30) | (b >>> 2);
  27333. b = a;
  27334. a = t;
  27335. }
  27336. // Intermediate hash value
  27337. H[0] = (H[0] + a) | 0;
  27338. H[1] = (H[1] + b) | 0;
  27339. H[2] = (H[2] + c) | 0;
  27340. H[3] = (H[3] + d) | 0;
  27341. H[4] = (H[4] + e) | 0;
  27342. },
  27343. _doFinalize: function () {
  27344. // Shortcuts
  27345. var data = this._data;
  27346. var dataWords = data.words;
  27347. var nBitsTotal = this._nDataBytes * 8;
  27348. var nBitsLeft = data.sigBytes * 8;
  27349. // Add padding
  27350. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  27351. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  27352. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  27353. data.sigBytes = dataWords.length * 4;
  27354. // Hash final blocks
  27355. this._process();
  27356. // Return final computed hash
  27357. return this._hash;
  27358. },
  27359. clone: function () {
  27360. var clone = Hasher.clone.call(this);
  27361. clone._hash = this._hash.clone();
  27362. return clone;
  27363. }
  27364. });
  27365. /**
  27366. * Shortcut function to the hasher's object interface.
  27367. *
  27368. * @param {WordArray|string} message The message to hash.
  27369. *
  27370. * @return {WordArray} The hash.
  27371. *
  27372. * @static
  27373. *
  27374. * @example
  27375. *
  27376. * var hash = CryptoJS.SHA1('message');
  27377. * var hash = CryptoJS.SHA1(wordArray);
  27378. */
  27379. C.SHA1 = Hasher._createHelper(SHA1);
  27380. /**
  27381. * Shortcut function to the HMAC's object interface.
  27382. *
  27383. * @param {WordArray|string} message The message to hash.
  27384. * @param {WordArray|string} key The secret key.
  27385. *
  27386. * @return {WordArray} The HMAC.
  27387. *
  27388. * @static
  27389. *
  27390. * @example
  27391. *
  27392. * var hmac = CryptoJS.HmacSHA1(message, key);
  27393. */
  27394. C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
  27395. }());
  27396. return CryptoJS.SHA1;
  27397. }));
  27398. },{"./core":614}],621:[function(_dereq_,module,exports){
  27399. // Copyright Joyent, Inc. and other Node contributors.
  27400. //
  27401. // Permission is hereby granted, free of charge, to any person obtaining a
  27402. // copy of this software and associated documentation files (the
  27403. // "Software"), to deal in the Software without restriction, including
  27404. // without limitation the rights to use, copy, modify, merge, publish,
  27405. // distribute, sublicense, and/or sell copies of the Software, and to permit
  27406. // persons to whom the Software is furnished to do so, subject to the
  27407. // following conditions:
  27408. //
  27409. // The above copyright notice and this permission notice shall be included
  27410. // in all copies or substantial portions of the Software.
  27411. //
  27412. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  27413. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27414. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  27415. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  27416. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  27417. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  27418. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  27419. 'use strict';
  27420. var R = typeof Reflect === 'object' ? Reflect : null
  27421. var ReflectApply = R && typeof R.apply === 'function'
  27422. ? R.apply
  27423. : function ReflectApply(target, receiver, args) {
  27424. return Function.prototype.apply.call(target, receiver, args);
  27425. }
  27426. var ReflectOwnKeys
  27427. if (R && typeof R.ownKeys === 'function') {
  27428. ReflectOwnKeys = R.ownKeys
  27429. } else if (Object.getOwnPropertySymbols) {
  27430. ReflectOwnKeys = function ReflectOwnKeys(target) {
  27431. return Object.getOwnPropertyNames(target)
  27432. .concat(Object.getOwnPropertySymbols(target));
  27433. };
  27434. } else {
  27435. ReflectOwnKeys = function ReflectOwnKeys(target) {
  27436. return Object.getOwnPropertyNames(target);
  27437. };
  27438. }
  27439. function ProcessEmitWarning(warning) {
  27440. if (console && console.warn) console.warn(warning);
  27441. }
  27442. var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
  27443. return value !== value;
  27444. }
  27445. function EventEmitter() {
  27446. EventEmitter.init.call(this);
  27447. }
  27448. module.exports = EventEmitter;
  27449. module.exports.once = once;
  27450. // Backwards-compat with node 0.10.x
  27451. EventEmitter.EventEmitter = EventEmitter;
  27452. EventEmitter.prototype._events = undefined;
  27453. EventEmitter.prototype._eventsCount = 0;
  27454. EventEmitter.prototype._maxListeners = undefined;
  27455. // By default EventEmitters will print a warning if more than 10 listeners are
  27456. // added to it. This is a useful default which helps finding memory leaks.
  27457. var defaultMaxListeners = 10;
  27458. function checkListener(listener) {
  27459. if (typeof listener !== 'function') {
  27460. throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
  27461. }
  27462. }
  27463. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  27464. enumerable: true,
  27465. get: function() {
  27466. return defaultMaxListeners;
  27467. },
  27468. set: function(arg) {
  27469. if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
  27470. throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
  27471. }
  27472. defaultMaxListeners = arg;
  27473. }
  27474. });
  27475. EventEmitter.init = function() {
  27476. if (this._events === undefined ||
  27477. this._events === Object.getPrototypeOf(this)._events) {
  27478. this._events = Object.create(null);
  27479. this._eventsCount = 0;
  27480. }
  27481. this._maxListeners = this._maxListeners || undefined;
  27482. };
  27483. // Obviously not all Emitters should be limited to 10. This function allows
  27484. // that to be increased. Set to zero for unlimited.
  27485. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  27486. if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
  27487. throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
  27488. }
  27489. this._maxListeners = n;
  27490. return this;
  27491. };
  27492. function _getMaxListeners(that) {
  27493. if (that._maxListeners === undefined)
  27494. return EventEmitter.defaultMaxListeners;
  27495. return that._maxListeners;
  27496. }
  27497. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  27498. return _getMaxListeners(this);
  27499. };
  27500. EventEmitter.prototype.emit = function emit(type) {
  27501. var args = [];
  27502. for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
  27503. var doError = (type === 'error');
  27504. var events = this._events;
  27505. if (events !== undefined)
  27506. doError = (doError && events.error === undefined);
  27507. else if (!doError)
  27508. return false;
  27509. // If there is no 'error' event listener then throw.
  27510. if (doError) {
  27511. var er;
  27512. if (args.length > 0)
  27513. er = args[0];
  27514. if (er instanceof Error) {
  27515. // Note: The comments on the `throw` lines are intentional, they show
  27516. // up in Node's output if this results in an unhandled exception.
  27517. throw er; // Unhandled 'error' event
  27518. }
  27519. // At least give some kind of context to the user
  27520. var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
  27521. err.context = er;
  27522. throw err; // Unhandled 'error' event
  27523. }
  27524. var handler = events[type];
  27525. if (handler === undefined)
  27526. return false;
  27527. if (typeof handler === 'function') {
  27528. ReflectApply(handler, this, args);
  27529. } else {
  27530. var len = handler.length;
  27531. var listeners = arrayClone(handler, len);
  27532. for (var i = 0; i < len; ++i)
  27533. ReflectApply(listeners[i], this, args);
  27534. }
  27535. return true;
  27536. };
  27537. function _addListener(target, type, listener, prepend) {
  27538. var m;
  27539. var events;
  27540. var existing;
  27541. checkListener(listener);
  27542. events = target._events;
  27543. if (events === undefined) {
  27544. events = target._events = Object.create(null);
  27545. target._eventsCount = 0;
  27546. } else {
  27547. // To avoid recursion in the case that type === "newListener"! Before
  27548. // adding it to the listeners, first emit "newListener".
  27549. if (events.newListener !== undefined) {
  27550. target.emit('newListener', type,
  27551. listener.listener ? listener.listener : listener);
  27552. // Re-assign `events` because a newListener handler could have caused the
  27553. // this._events to be assigned to a new object
  27554. events = target._events;
  27555. }
  27556. existing = events[type];
  27557. }
  27558. if (existing === undefined) {
  27559. // Optimize the case of one listener. Don't need the extra array object.
  27560. existing = events[type] = listener;
  27561. ++target._eventsCount;
  27562. } else {
  27563. if (typeof existing === 'function') {
  27564. // Adding the second element, need to change to array.
  27565. existing = events[type] =
  27566. prepend ? [listener, existing] : [existing, listener];
  27567. // If we've already got an array, just append.
  27568. } else if (prepend) {
  27569. existing.unshift(listener);
  27570. } else {
  27571. existing.push(listener);
  27572. }
  27573. // Check for listener leak
  27574. m = _getMaxListeners(target);
  27575. if (m > 0 && existing.length > m && !existing.warned) {
  27576. existing.warned = true;
  27577. // No error code for this since it is a Warning
  27578. // eslint-disable-next-line no-restricted-syntax
  27579. var w = new Error('Possible EventEmitter memory leak detected. ' +
  27580. existing.length + ' ' + String(type) + ' listeners ' +
  27581. 'added. Use emitter.setMaxListeners() to ' +
  27582. 'increase limit');
  27583. w.name = 'MaxListenersExceededWarning';
  27584. w.emitter = target;
  27585. w.type = type;
  27586. w.count = existing.length;
  27587. ProcessEmitWarning(w);
  27588. }
  27589. }
  27590. return target;
  27591. }
  27592. EventEmitter.prototype.addListener = function addListener(type, listener) {
  27593. return _addListener(this, type, listener, false);
  27594. };
  27595. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  27596. EventEmitter.prototype.prependListener =
  27597. function prependListener(type, listener) {
  27598. return _addListener(this, type, listener, true);
  27599. };
  27600. function onceWrapper() {
  27601. if (!this.fired) {
  27602. this.target.removeListener(this.type, this.wrapFn);
  27603. this.fired = true;
  27604. if (arguments.length === 0)
  27605. return this.listener.call(this.target);
  27606. return this.listener.apply(this.target, arguments);
  27607. }
  27608. }
  27609. function _onceWrap(target, type, listener) {
  27610. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  27611. var wrapped = onceWrapper.bind(state);
  27612. wrapped.listener = listener;
  27613. state.wrapFn = wrapped;
  27614. return wrapped;
  27615. }
  27616. EventEmitter.prototype.once = function once(type, listener) {
  27617. checkListener(listener);
  27618. this.on(type, _onceWrap(this, type, listener));
  27619. return this;
  27620. };
  27621. EventEmitter.prototype.prependOnceListener =
  27622. function prependOnceListener(type, listener) {
  27623. checkListener(listener);
  27624. this.prependListener(type, _onceWrap(this, type, listener));
  27625. return this;
  27626. };
  27627. // Emits a 'removeListener' event if and only if the listener was removed.
  27628. EventEmitter.prototype.removeListener =
  27629. function removeListener(type, listener) {
  27630. var list, events, position, i, originalListener;
  27631. checkListener(listener);
  27632. events = this._events;
  27633. if (events === undefined)
  27634. return this;
  27635. list = events[type];
  27636. if (list === undefined)
  27637. return this;
  27638. if (list === listener || list.listener === listener) {
  27639. if (--this._eventsCount === 0)
  27640. this._events = Object.create(null);
  27641. else {
  27642. delete events[type];
  27643. if (events.removeListener)
  27644. this.emit('removeListener', type, list.listener || listener);
  27645. }
  27646. } else if (typeof list !== 'function') {
  27647. position = -1;
  27648. for (i = list.length - 1; i >= 0; i--) {
  27649. if (list[i] === listener || list[i].listener === listener) {
  27650. originalListener = list[i].listener;
  27651. position = i;
  27652. break;
  27653. }
  27654. }
  27655. if (position < 0)
  27656. return this;
  27657. if (position === 0)
  27658. list.shift();
  27659. else {
  27660. spliceOne(list, position);
  27661. }
  27662. if (list.length === 1)
  27663. events[type] = list[0];
  27664. if (events.removeListener !== undefined)
  27665. this.emit('removeListener', type, originalListener || listener);
  27666. }
  27667. return this;
  27668. };
  27669. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  27670. EventEmitter.prototype.removeAllListeners =
  27671. function removeAllListeners(type) {
  27672. var listeners, events, i;
  27673. events = this._events;
  27674. if (events === undefined)
  27675. return this;
  27676. // not listening for removeListener, no need to emit
  27677. if (events.removeListener === undefined) {
  27678. if (arguments.length === 0) {
  27679. this._events = Object.create(null);
  27680. this._eventsCount = 0;
  27681. } else if (events[type] !== undefined) {
  27682. if (--this._eventsCount === 0)
  27683. this._events = Object.create(null);
  27684. else
  27685. delete events[type];
  27686. }
  27687. return this;
  27688. }
  27689. // emit removeListener for all listeners on all events
  27690. if (arguments.length === 0) {
  27691. var keys = Object.keys(events);
  27692. var key;
  27693. for (i = 0; i < keys.length; ++i) {
  27694. key = keys[i];
  27695. if (key === 'removeListener') continue;
  27696. this.removeAllListeners(key);
  27697. }
  27698. this.removeAllListeners('removeListener');
  27699. this._events = Object.create(null);
  27700. this._eventsCount = 0;
  27701. return this;
  27702. }
  27703. listeners = events[type];
  27704. if (typeof listeners === 'function') {
  27705. this.removeListener(type, listeners);
  27706. } else if (listeners !== undefined) {
  27707. // LIFO order
  27708. for (i = listeners.length - 1; i >= 0; i--) {
  27709. this.removeListener(type, listeners[i]);
  27710. }
  27711. }
  27712. return this;
  27713. };
  27714. function _listeners(target, type, unwrap) {
  27715. var events = target._events;
  27716. if (events === undefined)
  27717. return [];
  27718. var evlistener = events[type];
  27719. if (evlistener === undefined)
  27720. return [];
  27721. if (typeof evlistener === 'function')
  27722. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  27723. return unwrap ?
  27724. unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  27725. }
  27726. EventEmitter.prototype.listeners = function listeners(type) {
  27727. return _listeners(this, type, true);
  27728. };
  27729. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  27730. return _listeners(this, type, false);
  27731. };
  27732. EventEmitter.listenerCount = function(emitter, type) {
  27733. if (typeof emitter.listenerCount === 'function') {
  27734. return emitter.listenerCount(type);
  27735. } else {
  27736. return listenerCount.call(emitter, type);
  27737. }
  27738. };
  27739. EventEmitter.prototype.listenerCount = listenerCount;
  27740. function listenerCount(type) {
  27741. var events = this._events;
  27742. if (events !== undefined) {
  27743. var evlistener = events[type];
  27744. if (typeof evlistener === 'function') {
  27745. return 1;
  27746. } else if (evlistener !== undefined) {
  27747. return evlistener.length;
  27748. }
  27749. }
  27750. return 0;
  27751. }
  27752. EventEmitter.prototype.eventNames = function eventNames() {
  27753. return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
  27754. };
  27755. function arrayClone(arr, n) {
  27756. var copy = new Array(n);
  27757. for (var i = 0; i < n; ++i)
  27758. copy[i] = arr[i];
  27759. return copy;
  27760. }
  27761. function spliceOne(list, index) {
  27762. for (; index + 1 < list.length; index++)
  27763. list[index] = list[index + 1];
  27764. list.pop();
  27765. }
  27766. function unwrapListeners(arr) {
  27767. var ret = new Array(arr.length);
  27768. for (var i = 0; i < ret.length; ++i) {
  27769. ret[i] = arr[i].listener || arr[i];
  27770. }
  27771. return ret;
  27772. }
  27773. function once(emitter, name) {
  27774. return new Promise(function (resolve, reject) {
  27775. function errorListener(err) {
  27776. emitter.removeListener(name, resolver);
  27777. reject(err);
  27778. }
  27779. function resolver() {
  27780. if (typeof emitter.removeListener === 'function') {
  27781. emitter.removeListener('error', errorListener);
  27782. }
  27783. resolve([].slice.call(arguments));
  27784. };
  27785. eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
  27786. if (name !== 'error') {
  27787. addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
  27788. }
  27789. });
  27790. }
  27791. function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
  27792. if (typeof emitter.on === 'function') {
  27793. eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
  27794. }
  27795. }
  27796. function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
  27797. if (typeof emitter.on === 'function') {
  27798. if (flags.once) {
  27799. emitter.once(name, listener);
  27800. } else {
  27801. emitter.on(name, listener);
  27802. }
  27803. } else if (typeof emitter.addEventListener === 'function') {
  27804. // EventTarget does not have `error` event semantics like Node
  27805. // EventEmitters, we do not listen for `error` events here.
  27806. emitter.addEventListener(name, function wrapListener(arg) {
  27807. // IE does not have builtin `{ once: true }` support so we
  27808. // have to do it manually.
  27809. if (flags.once) {
  27810. emitter.removeEventListener(name, wrapListener);
  27811. }
  27812. listener(arg);
  27813. });
  27814. } else {
  27815. throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
  27816. }
  27817. }
  27818. },{}]},{},[17])(17)
  27819. });