babylon.sandbox.max.js 1.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs-loaders"), require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-sandbox", ["babylonjs-loaders", "babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-sandbox"] = factory(require("babylonjs-loaders"), require("babylonjs"));
  8. else
  9. root["SANDBOX"] = factory(root["BABYLON"], root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_loaders_glTF_glTFFileLoader__, __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/dist/cjs.js!./scss/animationBar.scss":
  99. /*!*************************************************************************************************************************************************************!*\
  100. !*** C:/Dev/Babylon/Babylon.js/node_modules/css-loader/dist/cjs.js!C:/Dev/Babylon/Babylon.js/node_modules/sass-loader/dist/cjs.js!./scss/animationBar.scss ***!
  101. \*************************************************************************************************************************************************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports, __webpack_require__) {
  104. // Imports
  105. var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(/*! ../../../node_modules/css-loader/dist/runtime/api.js */ "../../node_modules/css-loader/dist/runtime/api.js");
  106. exports = ___CSS_LOADER_API_IMPORT___(false);
  107. // Module
  108. exports.push([module.i, ".animationBar {\n align-items: center;\n color: white;\n min-height: 30px;\n height: var(--footer-height);\n background-color: var(--footer-background);\n grid-column: 2;\n grid-row: 1;\n margin-left: 10px;\n display: flex;\n /*Chrome -webkit */\n /** FireFox -moz */\n /** IE -ms */ }\n .animationBar * {\n padding: 0px;\n margin: 0px; }\n .animationBar .row {\n display: flex;\n flex-direction: row;\n justify-content: center;\n flex-grow: 10;\n align-items: center; }\n .animationBar #playBtn {\n display: flex;\n align-items: center;\n height: var(--footer-height);\n width: var(--footer-height);\n border: none;\n background-color: inherit;\n cursor: pointer; }\n .animationBar #playBtn img {\n width: var(--footer-height);\n height: var(--footer-height); }\n .animationBar #playBtn:hover {\n background-color: var(--button-hover-color); }\n .animationBar #playBtn:active {\n background-color: var(--button-hover-background); }\n .animationBar #playBtn:focus {\n outline: none !important;\n border: none; }\n .animationBar .slider {\n -webkit-appearance: none;\n cursor: pointer;\n width: 100%;\n max-width: 820px;\n height: var(--footer-height);\n outline: none;\n margin-left: 20px;\n margin-right: 10px;\n background-color: transparent; }\n .animationBar .slider::-webkit-slider-thumb {\n -webkit-appearance: none;\n width: 20px;\n height: 20px;\n border: 2px solid white;\n border-radius: 50%;\n background: var(--footer-background);\n margin-top: -10px; }\n .animationBar .slider::-webkit-slider-runnable-track {\n height: 2px;\n -webkit-appearance: none;\n background-color: white; }\n .animationBar .slider::-moz-range-progress {\n background-color: white;\n height: 2px; }\n .animationBar .slider::-moz-range-thumb {\n width: 20px;\n height: 20px;\n border: 2px solid white;\n border-radius: 50%;\n background: var(--footer-background); }\n .animationBar .slider::-moz-range-track {\n background: white;\n height: 2px; }\n .animationBar .slider::-ms-track {\n height: 2px;\n /*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */\n background: transparent;\n /*leave room for the larger thumb to overflow with a transparent border */\n border-color: transparent;\n border-width: 10px 0;\n /*remove default tick marks*/\n color: transparent; }\n .animationBar .slider::-ms-fill-lower {\n background: white;\n border-radius: 5px; }\n .animationBar .slider::-ms-fill-upper {\n background: white;\n border-radius: 5px; }\n .animationBar .slider::-ms-thumb {\n width: 16px;\n height: 16px;\n border: 2px solid white;\n border-radius: 50%;\n background: var(--footer-background);\n margin-top: 0px; }\n\n@media (max-width: 768px) {\n .animationBar {\n margin-left: 0; } }\n", ""]);
  109. // Exports
  110. module.exports = exports;
  111. /***/ }),
  112. /***/ "../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/dist/cjs.js!./scss/footer.scss":
  113. /*!*******************************************************************************************************************************************************!*\
  114. !*** C:/Dev/Babylon/Babylon.js/node_modules/css-loader/dist/cjs.js!C:/Dev/Babylon/Babylon.js/node_modules/sass-loader/dist/cjs.js!./scss/footer.scss ***!
  115. \*******************************************************************************************************************************************************/
  116. /*! no static exports found */
  117. /***/ (function(module, exports, __webpack_require__) {
  118. // Imports
  119. var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(/*! ../../../node_modules/css-loader/dist/runtime/api.js */ "../../node_modules/css-loader/dist/runtime/api.js");
  120. exports = ___CSS_LOADER_API_IMPORT___(false);
  121. // Module
  122. exports.push([module.i, ".footer {\n position: relative;\n width: 100%;\n height: var(--footer-height);\n margin: 0;\n padding: 0;\n background-color: var(--footer-background);\n font-size: 0;\n display: grid;\n grid-template-rows: 100%;\n grid-template-columns: 201px 1fr 210px; }\n .footer .footerLeft {\n display: grid;\n grid-column: 1;\n grid-row: 1;\n padding-left: 40px;\n align-content: center;\n overflow: hidden; }\n .footer .footerLeft #logoImg {\n height: var(--footer-height);\n width: 161px; }\n .footer .button {\n float: left;\n /* Float links side by side */\n width: var(--footer-height);\n height: var(--footer-height);\n margin: 0px;\n padding: 0;\n transition: all 0.3s ease;\n /* Add transition for hover effects */\n display: grid;\n align-content: center;\n justify-content: center;\n cursor: pointer; }\n .footer .button.long {\n width: 200px;\n grid-template-columns: var(--footer-height) calc(200px - var(--footer-height)); }\n .footer .button.long .button-icon {\n grid-row: 1;\n grid-column: 1; }\n .footer .button.long .button-text {\n grid-row: 1;\n grid-column: 2;\n align-self: center;\n justify-self: left;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--font-size); }\n .footer .button.active {\n background-color: var(--button-hover-color); }\n .footer .button img {\n width: var(--footer-height);\n height: var(--footer-height); }\n .footer .button:hover {\n background-color: var(--button-hover-color); }\n .footer .button:active {\n background-color: var(--button-hover-background); }\n .footer .dropup {\n position: relative; }\n .footer .dropup .dropup-content {\n position: absolute;\n bottom: var(--footer-height);\n left: 0px;\n z-index: 100;\n width: calc(2 * var(--footer-height)); }\n .footer .dropup .dropup-content.long-mode {\n width: 200px; }\n .footer .dropup .dropup-content div {\n background-color: var(--button-hover-color);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--font-size);\n width: 100%;\n color: white;\n cursor: pointer;\n height: 40px;\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n display: grid;\n align-content: center;\n justify-content: center; }\n .footer .dropup .dropup-content div:hover {\n background-color: var(--button-hover-hover);\n transition: all 0.3s ease; }\n .footer .dropup .dropup-content div:active {\n background-color: var(--button-hover-background);\n transition: all 0.3s ease; }\n .footer .footerRight {\n display: flex;\n flex-direction: row-reverse;\n grid-column: 3;\n grid-row: 1; }\n .footer .footerRight .custom-upload {\n position: relative;\n background-position: center right;\n background-repeat: no-repeat;\n width: var(--footer-height);\n height: var(--footer-height);\n cursor: pointer;\n display: grid; }\n .footer .footerRight .custom-upload img {\n grid-row: 1;\n grid-column: 1;\n width: var(--footer-height);\n height: var(--footer-height);\n pointer-events: none; }\n .footer .footerRight .custom-upload:hover {\n background-color: var(--button-hover-color); }\n .footer .footerRight .custom-upload:active {\n background-color: var(--button-hover-background); }\n .footer .footerRight .custom-upload input[type=file] {\n grid-row: 1;\n grid-column: 1;\n outline: none;\n position: relative;\n text-align: right;\n -moz-opacity: 0;\n opacity: 0;\n z-index: 2;\n width: 100%;\n height: 100%;\n filter: alpha(opacity=0); }\n\n@media (max-width: 768px) {\n .footer {\n grid-template-columns: 0px 1fr 150px; }\n .footer .dropup .dropup-content {\n width: 100px; }\n .footer .button.long {\n width: 100px;\n grid-template-columns: var(--footer-height) calc(100px - var(--footer-height)); } }\n", ""]);
  123. // Exports
  124. module.exports = exports;
  125. /***/ }),
  126. /***/ "../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/dist/cjs.js!./scss/main.scss":
  127. /*!*****************************************************************************************************************************************************!*\
  128. !*** C:/Dev/Babylon/Babylon.js/node_modules/css-loader/dist/cjs.js!C:/Dev/Babylon/Babylon.js/node_modules/sass-loader/dist/cjs.js!./scss/main.scss ***!
  129. \*****************************************************************************************************************************************************/
  130. /*! no static exports found */
  131. /***/ (function(module, exports, __webpack_require__) {
  132. // Imports
  133. var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(/*! ../../../node_modules/css-loader/dist/runtime/api.js */ "../../node_modules/css-loader/dist/runtime/api.js");
  134. exports = ___CSS_LOADER_API_IMPORT___(false);
  135. // Module
  136. exports.push([module.i, "html {\n --background: #2A2342;\n --footer-background: #201936;\n --footer-height: 70px;\n --button-hover-color: #BB464B;\n --button-hover-hover: #e0684b;\n --button-hover-background: #162D3A;\n --font-size: 20px; }\n\nhtml, body, #root {\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n overflow: hidden;\n font-size: var(--font-size);\n background: var(--background);\n font-family: \"acumin-pro-condensed\";\n font-weight: normal; }\n\n.hidden {\n display: none !important; }\n\n.clickInterceptor {\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: 99;\n top: 0;\n left: 0; }\n\n#droptext {\n position: absolute;\n text-align: center;\n color: #fff;\n height: 50px;\n width: 100%;\n bottom: 50px; }\n\n#logoContainer {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: calc(100% - 70px);\n pointer-events: none; }\n\n#logo {\n position: absolute;\n width: 20%;\n height: 20%;\n top: 40%;\n left: 40%;\n pointer-events: none; }\n\n#errorZone {\n position: absolute;\n width: 50%;\n left: 25%;\n bottom: 80px;\n background-color: #C73228;\n padding: 20px;\n border-radius: 5px;\n color: white;\n display: grid;\n grid-template-columns: 1fr 32px; }\n #errorZone .message {\n grid-column: 1;\n grid-row: 1;\n align-self: center; }\n #errorZone button {\n grid-column: 2;\n grid-row: 1;\n padding: 0;\n cursor: pointer;\n background: transparent;\n border: 0;\n -webkit-appearance: none;\n color: #000;\n text-shadow: 0 1px 0 #fff;\n opacity: .4;\n font-size: 1.8em; }\n #errorZone button:hover {\n transform: scale(1.2); }\n\n@media (max-width: 768px) {\n html {\n --footer-height: 50px;\n --font-size: 16px; } }\n", ""]);
  137. // Exports
  138. module.exports = exports;
  139. /***/ }),
  140. /***/ "../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/dist/cjs.js!./scss/renderingZone.scss":
  141. /*!**************************************************************************************************************************************************************!*\
  142. !*** C:/Dev/Babylon/Babylon.js/node_modules/css-loader/dist/cjs.js!C:/Dev/Babylon/Babylon.js/node_modules/sass-loader/dist/cjs.js!./scss/renderingZone.scss ***!
  143. \**************************************************************************************************************************************************************/
  144. /*! no static exports found */
  145. /***/ (function(module, exports, __webpack_require__) {
  146. // Imports
  147. var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(/*! ../../../node_modules/css-loader/dist/runtime/api.js */ "../../node_modules/css-loader/dist/runtime/api.js");
  148. exports = ___CSS_LOADER_API_IMPORT___(false);
  149. // Module
  150. exports.push([module.i, "#canvasZone {\n display: block;\n padding: 0;\n margin: 0;\n overflow: hidden;\n width: 100%;\n height: calc(100% - var(--footer-height)); }\n #canvasZone.expanded {\n height: 100%; }\n\n#renderCanvas {\n position: relative;\n overflow: hidden;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n touch-action: none;\n -ms-touch-action: none;\n display: block;\n border: 0;\n outline: 0; }\n", ""]);
  151. // Exports
  152. module.exports = exports;
  153. /***/ }),
  154. /***/ "../../node_modules/css-loader/dist/runtime/api.js":
  155. /*!*****************************************************************************!*\
  156. !*** C:/Dev/Babylon/Babylon.js/node_modules/css-loader/dist/runtime/api.js ***!
  157. \*****************************************************************************/
  158. /*! no static exports found */
  159. /***/ (function(module, exports, __webpack_require__) {
  160. "use strict";
  161. /*
  162. MIT License http://www.opensource.org/licenses/mit-license.php
  163. Author Tobias Koppers @sokra
  164. */
  165. // css base code, injected by the css-loader
  166. // eslint-disable-next-line func-names
  167. module.exports = function (useSourceMap) {
  168. var list = []; // return the list of modules as css string
  169. list.toString = function toString() {
  170. return this.map(function (item) {
  171. var content = cssWithMappingToString(item, useSourceMap);
  172. if (item[2]) {
  173. return "@media ".concat(item[2], " {").concat(content, "}");
  174. }
  175. return content;
  176. }).join('');
  177. }; // import a list of modules into the list
  178. // eslint-disable-next-line func-names
  179. list.i = function (modules, mediaQuery, dedupe) {
  180. if (typeof modules === 'string') {
  181. // eslint-disable-next-line no-param-reassign
  182. modules = [[null, modules, '']];
  183. }
  184. var alreadyImportedModules = {};
  185. if (dedupe) {
  186. for (var i = 0; i < this.length; i++) {
  187. // eslint-disable-next-line prefer-destructuring
  188. var id = this[i][0];
  189. if (id != null) {
  190. alreadyImportedModules[id] = true;
  191. }
  192. }
  193. }
  194. for (var _i = 0; _i < modules.length; _i++) {
  195. var item = [].concat(modules[_i]);
  196. if (dedupe && alreadyImportedModules[item[0]]) {
  197. // eslint-disable-next-line no-continue
  198. continue;
  199. }
  200. if (mediaQuery) {
  201. if (!item[2]) {
  202. item[2] = mediaQuery;
  203. } else {
  204. item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
  205. }
  206. }
  207. list.push(item);
  208. }
  209. };
  210. return list;
  211. };
  212. function cssWithMappingToString(item, useSourceMap) {
  213. var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring
  214. var cssMapping = item[3];
  215. if (!cssMapping) {
  216. return content;
  217. }
  218. if (useSourceMap && typeof btoa === 'function') {
  219. var sourceMapping = toComment(cssMapping);
  220. var sourceURLs = cssMapping.sources.map(function (source) {
  221. return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */");
  222. });
  223. return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
  224. }
  225. return [content].join('\n');
  226. } // Adapted from convert-source-map (MIT)
  227. function toComment(sourceMap) {
  228. // eslint-disable-next-line no-undef
  229. var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
  230. var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
  231. return "/*# ".concat(data, " */");
  232. }
  233. /***/ }),
  234. /***/ "../../node_modules/object-assign/index.js":
  235. /*!*********************************************************************!*\
  236. !*** C:/Dev/Babylon/Babylon.js/node_modules/object-assign/index.js ***!
  237. \*********************************************************************/
  238. /*! no static exports found */
  239. /***/ (function(module, exports, __webpack_require__) {
  240. "use strict";
  241. /*
  242. object-assign
  243. (c) Sindre Sorhus
  244. @license MIT
  245. */
  246. /* eslint-disable no-unused-vars */
  247. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  248. var hasOwnProperty = Object.prototype.hasOwnProperty;
  249. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  250. function toObject(val) {
  251. if (val === null || val === undefined) {
  252. throw new TypeError('Object.assign cannot be called with null or undefined');
  253. }
  254. return Object(val);
  255. }
  256. function shouldUseNative() {
  257. try {
  258. if (!Object.assign) {
  259. return false;
  260. }
  261. // Detect buggy property enumeration order in older V8 versions.
  262. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  263. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  264. test1[5] = 'de';
  265. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  266. return false;
  267. }
  268. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  269. var test2 = {};
  270. for (var i = 0; i < 10; i++) {
  271. test2['_' + String.fromCharCode(i)] = i;
  272. }
  273. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  274. return test2[n];
  275. });
  276. if (order2.join('') !== '0123456789') {
  277. return false;
  278. }
  279. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  280. var test3 = {};
  281. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  282. test3[letter] = letter;
  283. });
  284. if (Object.keys(Object.assign({}, test3)).join('') !==
  285. 'abcdefghijklmnopqrst') {
  286. return false;
  287. }
  288. return true;
  289. } catch (err) {
  290. // We don't expect any of the above to throw, but better to be safe.
  291. return false;
  292. }
  293. }
  294. module.exports = shouldUseNative() ? Object.assign : function (target, source) {
  295. var from;
  296. var to = toObject(target);
  297. var symbols;
  298. for (var s = 1; s < arguments.length; s++) {
  299. from = Object(arguments[s]);
  300. for (var key in from) {
  301. if (hasOwnProperty.call(from, key)) {
  302. to[key] = from[key];
  303. }
  304. }
  305. if (getOwnPropertySymbols) {
  306. symbols = getOwnPropertySymbols(from);
  307. for (var i = 0; i < symbols.length; i++) {
  308. if (propIsEnumerable.call(from, symbols[i])) {
  309. to[symbols[i]] = from[symbols[i]];
  310. }
  311. }
  312. }
  313. }
  314. return to;
  315. };
  316. /***/ }),
  317. /***/ "../../node_modules/prop-types/checkPropTypes.js":
  318. /*!***************************************************************************!*\
  319. !*** C:/Dev/Babylon/Babylon.js/node_modules/prop-types/checkPropTypes.js ***!
  320. \***************************************************************************/
  321. /*! no static exports found */
  322. /***/ (function(module, exports, __webpack_require__) {
  323. "use strict";
  324. /**
  325. * Copyright (c) 2013-present, Facebook, Inc.
  326. *
  327. * This source code is licensed under the MIT license found in the
  328. * LICENSE file in the root directory of this source tree.
  329. */
  330. var printWarning = function() {};
  331. if (true) {
  332. var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js");
  333. var loggedTypeFailures = {};
  334. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  335. printWarning = function(text) {
  336. var message = 'Warning: ' + text;
  337. if (typeof console !== 'undefined') {
  338. console.error(message);
  339. }
  340. try {
  341. // --- Welcome to debugging React ---
  342. // This error was thrown as a convenience so that you can use this stack
  343. // to find the callsite that caused this warning to fire.
  344. throw new Error(message);
  345. } catch (x) {}
  346. };
  347. }
  348. /**
  349. * Assert that the values match with the type specs.
  350. * Error messages are memorized and will only be shown once.
  351. *
  352. * @param {object} typeSpecs Map of name to a ReactPropType
  353. * @param {object} values Runtime values that need to be type-checked
  354. * @param {string} location e.g. "prop", "context", "child context"
  355. * @param {string} componentName Name of the component for error messages.
  356. * @param {?Function} getStack Returns the component stack.
  357. * @private
  358. */
  359. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  360. if (true) {
  361. for (var typeSpecName in typeSpecs) {
  362. if (has(typeSpecs, typeSpecName)) {
  363. var error;
  364. // Prop type validation may throw. In case they do, we don't want to
  365. // fail the render phase where it didn't fail before. So we log it.
  366. // After these have been cleaned up, we'll let them throw.
  367. try {
  368. // This is intentionally an invariant that gets caught. It's the same
  369. // behavior as without this statement except with a better message.
  370. if (typeof typeSpecs[typeSpecName] !== 'function') {
  371. var err = Error(
  372. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  373. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  374. );
  375. err.name = 'Invariant Violation';
  376. throw err;
  377. }
  378. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
  379. } catch (ex) {
  380. error = ex;
  381. }
  382. if (error && !(error instanceof Error)) {
  383. printWarning(
  384. (componentName || 'React class') + ': type specification of ' +
  385. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  386. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  387. 'You may have forgotten to pass an argument to the type checker ' +
  388. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  389. 'shape all require an argument).'
  390. );
  391. }
  392. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  393. // Only monitor this failure once because there tends to be a lot of the
  394. // same error.
  395. loggedTypeFailures[error.message] = true;
  396. var stack = getStack ? getStack() : '';
  397. printWarning(
  398. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  399. );
  400. }
  401. }
  402. }
  403. }
  404. }
  405. /**
  406. * Resets warning cache when testing.
  407. *
  408. * @private
  409. */
  410. checkPropTypes.resetWarningCache = function() {
  411. if (true) {
  412. loggedTypeFailures = {};
  413. }
  414. }
  415. module.exports = checkPropTypes;
  416. /***/ }),
  417. /***/ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js":
  418. /*!*************************************************************************************!*\
  419. !*** C:/Dev/Babylon/Babylon.js/node_modules/prop-types/lib/ReactPropTypesSecret.js ***!
  420. \*************************************************************************************/
  421. /*! no static exports found */
  422. /***/ (function(module, exports, __webpack_require__) {
  423. "use strict";
  424. /**
  425. * Copyright (c) 2013-present, Facebook, Inc.
  426. *
  427. * This source code is licensed under the MIT license found in the
  428. * LICENSE file in the root directory of this source tree.
  429. */
  430. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  431. module.exports = ReactPropTypesSecret;
  432. /***/ }),
  433. /***/ "../../node_modules/react-dom/cjs/react-dom.development.js":
  434. /*!*************************************************************************************!*\
  435. !*** C:/Dev/Babylon/Babylon.js/node_modules/react-dom/cjs/react-dom.development.js ***!
  436. \*************************************************************************************/
  437. /*! no static exports found */
  438. /***/ (function(module, exports, __webpack_require__) {
  439. "use strict";
  440. /** @license React v16.13.1
  441. * react-dom.development.js
  442. *
  443. * Copyright (c) Facebook, Inc. and its affiliates.
  444. *
  445. * This source code is licensed under the MIT license found in the
  446. * LICENSE file in the root directory of this source tree.
  447. */
  448. if (true) {
  449. (function() {
  450. 'use strict';
  451. var React = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  452. var _assign = __webpack_require__(/*! object-assign */ "../../node_modules/object-assign/index.js");
  453. var Scheduler = __webpack_require__(/*! scheduler */ "../../node_modules/scheduler/index.js");
  454. var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "../../node_modules/prop-types/checkPropTypes.js");
  455. var tracing = __webpack_require__(/*! scheduler/tracing */ "../../node_modules/scheduler/tracing.js");
  456. var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions.
  457. // Current owner and dispatcher used to share the same ref,
  458. // but PR #14548 split them out to better support the react-debug-tools package.
  459. if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
  460. ReactSharedInternals.ReactCurrentDispatcher = {
  461. current: null
  462. };
  463. }
  464. if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
  465. ReactSharedInternals.ReactCurrentBatchConfig = {
  466. suspense: null
  467. };
  468. }
  469. // by calls to these methods by a Babel plugin.
  470. //
  471. // In PROD (or in packages without access to React internals),
  472. // they are left as they are instead.
  473. function warn(format) {
  474. {
  475. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  476. args[_key - 1] = arguments[_key];
  477. }
  478. printWarning('warn', format, args);
  479. }
  480. }
  481. function error(format) {
  482. {
  483. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  484. args[_key2 - 1] = arguments[_key2];
  485. }
  486. printWarning('error', format, args);
  487. }
  488. }
  489. function printWarning(level, format, args) {
  490. // When changing this logic, you might want to also
  491. // update consoleWithStackDev.www.js as well.
  492. {
  493. var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0;
  494. if (!hasExistingStack) {
  495. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  496. var stack = ReactDebugCurrentFrame.getStackAddendum();
  497. if (stack !== '') {
  498. format += '%s';
  499. args = args.concat([stack]);
  500. }
  501. }
  502. var argsWithFormat = args.map(function (item) {
  503. return '' + item;
  504. }); // Careful: RN currently depends on this prefix
  505. argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
  506. // breaks IE9: https://github.com/facebook/react/issues/13610
  507. // eslint-disable-next-line react-internal/no-production-logging
  508. Function.prototype.apply.call(console[level], console, argsWithFormat);
  509. try {
  510. // --- Welcome to debugging React ---
  511. // This error was thrown as a convenience so that you can use this stack
  512. // to find the callsite that caused this warning to fire.
  513. var argIndex = 0;
  514. var message = 'Warning: ' + format.replace(/%s/g, function () {
  515. return args[argIndex++];
  516. });
  517. throw new Error(message);
  518. } catch (x) {}
  519. }
  520. }
  521. if (!React) {
  522. {
  523. throw Error( "ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM." );
  524. }
  525. }
  526. var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
  527. var funcArgs = Array.prototype.slice.call(arguments, 3);
  528. try {
  529. func.apply(context, funcArgs);
  530. } catch (error) {
  531. this.onError(error);
  532. }
  533. };
  534. {
  535. // In DEV mode, we swap out invokeGuardedCallback for a special version
  536. // that plays more nicely with the browser's DevTools. The idea is to preserve
  537. // "Pause on exceptions" behavior. Because React wraps all user-provided
  538. // functions in invokeGuardedCallback, and the production version of
  539. // invokeGuardedCallback uses a try-catch, all user exceptions are treated
  540. // like caught exceptions, and the DevTools won't pause unless the developer
  541. // takes the extra step of enabling pause on caught exceptions. This is
  542. // unintuitive, though, because even though React has caught the error, from
  543. // the developer's perspective, the error is uncaught.
  544. //
  545. // To preserve the expected "Pause on exceptions" behavior, we don't use a
  546. // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
  547. // DOM node, and call the user-provided callback from inside an event handler
  548. // for that fake event. If the callback throws, the error is "captured" using
  549. // a global event handler. But because the error happens in a different
  550. // event loop context, it does not interrupt the normal program flow.
  551. // Effectively, this gives us try-catch behavior without actually using
  552. // try-catch. Neat!
  553. // Check that the browser supports the APIs we need to implement our special
  554. // DEV version of invokeGuardedCallback
  555. if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
  556. var fakeNode = document.createElement('react');
  557. var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
  558. // If document doesn't exist we know for sure we will crash in this method
  559. // when we call document.createEvent(). However this can cause confusing
  560. // errors: https://github.com/facebookincubator/create-react-app/issues/3482
  561. // So we preemptively throw with a better message instead.
  562. if (!(typeof document !== 'undefined')) {
  563. {
  564. throw Error( "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous." );
  565. }
  566. }
  567. var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We
  568. // set this to true at the beginning, then set it to false right after
  569. // calling the function. If the function errors, `didError` will never be
  570. // set to false. This strategy works even if the browser is flaky and
  571. // fails to call our global error handler, because it doesn't rely on
  572. // the error event at all.
  573. var didError = true; // Keeps track of the value of window.event so that we can reset it
  574. // during the callback to let user code access window.event in the
  575. // browsers that support it.
  576. var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event
  577. // dispatching: https://github.com/facebook/react/issues/13688
  578. var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously
  579. // dispatch our fake event using `dispatchEvent`. Inside the handler, we
  580. // call the user-provided callback.
  581. var funcArgs = Array.prototype.slice.call(arguments, 3);
  582. function callCallback() {
  583. // We immediately remove the callback from event listeners so that
  584. // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
  585. // nested call would trigger the fake event handlers of any call higher
  586. // in the stack.
  587. fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the
  588. // window.event assignment in both IE <= 10 as they throw an error
  589. // "Member not found" in strict mode, and in Firefox which does not
  590. // support window.event.
  591. if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
  592. window.event = windowEvent;
  593. }
  594. func.apply(context, funcArgs);
  595. didError = false;
  596. } // Create a global error event handler. We use this to capture the value
  597. // that was thrown. It's possible that this error handler will fire more
  598. // than once; for example, if non-React code also calls `dispatchEvent`
  599. // and a handler for that event throws. We should be resilient to most of
  600. // those cases. Even if our error event handler fires more than once, the
  601. // last error event is always used. If the callback actually does error,
  602. // we know that the last error event is the correct one, because it's not
  603. // possible for anything else to have happened in between our callback
  604. // erroring and the code that follows the `dispatchEvent` call below. If
  605. // the callback doesn't error, but the error event was fired, we know to
  606. // ignore it because `didError` will be false, as described above.
  607. var error; // Use this to track whether the error event is ever called.
  608. var didSetError = false;
  609. var isCrossOriginError = false;
  610. function handleWindowError(event) {
  611. error = event.error;
  612. didSetError = true;
  613. if (error === null && event.colno === 0 && event.lineno === 0) {
  614. isCrossOriginError = true;
  615. }
  616. if (event.defaultPrevented) {
  617. // Some other error handler has prevented default.
  618. // Browsers silence the error report if this happens.
  619. // We'll remember this to later decide whether to log it or not.
  620. if (error != null && typeof error === 'object') {
  621. try {
  622. error._suppressLogging = true;
  623. } catch (inner) {// Ignore.
  624. }
  625. }
  626. }
  627. } // Create a fake event type.
  628. var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers
  629. window.addEventListener('error', handleWindowError);
  630. fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function
  631. // errors, it will trigger our global error handler.
  632. evt.initEvent(evtType, false, false);
  633. fakeNode.dispatchEvent(evt);
  634. if (windowEventDescriptor) {
  635. Object.defineProperty(window, 'event', windowEventDescriptor);
  636. }
  637. if (didError) {
  638. if (!didSetError) {
  639. // The callback errored, but the error event never fired.
  640. error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.');
  641. } else if (isCrossOriginError) {
  642. error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.');
  643. }
  644. this.onError(error);
  645. } // Remove our event listeners
  646. window.removeEventListener('error', handleWindowError);
  647. };
  648. invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
  649. }
  650. }
  651. var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
  652. var hasError = false;
  653. var caughtError = null; // Used by event system to capture/rethrow the first error.
  654. var hasRethrowError = false;
  655. var rethrowError = null;
  656. var reporter = {
  657. onError: function (error) {
  658. hasError = true;
  659. caughtError = error;
  660. }
  661. };
  662. /**
  663. * Call a function while guarding against errors that happens within it.
  664. * Returns an error if it throws, otherwise null.
  665. *
  666. * In production, this is implemented using a try-catch. The reason we don't
  667. * use a try-catch directly is so that we can swap out a different
  668. * implementation in DEV mode.
  669. *
  670. * @param {String} name of the guard to use for logging or debugging
  671. * @param {Function} func The function to invoke
  672. * @param {*} context The context to use when calling the function
  673. * @param {...*} args Arguments for function
  674. */
  675. function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
  676. hasError = false;
  677. caughtError = null;
  678. invokeGuardedCallbackImpl$1.apply(reporter, arguments);
  679. }
  680. /**
  681. * Same as invokeGuardedCallback, but instead of returning an error, it stores
  682. * it in a global so it can be rethrown by `rethrowCaughtError` later.
  683. * TODO: See if caughtError and rethrowError can be unified.
  684. *
  685. * @param {String} name of the guard to use for logging or debugging
  686. * @param {Function} func The function to invoke
  687. * @param {*} context The context to use when calling the function
  688. * @param {...*} args Arguments for function
  689. */
  690. function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) {
  691. invokeGuardedCallback.apply(this, arguments);
  692. if (hasError) {
  693. var error = clearCaughtError();
  694. if (!hasRethrowError) {
  695. hasRethrowError = true;
  696. rethrowError = error;
  697. }
  698. }
  699. }
  700. /**
  701. * During execution of guarded functions we will capture the first error which
  702. * we will rethrow to be handled by the top level error handler.
  703. */
  704. function rethrowCaughtError() {
  705. if (hasRethrowError) {
  706. var error = rethrowError;
  707. hasRethrowError = false;
  708. rethrowError = null;
  709. throw error;
  710. }
  711. }
  712. function hasCaughtError() {
  713. return hasError;
  714. }
  715. function clearCaughtError() {
  716. if (hasError) {
  717. var error = caughtError;
  718. hasError = false;
  719. caughtError = null;
  720. return error;
  721. } else {
  722. {
  723. {
  724. throw Error( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." );
  725. }
  726. }
  727. }
  728. }
  729. var getFiberCurrentPropsFromNode = null;
  730. var getInstanceFromNode = null;
  731. var getNodeFromInstance = null;
  732. function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) {
  733. getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl;
  734. getInstanceFromNode = getInstanceFromNodeImpl;
  735. getNodeFromInstance = getNodeFromInstanceImpl;
  736. {
  737. if (!getNodeFromInstance || !getInstanceFromNode) {
  738. error('EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.');
  739. }
  740. }
  741. }
  742. var validateEventDispatches;
  743. {
  744. validateEventDispatches = function (event) {
  745. var dispatchListeners = event._dispatchListeners;
  746. var dispatchInstances = event._dispatchInstances;
  747. var listenersIsArr = Array.isArray(dispatchListeners);
  748. var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
  749. var instancesIsArr = Array.isArray(dispatchInstances);
  750. var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
  751. if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) {
  752. error('EventPluginUtils: Invalid `event`.');
  753. }
  754. };
  755. }
  756. /**
  757. * Dispatch the event to the listener.
  758. * @param {SyntheticEvent} event SyntheticEvent to handle
  759. * @param {function} listener Application-level callback
  760. * @param {*} inst Internal component instance
  761. */
  762. function executeDispatch(event, listener, inst) {
  763. var type = event.type || 'unknown-event';
  764. event.currentTarget = getNodeFromInstance(inst);
  765. invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
  766. event.currentTarget = null;
  767. }
  768. /**
  769. * Standard/simple iteration through an event's collected dispatches.
  770. */
  771. function executeDispatchesInOrder(event) {
  772. var dispatchListeners = event._dispatchListeners;
  773. var dispatchInstances = event._dispatchInstances;
  774. {
  775. validateEventDispatches(event);
  776. }
  777. if (Array.isArray(dispatchListeners)) {
  778. for (var i = 0; i < dispatchListeners.length; i++) {
  779. if (event.isPropagationStopped()) {
  780. break;
  781. } // Listeners and Instances are two parallel arrays that are always in sync.
  782. executeDispatch(event, dispatchListeners[i], dispatchInstances[i]);
  783. }
  784. } else if (dispatchListeners) {
  785. executeDispatch(event, dispatchListeners, dispatchInstances);
  786. }
  787. event._dispatchListeners = null;
  788. event._dispatchInstances = null;
  789. }
  790. var FunctionComponent = 0;
  791. var ClassComponent = 1;
  792. var IndeterminateComponent = 2; // Before we know whether it is function or class
  793. var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
  794. var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
  795. var HostComponent = 5;
  796. var HostText = 6;
  797. var Fragment = 7;
  798. var Mode = 8;
  799. var ContextConsumer = 9;
  800. var ContextProvider = 10;
  801. var ForwardRef = 11;
  802. var Profiler = 12;
  803. var SuspenseComponent = 13;
  804. var MemoComponent = 14;
  805. var SimpleMemoComponent = 15;
  806. var LazyComponent = 16;
  807. var IncompleteClassComponent = 17;
  808. var DehydratedFragment = 18;
  809. var SuspenseListComponent = 19;
  810. var FundamentalComponent = 20;
  811. var ScopeComponent = 21;
  812. var Block = 22;
  813. /**
  814. * Injectable ordering of event plugins.
  815. */
  816. var eventPluginOrder = null;
  817. /**
  818. * Injectable mapping from names to event plugin modules.
  819. */
  820. var namesToPlugins = {};
  821. /**
  822. * Recomputes the plugin list using the injected plugins and plugin ordering.
  823. *
  824. * @private
  825. */
  826. function recomputePluginOrdering() {
  827. if (!eventPluginOrder) {
  828. // Wait until an `eventPluginOrder` is injected.
  829. return;
  830. }
  831. for (var pluginName in namesToPlugins) {
  832. var pluginModule = namesToPlugins[pluginName];
  833. var pluginIndex = eventPluginOrder.indexOf(pluginName);
  834. if (!(pluginIndex > -1)) {
  835. {
  836. throw Error( "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + pluginName + "`." );
  837. }
  838. }
  839. if (plugins[pluginIndex]) {
  840. continue;
  841. }
  842. if (!pluginModule.extractEvents) {
  843. {
  844. throw Error( "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not." );
  845. }
  846. }
  847. plugins[pluginIndex] = pluginModule;
  848. var publishedEvents = pluginModule.eventTypes;
  849. for (var eventName in publishedEvents) {
  850. if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) {
  851. {
  852. throw Error( "EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + pluginName + "`." );
  853. }
  854. }
  855. }
  856. }
  857. }
  858. /**
  859. * Publishes an event so that it can be dispatched by the supplied plugin.
  860. *
  861. * @param {object} dispatchConfig Dispatch configuration for the event.
  862. * @param {object} PluginModule Plugin publishing the event.
  863. * @return {boolean} True if the event was successfully published.
  864. * @private
  865. */
  866. function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
  867. if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) {
  868. {
  869. throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + eventName + "`." );
  870. }
  871. }
  872. eventNameDispatchConfigs[eventName] = dispatchConfig;
  873. var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
  874. if (phasedRegistrationNames) {
  875. for (var phaseName in phasedRegistrationNames) {
  876. if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
  877. var phasedRegistrationName = phasedRegistrationNames[phaseName];
  878. publishRegistrationName(phasedRegistrationName, pluginModule, eventName);
  879. }
  880. }
  881. return true;
  882. } else if (dispatchConfig.registrationName) {
  883. publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName);
  884. return true;
  885. }
  886. return false;
  887. }
  888. /**
  889. * Publishes a registration name that is used to identify dispatched events.
  890. *
  891. * @param {string} registrationName Registration name to add.
  892. * @param {object} PluginModule Plugin publishing the event.
  893. * @private
  894. */
  895. function publishRegistrationName(registrationName, pluginModule, eventName) {
  896. if (!!registrationNameModules[registrationName]) {
  897. {
  898. throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + registrationName + "`." );
  899. }
  900. }
  901. registrationNameModules[registrationName] = pluginModule;
  902. registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
  903. {
  904. var lowerCasedName = registrationName.toLowerCase();
  905. possibleRegistrationNames[lowerCasedName] = registrationName;
  906. if (registrationName === 'onDoubleClick') {
  907. possibleRegistrationNames.ondblclick = registrationName;
  908. }
  909. }
  910. }
  911. /**
  912. * Registers plugins so that they can extract and dispatch events.
  913. */
  914. /**
  915. * Ordered list of injected plugins.
  916. */
  917. var plugins = [];
  918. /**
  919. * Mapping from event name to dispatch config
  920. */
  921. var eventNameDispatchConfigs = {};
  922. /**
  923. * Mapping from registration name to plugin module
  924. */
  925. var registrationNameModules = {};
  926. /**
  927. * Mapping from registration name to event name
  928. */
  929. var registrationNameDependencies = {};
  930. /**
  931. * Mapping from lowercase registration names to the properly cased version,
  932. * used to warn in the case of missing event handlers. Available
  933. * only in true.
  934. * @type {Object}
  935. */
  936. var possibleRegistrationNames = {} ; // Trust the developer to only use possibleRegistrationNames in true
  937. /**
  938. * Injects an ordering of plugins (by plugin name). This allows the ordering
  939. * to be decoupled from injection of the actual plugins so that ordering is
  940. * always deterministic regardless of packaging, on-the-fly injection, etc.
  941. *
  942. * @param {array} InjectedEventPluginOrder
  943. * @internal
  944. */
  945. function injectEventPluginOrder(injectedEventPluginOrder) {
  946. if (!!eventPluginOrder) {
  947. {
  948. throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." );
  949. }
  950. } // Clone the ordering so it cannot be dynamically mutated.
  951. eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
  952. recomputePluginOrdering();
  953. }
  954. /**
  955. * Injects plugins to be used by plugin event system. The plugin names must be
  956. * in the ordering injected by `injectEventPluginOrder`.
  957. *
  958. * Plugins can be injected as part of page initialization or on-the-fly.
  959. *
  960. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  961. * @internal
  962. */
  963. function injectEventPluginsByName(injectedNamesToPlugins) {
  964. var isOrderingDirty = false;
  965. for (var pluginName in injectedNamesToPlugins) {
  966. if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
  967. continue;
  968. }
  969. var pluginModule = injectedNamesToPlugins[pluginName];
  970. if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) {
  971. if (!!namesToPlugins[pluginName]) {
  972. {
  973. throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + pluginName + "`." );
  974. }
  975. }
  976. namesToPlugins[pluginName] = pluginModule;
  977. isOrderingDirty = true;
  978. }
  979. }
  980. if (isOrderingDirty) {
  981. recomputePluginOrdering();
  982. }
  983. }
  984. var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
  985. var PLUGIN_EVENT_SYSTEM = 1;
  986. var IS_REPLAYED = 1 << 5;
  987. var IS_FIRST_ANCESTOR = 1 << 6;
  988. var restoreImpl = null;
  989. var restoreTarget = null;
  990. var restoreQueue = null;
  991. function restoreStateOfTarget(target) {
  992. // We perform this translation at the end of the event loop so that we
  993. // always receive the correct fiber here
  994. var internalInstance = getInstanceFromNode(target);
  995. if (!internalInstance) {
  996. // Unmounted
  997. return;
  998. }
  999. if (!(typeof restoreImpl === 'function')) {
  1000. {
  1001. throw Error( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." );
  1002. }
  1003. }
  1004. var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted.
  1005. if (stateNode) {
  1006. var _props = getFiberCurrentPropsFromNode(stateNode);
  1007. restoreImpl(internalInstance.stateNode, internalInstance.type, _props);
  1008. }
  1009. }
  1010. function setRestoreImplementation(impl) {
  1011. restoreImpl = impl;
  1012. }
  1013. function enqueueStateRestore(target) {
  1014. if (restoreTarget) {
  1015. if (restoreQueue) {
  1016. restoreQueue.push(target);
  1017. } else {
  1018. restoreQueue = [target];
  1019. }
  1020. } else {
  1021. restoreTarget = target;
  1022. }
  1023. }
  1024. function needsStateRestore() {
  1025. return restoreTarget !== null || restoreQueue !== null;
  1026. }
  1027. function restoreStateIfNeeded() {
  1028. if (!restoreTarget) {
  1029. return;
  1030. }
  1031. var target = restoreTarget;
  1032. var queuedTargets = restoreQueue;
  1033. restoreTarget = null;
  1034. restoreQueue = null;
  1035. restoreStateOfTarget(target);
  1036. if (queuedTargets) {
  1037. for (var i = 0; i < queuedTargets.length; i++) {
  1038. restoreStateOfTarget(queuedTargets[i]);
  1039. }
  1040. }
  1041. }
  1042. var enableProfilerTimer = true; // Trace which interactions trigger each commit.
  1043. var enableDeprecatedFlareAPI = false; // Experimental Host Component support.
  1044. var enableFundamentalAPI = false; // Experimental Scope support.
  1045. var warnAboutStringRefs = false;
  1046. // the renderer. Such as when we're dispatching events or if third party
  1047. // libraries need to call batchedUpdates. Eventually, this API will go away when
  1048. // everything is batched by default. We'll then have a similar API to opt-out of
  1049. // scheduled work and instead do synchronous work.
  1050. // Defaults
  1051. var batchedUpdatesImpl = function (fn, bookkeeping) {
  1052. return fn(bookkeeping);
  1053. };
  1054. var discreteUpdatesImpl = function (fn, a, b, c, d) {
  1055. return fn(a, b, c, d);
  1056. };
  1057. var flushDiscreteUpdatesImpl = function () {};
  1058. var batchedEventUpdatesImpl = batchedUpdatesImpl;
  1059. var isInsideEventHandler = false;
  1060. var isBatchingEventUpdates = false;
  1061. function finishEventHandler() {
  1062. // Here we wait until all updates have propagated, which is important
  1063. // when using controlled components within layers:
  1064. // https://github.com/facebook/react/issues/1698
  1065. // Then we restore state of any controlled component.
  1066. var controlledComponentsHavePendingUpdates = needsStateRestore();
  1067. if (controlledComponentsHavePendingUpdates) {
  1068. // If a controlled event was fired, we may need to restore the state of
  1069. // the DOM node back to the controlled value. This is necessary when React
  1070. // bails out of the update without touching the DOM.
  1071. flushDiscreteUpdatesImpl();
  1072. restoreStateIfNeeded();
  1073. }
  1074. }
  1075. function batchedUpdates(fn, bookkeeping) {
  1076. if (isInsideEventHandler) {
  1077. // If we are currently inside another batch, we need to wait until it
  1078. // fully completes before restoring state.
  1079. return fn(bookkeeping);
  1080. }
  1081. isInsideEventHandler = true;
  1082. try {
  1083. return batchedUpdatesImpl(fn, bookkeeping);
  1084. } finally {
  1085. isInsideEventHandler = false;
  1086. finishEventHandler();
  1087. }
  1088. }
  1089. function batchedEventUpdates(fn, a, b) {
  1090. if (isBatchingEventUpdates) {
  1091. // If we are currently inside another batch, we need to wait until it
  1092. // fully completes before restoring state.
  1093. return fn(a, b);
  1094. }
  1095. isBatchingEventUpdates = true;
  1096. try {
  1097. return batchedEventUpdatesImpl(fn, a, b);
  1098. } finally {
  1099. isBatchingEventUpdates = false;
  1100. finishEventHandler();
  1101. }
  1102. } // This is for the React Flare event system
  1103. function discreteUpdates(fn, a, b, c, d) {
  1104. var prevIsInsideEventHandler = isInsideEventHandler;
  1105. isInsideEventHandler = true;
  1106. try {
  1107. return discreteUpdatesImpl(fn, a, b, c, d);
  1108. } finally {
  1109. isInsideEventHandler = prevIsInsideEventHandler;
  1110. if (!isInsideEventHandler) {
  1111. finishEventHandler();
  1112. }
  1113. }
  1114. }
  1115. function flushDiscreteUpdatesIfNeeded(timeStamp) {
  1116. // event.timeStamp isn't overly reliable due to inconsistencies in
  1117. // how different browsers have historically provided the time stamp.
  1118. // Some browsers provide high-resolution time stamps for all events,
  1119. // some provide low-resolution time stamps for all events. FF < 52
  1120. // even mixes both time stamps together. Some browsers even report
  1121. // negative time stamps or time stamps that are 0 (iOS9) in some cases.
  1122. // Given we are only comparing two time stamps with equality (!==),
  1123. // we are safe from the resolution differences. If the time stamp is 0
  1124. // we bail-out of preventing the flush, which can affect semantics,
  1125. // such as if an earlier flush removes or adds event listeners that
  1126. // are fired in the subsequent flush. However, this is the same
  1127. // behaviour as we had before this change, so the risks are low.
  1128. if (!isInsideEventHandler && (!enableDeprecatedFlareAPI )) {
  1129. flushDiscreteUpdatesImpl();
  1130. }
  1131. }
  1132. function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) {
  1133. batchedUpdatesImpl = _batchedUpdatesImpl;
  1134. discreteUpdatesImpl = _discreteUpdatesImpl;
  1135. flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl;
  1136. batchedEventUpdatesImpl = _batchedEventUpdatesImpl;
  1137. }
  1138. var DiscreteEvent = 0;
  1139. var UserBlockingEvent = 1;
  1140. var ContinuousEvent = 2;
  1141. // A reserved attribute.
  1142. // It is handled by React separately and shouldn't be written to the DOM.
  1143. var RESERVED = 0; // A simple string attribute.
  1144. // Attributes that aren't in the whitelist are presumed to have this type.
  1145. var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called
  1146. // "enumerated" attributes with "true" and "false" as possible values.
  1147. // When true, it should be set to a "true" string.
  1148. // When false, it should be set to a "false" string.
  1149. var BOOLEANISH_STRING = 2; // A real boolean attribute.
  1150. // When true, it should be present (set either to an empty string or its name).
  1151. // When false, it should be omitted.
  1152. var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value.
  1153. // When true, it should be present (set either to an empty string or its name).
  1154. // When false, it should be omitted.
  1155. // For any other value, should be present with that value.
  1156. var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric.
  1157. // When falsy, it should be removed.
  1158. var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric.
  1159. // When falsy, it should be removed.
  1160. var POSITIVE_NUMERIC = 6;
  1161. /* eslint-disable max-len */
  1162. var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
  1163. /* eslint-enable max-len */
  1164. var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
  1165. var ROOT_ATTRIBUTE_NAME = 'data-reactroot';
  1166. var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
  1167. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1168. var illegalAttributeNameCache = {};
  1169. var validatedAttributeNameCache = {};
  1170. function isAttributeNameSafe(attributeName) {
  1171. if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) {
  1172. return true;
  1173. }
  1174. if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) {
  1175. return false;
  1176. }
  1177. if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
  1178. validatedAttributeNameCache[attributeName] = true;
  1179. return true;
  1180. }
  1181. illegalAttributeNameCache[attributeName] = true;
  1182. {
  1183. error('Invalid attribute name: `%s`', attributeName);
  1184. }
  1185. return false;
  1186. }
  1187. function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
  1188. if (propertyInfo !== null) {
  1189. return propertyInfo.type === RESERVED;
  1190. }
  1191. if (isCustomComponentTag) {
  1192. return false;
  1193. }
  1194. if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
  1195. return true;
  1196. }
  1197. return false;
  1198. }
  1199. function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
  1200. if (propertyInfo !== null && propertyInfo.type === RESERVED) {
  1201. return false;
  1202. }
  1203. switch (typeof value) {
  1204. case 'function': // $FlowIssue symbol is perfectly valid here
  1205. case 'symbol':
  1206. // eslint-disable-line
  1207. return true;
  1208. case 'boolean':
  1209. {
  1210. if (isCustomComponentTag) {
  1211. return false;
  1212. }
  1213. if (propertyInfo !== null) {
  1214. return !propertyInfo.acceptsBooleans;
  1215. } else {
  1216. var prefix = name.toLowerCase().slice(0, 5);
  1217. return prefix !== 'data-' && prefix !== 'aria-';
  1218. }
  1219. }
  1220. default:
  1221. return false;
  1222. }
  1223. }
  1224. function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
  1225. if (value === null || typeof value === 'undefined') {
  1226. return true;
  1227. }
  1228. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
  1229. return true;
  1230. }
  1231. if (isCustomComponentTag) {
  1232. return false;
  1233. }
  1234. if (propertyInfo !== null) {
  1235. switch (propertyInfo.type) {
  1236. case BOOLEAN:
  1237. return !value;
  1238. case OVERLOADED_BOOLEAN:
  1239. return value === false;
  1240. case NUMERIC:
  1241. return isNaN(value);
  1242. case POSITIVE_NUMERIC:
  1243. return isNaN(value) || value < 1;
  1244. }
  1245. }
  1246. return false;
  1247. }
  1248. function getPropertyInfo(name) {
  1249. return properties.hasOwnProperty(name) ? properties[name] : null;
  1250. }
  1251. function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL) {
  1252. this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
  1253. this.attributeName = attributeName;
  1254. this.attributeNamespace = attributeNamespace;
  1255. this.mustUseProperty = mustUseProperty;
  1256. this.propertyName = name;
  1257. this.type = type;
  1258. this.sanitizeURL = sanitizeURL;
  1259. } // When adding attributes to this list, be sure to also add them to
  1260. // the `possibleStandardNames` module to ensure casing and incorrect
  1261. // name warnings.
  1262. var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM.
  1263. var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular
  1264. // elements (not just inputs). Now that ReactDOMInput assigns to the
  1265. // defaultValue property -- do we need this?
  1266. 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'];
  1267. reservedProps.forEach(function (name) {
  1268. properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
  1269. name, // attributeName
  1270. null, // attributeNamespace
  1271. false);
  1272. }); // A few React string attributes have a different name.
  1273. // This is a mapping from React prop names to the attribute names.
  1274. [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
  1275. var name = _ref[0],
  1276. attributeName = _ref[1];
  1277. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  1278. attributeName, // attributeName
  1279. null, // attributeNamespace
  1280. false);
  1281. }); // These are "enumerated" HTML attributes that accept "true" and "false".
  1282. // In React, we let users pass `true` and `false` even though technically
  1283. // these aren't boolean attributes (they are coerced to strings).
  1284. ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
  1285. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  1286. name.toLowerCase(), // attributeName
  1287. null, // attributeNamespace
  1288. false);
  1289. }); // These are "enumerated" SVG attributes that accept "true" and "false".
  1290. // In React, we let users pass `true` and `false` even though technically
  1291. // these aren't boolean attributes (they are coerced to strings).
  1292. // Since these are SVG attributes, their attribute names are case-sensitive.
  1293. ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
  1294. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  1295. name, // attributeName
  1296. null, // attributeNamespace
  1297. false);
  1298. }); // These are HTML boolean attributes.
  1299. ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM
  1300. // on the client side because the browsers are inconsistent. Instead we call focus().
  1301. 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata
  1302. 'itemScope'].forEach(function (name) {
  1303. properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
  1304. name.toLowerCase(), // attributeName
  1305. null, // attributeNamespace
  1306. false);
  1307. }); // These are the few React props that we set as DOM properties
  1308. // rather than attributes. These are all booleans.
  1309. ['checked', // Note: `option.selected` is not updated if `select.multiple` is
  1310. // disabled with `removeAttribute`. We have special logic for handling this.
  1311. 'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list,
  1312. // you'll need to set attributeName to name.toLowerCase()
  1313. // instead in the assignment below.
  1314. ].forEach(function (name) {
  1315. properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
  1316. name, // attributeName
  1317. null, // attributeNamespace
  1318. false);
  1319. }); // These are HTML attributes that are "overloaded booleans": they behave like
  1320. // booleans, but can also accept a string value.
  1321. ['capture', 'download' // NOTE: if you add a camelCased prop to this list,
  1322. // you'll need to set attributeName to name.toLowerCase()
  1323. // instead in the assignment below.
  1324. ].forEach(function (name) {
  1325. properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
  1326. name, // attributeName
  1327. null, // attributeNamespace
  1328. false);
  1329. }); // These are HTML attributes that must be positive numbers.
  1330. ['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list,
  1331. // you'll need to set attributeName to name.toLowerCase()
  1332. // instead in the assignment below.
  1333. ].forEach(function (name) {
  1334. properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
  1335. name, // attributeName
  1336. null, // attributeNamespace
  1337. false);
  1338. }); // These are HTML attributes that must be numbers.
  1339. ['rowSpan', 'start'].forEach(function (name) {
  1340. properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
  1341. name.toLowerCase(), // attributeName
  1342. null, // attributeNamespace
  1343. false);
  1344. });
  1345. var CAMELIZE = /[\-\:]([a-z])/g;
  1346. var capitalize = function (token) {
  1347. return token[1].toUpperCase();
  1348. }; // This is a list of all SVG attributes that need special casing, namespacing,
  1349. // or boolean value assignment. Regular attributes that just accept strings
  1350. // and have the same names are omitted, just like in the HTML whitelist.
  1351. // Some of these attributes can be hard to find. This list was created by
  1352. // scraping the MDN documentation.
  1353. ['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height' // NOTE: if you add a camelCased prop to this list,
  1354. // you'll need to set attributeName to name.toLowerCase()
  1355. // instead in the assignment below.
  1356. ].forEach(function (attributeName) {
  1357. var name = attributeName.replace(CAMELIZE, capitalize);
  1358. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  1359. attributeName, null, // attributeNamespace
  1360. false);
  1361. }); // String SVG attributes with the xlink namespace.
  1362. ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list,
  1363. // you'll need to set attributeName to name.toLowerCase()
  1364. // instead in the assignment below.
  1365. ].forEach(function (attributeName) {
  1366. var name = attributeName.replace(CAMELIZE, capitalize);
  1367. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  1368. attributeName, 'http://www.w3.org/1999/xlink', false);
  1369. }); // String SVG attributes with the xml namespace.
  1370. ['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list,
  1371. // you'll need to set attributeName to name.toLowerCase()
  1372. // instead in the assignment below.
  1373. ].forEach(function (attributeName) {
  1374. var name = attributeName.replace(CAMELIZE, capitalize);
  1375. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  1376. attributeName, 'http://www.w3.org/XML/1998/namespace', false);
  1377. }); // These attribute exists both in HTML and SVG.
  1378. // The attribute name is case-sensitive in SVG so we can't just use
  1379. // the React name like we do for attributes that exist only in HTML.
  1380. ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
  1381. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  1382. attributeName.toLowerCase(), // attributeName
  1383. null, // attributeNamespace
  1384. false);
  1385. }); // These attributes accept URLs. These must not allow javascript: URLS.
  1386. // These will also need to accept Trusted Types object in the future.
  1387. var xlinkHref = 'xlinkHref';
  1388. properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
  1389. 'xlink:href', 'http://www.w3.org/1999/xlink', true);
  1390. ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
  1391. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  1392. attributeName.toLowerCase(), // attributeName
  1393. null, // attributeNamespace
  1394. true);
  1395. });
  1396. var ReactDebugCurrentFrame = null;
  1397. {
  1398. ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  1399. } // A javascript: URL can contain leading C0 control or \u0020 SPACE,
  1400. // and any newline or tab are filtered out as if they're not part of the URL.
  1401. // https://url.spec.whatwg.org/#url-parsing
  1402. // Tab or newline are defined as \r\n\t:
  1403. // https://infra.spec.whatwg.org/#ascii-tab-or-newline
  1404. // A C0 control is a code point in the range \u0000 NULL to \u001F
  1405. // INFORMATION SEPARATOR ONE, inclusive:
  1406. // https://infra.spec.whatwg.org/#c0-control-or-space
  1407. /* eslint-disable max-len */
  1408. var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i;
  1409. var didWarn = false;
  1410. function sanitizeURL(url) {
  1411. {
  1412. if (!didWarn && isJavaScriptProtocol.test(url)) {
  1413. didWarn = true;
  1414. error('A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url));
  1415. }
  1416. }
  1417. }
  1418. /**
  1419. * Get the value for a property on a node. Only used in DEV for SSR validation.
  1420. * The "expected" argument is used as a hint of what the expected value is.
  1421. * Some properties have multiple equivalent values.
  1422. */
  1423. function getValueForProperty(node, name, expected, propertyInfo) {
  1424. {
  1425. if (propertyInfo.mustUseProperty) {
  1426. var propertyName = propertyInfo.propertyName;
  1427. return node[propertyName];
  1428. } else {
  1429. if ( propertyInfo.sanitizeURL) {
  1430. // If we haven't fully disabled javascript: URLs, and if
  1431. // the hydration is successful of a javascript: URL, we
  1432. // still want to warn on the client.
  1433. sanitizeURL('' + expected);
  1434. }
  1435. var attributeName = propertyInfo.attributeName;
  1436. var stringValue = null;
  1437. if (propertyInfo.type === OVERLOADED_BOOLEAN) {
  1438. if (node.hasAttribute(attributeName)) {
  1439. var value = node.getAttribute(attributeName);
  1440. if (value === '') {
  1441. return true;
  1442. }
  1443. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  1444. return value;
  1445. }
  1446. if (value === '' + expected) {
  1447. return expected;
  1448. }
  1449. return value;
  1450. }
  1451. } else if (node.hasAttribute(attributeName)) {
  1452. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  1453. // We had an attribute but shouldn't have had one, so read it
  1454. // for the error message.
  1455. return node.getAttribute(attributeName);
  1456. }
  1457. if (propertyInfo.type === BOOLEAN) {
  1458. // If this was a boolean, it doesn't matter what the value is
  1459. // the fact that we have it is the same as the expected.
  1460. return expected;
  1461. } // Even if this property uses a namespace we use getAttribute
  1462. // because we assume its namespaced name is the same as our config.
  1463. // To use getAttributeNS we need the local name which we don't have
  1464. // in our config atm.
  1465. stringValue = node.getAttribute(attributeName);
  1466. }
  1467. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  1468. return stringValue === null ? expected : stringValue;
  1469. } else if (stringValue === '' + expected) {
  1470. return expected;
  1471. } else {
  1472. return stringValue;
  1473. }
  1474. }
  1475. }
  1476. }
  1477. /**
  1478. * Get the value for a attribute on a node. Only used in DEV for SSR validation.
  1479. * The third argument is used as a hint of what the expected value is. Some
  1480. * attributes have multiple equivalent values.
  1481. */
  1482. function getValueForAttribute(node, name, expected) {
  1483. {
  1484. if (!isAttributeNameSafe(name)) {
  1485. return;
  1486. }
  1487. if (!node.hasAttribute(name)) {
  1488. return expected === undefined ? undefined : null;
  1489. }
  1490. var value = node.getAttribute(name);
  1491. if (value === '' + expected) {
  1492. return expected;
  1493. }
  1494. return value;
  1495. }
  1496. }
  1497. /**
  1498. * Sets the value for a property on a node.
  1499. *
  1500. * @param {DOMElement} node
  1501. * @param {string} name
  1502. * @param {*} value
  1503. */
  1504. function setValueForProperty(node, name, value, isCustomComponentTag) {
  1505. var propertyInfo = getPropertyInfo(name);
  1506. if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) {
  1507. return;
  1508. }
  1509. if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) {
  1510. value = null;
  1511. } // If the prop isn't in the special list, treat it as a simple attribute.
  1512. if (isCustomComponentTag || propertyInfo === null) {
  1513. if (isAttributeNameSafe(name)) {
  1514. var _attributeName = name;
  1515. if (value === null) {
  1516. node.removeAttribute(_attributeName);
  1517. } else {
  1518. node.setAttribute(_attributeName, '' + value);
  1519. }
  1520. }
  1521. return;
  1522. }
  1523. var mustUseProperty = propertyInfo.mustUseProperty;
  1524. if (mustUseProperty) {
  1525. var propertyName = propertyInfo.propertyName;
  1526. if (value === null) {
  1527. var type = propertyInfo.type;
  1528. node[propertyName] = type === BOOLEAN ? false : '';
  1529. } else {
  1530. // Contrary to `setAttribute`, object properties are properly
  1531. // `toString`ed by IE8/9.
  1532. node[propertyName] = value;
  1533. }
  1534. return;
  1535. } // The rest are treated as attributes with special cases.
  1536. var attributeName = propertyInfo.attributeName,
  1537. attributeNamespace = propertyInfo.attributeNamespace;
  1538. if (value === null) {
  1539. node.removeAttribute(attributeName);
  1540. } else {
  1541. var _type = propertyInfo.type;
  1542. var attributeValue;
  1543. if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) {
  1544. // If attribute type is boolean, we know for sure it won't be an execution sink
  1545. // and we won't require Trusted Type here.
  1546. attributeValue = '';
  1547. } else {
  1548. // `setAttribute` with objects becomes only `[object]` in IE8/9,
  1549. // ('' + value) makes it output the correct toString()-value.
  1550. {
  1551. attributeValue = '' + value;
  1552. }
  1553. if (propertyInfo.sanitizeURL) {
  1554. sanitizeURL(attributeValue.toString());
  1555. }
  1556. }
  1557. if (attributeNamespace) {
  1558. node.setAttributeNS(attributeNamespace, attributeName, attributeValue);
  1559. } else {
  1560. node.setAttribute(attributeName, attributeValue);
  1561. }
  1562. }
  1563. }
  1564. var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
  1565. function describeComponentFrame (name, source, ownerName) {
  1566. var sourceInfo = '';
  1567. if (source) {
  1568. var path = source.fileName;
  1569. var fileName = path.replace(BEFORE_SLASH_RE, '');
  1570. {
  1571. // In DEV, include code for a common special case:
  1572. // prefer "folder/index.js" instead of just "index.js".
  1573. if (/^index\./.test(fileName)) {
  1574. var match = path.match(BEFORE_SLASH_RE);
  1575. if (match) {
  1576. var pathBeforeSlash = match[1];
  1577. if (pathBeforeSlash) {
  1578. var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
  1579. fileName = folderName + '/' + fileName;
  1580. }
  1581. }
  1582. }
  1583. }
  1584. sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
  1585. } else if (ownerName) {
  1586. sourceInfo = ' (created by ' + ownerName + ')';
  1587. }
  1588. return '\n in ' + (name || 'Unknown') + sourceInfo;
  1589. }
  1590. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  1591. // nor polyfill, then a plain number is used for performance.
  1592. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  1593. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  1594. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  1595. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  1596. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  1597. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  1598. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  1599. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  1600. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  1601. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  1602. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  1603. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  1604. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  1605. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  1606. var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
  1607. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  1608. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  1609. function getIteratorFn(maybeIterable) {
  1610. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  1611. return null;
  1612. }
  1613. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  1614. if (typeof maybeIterator === 'function') {
  1615. return maybeIterator;
  1616. }
  1617. return null;
  1618. }
  1619. var Uninitialized = -1;
  1620. var Pending = 0;
  1621. var Resolved = 1;
  1622. var Rejected = 2;
  1623. function refineResolvedLazyComponent(lazyComponent) {
  1624. return lazyComponent._status === Resolved ? lazyComponent._result : null;
  1625. }
  1626. function initializeLazyComponentType(lazyComponent) {
  1627. if (lazyComponent._status === Uninitialized) {
  1628. lazyComponent._status = Pending;
  1629. var ctor = lazyComponent._ctor;
  1630. var thenable = ctor();
  1631. lazyComponent._result = thenable;
  1632. thenable.then(function (moduleObject) {
  1633. if (lazyComponent._status === Pending) {
  1634. var defaultExport = moduleObject.default;
  1635. {
  1636. if (defaultExport === undefined) {
  1637. error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
  1638. }
  1639. }
  1640. lazyComponent._status = Resolved;
  1641. lazyComponent._result = defaultExport;
  1642. }
  1643. }, function (error) {
  1644. if (lazyComponent._status === Pending) {
  1645. lazyComponent._status = Rejected;
  1646. lazyComponent._result = error;
  1647. }
  1648. });
  1649. }
  1650. }
  1651. function getWrappedName(outerType, innerType, wrapperName) {
  1652. var functionName = innerType.displayName || innerType.name || '';
  1653. return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
  1654. }
  1655. function getComponentName(type) {
  1656. if (type == null) {
  1657. // Host root, text node or just invalid type.
  1658. return null;
  1659. }
  1660. {
  1661. if (typeof type.tag === 'number') {
  1662. error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  1663. }
  1664. }
  1665. if (typeof type === 'function') {
  1666. return type.displayName || type.name || null;
  1667. }
  1668. if (typeof type === 'string') {
  1669. return type;
  1670. }
  1671. switch (type) {
  1672. case REACT_FRAGMENT_TYPE:
  1673. return 'Fragment';
  1674. case REACT_PORTAL_TYPE:
  1675. return 'Portal';
  1676. case REACT_PROFILER_TYPE:
  1677. return "Profiler";
  1678. case REACT_STRICT_MODE_TYPE:
  1679. return 'StrictMode';
  1680. case REACT_SUSPENSE_TYPE:
  1681. return 'Suspense';
  1682. case REACT_SUSPENSE_LIST_TYPE:
  1683. return 'SuspenseList';
  1684. }
  1685. if (typeof type === 'object') {
  1686. switch (type.$$typeof) {
  1687. case REACT_CONTEXT_TYPE:
  1688. return 'Context.Consumer';
  1689. case REACT_PROVIDER_TYPE:
  1690. return 'Context.Provider';
  1691. case REACT_FORWARD_REF_TYPE:
  1692. return getWrappedName(type, type.render, 'ForwardRef');
  1693. case REACT_MEMO_TYPE:
  1694. return getComponentName(type.type);
  1695. case REACT_BLOCK_TYPE:
  1696. return getComponentName(type.render);
  1697. case REACT_LAZY_TYPE:
  1698. {
  1699. var thenable = type;
  1700. var resolvedThenable = refineResolvedLazyComponent(thenable);
  1701. if (resolvedThenable) {
  1702. return getComponentName(resolvedThenable);
  1703. }
  1704. break;
  1705. }
  1706. }
  1707. }
  1708. return null;
  1709. }
  1710. var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
  1711. function describeFiber(fiber) {
  1712. switch (fiber.tag) {
  1713. case HostRoot:
  1714. case HostPortal:
  1715. case HostText:
  1716. case Fragment:
  1717. case ContextProvider:
  1718. case ContextConsumer:
  1719. return '';
  1720. default:
  1721. var owner = fiber._debugOwner;
  1722. var source = fiber._debugSource;
  1723. var name = getComponentName(fiber.type);
  1724. var ownerName = null;
  1725. if (owner) {
  1726. ownerName = getComponentName(owner.type);
  1727. }
  1728. return describeComponentFrame(name, source, ownerName);
  1729. }
  1730. }
  1731. function getStackByFiberInDevAndProd(workInProgress) {
  1732. var info = '';
  1733. var node = workInProgress;
  1734. do {
  1735. info += describeFiber(node);
  1736. node = node.return;
  1737. } while (node);
  1738. return info;
  1739. }
  1740. var current = null;
  1741. var isRendering = false;
  1742. function getCurrentFiberOwnerNameInDevOrNull() {
  1743. {
  1744. if (current === null) {
  1745. return null;
  1746. }
  1747. var owner = current._debugOwner;
  1748. if (owner !== null && typeof owner !== 'undefined') {
  1749. return getComponentName(owner.type);
  1750. }
  1751. }
  1752. return null;
  1753. }
  1754. function getCurrentFiberStackInDev() {
  1755. {
  1756. if (current === null) {
  1757. return '';
  1758. } // Safe because if current fiber exists, we are reconciling,
  1759. // and it is guaranteed to be the work-in-progress version.
  1760. return getStackByFiberInDevAndProd(current);
  1761. }
  1762. }
  1763. function resetCurrentFiber() {
  1764. {
  1765. ReactDebugCurrentFrame$1.getCurrentStack = null;
  1766. current = null;
  1767. isRendering = false;
  1768. }
  1769. }
  1770. function setCurrentFiber(fiber) {
  1771. {
  1772. ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev;
  1773. current = fiber;
  1774. isRendering = false;
  1775. }
  1776. }
  1777. function setIsRendering(rendering) {
  1778. {
  1779. isRendering = rendering;
  1780. }
  1781. }
  1782. // Flow does not allow string concatenation of most non-string types. To work
  1783. // around this limitation, we use an opaque type that can only be obtained by
  1784. // passing the value through getToStringValue first.
  1785. function toString(value) {
  1786. return '' + value;
  1787. }
  1788. function getToStringValue(value) {
  1789. switch (typeof value) {
  1790. case 'boolean':
  1791. case 'number':
  1792. case 'object':
  1793. case 'string':
  1794. case 'undefined':
  1795. return value;
  1796. default:
  1797. // function, symbol are assigned as empty strings
  1798. return '';
  1799. }
  1800. }
  1801. var ReactDebugCurrentFrame$2 = null;
  1802. var ReactControlledValuePropTypes = {
  1803. checkPropTypes: null
  1804. };
  1805. {
  1806. ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame;
  1807. var hasReadOnlyValue = {
  1808. button: true,
  1809. checkbox: true,
  1810. image: true,
  1811. hidden: true,
  1812. radio: true,
  1813. reset: true,
  1814. submit: true
  1815. };
  1816. var propTypes = {
  1817. value: function (props, propName, componentName) {
  1818. if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null || enableDeprecatedFlareAPI ) {
  1819. return null;
  1820. }
  1821. return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
  1822. },
  1823. checked: function (props, propName, componentName) {
  1824. if (props.onChange || props.readOnly || props.disabled || props[propName] == null || enableDeprecatedFlareAPI ) {
  1825. return null;
  1826. }
  1827. return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
  1828. }
  1829. };
  1830. /**
  1831. * Provide a linked `value` attribute for controlled forms. You should not use
  1832. * this outside of the ReactDOM controlled form components.
  1833. */
  1834. ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) {
  1835. checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$2.getStackAddendum);
  1836. };
  1837. }
  1838. function isCheckable(elem) {
  1839. var type = elem.type;
  1840. var nodeName = elem.nodeName;
  1841. return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio');
  1842. }
  1843. function getTracker(node) {
  1844. return node._valueTracker;
  1845. }
  1846. function detachTracker(node) {
  1847. node._valueTracker = null;
  1848. }
  1849. function getValueFromNode(node) {
  1850. var value = '';
  1851. if (!node) {
  1852. return value;
  1853. }
  1854. if (isCheckable(node)) {
  1855. value = node.checked ? 'true' : 'false';
  1856. } else {
  1857. value = node.value;
  1858. }
  1859. return value;
  1860. }
  1861. function trackValueOnNode(node) {
  1862. var valueField = isCheckable(node) ? 'checked' : 'value';
  1863. var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField);
  1864. var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail
  1865. // and don't track value will cause over reporting of changes,
  1866. // but it's better then a hard failure
  1867. // (needed for certain tests that spyOn input values and Safari)
  1868. if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') {
  1869. return;
  1870. }
  1871. var get = descriptor.get,
  1872. set = descriptor.set;
  1873. Object.defineProperty(node, valueField, {
  1874. configurable: true,
  1875. get: function () {
  1876. return get.call(this);
  1877. },
  1878. set: function (value) {
  1879. currentValue = '' + value;
  1880. set.call(this, value);
  1881. }
  1882. }); // We could've passed this the first time
  1883. // but it triggers a bug in IE11 and Edge 14/15.
  1884. // Calling defineProperty() again should be equivalent.
  1885. // https://github.com/facebook/react/issues/11768
  1886. Object.defineProperty(node, valueField, {
  1887. enumerable: descriptor.enumerable
  1888. });
  1889. var tracker = {
  1890. getValue: function () {
  1891. return currentValue;
  1892. },
  1893. setValue: function (value) {
  1894. currentValue = '' + value;
  1895. },
  1896. stopTracking: function () {
  1897. detachTracker(node);
  1898. delete node[valueField];
  1899. }
  1900. };
  1901. return tracker;
  1902. }
  1903. function track(node) {
  1904. if (getTracker(node)) {
  1905. return;
  1906. } // TODO: Once it's just Fiber we can move this to node._wrapperState
  1907. node._valueTracker = trackValueOnNode(node);
  1908. }
  1909. function updateValueIfChanged(node) {
  1910. if (!node) {
  1911. return false;
  1912. }
  1913. var tracker = getTracker(node); // if there is no tracker at this point it's unlikely
  1914. // that trying again will succeed
  1915. if (!tracker) {
  1916. return true;
  1917. }
  1918. var lastValue = tracker.getValue();
  1919. var nextValue = getValueFromNode(node);
  1920. if (nextValue !== lastValue) {
  1921. tracker.setValue(nextValue);
  1922. return true;
  1923. }
  1924. return false;
  1925. }
  1926. var didWarnValueDefaultValue = false;
  1927. var didWarnCheckedDefaultChecked = false;
  1928. var didWarnControlledToUncontrolled = false;
  1929. var didWarnUncontrolledToControlled = false;
  1930. function isControlled(props) {
  1931. var usesChecked = props.type === 'checkbox' || props.type === 'radio';
  1932. return usesChecked ? props.checked != null : props.value != null;
  1933. }
  1934. /**
  1935. * Implements an <input> host component that allows setting these optional
  1936. * props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
  1937. *
  1938. * If `checked` or `value` are not supplied (or null/undefined), user actions
  1939. * that affect the checked state or value will trigger updates to the element.
  1940. *
  1941. * If they are supplied (and not null/undefined), the rendered element will not
  1942. * trigger updates to the element. Instead, the props must change in order for
  1943. * the rendered element to be updated.
  1944. *
  1945. * The rendered element will be initialized as unchecked (or `defaultChecked`)
  1946. * with an empty value (or `defaultValue`).
  1947. *
  1948. * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
  1949. */
  1950. function getHostProps(element, props) {
  1951. var node = element;
  1952. var checked = props.checked;
  1953. var hostProps = _assign({}, props, {
  1954. defaultChecked: undefined,
  1955. defaultValue: undefined,
  1956. value: undefined,
  1957. checked: checked != null ? checked : node._wrapperState.initialChecked
  1958. });
  1959. return hostProps;
  1960. }
  1961. function initWrapperState(element, props) {
  1962. {
  1963. ReactControlledValuePropTypes.checkPropTypes('input', props);
  1964. if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) {
  1965. error('%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type);
  1966. didWarnCheckedDefaultChecked = true;
  1967. }
  1968. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
  1969. error('%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type);
  1970. didWarnValueDefaultValue = true;
  1971. }
  1972. }
  1973. var node = element;
  1974. var defaultValue = props.defaultValue == null ? '' : props.defaultValue;
  1975. node._wrapperState = {
  1976. initialChecked: props.checked != null ? props.checked : props.defaultChecked,
  1977. initialValue: getToStringValue(props.value != null ? props.value : defaultValue),
  1978. controlled: isControlled(props)
  1979. };
  1980. }
  1981. function updateChecked(element, props) {
  1982. var node = element;
  1983. var checked = props.checked;
  1984. if (checked != null) {
  1985. setValueForProperty(node, 'checked', checked, false);
  1986. }
  1987. }
  1988. function updateWrapper(element, props) {
  1989. var node = element;
  1990. {
  1991. var controlled = isControlled(props);
  1992. if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) {
  1993. error('A component is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type);
  1994. didWarnUncontrolledToControlled = true;
  1995. }
  1996. if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) {
  1997. error('A component is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type);
  1998. didWarnControlledToUncontrolled = true;
  1999. }
  2000. }
  2001. updateChecked(element, props);
  2002. var value = getToStringValue(props.value);
  2003. var type = props.type;
  2004. if (value != null) {
  2005. if (type === 'number') {
  2006. if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible.
  2007. // eslint-disable-next-line
  2008. node.value != value) {
  2009. node.value = toString(value);
  2010. }
  2011. } else if (node.value !== toString(value)) {
  2012. node.value = toString(value);
  2013. }
  2014. } else if (type === 'submit' || type === 'reset') {
  2015. // Submit/reset inputs need the attribute removed completely to avoid
  2016. // blank-text buttons.
  2017. node.removeAttribute('value');
  2018. return;
  2019. }
  2020. {
  2021. // When syncing the value attribute, the value comes from a cascade of
  2022. // properties:
  2023. // 1. The value React property
  2024. // 2. The defaultValue React property
  2025. // 3. Otherwise there should be no change
  2026. if (props.hasOwnProperty('value')) {
  2027. setDefaultValue(node, props.type, value);
  2028. } else if (props.hasOwnProperty('defaultValue')) {
  2029. setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
  2030. }
  2031. }
  2032. {
  2033. // When syncing the checked attribute, it only changes when it needs
  2034. // to be removed, such as transitioning from a checkbox into a text input
  2035. if (props.checked == null && props.defaultChecked != null) {
  2036. node.defaultChecked = !!props.defaultChecked;
  2037. }
  2038. }
  2039. }
  2040. function postMountWrapper(element, props, isHydrating) {
  2041. var node = element; // Do not assign value if it is already set. This prevents user text input
  2042. // from being lost during SSR hydration.
  2043. if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) {
  2044. var type = props.type;
  2045. var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the
  2046. // default value provided by the browser. See: #12872
  2047. if (isButton && (props.value === undefined || props.value === null)) {
  2048. return;
  2049. }
  2050. var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input
  2051. // from being lost during SSR hydration.
  2052. if (!isHydrating) {
  2053. {
  2054. // When syncing the value attribute, the value property should use
  2055. // the wrapperState._initialValue property. This uses:
  2056. //
  2057. // 1. The value React property when present
  2058. // 2. The defaultValue React property when present
  2059. // 3. An empty string
  2060. if (initialValue !== node.value) {
  2061. node.value = initialValue;
  2062. }
  2063. }
  2064. }
  2065. {
  2066. // Otherwise, the value attribute is synchronized to the property,
  2067. // so we assign defaultValue to the same thing as the value property
  2068. // assignment step above.
  2069. node.defaultValue = initialValue;
  2070. }
  2071. } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
  2072. // this is needed to work around a chrome bug where setting defaultChecked
  2073. // will sometimes influence the value of checked (even after detachment).
  2074. // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416
  2075. // We need to temporarily unset name to avoid disrupting radio button groups.
  2076. var name = node.name;
  2077. if (name !== '') {
  2078. node.name = '';
  2079. }
  2080. {
  2081. // When syncing the checked attribute, both the checked property and
  2082. // attribute are assigned at the same time using defaultChecked. This uses:
  2083. //
  2084. // 1. The checked React property when present
  2085. // 2. The defaultChecked React property when present
  2086. // 3. Otherwise, false
  2087. node.defaultChecked = !node.defaultChecked;
  2088. node.defaultChecked = !!node._wrapperState.initialChecked;
  2089. }
  2090. if (name !== '') {
  2091. node.name = name;
  2092. }
  2093. }
  2094. function restoreControlledState(element, props) {
  2095. var node = element;
  2096. updateWrapper(node, props);
  2097. updateNamedCousins(node, props);
  2098. }
  2099. function updateNamedCousins(rootNode, props) {
  2100. var name = props.name;
  2101. if (props.type === 'radio' && name != null) {
  2102. var queryRoot = rootNode;
  2103. while (queryRoot.parentNode) {
  2104. queryRoot = queryRoot.parentNode;
  2105. } // If `rootNode.form` was non-null, then we could try `form.elements`,
  2106. // but that sometimes behaves strangely in IE8. We could also try using
  2107. // `form.getElementsByName`, but that will only return direct children
  2108. // and won't include inputs that use the HTML5 `form=` attribute. Since
  2109. // the input might not even be in a form. It might not even be in the
  2110. // document. Let's just use the local `querySelectorAll` to ensure we don't
  2111. // miss anything.
  2112. var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
  2113. for (var i = 0; i < group.length; i++) {
  2114. var otherNode = group[i];
  2115. if (otherNode === rootNode || otherNode.form !== rootNode.form) {
  2116. continue;
  2117. } // This will throw if radio buttons rendered by different copies of React
  2118. // and the same name are rendered into the same form (same as #1939).
  2119. // That's probably okay; we don't support it just as we don't support
  2120. // mixing React radio buttons with non-React ones.
  2121. var otherProps = getFiberCurrentPropsFromNode$1(otherNode);
  2122. if (!otherProps) {
  2123. {
  2124. throw Error( "ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported." );
  2125. }
  2126. } // We need update the tracked value on the named cousin since the value
  2127. // was changed but the input saw no event or value set
  2128. updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that
  2129. // was previously checked to update will cause it to be come re-checked
  2130. // as appropriate.
  2131. updateWrapper(otherNode, otherProps);
  2132. }
  2133. }
  2134. } // In Chrome, assigning defaultValue to certain input types triggers input validation.
  2135. // For number inputs, the display value loses trailing decimal points. For email inputs,
  2136. // Chrome raises "The specified value <x> is not a valid email address".
  2137. //
  2138. // Here we check to see if the defaultValue has actually changed, avoiding these problems
  2139. // when the user is inputting text
  2140. //
  2141. // https://github.com/facebook/react/issues/7253
  2142. function setDefaultValue(node, type, value) {
  2143. if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js
  2144. type !== 'number' || node.ownerDocument.activeElement !== node) {
  2145. if (value == null) {
  2146. node.defaultValue = toString(node._wrapperState.initialValue);
  2147. } else if (node.defaultValue !== toString(value)) {
  2148. node.defaultValue = toString(value);
  2149. }
  2150. }
  2151. }
  2152. var didWarnSelectedSetOnOption = false;
  2153. var didWarnInvalidChild = false;
  2154. function flattenChildren(children) {
  2155. var content = ''; // Flatten children. We'll warn if they are invalid
  2156. // during validateProps() which runs for hydration too.
  2157. // Note that this would throw on non-element objects.
  2158. // Elements are stringified (which is normally irrelevant
  2159. // but matters for <fbt>).
  2160. React.Children.forEach(children, function (child) {
  2161. if (child == null) {
  2162. return;
  2163. }
  2164. content += child; // Note: we don't warn about invalid children here.
  2165. // Instead, this is done separately below so that
  2166. // it happens during the hydration codepath too.
  2167. });
  2168. return content;
  2169. }
  2170. /**
  2171. * Implements an <option> host component that warns when `selected` is set.
  2172. */
  2173. function validateProps(element, props) {
  2174. {
  2175. // This mirrors the codepath above, but runs for hydration too.
  2176. // Warn about invalid children here so that client and hydration are consistent.
  2177. // TODO: this seems like it could cause a DEV-only throw for hydration
  2178. // if children contains a non-element object. We should try to avoid that.
  2179. if (typeof props.children === 'object' && props.children !== null) {
  2180. React.Children.forEach(props.children, function (child) {
  2181. if (child == null) {
  2182. return;
  2183. }
  2184. if (typeof child === 'string' || typeof child === 'number') {
  2185. return;
  2186. }
  2187. if (typeof child.type !== 'string') {
  2188. return;
  2189. }
  2190. if (!didWarnInvalidChild) {
  2191. didWarnInvalidChild = true;
  2192. error('Only strings and numbers are supported as <option> children.');
  2193. }
  2194. });
  2195. } // TODO: Remove support for `selected` in <option>.
  2196. if (props.selected != null && !didWarnSelectedSetOnOption) {
  2197. error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.');
  2198. didWarnSelectedSetOnOption = true;
  2199. }
  2200. }
  2201. }
  2202. function postMountWrapper$1(element, props) {
  2203. // value="" should make a value attribute (#6219)
  2204. if (props.value != null) {
  2205. element.setAttribute('value', toString(getToStringValue(props.value)));
  2206. }
  2207. }
  2208. function getHostProps$1(element, props) {
  2209. var hostProps = _assign({
  2210. children: undefined
  2211. }, props);
  2212. var content = flattenChildren(props.children);
  2213. if (content) {
  2214. hostProps.children = content;
  2215. }
  2216. return hostProps;
  2217. }
  2218. var didWarnValueDefaultValue$1;
  2219. {
  2220. didWarnValueDefaultValue$1 = false;
  2221. }
  2222. function getDeclarationErrorAddendum() {
  2223. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  2224. if (ownerName) {
  2225. return '\n\nCheck the render method of `' + ownerName + '`.';
  2226. }
  2227. return '';
  2228. }
  2229. var valuePropNames = ['value', 'defaultValue'];
  2230. /**
  2231. * Validation function for `value` and `defaultValue`.
  2232. */
  2233. function checkSelectPropTypes(props) {
  2234. {
  2235. ReactControlledValuePropTypes.checkPropTypes('select', props);
  2236. for (var i = 0; i < valuePropNames.length; i++) {
  2237. var propName = valuePropNames[i];
  2238. if (props[propName] == null) {
  2239. continue;
  2240. }
  2241. var isArray = Array.isArray(props[propName]);
  2242. if (props.multiple && !isArray) {
  2243. error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum());
  2244. } else if (!props.multiple && isArray) {
  2245. error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum());
  2246. }
  2247. }
  2248. }
  2249. }
  2250. function updateOptions(node, multiple, propValue, setDefaultSelected) {
  2251. var options = node.options;
  2252. if (multiple) {
  2253. var selectedValues = propValue;
  2254. var selectedValue = {};
  2255. for (var i = 0; i < selectedValues.length; i++) {
  2256. // Prefix to avoid chaos with special keys.
  2257. selectedValue['$' + selectedValues[i]] = true;
  2258. }
  2259. for (var _i = 0; _i < options.length; _i++) {
  2260. var selected = selectedValue.hasOwnProperty('$' + options[_i].value);
  2261. if (options[_i].selected !== selected) {
  2262. options[_i].selected = selected;
  2263. }
  2264. if (selected && setDefaultSelected) {
  2265. options[_i].defaultSelected = true;
  2266. }
  2267. }
  2268. } else {
  2269. // Do not set `select.value` as exact behavior isn't consistent across all
  2270. // browsers for all cases.
  2271. var _selectedValue = toString(getToStringValue(propValue));
  2272. var defaultSelected = null;
  2273. for (var _i2 = 0; _i2 < options.length; _i2++) {
  2274. if (options[_i2].value === _selectedValue) {
  2275. options[_i2].selected = true;
  2276. if (setDefaultSelected) {
  2277. options[_i2].defaultSelected = true;
  2278. }
  2279. return;
  2280. }
  2281. if (defaultSelected === null && !options[_i2].disabled) {
  2282. defaultSelected = options[_i2];
  2283. }
  2284. }
  2285. if (defaultSelected !== null) {
  2286. defaultSelected.selected = true;
  2287. }
  2288. }
  2289. }
  2290. /**
  2291. * Implements a <select> host component that allows optionally setting the
  2292. * props `value` and `defaultValue`. If `multiple` is false, the prop must be a
  2293. * stringable. If `multiple` is true, the prop must be an array of stringables.
  2294. *
  2295. * If `value` is not supplied (or null/undefined), user actions that change the
  2296. * selected option will trigger updates to the rendered options.
  2297. *
  2298. * If it is supplied (and not null/undefined), the rendered options will not
  2299. * update in response to user actions. Instead, the `value` prop must change in
  2300. * order for the rendered options to update.
  2301. *
  2302. * If `defaultValue` is provided, any options with the supplied values will be
  2303. * selected.
  2304. */
  2305. function getHostProps$2(element, props) {
  2306. return _assign({}, props, {
  2307. value: undefined
  2308. });
  2309. }
  2310. function initWrapperState$1(element, props) {
  2311. var node = element;
  2312. {
  2313. checkSelectPropTypes(props);
  2314. }
  2315. node._wrapperState = {
  2316. wasMultiple: !!props.multiple
  2317. };
  2318. {
  2319. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) {
  2320. error('Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components');
  2321. didWarnValueDefaultValue$1 = true;
  2322. }
  2323. }
  2324. }
  2325. function postMountWrapper$2(element, props) {
  2326. var node = element;
  2327. node.multiple = !!props.multiple;
  2328. var value = props.value;
  2329. if (value != null) {
  2330. updateOptions(node, !!props.multiple, value, false);
  2331. } else if (props.defaultValue != null) {
  2332. updateOptions(node, !!props.multiple, props.defaultValue, true);
  2333. }
  2334. }
  2335. function postUpdateWrapper(element, props) {
  2336. var node = element;
  2337. var wasMultiple = node._wrapperState.wasMultiple;
  2338. node._wrapperState.wasMultiple = !!props.multiple;
  2339. var value = props.value;
  2340. if (value != null) {
  2341. updateOptions(node, !!props.multiple, value, false);
  2342. } else if (wasMultiple !== !!props.multiple) {
  2343. // For simplicity, reapply `defaultValue` if `multiple` is toggled.
  2344. if (props.defaultValue != null) {
  2345. updateOptions(node, !!props.multiple, props.defaultValue, true);
  2346. } else {
  2347. // Revert the select back to its default unselected state.
  2348. updateOptions(node, !!props.multiple, props.multiple ? [] : '', false);
  2349. }
  2350. }
  2351. }
  2352. function restoreControlledState$1(element, props) {
  2353. var node = element;
  2354. var value = props.value;
  2355. if (value != null) {
  2356. updateOptions(node, !!props.multiple, value, false);
  2357. }
  2358. }
  2359. var didWarnValDefaultVal = false;
  2360. /**
  2361. * Implements a <textarea> host component that allows setting `value`, and
  2362. * `defaultValue`. This differs from the traditional DOM API because value is
  2363. * usually set as PCDATA children.
  2364. *
  2365. * If `value` is not supplied (or null/undefined), user actions that affect the
  2366. * value will trigger updates to the element.
  2367. *
  2368. * If `value` is supplied (and not null/undefined), the rendered element will
  2369. * not trigger updates to the element. Instead, the `value` prop must change in
  2370. * order for the rendered element to be updated.
  2371. *
  2372. * The rendered element will be initialized with an empty value, the prop
  2373. * `defaultValue` if specified, or the children content (deprecated).
  2374. */
  2375. function getHostProps$3(element, props) {
  2376. var node = element;
  2377. if (!(props.dangerouslySetInnerHTML == null)) {
  2378. {
  2379. throw Error( "`dangerouslySetInnerHTML` does not make sense on <textarea>." );
  2380. }
  2381. } // Always set children to the same thing. In IE9, the selection range will
  2382. // get reset if `textContent` is mutated. We could add a check in setTextContent
  2383. // to only set the value if/when the value differs from the node value (which would
  2384. // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this
  2385. // solution. The value can be a boolean or object so that's why it's forced
  2386. // to be a string.
  2387. var hostProps = _assign({}, props, {
  2388. value: undefined,
  2389. defaultValue: undefined,
  2390. children: toString(node._wrapperState.initialValue)
  2391. });
  2392. return hostProps;
  2393. }
  2394. function initWrapperState$2(element, props) {
  2395. var node = element;
  2396. {
  2397. ReactControlledValuePropTypes.checkPropTypes('textarea', props);
  2398. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
  2399. error('%s contains a textarea with both value and defaultValue props. ' + 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
  2400. didWarnValDefaultVal = true;
  2401. }
  2402. }
  2403. var initialValue = props.value; // Only bother fetching default value if we're going to use it
  2404. if (initialValue == null) {
  2405. var children = props.children,
  2406. defaultValue = props.defaultValue;
  2407. if (children != null) {
  2408. {
  2409. error('Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
  2410. }
  2411. {
  2412. if (!(defaultValue == null)) {
  2413. {
  2414. throw Error( "If you supply `defaultValue` on a <textarea>, do not pass children." );
  2415. }
  2416. }
  2417. if (Array.isArray(children)) {
  2418. if (!(children.length <= 1)) {
  2419. {
  2420. throw Error( "<textarea> can only have at most one child." );
  2421. }
  2422. }
  2423. children = children[0];
  2424. }
  2425. defaultValue = children;
  2426. }
  2427. }
  2428. if (defaultValue == null) {
  2429. defaultValue = '';
  2430. }
  2431. initialValue = defaultValue;
  2432. }
  2433. node._wrapperState = {
  2434. initialValue: getToStringValue(initialValue)
  2435. };
  2436. }
  2437. function updateWrapper$1(element, props) {
  2438. var node = element;
  2439. var value = getToStringValue(props.value);
  2440. var defaultValue = getToStringValue(props.defaultValue);
  2441. if (value != null) {
  2442. // Cast `value` to a string to ensure the value is set correctly. While
  2443. // browsers typically do this as necessary, jsdom doesn't.
  2444. var newValue = toString(value); // To avoid side effects (such as losing text selection), only set value if changed
  2445. if (newValue !== node.value) {
  2446. node.value = newValue;
  2447. }
  2448. if (props.defaultValue == null && node.defaultValue !== newValue) {
  2449. node.defaultValue = newValue;
  2450. }
  2451. }
  2452. if (defaultValue != null) {
  2453. node.defaultValue = toString(defaultValue);
  2454. }
  2455. }
  2456. function postMountWrapper$3(element, props) {
  2457. var node = element; // This is in postMount because we need access to the DOM node, which is not
  2458. // available until after the component has mounted.
  2459. var textContent = node.textContent; // Only set node.value if textContent is equal to the expected
  2460. // initial value. In IE10/IE11 there is a bug where the placeholder attribute
  2461. // will populate textContent as well.
  2462. // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/
  2463. if (textContent === node._wrapperState.initialValue) {
  2464. if (textContent !== '' && textContent !== null) {
  2465. node.value = textContent;
  2466. }
  2467. }
  2468. }
  2469. function restoreControlledState$2(element, props) {
  2470. // DOM component is still mounted; update
  2471. updateWrapper$1(element, props);
  2472. }
  2473. var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
  2474. var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
  2475. var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  2476. var Namespaces = {
  2477. html: HTML_NAMESPACE,
  2478. mathml: MATH_NAMESPACE,
  2479. svg: SVG_NAMESPACE
  2480. }; // Assumes there is no parent namespace.
  2481. function getIntrinsicNamespace(type) {
  2482. switch (type) {
  2483. case 'svg':
  2484. return SVG_NAMESPACE;
  2485. case 'math':
  2486. return MATH_NAMESPACE;
  2487. default:
  2488. return HTML_NAMESPACE;
  2489. }
  2490. }
  2491. function getChildNamespace(parentNamespace, type) {
  2492. if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) {
  2493. // No (or default) parent namespace: potential entry point.
  2494. return getIntrinsicNamespace(type);
  2495. }
  2496. if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') {
  2497. // We're leaving SVG.
  2498. return HTML_NAMESPACE;
  2499. } // By default, pass namespace below.
  2500. return parentNamespace;
  2501. }
  2502. /* globals MSApp */
  2503. /**
  2504. * Create a function which has 'unsafe' privileges (required by windows8 apps)
  2505. */
  2506. var createMicrosoftUnsafeLocalFunction = function (func) {
  2507. if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
  2508. return function (arg0, arg1, arg2, arg3) {
  2509. MSApp.execUnsafeLocalFunction(function () {
  2510. return func(arg0, arg1, arg2, arg3);
  2511. });
  2512. };
  2513. } else {
  2514. return func;
  2515. }
  2516. };
  2517. var reusableSVGContainer;
  2518. /**
  2519. * Set the innerHTML property of a node
  2520. *
  2521. * @param {DOMElement} node
  2522. * @param {string} html
  2523. * @internal
  2524. */
  2525. var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
  2526. if (node.namespaceURI === Namespaces.svg) {
  2527. if (!('innerHTML' in node)) {
  2528. // IE does not have innerHTML for SVG nodes, so instead we inject the
  2529. // new markup in a temp node and then move the child nodes across into
  2530. // the target node
  2531. reusableSVGContainer = reusableSVGContainer || document.createElement('div');
  2532. reusableSVGContainer.innerHTML = '<svg>' + html.valueOf().toString() + '</svg>';
  2533. var svgNode = reusableSVGContainer.firstChild;
  2534. while (node.firstChild) {
  2535. node.removeChild(node.firstChild);
  2536. }
  2537. while (svgNode.firstChild) {
  2538. node.appendChild(svgNode.firstChild);
  2539. }
  2540. return;
  2541. }
  2542. }
  2543. node.innerHTML = html;
  2544. });
  2545. /**
  2546. * HTML nodeType values that represent the type of the node
  2547. */
  2548. var ELEMENT_NODE = 1;
  2549. var TEXT_NODE = 3;
  2550. var COMMENT_NODE = 8;
  2551. var DOCUMENT_NODE = 9;
  2552. var DOCUMENT_FRAGMENT_NODE = 11;
  2553. /**
  2554. * Set the textContent property of a node. For text updates, it's faster
  2555. * to set the `nodeValue` of the Text node directly instead of using
  2556. * `.textContent` which will remove the existing node and create a new one.
  2557. *
  2558. * @param {DOMElement} node
  2559. * @param {string} text
  2560. * @internal
  2561. */
  2562. var setTextContent = function (node, text) {
  2563. if (text) {
  2564. var firstChild = node.firstChild;
  2565. if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) {
  2566. firstChild.nodeValue = text;
  2567. return;
  2568. }
  2569. }
  2570. node.textContent = text;
  2571. };
  2572. // Do not use the below two methods directly!
  2573. // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
  2574. // (It is the only module that is allowed to access these methods.)
  2575. function unsafeCastStringToDOMTopLevelType(topLevelType) {
  2576. return topLevelType;
  2577. }
  2578. function unsafeCastDOMTopLevelTypeToString(topLevelType) {
  2579. return topLevelType;
  2580. }
  2581. /**
  2582. * Generate a mapping of standard vendor prefixes using the defined style property and event name.
  2583. *
  2584. * @param {string} styleProp
  2585. * @param {string} eventName
  2586. * @returns {object}
  2587. */
  2588. function makePrefixMap(styleProp, eventName) {
  2589. var prefixes = {};
  2590. prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
  2591. prefixes['Webkit' + styleProp] = 'webkit' + eventName;
  2592. prefixes['Moz' + styleProp] = 'moz' + eventName;
  2593. return prefixes;
  2594. }
  2595. /**
  2596. * A list of event names to a configurable list of vendor prefixes.
  2597. */
  2598. var vendorPrefixes = {
  2599. animationend: makePrefixMap('Animation', 'AnimationEnd'),
  2600. animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
  2601. animationstart: makePrefixMap('Animation', 'AnimationStart'),
  2602. transitionend: makePrefixMap('Transition', 'TransitionEnd')
  2603. };
  2604. /**
  2605. * Event names that have already been detected and prefixed (if applicable).
  2606. */
  2607. var prefixedEventNames = {};
  2608. /**
  2609. * Element to check for prefixes on.
  2610. */
  2611. var style = {};
  2612. /**
  2613. * Bootstrap if a DOM exists.
  2614. */
  2615. if (canUseDOM) {
  2616. style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x,
  2617. // the un-prefixed "animation" and "transition" properties are defined on the
  2618. // style object but the events that fire will still be prefixed, so we need
  2619. // to check if the un-prefixed events are usable, and if not remove them from the map.
  2620. if (!('AnimationEvent' in window)) {
  2621. delete vendorPrefixes.animationend.animation;
  2622. delete vendorPrefixes.animationiteration.animation;
  2623. delete vendorPrefixes.animationstart.animation;
  2624. } // Same as above
  2625. if (!('TransitionEvent' in window)) {
  2626. delete vendorPrefixes.transitionend.transition;
  2627. }
  2628. }
  2629. /**
  2630. * Attempts to determine the correct vendor prefixed event name.
  2631. *
  2632. * @param {string} eventName
  2633. * @returns {string}
  2634. */
  2635. function getVendorPrefixedEventName(eventName) {
  2636. if (prefixedEventNames[eventName]) {
  2637. return prefixedEventNames[eventName];
  2638. } else if (!vendorPrefixes[eventName]) {
  2639. return eventName;
  2640. }
  2641. var prefixMap = vendorPrefixes[eventName];
  2642. for (var styleProp in prefixMap) {
  2643. if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
  2644. return prefixedEventNames[eventName] = prefixMap[styleProp];
  2645. }
  2646. }
  2647. return eventName;
  2648. }
  2649. /**
  2650. * To identify top level events in ReactDOM, we use constants defined by this
  2651. * module. This is the only module that uses the unsafe* methods to express
  2652. * that the constants actually correspond to the browser event names. This lets
  2653. * us save some bundle size by avoiding a top level type -> event name map.
  2654. * The rest of ReactDOM code should import top level types from this file.
  2655. */
  2656. var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
  2657. var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
  2658. var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
  2659. var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
  2660. var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
  2661. var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
  2662. var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
  2663. var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
  2664. var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
  2665. var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
  2666. var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
  2667. var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
  2668. var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
  2669. var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
  2670. var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
  2671. var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
  2672. var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
  2673. var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
  2674. var TOP_AUX_CLICK = unsafeCastStringToDOMTopLevelType('auxclick');
  2675. var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
  2676. var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
  2677. var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
  2678. var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
  2679. var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
  2680. var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
  2681. var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
  2682. var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
  2683. var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
  2684. var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
  2685. var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
  2686. var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
  2687. var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
  2688. var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
  2689. var TOP_GOT_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('gotpointercapture');
  2690. var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
  2691. var TOP_INVALID = unsafeCastStringToDOMTopLevelType('invalid');
  2692. var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
  2693. var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
  2694. var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
  2695. var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
  2696. var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
  2697. var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
  2698. var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
  2699. var TOP_LOST_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('lostpointercapture');
  2700. var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
  2701. var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
  2702. var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
  2703. var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
  2704. var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
  2705. var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
  2706. var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
  2707. var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
  2708. var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
  2709. var TOP_POINTER_CANCEL = unsafeCastStringToDOMTopLevelType('pointercancel');
  2710. var TOP_POINTER_DOWN = unsafeCastStringToDOMTopLevelType('pointerdown');
  2711. var TOP_POINTER_MOVE = unsafeCastStringToDOMTopLevelType('pointermove');
  2712. var TOP_POINTER_OUT = unsafeCastStringToDOMTopLevelType('pointerout');
  2713. var TOP_POINTER_OVER = unsafeCastStringToDOMTopLevelType('pointerover');
  2714. var TOP_POINTER_UP = unsafeCastStringToDOMTopLevelType('pointerup');
  2715. var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
  2716. var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
  2717. var TOP_RESET = unsafeCastStringToDOMTopLevelType('reset');
  2718. var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
  2719. var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
  2720. var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
  2721. var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
  2722. var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
  2723. var TOP_SUBMIT = unsafeCastStringToDOMTopLevelType('submit');
  2724. var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
  2725. var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
  2726. var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
  2727. var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
  2728. var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
  2729. var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
  2730. var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
  2731. var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
  2732. var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
  2733. var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
  2734. var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
  2735. var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel'); // List of events that need to be individually attached to media elements.
  2736. // Note that events in this list will *not* be listened to at the top level
  2737. // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
  2738. var mediaEventTypes = [TOP_ABORT, TOP_CAN_PLAY, TOP_CAN_PLAY_THROUGH, TOP_DURATION_CHANGE, TOP_EMPTIED, TOP_ENCRYPTED, TOP_ENDED, TOP_ERROR, TOP_LOADED_DATA, TOP_LOADED_METADATA, TOP_LOAD_START, TOP_PAUSE, TOP_PLAY, TOP_PLAYING, TOP_PROGRESS, TOP_RATE_CHANGE, TOP_SEEKED, TOP_SEEKING, TOP_STALLED, TOP_SUSPEND, TOP_TIME_UPDATE, TOP_VOLUME_CHANGE, TOP_WAITING];
  2739. function getRawEventName(topLevelType) {
  2740. return unsafeCastDOMTopLevelTypeToString(topLevelType);
  2741. }
  2742. var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; // prettier-ignore
  2743. var elementListenerMap = new PossiblyWeakMap();
  2744. function getListenerMapForElement(element) {
  2745. var listenerMap = elementListenerMap.get(element);
  2746. if (listenerMap === undefined) {
  2747. listenerMap = new Map();
  2748. elementListenerMap.set(element, listenerMap);
  2749. }
  2750. return listenerMap;
  2751. }
  2752. /**
  2753. * `ReactInstanceMap` maintains a mapping from a public facing stateful
  2754. * instance (key) and the internal representation (value). This allows public
  2755. * methods to accept the user facing instance as an argument and map them back
  2756. * to internal methods.
  2757. *
  2758. * Note that this module is currently shared and assumed to be stateless.
  2759. * If this becomes an actual Map, that will break.
  2760. */
  2761. function get(key) {
  2762. return key._reactInternalFiber;
  2763. }
  2764. function has(key) {
  2765. return key._reactInternalFiber !== undefined;
  2766. }
  2767. function set(key, value) {
  2768. key._reactInternalFiber = value;
  2769. }
  2770. // Don't change these two values. They're used by React Dev Tools.
  2771. var NoEffect =
  2772. /* */
  2773. 0;
  2774. var PerformedWork =
  2775. /* */
  2776. 1; // You can change the rest (and add more).
  2777. var Placement =
  2778. /* */
  2779. 2;
  2780. var Update =
  2781. /* */
  2782. 4;
  2783. var PlacementAndUpdate =
  2784. /* */
  2785. 6;
  2786. var Deletion =
  2787. /* */
  2788. 8;
  2789. var ContentReset =
  2790. /* */
  2791. 16;
  2792. var Callback =
  2793. /* */
  2794. 32;
  2795. var DidCapture =
  2796. /* */
  2797. 64;
  2798. var Ref =
  2799. /* */
  2800. 128;
  2801. var Snapshot =
  2802. /* */
  2803. 256;
  2804. var Passive =
  2805. /* */
  2806. 512;
  2807. var Hydrating =
  2808. /* */
  2809. 1024;
  2810. var HydratingAndUpdate =
  2811. /* */
  2812. 1028; // Passive & Update & Callback & Ref & Snapshot
  2813. var LifecycleEffectMask =
  2814. /* */
  2815. 932; // Union of all host effects
  2816. var HostEffectMask =
  2817. /* */
  2818. 2047;
  2819. var Incomplete =
  2820. /* */
  2821. 2048;
  2822. var ShouldCapture =
  2823. /* */
  2824. 4096;
  2825. var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
  2826. function getNearestMountedFiber(fiber) {
  2827. var node = fiber;
  2828. var nearestMounted = fiber;
  2829. if (!fiber.alternate) {
  2830. // If there is no alternate, this might be a new tree that isn't inserted
  2831. // yet. If it is, then it will have a pending insertion effect on it.
  2832. var nextNode = node;
  2833. do {
  2834. node = nextNode;
  2835. if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
  2836. // This is an insertion or in-progress hydration. The nearest possible
  2837. // mounted fiber is the parent but we need to continue to figure out
  2838. // if that one is still mounted.
  2839. nearestMounted = node.return;
  2840. }
  2841. nextNode = node.return;
  2842. } while (nextNode);
  2843. } else {
  2844. while (node.return) {
  2845. node = node.return;
  2846. }
  2847. }
  2848. if (node.tag === HostRoot) {
  2849. // TODO: Check if this was a nested HostRoot when used with
  2850. // renderContainerIntoSubtree.
  2851. return nearestMounted;
  2852. } // If we didn't hit the root, that means that we're in an disconnected tree
  2853. // that has been unmounted.
  2854. return null;
  2855. }
  2856. function getSuspenseInstanceFromFiber(fiber) {
  2857. if (fiber.tag === SuspenseComponent) {
  2858. var suspenseState = fiber.memoizedState;
  2859. if (suspenseState === null) {
  2860. var current = fiber.alternate;
  2861. if (current !== null) {
  2862. suspenseState = current.memoizedState;
  2863. }
  2864. }
  2865. if (suspenseState !== null) {
  2866. return suspenseState.dehydrated;
  2867. }
  2868. }
  2869. return null;
  2870. }
  2871. function getContainerFromFiber(fiber) {
  2872. return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null;
  2873. }
  2874. function isFiberMounted(fiber) {
  2875. return getNearestMountedFiber(fiber) === fiber;
  2876. }
  2877. function isMounted(component) {
  2878. {
  2879. var owner = ReactCurrentOwner.current;
  2880. if (owner !== null && owner.tag === ClassComponent) {
  2881. var ownerFiber = owner;
  2882. var instance = ownerFiber.stateNode;
  2883. if (!instance._warnedAboutRefsInRender) {
  2884. error('%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber.type) || 'A component');
  2885. }
  2886. instance._warnedAboutRefsInRender = true;
  2887. }
  2888. }
  2889. var fiber = get(component);
  2890. if (!fiber) {
  2891. return false;
  2892. }
  2893. return getNearestMountedFiber(fiber) === fiber;
  2894. }
  2895. function assertIsMounted(fiber) {
  2896. if (!(getNearestMountedFiber(fiber) === fiber)) {
  2897. {
  2898. throw Error( "Unable to find node on an unmounted component." );
  2899. }
  2900. }
  2901. }
  2902. function findCurrentFiberUsingSlowPath(fiber) {
  2903. var alternate = fiber.alternate;
  2904. if (!alternate) {
  2905. // If there is no alternate, then we only need to check if it is mounted.
  2906. var nearestMounted = getNearestMountedFiber(fiber);
  2907. if (!(nearestMounted !== null)) {
  2908. {
  2909. throw Error( "Unable to find node on an unmounted component." );
  2910. }
  2911. }
  2912. if (nearestMounted !== fiber) {
  2913. return null;
  2914. }
  2915. return fiber;
  2916. } // If we have two possible branches, we'll walk backwards up to the root
  2917. // to see what path the root points to. On the way we may hit one of the
  2918. // special cases and we'll deal with them.
  2919. var a = fiber;
  2920. var b = alternate;
  2921. while (true) {
  2922. var parentA = a.return;
  2923. if (parentA === null) {
  2924. // We're at the root.
  2925. break;
  2926. }
  2927. var parentB = parentA.alternate;
  2928. if (parentB === null) {
  2929. // There is no alternate. This is an unusual case. Currently, it only
  2930. // happens when a Suspense component is hidden. An extra fragment fiber
  2931. // is inserted in between the Suspense fiber and its children. Skip
  2932. // over this extra fragment fiber and proceed to the next parent.
  2933. var nextParent = parentA.return;
  2934. if (nextParent !== null) {
  2935. a = b = nextParent;
  2936. continue;
  2937. } // If there's no parent, we're at the root.
  2938. break;
  2939. } // If both copies of the parent fiber point to the same child, we can
  2940. // assume that the child is current. This happens when we bailout on low
  2941. // priority: the bailed out fiber's child reuses the current child.
  2942. if (parentA.child === parentB.child) {
  2943. var child = parentA.child;
  2944. while (child) {
  2945. if (child === a) {
  2946. // We've determined that A is the current branch.
  2947. assertIsMounted(parentA);
  2948. return fiber;
  2949. }
  2950. if (child === b) {
  2951. // We've determined that B is the current branch.
  2952. assertIsMounted(parentA);
  2953. return alternate;
  2954. }
  2955. child = child.sibling;
  2956. } // We should never have an alternate for any mounting node. So the only
  2957. // way this could possibly happen is if this was unmounted, if at all.
  2958. {
  2959. {
  2960. throw Error( "Unable to find node on an unmounted component." );
  2961. }
  2962. }
  2963. }
  2964. if (a.return !== b.return) {
  2965. // The return pointer of A and the return pointer of B point to different
  2966. // fibers. We assume that return pointers never criss-cross, so A must
  2967. // belong to the child set of A.return, and B must belong to the child
  2968. // set of B.return.
  2969. a = parentA;
  2970. b = parentB;
  2971. } else {
  2972. // The return pointers point to the same fiber. We'll have to use the
  2973. // default, slow path: scan the child sets of each parent alternate to see
  2974. // which child belongs to which set.
  2975. //
  2976. // Search parent A's child set
  2977. var didFindChild = false;
  2978. var _child = parentA.child;
  2979. while (_child) {
  2980. if (_child === a) {
  2981. didFindChild = true;
  2982. a = parentA;
  2983. b = parentB;
  2984. break;
  2985. }
  2986. if (_child === b) {
  2987. didFindChild = true;
  2988. b = parentA;
  2989. a = parentB;
  2990. break;
  2991. }
  2992. _child = _child.sibling;
  2993. }
  2994. if (!didFindChild) {
  2995. // Search parent B's child set
  2996. _child = parentB.child;
  2997. while (_child) {
  2998. if (_child === a) {
  2999. didFindChild = true;
  3000. a = parentB;
  3001. b = parentA;
  3002. break;
  3003. }
  3004. if (_child === b) {
  3005. didFindChild = true;
  3006. b = parentB;
  3007. a = parentA;
  3008. break;
  3009. }
  3010. _child = _child.sibling;
  3011. }
  3012. if (!didFindChild) {
  3013. {
  3014. throw Error( "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." );
  3015. }
  3016. }
  3017. }
  3018. }
  3019. if (!(a.alternate === b)) {
  3020. {
  3021. throw Error( "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." );
  3022. }
  3023. }
  3024. } // If the root is not a host container, we're in a disconnected tree. I.e.
  3025. // unmounted.
  3026. if (!(a.tag === HostRoot)) {
  3027. {
  3028. throw Error( "Unable to find node on an unmounted component." );
  3029. }
  3030. }
  3031. if (a.stateNode.current === a) {
  3032. // We've determined that A is the current branch.
  3033. return fiber;
  3034. } // Otherwise B has to be current branch.
  3035. return alternate;
  3036. }
  3037. function findCurrentHostFiber(parent) {
  3038. var currentParent = findCurrentFiberUsingSlowPath(parent);
  3039. if (!currentParent) {
  3040. return null;
  3041. } // Next we'll drill down this component to find the first HostComponent/Text.
  3042. var node = currentParent;
  3043. while (true) {
  3044. if (node.tag === HostComponent || node.tag === HostText) {
  3045. return node;
  3046. } else if (node.child) {
  3047. node.child.return = node;
  3048. node = node.child;
  3049. continue;
  3050. }
  3051. if (node === currentParent) {
  3052. return null;
  3053. }
  3054. while (!node.sibling) {
  3055. if (!node.return || node.return === currentParent) {
  3056. return null;
  3057. }
  3058. node = node.return;
  3059. }
  3060. node.sibling.return = node.return;
  3061. node = node.sibling;
  3062. } // Flow needs the return null here, but ESLint complains about it.
  3063. // eslint-disable-next-line no-unreachable
  3064. return null;
  3065. }
  3066. function findCurrentHostFiberWithNoPortals(parent) {
  3067. var currentParent = findCurrentFiberUsingSlowPath(parent);
  3068. if (!currentParent) {
  3069. return null;
  3070. } // Next we'll drill down this component to find the first HostComponent/Text.
  3071. var node = currentParent;
  3072. while (true) {
  3073. if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI ) {
  3074. return node;
  3075. } else if (node.child && node.tag !== HostPortal) {
  3076. node.child.return = node;
  3077. node = node.child;
  3078. continue;
  3079. }
  3080. if (node === currentParent) {
  3081. return null;
  3082. }
  3083. while (!node.sibling) {
  3084. if (!node.return || node.return === currentParent) {
  3085. return null;
  3086. }
  3087. node = node.return;
  3088. }
  3089. node.sibling.return = node.return;
  3090. node = node.sibling;
  3091. } // Flow needs the return null here, but ESLint complains about it.
  3092. // eslint-disable-next-line no-unreachable
  3093. return null;
  3094. }
  3095. /**
  3096. * Accumulates items that must not be null or undefined into the first one. This
  3097. * is used to conserve memory by avoiding array allocations, and thus sacrifices
  3098. * API cleanness. Since `current` can be null before being passed in and not
  3099. * null after this function, make sure to assign it back to `current`:
  3100. *
  3101. * `a = accumulateInto(a, b);`
  3102. *
  3103. * This API should be sparingly used. Try `accumulate` for something cleaner.
  3104. *
  3105. * @return {*|array<*>} An accumulation of items.
  3106. */
  3107. function accumulateInto(current, next) {
  3108. if (!(next != null)) {
  3109. {
  3110. throw Error( "accumulateInto(...): Accumulated items must not be null or undefined." );
  3111. }
  3112. }
  3113. if (current == null) {
  3114. return next;
  3115. } // Both are not empty. Warning: Never call x.concat(y) when you are not
  3116. // certain that x is an Array (x could be a string with concat method).
  3117. if (Array.isArray(current)) {
  3118. if (Array.isArray(next)) {
  3119. current.push.apply(current, next);
  3120. return current;
  3121. }
  3122. current.push(next);
  3123. return current;
  3124. }
  3125. if (Array.isArray(next)) {
  3126. // A bit too dangerous to mutate `next`.
  3127. return [current].concat(next);
  3128. }
  3129. return [current, next];
  3130. }
  3131. /**
  3132. * @param {array} arr an "accumulation" of items which is either an Array or
  3133. * a single item. Useful when paired with the `accumulate` module. This is a
  3134. * simple utility that allows us to reason about a collection of items, but
  3135. * handling the case when there is exactly one item (and we do not need to
  3136. * allocate an array).
  3137. * @param {function} cb Callback invoked with each element or a collection.
  3138. * @param {?} [scope] Scope used as `this` in a callback.
  3139. */
  3140. function forEachAccumulated(arr, cb, scope) {
  3141. if (Array.isArray(arr)) {
  3142. arr.forEach(cb, scope);
  3143. } else if (arr) {
  3144. cb.call(scope, arr);
  3145. }
  3146. }
  3147. /**
  3148. * Internal queue of events that have accumulated their dispatches and are
  3149. * waiting to have their dispatches executed.
  3150. */
  3151. var eventQueue = null;
  3152. /**
  3153. * Dispatches an event and releases it back into the pool, unless persistent.
  3154. *
  3155. * @param {?object} event Synthetic event to be dispatched.
  3156. * @private
  3157. */
  3158. var executeDispatchesAndRelease = function (event) {
  3159. if (event) {
  3160. executeDispatchesInOrder(event);
  3161. if (!event.isPersistent()) {
  3162. event.constructor.release(event);
  3163. }
  3164. }
  3165. };
  3166. var executeDispatchesAndReleaseTopLevel = function (e) {
  3167. return executeDispatchesAndRelease(e);
  3168. };
  3169. function runEventsInBatch(events) {
  3170. if (events !== null) {
  3171. eventQueue = accumulateInto(eventQueue, events);
  3172. } // Set `eventQueue` to null before processing it so that we can tell if more
  3173. // events get enqueued while processing.
  3174. var processingEventQueue = eventQueue;
  3175. eventQueue = null;
  3176. if (!processingEventQueue) {
  3177. return;
  3178. }
  3179. forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
  3180. if (!!eventQueue) {
  3181. {
  3182. throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." );
  3183. }
  3184. } // This would be a good time to rethrow if any of the event handlers threw.
  3185. rethrowCaughtError();
  3186. }
  3187. /**
  3188. * Gets the target node from a native browser event by accounting for
  3189. * inconsistencies in browser DOM APIs.
  3190. *
  3191. * @param {object} nativeEvent Native browser event.
  3192. * @return {DOMEventTarget} Target node.
  3193. */
  3194. function getEventTarget(nativeEvent) {
  3195. // Fallback to nativeEvent.srcElement for IE9
  3196. // https://github.com/facebook/react/issues/12506
  3197. var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963
  3198. if (target.correspondingUseElement) {
  3199. target = target.correspondingUseElement;
  3200. } // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
  3201. // @see http://www.quirksmode.org/js/events_properties.html
  3202. return target.nodeType === TEXT_NODE ? target.parentNode : target;
  3203. }
  3204. /**
  3205. * Checks if an event is supported in the current execution environment.
  3206. *
  3207. * NOTE: This will not work correctly for non-generic events such as `change`,
  3208. * `reset`, `load`, `error`, and `select`.
  3209. *
  3210. * Borrows from Modernizr.
  3211. *
  3212. * @param {string} eventNameSuffix Event name, e.g. "click".
  3213. * @return {boolean} True if the event is supported.
  3214. * @internal
  3215. * @license Modernizr 3.0.0pre (Custom Build) | MIT
  3216. */
  3217. function isEventSupported(eventNameSuffix) {
  3218. if (!canUseDOM) {
  3219. return false;
  3220. }
  3221. var eventName = 'on' + eventNameSuffix;
  3222. var isSupported = eventName in document;
  3223. if (!isSupported) {
  3224. var element = document.createElement('div');
  3225. element.setAttribute(eventName, 'return;');
  3226. isSupported = typeof element[eventName] === 'function';
  3227. }
  3228. return isSupported;
  3229. }
  3230. /**
  3231. * Summary of `DOMEventPluginSystem` event handling:
  3232. *
  3233. * - Top-level delegation is used to trap most native browser events. This
  3234. * may only occur in the main thread and is the responsibility of
  3235. * ReactDOMEventListener, which is injected and can therefore support
  3236. * pluggable event sources. This is the only work that occurs in the main
  3237. * thread.
  3238. *
  3239. * - We normalize and de-duplicate events to account for browser quirks. This
  3240. * may be done in the worker thread.
  3241. *
  3242. * - Forward these native events (with the associated top-level type used to
  3243. * trap it) to `EventPluginRegistry`, which in turn will ask plugins if they want
  3244. * to extract any synthetic events.
  3245. *
  3246. * - The `EventPluginRegistry` will then process each event by annotating them with
  3247. * "dispatches", a sequence of listeners and IDs that care about that event.
  3248. *
  3249. * - The `EventPluginRegistry` then dispatches the events.
  3250. *
  3251. * Overview of React and the event system:
  3252. *
  3253. * +------------+ .
  3254. * | DOM | .
  3255. * +------------+ .
  3256. * | .
  3257. * v .
  3258. * +------------+ .
  3259. * | ReactEvent | .
  3260. * | Listener | .
  3261. * +------------+ . +-----------+
  3262. * | . +--------+|SimpleEvent|
  3263. * | . | |Plugin |
  3264. * +-----|------+ . v +-----------+
  3265. * | | | . +--------------+ +------------+
  3266. * | +-----------.--->|PluginRegistry| | Event |
  3267. * | | . | | +-----------+ | Propagators|
  3268. * | ReactEvent | . | | |TapEvent | |------------|
  3269. * | Emitter | . | |<---+|Plugin | |other plugin|
  3270. * | | . | | +-----------+ | utilities |
  3271. * | +-----------.--->| | +------------+
  3272. * | | | . +--------------+
  3273. * +-----|------+ . ^ +-----------+
  3274. * | . | |Enter/Leave|
  3275. * + . +-------+|Plugin |
  3276. * +-------------+ . +-----------+
  3277. * | application | .
  3278. * |-------------| .
  3279. * | | .
  3280. * | | .
  3281. * +-------------+ .
  3282. * .
  3283. * React Core . General Purpose Event Plugin System
  3284. */
  3285. var CALLBACK_BOOKKEEPING_POOL_SIZE = 10;
  3286. var callbackBookkeepingPool = [];
  3287. function releaseTopLevelCallbackBookKeeping(instance) {
  3288. instance.topLevelType = null;
  3289. instance.nativeEvent = null;
  3290. instance.targetInst = null;
  3291. instance.ancestors.length = 0;
  3292. if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) {
  3293. callbackBookkeepingPool.push(instance);
  3294. }
  3295. } // Used to store ancestor hierarchy in top level callback
  3296. function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags) {
  3297. if (callbackBookkeepingPool.length) {
  3298. var instance = callbackBookkeepingPool.pop();
  3299. instance.topLevelType = topLevelType;
  3300. instance.eventSystemFlags = eventSystemFlags;
  3301. instance.nativeEvent = nativeEvent;
  3302. instance.targetInst = targetInst;
  3303. return instance;
  3304. }
  3305. return {
  3306. topLevelType: topLevelType,
  3307. eventSystemFlags: eventSystemFlags,
  3308. nativeEvent: nativeEvent,
  3309. targetInst: targetInst,
  3310. ancestors: []
  3311. };
  3312. }
  3313. /**
  3314. * Find the deepest React component completely containing the root of the
  3315. * passed-in instance (for use when entire React trees are nested within each
  3316. * other). If React trees are not nested, returns null.
  3317. */
  3318. function findRootContainerNode(inst) {
  3319. if (inst.tag === HostRoot) {
  3320. return inst.stateNode.containerInfo;
  3321. } // TODO: It may be a good idea to cache this to prevent unnecessary DOM
  3322. // traversal, but caching is difficult to do correctly without using a
  3323. // mutation observer to listen for all DOM changes.
  3324. while (inst.return) {
  3325. inst = inst.return;
  3326. }
  3327. if (inst.tag !== HostRoot) {
  3328. // This can happen if we're in a detached tree.
  3329. return null;
  3330. }
  3331. return inst.stateNode.containerInfo;
  3332. }
  3333. /**
  3334. * Allows registered plugins an opportunity to extract events from top-level
  3335. * native browser events.
  3336. *
  3337. * @return {*} An accumulation of synthetic events.
  3338. * @internal
  3339. */
  3340. function extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  3341. var events = null;
  3342. for (var i = 0; i < plugins.length; i++) {
  3343. // Not every plugin in the ordering may be loaded at runtime.
  3344. var possiblePlugin = plugins[i];
  3345. if (possiblePlugin) {
  3346. var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
  3347. if (extractedEvents) {
  3348. events = accumulateInto(events, extractedEvents);
  3349. }
  3350. }
  3351. }
  3352. return events;
  3353. }
  3354. function runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  3355. var events = extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
  3356. runEventsInBatch(events);
  3357. }
  3358. function handleTopLevel(bookKeeping) {
  3359. var targetInst = bookKeeping.targetInst; // Loop through the hierarchy, in case there's any nested components.
  3360. // It's important that we build the array of ancestors before calling any
  3361. // event handlers, because event handlers can modify the DOM, leading to
  3362. // inconsistencies with ReactMount's node cache. See #1105.
  3363. var ancestor = targetInst;
  3364. do {
  3365. if (!ancestor) {
  3366. var ancestors = bookKeeping.ancestors;
  3367. ancestors.push(ancestor);
  3368. break;
  3369. }
  3370. var root = findRootContainerNode(ancestor);
  3371. if (!root) {
  3372. break;
  3373. }
  3374. var tag = ancestor.tag;
  3375. if (tag === HostComponent || tag === HostText) {
  3376. bookKeeping.ancestors.push(ancestor);
  3377. }
  3378. ancestor = getClosestInstanceFromNode(root);
  3379. } while (ancestor);
  3380. for (var i = 0; i < bookKeeping.ancestors.length; i++) {
  3381. targetInst = bookKeeping.ancestors[i];
  3382. var eventTarget = getEventTarget(bookKeeping.nativeEvent);
  3383. var topLevelType = bookKeeping.topLevelType;
  3384. var nativeEvent = bookKeeping.nativeEvent;
  3385. var eventSystemFlags = bookKeeping.eventSystemFlags; // If this is the first ancestor, we mark it on the system flags
  3386. if (i === 0) {
  3387. eventSystemFlags |= IS_FIRST_ANCESTOR;
  3388. }
  3389. runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, eventTarget, eventSystemFlags);
  3390. }
  3391. }
  3392. function dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst) {
  3393. var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags);
  3394. try {
  3395. // Event queue being processed in the same cycle allows
  3396. // `preventDefault`.
  3397. batchedEventUpdates(handleTopLevel, bookKeeping);
  3398. } finally {
  3399. releaseTopLevelCallbackBookKeeping(bookKeeping);
  3400. }
  3401. }
  3402. /**
  3403. * We listen for bubbled touch events on the document object.
  3404. *
  3405. * Firefox v8.01 (and possibly others) exhibited strange behavior when
  3406. * mounting `onmousemove` events at some node that was not the document
  3407. * element. The symptoms were that if your mouse is not moving over something
  3408. * contained within that mount point (for example on the background) the
  3409. * top-level listeners for `onmousemove` won't be called. However, if you
  3410. * register the `mousemove` on the document object, then it will of course
  3411. * catch all `mousemove`s. This along with iOS quirks, justifies restricting
  3412. * top-level listeners to the document object only, at least for these
  3413. * movement types of events and possibly all events.
  3414. *
  3415. * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  3416. *
  3417. * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
  3418. * they bubble to document.
  3419. *
  3420. * @param {string} registrationName Name of listener (e.g. `onClick`).
  3421. * @param {object} mountAt Container where to mount the listener
  3422. */
  3423. function legacyListenToEvent(registrationName, mountAt) {
  3424. var listenerMap = getListenerMapForElement(mountAt);
  3425. var dependencies = registrationNameDependencies[registrationName];
  3426. for (var i = 0; i < dependencies.length; i++) {
  3427. var dependency = dependencies[i];
  3428. legacyListenToTopLevelEvent(dependency, mountAt, listenerMap);
  3429. }
  3430. }
  3431. function legacyListenToTopLevelEvent(topLevelType, mountAt, listenerMap) {
  3432. if (!listenerMap.has(topLevelType)) {
  3433. switch (topLevelType) {
  3434. case TOP_SCROLL:
  3435. trapCapturedEvent(TOP_SCROLL, mountAt);
  3436. break;
  3437. case TOP_FOCUS:
  3438. case TOP_BLUR:
  3439. trapCapturedEvent(TOP_FOCUS, mountAt);
  3440. trapCapturedEvent(TOP_BLUR, mountAt); // We set the flag for a single dependency later in this function,
  3441. // but this ensures we mark both as attached rather than just one.
  3442. listenerMap.set(TOP_BLUR, null);
  3443. listenerMap.set(TOP_FOCUS, null);
  3444. break;
  3445. case TOP_CANCEL:
  3446. case TOP_CLOSE:
  3447. if (isEventSupported(getRawEventName(topLevelType))) {
  3448. trapCapturedEvent(topLevelType, mountAt);
  3449. }
  3450. break;
  3451. case TOP_INVALID:
  3452. case TOP_SUBMIT:
  3453. case TOP_RESET:
  3454. // We listen to them on the target DOM elements.
  3455. // Some of them bubble so we don't want them to fire twice.
  3456. break;
  3457. default:
  3458. // By default, listen on the top level to all non-media events.
  3459. // Media events don't bubble so adding the listener wouldn't do anything.
  3460. var isMediaEvent = mediaEventTypes.indexOf(topLevelType) !== -1;
  3461. if (!isMediaEvent) {
  3462. trapBubbledEvent(topLevelType, mountAt);
  3463. }
  3464. break;
  3465. }
  3466. listenerMap.set(topLevelType, null);
  3467. }
  3468. }
  3469. function isListeningToAllDependencies(registrationName, mountAt) {
  3470. var listenerMap = getListenerMapForElement(mountAt);
  3471. var dependencies = registrationNameDependencies[registrationName];
  3472. for (var i = 0; i < dependencies.length; i++) {
  3473. var dependency = dependencies[i];
  3474. if (!listenerMap.has(dependency)) {
  3475. return false;
  3476. }
  3477. }
  3478. return true;
  3479. }
  3480. var attemptUserBlockingHydration;
  3481. function setAttemptUserBlockingHydration(fn) {
  3482. attemptUserBlockingHydration = fn;
  3483. }
  3484. var attemptContinuousHydration;
  3485. function setAttemptContinuousHydration(fn) {
  3486. attemptContinuousHydration = fn;
  3487. }
  3488. var attemptHydrationAtCurrentPriority;
  3489. function setAttemptHydrationAtCurrentPriority(fn) {
  3490. attemptHydrationAtCurrentPriority = fn;
  3491. } // TODO: Upgrade this definition once we're on a newer version of Flow that
  3492. var hasScheduledReplayAttempt = false; // The queue of discrete events to be replayed.
  3493. var queuedDiscreteEvents = []; // Indicates if any continuous event targets are non-null for early bailout.
  3494. // if the last target was dehydrated.
  3495. var queuedFocus = null;
  3496. var queuedDrag = null;
  3497. var queuedMouse = null; // For pointer events there can be one latest event per pointerId.
  3498. var queuedPointers = new Map();
  3499. var queuedPointerCaptures = new Map(); // We could consider replaying selectionchange and touchmoves too.
  3500. var queuedExplicitHydrationTargets = [];
  3501. function hasQueuedDiscreteEvents() {
  3502. return queuedDiscreteEvents.length > 0;
  3503. }
  3504. var discreteReplayableEvents = [TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_TOUCH_START, TOP_AUX_CLICK, TOP_DOUBLE_CLICK, TOP_POINTER_CANCEL, TOP_POINTER_DOWN, TOP_POINTER_UP, TOP_DRAG_END, TOP_DRAG_START, TOP_DROP, TOP_COMPOSITION_END, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_INPUT, TOP_TEXT_INPUT, TOP_CLOSE, TOP_CANCEL, TOP_COPY, TOP_CUT, TOP_PASTE, TOP_CLICK, TOP_CHANGE, TOP_CONTEXT_MENU, TOP_RESET, TOP_SUBMIT];
  3505. var continuousReplayableEvents = [TOP_FOCUS, TOP_BLUR, TOP_DRAG_ENTER, TOP_DRAG_LEAVE, TOP_MOUSE_OVER, TOP_MOUSE_OUT, TOP_POINTER_OVER, TOP_POINTER_OUT, TOP_GOT_POINTER_CAPTURE, TOP_LOST_POINTER_CAPTURE];
  3506. function isReplayableDiscreteEvent(eventType) {
  3507. return discreteReplayableEvents.indexOf(eventType) > -1;
  3508. }
  3509. function trapReplayableEventForDocument(topLevelType, document, listenerMap) {
  3510. legacyListenToTopLevelEvent(topLevelType, document, listenerMap);
  3511. }
  3512. function eagerlyTrapReplayableEvents(container, document) {
  3513. var listenerMapForDoc = getListenerMapForElement(document); // Discrete
  3514. discreteReplayableEvents.forEach(function (topLevelType) {
  3515. trapReplayableEventForDocument(topLevelType, document, listenerMapForDoc);
  3516. }); // Continuous
  3517. continuousReplayableEvents.forEach(function (topLevelType) {
  3518. trapReplayableEventForDocument(topLevelType, document, listenerMapForDoc);
  3519. });
  3520. }
  3521. function createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) {
  3522. return {
  3523. blockedOn: blockedOn,
  3524. topLevelType: topLevelType,
  3525. eventSystemFlags: eventSystemFlags | IS_REPLAYED,
  3526. nativeEvent: nativeEvent,
  3527. container: container
  3528. };
  3529. }
  3530. function queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) {
  3531. var queuedEvent = createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent);
  3532. queuedDiscreteEvents.push(queuedEvent);
  3533. } // Resets the replaying for this type of continuous event to no event.
  3534. function clearIfContinuousEvent(topLevelType, nativeEvent) {
  3535. switch (topLevelType) {
  3536. case TOP_FOCUS:
  3537. case TOP_BLUR:
  3538. queuedFocus = null;
  3539. break;
  3540. case TOP_DRAG_ENTER:
  3541. case TOP_DRAG_LEAVE:
  3542. queuedDrag = null;
  3543. break;
  3544. case TOP_MOUSE_OVER:
  3545. case TOP_MOUSE_OUT:
  3546. queuedMouse = null;
  3547. break;
  3548. case TOP_POINTER_OVER:
  3549. case TOP_POINTER_OUT:
  3550. {
  3551. var pointerId = nativeEvent.pointerId;
  3552. queuedPointers.delete(pointerId);
  3553. break;
  3554. }
  3555. case TOP_GOT_POINTER_CAPTURE:
  3556. case TOP_LOST_POINTER_CAPTURE:
  3557. {
  3558. var _pointerId = nativeEvent.pointerId;
  3559. queuedPointerCaptures.delete(_pointerId);
  3560. break;
  3561. }
  3562. }
  3563. }
  3564. function accumulateOrCreateContinuousQueuedReplayableEvent(existingQueuedEvent, blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) {
  3565. if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) {
  3566. var queuedEvent = createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent);
  3567. if (blockedOn !== null) {
  3568. var _fiber2 = getInstanceFromNode$1(blockedOn);
  3569. if (_fiber2 !== null) {
  3570. // Attempt to increase the priority of this target.
  3571. attemptContinuousHydration(_fiber2);
  3572. }
  3573. }
  3574. return queuedEvent;
  3575. } // If we have already queued this exact event, then it's because
  3576. // the different event systems have different DOM event listeners.
  3577. // We can accumulate the flags and store a single event to be
  3578. // replayed.
  3579. existingQueuedEvent.eventSystemFlags |= eventSystemFlags;
  3580. return existingQueuedEvent;
  3581. }
  3582. function queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent) {
  3583. // These set relatedTarget to null because the replayed event will be treated as if we
  3584. // moved from outside the window (no target) onto the target once it hydrates.
  3585. // Instead of mutating we could clone the event.
  3586. switch (topLevelType) {
  3587. case TOP_FOCUS:
  3588. {
  3589. var focusEvent = nativeEvent;
  3590. queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(queuedFocus, blockedOn, topLevelType, eventSystemFlags, container, focusEvent);
  3591. return true;
  3592. }
  3593. case TOP_DRAG_ENTER:
  3594. {
  3595. var dragEvent = nativeEvent;
  3596. queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(queuedDrag, blockedOn, topLevelType, eventSystemFlags, container, dragEvent);
  3597. return true;
  3598. }
  3599. case TOP_MOUSE_OVER:
  3600. {
  3601. var mouseEvent = nativeEvent;
  3602. queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(queuedMouse, blockedOn, topLevelType, eventSystemFlags, container, mouseEvent);
  3603. return true;
  3604. }
  3605. case TOP_POINTER_OVER:
  3606. {
  3607. var pointerEvent = nativeEvent;
  3608. var pointerId = pointerEvent.pointerId;
  3609. queuedPointers.set(pointerId, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, topLevelType, eventSystemFlags, container, pointerEvent));
  3610. return true;
  3611. }
  3612. case TOP_GOT_POINTER_CAPTURE:
  3613. {
  3614. var _pointerEvent = nativeEvent;
  3615. var _pointerId2 = _pointerEvent.pointerId;
  3616. queuedPointerCaptures.set(_pointerId2, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, topLevelType, eventSystemFlags, container, _pointerEvent));
  3617. return true;
  3618. }
  3619. }
  3620. return false;
  3621. } // Check if this target is unblocked. Returns true if it's unblocked.
  3622. function attemptExplicitHydrationTarget(queuedTarget) {
  3623. // TODO: This function shares a lot of logic with attemptToDispatchEvent.
  3624. // Try to unify them. It's a bit tricky since it would require two return
  3625. // values.
  3626. var targetInst = getClosestInstanceFromNode(queuedTarget.target);
  3627. if (targetInst !== null) {
  3628. var nearestMounted = getNearestMountedFiber(targetInst);
  3629. if (nearestMounted !== null) {
  3630. var tag = nearestMounted.tag;
  3631. if (tag === SuspenseComponent) {
  3632. var instance = getSuspenseInstanceFromFiber(nearestMounted);
  3633. if (instance !== null) {
  3634. // We're blocked on hydrating this boundary.
  3635. // Increase its priority.
  3636. queuedTarget.blockedOn = instance;
  3637. Scheduler.unstable_runWithPriority(queuedTarget.priority, function () {
  3638. attemptHydrationAtCurrentPriority(nearestMounted);
  3639. });
  3640. return;
  3641. }
  3642. } else if (tag === HostRoot) {
  3643. var root = nearestMounted.stateNode;
  3644. if (root.hydrate) {
  3645. queuedTarget.blockedOn = getContainerFromFiber(nearestMounted); // We don't currently have a way to increase the priority of
  3646. // a root other than sync.
  3647. return;
  3648. }
  3649. }
  3650. }
  3651. }
  3652. queuedTarget.blockedOn = null;
  3653. }
  3654. function attemptReplayContinuousQueuedEvent(queuedEvent) {
  3655. if (queuedEvent.blockedOn !== null) {
  3656. return false;
  3657. }
  3658. var nextBlockedOn = attemptToDispatchEvent(queuedEvent.topLevelType, queuedEvent.eventSystemFlags, queuedEvent.container, queuedEvent.nativeEvent);
  3659. if (nextBlockedOn !== null) {
  3660. // We're still blocked. Try again later.
  3661. var _fiber3 = getInstanceFromNode$1(nextBlockedOn);
  3662. if (_fiber3 !== null) {
  3663. attemptContinuousHydration(_fiber3);
  3664. }
  3665. queuedEvent.blockedOn = nextBlockedOn;
  3666. return false;
  3667. }
  3668. return true;
  3669. }
  3670. function attemptReplayContinuousQueuedEventInMap(queuedEvent, key, map) {
  3671. if (attemptReplayContinuousQueuedEvent(queuedEvent)) {
  3672. map.delete(key);
  3673. }
  3674. }
  3675. function replayUnblockedEvents() {
  3676. hasScheduledReplayAttempt = false; // First replay discrete events.
  3677. while (queuedDiscreteEvents.length > 0) {
  3678. var nextDiscreteEvent = queuedDiscreteEvents[0];
  3679. if (nextDiscreteEvent.blockedOn !== null) {
  3680. // We're still blocked.
  3681. // Increase the priority of this boundary to unblock
  3682. // the next discrete event.
  3683. var _fiber4 = getInstanceFromNode$1(nextDiscreteEvent.blockedOn);
  3684. if (_fiber4 !== null) {
  3685. attemptUserBlockingHydration(_fiber4);
  3686. }
  3687. break;
  3688. }
  3689. var nextBlockedOn = attemptToDispatchEvent(nextDiscreteEvent.topLevelType, nextDiscreteEvent.eventSystemFlags, nextDiscreteEvent.container, nextDiscreteEvent.nativeEvent);
  3690. if (nextBlockedOn !== null) {
  3691. // We're still blocked. Try again later.
  3692. nextDiscreteEvent.blockedOn = nextBlockedOn;
  3693. } else {
  3694. // We've successfully replayed the first event. Let's try the next one.
  3695. queuedDiscreteEvents.shift();
  3696. }
  3697. } // Next replay any continuous events.
  3698. if (queuedFocus !== null && attemptReplayContinuousQueuedEvent(queuedFocus)) {
  3699. queuedFocus = null;
  3700. }
  3701. if (queuedDrag !== null && attemptReplayContinuousQueuedEvent(queuedDrag)) {
  3702. queuedDrag = null;
  3703. }
  3704. if (queuedMouse !== null && attemptReplayContinuousQueuedEvent(queuedMouse)) {
  3705. queuedMouse = null;
  3706. }
  3707. queuedPointers.forEach(attemptReplayContinuousQueuedEventInMap);
  3708. queuedPointerCaptures.forEach(attemptReplayContinuousQueuedEventInMap);
  3709. }
  3710. function scheduleCallbackIfUnblocked(queuedEvent, unblocked) {
  3711. if (queuedEvent.blockedOn === unblocked) {
  3712. queuedEvent.blockedOn = null;
  3713. if (!hasScheduledReplayAttempt) {
  3714. hasScheduledReplayAttempt = true; // Schedule a callback to attempt replaying as many events as are
  3715. // now unblocked. This first might not actually be unblocked yet.
  3716. // We could check it early to avoid scheduling an unnecessary callback.
  3717. Scheduler.unstable_scheduleCallback(Scheduler.unstable_NormalPriority, replayUnblockedEvents);
  3718. }
  3719. }
  3720. }
  3721. function retryIfBlockedOn(unblocked) {
  3722. // Mark anything that was blocked on this as no longer blocked
  3723. // and eligible for a replay.
  3724. if (queuedDiscreteEvents.length > 0) {
  3725. scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked); // This is a exponential search for each boundary that commits. I think it's
  3726. // worth it because we expect very few discrete events to queue up and once
  3727. // we are actually fully unblocked it will be fast to replay them.
  3728. for (var i = 1; i < queuedDiscreteEvents.length; i++) {
  3729. var queuedEvent = queuedDiscreteEvents[i];
  3730. if (queuedEvent.blockedOn === unblocked) {
  3731. queuedEvent.blockedOn = null;
  3732. }
  3733. }
  3734. }
  3735. if (queuedFocus !== null) {
  3736. scheduleCallbackIfUnblocked(queuedFocus, unblocked);
  3737. }
  3738. if (queuedDrag !== null) {
  3739. scheduleCallbackIfUnblocked(queuedDrag, unblocked);
  3740. }
  3741. if (queuedMouse !== null) {
  3742. scheduleCallbackIfUnblocked(queuedMouse, unblocked);
  3743. }
  3744. var unblock = function (queuedEvent) {
  3745. return scheduleCallbackIfUnblocked(queuedEvent, unblocked);
  3746. };
  3747. queuedPointers.forEach(unblock);
  3748. queuedPointerCaptures.forEach(unblock);
  3749. for (var _i = 0; _i < queuedExplicitHydrationTargets.length; _i++) {
  3750. var queuedTarget = queuedExplicitHydrationTargets[_i];
  3751. if (queuedTarget.blockedOn === unblocked) {
  3752. queuedTarget.blockedOn = null;
  3753. }
  3754. }
  3755. while (queuedExplicitHydrationTargets.length > 0) {
  3756. var nextExplicitTarget = queuedExplicitHydrationTargets[0];
  3757. if (nextExplicitTarget.blockedOn !== null) {
  3758. // We're still blocked.
  3759. break;
  3760. } else {
  3761. attemptExplicitHydrationTarget(nextExplicitTarget);
  3762. if (nextExplicitTarget.blockedOn === null) {
  3763. // We're unblocked.
  3764. queuedExplicitHydrationTargets.shift();
  3765. }
  3766. }
  3767. }
  3768. }
  3769. function addEventBubbleListener(element, eventType, listener) {
  3770. element.addEventListener(eventType, listener, false);
  3771. }
  3772. function addEventCaptureListener(element, eventType, listener) {
  3773. element.addEventListener(eventType, listener, true);
  3774. }
  3775. // do it in two places, which duplicates logic
  3776. // and increases the bundle size, we do it all
  3777. // here once. If we remove or refactor the
  3778. // SimpleEventPlugin, we should also remove or
  3779. // update the below line.
  3780. var simpleEventPluginEventTypes = {};
  3781. var topLevelEventsToDispatchConfig = new Map();
  3782. var eventPriorities = new Map(); // We store most of the events in this module in pairs of two strings so we can re-use
  3783. // the code required to apply the same logic for event prioritization and that of the
  3784. // SimpleEventPlugin. This complicates things slightly, but the aim is to reduce code
  3785. // duplication (for which there would be quite a bit). For the events that are not needed
  3786. // for the SimpleEventPlugin (otherDiscreteEvents) we process them separately as an
  3787. // array of top level events.
  3788. // Lastly, we ignore prettier so we can keep the formatting sane.
  3789. // prettier-ignore
  3790. var discreteEventPairsForSimpleEventPlugin = [TOP_BLUR, 'blur', TOP_CANCEL, 'cancel', TOP_CLICK, 'click', TOP_CLOSE, 'close', TOP_CONTEXT_MENU, 'contextMenu', TOP_COPY, 'copy', TOP_CUT, 'cut', TOP_AUX_CLICK, 'auxClick', TOP_DOUBLE_CLICK, 'doubleClick', TOP_DRAG_END, 'dragEnd', TOP_DRAG_START, 'dragStart', TOP_DROP, 'drop', TOP_FOCUS, 'focus', TOP_INPUT, 'input', TOP_INVALID, 'invalid', TOP_KEY_DOWN, 'keyDown', TOP_KEY_PRESS, 'keyPress', TOP_KEY_UP, 'keyUp', TOP_MOUSE_DOWN, 'mouseDown', TOP_MOUSE_UP, 'mouseUp', TOP_PASTE, 'paste', TOP_PAUSE, 'pause', TOP_PLAY, 'play', TOP_POINTER_CANCEL, 'pointerCancel', TOP_POINTER_DOWN, 'pointerDown', TOP_POINTER_UP, 'pointerUp', TOP_RATE_CHANGE, 'rateChange', TOP_RESET, 'reset', TOP_SEEKED, 'seeked', TOP_SUBMIT, 'submit', TOP_TOUCH_CANCEL, 'touchCancel', TOP_TOUCH_END, 'touchEnd', TOP_TOUCH_START, 'touchStart', TOP_VOLUME_CHANGE, 'volumeChange'];
  3791. var otherDiscreteEvents = [TOP_CHANGE, TOP_SELECTION_CHANGE, TOP_TEXT_INPUT, TOP_COMPOSITION_START, TOP_COMPOSITION_END, TOP_COMPOSITION_UPDATE]; // prettier-ignore
  3792. var userBlockingPairsForSimpleEventPlugin = [TOP_DRAG, 'drag', TOP_DRAG_ENTER, 'dragEnter', TOP_DRAG_EXIT, 'dragExit', TOP_DRAG_LEAVE, 'dragLeave', TOP_DRAG_OVER, 'dragOver', TOP_MOUSE_MOVE, 'mouseMove', TOP_MOUSE_OUT, 'mouseOut', TOP_MOUSE_OVER, 'mouseOver', TOP_POINTER_MOVE, 'pointerMove', TOP_POINTER_OUT, 'pointerOut', TOP_POINTER_OVER, 'pointerOver', TOP_SCROLL, 'scroll', TOP_TOGGLE, 'toggle', TOP_TOUCH_MOVE, 'touchMove', TOP_WHEEL, 'wheel']; // prettier-ignore
  3793. var continuousPairsForSimpleEventPlugin = [TOP_ABORT, 'abort', TOP_ANIMATION_END, 'animationEnd', TOP_ANIMATION_ITERATION, 'animationIteration', TOP_ANIMATION_START, 'animationStart', TOP_CAN_PLAY, 'canPlay', TOP_CAN_PLAY_THROUGH, 'canPlayThrough', TOP_DURATION_CHANGE, 'durationChange', TOP_EMPTIED, 'emptied', TOP_ENCRYPTED, 'encrypted', TOP_ENDED, 'ended', TOP_ERROR, 'error', TOP_GOT_POINTER_CAPTURE, 'gotPointerCapture', TOP_LOAD, 'load', TOP_LOADED_DATA, 'loadedData', TOP_LOADED_METADATA, 'loadedMetadata', TOP_LOAD_START, 'loadStart', TOP_LOST_POINTER_CAPTURE, 'lostPointerCapture', TOP_PLAYING, 'playing', TOP_PROGRESS, 'progress', TOP_SEEKING, 'seeking', TOP_STALLED, 'stalled', TOP_SUSPEND, 'suspend', TOP_TIME_UPDATE, 'timeUpdate', TOP_TRANSITION_END, 'transitionEnd', TOP_WAITING, 'waiting'];
  3794. /**
  3795. * Turns
  3796. * ['abort', ...]
  3797. * into
  3798. * eventTypes = {
  3799. * 'abort': {
  3800. * phasedRegistrationNames: {
  3801. * bubbled: 'onAbort',
  3802. * captured: 'onAbortCapture',
  3803. * },
  3804. * dependencies: [TOP_ABORT],
  3805. * },
  3806. * ...
  3807. * };
  3808. * topLevelEventsToDispatchConfig = new Map([
  3809. * [TOP_ABORT, { sameConfig }],
  3810. * ]);
  3811. */
  3812. function processSimpleEventPluginPairsByPriority(eventTypes, priority) {
  3813. // As the event types are in pairs of two, we need to iterate
  3814. // through in twos. The events are in pairs of two to save code
  3815. // and improve init perf of processing this array, as it will
  3816. // result in far fewer object allocations and property accesses
  3817. // if we only use three arrays to process all the categories of
  3818. // instead of tuples.
  3819. for (var i = 0; i < eventTypes.length; i += 2) {
  3820. var topEvent = eventTypes[i];
  3821. var event = eventTypes[i + 1];
  3822. var capitalizedEvent = event[0].toUpperCase() + event.slice(1);
  3823. var onEvent = 'on' + capitalizedEvent;
  3824. var config = {
  3825. phasedRegistrationNames: {
  3826. bubbled: onEvent,
  3827. captured: onEvent + 'Capture'
  3828. },
  3829. dependencies: [topEvent],
  3830. eventPriority: priority
  3831. };
  3832. eventPriorities.set(topEvent, priority);
  3833. topLevelEventsToDispatchConfig.set(topEvent, config);
  3834. simpleEventPluginEventTypes[event] = config;
  3835. }
  3836. }
  3837. function processTopEventPairsByPriority(eventTypes, priority) {
  3838. for (var i = 0; i < eventTypes.length; i++) {
  3839. eventPriorities.set(eventTypes[i], priority);
  3840. }
  3841. } // SimpleEventPlugin
  3842. processSimpleEventPluginPairsByPriority(discreteEventPairsForSimpleEventPlugin, DiscreteEvent);
  3843. processSimpleEventPluginPairsByPriority(userBlockingPairsForSimpleEventPlugin, UserBlockingEvent);
  3844. processSimpleEventPluginPairsByPriority(continuousPairsForSimpleEventPlugin, ContinuousEvent); // Not used by SimpleEventPlugin
  3845. processTopEventPairsByPriority(otherDiscreteEvents, DiscreteEvent);
  3846. function getEventPriorityForPluginSystem(topLevelType) {
  3847. var priority = eventPriorities.get(topLevelType); // Default to a ContinuousEvent. Note: we might
  3848. // want to warn if we can't detect the priority
  3849. // for the event.
  3850. return priority === undefined ? ContinuousEvent : priority;
  3851. }
  3852. // Intentionally not named imports because Rollup would use dynamic dispatch for
  3853. var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority,
  3854. runWithPriority = Scheduler.unstable_runWithPriority; // TODO: can we stop exporting these?
  3855. var _enabled = true;
  3856. function setEnabled(enabled) {
  3857. _enabled = !!enabled;
  3858. }
  3859. function isEnabled() {
  3860. return _enabled;
  3861. }
  3862. function trapBubbledEvent(topLevelType, element) {
  3863. trapEventForPluginEventSystem(element, topLevelType, false);
  3864. }
  3865. function trapCapturedEvent(topLevelType, element) {
  3866. trapEventForPluginEventSystem(element, topLevelType, true);
  3867. }
  3868. function trapEventForPluginEventSystem(container, topLevelType, capture) {
  3869. var listener;
  3870. switch (getEventPriorityForPluginSystem(topLevelType)) {
  3871. case DiscreteEvent:
  3872. listener = dispatchDiscreteEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container);
  3873. break;
  3874. case UserBlockingEvent:
  3875. listener = dispatchUserBlockingUpdate.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container);
  3876. break;
  3877. case ContinuousEvent:
  3878. default:
  3879. listener = dispatchEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM, container);
  3880. break;
  3881. }
  3882. var rawEventName = getRawEventName(topLevelType);
  3883. if (capture) {
  3884. addEventCaptureListener(container, rawEventName, listener);
  3885. } else {
  3886. addEventBubbleListener(container, rawEventName, listener);
  3887. }
  3888. }
  3889. function dispatchDiscreteEvent(topLevelType, eventSystemFlags, container, nativeEvent) {
  3890. flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp);
  3891. discreteUpdates(dispatchEvent, topLevelType, eventSystemFlags, container, nativeEvent);
  3892. }
  3893. function dispatchUserBlockingUpdate(topLevelType, eventSystemFlags, container, nativeEvent) {
  3894. runWithPriority(UserBlockingPriority, dispatchEvent.bind(null, topLevelType, eventSystemFlags, container, nativeEvent));
  3895. }
  3896. function dispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent) {
  3897. if (!_enabled) {
  3898. return;
  3899. }
  3900. if (hasQueuedDiscreteEvents() && isReplayableDiscreteEvent(topLevelType)) {
  3901. // If we already have a queue of discrete events, and this is another discrete
  3902. // event, then we can't dispatch it regardless of its target, since they
  3903. // need to dispatch in order.
  3904. queueDiscreteEvent(null, // Flags that we're not actually blocked on anything as far as we know.
  3905. topLevelType, eventSystemFlags, container, nativeEvent);
  3906. return;
  3907. }
  3908. var blockedOn = attemptToDispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent);
  3909. if (blockedOn === null) {
  3910. // We successfully dispatched this event.
  3911. clearIfContinuousEvent(topLevelType, nativeEvent);
  3912. return;
  3913. }
  3914. if (isReplayableDiscreteEvent(topLevelType)) {
  3915. // This this to be replayed later once the target is available.
  3916. queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent);
  3917. return;
  3918. }
  3919. if (queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, container, nativeEvent)) {
  3920. return;
  3921. } // We need to clear only if we didn't queue because
  3922. // queueing is accummulative.
  3923. clearIfContinuousEvent(topLevelType, nativeEvent); // This is not replayable so we'll invoke it but without a target,
  3924. // in case the event system needs to trace it.
  3925. {
  3926. dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, null);
  3927. }
  3928. } // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked.
  3929. function attemptToDispatchEvent(topLevelType, eventSystemFlags, container, nativeEvent) {
  3930. // TODO: Warn if _enabled is false.
  3931. var nativeEventTarget = getEventTarget(nativeEvent);
  3932. var targetInst = getClosestInstanceFromNode(nativeEventTarget);
  3933. if (targetInst !== null) {
  3934. var nearestMounted = getNearestMountedFiber(targetInst);
  3935. if (nearestMounted === null) {
  3936. // This tree has been unmounted already. Dispatch without a target.
  3937. targetInst = null;
  3938. } else {
  3939. var tag = nearestMounted.tag;
  3940. if (tag === SuspenseComponent) {
  3941. var instance = getSuspenseInstanceFromFiber(nearestMounted);
  3942. if (instance !== null) {
  3943. // Queue the event to be replayed later. Abort dispatching since we
  3944. // don't want this event dispatched twice through the event system.
  3945. // TODO: If this is the first discrete event in the queue. Schedule an increased
  3946. // priority for this boundary.
  3947. return instance;
  3948. } // This shouldn't happen, something went wrong but to avoid blocking
  3949. // the whole system, dispatch the event without a target.
  3950. // TODO: Warn.
  3951. targetInst = null;
  3952. } else if (tag === HostRoot) {
  3953. var root = nearestMounted.stateNode;
  3954. if (root.hydrate) {
  3955. // If this happens during a replay something went wrong and it might block
  3956. // the whole system.
  3957. return getContainerFromFiber(nearestMounted);
  3958. }
  3959. targetInst = null;
  3960. } else if (nearestMounted !== targetInst) {
  3961. // If we get an event (ex: img onload) before committing that
  3962. // component's mount, ignore it for now (that is, treat it as if it was an
  3963. // event on a non-React tree). We might also consider queueing events and
  3964. // dispatching them after the mount.
  3965. targetInst = null;
  3966. }
  3967. }
  3968. }
  3969. {
  3970. dispatchEventForLegacyPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst);
  3971. } // We're not blocked on anything.
  3972. return null;
  3973. }
  3974. // List derived from Gecko source code:
  3975. // https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js
  3976. var shorthandToLonghand = {
  3977. animation: ['animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction'],
  3978. background: ['backgroundAttachment', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundSize'],
  3979. backgroundPosition: ['backgroundPositionX', 'backgroundPositionY'],
  3980. border: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderTopColor', 'borderTopStyle', 'borderTopWidth'],
  3981. borderBlockEnd: ['borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth'],
  3982. borderBlockStart: ['borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth'],
  3983. borderBottom: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth'],
  3984. borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'],
  3985. borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'],
  3986. borderInlineEnd: ['borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth'],
  3987. borderInlineStart: ['borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth'],
  3988. borderLeft: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth'],
  3989. borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'],
  3990. borderRight: ['borderRightColor', 'borderRightStyle', 'borderRightWidth'],
  3991. borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'],
  3992. borderTop: ['borderTopColor', 'borderTopStyle', 'borderTopWidth'],
  3993. borderWidth: ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth'],
  3994. columnRule: ['columnRuleColor', 'columnRuleStyle', 'columnRuleWidth'],
  3995. columns: ['columnCount', 'columnWidth'],
  3996. flex: ['flexBasis', 'flexGrow', 'flexShrink'],
  3997. flexFlow: ['flexDirection', 'flexWrap'],
  3998. font: ['fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontLanguageOverride', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition', 'fontWeight', 'lineHeight'],
  3999. fontVariant: ['fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition'],
  4000. gap: ['columnGap', 'rowGap'],
  4001. grid: ['gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'],
  4002. gridArea: ['gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart'],
  4003. gridColumn: ['gridColumnEnd', 'gridColumnStart'],
  4004. gridColumnGap: ['columnGap'],
  4005. gridGap: ['columnGap', 'rowGap'],
  4006. gridRow: ['gridRowEnd', 'gridRowStart'],
  4007. gridRowGap: ['rowGap'],
  4008. gridTemplate: ['gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'],
  4009. listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'],
  4010. margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'],
  4011. marker: ['markerEnd', 'markerMid', 'markerStart'],
  4012. mask: ['maskClip', 'maskComposite', 'maskImage', 'maskMode', 'maskOrigin', 'maskPositionX', 'maskPositionY', 'maskRepeat', 'maskSize'],
  4013. maskPosition: ['maskPositionX', 'maskPositionY'],
  4014. outline: ['outlineColor', 'outlineStyle', 'outlineWidth'],
  4015. overflow: ['overflowX', 'overflowY'],
  4016. padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'],
  4017. placeContent: ['alignContent', 'justifyContent'],
  4018. placeItems: ['alignItems', 'justifyItems'],
  4019. placeSelf: ['alignSelf', 'justifySelf'],
  4020. textDecoration: ['textDecorationColor', 'textDecorationLine', 'textDecorationStyle'],
  4021. textEmphasis: ['textEmphasisColor', 'textEmphasisStyle'],
  4022. transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'],
  4023. wordWrap: ['overflowWrap']
  4024. };
  4025. /**
  4026. * CSS properties which accept numbers but are not in units of "px".
  4027. */
  4028. var isUnitlessNumber = {
  4029. animationIterationCount: true,
  4030. borderImageOutset: true,
  4031. borderImageSlice: true,
  4032. borderImageWidth: true,
  4033. boxFlex: true,
  4034. boxFlexGroup: true,
  4035. boxOrdinalGroup: true,
  4036. columnCount: true,
  4037. columns: true,
  4038. flex: true,
  4039. flexGrow: true,
  4040. flexPositive: true,
  4041. flexShrink: true,
  4042. flexNegative: true,
  4043. flexOrder: true,
  4044. gridArea: true,
  4045. gridRow: true,
  4046. gridRowEnd: true,
  4047. gridRowSpan: true,
  4048. gridRowStart: true,
  4049. gridColumn: true,
  4050. gridColumnEnd: true,
  4051. gridColumnSpan: true,
  4052. gridColumnStart: true,
  4053. fontWeight: true,
  4054. lineClamp: true,
  4055. lineHeight: true,
  4056. opacity: true,
  4057. order: true,
  4058. orphans: true,
  4059. tabSize: true,
  4060. widows: true,
  4061. zIndex: true,
  4062. zoom: true,
  4063. // SVG-related properties
  4064. fillOpacity: true,
  4065. floodOpacity: true,
  4066. stopOpacity: true,
  4067. strokeDasharray: true,
  4068. strokeDashoffset: true,
  4069. strokeMiterlimit: true,
  4070. strokeOpacity: true,
  4071. strokeWidth: true
  4072. };
  4073. /**
  4074. * @param {string} prefix vendor-specific prefix, eg: Webkit
  4075. * @param {string} key style name, eg: transitionDuration
  4076. * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
  4077. * WebkitTransitionDuration
  4078. */
  4079. function prefixKey(prefix, key) {
  4080. return prefix + key.charAt(0).toUpperCase() + key.substring(1);
  4081. }
  4082. /**
  4083. * Support style names that may come passed in prefixed by adding permutations
  4084. * of vendor prefixes.
  4085. */
  4086. var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
  4087. // infinite loop, because it iterates over the newly added props too.
  4088. Object.keys(isUnitlessNumber).forEach(function (prop) {
  4089. prefixes.forEach(function (prefix) {
  4090. isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
  4091. });
  4092. });
  4093. /**
  4094. * Convert a value into the proper css writable value. The style name `name`
  4095. * should be logical (no hyphens), as specified
  4096. * in `CSSProperty.isUnitlessNumber`.
  4097. *
  4098. * @param {string} name CSS property name such as `topMargin`.
  4099. * @param {*} value CSS property value such as `10px`.
  4100. * @return {string} Normalized style value with dimensions applied.
  4101. */
  4102. function dangerousStyleValue(name, value, isCustomProperty) {
  4103. // Note that we've removed escapeTextForBrowser() calls here since the
  4104. // whole string will be escaped when the attribute is injected into
  4105. // the markup. If you provide unsafe user data here they can inject
  4106. // arbitrary CSS which may be problematic (I couldn't repro this):
  4107. // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
  4108. // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
  4109. // This is not an XSS hole but instead a potential CSS injection issue
  4110. // which has lead to a greater discussion about how we're going to
  4111. // trust URLs moving forward. See #2115901
  4112. var isEmpty = value == null || typeof value === 'boolean' || value === '';
  4113. if (isEmpty) {
  4114. return '';
  4115. }
  4116. if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
  4117. return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
  4118. }
  4119. return ('' + value).trim();
  4120. }
  4121. var uppercasePattern = /([A-Z])/g;
  4122. var msPattern = /^ms-/;
  4123. /**
  4124. * Hyphenates a camelcased CSS property name, for example:
  4125. *
  4126. * > hyphenateStyleName('backgroundColor')
  4127. * < "background-color"
  4128. * > hyphenateStyleName('MozTransition')
  4129. * < "-moz-transition"
  4130. * > hyphenateStyleName('msTransition')
  4131. * < "-ms-transition"
  4132. *
  4133. * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
  4134. * is converted to `-ms-`.
  4135. */
  4136. function hyphenateStyleName(name) {
  4137. return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-');
  4138. }
  4139. var warnValidStyle = function () {};
  4140. {
  4141. // 'msTransform' is correct, but the other prefixes should be capitalized
  4142. var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
  4143. var msPattern$1 = /^-ms-/;
  4144. var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon
  4145. var badStyleValueWithSemicolonPattern = /;\s*$/;
  4146. var warnedStyleNames = {};
  4147. var warnedStyleValues = {};
  4148. var warnedForNaNValue = false;
  4149. var warnedForInfinityValue = false;
  4150. var camelize = function (string) {
  4151. return string.replace(hyphenPattern, function (_, character) {
  4152. return character.toUpperCase();
  4153. });
  4154. };
  4155. var warnHyphenatedStyleName = function (name) {
  4156. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  4157. return;
  4158. }
  4159. warnedStyleNames[name] = true;
  4160. error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests
  4161. // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
  4162. // is converted to lowercase `ms`.
  4163. camelize(name.replace(msPattern$1, 'ms-')));
  4164. };
  4165. var warnBadVendoredStyleName = function (name) {
  4166. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  4167. return;
  4168. }
  4169. warnedStyleNames[name] = true;
  4170. error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1));
  4171. };
  4172. var warnStyleValueWithSemicolon = function (name, value) {
  4173. if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
  4174. return;
  4175. }
  4176. warnedStyleValues[value] = true;
  4177. error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ''));
  4178. };
  4179. var warnStyleValueIsNaN = function (name, value) {
  4180. if (warnedForNaNValue) {
  4181. return;
  4182. }
  4183. warnedForNaNValue = true;
  4184. error('`NaN` is an invalid value for the `%s` css style property.', name);
  4185. };
  4186. var warnStyleValueIsInfinity = function (name, value) {
  4187. if (warnedForInfinityValue) {
  4188. return;
  4189. }
  4190. warnedForInfinityValue = true;
  4191. error('`Infinity` is an invalid value for the `%s` css style property.', name);
  4192. };
  4193. warnValidStyle = function (name, value) {
  4194. if (name.indexOf('-') > -1) {
  4195. warnHyphenatedStyleName(name);
  4196. } else if (badVendoredStyleNamePattern.test(name)) {
  4197. warnBadVendoredStyleName(name);
  4198. } else if (badStyleValueWithSemicolonPattern.test(value)) {
  4199. warnStyleValueWithSemicolon(name, value);
  4200. }
  4201. if (typeof value === 'number') {
  4202. if (isNaN(value)) {
  4203. warnStyleValueIsNaN(name, value);
  4204. } else if (!isFinite(value)) {
  4205. warnStyleValueIsInfinity(name, value);
  4206. }
  4207. }
  4208. };
  4209. }
  4210. var warnValidStyle$1 = warnValidStyle;
  4211. /**
  4212. * Operations for dealing with CSS properties.
  4213. */
  4214. /**
  4215. * This creates a string that is expected to be equivalent to the style
  4216. * attribute generated by server-side rendering. It by-passes warnings and
  4217. * security checks so it's not safe to use this value for anything other than
  4218. * comparison. It is only used in DEV for SSR validation.
  4219. */
  4220. function createDangerousStringForStyles(styles) {
  4221. {
  4222. var serialized = '';
  4223. var delimiter = '';
  4224. for (var styleName in styles) {
  4225. if (!styles.hasOwnProperty(styleName)) {
  4226. continue;
  4227. }
  4228. var styleValue = styles[styleName];
  4229. if (styleValue != null) {
  4230. var isCustomProperty = styleName.indexOf('--') === 0;
  4231. serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':';
  4232. serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
  4233. delimiter = ';';
  4234. }
  4235. }
  4236. return serialized || null;
  4237. }
  4238. }
  4239. /**
  4240. * Sets the value for multiple styles on a node. If a value is specified as
  4241. * '' (empty string), the corresponding style property will be unset.
  4242. *
  4243. * @param {DOMElement} node
  4244. * @param {object} styles
  4245. */
  4246. function setValueForStyles(node, styles) {
  4247. var style = node.style;
  4248. for (var styleName in styles) {
  4249. if (!styles.hasOwnProperty(styleName)) {
  4250. continue;
  4251. }
  4252. var isCustomProperty = styleName.indexOf('--') === 0;
  4253. {
  4254. if (!isCustomProperty) {
  4255. warnValidStyle$1(styleName, styles[styleName]);
  4256. }
  4257. }
  4258. var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
  4259. if (styleName === 'float') {
  4260. styleName = 'cssFloat';
  4261. }
  4262. if (isCustomProperty) {
  4263. style.setProperty(styleName, styleValue);
  4264. } else {
  4265. style[styleName] = styleValue;
  4266. }
  4267. }
  4268. }
  4269. function isValueEmpty(value) {
  4270. return value == null || typeof value === 'boolean' || value === '';
  4271. }
  4272. /**
  4273. * Given {color: 'red', overflow: 'hidden'} returns {
  4274. * color: 'color',
  4275. * overflowX: 'overflow',
  4276. * overflowY: 'overflow',
  4277. * }. This can be read as "the overflowY property was set by the overflow
  4278. * shorthand". That is, the values are the property that each was derived from.
  4279. */
  4280. function expandShorthandMap(styles) {
  4281. var expanded = {};
  4282. for (var key in styles) {
  4283. var longhands = shorthandToLonghand[key] || [key];
  4284. for (var i = 0; i < longhands.length; i++) {
  4285. expanded[longhands[i]] = key;
  4286. }
  4287. }
  4288. return expanded;
  4289. }
  4290. /**
  4291. * When mixing shorthand and longhand property names, we warn during updates if
  4292. * we expect an incorrect result to occur. In particular, we warn for:
  4293. *
  4294. * Updating a shorthand property (longhand gets overwritten):
  4295. * {font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'}
  4296. * becomes .style.font = 'baz'
  4297. * Removing a shorthand property (longhand gets lost too):
  4298. * {font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'}
  4299. * becomes .style.font = ''
  4300. * Removing a longhand property (should revert to shorthand; doesn't):
  4301. * {font: 'foo', fontVariant: 'bar'} -> {font: 'foo'}
  4302. * becomes .style.fontVariant = ''
  4303. */
  4304. function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) {
  4305. {
  4306. if (!nextStyles) {
  4307. return;
  4308. }
  4309. var expandedUpdates = expandShorthandMap(styleUpdates);
  4310. var expandedStyles = expandShorthandMap(nextStyles);
  4311. var warnedAbout = {};
  4312. for (var key in expandedUpdates) {
  4313. var originalKey = expandedUpdates[key];
  4314. var correctOriginalKey = expandedStyles[key];
  4315. if (correctOriginalKey && originalKey !== correctOriginalKey) {
  4316. var warningKey = originalKey + ',' + correctOriginalKey;
  4317. if (warnedAbout[warningKey]) {
  4318. continue;
  4319. }
  4320. warnedAbout[warningKey] = true;
  4321. error('%s a style property during rerender (%s) when a ' + 'conflicting property is set (%s) can lead to styling bugs. To ' + "avoid this, don't mix shorthand and non-shorthand properties " + 'for the same value; instead, replace the shorthand with ' + 'separate values.', isValueEmpty(styleUpdates[originalKey]) ? 'Removing' : 'Updating', originalKey, correctOriginalKey);
  4322. }
  4323. }
  4324. }
  4325. }
  4326. // For HTML, certain tags should omit their close tag. We keep a whitelist for
  4327. // those special-case tags.
  4328. var omittedCloseTags = {
  4329. area: true,
  4330. base: true,
  4331. br: true,
  4332. col: true,
  4333. embed: true,
  4334. hr: true,
  4335. img: true,
  4336. input: true,
  4337. keygen: true,
  4338. link: true,
  4339. meta: true,
  4340. param: true,
  4341. source: true,
  4342. track: true,
  4343. wbr: true // NOTE: menuitem's close tag should be omitted, but that causes problems.
  4344. };
  4345. // `omittedCloseTags` except that `menuitem` should still have its closing tag.
  4346. var voidElementTags = _assign({
  4347. menuitem: true
  4348. }, omittedCloseTags);
  4349. var HTML = '__html';
  4350. var ReactDebugCurrentFrame$3 = null;
  4351. {
  4352. ReactDebugCurrentFrame$3 = ReactSharedInternals.ReactDebugCurrentFrame;
  4353. }
  4354. function assertValidProps(tag, props) {
  4355. if (!props) {
  4356. return;
  4357. } // Note the use of `==` which checks for null or undefined.
  4358. if (voidElementTags[tag]) {
  4359. if (!(props.children == null && props.dangerouslySetInnerHTML == null)) {
  4360. {
  4361. throw Error( tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`." + ( ReactDebugCurrentFrame$3.getStackAddendum() ) );
  4362. }
  4363. }
  4364. }
  4365. if (props.dangerouslySetInnerHTML != null) {
  4366. if (!(props.children == null)) {
  4367. {
  4368. throw Error( "Can only set one of `children` or `props.dangerouslySetInnerHTML`." );
  4369. }
  4370. }
  4371. if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML)) {
  4372. {
  4373. throw Error( "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information." );
  4374. }
  4375. }
  4376. }
  4377. {
  4378. if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) {
  4379. error('A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.');
  4380. }
  4381. }
  4382. if (!(props.style == null || typeof props.style === 'object')) {
  4383. {
  4384. throw Error( "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX." + ( ReactDebugCurrentFrame$3.getStackAddendum() ) );
  4385. }
  4386. }
  4387. }
  4388. function isCustomComponent(tagName, props) {
  4389. if (tagName.indexOf('-') === -1) {
  4390. return typeof props.is === 'string';
  4391. }
  4392. switch (tagName) {
  4393. // These are reserved SVG and MathML elements.
  4394. // We don't mind this whitelist too much because we expect it to never grow.
  4395. // The alternative is to track the namespace in a few places which is convoluted.
  4396. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
  4397. case 'annotation-xml':
  4398. case 'color-profile':
  4399. case 'font-face':
  4400. case 'font-face-src':
  4401. case 'font-face-uri':
  4402. case 'font-face-format':
  4403. case 'font-face-name':
  4404. case 'missing-glyph':
  4405. return false;
  4406. default:
  4407. return true;
  4408. }
  4409. }
  4410. // When adding attributes to the HTML or SVG whitelist, be sure to
  4411. // also add them to this module to ensure casing and incorrect name
  4412. // warnings.
  4413. var possibleStandardNames = {
  4414. // HTML
  4415. accept: 'accept',
  4416. acceptcharset: 'acceptCharset',
  4417. 'accept-charset': 'acceptCharset',
  4418. accesskey: 'accessKey',
  4419. action: 'action',
  4420. allowfullscreen: 'allowFullScreen',
  4421. alt: 'alt',
  4422. as: 'as',
  4423. async: 'async',
  4424. autocapitalize: 'autoCapitalize',
  4425. autocomplete: 'autoComplete',
  4426. autocorrect: 'autoCorrect',
  4427. autofocus: 'autoFocus',
  4428. autoplay: 'autoPlay',
  4429. autosave: 'autoSave',
  4430. capture: 'capture',
  4431. cellpadding: 'cellPadding',
  4432. cellspacing: 'cellSpacing',
  4433. challenge: 'challenge',
  4434. charset: 'charSet',
  4435. checked: 'checked',
  4436. children: 'children',
  4437. cite: 'cite',
  4438. class: 'className',
  4439. classid: 'classID',
  4440. classname: 'className',
  4441. cols: 'cols',
  4442. colspan: 'colSpan',
  4443. content: 'content',
  4444. contenteditable: 'contentEditable',
  4445. contextmenu: 'contextMenu',
  4446. controls: 'controls',
  4447. controlslist: 'controlsList',
  4448. coords: 'coords',
  4449. crossorigin: 'crossOrigin',
  4450. dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
  4451. data: 'data',
  4452. datetime: 'dateTime',
  4453. default: 'default',
  4454. defaultchecked: 'defaultChecked',
  4455. defaultvalue: 'defaultValue',
  4456. defer: 'defer',
  4457. dir: 'dir',
  4458. disabled: 'disabled',
  4459. disablepictureinpicture: 'disablePictureInPicture',
  4460. download: 'download',
  4461. draggable: 'draggable',
  4462. enctype: 'encType',
  4463. for: 'htmlFor',
  4464. form: 'form',
  4465. formmethod: 'formMethod',
  4466. formaction: 'formAction',
  4467. formenctype: 'formEncType',
  4468. formnovalidate: 'formNoValidate',
  4469. formtarget: 'formTarget',
  4470. frameborder: 'frameBorder',
  4471. headers: 'headers',
  4472. height: 'height',
  4473. hidden: 'hidden',
  4474. high: 'high',
  4475. href: 'href',
  4476. hreflang: 'hrefLang',
  4477. htmlfor: 'htmlFor',
  4478. httpequiv: 'httpEquiv',
  4479. 'http-equiv': 'httpEquiv',
  4480. icon: 'icon',
  4481. id: 'id',
  4482. innerhtml: 'innerHTML',
  4483. inputmode: 'inputMode',
  4484. integrity: 'integrity',
  4485. is: 'is',
  4486. itemid: 'itemID',
  4487. itemprop: 'itemProp',
  4488. itemref: 'itemRef',
  4489. itemscope: 'itemScope',
  4490. itemtype: 'itemType',
  4491. keyparams: 'keyParams',
  4492. keytype: 'keyType',
  4493. kind: 'kind',
  4494. label: 'label',
  4495. lang: 'lang',
  4496. list: 'list',
  4497. loop: 'loop',
  4498. low: 'low',
  4499. manifest: 'manifest',
  4500. marginwidth: 'marginWidth',
  4501. marginheight: 'marginHeight',
  4502. max: 'max',
  4503. maxlength: 'maxLength',
  4504. media: 'media',
  4505. mediagroup: 'mediaGroup',
  4506. method: 'method',
  4507. min: 'min',
  4508. minlength: 'minLength',
  4509. multiple: 'multiple',
  4510. muted: 'muted',
  4511. name: 'name',
  4512. nomodule: 'noModule',
  4513. nonce: 'nonce',
  4514. novalidate: 'noValidate',
  4515. open: 'open',
  4516. optimum: 'optimum',
  4517. pattern: 'pattern',
  4518. placeholder: 'placeholder',
  4519. playsinline: 'playsInline',
  4520. poster: 'poster',
  4521. preload: 'preload',
  4522. profile: 'profile',
  4523. radiogroup: 'radioGroup',
  4524. readonly: 'readOnly',
  4525. referrerpolicy: 'referrerPolicy',
  4526. rel: 'rel',
  4527. required: 'required',
  4528. reversed: 'reversed',
  4529. role: 'role',
  4530. rows: 'rows',
  4531. rowspan: 'rowSpan',
  4532. sandbox: 'sandbox',
  4533. scope: 'scope',
  4534. scoped: 'scoped',
  4535. scrolling: 'scrolling',
  4536. seamless: 'seamless',
  4537. selected: 'selected',
  4538. shape: 'shape',
  4539. size: 'size',
  4540. sizes: 'sizes',
  4541. span: 'span',
  4542. spellcheck: 'spellCheck',
  4543. src: 'src',
  4544. srcdoc: 'srcDoc',
  4545. srclang: 'srcLang',
  4546. srcset: 'srcSet',
  4547. start: 'start',
  4548. step: 'step',
  4549. style: 'style',
  4550. summary: 'summary',
  4551. tabindex: 'tabIndex',
  4552. target: 'target',
  4553. title: 'title',
  4554. type: 'type',
  4555. usemap: 'useMap',
  4556. value: 'value',
  4557. width: 'width',
  4558. wmode: 'wmode',
  4559. wrap: 'wrap',
  4560. // SVG
  4561. about: 'about',
  4562. accentheight: 'accentHeight',
  4563. 'accent-height': 'accentHeight',
  4564. accumulate: 'accumulate',
  4565. additive: 'additive',
  4566. alignmentbaseline: 'alignmentBaseline',
  4567. 'alignment-baseline': 'alignmentBaseline',
  4568. allowreorder: 'allowReorder',
  4569. alphabetic: 'alphabetic',
  4570. amplitude: 'amplitude',
  4571. arabicform: 'arabicForm',
  4572. 'arabic-form': 'arabicForm',
  4573. ascent: 'ascent',
  4574. attributename: 'attributeName',
  4575. attributetype: 'attributeType',
  4576. autoreverse: 'autoReverse',
  4577. azimuth: 'azimuth',
  4578. basefrequency: 'baseFrequency',
  4579. baselineshift: 'baselineShift',
  4580. 'baseline-shift': 'baselineShift',
  4581. baseprofile: 'baseProfile',
  4582. bbox: 'bbox',
  4583. begin: 'begin',
  4584. bias: 'bias',
  4585. by: 'by',
  4586. calcmode: 'calcMode',
  4587. capheight: 'capHeight',
  4588. 'cap-height': 'capHeight',
  4589. clip: 'clip',
  4590. clippath: 'clipPath',
  4591. 'clip-path': 'clipPath',
  4592. clippathunits: 'clipPathUnits',
  4593. cliprule: 'clipRule',
  4594. 'clip-rule': 'clipRule',
  4595. color: 'color',
  4596. colorinterpolation: 'colorInterpolation',
  4597. 'color-interpolation': 'colorInterpolation',
  4598. colorinterpolationfilters: 'colorInterpolationFilters',
  4599. 'color-interpolation-filters': 'colorInterpolationFilters',
  4600. colorprofile: 'colorProfile',
  4601. 'color-profile': 'colorProfile',
  4602. colorrendering: 'colorRendering',
  4603. 'color-rendering': 'colorRendering',
  4604. contentscripttype: 'contentScriptType',
  4605. contentstyletype: 'contentStyleType',
  4606. cursor: 'cursor',
  4607. cx: 'cx',
  4608. cy: 'cy',
  4609. d: 'd',
  4610. datatype: 'datatype',
  4611. decelerate: 'decelerate',
  4612. descent: 'descent',
  4613. diffuseconstant: 'diffuseConstant',
  4614. direction: 'direction',
  4615. display: 'display',
  4616. divisor: 'divisor',
  4617. dominantbaseline: 'dominantBaseline',
  4618. 'dominant-baseline': 'dominantBaseline',
  4619. dur: 'dur',
  4620. dx: 'dx',
  4621. dy: 'dy',
  4622. edgemode: 'edgeMode',
  4623. elevation: 'elevation',
  4624. enablebackground: 'enableBackground',
  4625. 'enable-background': 'enableBackground',
  4626. end: 'end',
  4627. exponent: 'exponent',
  4628. externalresourcesrequired: 'externalResourcesRequired',
  4629. fill: 'fill',
  4630. fillopacity: 'fillOpacity',
  4631. 'fill-opacity': 'fillOpacity',
  4632. fillrule: 'fillRule',
  4633. 'fill-rule': 'fillRule',
  4634. filter: 'filter',
  4635. filterres: 'filterRes',
  4636. filterunits: 'filterUnits',
  4637. floodopacity: 'floodOpacity',
  4638. 'flood-opacity': 'floodOpacity',
  4639. floodcolor: 'floodColor',
  4640. 'flood-color': 'floodColor',
  4641. focusable: 'focusable',
  4642. fontfamily: 'fontFamily',
  4643. 'font-family': 'fontFamily',
  4644. fontsize: 'fontSize',
  4645. 'font-size': 'fontSize',
  4646. fontsizeadjust: 'fontSizeAdjust',
  4647. 'font-size-adjust': 'fontSizeAdjust',
  4648. fontstretch: 'fontStretch',
  4649. 'font-stretch': 'fontStretch',
  4650. fontstyle: 'fontStyle',
  4651. 'font-style': 'fontStyle',
  4652. fontvariant: 'fontVariant',
  4653. 'font-variant': 'fontVariant',
  4654. fontweight: 'fontWeight',
  4655. 'font-weight': 'fontWeight',
  4656. format: 'format',
  4657. from: 'from',
  4658. fx: 'fx',
  4659. fy: 'fy',
  4660. g1: 'g1',
  4661. g2: 'g2',
  4662. glyphname: 'glyphName',
  4663. 'glyph-name': 'glyphName',
  4664. glyphorientationhorizontal: 'glyphOrientationHorizontal',
  4665. 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
  4666. glyphorientationvertical: 'glyphOrientationVertical',
  4667. 'glyph-orientation-vertical': 'glyphOrientationVertical',
  4668. glyphref: 'glyphRef',
  4669. gradienttransform: 'gradientTransform',
  4670. gradientunits: 'gradientUnits',
  4671. hanging: 'hanging',
  4672. horizadvx: 'horizAdvX',
  4673. 'horiz-adv-x': 'horizAdvX',
  4674. horizoriginx: 'horizOriginX',
  4675. 'horiz-origin-x': 'horizOriginX',
  4676. ideographic: 'ideographic',
  4677. imagerendering: 'imageRendering',
  4678. 'image-rendering': 'imageRendering',
  4679. in2: 'in2',
  4680. in: 'in',
  4681. inlist: 'inlist',
  4682. intercept: 'intercept',
  4683. k1: 'k1',
  4684. k2: 'k2',
  4685. k3: 'k3',
  4686. k4: 'k4',
  4687. k: 'k',
  4688. kernelmatrix: 'kernelMatrix',
  4689. kernelunitlength: 'kernelUnitLength',
  4690. kerning: 'kerning',
  4691. keypoints: 'keyPoints',
  4692. keysplines: 'keySplines',
  4693. keytimes: 'keyTimes',
  4694. lengthadjust: 'lengthAdjust',
  4695. letterspacing: 'letterSpacing',
  4696. 'letter-spacing': 'letterSpacing',
  4697. lightingcolor: 'lightingColor',
  4698. 'lighting-color': 'lightingColor',
  4699. limitingconeangle: 'limitingConeAngle',
  4700. local: 'local',
  4701. markerend: 'markerEnd',
  4702. 'marker-end': 'markerEnd',
  4703. markerheight: 'markerHeight',
  4704. markermid: 'markerMid',
  4705. 'marker-mid': 'markerMid',
  4706. markerstart: 'markerStart',
  4707. 'marker-start': 'markerStart',
  4708. markerunits: 'markerUnits',
  4709. markerwidth: 'markerWidth',
  4710. mask: 'mask',
  4711. maskcontentunits: 'maskContentUnits',
  4712. maskunits: 'maskUnits',
  4713. mathematical: 'mathematical',
  4714. mode: 'mode',
  4715. numoctaves: 'numOctaves',
  4716. offset: 'offset',
  4717. opacity: 'opacity',
  4718. operator: 'operator',
  4719. order: 'order',
  4720. orient: 'orient',
  4721. orientation: 'orientation',
  4722. origin: 'origin',
  4723. overflow: 'overflow',
  4724. overlineposition: 'overlinePosition',
  4725. 'overline-position': 'overlinePosition',
  4726. overlinethickness: 'overlineThickness',
  4727. 'overline-thickness': 'overlineThickness',
  4728. paintorder: 'paintOrder',
  4729. 'paint-order': 'paintOrder',
  4730. panose1: 'panose1',
  4731. 'panose-1': 'panose1',
  4732. pathlength: 'pathLength',
  4733. patterncontentunits: 'patternContentUnits',
  4734. patterntransform: 'patternTransform',
  4735. patternunits: 'patternUnits',
  4736. pointerevents: 'pointerEvents',
  4737. 'pointer-events': 'pointerEvents',
  4738. points: 'points',
  4739. pointsatx: 'pointsAtX',
  4740. pointsaty: 'pointsAtY',
  4741. pointsatz: 'pointsAtZ',
  4742. prefix: 'prefix',
  4743. preservealpha: 'preserveAlpha',
  4744. preserveaspectratio: 'preserveAspectRatio',
  4745. primitiveunits: 'primitiveUnits',
  4746. property: 'property',
  4747. r: 'r',
  4748. radius: 'radius',
  4749. refx: 'refX',
  4750. refy: 'refY',
  4751. renderingintent: 'renderingIntent',
  4752. 'rendering-intent': 'renderingIntent',
  4753. repeatcount: 'repeatCount',
  4754. repeatdur: 'repeatDur',
  4755. requiredextensions: 'requiredExtensions',
  4756. requiredfeatures: 'requiredFeatures',
  4757. resource: 'resource',
  4758. restart: 'restart',
  4759. result: 'result',
  4760. results: 'results',
  4761. rotate: 'rotate',
  4762. rx: 'rx',
  4763. ry: 'ry',
  4764. scale: 'scale',
  4765. security: 'security',
  4766. seed: 'seed',
  4767. shaperendering: 'shapeRendering',
  4768. 'shape-rendering': 'shapeRendering',
  4769. slope: 'slope',
  4770. spacing: 'spacing',
  4771. specularconstant: 'specularConstant',
  4772. specularexponent: 'specularExponent',
  4773. speed: 'speed',
  4774. spreadmethod: 'spreadMethod',
  4775. startoffset: 'startOffset',
  4776. stddeviation: 'stdDeviation',
  4777. stemh: 'stemh',
  4778. stemv: 'stemv',
  4779. stitchtiles: 'stitchTiles',
  4780. stopcolor: 'stopColor',
  4781. 'stop-color': 'stopColor',
  4782. stopopacity: 'stopOpacity',
  4783. 'stop-opacity': 'stopOpacity',
  4784. strikethroughposition: 'strikethroughPosition',
  4785. 'strikethrough-position': 'strikethroughPosition',
  4786. strikethroughthickness: 'strikethroughThickness',
  4787. 'strikethrough-thickness': 'strikethroughThickness',
  4788. string: 'string',
  4789. stroke: 'stroke',
  4790. strokedasharray: 'strokeDasharray',
  4791. 'stroke-dasharray': 'strokeDasharray',
  4792. strokedashoffset: 'strokeDashoffset',
  4793. 'stroke-dashoffset': 'strokeDashoffset',
  4794. strokelinecap: 'strokeLinecap',
  4795. 'stroke-linecap': 'strokeLinecap',
  4796. strokelinejoin: 'strokeLinejoin',
  4797. 'stroke-linejoin': 'strokeLinejoin',
  4798. strokemiterlimit: 'strokeMiterlimit',
  4799. 'stroke-miterlimit': 'strokeMiterlimit',
  4800. strokewidth: 'strokeWidth',
  4801. 'stroke-width': 'strokeWidth',
  4802. strokeopacity: 'strokeOpacity',
  4803. 'stroke-opacity': 'strokeOpacity',
  4804. suppresscontenteditablewarning: 'suppressContentEditableWarning',
  4805. suppresshydrationwarning: 'suppressHydrationWarning',
  4806. surfacescale: 'surfaceScale',
  4807. systemlanguage: 'systemLanguage',
  4808. tablevalues: 'tableValues',
  4809. targetx: 'targetX',
  4810. targety: 'targetY',
  4811. textanchor: 'textAnchor',
  4812. 'text-anchor': 'textAnchor',
  4813. textdecoration: 'textDecoration',
  4814. 'text-decoration': 'textDecoration',
  4815. textlength: 'textLength',
  4816. textrendering: 'textRendering',
  4817. 'text-rendering': 'textRendering',
  4818. to: 'to',
  4819. transform: 'transform',
  4820. typeof: 'typeof',
  4821. u1: 'u1',
  4822. u2: 'u2',
  4823. underlineposition: 'underlinePosition',
  4824. 'underline-position': 'underlinePosition',
  4825. underlinethickness: 'underlineThickness',
  4826. 'underline-thickness': 'underlineThickness',
  4827. unicode: 'unicode',
  4828. unicodebidi: 'unicodeBidi',
  4829. 'unicode-bidi': 'unicodeBidi',
  4830. unicoderange: 'unicodeRange',
  4831. 'unicode-range': 'unicodeRange',
  4832. unitsperem: 'unitsPerEm',
  4833. 'units-per-em': 'unitsPerEm',
  4834. unselectable: 'unselectable',
  4835. valphabetic: 'vAlphabetic',
  4836. 'v-alphabetic': 'vAlphabetic',
  4837. values: 'values',
  4838. vectoreffect: 'vectorEffect',
  4839. 'vector-effect': 'vectorEffect',
  4840. version: 'version',
  4841. vertadvy: 'vertAdvY',
  4842. 'vert-adv-y': 'vertAdvY',
  4843. vertoriginx: 'vertOriginX',
  4844. 'vert-origin-x': 'vertOriginX',
  4845. vertoriginy: 'vertOriginY',
  4846. 'vert-origin-y': 'vertOriginY',
  4847. vhanging: 'vHanging',
  4848. 'v-hanging': 'vHanging',
  4849. videographic: 'vIdeographic',
  4850. 'v-ideographic': 'vIdeographic',
  4851. viewbox: 'viewBox',
  4852. viewtarget: 'viewTarget',
  4853. visibility: 'visibility',
  4854. vmathematical: 'vMathematical',
  4855. 'v-mathematical': 'vMathematical',
  4856. vocab: 'vocab',
  4857. widths: 'widths',
  4858. wordspacing: 'wordSpacing',
  4859. 'word-spacing': 'wordSpacing',
  4860. writingmode: 'writingMode',
  4861. 'writing-mode': 'writingMode',
  4862. x1: 'x1',
  4863. x2: 'x2',
  4864. x: 'x',
  4865. xchannelselector: 'xChannelSelector',
  4866. xheight: 'xHeight',
  4867. 'x-height': 'xHeight',
  4868. xlinkactuate: 'xlinkActuate',
  4869. 'xlink:actuate': 'xlinkActuate',
  4870. xlinkarcrole: 'xlinkArcrole',
  4871. 'xlink:arcrole': 'xlinkArcrole',
  4872. xlinkhref: 'xlinkHref',
  4873. 'xlink:href': 'xlinkHref',
  4874. xlinkrole: 'xlinkRole',
  4875. 'xlink:role': 'xlinkRole',
  4876. xlinkshow: 'xlinkShow',
  4877. 'xlink:show': 'xlinkShow',
  4878. xlinktitle: 'xlinkTitle',
  4879. 'xlink:title': 'xlinkTitle',
  4880. xlinktype: 'xlinkType',
  4881. 'xlink:type': 'xlinkType',
  4882. xmlbase: 'xmlBase',
  4883. 'xml:base': 'xmlBase',
  4884. xmllang: 'xmlLang',
  4885. 'xml:lang': 'xmlLang',
  4886. xmlns: 'xmlns',
  4887. 'xml:space': 'xmlSpace',
  4888. xmlnsxlink: 'xmlnsXlink',
  4889. 'xmlns:xlink': 'xmlnsXlink',
  4890. xmlspace: 'xmlSpace',
  4891. y1: 'y1',
  4892. y2: 'y2',
  4893. y: 'y',
  4894. ychannelselector: 'yChannelSelector',
  4895. z: 'z',
  4896. zoomandpan: 'zoomAndPan'
  4897. };
  4898. var ariaProperties = {
  4899. 'aria-current': 0,
  4900. // state
  4901. 'aria-details': 0,
  4902. 'aria-disabled': 0,
  4903. // state
  4904. 'aria-hidden': 0,
  4905. // state
  4906. 'aria-invalid': 0,
  4907. // state
  4908. 'aria-keyshortcuts': 0,
  4909. 'aria-label': 0,
  4910. 'aria-roledescription': 0,
  4911. // Widget Attributes
  4912. 'aria-autocomplete': 0,
  4913. 'aria-checked': 0,
  4914. 'aria-expanded': 0,
  4915. 'aria-haspopup': 0,
  4916. 'aria-level': 0,
  4917. 'aria-modal': 0,
  4918. 'aria-multiline': 0,
  4919. 'aria-multiselectable': 0,
  4920. 'aria-orientation': 0,
  4921. 'aria-placeholder': 0,
  4922. 'aria-pressed': 0,
  4923. 'aria-readonly': 0,
  4924. 'aria-required': 0,
  4925. 'aria-selected': 0,
  4926. 'aria-sort': 0,
  4927. 'aria-valuemax': 0,
  4928. 'aria-valuemin': 0,
  4929. 'aria-valuenow': 0,
  4930. 'aria-valuetext': 0,
  4931. // Live Region Attributes
  4932. 'aria-atomic': 0,
  4933. 'aria-busy': 0,
  4934. 'aria-live': 0,
  4935. 'aria-relevant': 0,
  4936. // Drag-and-Drop Attributes
  4937. 'aria-dropeffect': 0,
  4938. 'aria-grabbed': 0,
  4939. // Relationship Attributes
  4940. 'aria-activedescendant': 0,
  4941. 'aria-colcount': 0,
  4942. 'aria-colindex': 0,
  4943. 'aria-colspan': 0,
  4944. 'aria-controls': 0,
  4945. 'aria-describedby': 0,
  4946. 'aria-errormessage': 0,
  4947. 'aria-flowto': 0,
  4948. 'aria-labelledby': 0,
  4949. 'aria-owns': 0,
  4950. 'aria-posinset': 0,
  4951. 'aria-rowcount': 0,
  4952. 'aria-rowindex': 0,
  4953. 'aria-rowspan': 0,
  4954. 'aria-setsize': 0
  4955. };
  4956. var warnedProperties = {};
  4957. var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  4958. var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  4959. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  4960. function validateProperty(tagName, name) {
  4961. {
  4962. if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) {
  4963. return true;
  4964. }
  4965. if (rARIACamel.test(name)) {
  4966. var ariaName = 'aria-' + name.slice(4).toLowerCase();
  4967. var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  4968. // DOM properties, then it is an invalid aria-* attribute.
  4969. if (correctName == null) {
  4970. error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name);
  4971. warnedProperties[name] = true;
  4972. return true;
  4973. } // aria-* attributes should be lowercase; suggest the lowercase version.
  4974. if (name !== correctName) {
  4975. error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName);
  4976. warnedProperties[name] = true;
  4977. return true;
  4978. }
  4979. }
  4980. if (rARIA.test(name)) {
  4981. var lowerCasedName = name.toLowerCase();
  4982. var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  4983. // DOM properties, then it is an invalid aria-* attribute.
  4984. if (standardName == null) {
  4985. warnedProperties[name] = true;
  4986. return false;
  4987. } // aria-* attributes should be lowercase; suggest the lowercase version.
  4988. if (name !== standardName) {
  4989. error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName);
  4990. warnedProperties[name] = true;
  4991. return true;
  4992. }
  4993. }
  4994. }
  4995. return true;
  4996. }
  4997. function warnInvalidARIAProps(type, props) {
  4998. {
  4999. var invalidProps = [];
  5000. for (var key in props) {
  5001. var isValid = validateProperty(type, key);
  5002. if (!isValid) {
  5003. invalidProps.push(key);
  5004. }
  5005. }
  5006. var unknownPropString = invalidProps.map(function (prop) {
  5007. return '`' + prop + '`';
  5008. }).join(', ');
  5009. if (invalidProps.length === 1) {
  5010. error('Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
  5011. } else if (invalidProps.length > 1) {
  5012. error('Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
  5013. }
  5014. }
  5015. }
  5016. function validateProperties(type, props) {
  5017. if (isCustomComponent(type, props)) {
  5018. return;
  5019. }
  5020. warnInvalidARIAProps(type, props);
  5021. }
  5022. var didWarnValueNull = false;
  5023. function validateProperties$1(type, props) {
  5024. {
  5025. if (type !== 'input' && type !== 'textarea' && type !== 'select') {
  5026. return;
  5027. }
  5028. if (props != null && props.value === null && !didWarnValueNull) {
  5029. didWarnValueNull = true;
  5030. if (type === 'select' && props.multiple) {
  5031. error('`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.', type);
  5032. } else {
  5033. error('`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type);
  5034. }
  5035. }
  5036. }
  5037. }
  5038. var validateProperty$1 = function () {};
  5039. {
  5040. var warnedProperties$1 = {};
  5041. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  5042. var EVENT_NAME_REGEX = /^on./;
  5043. var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
  5044. var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  5045. var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  5046. validateProperty$1 = function (tagName, name, value, canUseEventSystem) {
  5047. if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
  5048. return true;
  5049. }
  5050. var lowerCasedName = name.toLowerCase();
  5051. if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
  5052. error('React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.');
  5053. warnedProperties$1[name] = true;
  5054. return true;
  5055. } // We can't rely on the event system being injected on the server.
  5056. if (canUseEventSystem) {
  5057. if (registrationNameModules.hasOwnProperty(name)) {
  5058. return true;
  5059. }
  5060. var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
  5061. if (registrationName != null) {
  5062. error('Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName);
  5063. warnedProperties$1[name] = true;
  5064. return true;
  5065. }
  5066. if (EVENT_NAME_REGEX.test(name)) {
  5067. error('Unknown event handler property `%s`. It will be ignored.', name);
  5068. warnedProperties$1[name] = true;
  5069. return true;
  5070. }
  5071. } else if (EVENT_NAME_REGEX.test(name)) {
  5072. // If no event plugins have been injected, we are in a server environment.
  5073. // So we can't tell if the event name is correct for sure, but we can filter
  5074. // out known bad ones like `onclick`. We can't suggest a specific replacement though.
  5075. if (INVALID_EVENT_NAME_REGEX.test(name)) {
  5076. error('Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name);
  5077. }
  5078. warnedProperties$1[name] = true;
  5079. return true;
  5080. } // Let the ARIA attribute hook validate ARIA attributes
  5081. if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
  5082. return true;
  5083. }
  5084. if (lowerCasedName === 'innerhtml') {
  5085. error('Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
  5086. warnedProperties$1[name] = true;
  5087. return true;
  5088. }
  5089. if (lowerCasedName === 'aria') {
  5090. error('The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
  5091. warnedProperties$1[name] = true;
  5092. return true;
  5093. }
  5094. if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
  5095. error('Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value);
  5096. warnedProperties$1[name] = true;
  5097. return true;
  5098. }
  5099. if (typeof value === 'number' && isNaN(value)) {
  5100. error('Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name);
  5101. warnedProperties$1[name] = true;
  5102. return true;
  5103. }
  5104. var propertyInfo = getPropertyInfo(name);
  5105. var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config.
  5106. if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  5107. var standardName = possibleStandardNames[lowerCasedName];
  5108. if (standardName !== name) {
  5109. error('Invalid DOM property `%s`. Did you mean `%s`?', name, standardName);
  5110. warnedProperties$1[name] = true;
  5111. return true;
  5112. }
  5113. } else if (!isReserved && name !== lowerCasedName) {
  5114. // Unknown attributes should have lowercase casing since that's how they
  5115. // will be cased anyway with server rendering.
  5116. error('React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.', name, lowerCasedName);
  5117. warnedProperties$1[name] = true;
  5118. return true;
  5119. }
  5120. if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  5121. if (value) {
  5122. error('Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.', value, name, name, value, name);
  5123. } else {
  5124. error('Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', value, name, name, value, name, name, name);
  5125. }
  5126. warnedProperties$1[name] = true;
  5127. return true;
  5128. } // Now that we've validated casing, do not validate
  5129. // data types for reserved props
  5130. if (isReserved) {
  5131. return true;
  5132. } // Warn when a known attribute is a bad type
  5133. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  5134. warnedProperties$1[name] = true;
  5135. return false;
  5136. } // Warn when passing the strings 'false' or 'true' into a boolean prop
  5137. if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
  5138. error('Received the string `%s` for the boolean attribute `%s`. ' + '%s ' + 'Did you mean %s={%s}?', value, name, value === 'false' ? 'The browser will interpret it as a truthy value.' : 'Although this works, it will not work as expected if you pass the string "false".', name, value);
  5139. warnedProperties$1[name] = true;
  5140. return true;
  5141. }
  5142. return true;
  5143. };
  5144. }
  5145. var warnUnknownProperties = function (type, props, canUseEventSystem) {
  5146. {
  5147. var unknownProps = [];
  5148. for (var key in props) {
  5149. var isValid = validateProperty$1(type, key, props[key], canUseEventSystem);
  5150. if (!isValid) {
  5151. unknownProps.push(key);
  5152. }
  5153. }
  5154. var unknownPropString = unknownProps.map(function (prop) {
  5155. return '`' + prop + '`';
  5156. }).join(', ');
  5157. if (unknownProps.length === 1) {
  5158. error('Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior', unknownPropString, type);
  5159. } else if (unknownProps.length > 1) {
  5160. error('Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior', unknownPropString, type);
  5161. }
  5162. }
  5163. };
  5164. function validateProperties$2(type, props, canUseEventSystem) {
  5165. if (isCustomComponent(type, props)) {
  5166. return;
  5167. }
  5168. warnUnknownProperties(type, props, canUseEventSystem);
  5169. }
  5170. var didWarnInvalidHydration = false;
  5171. var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML';
  5172. var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning';
  5173. var SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
  5174. var AUTOFOCUS = 'autoFocus';
  5175. var CHILDREN = 'children';
  5176. var STYLE = 'style';
  5177. var HTML$1 = '__html';
  5178. var HTML_NAMESPACE$1 = Namespaces.html;
  5179. var warnedUnknownTags;
  5180. var suppressHydrationWarning;
  5181. var validatePropertiesInDevelopment;
  5182. var warnForTextDifference;
  5183. var warnForPropDifference;
  5184. var warnForExtraAttributes;
  5185. var warnForInvalidEventListener;
  5186. var canDiffStyleForHydrationWarning;
  5187. var normalizeMarkupForTextOrAttribute;
  5188. var normalizeHTML;
  5189. {
  5190. warnedUnknownTags = {
  5191. // Chrome is the only major browser not shipping <time>. But as of July
  5192. // 2017 it intends to ship it due to widespread usage. We intentionally
  5193. // *don't* warn for <time> even if it's unrecognized by Chrome because
  5194. // it soon will be, and many apps have been using it anyway.
  5195. time: true,
  5196. // There are working polyfills for <dialog>. Let people use it.
  5197. dialog: true,
  5198. // Electron ships a custom <webview> tag to display external web content in
  5199. // an isolated frame and process.
  5200. // This tag is not present in non Electron environments such as JSDom which
  5201. // is often used for testing purposes.
  5202. // @see https://electronjs.org/docs/api/webview-tag
  5203. webview: true
  5204. };
  5205. validatePropertiesInDevelopment = function (type, props) {
  5206. validateProperties(type, props);
  5207. validateProperties$1(type, props);
  5208. validateProperties$2(type, props,
  5209. /* canUseEventSystem */
  5210. true);
  5211. }; // IE 11 parses & normalizes the style attribute as opposed to other
  5212. // browsers. It adds spaces and sorts the properties in some
  5213. // non-alphabetical order. Handling that would require sorting CSS
  5214. // properties in the client & server versions or applying
  5215. // `expectedStyle` to a temporary DOM node to read its `style` attribute
  5216. // normalized. Since it only affects IE, we're skipping style warnings
  5217. // in that browser completely in favor of doing all that work.
  5218. // See https://github.com/facebook/react/issues/11807
  5219. canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode; // HTML parsing normalizes CR and CRLF to LF.
  5220. // It also can turn \u0000 into \uFFFD inside attributes.
  5221. // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream
  5222. // If we have a mismatch, it might be caused by that.
  5223. // We will still patch up in this case but not fire the warning.
  5224. var NORMALIZE_NEWLINES_REGEX = /\r\n?/g;
  5225. var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g;
  5226. normalizeMarkupForTextOrAttribute = function (markup) {
  5227. var markupString = typeof markup === 'string' ? markup : '' + markup;
  5228. return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, '');
  5229. };
  5230. warnForTextDifference = function (serverText, clientText) {
  5231. if (didWarnInvalidHydration) {
  5232. return;
  5233. }
  5234. var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText);
  5235. var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText);
  5236. if (normalizedServerText === normalizedClientText) {
  5237. return;
  5238. }
  5239. didWarnInvalidHydration = true;
  5240. error('Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText);
  5241. };
  5242. warnForPropDifference = function (propName, serverValue, clientValue) {
  5243. if (didWarnInvalidHydration) {
  5244. return;
  5245. }
  5246. var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue);
  5247. var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue);
  5248. if (normalizedServerValue === normalizedClientValue) {
  5249. return;
  5250. }
  5251. didWarnInvalidHydration = true;
  5252. error('Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue));
  5253. };
  5254. warnForExtraAttributes = function (attributeNames) {
  5255. if (didWarnInvalidHydration) {
  5256. return;
  5257. }
  5258. didWarnInvalidHydration = true;
  5259. var names = [];
  5260. attributeNames.forEach(function (name) {
  5261. names.push(name);
  5262. });
  5263. error('Extra attributes from the server: %s', names);
  5264. };
  5265. warnForInvalidEventListener = function (registrationName, listener) {
  5266. if (listener === false) {
  5267. error('Expected `%s` listener to be a function, instead got `false`.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', registrationName, registrationName, registrationName);
  5268. } else {
  5269. error('Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener);
  5270. }
  5271. }; // Parse the HTML and read it back to normalize the HTML string so that it
  5272. // can be used for comparison.
  5273. normalizeHTML = function (parent, html) {
  5274. // We could have created a separate document here to avoid
  5275. // re-initializing custom elements if they exist. But this breaks
  5276. // how <noscript> is being handled. So we use the same document.
  5277. // See the discussion in https://github.com/facebook/react/pull/11157.
  5278. var testElement = parent.namespaceURI === HTML_NAMESPACE$1 ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName);
  5279. testElement.innerHTML = html;
  5280. return testElement.innerHTML;
  5281. };
  5282. }
  5283. function ensureListeningTo(rootContainerElement, registrationName) {
  5284. var isDocumentOrFragment = rootContainerElement.nodeType === DOCUMENT_NODE || rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE;
  5285. var doc = isDocumentOrFragment ? rootContainerElement : rootContainerElement.ownerDocument;
  5286. legacyListenToEvent(registrationName, doc);
  5287. }
  5288. function getOwnerDocumentFromRootContainer(rootContainerElement) {
  5289. return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument;
  5290. }
  5291. function noop() {}
  5292. function trapClickOnNonInteractiveElement(node) {
  5293. // Mobile Safari does not fire properly bubble click events on
  5294. // non-interactive elements, which means delegated click listeners do not
  5295. // fire. The workaround for this bug involves attaching an empty click
  5296. // listener on the target node.
  5297. // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  5298. // Just set it using the onclick property so that we don't have to manage any
  5299. // bookkeeping for it. Not sure if we need to clear it when the listener is
  5300. // removed.
  5301. // TODO: Only do this for the relevant Safaris maybe?
  5302. node.onclick = noop;
  5303. }
  5304. function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
  5305. for (var propKey in nextProps) {
  5306. if (!nextProps.hasOwnProperty(propKey)) {
  5307. continue;
  5308. }
  5309. var nextProp = nextProps[propKey];
  5310. if (propKey === STYLE) {
  5311. {
  5312. if (nextProp) {
  5313. // Freeze the next style object so that we can assume it won't be
  5314. // mutated. We have already warned for this in the past.
  5315. Object.freeze(nextProp);
  5316. }
  5317. } // Relies on `updateStylesByID` not mutating `styleUpdates`.
  5318. setValueForStyles(domElement, nextProp);
  5319. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  5320. var nextHtml = nextProp ? nextProp[HTML$1] : undefined;
  5321. if (nextHtml != null) {
  5322. setInnerHTML(domElement, nextHtml);
  5323. }
  5324. } else if (propKey === CHILDREN) {
  5325. if (typeof nextProp === 'string') {
  5326. // Avoid setting initial textContent when the text is empty. In IE11 setting
  5327. // textContent on a <textarea> will cause the placeholder to not
  5328. // show within the <textarea> until it has been focused and blurred again.
  5329. // https://github.com/facebook/react/issues/6731#issuecomment-254874553
  5330. var canSetTextContent = tag !== 'textarea' || nextProp !== '';
  5331. if (canSetTextContent) {
  5332. setTextContent(domElement, nextProp);
  5333. }
  5334. } else if (typeof nextProp === 'number') {
  5335. setTextContent(domElement, '' + nextProp);
  5336. }
  5337. } else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameModules.hasOwnProperty(propKey)) {
  5338. if (nextProp != null) {
  5339. if ( typeof nextProp !== 'function') {
  5340. warnForInvalidEventListener(propKey, nextProp);
  5341. }
  5342. ensureListeningTo(rootContainerElement, propKey);
  5343. }
  5344. } else if (nextProp != null) {
  5345. setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
  5346. }
  5347. }
  5348. }
  5349. function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
  5350. // TODO: Handle wasCustomComponentTag
  5351. for (var i = 0; i < updatePayload.length; i += 2) {
  5352. var propKey = updatePayload[i];
  5353. var propValue = updatePayload[i + 1];
  5354. if (propKey === STYLE) {
  5355. setValueForStyles(domElement, propValue);
  5356. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  5357. setInnerHTML(domElement, propValue);
  5358. } else if (propKey === CHILDREN) {
  5359. setTextContent(domElement, propValue);
  5360. } else {
  5361. setValueForProperty(domElement, propKey, propValue, isCustomComponentTag);
  5362. }
  5363. }
  5364. }
  5365. function createElement(type, props, rootContainerElement, parentNamespace) {
  5366. var isCustomComponentTag; // We create tags in the namespace of their parent container, except HTML
  5367. // tags get no namespace.
  5368. var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
  5369. var domElement;
  5370. var namespaceURI = parentNamespace;
  5371. if (namespaceURI === HTML_NAMESPACE$1) {
  5372. namespaceURI = getIntrinsicNamespace(type);
  5373. }
  5374. if (namespaceURI === HTML_NAMESPACE$1) {
  5375. {
  5376. isCustomComponentTag = isCustomComponent(type, props); // Should this check be gated by parent namespace? Not sure we want to
  5377. // allow <SVG> or <mATH>.
  5378. if (!isCustomComponentTag && type !== type.toLowerCase()) {
  5379. error('<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type);
  5380. }
  5381. }
  5382. if (type === 'script') {
  5383. // Create the script via .innerHTML so its "parser-inserted" flag is
  5384. // set to true and it does not execute
  5385. var div = ownerDocument.createElement('div');
  5386. div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
  5387. // This is guaranteed to yield a script element.
  5388. var firstChild = div.firstChild;
  5389. domElement = div.removeChild(firstChild);
  5390. } else if (typeof props.is === 'string') {
  5391. // $FlowIssue `createElement` should be updated for Web Components
  5392. domElement = ownerDocument.createElement(type, {
  5393. is: props.is
  5394. });
  5395. } else {
  5396. // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
  5397. // See discussion in https://github.com/facebook/react/pull/6896
  5398. // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
  5399. domElement = ownerDocument.createElement(type); // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size`
  5400. // attributes on `select`s needs to be added before `option`s are inserted.
  5401. // This prevents:
  5402. // - a bug where the `select` does not scroll to the correct option because singular
  5403. // `select` elements automatically pick the first item #13222
  5404. // - a bug where the `select` set the first item as selected despite the `size` attribute #14239
  5405. // See https://github.com/facebook/react/issues/13222
  5406. // and https://github.com/facebook/react/issues/14239
  5407. if (type === 'select') {
  5408. var node = domElement;
  5409. if (props.multiple) {
  5410. node.multiple = true;
  5411. } else if (props.size) {
  5412. // Setting a size greater than 1 causes a select to behave like `multiple=true`, where
  5413. // it is possible that no option is selected.
  5414. //
  5415. // This is only necessary when a select in "single selection mode".
  5416. node.size = props.size;
  5417. }
  5418. }
  5419. }
  5420. } else {
  5421. domElement = ownerDocument.createElementNS(namespaceURI, type);
  5422. }
  5423. {
  5424. if (namespaceURI === HTML_NAMESPACE$1) {
  5425. if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
  5426. warnedUnknownTags[type] = true;
  5427. error('The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type);
  5428. }
  5429. }
  5430. }
  5431. return domElement;
  5432. }
  5433. function createTextNode(text, rootContainerElement) {
  5434. return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text);
  5435. }
  5436. function setInitialProperties(domElement, tag, rawProps, rootContainerElement) {
  5437. var isCustomComponentTag = isCustomComponent(tag, rawProps);
  5438. {
  5439. validatePropertiesInDevelopment(tag, rawProps);
  5440. } // TODO: Make sure that we check isMounted before firing any of these events.
  5441. var props;
  5442. switch (tag) {
  5443. case 'iframe':
  5444. case 'object':
  5445. case 'embed':
  5446. trapBubbledEvent(TOP_LOAD, domElement);
  5447. props = rawProps;
  5448. break;
  5449. case 'video':
  5450. case 'audio':
  5451. // Create listener for each media event
  5452. for (var i = 0; i < mediaEventTypes.length; i++) {
  5453. trapBubbledEvent(mediaEventTypes[i], domElement);
  5454. }
  5455. props = rawProps;
  5456. break;
  5457. case 'source':
  5458. trapBubbledEvent(TOP_ERROR, domElement);
  5459. props = rawProps;
  5460. break;
  5461. case 'img':
  5462. case 'image':
  5463. case 'link':
  5464. trapBubbledEvent(TOP_ERROR, domElement);
  5465. trapBubbledEvent(TOP_LOAD, domElement);
  5466. props = rawProps;
  5467. break;
  5468. case 'form':
  5469. trapBubbledEvent(TOP_RESET, domElement);
  5470. trapBubbledEvent(TOP_SUBMIT, domElement);
  5471. props = rawProps;
  5472. break;
  5473. case 'details':
  5474. trapBubbledEvent(TOP_TOGGLE, domElement);
  5475. props = rawProps;
  5476. break;
  5477. case 'input':
  5478. initWrapperState(domElement, rawProps);
  5479. props = getHostProps(domElement, rawProps);
  5480. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  5481. // to onChange. Even if there is no listener.
  5482. ensureListeningTo(rootContainerElement, 'onChange');
  5483. break;
  5484. case 'option':
  5485. validateProps(domElement, rawProps);
  5486. props = getHostProps$1(domElement, rawProps);
  5487. break;
  5488. case 'select':
  5489. initWrapperState$1(domElement, rawProps);
  5490. props = getHostProps$2(domElement, rawProps);
  5491. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  5492. // to onChange. Even if there is no listener.
  5493. ensureListeningTo(rootContainerElement, 'onChange');
  5494. break;
  5495. case 'textarea':
  5496. initWrapperState$2(domElement, rawProps);
  5497. props = getHostProps$3(domElement, rawProps);
  5498. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  5499. // to onChange. Even if there is no listener.
  5500. ensureListeningTo(rootContainerElement, 'onChange');
  5501. break;
  5502. default:
  5503. props = rawProps;
  5504. }
  5505. assertValidProps(tag, props);
  5506. setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag);
  5507. switch (tag) {
  5508. case 'input':
  5509. // TODO: Make sure we check if this is still unmounted or do any clean
  5510. // up necessary since we never stop tracking anymore.
  5511. track(domElement);
  5512. postMountWrapper(domElement, rawProps, false);
  5513. break;
  5514. case 'textarea':
  5515. // TODO: Make sure we check if this is still unmounted or do any clean
  5516. // up necessary since we never stop tracking anymore.
  5517. track(domElement);
  5518. postMountWrapper$3(domElement);
  5519. break;
  5520. case 'option':
  5521. postMountWrapper$1(domElement, rawProps);
  5522. break;
  5523. case 'select':
  5524. postMountWrapper$2(domElement, rawProps);
  5525. break;
  5526. default:
  5527. if (typeof props.onClick === 'function') {
  5528. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  5529. trapClickOnNonInteractiveElement(domElement);
  5530. }
  5531. break;
  5532. }
  5533. } // Calculate the diff between the two objects.
  5534. function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) {
  5535. {
  5536. validatePropertiesInDevelopment(tag, nextRawProps);
  5537. }
  5538. var updatePayload = null;
  5539. var lastProps;
  5540. var nextProps;
  5541. switch (tag) {
  5542. case 'input':
  5543. lastProps = getHostProps(domElement, lastRawProps);
  5544. nextProps = getHostProps(domElement, nextRawProps);
  5545. updatePayload = [];
  5546. break;
  5547. case 'option':
  5548. lastProps = getHostProps$1(domElement, lastRawProps);
  5549. nextProps = getHostProps$1(domElement, nextRawProps);
  5550. updatePayload = [];
  5551. break;
  5552. case 'select':
  5553. lastProps = getHostProps$2(domElement, lastRawProps);
  5554. nextProps = getHostProps$2(domElement, nextRawProps);
  5555. updatePayload = [];
  5556. break;
  5557. case 'textarea':
  5558. lastProps = getHostProps$3(domElement, lastRawProps);
  5559. nextProps = getHostProps$3(domElement, nextRawProps);
  5560. updatePayload = [];
  5561. break;
  5562. default:
  5563. lastProps = lastRawProps;
  5564. nextProps = nextRawProps;
  5565. if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') {
  5566. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  5567. trapClickOnNonInteractiveElement(domElement);
  5568. }
  5569. break;
  5570. }
  5571. assertValidProps(tag, nextProps);
  5572. var propKey;
  5573. var styleName;
  5574. var styleUpdates = null;
  5575. for (propKey in lastProps) {
  5576. if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
  5577. continue;
  5578. }
  5579. if (propKey === STYLE) {
  5580. var lastStyle = lastProps[propKey];
  5581. for (styleName in lastStyle) {
  5582. if (lastStyle.hasOwnProperty(styleName)) {
  5583. if (!styleUpdates) {
  5584. styleUpdates = {};
  5585. }
  5586. styleUpdates[styleName] = '';
  5587. }
  5588. }
  5589. } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) ; else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameModules.hasOwnProperty(propKey)) {
  5590. // This is a special case. If any listener updates we need to ensure
  5591. // that the "current" fiber pointer gets updated so we need a commit
  5592. // to update this element.
  5593. if (!updatePayload) {
  5594. updatePayload = [];
  5595. }
  5596. } else {
  5597. // For all other deleted properties we add it to the queue. We use
  5598. // the whitelist in the commit phase instead.
  5599. (updatePayload = updatePayload || []).push(propKey, null);
  5600. }
  5601. }
  5602. for (propKey in nextProps) {
  5603. var nextProp = nextProps[propKey];
  5604. var lastProp = lastProps != null ? lastProps[propKey] : undefined;
  5605. if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {
  5606. continue;
  5607. }
  5608. if (propKey === STYLE) {
  5609. {
  5610. if (nextProp) {
  5611. // Freeze the next style object so that we can assume it won't be
  5612. // mutated. We have already warned for this in the past.
  5613. Object.freeze(nextProp);
  5614. }
  5615. }
  5616. if (lastProp) {
  5617. // Unset styles on `lastProp` but not on `nextProp`.
  5618. for (styleName in lastProp) {
  5619. if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
  5620. if (!styleUpdates) {
  5621. styleUpdates = {};
  5622. }
  5623. styleUpdates[styleName] = '';
  5624. }
  5625. } // Update styles that changed since `lastProp`.
  5626. for (styleName in nextProp) {
  5627. if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
  5628. if (!styleUpdates) {
  5629. styleUpdates = {};
  5630. }
  5631. styleUpdates[styleName] = nextProp[styleName];
  5632. }
  5633. }
  5634. } else {
  5635. // Relies on `updateStylesByID` not mutating `styleUpdates`.
  5636. if (!styleUpdates) {
  5637. if (!updatePayload) {
  5638. updatePayload = [];
  5639. }
  5640. updatePayload.push(propKey, styleUpdates);
  5641. }
  5642. styleUpdates = nextProp;
  5643. }
  5644. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  5645. var nextHtml = nextProp ? nextProp[HTML$1] : undefined;
  5646. var lastHtml = lastProp ? lastProp[HTML$1] : undefined;
  5647. if (nextHtml != null) {
  5648. if (lastHtml !== nextHtml) {
  5649. (updatePayload = updatePayload || []).push(propKey, nextHtml);
  5650. }
  5651. }
  5652. } else if (propKey === CHILDREN) {
  5653. if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) {
  5654. (updatePayload = updatePayload || []).push(propKey, '' + nextProp);
  5655. }
  5656. } else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (registrationNameModules.hasOwnProperty(propKey)) {
  5657. if (nextProp != null) {
  5658. // We eagerly listen to this even though we haven't committed yet.
  5659. if ( typeof nextProp !== 'function') {
  5660. warnForInvalidEventListener(propKey, nextProp);
  5661. }
  5662. ensureListeningTo(rootContainerElement, propKey);
  5663. }
  5664. if (!updatePayload && lastProp !== nextProp) {
  5665. // This is a special case. If any listener updates we need to ensure
  5666. // that the "current" props pointer gets updated so we need a commit
  5667. // to update this element.
  5668. updatePayload = [];
  5669. }
  5670. } else {
  5671. // For any other property we always add it to the queue and then we
  5672. // filter it out using the whitelist during the commit.
  5673. (updatePayload = updatePayload || []).push(propKey, nextProp);
  5674. }
  5675. }
  5676. if (styleUpdates) {
  5677. {
  5678. validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE]);
  5679. }
  5680. (updatePayload = updatePayload || []).push(STYLE, styleUpdates);
  5681. }
  5682. return updatePayload;
  5683. } // Apply the diff.
  5684. function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) {
  5685. // Update checked *before* name.
  5686. // In the middle of an update, it is possible to have multiple checked.
  5687. // When a checked radio tries to change name, browser makes another radio's checked false.
  5688. if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) {
  5689. updateChecked(domElement, nextRawProps);
  5690. }
  5691. var wasCustomComponentTag = isCustomComponent(tag, lastRawProps);
  5692. var isCustomComponentTag = isCustomComponent(tag, nextRawProps); // Apply the diff.
  5693. updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); // TODO: Ensure that an update gets scheduled if any of the special props
  5694. // changed.
  5695. switch (tag) {
  5696. case 'input':
  5697. // Update the wrapper around inputs *after* updating props. This has to
  5698. // happen after `updateDOMProperties`. Otherwise HTML5 input validations
  5699. // raise warnings and prevent the new value from being assigned.
  5700. updateWrapper(domElement, nextRawProps);
  5701. break;
  5702. case 'textarea':
  5703. updateWrapper$1(domElement, nextRawProps);
  5704. break;
  5705. case 'select':
  5706. // <select> value update needs to occur after <option> children
  5707. // reconciliation
  5708. postUpdateWrapper(domElement, nextRawProps);
  5709. break;
  5710. }
  5711. }
  5712. function getPossibleStandardName(propName) {
  5713. {
  5714. var lowerCasedName = propName.toLowerCase();
  5715. if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  5716. return null;
  5717. }
  5718. return possibleStandardNames[lowerCasedName] || null;
  5719. }
  5720. }
  5721. function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) {
  5722. var isCustomComponentTag;
  5723. var extraAttributeNames;
  5724. {
  5725. suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true;
  5726. isCustomComponentTag = isCustomComponent(tag, rawProps);
  5727. validatePropertiesInDevelopment(tag, rawProps);
  5728. } // TODO: Make sure that we check isMounted before firing any of these events.
  5729. switch (tag) {
  5730. case 'iframe':
  5731. case 'object':
  5732. case 'embed':
  5733. trapBubbledEvent(TOP_LOAD, domElement);
  5734. break;
  5735. case 'video':
  5736. case 'audio':
  5737. // Create listener for each media event
  5738. for (var i = 0; i < mediaEventTypes.length; i++) {
  5739. trapBubbledEvent(mediaEventTypes[i], domElement);
  5740. }
  5741. break;
  5742. case 'source':
  5743. trapBubbledEvent(TOP_ERROR, domElement);
  5744. break;
  5745. case 'img':
  5746. case 'image':
  5747. case 'link':
  5748. trapBubbledEvent(TOP_ERROR, domElement);
  5749. trapBubbledEvent(TOP_LOAD, domElement);
  5750. break;
  5751. case 'form':
  5752. trapBubbledEvent(TOP_RESET, domElement);
  5753. trapBubbledEvent(TOP_SUBMIT, domElement);
  5754. break;
  5755. case 'details':
  5756. trapBubbledEvent(TOP_TOGGLE, domElement);
  5757. break;
  5758. case 'input':
  5759. initWrapperState(domElement, rawProps);
  5760. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  5761. // to onChange. Even if there is no listener.
  5762. ensureListeningTo(rootContainerElement, 'onChange');
  5763. break;
  5764. case 'option':
  5765. validateProps(domElement, rawProps);
  5766. break;
  5767. case 'select':
  5768. initWrapperState$1(domElement, rawProps);
  5769. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  5770. // to onChange. Even if there is no listener.
  5771. ensureListeningTo(rootContainerElement, 'onChange');
  5772. break;
  5773. case 'textarea':
  5774. initWrapperState$2(domElement, rawProps);
  5775. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  5776. // to onChange. Even if there is no listener.
  5777. ensureListeningTo(rootContainerElement, 'onChange');
  5778. break;
  5779. }
  5780. assertValidProps(tag, rawProps);
  5781. {
  5782. extraAttributeNames = new Set();
  5783. var attributes = domElement.attributes;
  5784. for (var _i = 0; _i < attributes.length; _i++) {
  5785. var name = attributes[_i].name.toLowerCase();
  5786. switch (name) {
  5787. // Built-in SSR attribute is whitelisted
  5788. case 'data-reactroot':
  5789. break;
  5790. // Controlled attributes are not validated
  5791. // TODO: Only ignore them on controlled tags.
  5792. case 'value':
  5793. break;
  5794. case 'checked':
  5795. break;
  5796. case 'selected':
  5797. break;
  5798. default:
  5799. // Intentionally use the original name.
  5800. // See discussion in https://github.com/facebook/react/pull/10676.
  5801. extraAttributeNames.add(attributes[_i].name);
  5802. }
  5803. }
  5804. }
  5805. var updatePayload = null;
  5806. for (var propKey in rawProps) {
  5807. if (!rawProps.hasOwnProperty(propKey)) {
  5808. continue;
  5809. }
  5810. var nextProp = rawProps[propKey];
  5811. if (propKey === CHILDREN) {
  5812. // For text content children we compare against textContent. This
  5813. // might match additional HTML that is hidden when we read it using
  5814. // textContent. E.g. "foo" will match "f<span>oo</span>" but that still
  5815. // satisfies our requirement. Our requirement is not to produce perfect
  5816. // HTML and attributes. Ideally we should preserve structure but it's
  5817. // ok not to if the visible content is still enough to indicate what
  5818. // even listeners these nodes might be wired up to.
  5819. // TODO: Warn if there is more than a single textNode as a child.
  5820. // TODO: Should we use domElement.firstChild.nodeValue to compare?
  5821. if (typeof nextProp === 'string') {
  5822. if (domElement.textContent !== nextProp) {
  5823. if ( !suppressHydrationWarning) {
  5824. warnForTextDifference(domElement.textContent, nextProp);
  5825. }
  5826. updatePayload = [CHILDREN, nextProp];
  5827. }
  5828. } else if (typeof nextProp === 'number') {
  5829. if (domElement.textContent !== '' + nextProp) {
  5830. if ( !suppressHydrationWarning) {
  5831. warnForTextDifference(domElement.textContent, nextProp);
  5832. }
  5833. updatePayload = [CHILDREN, '' + nextProp];
  5834. }
  5835. }
  5836. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  5837. if (nextProp != null) {
  5838. if ( typeof nextProp !== 'function') {
  5839. warnForInvalidEventListener(propKey, nextProp);
  5840. }
  5841. ensureListeningTo(rootContainerElement, propKey);
  5842. }
  5843. } else if ( // Convince Flow we've calculated it (it's DEV-only in this method.)
  5844. typeof isCustomComponentTag === 'boolean') {
  5845. // Validate that the properties correspond to their expected values.
  5846. var serverValue = void 0;
  5847. var propertyInfo = getPropertyInfo(propKey);
  5848. if (suppressHydrationWarning) ; else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || // Controlled attributes are not validated
  5849. // TODO: Only ignore them on controlled tags.
  5850. propKey === 'value' || propKey === 'checked' || propKey === 'selected') ; else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  5851. var serverHTML = domElement.innerHTML;
  5852. var nextHtml = nextProp ? nextProp[HTML$1] : undefined;
  5853. var expectedHTML = normalizeHTML(domElement, nextHtml != null ? nextHtml : '');
  5854. if (expectedHTML !== serverHTML) {
  5855. warnForPropDifference(propKey, serverHTML, expectedHTML);
  5856. }
  5857. } else if (propKey === STYLE) {
  5858. // $FlowFixMe - Should be inferred as not undefined.
  5859. extraAttributeNames.delete(propKey);
  5860. if (canDiffStyleForHydrationWarning) {
  5861. var expectedStyle = createDangerousStringForStyles(nextProp);
  5862. serverValue = domElement.getAttribute('style');
  5863. if (expectedStyle !== serverValue) {
  5864. warnForPropDifference(propKey, serverValue, expectedStyle);
  5865. }
  5866. }
  5867. } else if (isCustomComponentTag) {
  5868. // $FlowFixMe - Should be inferred as not undefined.
  5869. extraAttributeNames.delete(propKey.toLowerCase());
  5870. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  5871. if (nextProp !== serverValue) {
  5872. warnForPropDifference(propKey, serverValue, nextProp);
  5873. }
  5874. } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) {
  5875. var isMismatchDueToBadCasing = false;
  5876. if (propertyInfo !== null) {
  5877. // $FlowFixMe - Should be inferred as not undefined.
  5878. extraAttributeNames.delete(propertyInfo.attributeName);
  5879. serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo);
  5880. } else {
  5881. var ownNamespace = parentNamespace;
  5882. if (ownNamespace === HTML_NAMESPACE$1) {
  5883. ownNamespace = getIntrinsicNamespace(tag);
  5884. }
  5885. if (ownNamespace === HTML_NAMESPACE$1) {
  5886. // $FlowFixMe - Should be inferred as not undefined.
  5887. extraAttributeNames.delete(propKey.toLowerCase());
  5888. } else {
  5889. var standardName = getPossibleStandardName(propKey);
  5890. if (standardName !== null && standardName !== propKey) {
  5891. // If an SVG prop is supplied with bad casing, it will
  5892. // be successfully parsed from HTML, but will produce a mismatch
  5893. // (and would be incorrectly rendered on the client).
  5894. // However, we already warn about bad casing elsewhere.
  5895. // So we'll skip the misleading extra mismatch warning in this case.
  5896. isMismatchDueToBadCasing = true; // $FlowFixMe - Should be inferred as not undefined.
  5897. extraAttributeNames.delete(standardName);
  5898. } // $FlowFixMe - Should be inferred as not undefined.
  5899. extraAttributeNames.delete(propKey);
  5900. }
  5901. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  5902. }
  5903. if (nextProp !== serverValue && !isMismatchDueToBadCasing) {
  5904. warnForPropDifference(propKey, serverValue, nextProp);
  5905. }
  5906. }
  5907. }
  5908. }
  5909. {
  5910. // $FlowFixMe - Should be inferred as not undefined.
  5911. if (extraAttributeNames.size > 0 && !suppressHydrationWarning) {
  5912. // $FlowFixMe - Should be inferred as not undefined.
  5913. warnForExtraAttributes(extraAttributeNames);
  5914. }
  5915. }
  5916. switch (tag) {
  5917. case 'input':
  5918. // TODO: Make sure we check if this is still unmounted or do any clean
  5919. // up necessary since we never stop tracking anymore.
  5920. track(domElement);
  5921. postMountWrapper(domElement, rawProps, true);
  5922. break;
  5923. case 'textarea':
  5924. // TODO: Make sure we check if this is still unmounted or do any clean
  5925. // up necessary since we never stop tracking anymore.
  5926. track(domElement);
  5927. postMountWrapper$3(domElement);
  5928. break;
  5929. case 'select':
  5930. case 'option':
  5931. // For input and textarea we current always set the value property at
  5932. // post mount to force it to diverge from attributes. However, for
  5933. // option and select we don't quite do the same thing and select
  5934. // is not resilient to the DOM state changing so we don't do that here.
  5935. // TODO: Consider not doing this for input and textarea.
  5936. break;
  5937. default:
  5938. if (typeof rawProps.onClick === 'function') {
  5939. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  5940. trapClickOnNonInteractiveElement(domElement);
  5941. }
  5942. break;
  5943. }
  5944. return updatePayload;
  5945. }
  5946. function diffHydratedText(textNode, text) {
  5947. var isDifferent = textNode.nodeValue !== text;
  5948. return isDifferent;
  5949. }
  5950. function warnForUnmatchedText(textNode, text) {
  5951. {
  5952. warnForTextDifference(textNode.nodeValue, text);
  5953. }
  5954. }
  5955. function warnForDeletedHydratableElement(parentNode, child) {
  5956. {
  5957. if (didWarnInvalidHydration) {
  5958. return;
  5959. }
  5960. didWarnInvalidHydration = true;
  5961. error('Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase());
  5962. }
  5963. }
  5964. function warnForDeletedHydratableText(parentNode, child) {
  5965. {
  5966. if (didWarnInvalidHydration) {
  5967. return;
  5968. }
  5969. didWarnInvalidHydration = true;
  5970. error('Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase());
  5971. }
  5972. }
  5973. function warnForInsertedHydratedElement(parentNode, tag, props) {
  5974. {
  5975. if (didWarnInvalidHydration) {
  5976. return;
  5977. }
  5978. didWarnInvalidHydration = true;
  5979. error('Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase());
  5980. }
  5981. }
  5982. function warnForInsertedHydratedText(parentNode, text) {
  5983. {
  5984. if (text === '') {
  5985. // We expect to insert empty text nodes since they're not represented in
  5986. // the HTML.
  5987. // TODO: Remove this special case if we can just avoid inserting empty
  5988. // text nodes.
  5989. return;
  5990. }
  5991. if (didWarnInvalidHydration) {
  5992. return;
  5993. }
  5994. didWarnInvalidHydration = true;
  5995. error('Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase());
  5996. }
  5997. }
  5998. function restoreControlledState$3(domElement, tag, props) {
  5999. switch (tag) {
  6000. case 'input':
  6001. restoreControlledState(domElement, props);
  6002. return;
  6003. case 'textarea':
  6004. restoreControlledState$2(domElement, props);
  6005. return;
  6006. case 'select':
  6007. restoreControlledState$1(domElement, props);
  6008. return;
  6009. }
  6010. }
  6011. function getActiveElement(doc) {
  6012. doc = doc || (typeof document !== 'undefined' ? document : undefined);
  6013. if (typeof doc === 'undefined') {
  6014. return null;
  6015. }
  6016. try {
  6017. return doc.activeElement || doc.body;
  6018. } catch (e) {
  6019. return doc.body;
  6020. }
  6021. }
  6022. /**
  6023. * Given any node return the first leaf node without children.
  6024. *
  6025. * @param {DOMElement|DOMTextNode} node
  6026. * @return {DOMElement|DOMTextNode}
  6027. */
  6028. function getLeafNode(node) {
  6029. while (node && node.firstChild) {
  6030. node = node.firstChild;
  6031. }
  6032. return node;
  6033. }
  6034. /**
  6035. * Get the next sibling within a container. This will walk up the
  6036. * DOM if a node's siblings have been exhausted.
  6037. *
  6038. * @param {DOMElement|DOMTextNode} node
  6039. * @return {?DOMElement|DOMTextNode}
  6040. */
  6041. function getSiblingNode(node) {
  6042. while (node) {
  6043. if (node.nextSibling) {
  6044. return node.nextSibling;
  6045. }
  6046. node = node.parentNode;
  6047. }
  6048. }
  6049. /**
  6050. * Get object describing the nodes which contain characters at offset.
  6051. *
  6052. * @param {DOMElement|DOMTextNode} root
  6053. * @param {number} offset
  6054. * @return {?object}
  6055. */
  6056. function getNodeForCharacterOffset(root, offset) {
  6057. var node = getLeafNode(root);
  6058. var nodeStart = 0;
  6059. var nodeEnd = 0;
  6060. while (node) {
  6061. if (node.nodeType === TEXT_NODE) {
  6062. nodeEnd = nodeStart + node.textContent.length;
  6063. if (nodeStart <= offset && nodeEnd >= offset) {
  6064. return {
  6065. node: node,
  6066. offset: offset - nodeStart
  6067. };
  6068. }
  6069. nodeStart = nodeEnd;
  6070. }
  6071. node = getLeafNode(getSiblingNode(node));
  6072. }
  6073. }
  6074. /**
  6075. * @param {DOMElement} outerNode
  6076. * @return {?object}
  6077. */
  6078. function getOffsets(outerNode) {
  6079. var ownerDocument = outerNode.ownerDocument;
  6080. var win = ownerDocument && ownerDocument.defaultView || window;
  6081. var selection = win.getSelection && win.getSelection();
  6082. if (!selection || selection.rangeCount === 0) {
  6083. return null;
  6084. }
  6085. var anchorNode = selection.anchorNode,
  6086. anchorOffset = selection.anchorOffset,
  6087. focusNode = selection.focusNode,
  6088. focusOffset = selection.focusOffset; // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the
  6089. // up/down buttons on an <input type="number">. Anonymous divs do not seem to
  6090. // expose properties, triggering a "Permission denied error" if any of its
  6091. // properties are accessed. The only seemingly possible way to avoid erroring
  6092. // is to access a property that typically works for non-anonymous divs and
  6093. // catch any error that may otherwise arise. See
  6094. // https://bugzilla.mozilla.org/show_bug.cgi?id=208427
  6095. try {
  6096. /* eslint-disable no-unused-expressions */
  6097. anchorNode.nodeType;
  6098. focusNode.nodeType;
  6099. /* eslint-enable no-unused-expressions */
  6100. } catch (e) {
  6101. return null;
  6102. }
  6103. return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset);
  6104. }
  6105. /**
  6106. * Returns {start, end} where `start` is the character/codepoint index of
  6107. * (anchorNode, anchorOffset) within the textContent of `outerNode`, and
  6108. * `end` is the index of (focusNode, focusOffset).
  6109. *
  6110. * Returns null if you pass in garbage input but we should probably just crash.
  6111. *
  6112. * Exported only for testing.
  6113. */
  6114. function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) {
  6115. var length = 0;
  6116. var start = -1;
  6117. var end = -1;
  6118. var indexWithinAnchor = 0;
  6119. var indexWithinFocus = 0;
  6120. var node = outerNode;
  6121. var parentNode = null;
  6122. outer: while (true) {
  6123. var next = null;
  6124. while (true) {
  6125. if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) {
  6126. start = length + anchorOffset;
  6127. }
  6128. if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) {
  6129. end = length + focusOffset;
  6130. }
  6131. if (node.nodeType === TEXT_NODE) {
  6132. length += node.nodeValue.length;
  6133. }
  6134. if ((next = node.firstChild) === null) {
  6135. break;
  6136. } // Moving from `node` to its first child `next`.
  6137. parentNode = node;
  6138. node = next;
  6139. }
  6140. while (true) {
  6141. if (node === outerNode) {
  6142. // If `outerNode` has children, this is always the second time visiting
  6143. // it. If it has no children, this is still the first loop, and the only
  6144. // valid selection is anchorNode and focusNode both equal to this node
  6145. // and both offsets 0, in which case we will have handled above.
  6146. break outer;
  6147. }
  6148. if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) {
  6149. start = length;
  6150. }
  6151. if (parentNode === focusNode && ++indexWithinFocus === focusOffset) {
  6152. end = length;
  6153. }
  6154. if ((next = node.nextSibling) !== null) {
  6155. break;
  6156. }
  6157. node = parentNode;
  6158. parentNode = node.parentNode;
  6159. } // Moving from `node` to its next sibling `next`.
  6160. node = next;
  6161. }
  6162. if (start === -1 || end === -1) {
  6163. // This should never happen. (Would happen if the anchor/focus nodes aren't
  6164. // actually inside the passed-in node.)
  6165. return null;
  6166. }
  6167. return {
  6168. start: start,
  6169. end: end
  6170. };
  6171. }
  6172. /**
  6173. * In modern non-IE browsers, we can support both forward and backward
  6174. * selections.
  6175. *
  6176. * Note: IE10+ supports the Selection object, but it does not support
  6177. * the `extend` method, which means that even in modern IE, it's not possible
  6178. * to programmatically create a backward selection. Thus, for all IE
  6179. * versions, we use the old IE API to create our selections.
  6180. *
  6181. * @param {DOMElement|DOMTextNode} node
  6182. * @param {object} offsets
  6183. */
  6184. function setOffsets(node, offsets) {
  6185. var doc = node.ownerDocument || document;
  6186. var win = doc && doc.defaultView || window; // Edge fails with "Object expected" in some scenarios.
  6187. // (For instance: TinyMCE editor used in a list component that supports pasting to add more,
  6188. // fails when pasting 100+ items)
  6189. if (!win.getSelection) {
  6190. return;
  6191. }
  6192. var selection = win.getSelection();
  6193. var length = node.textContent.length;
  6194. var start = Math.min(offsets.start, length);
  6195. var end = offsets.end === undefined ? start : Math.min(offsets.end, length); // IE 11 uses modern selection, but doesn't support the extend method.
  6196. // Flip backward selections, so we can set with a single range.
  6197. if (!selection.extend && start > end) {
  6198. var temp = end;
  6199. end = start;
  6200. start = temp;
  6201. }
  6202. var startMarker = getNodeForCharacterOffset(node, start);
  6203. var endMarker = getNodeForCharacterOffset(node, end);
  6204. if (startMarker && endMarker) {
  6205. if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) {
  6206. return;
  6207. }
  6208. var range = doc.createRange();
  6209. range.setStart(startMarker.node, startMarker.offset);
  6210. selection.removeAllRanges();
  6211. if (start > end) {
  6212. selection.addRange(range);
  6213. selection.extend(endMarker.node, endMarker.offset);
  6214. } else {
  6215. range.setEnd(endMarker.node, endMarker.offset);
  6216. selection.addRange(range);
  6217. }
  6218. }
  6219. }
  6220. function isTextNode(node) {
  6221. return node && node.nodeType === TEXT_NODE;
  6222. }
  6223. function containsNode(outerNode, innerNode) {
  6224. if (!outerNode || !innerNode) {
  6225. return false;
  6226. } else if (outerNode === innerNode) {
  6227. return true;
  6228. } else if (isTextNode(outerNode)) {
  6229. return false;
  6230. } else if (isTextNode(innerNode)) {
  6231. return containsNode(outerNode, innerNode.parentNode);
  6232. } else if ('contains' in outerNode) {
  6233. return outerNode.contains(innerNode);
  6234. } else if (outerNode.compareDocumentPosition) {
  6235. return !!(outerNode.compareDocumentPosition(innerNode) & 16);
  6236. } else {
  6237. return false;
  6238. }
  6239. }
  6240. function isInDocument(node) {
  6241. return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node);
  6242. }
  6243. function isSameOriginFrame(iframe) {
  6244. try {
  6245. // Accessing the contentDocument of a HTMLIframeElement can cause the browser
  6246. // to throw, e.g. if it has a cross-origin src attribute.
  6247. // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g:
  6248. // iframe.contentDocument.defaultView;
  6249. // A safety way is to access one of the cross origin properties: Window or Location
  6250. // Which might result in "SecurityError" DOM Exception and it is compatible to Safari.
  6251. // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl
  6252. return typeof iframe.contentWindow.location.href === 'string';
  6253. } catch (err) {
  6254. return false;
  6255. }
  6256. }
  6257. function getActiveElementDeep() {
  6258. var win = window;
  6259. var element = getActiveElement();
  6260. while (element instanceof win.HTMLIFrameElement) {
  6261. if (isSameOriginFrame(element)) {
  6262. win = element.contentWindow;
  6263. } else {
  6264. return element;
  6265. }
  6266. element = getActiveElement(win.document);
  6267. }
  6268. return element;
  6269. }
  6270. /**
  6271. * @ReactInputSelection: React input selection module. Based on Selection.js,
  6272. * but modified to be suitable for react and has a couple of bug fixes (doesn't
  6273. * assume buttons have range selections allowed).
  6274. * Input selection module for React.
  6275. */
  6276. /**
  6277. * @hasSelectionCapabilities: we get the element types that support selection
  6278. * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart`
  6279. * and `selectionEnd` rows.
  6280. */
  6281. function hasSelectionCapabilities(elem) {
  6282. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  6283. return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true');
  6284. }
  6285. function getSelectionInformation() {
  6286. var focusedElem = getActiveElementDeep();
  6287. return {
  6288. // Used by Flare
  6289. activeElementDetached: null,
  6290. focusedElem: focusedElem,
  6291. selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null
  6292. };
  6293. }
  6294. /**
  6295. * @restoreSelection: If any selection information was potentially lost,
  6296. * restore it. This is useful when performing operations that could remove dom
  6297. * nodes and place them back in, resulting in focus being lost.
  6298. */
  6299. function restoreSelection(priorSelectionInformation) {
  6300. var curFocusedElem = getActiveElementDeep();
  6301. var priorFocusedElem = priorSelectionInformation.focusedElem;
  6302. var priorSelectionRange = priorSelectionInformation.selectionRange;
  6303. if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
  6304. if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) {
  6305. setSelection(priorFocusedElem, priorSelectionRange);
  6306. } // Focusing a node can change the scroll position, which is undesirable
  6307. var ancestors = [];
  6308. var ancestor = priorFocusedElem;
  6309. while (ancestor = ancestor.parentNode) {
  6310. if (ancestor.nodeType === ELEMENT_NODE) {
  6311. ancestors.push({
  6312. element: ancestor,
  6313. left: ancestor.scrollLeft,
  6314. top: ancestor.scrollTop
  6315. });
  6316. }
  6317. }
  6318. if (typeof priorFocusedElem.focus === 'function') {
  6319. priorFocusedElem.focus();
  6320. }
  6321. for (var i = 0; i < ancestors.length; i++) {
  6322. var info = ancestors[i];
  6323. info.element.scrollLeft = info.left;
  6324. info.element.scrollTop = info.top;
  6325. }
  6326. }
  6327. }
  6328. /**
  6329. * @getSelection: Gets the selection bounds of a focused textarea, input or
  6330. * contentEditable node.
  6331. * -@input: Look up selection bounds of this input
  6332. * -@return {start: selectionStart, end: selectionEnd}
  6333. */
  6334. function getSelection(input) {
  6335. var selection;
  6336. if ('selectionStart' in input) {
  6337. // Modern browser with input or textarea.
  6338. selection = {
  6339. start: input.selectionStart,
  6340. end: input.selectionEnd
  6341. };
  6342. } else {
  6343. // Content editable or old IE textarea.
  6344. selection = getOffsets(input);
  6345. }
  6346. return selection || {
  6347. start: 0,
  6348. end: 0
  6349. };
  6350. }
  6351. /**
  6352. * @setSelection: Sets the selection bounds of a textarea or input and focuses
  6353. * the input.
  6354. * -@input Set selection bounds of this input or textarea
  6355. * -@offsets Object of same form that is returned from get*
  6356. */
  6357. function setSelection(input, offsets) {
  6358. var start = offsets.start,
  6359. end = offsets.end;
  6360. if (end === undefined) {
  6361. end = start;
  6362. }
  6363. if ('selectionStart' in input) {
  6364. input.selectionStart = start;
  6365. input.selectionEnd = Math.min(end, input.value.length);
  6366. } else {
  6367. setOffsets(input, offsets);
  6368. }
  6369. }
  6370. var validateDOMNesting = function () {};
  6371. var updatedAncestorInfo = function () {};
  6372. {
  6373. // This validation code was written based on the HTML5 parsing spec:
  6374. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  6375. //
  6376. // Note: this does not catch all invalid nesting, nor does it try to (as it's
  6377. // not clear what practical benefit doing so provides); instead, we warn only
  6378. // for cases where the parser will give a parse tree differing from what React
  6379. // intended. For example, <b><div></div></b> is invalid but we don't warn
  6380. // because it still parses correctly; we do warn for other cases like nested
  6381. // <p> tags where the beginning of the second element implicitly closes the
  6382. // first, causing a confusing mess.
  6383. // https://html.spec.whatwg.org/multipage/syntax.html#special
  6384. var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  6385. var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point
  6386. // TODO: Distinguish by namespace here -- for <title>, including it here
  6387. // errs on the side of fewer warnings
  6388. 'foreignObject', 'desc', 'title']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope
  6389. var buttonScopeTags = inScopeTags.concat(['button']); // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags
  6390. var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
  6391. var emptyAncestorInfo = {
  6392. current: null,
  6393. formTag: null,
  6394. aTagInScope: null,
  6395. buttonTagInScope: null,
  6396. nobrTagInScope: null,
  6397. pTagInButtonScope: null,
  6398. listItemTagAutoclosing: null,
  6399. dlItemTagAutoclosing: null
  6400. };
  6401. updatedAncestorInfo = function (oldInfo, tag) {
  6402. var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo);
  6403. var info = {
  6404. tag: tag
  6405. };
  6406. if (inScopeTags.indexOf(tag) !== -1) {
  6407. ancestorInfo.aTagInScope = null;
  6408. ancestorInfo.buttonTagInScope = null;
  6409. ancestorInfo.nobrTagInScope = null;
  6410. }
  6411. if (buttonScopeTags.indexOf(tag) !== -1) {
  6412. ancestorInfo.pTagInButtonScope = null;
  6413. } // See rules for 'li', 'dd', 'dt' start tags in
  6414. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  6415. if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') {
  6416. ancestorInfo.listItemTagAutoclosing = null;
  6417. ancestorInfo.dlItemTagAutoclosing = null;
  6418. }
  6419. ancestorInfo.current = info;
  6420. if (tag === 'form') {
  6421. ancestorInfo.formTag = info;
  6422. }
  6423. if (tag === 'a') {
  6424. ancestorInfo.aTagInScope = info;
  6425. }
  6426. if (tag === 'button') {
  6427. ancestorInfo.buttonTagInScope = info;
  6428. }
  6429. if (tag === 'nobr') {
  6430. ancestorInfo.nobrTagInScope = info;
  6431. }
  6432. if (tag === 'p') {
  6433. ancestorInfo.pTagInButtonScope = info;
  6434. }
  6435. if (tag === 'li') {
  6436. ancestorInfo.listItemTagAutoclosing = info;
  6437. }
  6438. if (tag === 'dd' || tag === 'dt') {
  6439. ancestorInfo.dlItemTagAutoclosing = info;
  6440. }
  6441. return ancestorInfo;
  6442. };
  6443. /**
  6444. * Returns whether
  6445. */
  6446. var isTagValidWithParent = function (tag, parentTag) {
  6447. // First, let's check if we're in an unusual parsing mode...
  6448. switch (parentTag) {
  6449. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect
  6450. case 'select':
  6451. return tag === 'option' || tag === 'optgroup' || tag === '#text';
  6452. case 'optgroup':
  6453. return tag === 'option' || tag === '#text';
  6454. // Strictly speaking, seeing an <option> doesn't mean we're in a <select>
  6455. // but
  6456. case 'option':
  6457. return tag === '#text';
  6458. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd
  6459. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption
  6460. // No special behavior since these rules fall back to "in body" mode for
  6461. // all except special table nodes which cause bad parsing behavior anyway.
  6462. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr
  6463. case 'tr':
  6464. return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template';
  6465. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody
  6466. case 'tbody':
  6467. case 'thead':
  6468. case 'tfoot':
  6469. return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template';
  6470. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup
  6471. case 'colgroup':
  6472. return tag === 'col' || tag === 'template';
  6473. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable
  6474. case 'table':
  6475. return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template';
  6476. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead
  6477. case 'head':
  6478. return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template';
  6479. // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
  6480. case 'html':
  6481. return tag === 'head' || tag === 'body' || tag === 'frameset';
  6482. case 'frameset':
  6483. return tag === 'frame';
  6484. case '#document':
  6485. return tag === 'html';
  6486. } // Probably in the "in body" parsing mode, so we outlaw only tag combos
  6487. // where the parsing rules cause implicit opens or closes to be added.
  6488. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  6489. switch (tag) {
  6490. case 'h1':
  6491. case 'h2':
  6492. case 'h3':
  6493. case 'h4':
  6494. case 'h5':
  6495. case 'h6':
  6496. return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6';
  6497. case 'rp':
  6498. case 'rt':
  6499. return impliedEndTags.indexOf(parentTag) === -1;
  6500. case 'body':
  6501. case 'caption':
  6502. case 'col':
  6503. case 'colgroup':
  6504. case 'frameset':
  6505. case 'frame':
  6506. case 'head':
  6507. case 'html':
  6508. case 'tbody':
  6509. case 'td':
  6510. case 'tfoot':
  6511. case 'th':
  6512. case 'thead':
  6513. case 'tr':
  6514. // These tags are only valid with a few parents that have special child
  6515. // parsing rules -- if we're down here, then none of those matched and
  6516. // so we allow it only if we don't know what the parent is, as all other
  6517. // cases are invalid.
  6518. return parentTag == null;
  6519. }
  6520. return true;
  6521. };
  6522. /**
  6523. * Returns whether
  6524. */
  6525. var findInvalidAncestorForTag = function (tag, ancestorInfo) {
  6526. switch (tag) {
  6527. case 'address':
  6528. case 'article':
  6529. case 'aside':
  6530. case 'blockquote':
  6531. case 'center':
  6532. case 'details':
  6533. case 'dialog':
  6534. case 'dir':
  6535. case 'div':
  6536. case 'dl':
  6537. case 'fieldset':
  6538. case 'figcaption':
  6539. case 'figure':
  6540. case 'footer':
  6541. case 'header':
  6542. case 'hgroup':
  6543. case 'main':
  6544. case 'menu':
  6545. case 'nav':
  6546. case 'ol':
  6547. case 'p':
  6548. case 'section':
  6549. case 'summary':
  6550. case 'ul':
  6551. case 'pre':
  6552. case 'listing':
  6553. case 'table':
  6554. case 'hr':
  6555. case 'xmp':
  6556. case 'h1':
  6557. case 'h2':
  6558. case 'h3':
  6559. case 'h4':
  6560. case 'h5':
  6561. case 'h6':
  6562. return ancestorInfo.pTagInButtonScope;
  6563. case 'form':
  6564. return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
  6565. case 'li':
  6566. return ancestorInfo.listItemTagAutoclosing;
  6567. case 'dd':
  6568. case 'dt':
  6569. return ancestorInfo.dlItemTagAutoclosing;
  6570. case 'button':
  6571. return ancestorInfo.buttonTagInScope;
  6572. case 'a':
  6573. // Spec says something about storing a list of markers, but it sounds
  6574. // equivalent to this check.
  6575. return ancestorInfo.aTagInScope;
  6576. case 'nobr':
  6577. return ancestorInfo.nobrTagInScope;
  6578. }
  6579. return null;
  6580. };
  6581. var didWarn$1 = {};
  6582. validateDOMNesting = function (childTag, childText, ancestorInfo) {
  6583. ancestorInfo = ancestorInfo || emptyAncestorInfo;
  6584. var parentInfo = ancestorInfo.current;
  6585. var parentTag = parentInfo && parentInfo.tag;
  6586. if (childText != null) {
  6587. if (childTag != null) {
  6588. error('validateDOMNesting: when childText is passed, childTag should be null');
  6589. }
  6590. childTag = '#text';
  6591. }
  6592. var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
  6593. var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
  6594. var invalidParentOrAncestor = invalidParent || invalidAncestor;
  6595. if (!invalidParentOrAncestor) {
  6596. return;
  6597. }
  6598. var ancestorTag = invalidParentOrAncestor.tag;
  6599. var addendum = getCurrentFiberStackInDev();
  6600. var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum;
  6601. if (didWarn$1[warnKey]) {
  6602. return;
  6603. }
  6604. didWarn$1[warnKey] = true;
  6605. var tagDisplayName = childTag;
  6606. var whitespaceInfo = '';
  6607. if (childTag === '#text') {
  6608. if (/\S/.test(childText)) {
  6609. tagDisplayName = 'Text nodes';
  6610. } else {
  6611. tagDisplayName = 'Whitespace text nodes';
  6612. whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.';
  6613. }
  6614. } else {
  6615. tagDisplayName = '<' + childTag + '>';
  6616. }
  6617. if (invalidParent) {
  6618. var info = '';
  6619. if (ancestorTag === 'table' && childTag === 'tr') {
  6620. info += ' Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by ' + 'the browser.';
  6621. }
  6622. error('validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info);
  6623. } else {
  6624. error('validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.', tagDisplayName, ancestorTag);
  6625. }
  6626. };
  6627. }
  6628. var SUPPRESS_HYDRATION_WARNING$1;
  6629. {
  6630. SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning';
  6631. }
  6632. var SUSPENSE_START_DATA = '$';
  6633. var SUSPENSE_END_DATA = '/$';
  6634. var SUSPENSE_PENDING_START_DATA = '$?';
  6635. var SUSPENSE_FALLBACK_START_DATA = '$!';
  6636. var STYLE$1 = 'style';
  6637. var eventsEnabled = null;
  6638. var selectionInformation = null;
  6639. function shouldAutoFocusHostComponent(type, props) {
  6640. switch (type) {
  6641. case 'button':
  6642. case 'input':
  6643. case 'select':
  6644. case 'textarea':
  6645. return !!props.autoFocus;
  6646. }
  6647. return false;
  6648. }
  6649. function getRootHostContext(rootContainerInstance) {
  6650. var type;
  6651. var namespace;
  6652. var nodeType = rootContainerInstance.nodeType;
  6653. switch (nodeType) {
  6654. case DOCUMENT_NODE:
  6655. case DOCUMENT_FRAGMENT_NODE:
  6656. {
  6657. type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment';
  6658. var root = rootContainerInstance.documentElement;
  6659. namespace = root ? root.namespaceURI : getChildNamespace(null, '');
  6660. break;
  6661. }
  6662. default:
  6663. {
  6664. var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance;
  6665. var ownNamespace = container.namespaceURI || null;
  6666. type = container.tagName;
  6667. namespace = getChildNamespace(ownNamespace, type);
  6668. break;
  6669. }
  6670. }
  6671. {
  6672. var validatedTag = type.toLowerCase();
  6673. var ancestorInfo = updatedAncestorInfo(null, validatedTag);
  6674. return {
  6675. namespace: namespace,
  6676. ancestorInfo: ancestorInfo
  6677. };
  6678. }
  6679. }
  6680. function getChildHostContext(parentHostContext, type, rootContainerInstance) {
  6681. {
  6682. var parentHostContextDev = parentHostContext;
  6683. var namespace = getChildNamespace(parentHostContextDev.namespace, type);
  6684. var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type);
  6685. return {
  6686. namespace: namespace,
  6687. ancestorInfo: ancestorInfo
  6688. };
  6689. }
  6690. }
  6691. function getPublicInstance(instance) {
  6692. return instance;
  6693. }
  6694. function prepareForCommit(containerInfo) {
  6695. eventsEnabled = isEnabled();
  6696. selectionInformation = getSelectionInformation();
  6697. setEnabled(false);
  6698. }
  6699. function resetAfterCommit(containerInfo) {
  6700. restoreSelection(selectionInformation);
  6701. setEnabled(eventsEnabled);
  6702. eventsEnabled = null;
  6703. selectionInformation = null;
  6704. }
  6705. function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  6706. var parentNamespace;
  6707. {
  6708. // TODO: take namespace into account when validating.
  6709. var hostContextDev = hostContext;
  6710. validateDOMNesting(type, null, hostContextDev.ancestorInfo);
  6711. if (typeof props.children === 'string' || typeof props.children === 'number') {
  6712. var string = '' + props.children;
  6713. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  6714. validateDOMNesting(null, string, ownAncestorInfo);
  6715. }
  6716. parentNamespace = hostContextDev.namespace;
  6717. }
  6718. var domElement = createElement(type, props, rootContainerInstance, parentNamespace);
  6719. precacheFiberNode(internalInstanceHandle, domElement);
  6720. updateFiberProps(domElement, props);
  6721. return domElement;
  6722. }
  6723. function appendInitialChild(parentInstance, child) {
  6724. parentInstance.appendChild(child);
  6725. }
  6726. function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) {
  6727. setInitialProperties(domElement, type, props, rootContainerInstance);
  6728. return shouldAutoFocusHostComponent(type, props);
  6729. }
  6730. function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) {
  6731. {
  6732. var hostContextDev = hostContext;
  6733. if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) {
  6734. var string = '' + newProps.children;
  6735. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  6736. validateDOMNesting(null, string, ownAncestorInfo);
  6737. }
  6738. }
  6739. return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance);
  6740. }
  6741. function shouldSetTextContent(type, props) {
  6742. return type === 'textarea' || type === 'option' || type === 'noscript' || typeof props.children === 'string' || typeof props.children === 'number' || typeof props.dangerouslySetInnerHTML === 'object' && props.dangerouslySetInnerHTML !== null && props.dangerouslySetInnerHTML.__html != null;
  6743. }
  6744. function shouldDeprioritizeSubtree(type, props) {
  6745. return !!props.hidden;
  6746. }
  6747. function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
  6748. {
  6749. var hostContextDev = hostContext;
  6750. validateDOMNesting(null, text, hostContextDev.ancestorInfo);
  6751. }
  6752. var textNode = createTextNode(text, rootContainerInstance);
  6753. precacheFiberNode(internalInstanceHandle, textNode);
  6754. return textNode;
  6755. }
  6756. // if a component just imports ReactDOM (e.g. for findDOMNode).
  6757. // Some environments might not have setTimeout or clearTimeout.
  6758. var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
  6759. var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
  6760. var noTimeout = -1; // -------------------
  6761. function commitMount(domElement, type, newProps, internalInstanceHandle) {
  6762. // Despite the naming that might imply otherwise, this method only
  6763. // fires if there is an `Update` effect scheduled during mounting.
  6764. // This happens if `finalizeInitialChildren` returns `true` (which it
  6765. // does to implement the `autoFocus` attribute on the client). But
  6766. // there are also other cases when this might happen (such as patching
  6767. // up text content during hydration mismatch). So we'll check this again.
  6768. if (shouldAutoFocusHostComponent(type, newProps)) {
  6769. domElement.focus();
  6770. }
  6771. }
  6772. function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) {
  6773. // Update the props handle so that we know which props are the ones with
  6774. // with current event handlers.
  6775. updateFiberProps(domElement, newProps); // Apply the diff to the DOM node.
  6776. updateProperties(domElement, updatePayload, type, oldProps, newProps);
  6777. }
  6778. function resetTextContent(domElement) {
  6779. setTextContent(domElement, '');
  6780. }
  6781. function commitTextUpdate(textInstance, oldText, newText) {
  6782. textInstance.nodeValue = newText;
  6783. }
  6784. function appendChild(parentInstance, child) {
  6785. parentInstance.appendChild(child);
  6786. }
  6787. function appendChildToContainer(container, child) {
  6788. var parentNode;
  6789. if (container.nodeType === COMMENT_NODE) {
  6790. parentNode = container.parentNode;
  6791. parentNode.insertBefore(child, container);
  6792. } else {
  6793. parentNode = container;
  6794. parentNode.appendChild(child);
  6795. } // This container might be used for a portal.
  6796. // If something inside a portal is clicked, that click should bubble
  6797. // through the React tree. However, on Mobile Safari the click would
  6798. // never bubble through the *DOM* tree unless an ancestor with onclick
  6799. // event exists. So we wouldn't see it and dispatch it.
  6800. // This is why we ensure that non React root containers have inline onclick
  6801. // defined.
  6802. // https://github.com/facebook/react/issues/11918
  6803. var reactRootContainer = container._reactRootContainer;
  6804. if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) {
  6805. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  6806. trapClickOnNonInteractiveElement(parentNode);
  6807. }
  6808. }
  6809. function insertBefore(parentInstance, child, beforeChild) {
  6810. parentInstance.insertBefore(child, beforeChild);
  6811. }
  6812. function insertInContainerBefore(container, child, beforeChild) {
  6813. if (container.nodeType === COMMENT_NODE) {
  6814. container.parentNode.insertBefore(child, beforeChild);
  6815. } else {
  6816. container.insertBefore(child, beforeChild);
  6817. }
  6818. }
  6819. function removeChild(parentInstance, child) {
  6820. parentInstance.removeChild(child);
  6821. }
  6822. function removeChildFromContainer(container, child) {
  6823. if (container.nodeType === COMMENT_NODE) {
  6824. container.parentNode.removeChild(child);
  6825. } else {
  6826. container.removeChild(child);
  6827. }
  6828. }
  6829. function hideInstance(instance) {
  6830. // pass host context to this method?
  6831. instance = instance;
  6832. var style = instance.style;
  6833. if (typeof style.setProperty === 'function') {
  6834. style.setProperty('display', 'none', 'important');
  6835. } else {
  6836. style.display = 'none';
  6837. }
  6838. }
  6839. function hideTextInstance(textInstance) {
  6840. textInstance.nodeValue = '';
  6841. }
  6842. function unhideInstance(instance, props) {
  6843. instance = instance;
  6844. var styleProp = props[STYLE$1];
  6845. var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null;
  6846. instance.style.display = dangerousStyleValue('display', display);
  6847. }
  6848. function unhideTextInstance(textInstance, text) {
  6849. textInstance.nodeValue = text;
  6850. } // -------------------
  6851. function canHydrateInstance(instance, type, props) {
  6852. if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) {
  6853. return null;
  6854. } // This has now been refined to an element node.
  6855. return instance;
  6856. }
  6857. function canHydrateTextInstance(instance, text) {
  6858. if (text === '' || instance.nodeType !== TEXT_NODE) {
  6859. // Empty strings are not parsed by HTML so there won't be a correct match here.
  6860. return null;
  6861. } // This has now been refined to a text node.
  6862. return instance;
  6863. }
  6864. function isSuspenseInstancePending(instance) {
  6865. return instance.data === SUSPENSE_PENDING_START_DATA;
  6866. }
  6867. function isSuspenseInstanceFallback(instance) {
  6868. return instance.data === SUSPENSE_FALLBACK_START_DATA;
  6869. }
  6870. function getNextHydratable(node) {
  6871. // Skip non-hydratable nodes.
  6872. for (; node != null; node = node.nextSibling) {
  6873. var nodeType = node.nodeType;
  6874. if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) {
  6875. break;
  6876. }
  6877. }
  6878. return node;
  6879. }
  6880. function getNextHydratableSibling(instance) {
  6881. return getNextHydratable(instance.nextSibling);
  6882. }
  6883. function getFirstHydratableChild(parentInstance) {
  6884. return getNextHydratable(parentInstance.firstChild);
  6885. }
  6886. function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  6887. precacheFiberNode(internalInstanceHandle, instance); // TODO: Possibly defer this until the commit phase where all the events
  6888. // get attached.
  6889. updateFiberProps(instance, props);
  6890. var parentNamespace;
  6891. {
  6892. var hostContextDev = hostContext;
  6893. parentNamespace = hostContextDev.namespace;
  6894. }
  6895. return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance);
  6896. }
  6897. function hydrateTextInstance(textInstance, text, internalInstanceHandle) {
  6898. precacheFiberNode(internalInstanceHandle, textInstance);
  6899. return diffHydratedText(textInstance, text);
  6900. }
  6901. function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) {
  6902. var node = suspenseInstance.nextSibling; // Skip past all nodes within this suspense boundary.
  6903. // There might be nested nodes so we need to keep track of how
  6904. // deep we are and only break out when we're back on top.
  6905. var depth = 0;
  6906. while (node) {
  6907. if (node.nodeType === COMMENT_NODE) {
  6908. var data = node.data;
  6909. if (data === SUSPENSE_END_DATA) {
  6910. if (depth === 0) {
  6911. return getNextHydratableSibling(node);
  6912. } else {
  6913. depth--;
  6914. }
  6915. } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
  6916. depth++;
  6917. }
  6918. }
  6919. node = node.nextSibling;
  6920. } // TODO: Warn, we didn't find the end comment boundary.
  6921. return null;
  6922. } // Returns the SuspenseInstance if this node is a direct child of a
  6923. // SuspenseInstance. I.e. if its previous sibling is a Comment with
  6924. // SUSPENSE_x_START_DATA. Otherwise, null.
  6925. function getParentSuspenseInstance(targetInstance) {
  6926. var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary.
  6927. // There might be nested nodes so we need to keep track of how
  6928. // deep we are and only break out when we're back on top.
  6929. var depth = 0;
  6930. while (node) {
  6931. if (node.nodeType === COMMENT_NODE) {
  6932. var data = node.data;
  6933. if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
  6934. if (depth === 0) {
  6935. return node;
  6936. } else {
  6937. depth--;
  6938. }
  6939. } else if (data === SUSPENSE_END_DATA) {
  6940. depth++;
  6941. }
  6942. }
  6943. node = node.previousSibling;
  6944. }
  6945. return null;
  6946. }
  6947. function commitHydratedContainer(container) {
  6948. // Retry if any event replaying was blocked on this.
  6949. retryIfBlockedOn(container);
  6950. }
  6951. function commitHydratedSuspenseInstance(suspenseInstance) {
  6952. // Retry if any event replaying was blocked on this.
  6953. retryIfBlockedOn(suspenseInstance);
  6954. }
  6955. function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) {
  6956. {
  6957. warnForUnmatchedText(textInstance, text);
  6958. }
  6959. }
  6960. function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) {
  6961. if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
  6962. warnForUnmatchedText(textInstance, text);
  6963. }
  6964. }
  6965. function didNotHydrateContainerInstance(parentContainer, instance) {
  6966. {
  6967. if (instance.nodeType === ELEMENT_NODE) {
  6968. warnForDeletedHydratableElement(parentContainer, instance);
  6969. } else if (instance.nodeType === COMMENT_NODE) ; else {
  6970. warnForDeletedHydratableText(parentContainer, instance);
  6971. }
  6972. }
  6973. }
  6974. function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) {
  6975. if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
  6976. if (instance.nodeType === ELEMENT_NODE) {
  6977. warnForDeletedHydratableElement(parentInstance, instance);
  6978. } else if (instance.nodeType === COMMENT_NODE) ; else {
  6979. warnForDeletedHydratableText(parentInstance, instance);
  6980. }
  6981. }
  6982. }
  6983. function didNotFindHydratableContainerInstance(parentContainer, type, props) {
  6984. {
  6985. warnForInsertedHydratedElement(parentContainer, type);
  6986. }
  6987. }
  6988. function didNotFindHydratableContainerTextInstance(parentContainer, text) {
  6989. {
  6990. warnForInsertedHydratedText(parentContainer, text);
  6991. }
  6992. }
  6993. function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) {
  6994. if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
  6995. warnForInsertedHydratedElement(parentInstance, type);
  6996. }
  6997. }
  6998. function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) {
  6999. if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
  7000. warnForInsertedHydratedText(parentInstance, text);
  7001. }
  7002. }
  7003. function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) {
  7004. if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) ;
  7005. }
  7006. var randomKey = Math.random().toString(36).slice(2);
  7007. var internalInstanceKey = '__reactInternalInstance$' + randomKey;
  7008. var internalEventHandlersKey = '__reactEventHandlers$' + randomKey;
  7009. var internalContainerInstanceKey = '__reactContainere$' + randomKey;
  7010. function precacheFiberNode(hostInst, node) {
  7011. node[internalInstanceKey] = hostInst;
  7012. }
  7013. function markContainerAsRoot(hostRoot, node) {
  7014. node[internalContainerInstanceKey] = hostRoot;
  7015. }
  7016. function unmarkContainerAsRoot(node) {
  7017. node[internalContainerInstanceKey] = null;
  7018. }
  7019. function isContainerMarkedAsRoot(node) {
  7020. return !!node[internalContainerInstanceKey];
  7021. } // Given a DOM node, return the closest HostComponent or HostText fiber ancestor.
  7022. // If the target node is part of a hydrated or not yet rendered subtree, then
  7023. // this may also return a SuspenseComponent or HostRoot to indicate that.
  7024. // Conceptually the HostRoot fiber is a child of the Container node. So if you
  7025. // pass the Container node as the targetNode, you will not actually get the
  7026. // HostRoot back. To get to the HostRoot, you need to pass a child of it.
  7027. // The same thing applies to Suspense boundaries.
  7028. function getClosestInstanceFromNode(targetNode) {
  7029. var targetInst = targetNode[internalInstanceKey];
  7030. if (targetInst) {
  7031. // Don't return HostRoot or SuspenseComponent here.
  7032. return targetInst;
  7033. } // If the direct event target isn't a React owned DOM node, we need to look
  7034. // to see if one of its parents is a React owned DOM node.
  7035. var parentNode = targetNode.parentNode;
  7036. while (parentNode) {
  7037. // We'll check if this is a container root that could include
  7038. // React nodes in the future. We need to check this first because
  7039. // if we're a child of a dehydrated container, we need to first
  7040. // find that inner container before moving on to finding the parent
  7041. // instance. Note that we don't check this field on the targetNode
  7042. // itself because the fibers are conceptually between the container
  7043. // node and the first child. It isn't surrounding the container node.
  7044. // If it's not a container, we check if it's an instance.
  7045. targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey];
  7046. if (targetInst) {
  7047. // Since this wasn't the direct target of the event, we might have
  7048. // stepped past dehydrated DOM nodes to get here. However they could
  7049. // also have been non-React nodes. We need to answer which one.
  7050. // If we the instance doesn't have any children, then there can't be
  7051. // a nested suspense boundary within it. So we can use this as a fast
  7052. // bailout. Most of the time, when people add non-React children to
  7053. // the tree, it is using a ref to a child-less DOM node.
  7054. // Normally we'd only need to check one of the fibers because if it
  7055. // has ever gone from having children to deleting them or vice versa
  7056. // it would have deleted the dehydrated boundary nested inside already.
  7057. // However, since the HostRoot starts out with an alternate it might
  7058. // have one on the alternate so we need to check in case this was a
  7059. // root.
  7060. var alternate = targetInst.alternate;
  7061. if (targetInst.child !== null || alternate !== null && alternate.child !== null) {
  7062. // Next we need to figure out if the node that skipped past is
  7063. // nested within a dehydrated boundary and if so, which one.
  7064. var suspenseInstance = getParentSuspenseInstance(targetNode);
  7065. while (suspenseInstance !== null) {
  7066. // We found a suspense instance. That means that we haven't
  7067. // hydrated it yet. Even though we leave the comments in the
  7068. // DOM after hydrating, and there are boundaries in the DOM
  7069. // that could already be hydrated, we wouldn't have found them
  7070. // through this pass since if the target is hydrated it would
  7071. // have had an internalInstanceKey on it.
  7072. // Let's get the fiber associated with the SuspenseComponent
  7073. // as the deepest instance.
  7074. var targetSuspenseInst = suspenseInstance[internalInstanceKey];
  7075. if (targetSuspenseInst) {
  7076. return targetSuspenseInst;
  7077. } // If we don't find a Fiber on the comment, it might be because
  7078. // we haven't gotten to hydrate it yet. There might still be a
  7079. // parent boundary that hasn't above this one so we need to find
  7080. // the outer most that is known.
  7081. suspenseInstance = getParentSuspenseInstance(suspenseInstance); // If we don't find one, then that should mean that the parent
  7082. // host component also hasn't hydrated yet. We can return it
  7083. // below since it will bail out on the isMounted check later.
  7084. }
  7085. }
  7086. return targetInst;
  7087. }
  7088. targetNode = parentNode;
  7089. parentNode = targetNode.parentNode;
  7090. }
  7091. return null;
  7092. }
  7093. /**
  7094. * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent
  7095. * instance, or null if the node was not rendered by this React.
  7096. */
  7097. function getInstanceFromNode$1(node) {
  7098. var inst = node[internalInstanceKey] || node[internalContainerInstanceKey];
  7099. if (inst) {
  7100. if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) {
  7101. return inst;
  7102. } else {
  7103. return null;
  7104. }
  7105. }
  7106. return null;
  7107. }
  7108. /**
  7109. * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
  7110. * DOM node.
  7111. */
  7112. function getNodeFromInstance$1(inst) {
  7113. if (inst.tag === HostComponent || inst.tag === HostText) {
  7114. // In Fiber this, is just the state node right now. We assume it will be
  7115. // a host component or host text.
  7116. return inst.stateNode;
  7117. } // Without this first invariant, passing a non-DOM-component triggers the next
  7118. // invariant for a missing parent, which is super confusing.
  7119. {
  7120. {
  7121. throw Error( "getNodeFromInstance: Invalid argument." );
  7122. }
  7123. }
  7124. }
  7125. function getFiberCurrentPropsFromNode$1(node) {
  7126. return node[internalEventHandlersKey] || null;
  7127. }
  7128. function updateFiberProps(node, props) {
  7129. node[internalEventHandlersKey] = props;
  7130. }
  7131. function getParent(inst) {
  7132. do {
  7133. inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
  7134. // That is depending on if we want nested subtrees (layers) to bubble
  7135. // events to their parent. We could also go through parentNode on the
  7136. // host node but that wouldn't work for React Native and doesn't let us
  7137. // do the portal feature.
  7138. } while (inst && inst.tag !== HostComponent);
  7139. if (inst) {
  7140. return inst;
  7141. }
  7142. return null;
  7143. }
  7144. /**
  7145. * Return the lowest common ancestor of A and B, or null if they are in
  7146. * different trees.
  7147. */
  7148. function getLowestCommonAncestor(instA, instB) {
  7149. var depthA = 0;
  7150. for (var tempA = instA; tempA; tempA = getParent(tempA)) {
  7151. depthA++;
  7152. }
  7153. var depthB = 0;
  7154. for (var tempB = instB; tempB; tempB = getParent(tempB)) {
  7155. depthB++;
  7156. } // If A is deeper, crawl up.
  7157. while (depthA - depthB > 0) {
  7158. instA = getParent(instA);
  7159. depthA--;
  7160. } // If B is deeper, crawl up.
  7161. while (depthB - depthA > 0) {
  7162. instB = getParent(instB);
  7163. depthB--;
  7164. } // Walk in lockstep until we find a match.
  7165. var depth = depthA;
  7166. while (depth--) {
  7167. if (instA === instB || instA === instB.alternate) {
  7168. return instA;
  7169. }
  7170. instA = getParent(instA);
  7171. instB = getParent(instB);
  7172. }
  7173. return null;
  7174. }
  7175. /**
  7176. * Simulates the traversal of a two-phase, capture/bubble event dispatch.
  7177. */
  7178. function traverseTwoPhase(inst, fn, arg) {
  7179. var path = [];
  7180. while (inst) {
  7181. path.push(inst);
  7182. inst = getParent(inst);
  7183. }
  7184. var i;
  7185. for (i = path.length; i-- > 0;) {
  7186. fn(path[i], 'captured', arg);
  7187. }
  7188. for (i = 0; i < path.length; i++) {
  7189. fn(path[i], 'bubbled', arg);
  7190. }
  7191. }
  7192. /**
  7193. * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
  7194. * should would receive a `mouseEnter` or `mouseLeave` event.
  7195. *
  7196. * Does not invoke the callback on the nearest common ancestor because nothing
  7197. * "entered" or "left" that element.
  7198. */
  7199. function traverseEnterLeave(from, to, fn, argFrom, argTo) {
  7200. var common = from && to ? getLowestCommonAncestor(from, to) : null;
  7201. var pathFrom = [];
  7202. while (true) {
  7203. if (!from) {
  7204. break;
  7205. }
  7206. if (from === common) {
  7207. break;
  7208. }
  7209. var alternate = from.alternate;
  7210. if (alternate !== null && alternate === common) {
  7211. break;
  7212. }
  7213. pathFrom.push(from);
  7214. from = getParent(from);
  7215. }
  7216. var pathTo = [];
  7217. while (true) {
  7218. if (!to) {
  7219. break;
  7220. }
  7221. if (to === common) {
  7222. break;
  7223. }
  7224. var _alternate = to.alternate;
  7225. if (_alternate !== null && _alternate === common) {
  7226. break;
  7227. }
  7228. pathTo.push(to);
  7229. to = getParent(to);
  7230. }
  7231. for (var i = 0; i < pathFrom.length; i++) {
  7232. fn(pathFrom[i], 'bubbled', argFrom);
  7233. }
  7234. for (var _i = pathTo.length; _i-- > 0;) {
  7235. fn(pathTo[_i], 'captured', argTo);
  7236. }
  7237. }
  7238. function isInteractive(tag) {
  7239. return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
  7240. }
  7241. function shouldPreventMouseEvent(name, type, props) {
  7242. switch (name) {
  7243. case 'onClick':
  7244. case 'onClickCapture':
  7245. case 'onDoubleClick':
  7246. case 'onDoubleClickCapture':
  7247. case 'onMouseDown':
  7248. case 'onMouseDownCapture':
  7249. case 'onMouseMove':
  7250. case 'onMouseMoveCapture':
  7251. case 'onMouseUp':
  7252. case 'onMouseUpCapture':
  7253. case 'onMouseEnter':
  7254. return !!(props.disabled && isInteractive(type));
  7255. default:
  7256. return false;
  7257. }
  7258. }
  7259. /**
  7260. * @param {object} inst The instance, which is the source of events.
  7261. * @param {string} registrationName Name of listener (e.g. `onClick`).
  7262. * @return {?function} The stored callback.
  7263. */
  7264. function getListener(inst, registrationName) {
  7265. var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
  7266. // live here; needs to be moved to a better place soon
  7267. var stateNode = inst.stateNode;
  7268. if (!stateNode) {
  7269. // Work in progress (ex: onload events in incremental mode).
  7270. return null;
  7271. }
  7272. var props = getFiberCurrentPropsFromNode(stateNode);
  7273. if (!props) {
  7274. // Work in progress.
  7275. return null;
  7276. }
  7277. listener = props[registrationName];
  7278. if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
  7279. return null;
  7280. }
  7281. if (!(!listener || typeof listener === 'function')) {
  7282. {
  7283. throw Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type." );
  7284. }
  7285. }
  7286. return listener;
  7287. }
  7288. /**
  7289. * Some event types have a notion of different registration names for different
  7290. * "phases" of propagation. This finds listeners by a given phase.
  7291. */
  7292. function listenerAtPhase(inst, event, propagationPhase) {
  7293. var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
  7294. return getListener(inst, registrationName);
  7295. }
  7296. /**
  7297. * A small set of propagation patterns, each of which will accept a small amount
  7298. * of information, and generate a set of "dispatch ready event objects" - which
  7299. * are sets of events that have already been annotated with a set of dispatched
  7300. * listener functions/ids. The API is designed this way to discourage these
  7301. * propagation strategies from actually executing the dispatches, since we
  7302. * always want to collect the entire set of dispatches before executing even a
  7303. * single one.
  7304. */
  7305. /**
  7306. * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
  7307. * here, allows us to not have to bind or create functions for each event.
  7308. * Mutating the event's members allows us to not have to create a wrapping
  7309. * "dispatch" object that pairs the event with the listener.
  7310. */
  7311. function accumulateDirectionalDispatches(inst, phase, event) {
  7312. {
  7313. if (!inst) {
  7314. error('Dispatching inst must not be null');
  7315. }
  7316. }
  7317. var listener = listenerAtPhase(inst, event, phase);
  7318. if (listener) {
  7319. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  7320. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  7321. }
  7322. }
  7323. /**
  7324. * Collect dispatches (must be entirely collected before dispatching - see unit
  7325. * tests). Lazily allocate the array to conserve memory. We must loop through
  7326. * each event and perform the traversal for each one. We cannot perform a
  7327. * single traversal for the entire collection of events because each event may
  7328. * have a different target.
  7329. */
  7330. function accumulateTwoPhaseDispatchesSingle(event) {
  7331. if (event && event.dispatchConfig.phasedRegistrationNames) {
  7332. traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
  7333. }
  7334. }
  7335. /**
  7336. * Accumulates without regard to direction, does not look for phased
  7337. * registration names. Same as `accumulateDirectDispatchesSingle` but without
  7338. * requiring that the `dispatchMarker` be the same as the dispatched ID.
  7339. */
  7340. function accumulateDispatches(inst, ignoredDirection, event) {
  7341. if (inst && event && event.dispatchConfig.registrationName) {
  7342. var registrationName = event.dispatchConfig.registrationName;
  7343. var listener = getListener(inst, registrationName);
  7344. if (listener) {
  7345. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  7346. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  7347. }
  7348. }
  7349. }
  7350. /**
  7351. * Accumulates dispatches on an `SyntheticEvent`, but only for the
  7352. * `dispatchMarker`.
  7353. * @param {SyntheticEvent} event
  7354. */
  7355. function accumulateDirectDispatchesSingle(event) {
  7356. if (event && event.dispatchConfig.registrationName) {
  7357. accumulateDispatches(event._targetInst, null, event);
  7358. }
  7359. }
  7360. function accumulateTwoPhaseDispatches(events) {
  7361. forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
  7362. }
  7363. function accumulateEnterLeaveDispatches(leave, enter, from, to) {
  7364. traverseEnterLeave(from, to, accumulateDispatches, leave, enter);
  7365. }
  7366. function accumulateDirectDispatches(events) {
  7367. forEachAccumulated(events, accumulateDirectDispatchesSingle);
  7368. }
  7369. /**
  7370. * These variables store information about text content of a target node,
  7371. * allowing comparison of content before and after a given event.
  7372. *
  7373. * Identify the node where selection currently begins, then observe
  7374. * both its text content and its current position in the DOM. Since the
  7375. * browser may natively replace the target node during composition, we can
  7376. * use its position to find its replacement.
  7377. *
  7378. *
  7379. */
  7380. var root = null;
  7381. var startText = null;
  7382. var fallbackText = null;
  7383. function initialize(nativeEventTarget) {
  7384. root = nativeEventTarget;
  7385. startText = getText();
  7386. return true;
  7387. }
  7388. function reset() {
  7389. root = null;
  7390. startText = null;
  7391. fallbackText = null;
  7392. }
  7393. function getData() {
  7394. if (fallbackText) {
  7395. return fallbackText;
  7396. }
  7397. var start;
  7398. var startValue = startText;
  7399. var startLength = startValue.length;
  7400. var end;
  7401. var endValue = getText();
  7402. var endLength = endValue.length;
  7403. for (start = 0; start < startLength; start++) {
  7404. if (startValue[start] !== endValue[start]) {
  7405. break;
  7406. }
  7407. }
  7408. var minEnd = startLength - start;
  7409. for (end = 1; end <= minEnd; end++) {
  7410. if (startValue[startLength - end] !== endValue[endLength - end]) {
  7411. break;
  7412. }
  7413. }
  7414. var sliceTail = end > 1 ? 1 - end : undefined;
  7415. fallbackText = endValue.slice(start, sliceTail);
  7416. return fallbackText;
  7417. }
  7418. function getText() {
  7419. if ('value' in root) {
  7420. return root.value;
  7421. }
  7422. return root.textContent;
  7423. }
  7424. var EVENT_POOL_SIZE = 10;
  7425. /**
  7426. * @interface Event
  7427. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  7428. */
  7429. var EventInterface = {
  7430. type: null,
  7431. target: null,
  7432. // currentTarget is set when dispatching; no use in copying it here
  7433. currentTarget: function () {
  7434. return null;
  7435. },
  7436. eventPhase: null,
  7437. bubbles: null,
  7438. cancelable: null,
  7439. timeStamp: function (event) {
  7440. return event.timeStamp || Date.now();
  7441. },
  7442. defaultPrevented: null,
  7443. isTrusted: null
  7444. };
  7445. function functionThatReturnsTrue() {
  7446. return true;
  7447. }
  7448. function functionThatReturnsFalse() {
  7449. return false;
  7450. }
  7451. /**
  7452. * Synthetic events are dispatched by event plugins, typically in response to a
  7453. * top-level event delegation handler.
  7454. *
  7455. * These systems should generally use pooling to reduce the frequency of garbage
  7456. * collection. The system should check `isPersistent` to determine whether the
  7457. * event should be released into the pool after being dispatched. Users that
  7458. * need a persisted event should invoke `persist`.
  7459. *
  7460. * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
  7461. * normalizing browser quirks. Subclasses do not necessarily have to implement a
  7462. * DOM interface; custom application-specific events can also subclass this.
  7463. *
  7464. * @param {object} dispatchConfig Configuration used to dispatch this event.
  7465. * @param {*} targetInst Marker identifying the event target.
  7466. * @param {object} nativeEvent Native browser event.
  7467. * @param {DOMEventTarget} nativeEventTarget Target node.
  7468. */
  7469. function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
  7470. {
  7471. // these have a getter/setter for warnings
  7472. delete this.nativeEvent;
  7473. delete this.preventDefault;
  7474. delete this.stopPropagation;
  7475. delete this.isDefaultPrevented;
  7476. delete this.isPropagationStopped;
  7477. }
  7478. this.dispatchConfig = dispatchConfig;
  7479. this._targetInst = targetInst;
  7480. this.nativeEvent = nativeEvent;
  7481. var Interface = this.constructor.Interface;
  7482. for (var propName in Interface) {
  7483. if (!Interface.hasOwnProperty(propName)) {
  7484. continue;
  7485. }
  7486. {
  7487. delete this[propName]; // this has a getter/setter for warnings
  7488. }
  7489. var normalize = Interface[propName];
  7490. if (normalize) {
  7491. this[propName] = normalize(nativeEvent);
  7492. } else {
  7493. if (propName === 'target') {
  7494. this.target = nativeEventTarget;
  7495. } else {
  7496. this[propName] = nativeEvent[propName];
  7497. }
  7498. }
  7499. }
  7500. var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
  7501. if (defaultPrevented) {
  7502. this.isDefaultPrevented = functionThatReturnsTrue;
  7503. } else {
  7504. this.isDefaultPrevented = functionThatReturnsFalse;
  7505. }
  7506. this.isPropagationStopped = functionThatReturnsFalse;
  7507. return this;
  7508. }
  7509. _assign(SyntheticEvent.prototype, {
  7510. preventDefault: function () {
  7511. this.defaultPrevented = true;
  7512. var event = this.nativeEvent;
  7513. if (!event) {
  7514. return;
  7515. }
  7516. if (event.preventDefault) {
  7517. event.preventDefault();
  7518. } else if (typeof event.returnValue !== 'unknown') {
  7519. event.returnValue = false;
  7520. }
  7521. this.isDefaultPrevented = functionThatReturnsTrue;
  7522. },
  7523. stopPropagation: function () {
  7524. var event = this.nativeEvent;
  7525. if (!event) {
  7526. return;
  7527. }
  7528. if (event.stopPropagation) {
  7529. event.stopPropagation();
  7530. } else if (typeof event.cancelBubble !== 'unknown') {
  7531. // The ChangeEventPlugin registers a "propertychange" event for
  7532. // IE. This event does not support bubbling or cancelling, and
  7533. // any references to cancelBubble throw "Member not found". A
  7534. // typeof check of "unknown" circumvents this issue (and is also
  7535. // IE specific).
  7536. event.cancelBubble = true;
  7537. }
  7538. this.isPropagationStopped = functionThatReturnsTrue;
  7539. },
  7540. /**
  7541. * We release all dispatched `SyntheticEvent`s after each event loop, adding
  7542. * them back into the pool. This allows a way to hold onto a reference that
  7543. * won't be added back into the pool.
  7544. */
  7545. persist: function () {
  7546. this.isPersistent = functionThatReturnsTrue;
  7547. },
  7548. /**
  7549. * Checks if this event should be released back into the pool.
  7550. *
  7551. * @return {boolean} True if this should not be released, false otherwise.
  7552. */
  7553. isPersistent: functionThatReturnsFalse,
  7554. /**
  7555. * `PooledClass` looks for `destructor` on each instance it releases.
  7556. */
  7557. destructor: function () {
  7558. var Interface = this.constructor.Interface;
  7559. for (var propName in Interface) {
  7560. {
  7561. Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
  7562. }
  7563. }
  7564. this.dispatchConfig = null;
  7565. this._targetInst = null;
  7566. this.nativeEvent = null;
  7567. this.isDefaultPrevented = functionThatReturnsFalse;
  7568. this.isPropagationStopped = functionThatReturnsFalse;
  7569. this._dispatchListeners = null;
  7570. this._dispatchInstances = null;
  7571. {
  7572. Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
  7573. Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
  7574. Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
  7575. Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
  7576. Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
  7577. }
  7578. }
  7579. });
  7580. SyntheticEvent.Interface = EventInterface;
  7581. /**
  7582. * Helper to reduce boilerplate when creating subclasses.
  7583. */
  7584. SyntheticEvent.extend = function (Interface) {
  7585. var Super = this;
  7586. var E = function () {};
  7587. E.prototype = Super.prototype;
  7588. var prototype = new E();
  7589. function Class() {
  7590. return Super.apply(this, arguments);
  7591. }
  7592. _assign(prototype, Class.prototype);
  7593. Class.prototype = prototype;
  7594. Class.prototype.constructor = Class;
  7595. Class.Interface = _assign({}, Super.Interface, Interface);
  7596. Class.extend = Super.extend;
  7597. addEventPoolingTo(Class);
  7598. return Class;
  7599. };
  7600. addEventPoolingTo(SyntheticEvent);
  7601. /**
  7602. * Helper to nullify syntheticEvent instance properties when destructing
  7603. *
  7604. * @param {String} propName
  7605. * @param {?object} getVal
  7606. * @return {object} defineProperty object
  7607. */
  7608. function getPooledWarningPropertyDefinition(propName, getVal) {
  7609. var isFunction = typeof getVal === 'function';
  7610. return {
  7611. configurable: true,
  7612. set: set,
  7613. get: get
  7614. };
  7615. function set(val) {
  7616. var action = isFunction ? 'setting the method' : 'setting the property';
  7617. warn(action, 'This is effectively a no-op');
  7618. return val;
  7619. }
  7620. function get() {
  7621. var action = isFunction ? 'accessing the method' : 'accessing the property';
  7622. var result = isFunction ? 'This is a no-op function' : 'This is set to null';
  7623. warn(action, result);
  7624. return getVal;
  7625. }
  7626. function warn(action, result) {
  7627. {
  7628. error("This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result);
  7629. }
  7630. }
  7631. }
  7632. function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
  7633. var EventConstructor = this;
  7634. if (EventConstructor.eventPool.length) {
  7635. var instance = EventConstructor.eventPool.pop();
  7636. EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
  7637. return instance;
  7638. }
  7639. return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
  7640. }
  7641. function releasePooledEvent(event) {
  7642. var EventConstructor = this;
  7643. if (!(event instanceof EventConstructor)) {
  7644. {
  7645. throw Error( "Trying to release an event instance into a pool of a different type." );
  7646. }
  7647. }
  7648. event.destructor();
  7649. if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
  7650. EventConstructor.eventPool.push(event);
  7651. }
  7652. }
  7653. function addEventPoolingTo(EventConstructor) {
  7654. EventConstructor.eventPool = [];
  7655. EventConstructor.getPooled = getPooledEvent;
  7656. EventConstructor.release = releasePooledEvent;
  7657. }
  7658. /**
  7659. * @interface Event
  7660. * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
  7661. */
  7662. var SyntheticCompositionEvent = SyntheticEvent.extend({
  7663. data: null
  7664. });
  7665. /**
  7666. * @interface Event
  7667. * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
  7668. * /#events-inputevents
  7669. */
  7670. var SyntheticInputEvent = SyntheticEvent.extend({
  7671. data: null
  7672. });
  7673. var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
  7674. var START_KEYCODE = 229;
  7675. var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window;
  7676. var documentMode = null;
  7677. if (canUseDOM && 'documentMode' in document) {
  7678. documentMode = document.documentMode;
  7679. } // Webkit offers a very useful `textInput` event that can be used to
  7680. // directly represent `beforeInput`. The IE `textinput` event is not as
  7681. // useful, so we don't use it.
  7682. var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode; // In IE9+, we have access to composition events, but the data supplied
  7683. // by the native compositionend event may be incorrect. Japanese ideographic
  7684. // spaces, for instance (\u3000) are not recorded correctly.
  7685. var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
  7686. var SPACEBAR_CODE = 32;
  7687. var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); // Events and their corresponding property names.
  7688. var eventTypes = {
  7689. beforeInput: {
  7690. phasedRegistrationNames: {
  7691. bubbled: 'onBeforeInput',
  7692. captured: 'onBeforeInputCapture'
  7693. },
  7694. dependencies: [TOP_COMPOSITION_END, TOP_KEY_PRESS, TOP_TEXT_INPUT, TOP_PASTE]
  7695. },
  7696. compositionEnd: {
  7697. phasedRegistrationNames: {
  7698. bubbled: 'onCompositionEnd',
  7699. captured: 'onCompositionEndCapture'
  7700. },
  7701. dependencies: [TOP_BLUR, TOP_COMPOSITION_END, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  7702. },
  7703. compositionStart: {
  7704. phasedRegistrationNames: {
  7705. bubbled: 'onCompositionStart',
  7706. captured: 'onCompositionStartCapture'
  7707. },
  7708. dependencies: [TOP_BLUR, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  7709. },
  7710. compositionUpdate: {
  7711. phasedRegistrationNames: {
  7712. bubbled: 'onCompositionUpdate',
  7713. captured: 'onCompositionUpdateCapture'
  7714. },
  7715. dependencies: [TOP_BLUR, TOP_COMPOSITION_UPDATE, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  7716. }
  7717. }; // Track whether we've ever handled a keypress on the space key.
  7718. var hasSpaceKeypress = false;
  7719. /**
  7720. * Return whether a native keypress event is assumed to be a command.
  7721. * This is required because Firefox fires `keypress` events for key commands
  7722. * (cut, copy, select-all, etc.) even though no character is inserted.
  7723. */
  7724. function isKeypressCommand(nativeEvent) {
  7725. return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command.
  7726. !(nativeEvent.ctrlKey && nativeEvent.altKey);
  7727. }
  7728. /**
  7729. * Translate native top level events into event types.
  7730. *
  7731. * @param {string} topLevelType
  7732. * @return {object}
  7733. */
  7734. function getCompositionEventType(topLevelType) {
  7735. switch (topLevelType) {
  7736. case TOP_COMPOSITION_START:
  7737. return eventTypes.compositionStart;
  7738. case TOP_COMPOSITION_END:
  7739. return eventTypes.compositionEnd;
  7740. case TOP_COMPOSITION_UPDATE:
  7741. return eventTypes.compositionUpdate;
  7742. }
  7743. }
  7744. /**
  7745. * Does our fallback best-guess model think this event signifies that
  7746. * composition has begun?
  7747. *
  7748. * @param {string} topLevelType
  7749. * @param {object} nativeEvent
  7750. * @return {boolean}
  7751. */
  7752. function isFallbackCompositionStart(topLevelType, nativeEvent) {
  7753. return topLevelType === TOP_KEY_DOWN && nativeEvent.keyCode === START_KEYCODE;
  7754. }
  7755. /**
  7756. * Does our fallback mode think that this event is the end of composition?
  7757. *
  7758. * @param {string} topLevelType
  7759. * @param {object} nativeEvent
  7760. * @return {boolean}
  7761. */
  7762. function isFallbackCompositionEnd(topLevelType, nativeEvent) {
  7763. switch (topLevelType) {
  7764. case TOP_KEY_UP:
  7765. // Command keys insert or clear IME input.
  7766. return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
  7767. case TOP_KEY_DOWN:
  7768. // Expect IME keyCode on each keydown. If we get any other
  7769. // code we must have exited earlier.
  7770. return nativeEvent.keyCode !== START_KEYCODE;
  7771. case TOP_KEY_PRESS:
  7772. case TOP_MOUSE_DOWN:
  7773. case TOP_BLUR:
  7774. // Events are not possible without cancelling IME.
  7775. return true;
  7776. default:
  7777. return false;
  7778. }
  7779. }
  7780. /**
  7781. * Google Input Tools provides composition data via a CustomEvent,
  7782. * with the `data` property populated in the `detail` object. If this
  7783. * is available on the event object, use it. If not, this is a plain
  7784. * composition event and we have nothing special to extract.
  7785. *
  7786. * @param {object} nativeEvent
  7787. * @return {?string}
  7788. */
  7789. function getDataFromCustomEvent(nativeEvent) {
  7790. var detail = nativeEvent.detail;
  7791. if (typeof detail === 'object' && 'data' in detail) {
  7792. return detail.data;
  7793. }
  7794. return null;
  7795. }
  7796. /**
  7797. * Check if a composition event was triggered by Korean IME.
  7798. * Our fallback mode does not work well with IE's Korean IME,
  7799. * so just use native composition events when Korean IME is used.
  7800. * Although CompositionEvent.locale property is deprecated,
  7801. * it is available in IE, where our fallback mode is enabled.
  7802. *
  7803. * @param {object} nativeEvent
  7804. * @return {boolean}
  7805. */
  7806. function isUsingKoreanIME(nativeEvent) {
  7807. return nativeEvent.locale === 'ko';
  7808. } // Track the current IME composition status, if any.
  7809. var isComposing = false;
  7810. /**
  7811. * @return {?object} A SyntheticCompositionEvent.
  7812. */
  7813. function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  7814. var eventType;
  7815. var fallbackData;
  7816. if (canUseCompositionEvent) {
  7817. eventType = getCompositionEventType(topLevelType);
  7818. } else if (!isComposing) {
  7819. if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
  7820. eventType = eventTypes.compositionStart;
  7821. }
  7822. } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  7823. eventType = eventTypes.compositionEnd;
  7824. }
  7825. if (!eventType) {
  7826. return null;
  7827. }
  7828. if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) {
  7829. // The current composition is stored statically and must not be
  7830. // overwritten while composition continues.
  7831. if (!isComposing && eventType === eventTypes.compositionStart) {
  7832. isComposing = initialize(nativeEventTarget);
  7833. } else if (eventType === eventTypes.compositionEnd) {
  7834. if (isComposing) {
  7835. fallbackData = getData();
  7836. }
  7837. }
  7838. }
  7839. var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget);
  7840. if (fallbackData) {
  7841. // Inject data generated from fallback path into the synthetic event.
  7842. // This matches the property of native CompositionEventInterface.
  7843. event.data = fallbackData;
  7844. } else {
  7845. var customData = getDataFromCustomEvent(nativeEvent);
  7846. if (customData !== null) {
  7847. event.data = customData;
  7848. }
  7849. }
  7850. accumulateTwoPhaseDispatches(event);
  7851. return event;
  7852. }
  7853. /**
  7854. * @param {TopLevelType} topLevelType Number from `TopLevelType`.
  7855. * @param {object} nativeEvent Native browser event.
  7856. * @return {?string} The string corresponding to this `beforeInput` event.
  7857. */
  7858. function getNativeBeforeInputChars(topLevelType, nativeEvent) {
  7859. switch (topLevelType) {
  7860. case TOP_COMPOSITION_END:
  7861. return getDataFromCustomEvent(nativeEvent);
  7862. case TOP_KEY_PRESS:
  7863. /**
  7864. * If native `textInput` events are available, our goal is to make
  7865. * use of them. However, there is a special case: the spacebar key.
  7866. * In Webkit, preventing default on a spacebar `textInput` event
  7867. * cancels character insertion, but it *also* causes the browser
  7868. * to fall back to its default spacebar behavior of scrolling the
  7869. * page.
  7870. *
  7871. * Tracking at:
  7872. * https://code.google.com/p/chromium/issues/detail?id=355103
  7873. *
  7874. * To avoid this issue, use the keypress event as if no `textInput`
  7875. * event is available.
  7876. */
  7877. var which = nativeEvent.which;
  7878. if (which !== SPACEBAR_CODE) {
  7879. return null;
  7880. }
  7881. hasSpaceKeypress = true;
  7882. return SPACEBAR_CHAR;
  7883. case TOP_TEXT_INPUT:
  7884. // Record the characters to be added to the DOM.
  7885. var chars = nativeEvent.data; // If it's a spacebar character, assume that we have already handled
  7886. // it at the keypress level and bail immediately. Android Chrome
  7887. // doesn't give us keycodes, so we need to ignore it.
  7888. if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
  7889. return null;
  7890. }
  7891. return chars;
  7892. default:
  7893. // For other native event types, do nothing.
  7894. return null;
  7895. }
  7896. }
  7897. /**
  7898. * For browsers that do not provide the `textInput` event, extract the
  7899. * appropriate string to use for SyntheticInputEvent.
  7900. *
  7901. * @param {number} topLevelType Number from `TopLevelEventTypes`.
  7902. * @param {object} nativeEvent Native browser event.
  7903. * @return {?string} The fallback string for this `beforeInput` event.
  7904. */
  7905. function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
  7906. // If we are currently composing (IME) and using a fallback to do so,
  7907. // try to extract the composed characters from the fallback object.
  7908. // If composition event is available, we extract a string only at
  7909. // compositionevent, otherwise extract it at fallback events.
  7910. if (isComposing) {
  7911. if (topLevelType === TOP_COMPOSITION_END || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  7912. var chars = getData();
  7913. reset();
  7914. isComposing = false;
  7915. return chars;
  7916. }
  7917. return null;
  7918. }
  7919. switch (topLevelType) {
  7920. case TOP_PASTE:
  7921. // If a paste event occurs after a keypress, throw out the input
  7922. // chars. Paste events should not lead to BeforeInput events.
  7923. return null;
  7924. case TOP_KEY_PRESS:
  7925. /**
  7926. * As of v27, Firefox may fire keypress events even when no character
  7927. * will be inserted. A few possibilities:
  7928. *
  7929. * - `which` is `0`. Arrow keys, Esc key, etc.
  7930. *
  7931. * - `which` is the pressed key code, but no char is available.
  7932. * Ex: 'AltGr + d` in Polish. There is no modified character for
  7933. * this key combination and no character is inserted into the
  7934. * document, but FF fires the keypress for char code `100` anyway.
  7935. * No `input` event will occur.
  7936. *
  7937. * - `which` is the pressed key code, but a command combination is
  7938. * being used. Ex: `Cmd+C`. No character is inserted, and no
  7939. * `input` event will occur.
  7940. */
  7941. if (!isKeypressCommand(nativeEvent)) {
  7942. // IE fires the `keypress` event when a user types an emoji via
  7943. // Touch keyboard of Windows. In such a case, the `char` property
  7944. // holds an emoji character like `\uD83D\uDE0A`. Because its length
  7945. // is 2, the property `which` does not represent an emoji correctly.
  7946. // In such a case, we directly return the `char` property instead of
  7947. // using `which`.
  7948. if (nativeEvent.char && nativeEvent.char.length > 1) {
  7949. return nativeEvent.char;
  7950. } else if (nativeEvent.which) {
  7951. return String.fromCharCode(nativeEvent.which);
  7952. }
  7953. }
  7954. return null;
  7955. case TOP_COMPOSITION_END:
  7956. return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data;
  7957. default:
  7958. return null;
  7959. }
  7960. }
  7961. /**
  7962. * Extract a SyntheticInputEvent for `beforeInput`, based on either native
  7963. * `textInput` or fallback behavior.
  7964. *
  7965. * @return {?object} A SyntheticInputEvent.
  7966. */
  7967. function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  7968. var chars;
  7969. if (canUseTextInputEvent) {
  7970. chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
  7971. } else {
  7972. chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
  7973. } // If no characters are being inserted, no BeforeInput event should
  7974. // be fired.
  7975. if (!chars) {
  7976. return null;
  7977. }
  7978. var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget);
  7979. event.data = chars;
  7980. accumulateTwoPhaseDispatches(event);
  7981. return event;
  7982. }
  7983. /**
  7984. * Create an `onBeforeInput` event to match
  7985. * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
  7986. *
  7987. * This event plugin is based on the native `textInput` event
  7988. * available in Chrome, Safari, Opera, and IE. This event fires after
  7989. * `onKeyPress` and `onCompositionEnd`, but before `onInput`.
  7990. *
  7991. * `beforeInput` is spec'd but not implemented in any browsers, and
  7992. * the `input` event does not provide any useful information about what has
  7993. * actually been added, contrary to the spec. Thus, `textInput` is the best
  7994. * available event to identify the characters that have actually been inserted
  7995. * into the target node.
  7996. *
  7997. * This plugin is also responsible for emitting `composition` events, thus
  7998. * allowing us to share composition fallback code for both `beforeInput` and
  7999. * `composition` event types.
  8000. */
  8001. var BeforeInputEventPlugin = {
  8002. eventTypes: eventTypes,
  8003. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  8004. var composition = extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  8005. var beforeInput = extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  8006. if (composition === null) {
  8007. return beforeInput;
  8008. }
  8009. if (beforeInput === null) {
  8010. return composition;
  8011. }
  8012. return [composition, beforeInput];
  8013. }
  8014. };
  8015. /**
  8016. * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
  8017. */
  8018. var supportedInputTypes = {
  8019. color: true,
  8020. date: true,
  8021. datetime: true,
  8022. 'datetime-local': true,
  8023. email: true,
  8024. month: true,
  8025. number: true,
  8026. password: true,
  8027. range: true,
  8028. search: true,
  8029. tel: true,
  8030. text: true,
  8031. time: true,
  8032. url: true,
  8033. week: true
  8034. };
  8035. function isTextInputElement(elem) {
  8036. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  8037. if (nodeName === 'input') {
  8038. return !!supportedInputTypes[elem.type];
  8039. }
  8040. if (nodeName === 'textarea') {
  8041. return true;
  8042. }
  8043. return false;
  8044. }
  8045. var eventTypes$1 = {
  8046. change: {
  8047. phasedRegistrationNames: {
  8048. bubbled: 'onChange',
  8049. captured: 'onChangeCapture'
  8050. },
  8051. dependencies: [TOP_BLUR, TOP_CHANGE, TOP_CLICK, TOP_FOCUS, TOP_INPUT, TOP_KEY_DOWN, TOP_KEY_UP, TOP_SELECTION_CHANGE]
  8052. }
  8053. };
  8054. function createAndAccumulateChangeEvent(inst, nativeEvent, target) {
  8055. var event = SyntheticEvent.getPooled(eventTypes$1.change, inst, nativeEvent, target);
  8056. event.type = 'change'; // Flag this event loop as needing state restore.
  8057. enqueueStateRestore(target);
  8058. accumulateTwoPhaseDispatches(event);
  8059. return event;
  8060. }
  8061. /**
  8062. * For IE shims
  8063. */
  8064. var activeElement = null;
  8065. var activeElementInst = null;
  8066. /**
  8067. * SECTION: handle `change` event
  8068. */
  8069. function shouldUseChangeEvent(elem) {
  8070. var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
  8071. return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
  8072. }
  8073. function manualDispatchChangeEvent(nativeEvent) {
  8074. var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent)); // If change and propertychange bubbled, we'd just bind to it like all the
  8075. // other events and have it go through ReactBrowserEventEmitter. Since it
  8076. // doesn't, we manually listen for the events and so we have to enqueue and
  8077. // process the abstract event manually.
  8078. //
  8079. // Batching is necessary here in order to ensure that all event handlers run
  8080. // before the next rerender (including event handlers attached to ancestor
  8081. // elements instead of directly on the input). Without this, controlled
  8082. // components don't work properly in conjunction with event bubbling because
  8083. // the component is rerendered and the value reverted before all the event
  8084. // handlers can run. See https://github.com/facebook/react/issues/708.
  8085. batchedUpdates(runEventInBatch, event);
  8086. }
  8087. function runEventInBatch(event) {
  8088. runEventsInBatch(event);
  8089. }
  8090. function getInstIfValueChanged(targetInst) {
  8091. var targetNode = getNodeFromInstance$1(targetInst);
  8092. if (updateValueIfChanged(targetNode)) {
  8093. return targetInst;
  8094. }
  8095. }
  8096. function getTargetInstForChangeEvent(topLevelType, targetInst) {
  8097. if (topLevelType === TOP_CHANGE) {
  8098. return targetInst;
  8099. }
  8100. }
  8101. /**
  8102. * SECTION: handle `input` event
  8103. */
  8104. var isInputEventSupported = false;
  8105. if (canUseDOM) {
  8106. // IE9 claims to support the input event but fails to trigger it when
  8107. // deleting text, so we ignore its input events.
  8108. isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9);
  8109. }
  8110. /**
  8111. * (For IE <=9) Starts tracking propertychange events on the passed-in element
  8112. * and override the value property so that we can distinguish user events from
  8113. * value changes in JS.
  8114. */
  8115. function startWatchingForValueChange(target, targetInst) {
  8116. activeElement = target;
  8117. activeElementInst = targetInst;
  8118. activeElement.attachEvent('onpropertychange', handlePropertyChange);
  8119. }
  8120. /**
  8121. * (For IE <=9) Removes the event listeners from the currently-tracked element,
  8122. * if any exists.
  8123. */
  8124. function stopWatchingForValueChange() {
  8125. if (!activeElement) {
  8126. return;
  8127. }
  8128. activeElement.detachEvent('onpropertychange', handlePropertyChange);
  8129. activeElement = null;
  8130. activeElementInst = null;
  8131. }
  8132. /**
  8133. * (For IE <=9) Handles a propertychange event, sending a `change` event if
  8134. * the value of the active element has changed.
  8135. */
  8136. function handlePropertyChange(nativeEvent) {
  8137. if (nativeEvent.propertyName !== 'value') {
  8138. return;
  8139. }
  8140. if (getInstIfValueChanged(activeElementInst)) {
  8141. manualDispatchChangeEvent(nativeEvent);
  8142. }
  8143. }
  8144. function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) {
  8145. if (topLevelType === TOP_FOCUS) {
  8146. // In IE9, propertychange fires for most input events but is buggy and
  8147. // doesn't fire when text is deleted, but conveniently, selectionchange
  8148. // appears to fire in all of the remaining cases so we catch those and
  8149. // forward the event if the value has changed
  8150. // In either case, we don't want to call the event handler if the value
  8151. // is changed from JS so we redefine a setter for `.value` that updates
  8152. // our activeElementValue variable, allowing us to ignore those changes
  8153. //
  8154. // stopWatching() should be a noop here but we call it just in case we
  8155. // missed a blur event somehow.
  8156. stopWatchingForValueChange();
  8157. startWatchingForValueChange(target, targetInst);
  8158. } else if (topLevelType === TOP_BLUR) {
  8159. stopWatchingForValueChange();
  8160. }
  8161. } // For IE8 and IE9.
  8162. function getTargetInstForInputEventPolyfill(topLevelType, targetInst) {
  8163. if (topLevelType === TOP_SELECTION_CHANGE || topLevelType === TOP_KEY_UP || topLevelType === TOP_KEY_DOWN) {
  8164. // On the selectionchange event, the target is just document which isn't
  8165. // helpful for us so just check activeElement instead.
  8166. //
  8167. // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
  8168. // propertychange on the first input event after setting `value` from a
  8169. // script and fires only keydown, keypress, keyup. Catching keyup usually
  8170. // gets it and catching keydown lets us fire an event for the first
  8171. // keystroke if user does a key repeat (it'll be a little delayed: right
  8172. // before the second keystroke). Other input methods (e.g., paste) seem to
  8173. // fire selectionchange normally.
  8174. return getInstIfValueChanged(activeElementInst);
  8175. }
  8176. }
  8177. /**
  8178. * SECTION: handle `click` event
  8179. */
  8180. function shouldUseClickEvent(elem) {
  8181. // Use the `click` event to detect changes to checkbox and radio inputs.
  8182. // This approach works across all browsers, whereas `change` does not fire
  8183. // until `blur` in IE8.
  8184. var nodeName = elem.nodeName;
  8185. return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
  8186. }
  8187. function getTargetInstForClickEvent(topLevelType, targetInst) {
  8188. if (topLevelType === TOP_CLICK) {
  8189. return getInstIfValueChanged(targetInst);
  8190. }
  8191. }
  8192. function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) {
  8193. if (topLevelType === TOP_INPUT || topLevelType === TOP_CHANGE) {
  8194. return getInstIfValueChanged(targetInst);
  8195. }
  8196. }
  8197. function handleControlledInputBlur(node) {
  8198. var state = node._wrapperState;
  8199. if (!state || !state.controlled || node.type !== 'number') {
  8200. return;
  8201. }
  8202. {
  8203. // If controlled, assign the value attribute to the current value on blur
  8204. setDefaultValue(node, 'number', node.value);
  8205. }
  8206. }
  8207. /**
  8208. * This plugin creates an `onChange` event that normalizes change events
  8209. * across form elements. This event fires at a time when it's possible to
  8210. * change the element's value without seeing a flicker.
  8211. *
  8212. * Supported elements are:
  8213. * - input (see `isTextInputElement`)
  8214. * - textarea
  8215. * - select
  8216. */
  8217. var ChangeEventPlugin = {
  8218. eventTypes: eventTypes$1,
  8219. _isInputEventSupported: isInputEventSupported,
  8220. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  8221. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  8222. var getTargetInstFunc, handleEventFunc;
  8223. if (shouldUseChangeEvent(targetNode)) {
  8224. getTargetInstFunc = getTargetInstForChangeEvent;
  8225. } else if (isTextInputElement(targetNode)) {
  8226. if (isInputEventSupported) {
  8227. getTargetInstFunc = getTargetInstForInputOrChangeEvent;
  8228. } else {
  8229. getTargetInstFunc = getTargetInstForInputEventPolyfill;
  8230. handleEventFunc = handleEventsForInputEventPolyfill;
  8231. }
  8232. } else if (shouldUseClickEvent(targetNode)) {
  8233. getTargetInstFunc = getTargetInstForClickEvent;
  8234. }
  8235. if (getTargetInstFunc) {
  8236. var inst = getTargetInstFunc(topLevelType, targetInst);
  8237. if (inst) {
  8238. var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget);
  8239. return event;
  8240. }
  8241. }
  8242. if (handleEventFunc) {
  8243. handleEventFunc(topLevelType, targetNode, targetInst);
  8244. } // When blurring, set the value attribute for number inputs
  8245. if (topLevelType === TOP_BLUR) {
  8246. handleControlledInputBlur(targetNode);
  8247. }
  8248. }
  8249. };
  8250. var SyntheticUIEvent = SyntheticEvent.extend({
  8251. view: null,
  8252. detail: null
  8253. });
  8254. /**
  8255. * Translation from modifier key to the associated property in the event.
  8256. * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
  8257. */
  8258. var modifierKeyToProp = {
  8259. Alt: 'altKey',
  8260. Control: 'ctrlKey',
  8261. Meta: 'metaKey',
  8262. Shift: 'shiftKey'
  8263. }; // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support
  8264. // getModifierState. If getModifierState is not supported, we map it to a set of
  8265. // modifier keys exposed by the event. In this case, Lock-keys are not supported.
  8266. function modifierStateGetter(keyArg) {
  8267. var syntheticEvent = this;
  8268. var nativeEvent = syntheticEvent.nativeEvent;
  8269. if (nativeEvent.getModifierState) {
  8270. return nativeEvent.getModifierState(keyArg);
  8271. }
  8272. var keyProp = modifierKeyToProp[keyArg];
  8273. return keyProp ? !!nativeEvent[keyProp] : false;
  8274. }
  8275. function getEventModifierState(nativeEvent) {
  8276. return modifierStateGetter;
  8277. }
  8278. var previousScreenX = 0;
  8279. var previousScreenY = 0; // Use flags to signal movementX/Y has already been set
  8280. var isMovementXSet = false;
  8281. var isMovementYSet = false;
  8282. /**
  8283. * @interface MouseEvent
  8284. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  8285. */
  8286. var SyntheticMouseEvent = SyntheticUIEvent.extend({
  8287. screenX: null,
  8288. screenY: null,
  8289. clientX: null,
  8290. clientY: null,
  8291. pageX: null,
  8292. pageY: null,
  8293. ctrlKey: null,
  8294. shiftKey: null,
  8295. altKey: null,
  8296. metaKey: null,
  8297. getModifierState: getEventModifierState,
  8298. button: null,
  8299. buttons: null,
  8300. relatedTarget: function (event) {
  8301. return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement);
  8302. },
  8303. movementX: function (event) {
  8304. if ('movementX' in event) {
  8305. return event.movementX;
  8306. }
  8307. var screenX = previousScreenX;
  8308. previousScreenX = event.screenX;
  8309. if (!isMovementXSet) {
  8310. isMovementXSet = true;
  8311. return 0;
  8312. }
  8313. return event.type === 'mousemove' ? event.screenX - screenX : 0;
  8314. },
  8315. movementY: function (event) {
  8316. if ('movementY' in event) {
  8317. return event.movementY;
  8318. }
  8319. var screenY = previousScreenY;
  8320. previousScreenY = event.screenY;
  8321. if (!isMovementYSet) {
  8322. isMovementYSet = true;
  8323. return 0;
  8324. }
  8325. return event.type === 'mousemove' ? event.screenY - screenY : 0;
  8326. }
  8327. });
  8328. /**
  8329. * @interface PointerEvent
  8330. * @see http://www.w3.org/TR/pointerevents/
  8331. */
  8332. var SyntheticPointerEvent = SyntheticMouseEvent.extend({
  8333. pointerId: null,
  8334. width: null,
  8335. height: null,
  8336. pressure: null,
  8337. tangentialPressure: null,
  8338. tiltX: null,
  8339. tiltY: null,
  8340. twist: null,
  8341. pointerType: null,
  8342. isPrimary: null
  8343. });
  8344. var eventTypes$2 = {
  8345. mouseEnter: {
  8346. registrationName: 'onMouseEnter',
  8347. dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER]
  8348. },
  8349. mouseLeave: {
  8350. registrationName: 'onMouseLeave',
  8351. dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER]
  8352. },
  8353. pointerEnter: {
  8354. registrationName: 'onPointerEnter',
  8355. dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER]
  8356. },
  8357. pointerLeave: {
  8358. registrationName: 'onPointerLeave',
  8359. dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER]
  8360. }
  8361. };
  8362. var EnterLeaveEventPlugin = {
  8363. eventTypes: eventTypes$2,
  8364. /**
  8365. * For almost every interaction we care about, there will be both a top-level
  8366. * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
  8367. * we do not extract duplicate events. However, moving the mouse into the
  8368. * browser from outside will not fire a `mouseout` event. In this case, we use
  8369. * the `mouseover` top-level event.
  8370. */
  8371. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  8372. var isOverEvent = topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER;
  8373. var isOutEvent = topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT;
  8374. if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0 && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
  8375. // If this is an over event with a target, then we've already dispatched
  8376. // the event in the out event of the other target. If this is replayed,
  8377. // then it's because we couldn't dispatch against this target previously
  8378. // so we have to do it now instead.
  8379. return null;
  8380. }
  8381. if (!isOutEvent && !isOverEvent) {
  8382. // Must not be a mouse or pointer in or out - ignoring.
  8383. return null;
  8384. }
  8385. var win;
  8386. if (nativeEventTarget.window === nativeEventTarget) {
  8387. // `nativeEventTarget` is probably a window object.
  8388. win = nativeEventTarget;
  8389. } else {
  8390. // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
  8391. var doc = nativeEventTarget.ownerDocument;
  8392. if (doc) {
  8393. win = doc.defaultView || doc.parentWindow;
  8394. } else {
  8395. win = window;
  8396. }
  8397. }
  8398. var from;
  8399. var to;
  8400. if (isOutEvent) {
  8401. from = targetInst;
  8402. var related = nativeEvent.relatedTarget || nativeEvent.toElement;
  8403. to = related ? getClosestInstanceFromNode(related) : null;
  8404. if (to !== null) {
  8405. var nearestMounted = getNearestMountedFiber(to);
  8406. if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) {
  8407. to = null;
  8408. }
  8409. }
  8410. } else {
  8411. // Moving to a node from outside the window.
  8412. from = null;
  8413. to = targetInst;
  8414. }
  8415. if (from === to) {
  8416. // Nothing pertains to our managed components.
  8417. return null;
  8418. }
  8419. var eventInterface, leaveEventType, enterEventType, eventTypePrefix;
  8420. if (topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_MOUSE_OVER) {
  8421. eventInterface = SyntheticMouseEvent;
  8422. leaveEventType = eventTypes$2.mouseLeave;
  8423. enterEventType = eventTypes$2.mouseEnter;
  8424. eventTypePrefix = 'mouse';
  8425. } else if (topLevelType === TOP_POINTER_OUT || topLevelType === TOP_POINTER_OVER) {
  8426. eventInterface = SyntheticPointerEvent;
  8427. leaveEventType = eventTypes$2.pointerLeave;
  8428. enterEventType = eventTypes$2.pointerEnter;
  8429. eventTypePrefix = 'pointer';
  8430. }
  8431. var fromNode = from == null ? win : getNodeFromInstance$1(from);
  8432. var toNode = to == null ? win : getNodeFromInstance$1(to);
  8433. var leave = eventInterface.getPooled(leaveEventType, from, nativeEvent, nativeEventTarget);
  8434. leave.type = eventTypePrefix + 'leave';
  8435. leave.target = fromNode;
  8436. leave.relatedTarget = toNode;
  8437. var enter = eventInterface.getPooled(enterEventType, to, nativeEvent, nativeEventTarget);
  8438. enter.type = eventTypePrefix + 'enter';
  8439. enter.target = toNode;
  8440. enter.relatedTarget = fromNode;
  8441. accumulateEnterLeaveDispatches(leave, enter, from, to); // If we are not processing the first ancestor, then we
  8442. // should not process the same nativeEvent again, as we
  8443. // will have already processed it in the first ancestor.
  8444. if ((eventSystemFlags & IS_FIRST_ANCESTOR) === 0) {
  8445. return [leave];
  8446. }
  8447. return [leave, enter];
  8448. }
  8449. };
  8450. /**
  8451. * inlined Object.is polyfill to avoid requiring consumers ship their own
  8452. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  8453. */
  8454. function is(x, y) {
  8455. return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
  8456. ;
  8457. }
  8458. var objectIs = typeof Object.is === 'function' ? Object.is : is;
  8459. var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
  8460. /**
  8461. * Performs equality by iterating through keys on an object and returning false
  8462. * when any key has values which are not strictly equal between the arguments.
  8463. * Returns true when the values of all keys are strictly equal.
  8464. */
  8465. function shallowEqual(objA, objB) {
  8466. if (objectIs(objA, objB)) {
  8467. return true;
  8468. }
  8469. if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
  8470. return false;
  8471. }
  8472. var keysA = Object.keys(objA);
  8473. var keysB = Object.keys(objB);
  8474. if (keysA.length !== keysB.length) {
  8475. return false;
  8476. } // Test for A's keys different from B.
  8477. for (var i = 0; i < keysA.length; i++) {
  8478. if (!hasOwnProperty$2.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) {
  8479. return false;
  8480. }
  8481. }
  8482. return true;
  8483. }
  8484. var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11;
  8485. var eventTypes$3 = {
  8486. select: {
  8487. phasedRegistrationNames: {
  8488. bubbled: 'onSelect',
  8489. captured: 'onSelectCapture'
  8490. },
  8491. dependencies: [TOP_BLUR, TOP_CONTEXT_MENU, TOP_DRAG_END, TOP_FOCUS, TOP_KEY_DOWN, TOP_KEY_UP, TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_SELECTION_CHANGE]
  8492. }
  8493. };
  8494. var activeElement$1 = null;
  8495. var activeElementInst$1 = null;
  8496. var lastSelection = null;
  8497. var mouseDown = false;
  8498. /**
  8499. * Get an object which is a unique representation of the current selection.
  8500. *
  8501. * The return value will not be consistent across nodes or browsers, but
  8502. * two identical selections on the same node will return identical objects.
  8503. *
  8504. * @param {DOMElement} node
  8505. * @return {object}
  8506. */
  8507. function getSelection$1(node) {
  8508. if ('selectionStart' in node && hasSelectionCapabilities(node)) {
  8509. return {
  8510. start: node.selectionStart,
  8511. end: node.selectionEnd
  8512. };
  8513. } else {
  8514. var win = node.ownerDocument && node.ownerDocument.defaultView || window;
  8515. var selection = win.getSelection();
  8516. return {
  8517. anchorNode: selection.anchorNode,
  8518. anchorOffset: selection.anchorOffset,
  8519. focusNode: selection.focusNode,
  8520. focusOffset: selection.focusOffset
  8521. };
  8522. }
  8523. }
  8524. /**
  8525. * Get document associated with the event target.
  8526. *
  8527. * @param {object} nativeEventTarget
  8528. * @return {Document}
  8529. */
  8530. function getEventTargetDocument(eventTarget) {
  8531. return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument;
  8532. }
  8533. /**
  8534. * Poll selection to see whether it's changed.
  8535. *
  8536. * @param {object} nativeEvent
  8537. * @param {object} nativeEventTarget
  8538. * @return {?SyntheticEvent}
  8539. */
  8540. function constructSelectEvent(nativeEvent, nativeEventTarget) {
  8541. // Ensure we have the right element, and that the user is not dragging a
  8542. // selection (this matches native `select` event behavior). In HTML5, select
  8543. // fires only on input and textarea thus if there's no focused element we
  8544. // won't dispatch.
  8545. var doc = getEventTargetDocument(nativeEventTarget);
  8546. if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) {
  8547. return null;
  8548. } // Only fire when selection has actually changed.
  8549. var currentSelection = getSelection$1(activeElement$1);
  8550. if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
  8551. lastSelection = currentSelection;
  8552. var syntheticEvent = SyntheticEvent.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);
  8553. syntheticEvent.type = 'select';
  8554. syntheticEvent.target = activeElement$1;
  8555. accumulateTwoPhaseDispatches(syntheticEvent);
  8556. return syntheticEvent;
  8557. }
  8558. return null;
  8559. }
  8560. /**
  8561. * This plugin creates an `onSelect` event that normalizes select events
  8562. * across form elements.
  8563. *
  8564. * Supported elements are:
  8565. * - input (see `isTextInputElement`)
  8566. * - textarea
  8567. * - contentEditable
  8568. *
  8569. * This differs from native browser implementations in the following ways:
  8570. * - Fires on contentEditable fields as well as inputs.
  8571. * - Fires for collapsed selection.
  8572. * - Fires after user input.
  8573. */
  8574. var SelectEventPlugin = {
  8575. eventTypes: eventTypes$3,
  8576. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, container) {
  8577. var containerOrDoc = container || getEventTargetDocument(nativeEventTarget); // Track whether all listeners exists for this plugin. If none exist, we do
  8578. // not extract events. See #3639.
  8579. if (!containerOrDoc || !isListeningToAllDependencies('onSelect', containerOrDoc)) {
  8580. return null;
  8581. }
  8582. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  8583. switch (topLevelType) {
  8584. // Track the input node that has focus.
  8585. case TOP_FOCUS:
  8586. if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') {
  8587. activeElement$1 = targetNode;
  8588. activeElementInst$1 = targetInst;
  8589. lastSelection = null;
  8590. }
  8591. break;
  8592. case TOP_BLUR:
  8593. activeElement$1 = null;
  8594. activeElementInst$1 = null;
  8595. lastSelection = null;
  8596. break;
  8597. // Don't fire the event while the user is dragging. This matches the
  8598. // semantics of the native select event.
  8599. case TOP_MOUSE_DOWN:
  8600. mouseDown = true;
  8601. break;
  8602. case TOP_CONTEXT_MENU:
  8603. case TOP_MOUSE_UP:
  8604. case TOP_DRAG_END:
  8605. mouseDown = false;
  8606. return constructSelectEvent(nativeEvent, nativeEventTarget);
  8607. // Chrome and IE fire non-standard event when selection is changed (and
  8608. // sometimes when it hasn't). IE's event fires out of order with respect
  8609. // to key and input events on deletion, so we discard it.
  8610. //
  8611. // Firefox doesn't support selectionchange, so check selection status
  8612. // after each key entry. The selection changes after keydown and before
  8613. // keyup, but we check on keydown as well in the case of holding down a
  8614. // key, when multiple keydown events are fired but only one keyup is.
  8615. // This is also our approach for IE handling, for the reason above.
  8616. case TOP_SELECTION_CHANGE:
  8617. if (skipSelectionChangeEvent) {
  8618. break;
  8619. }
  8620. // falls through
  8621. case TOP_KEY_DOWN:
  8622. case TOP_KEY_UP:
  8623. return constructSelectEvent(nativeEvent, nativeEventTarget);
  8624. }
  8625. return null;
  8626. }
  8627. };
  8628. /**
  8629. * @interface Event
  8630. * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
  8631. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
  8632. */
  8633. var SyntheticAnimationEvent = SyntheticEvent.extend({
  8634. animationName: null,
  8635. elapsedTime: null,
  8636. pseudoElement: null
  8637. });
  8638. /**
  8639. * @interface Event
  8640. * @see http://www.w3.org/TR/clipboard-apis/
  8641. */
  8642. var SyntheticClipboardEvent = SyntheticEvent.extend({
  8643. clipboardData: function (event) {
  8644. return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
  8645. }
  8646. });
  8647. /**
  8648. * @interface FocusEvent
  8649. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  8650. */
  8651. var SyntheticFocusEvent = SyntheticUIEvent.extend({
  8652. relatedTarget: null
  8653. });
  8654. /**
  8655. * `charCode` represents the actual "character code" and is safe to use with
  8656. * `String.fromCharCode`. As such, only keys that correspond to printable
  8657. * characters produce a valid `charCode`, the only exception to this is Enter.
  8658. * The Tab-key is considered non-printable and does not have a `charCode`,
  8659. * presumably because it does not produce a tab-character in browsers.
  8660. *
  8661. * @param {object} nativeEvent Native browser event.
  8662. * @return {number} Normalized `charCode` property.
  8663. */
  8664. function getEventCharCode(nativeEvent) {
  8665. var charCode;
  8666. var keyCode = nativeEvent.keyCode;
  8667. if ('charCode' in nativeEvent) {
  8668. charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`.
  8669. if (charCode === 0 && keyCode === 13) {
  8670. charCode = 13;
  8671. }
  8672. } else {
  8673. // IE8 does not implement `charCode`, but `keyCode` has the correct value.
  8674. charCode = keyCode;
  8675. } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux)
  8676. // report Enter as charCode 10 when ctrl is pressed.
  8677. if (charCode === 10) {
  8678. charCode = 13;
  8679. } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
  8680. // Must not discard the (non-)printable Enter-key.
  8681. if (charCode >= 32 || charCode === 13) {
  8682. return charCode;
  8683. }
  8684. return 0;
  8685. }
  8686. /**
  8687. * Normalization of deprecated HTML5 `key` values
  8688. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  8689. */
  8690. var normalizeKey = {
  8691. Esc: 'Escape',
  8692. Spacebar: ' ',
  8693. Left: 'ArrowLeft',
  8694. Up: 'ArrowUp',
  8695. Right: 'ArrowRight',
  8696. Down: 'ArrowDown',
  8697. Del: 'Delete',
  8698. Win: 'OS',
  8699. Menu: 'ContextMenu',
  8700. Apps: 'ContextMenu',
  8701. Scroll: 'ScrollLock',
  8702. MozPrintableKey: 'Unidentified'
  8703. };
  8704. /**
  8705. * Translation from legacy `keyCode` to HTML5 `key`
  8706. * Only special keys supported, all others depend on keyboard layout or browser
  8707. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  8708. */
  8709. var translateToKey = {
  8710. '8': 'Backspace',
  8711. '9': 'Tab',
  8712. '12': 'Clear',
  8713. '13': 'Enter',
  8714. '16': 'Shift',
  8715. '17': 'Control',
  8716. '18': 'Alt',
  8717. '19': 'Pause',
  8718. '20': 'CapsLock',
  8719. '27': 'Escape',
  8720. '32': ' ',
  8721. '33': 'PageUp',
  8722. '34': 'PageDown',
  8723. '35': 'End',
  8724. '36': 'Home',
  8725. '37': 'ArrowLeft',
  8726. '38': 'ArrowUp',
  8727. '39': 'ArrowRight',
  8728. '40': 'ArrowDown',
  8729. '45': 'Insert',
  8730. '46': 'Delete',
  8731. '112': 'F1',
  8732. '113': 'F2',
  8733. '114': 'F3',
  8734. '115': 'F4',
  8735. '116': 'F5',
  8736. '117': 'F6',
  8737. '118': 'F7',
  8738. '119': 'F8',
  8739. '120': 'F9',
  8740. '121': 'F10',
  8741. '122': 'F11',
  8742. '123': 'F12',
  8743. '144': 'NumLock',
  8744. '145': 'ScrollLock',
  8745. '224': 'Meta'
  8746. };
  8747. /**
  8748. * @param {object} nativeEvent Native browser event.
  8749. * @return {string} Normalized `key` property.
  8750. */
  8751. function getEventKey(nativeEvent) {
  8752. if (nativeEvent.key) {
  8753. // Normalize inconsistent values reported by browsers due to
  8754. // implementations of a working draft specification.
  8755. // FireFox implements `key` but returns `MozPrintableKey` for all
  8756. // printable characters (normalized to `Unidentified`), ignore it.
  8757. var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
  8758. if (key !== 'Unidentified') {
  8759. return key;
  8760. }
  8761. } // Browser does not implement `key`, polyfill as much of it as we can.
  8762. if (nativeEvent.type === 'keypress') {
  8763. var charCode = getEventCharCode(nativeEvent); // The enter-key is technically both printable and non-printable and can
  8764. // thus be captured by `keypress`, no other non-printable key should.
  8765. return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
  8766. }
  8767. if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
  8768. // While user keyboard layout determines the actual meaning of each
  8769. // `keyCode` value, almost all function keys have a universal value.
  8770. return translateToKey[nativeEvent.keyCode] || 'Unidentified';
  8771. }
  8772. return '';
  8773. }
  8774. /**
  8775. * @interface KeyboardEvent
  8776. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  8777. */
  8778. var SyntheticKeyboardEvent = SyntheticUIEvent.extend({
  8779. key: getEventKey,
  8780. location: null,
  8781. ctrlKey: null,
  8782. shiftKey: null,
  8783. altKey: null,
  8784. metaKey: null,
  8785. repeat: null,
  8786. locale: null,
  8787. getModifierState: getEventModifierState,
  8788. // Legacy Interface
  8789. charCode: function (event) {
  8790. // `charCode` is the result of a KeyPress event and represents the value of
  8791. // the actual printable character.
  8792. // KeyPress is deprecated, but its replacement is not yet final and not
  8793. // implemented in any major browser. Only KeyPress has charCode.
  8794. if (event.type === 'keypress') {
  8795. return getEventCharCode(event);
  8796. }
  8797. return 0;
  8798. },
  8799. keyCode: function (event) {
  8800. // `keyCode` is the result of a KeyDown/Up event and represents the value of
  8801. // physical keyboard key.
  8802. // The actual meaning of the value depends on the users' keyboard layout
  8803. // which cannot be detected. Assuming that it is a US keyboard layout
  8804. // provides a surprisingly accurate mapping for US and European users.
  8805. // Due to this, it is left to the user to implement at this time.
  8806. if (event.type === 'keydown' || event.type === 'keyup') {
  8807. return event.keyCode;
  8808. }
  8809. return 0;
  8810. },
  8811. which: function (event) {
  8812. // `which` is an alias for either `keyCode` or `charCode` depending on the
  8813. // type of the event.
  8814. if (event.type === 'keypress') {
  8815. return getEventCharCode(event);
  8816. }
  8817. if (event.type === 'keydown' || event.type === 'keyup') {
  8818. return event.keyCode;
  8819. }
  8820. return 0;
  8821. }
  8822. });
  8823. /**
  8824. * @interface DragEvent
  8825. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  8826. */
  8827. var SyntheticDragEvent = SyntheticMouseEvent.extend({
  8828. dataTransfer: null
  8829. });
  8830. /**
  8831. * @interface TouchEvent
  8832. * @see http://www.w3.org/TR/touch-events/
  8833. */
  8834. var SyntheticTouchEvent = SyntheticUIEvent.extend({
  8835. touches: null,
  8836. targetTouches: null,
  8837. changedTouches: null,
  8838. altKey: null,
  8839. metaKey: null,
  8840. ctrlKey: null,
  8841. shiftKey: null,
  8842. getModifierState: getEventModifierState
  8843. });
  8844. /**
  8845. * @interface Event
  8846. * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
  8847. * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent
  8848. */
  8849. var SyntheticTransitionEvent = SyntheticEvent.extend({
  8850. propertyName: null,
  8851. elapsedTime: null,
  8852. pseudoElement: null
  8853. });
  8854. /**
  8855. * @interface WheelEvent
  8856. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  8857. */
  8858. var SyntheticWheelEvent = SyntheticMouseEvent.extend({
  8859. deltaX: function (event) {
  8860. return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
  8861. 'wheelDeltaX' in event ? -event.wheelDeltaX : 0;
  8862. },
  8863. deltaY: function (event) {
  8864. return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
  8865. 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
  8866. 'wheelDelta' in event ? -event.wheelDelta : 0;
  8867. },
  8868. deltaZ: null,
  8869. // Browsers without "deltaMode" is reporting in raw wheel delta where one
  8870. // notch on the scroll is always +/- 120, roughly equivalent to pixels.
  8871. // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
  8872. // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
  8873. deltaMode: null
  8874. });
  8875. var knownHTMLTopLevelTypes = [TOP_ABORT, TOP_CANCEL, TOP_CAN_PLAY, TOP_CAN_PLAY_THROUGH, TOP_CLOSE, TOP_DURATION_CHANGE, TOP_EMPTIED, TOP_ENCRYPTED, TOP_ENDED, TOP_ERROR, TOP_INPUT, TOP_INVALID, TOP_LOAD, TOP_LOADED_DATA, TOP_LOADED_METADATA, TOP_LOAD_START, TOP_PAUSE, TOP_PLAY, TOP_PLAYING, TOP_PROGRESS, TOP_RATE_CHANGE, TOP_RESET, TOP_SEEKED, TOP_SEEKING, TOP_STALLED, TOP_SUBMIT, TOP_SUSPEND, TOP_TIME_UPDATE, TOP_TOGGLE, TOP_VOLUME_CHANGE, TOP_WAITING];
  8876. var SimpleEventPlugin = {
  8877. // simpleEventPluginEventTypes gets populated from
  8878. // the DOMEventProperties module.
  8879. eventTypes: simpleEventPluginEventTypes,
  8880. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  8881. var dispatchConfig = topLevelEventsToDispatchConfig.get(topLevelType);
  8882. if (!dispatchConfig) {
  8883. return null;
  8884. }
  8885. var EventConstructor;
  8886. switch (topLevelType) {
  8887. case TOP_KEY_PRESS:
  8888. // Firefox creates a keypress event for function keys too. This removes
  8889. // the unwanted keypress events. Enter is however both printable and
  8890. // non-printable. One would expect Tab to be as well (but it isn't).
  8891. if (getEventCharCode(nativeEvent) === 0) {
  8892. return null;
  8893. }
  8894. /* falls through */
  8895. case TOP_KEY_DOWN:
  8896. case TOP_KEY_UP:
  8897. EventConstructor = SyntheticKeyboardEvent;
  8898. break;
  8899. case TOP_BLUR:
  8900. case TOP_FOCUS:
  8901. EventConstructor = SyntheticFocusEvent;
  8902. break;
  8903. case TOP_CLICK:
  8904. // Firefox creates a click event on right mouse clicks. This removes the
  8905. // unwanted click events.
  8906. if (nativeEvent.button === 2) {
  8907. return null;
  8908. }
  8909. /* falls through */
  8910. case TOP_AUX_CLICK:
  8911. case TOP_DOUBLE_CLICK:
  8912. case TOP_MOUSE_DOWN:
  8913. case TOP_MOUSE_MOVE:
  8914. case TOP_MOUSE_UP: // TODO: Disabled elements should not respond to mouse events
  8915. /* falls through */
  8916. case TOP_MOUSE_OUT:
  8917. case TOP_MOUSE_OVER:
  8918. case TOP_CONTEXT_MENU:
  8919. EventConstructor = SyntheticMouseEvent;
  8920. break;
  8921. case TOP_DRAG:
  8922. case TOP_DRAG_END:
  8923. case TOP_DRAG_ENTER:
  8924. case TOP_DRAG_EXIT:
  8925. case TOP_DRAG_LEAVE:
  8926. case TOP_DRAG_OVER:
  8927. case TOP_DRAG_START:
  8928. case TOP_DROP:
  8929. EventConstructor = SyntheticDragEvent;
  8930. break;
  8931. case TOP_TOUCH_CANCEL:
  8932. case TOP_TOUCH_END:
  8933. case TOP_TOUCH_MOVE:
  8934. case TOP_TOUCH_START:
  8935. EventConstructor = SyntheticTouchEvent;
  8936. break;
  8937. case TOP_ANIMATION_END:
  8938. case TOP_ANIMATION_ITERATION:
  8939. case TOP_ANIMATION_START:
  8940. EventConstructor = SyntheticAnimationEvent;
  8941. break;
  8942. case TOP_TRANSITION_END:
  8943. EventConstructor = SyntheticTransitionEvent;
  8944. break;
  8945. case TOP_SCROLL:
  8946. EventConstructor = SyntheticUIEvent;
  8947. break;
  8948. case TOP_WHEEL:
  8949. EventConstructor = SyntheticWheelEvent;
  8950. break;
  8951. case TOP_COPY:
  8952. case TOP_CUT:
  8953. case TOP_PASTE:
  8954. EventConstructor = SyntheticClipboardEvent;
  8955. break;
  8956. case TOP_GOT_POINTER_CAPTURE:
  8957. case TOP_LOST_POINTER_CAPTURE:
  8958. case TOP_POINTER_CANCEL:
  8959. case TOP_POINTER_DOWN:
  8960. case TOP_POINTER_MOVE:
  8961. case TOP_POINTER_OUT:
  8962. case TOP_POINTER_OVER:
  8963. case TOP_POINTER_UP:
  8964. EventConstructor = SyntheticPointerEvent;
  8965. break;
  8966. default:
  8967. {
  8968. if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) {
  8969. error('SimpleEventPlugin: Unhandled event type, `%s`. This warning ' + 'is likely caused by a bug in React. Please file an issue.', topLevelType);
  8970. }
  8971. } // HTML Events
  8972. // @see http://www.w3.org/TR/html5/index.html#events-0
  8973. EventConstructor = SyntheticEvent;
  8974. break;
  8975. }
  8976. var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget);
  8977. accumulateTwoPhaseDispatches(event);
  8978. return event;
  8979. }
  8980. };
  8981. /**
  8982. * Specifies a deterministic ordering of `EventPlugin`s. A convenient way to
  8983. * reason about plugins, without having to package every one of them. This
  8984. * is better than having plugins be ordered in the same order that they
  8985. * are injected because that ordering would be influenced by the packaging order.
  8986. * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
  8987. * preventing default on events is convenient in `SimpleEventPlugin` handlers.
  8988. */
  8989. var DOMEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin'];
  8990. /**
  8991. * Inject modules for resolving DOM hierarchy and plugin ordering.
  8992. */
  8993. injectEventPluginOrder(DOMEventPluginOrder);
  8994. setComponentTree(getFiberCurrentPropsFromNode$1, getInstanceFromNode$1, getNodeFromInstance$1);
  8995. /**
  8996. * Some important event plugins included by default (without having to require
  8997. * them).
  8998. */
  8999. injectEventPluginsByName({
  9000. SimpleEventPlugin: SimpleEventPlugin,
  9001. EnterLeaveEventPlugin: EnterLeaveEventPlugin,
  9002. ChangeEventPlugin: ChangeEventPlugin,
  9003. SelectEventPlugin: SelectEventPlugin,
  9004. BeforeInputEventPlugin: BeforeInputEventPlugin
  9005. });
  9006. // Prefix measurements so that it's possible to filter them.
  9007. // Longer prefixes are hard to read in DevTools.
  9008. var reactEmoji = "\u269B";
  9009. var warningEmoji = "\u26D4";
  9010. var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; // Keep track of current fiber so that we know the path to unwind on pause.
  9011. // TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
  9012. var currentFiber = null; // If we're in the middle of user code, which fiber and method is it?
  9013. // Reusing `currentFiber` would be confusing for this because user code fiber
  9014. // can change during commit phase too, but we don't need to unwind it (since
  9015. // lifecycles in the commit phase don't resemble a tree).
  9016. var currentPhase = null;
  9017. var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem,
  9018. // so we will keep track of it, and include it in the report.
  9019. // Track commits caused by cascading updates.
  9020. var isCommitting = false;
  9021. var hasScheduledUpdateInCurrentCommit = false;
  9022. var hasScheduledUpdateInCurrentPhase = false;
  9023. var commitCountInCurrentWorkLoop = 0;
  9024. var effectCountInCurrentCommit = 0;
  9025. // to avoid stretch the commit phase with measurement overhead.
  9026. var labelsInCurrentCommit = new Set();
  9027. var formatMarkName = function (markName) {
  9028. return reactEmoji + " " + markName;
  9029. };
  9030. var formatLabel = function (label, warning) {
  9031. var prefix = warning ? warningEmoji + " " : reactEmoji + " ";
  9032. var suffix = warning ? " Warning: " + warning : '';
  9033. return "" + prefix + label + suffix;
  9034. };
  9035. var beginMark = function (markName) {
  9036. performance.mark(formatMarkName(markName));
  9037. };
  9038. var clearMark = function (markName) {
  9039. performance.clearMarks(formatMarkName(markName));
  9040. };
  9041. var endMark = function (label, markName, warning) {
  9042. var formattedMarkName = formatMarkName(markName);
  9043. var formattedLabel = formatLabel(label, warning);
  9044. try {
  9045. performance.measure(formattedLabel, formattedMarkName);
  9046. } catch (err) {} // If previous mark was missing for some reason, this will throw.
  9047. // This could only happen if React crashed in an unexpected place earlier.
  9048. // Don't pile on with more errors.
  9049. // Clear marks immediately to avoid growing buffer.
  9050. performance.clearMarks(formattedMarkName);
  9051. performance.clearMeasures(formattedLabel);
  9052. };
  9053. var getFiberMarkName = function (label, debugID) {
  9054. return label + " (#" + debugID + ")";
  9055. };
  9056. var getFiberLabel = function (componentName, isMounted, phase) {
  9057. if (phase === null) {
  9058. // These are composite component total time measurements.
  9059. return componentName + " [" + (isMounted ? 'update' : 'mount') + "]";
  9060. } else {
  9061. // Composite component methods.
  9062. return componentName + "." + phase;
  9063. }
  9064. };
  9065. var beginFiberMark = function (fiber, phase) {
  9066. var componentName = getComponentName(fiber.type) || 'Unknown';
  9067. var debugID = fiber._debugID;
  9068. var isMounted = fiber.alternate !== null;
  9069. var label = getFiberLabel(componentName, isMounted, phase);
  9070. if (isCommitting && labelsInCurrentCommit.has(label)) {
  9071. // During the commit phase, we don't show duplicate labels because
  9072. // there is a fixed overhead for every measurement, and we don't
  9073. // want to stretch the commit phase beyond necessary.
  9074. return false;
  9075. }
  9076. labelsInCurrentCommit.add(label);
  9077. var markName = getFiberMarkName(label, debugID);
  9078. beginMark(markName);
  9079. return true;
  9080. };
  9081. var clearFiberMark = function (fiber, phase) {
  9082. var componentName = getComponentName(fiber.type) || 'Unknown';
  9083. var debugID = fiber._debugID;
  9084. var isMounted = fiber.alternate !== null;
  9085. var label = getFiberLabel(componentName, isMounted, phase);
  9086. var markName = getFiberMarkName(label, debugID);
  9087. clearMark(markName);
  9088. };
  9089. var endFiberMark = function (fiber, phase, warning) {
  9090. var componentName = getComponentName(fiber.type) || 'Unknown';
  9091. var debugID = fiber._debugID;
  9092. var isMounted = fiber.alternate !== null;
  9093. var label = getFiberLabel(componentName, isMounted, phase);
  9094. var markName = getFiberMarkName(label, debugID);
  9095. endMark(label, markName, warning);
  9096. };
  9097. var shouldIgnoreFiber = function (fiber) {
  9098. // Host components should be skipped in the timeline.
  9099. // We could check typeof fiber.type, but does this work with RN?
  9100. switch (fiber.tag) {
  9101. case HostRoot:
  9102. case HostComponent:
  9103. case HostText:
  9104. case HostPortal:
  9105. case Fragment:
  9106. case ContextProvider:
  9107. case ContextConsumer:
  9108. case Mode:
  9109. return true;
  9110. default:
  9111. return false;
  9112. }
  9113. };
  9114. var clearPendingPhaseMeasurement = function () {
  9115. if (currentPhase !== null && currentPhaseFiber !== null) {
  9116. clearFiberMark(currentPhaseFiber, currentPhase);
  9117. }
  9118. currentPhaseFiber = null;
  9119. currentPhase = null;
  9120. hasScheduledUpdateInCurrentPhase = false;
  9121. };
  9122. var pauseTimers = function () {
  9123. // Stops all currently active measurements so that they can be resumed
  9124. // if we continue in a later deferred loop from the same unit of work.
  9125. var fiber = currentFiber;
  9126. while (fiber) {
  9127. if (fiber._debugIsCurrentlyTiming) {
  9128. endFiberMark(fiber, null, null);
  9129. }
  9130. fiber = fiber.return;
  9131. }
  9132. };
  9133. var resumeTimersRecursively = function (fiber) {
  9134. if (fiber.return !== null) {
  9135. resumeTimersRecursively(fiber.return);
  9136. }
  9137. if (fiber._debugIsCurrentlyTiming) {
  9138. beginFiberMark(fiber, null);
  9139. }
  9140. };
  9141. var resumeTimers = function () {
  9142. // Resumes all measurements that were active during the last deferred loop.
  9143. if (currentFiber !== null) {
  9144. resumeTimersRecursively(currentFiber);
  9145. }
  9146. };
  9147. function recordEffect() {
  9148. {
  9149. effectCountInCurrentCommit++;
  9150. }
  9151. }
  9152. function recordScheduleUpdate() {
  9153. {
  9154. if (isCommitting) {
  9155. hasScheduledUpdateInCurrentCommit = true;
  9156. }
  9157. if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
  9158. hasScheduledUpdateInCurrentPhase = true;
  9159. }
  9160. }
  9161. }
  9162. function startWorkTimer(fiber) {
  9163. {
  9164. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  9165. return;
  9166. } // If we pause, this is the fiber to unwind from.
  9167. currentFiber = fiber;
  9168. if (!beginFiberMark(fiber, null)) {
  9169. return;
  9170. }
  9171. fiber._debugIsCurrentlyTiming = true;
  9172. }
  9173. }
  9174. function cancelWorkTimer(fiber) {
  9175. {
  9176. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  9177. return;
  9178. } // Remember we shouldn't complete measurement for this fiber.
  9179. // Otherwise flamechart will be deep even for small updates.
  9180. fiber._debugIsCurrentlyTiming = false;
  9181. clearFiberMark(fiber, null);
  9182. }
  9183. }
  9184. function stopWorkTimer(fiber) {
  9185. {
  9186. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  9187. return;
  9188. } // If we pause, its parent is the fiber to unwind from.
  9189. currentFiber = fiber.return;
  9190. if (!fiber._debugIsCurrentlyTiming) {
  9191. return;
  9192. }
  9193. fiber._debugIsCurrentlyTiming = false;
  9194. endFiberMark(fiber, null, null);
  9195. }
  9196. }
  9197. function stopFailedWorkTimer(fiber) {
  9198. {
  9199. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  9200. return;
  9201. } // If we pause, its parent is the fiber to unwind from.
  9202. currentFiber = fiber.return;
  9203. if (!fiber._debugIsCurrentlyTiming) {
  9204. return;
  9205. }
  9206. fiber._debugIsCurrentlyTiming = false;
  9207. var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
  9208. endFiberMark(fiber, null, warning);
  9209. }
  9210. }
  9211. function startPhaseTimer(fiber, phase) {
  9212. {
  9213. if (!supportsUserTiming) {
  9214. return;
  9215. }
  9216. clearPendingPhaseMeasurement();
  9217. if (!beginFiberMark(fiber, phase)) {
  9218. return;
  9219. }
  9220. currentPhaseFiber = fiber;
  9221. currentPhase = phase;
  9222. }
  9223. }
  9224. function stopPhaseTimer() {
  9225. {
  9226. if (!supportsUserTiming) {
  9227. return;
  9228. }
  9229. if (currentPhase !== null && currentPhaseFiber !== null) {
  9230. var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
  9231. endFiberMark(currentPhaseFiber, currentPhase, warning);
  9232. }
  9233. currentPhase = null;
  9234. currentPhaseFiber = null;
  9235. }
  9236. }
  9237. function startWorkLoopTimer(nextUnitOfWork) {
  9238. {
  9239. currentFiber = nextUnitOfWork;
  9240. if (!supportsUserTiming) {
  9241. return;
  9242. }
  9243. commitCountInCurrentWorkLoop = 0; // This is top level call.
  9244. // Any other measurements are performed within.
  9245. beginMark('(React Tree Reconciliation)'); // Resume any measurements that were in progress during the last loop.
  9246. resumeTimers();
  9247. }
  9248. }
  9249. function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
  9250. {
  9251. if (!supportsUserTiming) {
  9252. return;
  9253. }
  9254. var warning = null;
  9255. if (interruptedBy !== null) {
  9256. if (interruptedBy.tag === HostRoot) {
  9257. warning = 'A top-level update interrupted the previous render';
  9258. } else {
  9259. var componentName = getComponentName(interruptedBy.type) || 'Unknown';
  9260. warning = "An update to " + componentName + " interrupted the previous render";
  9261. }
  9262. } else if (commitCountInCurrentWorkLoop > 1) {
  9263. warning = 'There were cascading updates';
  9264. }
  9265. commitCountInCurrentWorkLoop = 0;
  9266. var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)'; // Pause any measurements until the next loop.
  9267. pauseTimers();
  9268. endMark(label, '(React Tree Reconciliation)', warning);
  9269. }
  9270. }
  9271. function startCommitTimer() {
  9272. {
  9273. if (!supportsUserTiming) {
  9274. return;
  9275. }
  9276. isCommitting = true;
  9277. hasScheduledUpdateInCurrentCommit = false;
  9278. labelsInCurrentCommit.clear();
  9279. beginMark('(Committing Changes)');
  9280. }
  9281. }
  9282. function stopCommitTimer() {
  9283. {
  9284. if (!supportsUserTiming) {
  9285. return;
  9286. }
  9287. var warning = null;
  9288. if (hasScheduledUpdateInCurrentCommit) {
  9289. warning = 'Lifecycle hook scheduled a cascading update';
  9290. } else if (commitCountInCurrentWorkLoop > 0) {
  9291. warning = 'Caused by a cascading update in earlier commit';
  9292. }
  9293. hasScheduledUpdateInCurrentCommit = false;
  9294. commitCountInCurrentWorkLoop++;
  9295. isCommitting = false;
  9296. labelsInCurrentCommit.clear();
  9297. endMark('(Committing Changes)', '(Committing Changes)', warning);
  9298. }
  9299. }
  9300. function startCommitSnapshotEffectsTimer() {
  9301. {
  9302. if (!supportsUserTiming) {
  9303. return;
  9304. }
  9305. effectCountInCurrentCommit = 0;
  9306. beginMark('(Committing Snapshot Effects)');
  9307. }
  9308. }
  9309. function stopCommitSnapshotEffectsTimer() {
  9310. {
  9311. if (!supportsUserTiming) {
  9312. return;
  9313. }
  9314. var count = effectCountInCurrentCommit;
  9315. effectCountInCurrentCommit = 0;
  9316. endMark("(Committing Snapshot Effects: " + count + " Total)", '(Committing Snapshot Effects)', null);
  9317. }
  9318. }
  9319. function startCommitHostEffectsTimer() {
  9320. {
  9321. if (!supportsUserTiming) {
  9322. return;
  9323. }
  9324. effectCountInCurrentCommit = 0;
  9325. beginMark('(Committing Host Effects)');
  9326. }
  9327. }
  9328. function stopCommitHostEffectsTimer() {
  9329. {
  9330. if (!supportsUserTiming) {
  9331. return;
  9332. }
  9333. var count = effectCountInCurrentCommit;
  9334. effectCountInCurrentCommit = 0;
  9335. endMark("(Committing Host Effects: " + count + " Total)", '(Committing Host Effects)', null);
  9336. }
  9337. }
  9338. function startCommitLifeCyclesTimer() {
  9339. {
  9340. if (!supportsUserTiming) {
  9341. return;
  9342. }
  9343. effectCountInCurrentCommit = 0;
  9344. beginMark('(Calling Lifecycle Methods)');
  9345. }
  9346. }
  9347. function stopCommitLifeCyclesTimer() {
  9348. {
  9349. if (!supportsUserTiming) {
  9350. return;
  9351. }
  9352. var count = effectCountInCurrentCommit;
  9353. effectCountInCurrentCommit = 0;
  9354. endMark("(Calling Lifecycle Methods: " + count + " Total)", '(Calling Lifecycle Methods)', null);
  9355. }
  9356. }
  9357. var valueStack = [];
  9358. var fiberStack;
  9359. {
  9360. fiberStack = [];
  9361. }
  9362. var index = -1;
  9363. function createCursor(defaultValue) {
  9364. return {
  9365. current: defaultValue
  9366. };
  9367. }
  9368. function pop(cursor, fiber) {
  9369. if (index < 0) {
  9370. {
  9371. error('Unexpected pop.');
  9372. }
  9373. return;
  9374. }
  9375. {
  9376. if (fiber !== fiberStack[index]) {
  9377. error('Unexpected Fiber popped.');
  9378. }
  9379. }
  9380. cursor.current = valueStack[index];
  9381. valueStack[index] = null;
  9382. {
  9383. fiberStack[index] = null;
  9384. }
  9385. index--;
  9386. }
  9387. function push(cursor, value, fiber) {
  9388. index++;
  9389. valueStack[index] = cursor.current;
  9390. {
  9391. fiberStack[index] = fiber;
  9392. }
  9393. cursor.current = value;
  9394. }
  9395. var warnedAboutMissingGetChildContext;
  9396. {
  9397. warnedAboutMissingGetChildContext = {};
  9398. }
  9399. var emptyContextObject = {};
  9400. {
  9401. Object.freeze(emptyContextObject);
  9402. } // A cursor to the current merged context object on the stack.
  9403. var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed.
  9404. var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack.
  9405. // We use this to get access to the parent context after we have already
  9406. // pushed the next context provider, and now need to merge their contexts.
  9407. var previousContext = emptyContextObject;
  9408. function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
  9409. {
  9410. if (didPushOwnContextIfProvider && isContextProvider(Component)) {
  9411. // If the fiber is a context provider itself, when we read its context
  9412. // we may have already pushed its own child context on the stack. A context
  9413. // provider should not "see" its own child context. Therefore we read the
  9414. // previous (parent) context instead for a context provider.
  9415. return previousContext;
  9416. }
  9417. return contextStackCursor.current;
  9418. }
  9419. }
  9420. function cacheContext(workInProgress, unmaskedContext, maskedContext) {
  9421. {
  9422. var instance = workInProgress.stateNode;
  9423. instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
  9424. instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
  9425. }
  9426. }
  9427. function getMaskedContext(workInProgress, unmaskedContext) {
  9428. {
  9429. var type = workInProgress.type;
  9430. var contextTypes = type.contextTypes;
  9431. if (!contextTypes) {
  9432. return emptyContextObject;
  9433. } // Avoid recreating masked context unless unmasked context has changed.
  9434. // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
  9435. // This may trigger infinite loops if componentWillReceiveProps calls setState.
  9436. var instance = workInProgress.stateNode;
  9437. if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
  9438. return instance.__reactInternalMemoizedMaskedChildContext;
  9439. }
  9440. var context = {};
  9441. for (var key in contextTypes) {
  9442. context[key] = unmaskedContext[key];
  9443. }
  9444. {
  9445. var name = getComponentName(type) || 'Unknown';
  9446. checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
  9447. } // Cache unmasked context so we can avoid recreating masked context unless necessary.
  9448. // Context is created before the class component is instantiated so check for instance.
  9449. if (instance) {
  9450. cacheContext(workInProgress, unmaskedContext, context);
  9451. }
  9452. return context;
  9453. }
  9454. }
  9455. function hasContextChanged() {
  9456. {
  9457. return didPerformWorkStackCursor.current;
  9458. }
  9459. }
  9460. function isContextProvider(type) {
  9461. {
  9462. var childContextTypes = type.childContextTypes;
  9463. return childContextTypes !== null && childContextTypes !== undefined;
  9464. }
  9465. }
  9466. function popContext(fiber) {
  9467. {
  9468. pop(didPerformWorkStackCursor, fiber);
  9469. pop(contextStackCursor, fiber);
  9470. }
  9471. }
  9472. function popTopLevelContextObject(fiber) {
  9473. {
  9474. pop(didPerformWorkStackCursor, fiber);
  9475. pop(contextStackCursor, fiber);
  9476. }
  9477. }
  9478. function pushTopLevelContextObject(fiber, context, didChange) {
  9479. {
  9480. if (!(contextStackCursor.current === emptyContextObject)) {
  9481. {
  9482. throw Error( "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." );
  9483. }
  9484. }
  9485. push(contextStackCursor, context, fiber);
  9486. push(didPerformWorkStackCursor, didChange, fiber);
  9487. }
  9488. }
  9489. function processChildContext(fiber, type, parentContext) {
  9490. {
  9491. var instance = fiber.stateNode;
  9492. var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future.
  9493. // It has only been added in Fiber to match the (unintentional) behavior in Stack.
  9494. if (typeof instance.getChildContext !== 'function') {
  9495. {
  9496. var componentName = getComponentName(type) || 'Unknown';
  9497. if (!warnedAboutMissingGetChildContext[componentName]) {
  9498. warnedAboutMissingGetChildContext[componentName] = true;
  9499. error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName);
  9500. }
  9501. }
  9502. return parentContext;
  9503. }
  9504. var childContext;
  9505. startPhaseTimer(fiber, 'getChildContext');
  9506. childContext = instance.getChildContext();
  9507. stopPhaseTimer();
  9508. for (var contextKey in childContext) {
  9509. if (!(contextKey in childContextTypes)) {
  9510. {
  9511. throw Error( (getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes." );
  9512. }
  9513. }
  9514. }
  9515. {
  9516. var name = getComponentName(type) || 'Unknown';
  9517. checkPropTypes(childContextTypes, childContext, 'child context', name, // In practice, there is one case in which we won't get a stack. It's when
  9518. // somebody calls unstable_renderSubtreeIntoContainer() and we process
  9519. // context from the parent component instance. The stack will be missing
  9520. // because it's outside of the reconciliation, and so the pointer has not
  9521. // been set. This is rare and doesn't matter. We'll also remove that API.
  9522. getCurrentFiberStackInDev);
  9523. }
  9524. return _assign({}, parentContext, {}, childContext);
  9525. }
  9526. }
  9527. function pushContextProvider(workInProgress) {
  9528. {
  9529. var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity.
  9530. // If the instance does not exist yet, we will push null at first,
  9531. // and replace it on the stack later when invalidating the context.
  9532. var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later.
  9533. // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates.
  9534. previousContext = contextStackCursor.current;
  9535. push(contextStackCursor, memoizedMergedChildContext, workInProgress);
  9536. push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
  9537. return true;
  9538. }
  9539. }
  9540. function invalidateContextProvider(workInProgress, type, didChange) {
  9541. {
  9542. var instance = workInProgress.stateNode;
  9543. if (!instance) {
  9544. {
  9545. throw Error( "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." );
  9546. }
  9547. }
  9548. if (didChange) {
  9549. // Merge parent and own context.
  9550. // Skip this if we're not updating due to sCU.
  9551. // This avoids unnecessarily recomputing memoized values.
  9552. var mergedContext = processChildContext(workInProgress, type, previousContext);
  9553. instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one.
  9554. // It is important to unwind the context in the reverse order.
  9555. pop(didPerformWorkStackCursor, workInProgress);
  9556. pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed.
  9557. push(contextStackCursor, mergedContext, workInProgress);
  9558. push(didPerformWorkStackCursor, didChange, workInProgress);
  9559. } else {
  9560. pop(didPerformWorkStackCursor, workInProgress);
  9561. push(didPerformWorkStackCursor, didChange, workInProgress);
  9562. }
  9563. }
  9564. }
  9565. function findCurrentUnmaskedContext(fiber) {
  9566. {
  9567. // Currently this is only used with renderSubtreeIntoContainer; not sure if it
  9568. // makes sense elsewhere
  9569. if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
  9570. {
  9571. throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." );
  9572. }
  9573. }
  9574. var node = fiber;
  9575. do {
  9576. switch (node.tag) {
  9577. case HostRoot:
  9578. return node.stateNode.context;
  9579. case ClassComponent:
  9580. {
  9581. var Component = node.type;
  9582. if (isContextProvider(Component)) {
  9583. return node.stateNode.__reactInternalMemoizedMergedChildContext;
  9584. }
  9585. break;
  9586. }
  9587. }
  9588. node = node.return;
  9589. } while (node !== null);
  9590. {
  9591. {
  9592. throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." );
  9593. }
  9594. }
  9595. }
  9596. }
  9597. var LegacyRoot = 0;
  9598. var BlockingRoot = 1;
  9599. var ConcurrentRoot = 2;
  9600. var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
  9601. Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback,
  9602. Scheduler_cancelCallback = Scheduler.unstable_cancelCallback,
  9603. Scheduler_shouldYield = Scheduler.unstable_shouldYield,
  9604. Scheduler_requestPaint = Scheduler.unstable_requestPaint,
  9605. Scheduler_now = Scheduler.unstable_now,
  9606. Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel,
  9607. Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority,
  9608. Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority,
  9609. Scheduler_NormalPriority = Scheduler.unstable_NormalPriority,
  9610. Scheduler_LowPriority = Scheduler.unstable_LowPriority,
  9611. Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
  9612. {
  9613. // Provide explicit error message when production+profiling bundle of e.g.
  9614. // react-dom is used with production (non-profiling) bundle of
  9615. // scheduler/tracing
  9616. if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
  9617. {
  9618. throw Error( "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" );
  9619. }
  9620. }
  9621. }
  9622. var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use
  9623. // ascending numbers so we can compare them like numbers. They start at 90 to
  9624. // avoid clashing with Scheduler's priorities.
  9625. var ImmediatePriority = 99;
  9626. var UserBlockingPriority$1 = 98;
  9627. var NormalPriority = 97;
  9628. var LowPriority = 96;
  9629. var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only.
  9630. var NoPriority = 90;
  9631. var shouldYield = Scheduler_shouldYield;
  9632. var requestPaint = // Fall back gracefully if we're running an older version of Scheduler.
  9633. Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {};
  9634. var syncQueue = null;
  9635. var immediateQueueCallbackNode = null;
  9636. var isFlushingSyncQueue = false;
  9637. var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
  9638. // This will be the case for modern browsers that support `performance.now`. In
  9639. // older browsers, Scheduler falls back to `Date.now`, which returns a Unix
  9640. // timestamp. In that case, subtract the module initialization time to simulate
  9641. // the behavior of performance.now and keep our times small enough to fit
  9642. // within 32 bits.
  9643. // TODO: Consider lifting this into Scheduler.
  9644. var now = initialTimeMs < 10000 ? Scheduler_now : function () {
  9645. return Scheduler_now() - initialTimeMs;
  9646. };
  9647. function getCurrentPriorityLevel() {
  9648. switch (Scheduler_getCurrentPriorityLevel()) {
  9649. case Scheduler_ImmediatePriority:
  9650. return ImmediatePriority;
  9651. case Scheduler_UserBlockingPriority:
  9652. return UserBlockingPriority$1;
  9653. case Scheduler_NormalPriority:
  9654. return NormalPriority;
  9655. case Scheduler_LowPriority:
  9656. return LowPriority;
  9657. case Scheduler_IdlePriority:
  9658. return IdlePriority;
  9659. default:
  9660. {
  9661. {
  9662. throw Error( "Unknown priority level." );
  9663. }
  9664. }
  9665. }
  9666. }
  9667. function reactPriorityToSchedulerPriority(reactPriorityLevel) {
  9668. switch (reactPriorityLevel) {
  9669. case ImmediatePriority:
  9670. return Scheduler_ImmediatePriority;
  9671. case UserBlockingPriority$1:
  9672. return Scheduler_UserBlockingPriority;
  9673. case NormalPriority:
  9674. return Scheduler_NormalPriority;
  9675. case LowPriority:
  9676. return Scheduler_LowPriority;
  9677. case IdlePriority:
  9678. return Scheduler_IdlePriority;
  9679. default:
  9680. {
  9681. {
  9682. throw Error( "Unknown priority level." );
  9683. }
  9684. }
  9685. }
  9686. }
  9687. function runWithPriority$1(reactPriorityLevel, fn) {
  9688. var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
  9689. return Scheduler_runWithPriority(priorityLevel, fn);
  9690. }
  9691. function scheduleCallback(reactPriorityLevel, callback, options) {
  9692. var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
  9693. return Scheduler_scheduleCallback(priorityLevel, callback, options);
  9694. }
  9695. function scheduleSyncCallback(callback) {
  9696. // Push this callback into an internal queue. We'll flush these either in
  9697. // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
  9698. if (syncQueue === null) {
  9699. syncQueue = [callback]; // Flush the queue in the next tick, at the earliest.
  9700. immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl);
  9701. } else {
  9702. // Push onto existing queue. Don't need to schedule a callback because
  9703. // we already scheduled one when we created the queue.
  9704. syncQueue.push(callback);
  9705. }
  9706. return fakeCallbackNode;
  9707. }
  9708. function cancelCallback(callbackNode) {
  9709. if (callbackNode !== fakeCallbackNode) {
  9710. Scheduler_cancelCallback(callbackNode);
  9711. }
  9712. }
  9713. function flushSyncCallbackQueue() {
  9714. if (immediateQueueCallbackNode !== null) {
  9715. var node = immediateQueueCallbackNode;
  9716. immediateQueueCallbackNode = null;
  9717. Scheduler_cancelCallback(node);
  9718. }
  9719. flushSyncCallbackQueueImpl();
  9720. }
  9721. function flushSyncCallbackQueueImpl() {
  9722. if (!isFlushingSyncQueue && syncQueue !== null) {
  9723. // Prevent re-entrancy.
  9724. isFlushingSyncQueue = true;
  9725. var i = 0;
  9726. try {
  9727. var _isSync = true;
  9728. var queue = syncQueue;
  9729. runWithPriority$1(ImmediatePriority, function () {
  9730. for (; i < queue.length; i++) {
  9731. var callback = queue[i];
  9732. do {
  9733. callback = callback(_isSync);
  9734. } while (callback !== null);
  9735. }
  9736. });
  9737. syncQueue = null;
  9738. } catch (error) {
  9739. // If something throws, leave the remaining callbacks on the queue.
  9740. if (syncQueue !== null) {
  9741. syncQueue = syncQueue.slice(i + 1);
  9742. } // Resume flushing in the next tick
  9743. Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue);
  9744. throw error;
  9745. } finally {
  9746. isFlushingSyncQueue = false;
  9747. }
  9748. }
  9749. }
  9750. var NoMode = 0;
  9751. var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root
  9752. // tag instead
  9753. var BlockingMode = 2;
  9754. var ConcurrentMode = 4;
  9755. var ProfileMode = 8;
  9756. // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
  9757. // Math.pow(2, 30) - 1
  9758. // 0b111111111111111111111111111111
  9759. var MAX_SIGNED_31_BIT_INT = 1073741823;
  9760. var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that
  9761. // Never work can be committed in an inconsistent state without tearing the UI.
  9762. // The main example is offscreen content, like a hidden subtree. So one possible
  9763. // name is Offscreen. However, it also includes dehydrated Suspense boundaries,
  9764. // which are inconsistent in the sense that they haven't finished yet, but
  9765. // aren't visibly inconsistent because the server rendered HTML matches what the
  9766. // hydrated tree would look like.
  9767. var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in
  9768. // order to be consistent.
  9769. var Idle = 2; // Continuous Hydration is slightly higher than Idle and is used to increase
  9770. // priority of hover targets.
  9771. var ContinuousHydration = 3;
  9772. var Sync = MAX_SIGNED_31_BIT_INT;
  9773. var Batched = Sync - 1;
  9774. var UNIT_SIZE = 10;
  9775. var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms.
  9776. function msToExpirationTime(ms) {
  9777. // Always subtract from the offset so that we don't clash with the magic number for NoWork.
  9778. return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
  9779. }
  9780. function expirationTimeToMs(expirationTime) {
  9781. return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
  9782. }
  9783. function ceiling(num, precision) {
  9784. return ((num / precision | 0) + 1) * precision;
  9785. }
  9786. function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
  9787. return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
  9788. } // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update
  9789. // the names to reflect.
  9790. var LOW_PRIORITY_EXPIRATION = 5000;
  9791. var LOW_PRIORITY_BATCH_SIZE = 250;
  9792. function computeAsyncExpiration(currentTime) {
  9793. return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
  9794. }
  9795. function computeSuspenseExpiration(currentTime, timeoutMs) {
  9796. // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time?
  9797. return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE);
  9798. } // We intentionally set a higher expiration time for interactive updates in
  9799. // dev than in production.
  9800. //
  9801. // If the main thread is being blocked so long that you hit the expiration,
  9802. // it's a problem that could be solved with better scheduling.
  9803. //
  9804. // People will be more likely to notice this and fix it with the long
  9805. // expiration time in development.
  9806. //
  9807. // In production we opt for better UX at the risk of masking scheduling
  9808. // problems, by expiring fast.
  9809. var HIGH_PRIORITY_EXPIRATION = 500 ;
  9810. var HIGH_PRIORITY_BATCH_SIZE = 100;
  9811. function computeInteractiveExpiration(currentTime) {
  9812. return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
  9813. }
  9814. function inferPriorityFromExpirationTime(currentTime, expirationTime) {
  9815. if (expirationTime === Sync) {
  9816. return ImmediatePriority;
  9817. }
  9818. if (expirationTime === Never || expirationTime === Idle) {
  9819. return IdlePriority;
  9820. }
  9821. var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime);
  9822. if (msUntil <= 0) {
  9823. return ImmediatePriority;
  9824. }
  9825. if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) {
  9826. return UserBlockingPriority$1;
  9827. }
  9828. if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) {
  9829. return NormalPriority;
  9830. } // TODO: Handle LowPriority
  9831. // Assume anything lower has idle priority
  9832. return IdlePriority;
  9833. }
  9834. var ReactStrictModeWarnings = {
  9835. recordUnsafeLifecycleWarnings: function (fiber, instance) {},
  9836. flushPendingUnsafeLifecycleWarnings: function () {},
  9837. recordLegacyContextWarning: function (fiber, instance) {},
  9838. flushLegacyContextWarning: function () {},
  9839. discardPendingWarnings: function () {}
  9840. };
  9841. {
  9842. var findStrictRoot = function (fiber) {
  9843. var maybeStrictRoot = null;
  9844. var node = fiber;
  9845. while (node !== null) {
  9846. if (node.mode & StrictMode) {
  9847. maybeStrictRoot = node;
  9848. }
  9849. node = node.return;
  9850. }
  9851. return maybeStrictRoot;
  9852. };
  9853. var setToSortedString = function (set) {
  9854. var array = [];
  9855. set.forEach(function (value) {
  9856. array.push(value);
  9857. });
  9858. return array.sort().join(', ');
  9859. };
  9860. var pendingComponentWillMountWarnings = [];
  9861. var pendingUNSAFE_ComponentWillMountWarnings = [];
  9862. var pendingComponentWillReceivePropsWarnings = [];
  9863. var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  9864. var pendingComponentWillUpdateWarnings = [];
  9865. var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about.
  9866. var didWarnAboutUnsafeLifecycles = new Set();
  9867. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
  9868. // Dedup strategy: Warn once per component.
  9869. if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
  9870. return;
  9871. }
  9872. if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components.
  9873. instance.componentWillMount.__suppressDeprecationWarning !== true) {
  9874. pendingComponentWillMountWarnings.push(fiber);
  9875. }
  9876. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') {
  9877. pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
  9878. }
  9879. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  9880. pendingComponentWillReceivePropsWarnings.push(fiber);
  9881. }
  9882. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  9883. pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
  9884. }
  9885. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  9886. pendingComponentWillUpdateWarnings.push(fiber);
  9887. }
  9888. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') {
  9889. pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
  9890. }
  9891. };
  9892. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
  9893. // We do an initial pass to gather component names
  9894. var componentWillMountUniqueNames = new Set();
  9895. if (pendingComponentWillMountWarnings.length > 0) {
  9896. pendingComponentWillMountWarnings.forEach(function (fiber) {
  9897. componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9898. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9899. });
  9900. pendingComponentWillMountWarnings = [];
  9901. }
  9902. var UNSAFE_componentWillMountUniqueNames = new Set();
  9903. if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
  9904. pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) {
  9905. UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9906. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9907. });
  9908. pendingUNSAFE_ComponentWillMountWarnings = [];
  9909. }
  9910. var componentWillReceivePropsUniqueNames = new Set();
  9911. if (pendingComponentWillReceivePropsWarnings.length > 0) {
  9912. pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
  9913. componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9914. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9915. });
  9916. pendingComponentWillReceivePropsWarnings = [];
  9917. }
  9918. var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
  9919. if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
  9920. pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) {
  9921. UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9922. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9923. });
  9924. pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  9925. }
  9926. var componentWillUpdateUniqueNames = new Set();
  9927. if (pendingComponentWillUpdateWarnings.length > 0) {
  9928. pendingComponentWillUpdateWarnings.forEach(function (fiber) {
  9929. componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9930. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9931. });
  9932. pendingComponentWillUpdateWarnings = [];
  9933. }
  9934. var UNSAFE_componentWillUpdateUniqueNames = new Set();
  9935. if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
  9936. pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) {
  9937. UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9938. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9939. });
  9940. pendingUNSAFE_ComponentWillUpdateWarnings = [];
  9941. } // Finally, we flush all the warnings
  9942. // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
  9943. if (UNSAFE_componentWillMountUniqueNames.size > 0) {
  9944. var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
  9945. error('Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames);
  9946. }
  9947. if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
  9948. var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
  9949. error('Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '\nPlease update the following components: %s', _sortedNames);
  9950. }
  9951. if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
  9952. var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
  9953. error('Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2);
  9954. }
  9955. if (componentWillMountUniqueNames.size > 0) {
  9956. var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
  9957. warn('componentWillMount has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames3);
  9958. }
  9959. if (componentWillReceivePropsUniqueNames.size > 0) {
  9960. var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
  9961. warn('componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames4);
  9962. }
  9963. if (componentWillUpdateUniqueNames.size > 0) {
  9964. var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
  9965. warn('componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames5);
  9966. }
  9967. };
  9968. var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about.
  9969. var didWarnAboutLegacyContext = new Set();
  9970. ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
  9971. var strictRoot = findStrictRoot(fiber);
  9972. if (strictRoot === null) {
  9973. error('Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.');
  9974. return;
  9975. } // Dedup strategy: Warn once per component.
  9976. if (didWarnAboutLegacyContext.has(fiber.type)) {
  9977. return;
  9978. }
  9979. var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
  9980. if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
  9981. if (warningsForRoot === undefined) {
  9982. warningsForRoot = [];
  9983. pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
  9984. }
  9985. warningsForRoot.push(fiber);
  9986. }
  9987. };
  9988. ReactStrictModeWarnings.flushLegacyContextWarning = function () {
  9989. pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
  9990. if (fiberArray.length === 0) {
  9991. return;
  9992. }
  9993. var firstFiber = fiberArray[0];
  9994. var uniqueNames = new Set();
  9995. fiberArray.forEach(function (fiber) {
  9996. uniqueNames.add(getComponentName(fiber.type) || 'Component');
  9997. didWarnAboutLegacyContext.add(fiber.type);
  9998. });
  9999. var sortedNames = setToSortedString(uniqueNames);
  10000. var firstComponentStack = getStackByFiberInDevAndProd(firstFiber);
  10001. error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://fb.me/react-legacy-context' + '%s', sortedNames, firstComponentStack);
  10002. });
  10003. };
  10004. ReactStrictModeWarnings.discardPendingWarnings = function () {
  10005. pendingComponentWillMountWarnings = [];
  10006. pendingUNSAFE_ComponentWillMountWarnings = [];
  10007. pendingComponentWillReceivePropsWarnings = [];
  10008. pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  10009. pendingComponentWillUpdateWarnings = [];
  10010. pendingUNSAFE_ComponentWillUpdateWarnings = [];
  10011. pendingLegacyContextWarning = new Map();
  10012. };
  10013. }
  10014. var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
  10015. var failedBoundaries = null;
  10016. var setRefreshHandler = function (handler) {
  10017. {
  10018. resolveFamily = handler;
  10019. }
  10020. };
  10021. function resolveFunctionForHotReloading(type) {
  10022. {
  10023. if (resolveFamily === null) {
  10024. // Hot reloading is disabled.
  10025. return type;
  10026. }
  10027. var family = resolveFamily(type);
  10028. if (family === undefined) {
  10029. return type;
  10030. } // Use the latest known implementation.
  10031. return family.current;
  10032. }
  10033. }
  10034. function resolveClassForHotReloading(type) {
  10035. // No implementation differences.
  10036. return resolveFunctionForHotReloading(type);
  10037. }
  10038. function resolveForwardRefForHotReloading(type) {
  10039. {
  10040. if (resolveFamily === null) {
  10041. // Hot reloading is disabled.
  10042. return type;
  10043. }
  10044. var family = resolveFamily(type);
  10045. if (family === undefined) {
  10046. // Check if we're dealing with a real forwardRef. Don't want to crash early.
  10047. if (type !== null && type !== undefined && typeof type.render === 'function') {
  10048. // ForwardRef is special because its resolved .type is an object,
  10049. // but it's possible that we only have its inner render function in the map.
  10050. // If that inner render function is different, we'll build a new forwardRef type.
  10051. var currentRender = resolveFunctionForHotReloading(type.render);
  10052. if (type.render !== currentRender) {
  10053. var syntheticType = {
  10054. $$typeof: REACT_FORWARD_REF_TYPE,
  10055. render: currentRender
  10056. };
  10057. if (type.displayName !== undefined) {
  10058. syntheticType.displayName = type.displayName;
  10059. }
  10060. return syntheticType;
  10061. }
  10062. }
  10063. return type;
  10064. } // Use the latest known implementation.
  10065. return family.current;
  10066. }
  10067. }
  10068. function isCompatibleFamilyForHotReloading(fiber, element) {
  10069. {
  10070. if (resolveFamily === null) {
  10071. // Hot reloading is disabled.
  10072. return false;
  10073. }
  10074. var prevType = fiber.elementType;
  10075. var nextType = element.type; // If we got here, we know types aren't === equal.
  10076. var needsCompareFamilies = false;
  10077. var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null;
  10078. switch (fiber.tag) {
  10079. case ClassComponent:
  10080. {
  10081. if (typeof nextType === 'function') {
  10082. needsCompareFamilies = true;
  10083. }
  10084. break;
  10085. }
  10086. case FunctionComponent:
  10087. {
  10088. if (typeof nextType === 'function') {
  10089. needsCompareFamilies = true;
  10090. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  10091. // We don't know the inner type yet.
  10092. // We're going to assume that the lazy inner type is stable,
  10093. // and so it is sufficient to avoid reconciling it away.
  10094. // We're not going to unwrap or actually use the new lazy type.
  10095. needsCompareFamilies = true;
  10096. }
  10097. break;
  10098. }
  10099. case ForwardRef:
  10100. {
  10101. if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
  10102. needsCompareFamilies = true;
  10103. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  10104. needsCompareFamilies = true;
  10105. }
  10106. break;
  10107. }
  10108. case MemoComponent:
  10109. case SimpleMemoComponent:
  10110. {
  10111. if ($$typeofNextType === REACT_MEMO_TYPE) {
  10112. // TODO: if it was but can no longer be simple,
  10113. // we shouldn't set this.
  10114. needsCompareFamilies = true;
  10115. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  10116. needsCompareFamilies = true;
  10117. }
  10118. break;
  10119. }
  10120. default:
  10121. return false;
  10122. } // Check if both types have a family and it's the same one.
  10123. if (needsCompareFamilies) {
  10124. // Note: memo() and forwardRef() we'll compare outer rather than inner type.
  10125. // This means both of them need to be registered to preserve state.
  10126. // If we unwrapped and compared the inner types for wrappers instead,
  10127. // then we would risk falsely saying two separate memo(Foo)
  10128. // calls are equivalent because they wrap the same Foo function.
  10129. var prevFamily = resolveFamily(prevType);
  10130. if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
  10131. return true;
  10132. }
  10133. }
  10134. return false;
  10135. }
  10136. }
  10137. function markFailedErrorBoundaryForHotReloading(fiber) {
  10138. {
  10139. if (resolveFamily === null) {
  10140. // Hot reloading is disabled.
  10141. return;
  10142. }
  10143. if (typeof WeakSet !== 'function') {
  10144. return;
  10145. }
  10146. if (failedBoundaries === null) {
  10147. failedBoundaries = new WeakSet();
  10148. }
  10149. failedBoundaries.add(fiber);
  10150. }
  10151. }
  10152. var scheduleRefresh = function (root, update) {
  10153. {
  10154. if (resolveFamily === null) {
  10155. // Hot reloading is disabled.
  10156. return;
  10157. }
  10158. var staleFamilies = update.staleFamilies,
  10159. updatedFamilies = update.updatedFamilies;
  10160. flushPassiveEffects();
  10161. flushSync(function () {
  10162. scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies);
  10163. });
  10164. }
  10165. };
  10166. var scheduleRoot = function (root, element) {
  10167. {
  10168. if (root.context !== emptyContextObject) {
  10169. // Super edge case: root has a legacy _renderSubtree context
  10170. // but we don't know the parentComponent so we can't pass it.
  10171. // Just ignore. We'll delete this with _renderSubtree code path later.
  10172. return;
  10173. }
  10174. flushPassiveEffects();
  10175. syncUpdates(function () {
  10176. updateContainer(element, root, null, null);
  10177. });
  10178. }
  10179. };
  10180. function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
  10181. {
  10182. var alternate = fiber.alternate,
  10183. child = fiber.child,
  10184. sibling = fiber.sibling,
  10185. tag = fiber.tag,
  10186. type = fiber.type;
  10187. var candidateType = null;
  10188. switch (tag) {
  10189. case FunctionComponent:
  10190. case SimpleMemoComponent:
  10191. case ClassComponent:
  10192. candidateType = type;
  10193. break;
  10194. case ForwardRef:
  10195. candidateType = type.render;
  10196. break;
  10197. }
  10198. if (resolveFamily === null) {
  10199. throw new Error('Expected resolveFamily to be set during hot reload.');
  10200. }
  10201. var needsRender = false;
  10202. var needsRemount = false;
  10203. if (candidateType !== null) {
  10204. var family = resolveFamily(candidateType);
  10205. if (family !== undefined) {
  10206. if (staleFamilies.has(family)) {
  10207. needsRemount = true;
  10208. } else if (updatedFamilies.has(family)) {
  10209. if (tag === ClassComponent) {
  10210. needsRemount = true;
  10211. } else {
  10212. needsRender = true;
  10213. }
  10214. }
  10215. }
  10216. }
  10217. if (failedBoundaries !== null) {
  10218. if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
  10219. needsRemount = true;
  10220. }
  10221. }
  10222. if (needsRemount) {
  10223. fiber._debugNeedsRemount = true;
  10224. }
  10225. if (needsRemount || needsRender) {
  10226. scheduleWork(fiber, Sync);
  10227. }
  10228. if (child !== null && !needsRemount) {
  10229. scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
  10230. }
  10231. if (sibling !== null) {
  10232. scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
  10233. }
  10234. }
  10235. }
  10236. var findHostInstancesForRefresh = function (root, families) {
  10237. {
  10238. var hostInstances = new Set();
  10239. var types = new Set(families.map(function (family) {
  10240. return family.current;
  10241. }));
  10242. findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances);
  10243. return hostInstances;
  10244. }
  10245. };
  10246. function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
  10247. {
  10248. var child = fiber.child,
  10249. sibling = fiber.sibling,
  10250. tag = fiber.tag,
  10251. type = fiber.type;
  10252. var candidateType = null;
  10253. switch (tag) {
  10254. case FunctionComponent:
  10255. case SimpleMemoComponent:
  10256. case ClassComponent:
  10257. candidateType = type;
  10258. break;
  10259. case ForwardRef:
  10260. candidateType = type.render;
  10261. break;
  10262. }
  10263. var didMatch = false;
  10264. if (candidateType !== null) {
  10265. if (types.has(candidateType)) {
  10266. didMatch = true;
  10267. }
  10268. }
  10269. if (didMatch) {
  10270. // We have a match. This only drills down to the closest host components.
  10271. // There's no need to search deeper because for the purpose of giving
  10272. // visual feedback, "flashing" outermost parent rectangles is sufficient.
  10273. findHostInstancesForFiberShallowly(fiber, hostInstances);
  10274. } else {
  10275. // If there's no match, maybe there will be one further down in the child tree.
  10276. if (child !== null) {
  10277. findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
  10278. }
  10279. }
  10280. if (sibling !== null) {
  10281. findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
  10282. }
  10283. }
  10284. }
  10285. function findHostInstancesForFiberShallowly(fiber, hostInstances) {
  10286. {
  10287. var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
  10288. if (foundHostInstances) {
  10289. return;
  10290. } // If we didn't find any host children, fallback to closest host parent.
  10291. var node = fiber;
  10292. while (true) {
  10293. switch (node.tag) {
  10294. case HostComponent:
  10295. hostInstances.add(node.stateNode);
  10296. return;
  10297. case HostPortal:
  10298. hostInstances.add(node.stateNode.containerInfo);
  10299. return;
  10300. case HostRoot:
  10301. hostInstances.add(node.stateNode.containerInfo);
  10302. return;
  10303. }
  10304. if (node.return === null) {
  10305. throw new Error('Expected to reach root first.');
  10306. }
  10307. node = node.return;
  10308. }
  10309. }
  10310. }
  10311. function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
  10312. {
  10313. var node = fiber;
  10314. var foundHostInstances = false;
  10315. while (true) {
  10316. if (node.tag === HostComponent) {
  10317. // We got a match.
  10318. foundHostInstances = true;
  10319. hostInstances.add(node.stateNode); // There may still be more, so keep searching.
  10320. } else if (node.child !== null) {
  10321. node.child.return = node;
  10322. node = node.child;
  10323. continue;
  10324. }
  10325. if (node === fiber) {
  10326. return foundHostInstances;
  10327. }
  10328. while (node.sibling === null) {
  10329. if (node.return === null || node.return === fiber) {
  10330. return foundHostInstances;
  10331. }
  10332. node = node.return;
  10333. }
  10334. node.sibling.return = node.return;
  10335. node = node.sibling;
  10336. }
  10337. }
  10338. return false;
  10339. }
  10340. function resolveDefaultProps(Component, baseProps) {
  10341. if (Component && Component.defaultProps) {
  10342. // Resolve default props. Taken from ReactElement
  10343. var props = _assign({}, baseProps);
  10344. var defaultProps = Component.defaultProps;
  10345. for (var propName in defaultProps) {
  10346. if (props[propName] === undefined) {
  10347. props[propName] = defaultProps[propName];
  10348. }
  10349. }
  10350. return props;
  10351. }
  10352. return baseProps;
  10353. }
  10354. function readLazyComponentType(lazyComponent) {
  10355. initializeLazyComponentType(lazyComponent);
  10356. if (lazyComponent._status !== Resolved) {
  10357. throw lazyComponent._result;
  10358. }
  10359. return lazyComponent._result;
  10360. }
  10361. var valueCursor = createCursor(null);
  10362. var rendererSigil;
  10363. {
  10364. // Use this to detect multiple renderers using the same context
  10365. rendererSigil = {};
  10366. }
  10367. var currentlyRenderingFiber = null;
  10368. var lastContextDependency = null;
  10369. var lastContextWithAllBitsObserved = null;
  10370. var isDisallowedContextReadInDEV = false;
  10371. function resetContextDependencies() {
  10372. // This is called right before React yields execution, to ensure `readContext`
  10373. // cannot be called outside the render phase.
  10374. currentlyRenderingFiber = null;
  10375. lastContextDependency = null;
  10376. lastContextWithAllBitsObserved = null;
  10377. {
  10378. isDisallowedContextReadInDEV = false;
  10379. }
  10380. }
  10381. function enterDisallowedContextReadInDEV() {
  10382. {
  10383. isDisallowedContextReadInDEV = true;
  10384. }
  10385. }
  10386. function exitDisallowedContextReadInDEV() {
  10387. {
  10388. isDisallowedContextReadInDEV = false;
  10389. }
  10390. }
  10391. function pushProvider(providerFiber, nextValue) {
  10392. var context = providerFiber.type._context;
  10393. {
  10394. push(valueCursor, context._currentValue, providerFiber);
  10395. context._currentValue = nextValue;
  10396. {
  10397. if (context._currentRenderer !== undefined && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) {
  10398. error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
  10399. }
  10400. context._currentRenderer = rendererSigil;
  10401. }
  10402. }
  10403. }
  10404. function popProvider(providerFiber) {
  10405. var currentValue = valueCursor.current;
  10406. pop(valueCursor, providerFiber);
  10407. var context = providerFiber.type._context;
  10408. {
  10409. context._currentValue = currentValue;
  10410. }
  10411. }
  10412. function calculateChangedBits(context, newValue, oldValue) {
  10413. if (objectIs(oldValue, newValue)) {
  10414. // No change
  10415. return 0;
  10416. } else {
  10417. var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
  10418. {
  10419. if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) {
  10420. error('calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits);
  10421. }
  10422. }
  10423. return changedBits | 0;
  10424. }
  10425. }
  10426. function scheduleWorkOnParentPath(parent, renderExpirationTime) {
  10427. // Update the child expiration time of all the ancestors, including
  10428. // the alternates.
  10429. var node = parent;
  10430. while (node !== null) {
  10431. var alternate = node.alternate;
  10432. if (node.childExpirationTime < renderExpirationTime) {
  10433. node.childExpirationTime = renderExpirationTime;
  10434. if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
  10435. alternate.childExpirationTime = renderExpirationTime;
  10436. }
  10437. } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
  10438. alternate.childExpirationTime = renderExpirationTime;
  10439. } else {
  10440. // Neither alternate was updated, which means the rest of the
  10441. // ancestor path already has sufficient priority.
  10442. break;
  10443. }
  10444. node = node.return;
  10445. }
  10446. }
  10447. function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
  10448. var fiber = workInProgress.child;
  10449. if (fiber !== null) {
  10450. // Set the return pointer of the child to the work-in-progress fiber.
  10451. fiber.return = workInProgress;
  10452. }
  10453. while (fiber !== null) {
  10454. var nextFiber = void 0; // Visit this fiber.
  10455. var list = fiber.dependencies;
  10456. if (list !== null) {
  10457. nextFiber = fiber.child;
  10458. var dependency = list.firstContext;
  10459. while (dependency !== null) {
  10460. // Check if the context matches.
  10461. if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
  10462. // Match! Schedule an update on this fiber.
  10463. if (fiber.tag === ClassComponent) {
  10464. // Schedule a force update on the work-in-progress.
  10465. var update = createUpdate(renderExpirationTime, null);
  10466. update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the
  10467. // update to the current fiber, too, which means it will persist even if
  10468. // this render is thrown away. Since it's a race condition, not sure it's
  10469. // worth fixing.
  10470. enqueueUpdate(fiber, update);
  10471. }
  10472. if (fiber.expirationTime < renderExpirationTime) {
  10473. fiber.expirationTime = renderExpirationTime;
  10474. }
  10475. var alternate = fiber.alternate;
  10476. if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
  10477. alternate.expirationTime = renderExpirationTime;
  10478. }
  10479. scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too.
  10480. if (list.expirationTime < renderExpirationTime) {
  10481. list.expirationTime = renderExpirationTime;
  10482. } // Since we already found a match, we can stop traversing the
  10483. // dependency list.
  10484. break;
  10485. }
  10486. dependency = dependency.next;
  10487. }
  10488. } else if (fiber.tag === ContextProvider) {
  10489. // Don't scan deeper if this is a matching provider
  10490. nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
  10491. } else {
  10492. // Traverse down.
  10493. nextFiber = fiber.child;
  10494. }
  10495. if (nextFiber !== null) {
  10496. // Set the return pointer of the child to the work-in-progress fiber.
  10497. nextFiber.return = fiber;
  10498. } else {
  10499. // No child. Traverse to next sibling.
  10500. nextFiber = fiber;
  10501. while (nextFiber !== null) {
  10502. if (nextFiber === workInProgress) {
  10503. // We're back to the root of this subtree. Exit.
  10504. nextFiber = null;
  10505. break;
  10506. }
  10507. var sibling = nextFiber.sibling;
  10508. if (sibling !== null) {
  10509. // Set the return pointer of the sibling to the work-in-progress fiber.
  10510. sibling.return = nextFiber.return;
  10511. nextFiber = sibling;
  10512. break;
  10513. } // No more siblings. Traverse up.
  10514. nextFiber = nextFiber.return;
  10515. }
  10516. }
  10517. fiber = nextFiber;
  10518. }
  10519. }
  10520. function prepareToReadContext(workInProgress, renderExpirationTime) {
  10521. currentlyRenderingFiber = workInProgress;
  10522. lastContextDependency = null;
  10523. lastContextWithAllBitsObserved = null;
  10524. var dependencies = workInProgress.dependencies;
  10525. if (dependencies !== null) {
  10526. var firstContext = dependencies.firstContext;
  10527. if (firstContext !== null) {
  10528. if (dependencies.expirationTime >= renderExpirationTime) {
  10529. // Context list has a pending update. Mark that this fiber performed work.
  10530. markWorkInProgressReceivedUpdate();
  10531. } // Reset the work-in-progress list
  10532. dependencies.firstContext = null;
  10533. }
  10534. }
  10535. }
  10536. function readContext(context, observedBits) {
  10537. {
  10538. // This warning would fire if you read context inside a Hook like useMemo.
  10539. // Unlike the class check below, it's not enforced in production for perf.
  10540. if (isDisallowedContextReadInDEV) {
  10541. error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
  10542. }
  10543. }
  10544. if (lastContextWithAllBitsObserved === context) ; else if (observedBits === false || observedBits === 0) ; else {
  10545. var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types.
  10546. if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) {
  10547. // Observe all updates.
  10548. lastContextWithAllBitsObserved = context;
  10549. resolvedObservedBits = MAX_SIGNED_31_BIT_INT;
  10550. } else {
  10551. resolvedObservedBits = observedBits;
  10552. }
  10553. var contextItem = {
  10554. context: context,
  10555. observedBits: resolvedObservedBits,
  10556. next: null
  10557. };
  10558. if (lastContextDependency === null) {
  10559. if (!(currentlyRenderingFiber !== null)) {
  10560. {
  10561. throw Error( "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." );
  10562. }
  10563. } // This is the first dependency for this component. Create a new list.
  10564. lastContextDependency = contextItem;
  10565. currentlyRenderingFiber.dependencies = {
  10566. expirationTime: NoWork,
  10567. firstContext: contextItem,
  10568. responders: null
  10569. };
  10570. } else {
  10571. // Append a new context item.
  10572. lastContextDependency = lastContextDependency.next = contextItem;
  10573. }
  10574. }
  10575. return context._currentValue ;
  10576. }
  10577. var UpdateState = 0;
  10578. var ReplaceState = 1;
  10579. var ForceUpdate = 2;
  10580. var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`.
  10581. // It should only be read right after calling `processUpdateQueue`, via
  10582. // `checkHasForceUpdateAfterProcessing`.
  10583. var hasForceUpdate = false;
  10584. var didWarnUpdateInsideUpdate;
  10585. var currentlyProcessingQueue;
  10586. {
  10587. didWarnUpdateInsideUpdate = false;
  10588. currentlyProcessingQueue = null;
  10589. }
  10590. function initializeUpdateQueue(fiber) {
  10591. var queue = {
  10592. baseState: fiber.memoizedState,
  10593. baseQueue: null,
  10594. shared: {
  10595. pending: null
  10596. },
  10597. effects: null
  10598. };
  10599. fiber.updateQueue = queue;
  10600. }
  10601. function cloneUpdateQueue(current, workInProgress) {
  10602. // Clone the update queue from current. Unless it's already a clone.
  10603. var queue = workInProgress.updateQueue;
  10604. var currentQueue = current.updateQueue;
  10605. if (queue === currentQueue) {
  10606. var clone = {
  10607. baseState: currentQueue.baseState,
  10608. baseQueue: currentQueue.baseQueue,
  10609. shared: currentQueue.shared,
  10610. effects: currentQueue.effects
  10611. };
  10612. workInProgress.updateQueue = clone;
  10613. }
  10614. }
  10615. function createUpdate(expirationTime, suspenseConfig) {
  10616. var update = {
  10617. expirationTime: expirationTime,
  10618. suspenseConfig: suspenseConfig,
  10619. tag: UpdateState,
  10620. payload: null,
  10621. callback: null,
  10622. next: null
  10623. };
  10624. update.next = update;
  10625. {
  10626. update.priority = getCurrentPriorityLevel();
  10627. }
  10628. return update;
  10629. }
  10630. function enqueueUpdate(fiber, update) {
  10631. var updateQueue = fiber.updateQueue;
  10632. if (updateQueue === null) {
  10633. // Only occurs if the fiber has been unmounted.
  10634. return;
  10635. }
  10636. var sharedQueue = updateQueue.shared;
  10637. var pending = sharedQueue.pending;
  10638. if (pending === null) {
  10639. // This is the first update. Create a circular list.
  10640. update.next = update;
  10641. } else {
  10642. update.next = pending.next;
  10643. pending.next = update;
  10644. }
  10645. sharedQueue.pending = update;
  10646. {
  10647. if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) {
  10648. error('An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.');
  10649. didWarnUpdateInsideUpdate = true;
  10650. }
  10651. }
  10652. }
  10653. function enqueueCapturedUpdate(workInProgress, update) {
  10654. var current = workInProgress.alternate;
  10655. if (current !== null) {
  10656. // Ensure the work-in-progress queue is a clone
  10657. cloneUpdateQueue(current, workInProgress);
  10658. } // Captured updates go only on the work-in-progress queue.
  10659. var queue = workInProgress.updateQueue; // Append the update to the end of the list.
  10660. var last = queue.baseQueue;
  10661. if (last === null) {
  10662. queue.baseQueue = update.next = update;
  10663. update.next = update;
  10664. } else {
  10665. update.next = last.next;
  10666. last.next = update;
  10667. }
  10668. }
  10669. function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
  10670. switch (update.tag) {
  10671. case ReplaceState:
  10672. {
  10673. var payload = update.payload;
  10674. if (typeof payload === 'function') {
  10675. // Updater function
  10676. {
  10677. enterDisallowedContextReadInDEV();
  10678. if ( workInProgress.mode & StrictMode) {
  10679. payload.call(instance, prevState, nextProps);
  10680. }
  10681. }
  10682. var nextState = payload.call(instance, prevState, nextProps);
  10683. {
  10684. exitDisallowedContextReadInDEV();
  10685. }
  10686. return nextState;
  10687. } // State object
  10688. return payload;
  10689. }
  10690. case CaptureUpdate:
  10691. {
  10692. workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
  10693. }
  10694. // Intentional fallthrough
  10695. case UpdateState:
  10696. {
  10697. var _payload = update.payload;
  10698. var partialState;
  10699. if (typeof _payload === 'function') {
  10700. // Updater function
  10701. {
  10702. enterDisallowedContextReadInDEV();
  10703. if ( workInProgress.mode & StrictMode) {
  10704. _payload.call(instance, prevState, nextProps);
  10705. }
  10706. }
  10707. partialState = _payload.call(instance, prevState, nextProps);
  10708. {
  10709. exitDisallowedContextReadInDEV();
  10710. }
  10711. } else {
  10712. // Partial state object
  10713. partialState = _payload;
  10714. }
  10715. if (partialState === null || partialState === undefined) {
  10716. // Null and undefined are treated as no-ops.
  10717. return prevState;
  10718. } // Merge the partial state and the previous state.
  10719. return _assign({}, prevState, partialState);
  10720. }
  10721. case ForceUpdate:
  10722. {
  10723. hasForceUpdate = true;
  10724. return prevState;
  10725. }
  10726. }
  10727. return prevState;
  10728. }
  10729. function processUpdateQueue(workInProgress, props, instance, renderExpirationTime) {
  10730. // This is always non-null on a ClassComponent or HostRoot
  10731. var queue = workInProgress.updateQueue;
  10732. hasForceUpdate = false;
  10733. {
  10734. currentlyProcessingQueue = queue.shared;
  10735. } // The last rebase update that is NOT part of the base state.
  10736. var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet.
  10737. var pendingQueue = queue.shared.pending;
  10738. if (pendingQueue !== null) {
  10739. // We have new updates that haven't been processed yet.
  10740. // We'll add them to the base queue.
  10741. if (baseQueue !== null) {
  10742. // Merge the pending queue and the base queue.
  10743. var baseFirst = baseQueue.next;
  10744. var pendingFirst = pendingQueue.next;
  10745. baseQueue.next = pendingFirst;
  10746. pendingQueue.next = baseFirst;
  10747. }
  10748. baseQueue = pendingQueue;
  10749. queue.shared.pending = null; // TODO: Pass `current` as argument
  10750. var current = workInProgress.alternate;
  10751. if (current !== null) {
  10752. var currentQueue = current.updateQueue;
  10753. if (currentQueue !== null) {
  10754. currentQueue.baseQueue = pendingQueue;
  10755. }
  10756. }
  10757. } // These values may change as we process the queue.
  10758. if (baseQueue !== null) {
  10759. var first = baseQueue.next; // Iterate through the list of updates to compute the result.
  10760. var newState = queue.baseState;
  10761. var newExpirationTime = NoWork;
  10762. var newBaseState = null;
  10763. var newBaseQueueFirst = null;
  10764. var newBaseQueueLast = null;
  10765. if (first !== null) {
  10766. var update = first;
  10767. do {
  10768. var updateExpirationTime = update.expirationTime;
  10769. if (updateExpirationTime < renderExpirationTime) {
  10770. // Priority is insufficient. Skip this update. If this is the first
  10771. // skipped update, the previous update/state is the new base
  10772. // update/state.
  10773. var clone = {
  10774. expirationTime: update.expirationTime,
  10775. suspenseConfig: update.suspenseConfig,
  10776. tag: update.tag,
  10777. payload: update.payload,
  10778. callback: update.callback,
  10779. next: null
  10780. };
  10781. if (newBaseQueueLast === null) {
  10782. newBaseQueueFirst = newBaseQueueLast = clone;
  10783. newBaseState = newState;
  10784. } else {
  10785. newBaseQueueLast = newBaseQueueLast.next = clone;
  10786. } // Update the remaining priority in the queue.
  10787. if (updateExpirationTime > newExpirationTime) {
  10788. newExpirationTime = updateExpirationTime;
  10789. }
  10790. } else {
  10791. // This update does have sufficient priority.
  10792. if (newBaseQueueLast !== null) {
  10793. var _clone = {
  10794. expirationTime: Sync,
  10795. // This update is going to be committed so we never want uncommit it.
  10796. suspenseConfig: update.suspenseConfig,
  10797. tag: update.tag,
  10798. payload: update.payload,
  10799. callback: update.callback,
  10800. next: null
  10801. };
  10802. newBaseQueueLast = newBaseQueueLast.next = _clone;
  10803. } // Mark the event time of this update as relevant to this render pass.
  10804. // TODO: This should ideally use the true event time of this update rather than
  10805. // its priority which is a derived and not reverseable value.
  10806. // TODO: We should skip this update if it was already committed but currently
  10807. // we have no way of detecting the difference between a committed and suspended
  10808. // update here.
  10809. markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process this update.
  10810. newState = getStateFromUpdate(workInProgress, queue, update, newState, props, instance);
  10811. var callback = update.callback;
  10812. if (callback !== null) {
  10813. workInProgress.effectTag |= Callback;
  10814. var effects = queue.effects;
  10815. if (effects === null) {
  10816. queue.effects = [update];
  10817. } else {
  10818. effects.push(update);
  10819. }
  10820. }
  10821. }
  10822. update = update.next;
  10823. if (update === null || update === first) {
  10824. pendingQueue = queue.shared.pending;
  10825. if (pendingQueue === null) {
  10826. break;
  10827. } else {
  10828. // An update was scheduled from inside a reducer. Add the new
  10829. // pending updates to the end of the list and keep processing.
  10830. update = baseQueue.next = pendingQueue.next;
  10831. pendingQueue.next = first;
  10832. queue.baseQueue = baseQueue = pendingQueue;
  10833. queue.shared.pending = null;
  10834. }
  10835. }
  10836. } while (true);
  10837. }
  10838. if (newBaseQueueLast === null) {
  10839. newBaseState = newState;
  10840. } else {
  10841. newBaseQueueLast.next = newBaseQueueFirst;
  10842. }
  10843. queue.baseState = newBaseState;
  10844. queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue.
  10845. // This should be fine because the only two other things that contribute to
  10846. // expiration time are props and context. We're already in the middle of the
  10847. // begin phase by the time we start processing the queue, so we've already
  10848. // dealt with the props. Context in components that specify
  10849. // shouldComponentUpdate is tricky; but we'll have to account for
  10850. // that regardless.
  10851. markUnprocessedUpdateTime(newExpirationTime);
  10852. workInProgress.expirationTime = newExpirationTime;
  10853. workInProgress.memoizedState = newState;
  10854. }
  10855. {
  10856. currentlyProcessingQueue = null;
  10857. }
  10858. }
  10859. function callCallback(callback, context) {
  10860. if (!(typeof callback === 'function')) {
  10861. {
  10862. throw Error( "Invalid argument passed as callback. Expected a function. Instead received: " + callback );
  10863. }
  10864. }
  10865. callback.call(context);
  10866. }
  10867. function resetHasForceUpdateBeforeProcessing() {
  10868. hasForceUpdate = false;
  10869. }
  10870. function checkHasForceUpdateAfterProcessing() {
  10871. return hasForceUpdate;
  10872. }
  10873. function commitUpdateQueue(finishedWork, finishedQueue, instance) {
  10874. // Commit the effects
  10875. var effects = finishedQueue.effects;
  10876. finishedQueue.effects = null;
  10877. if (effects !== null) {
  10878. for (var i = 0; i < effects.length; i++) {
  10879. var effect = effects[i];
  10880. var callback = effect.callback;
  10881. if (callback !== null) {
  10882. effect.callback = null;
  10883. callCallback(callback, instance);
  10884. }
  10885. }
  10886. }
  10887. }
  10888. var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
  10889. function requestCurrentSuspenseConfig() {
  10890. return ReactCurrentBatchConfig.suspense;
  10891. }
  10892. var fakeInternalInstance = {};
  10893. var isArray = Array.isArray; // React.Component uses a shared frozen object by default.
  10894. // We'll use it to determine whether we need to initialize legacy refs.
  10895. var emptyRefsObject = new React.Component().refs;
  10896. var didWarnAboutStateAssignmentForComponent;
  10897. var didWarnAboutUninitializedState;
  10898. var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
  10899. var didWarnAboutLegacyLifecyclesAndDerivedState;
  10900. var didWarnAboutUndefinedDerivedState;
  10901. var warnOnUndefinedDerivedState;
  10902. var warnOnInvalidCallback;
  10903. var didWarnAboutDirectlyAssigningPropsToState;
  10904. var didWarnAboutContextTypeAndContextTypes;
  10905. var didWarnAboutInvalidateContextType;
  10906. {
  10907. didWarnAboutStateAssignmentForComponent = new Set();
  10908. didWarnAboutUninitializedState = new Set();
  10909. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
  10910. didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
  10911. didWarnAboutDirectlyAssigningPropsToState = new Set();
  10912. didWarnAboutUndefinedDerivedState = new Set();
  10913. didWarnAboutContextTypeAndContextTypes = new Set();
  10914. didWarnAboutInvalidateContextType = new Set();
  10915. var didWarnOnInvalidCallback = new Set();
  10916. warnOnInvalidCallback = function (callback, callerName) {
  10917. if (callback === null || typeof callback === 'function') {
  10918. return;
  10919. }
  10920. var key = callerName + "_" + callback;
  10921. if (!didWarnOnInvalidCallback.has(key)) {
  10922. didWarnOnInvalidCallback.add(key);
  10923. error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
  10924. }
  10925. };
  10926. warnOnUndefinedDerivedState = function (type, partialState) {
  10927. if (partialState === undefined) {
  10928. var componentName = getComponentName(type) || 'Component';
  10929. if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
  10930. didWarnAboutUndefinedDerivedState.add(componentName);
  10931. error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
  10932. }
  10933. }
  10934. }; // This is so gross but it's at least non-critical and can be removed if
  10935. // it causes problems. This is meant to give a nicer error message for
  10936. // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
  10937. // ...)) which otherwise throws a "_processChildContext is not a function"
  10938. // exception.
  10939. Object.defineProperty(fakeInternalInstance, '_processChildContext', {
  10940. enumerable: false,
  10941. value: function () {
  10942. {
  10943. {
  10944. throw Error( "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)." );
  10945. }
  10946. }
  10947. }
  10948. });
  10949. Object.freeze(fakeInternalInstance);
  10950. }
  10951. function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
  10952. var prevState = workInProgress.memoizedState;
  10953. {
  10954. if ( workInProgress.mode & StrictMode) {
  10955. // Invoke the function an extra time to help detect side-effects.
  10956. getDerivedStateFromProps(nextProps, prevState);
  10957. }
  10958. }
  10959. var partialState = getDerivedStateFromProps(nextProps, prevState);
  10960. {
  10961. warnOnUndefinedDerivedState(ctor, partialState);
  10962. } // Merge the partial state and the previous state.
  10963. var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
  10964. workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the
  10965. // base state.
  10966. if (workInProgress.expirationTime === NoWork) {
  10967. // Queue is always non-null for classes
  10968. var updateQueue = workInProgress.updateQueue;
  10969. updateQueue.baseState = memoizedState;
  10970. }
  10971. }
  10972. var classComponentUpdater = {
  10973. isMounted: isMounted,
  10974. enqueueSetState: function (inst, payload, callback) {
  10975. var fiber = get(inst);
  10976. var currentTime = requestCurrentTimeForUpdate();
  10977. var suspenseConfig = requestCurrentSuspenseConfig();
  10978. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  10979. var update = createUpdate(expirationTime, suspenseConfig);
  10980. update.payload = payload;
  10981. if (callback !== undefined && callback !== null) {
  10982. {
  10983. warnOnInvalidCallback(callback, 'setState');
  10984. }
  10985. update.callback = callback;
  10986. }
  10987. enqueueUpdate(fiber, update);
  10988. scheduleWork(fiber, expirationTime);
  10989. },
  10990. enqueueReplaceState: function (inst, payload, callback) {
  10991. var fiber = get(inst);
  10992. var currentTime = requestCurrentTimeForUpdate();
  10993. var suspenseConfig = requestCurrentSuspenseConfig();
  10994. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  10995. var update = createUpdate(expirationTime, suspenseConfig);
  10996. update.tag = ReplaceState;
  10997. update.payload = payload;
  10998. if (callback !== undefined && callback !== null) {
  10999. {
  11000. warnOnInvalidCallback(callback, 'replaceState');
  11001. }
  11002. update.callback = callback;
  11003. }
  11004. enqueueUpdate(fiber, update);
  11005. scheduleWork(fiber, expirationTime);
  11006. },
  11007. enqueueForceUpdate: function (inst, callback) {
  11008. var fiber = get(inst);
  11009. var currentTime = requestCurrentTimeForUpdate();
  11010. var suspenseConfig = requestCurrentSuspenseConfig();
  11011. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  11012. var update = createUpdate(expirationTime, suspenseConfig);
  11013. update.tag = ForceUpdate;
  11014. if (callback !== undefined && callback !== null) {
  11015. {
  11016. warnOnInvalidCallback(callback, 'forceUpdate');
  11017. }
  11018. update.callback = callback;
  11019. }
  11020. enqueueUpdate(fiber, update);
  11021. scheduleWork(fiber, expirationTime);
  11022. }
  11023. };
  11024. function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
  11025. var instance = workInProgress.stateNode;
  11026. if (typeof instance.shouldComponentUpdate === 'function') {
  11027. {
  11028. if ( workInProgress.mode & StrictMode) {
  11029. // Invoke the function an extra time to help detect side-effects.
  11030. instance.shouldComponentUpdate(newProps, newState, nextContext);
  11031. }
  11032. }
  11033. startPhaseTimer(workInProgress, 'shouldComponentUpdate');
  11034. var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
  11035. stopPhaseTimer();
  11036. {
  11037. if (shouldUpdate === undefined) {
  11038. error('%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component');
  11039. }
  11040. }
  11041. return shouldUpdate;
  11042. }
  11043. if (ctor.prototype && ctor.prototype.isPureReactComponent) {
  11044. return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
  11045. }
  11046. return true;
  11047. }
  11048. function checkClassInstance(workInProgress, ctor, newProps) {
  11049. var instance = workInProgress.stateNode;
  11050. {
  11051. var name = getComponentName(ctor) || 'Component';
  11052. var renderPresent = instance.render;
  11053. if (!renderPresent) {
  11054. if (ctor.prototype && typeof ctor.prototype.render === 'function') {
  11055. error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
  11056. } else {
  11057. error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
  11058. }
  11059. }
  11060. if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) {
  11061. error('getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name);
  11062. }
  11063. if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) {
  11064. error('getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name);
  11065. }
  11066. if (instance.propTypes) {
  11067. error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);
  11068. }
  11069. if (instance.contextType) {
  11070. error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name);
  11071. }
  11072. {
  11073. if (instance.contextTypes) {
  11074. error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);
  11075. }
  11076. if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
  11077. didWarnAboutContextTypeAndContextTypes.add(ctor);
  11078. error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
  11079. }
  11080. }
  11081. if (typeof instance.componentShouldUpdate === 'function') {
  11082. error('%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name);
  11083. }
  11084. if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
  11085. error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component');
  11086. }
  11087. if (typeof instance.componentDidUnmount === 'function') {
  11088. error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);
  11089. }
  11090. if (typeof instance.componentDidReceiveProps === 'function') {
  11091. error('%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name);
  11092. }
  11093. if (typeof instance.componentWillRecieveProps === 'function') {
  11094. error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);
  11095. }
  11096. if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') {
  11097. error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name);
  11098. }
  11099. var hasMutatedProps = instance.props !== newProps;
  11100. if (instance.props !== undefined && hasMutatedProps) {
  11101. error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);
  11102. }
  11103. if (instance.defaultProps) {
  11104. error('Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name);
  11105. }
  11106. if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
  11107. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
  11108. error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
  11109. }
  11110. if (typeof instance.getDerivedStateFromProps === 'function') {
  11111. error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
  11112. }
  11113. if (typeof instance.getDerivedStateFromError === 'function') {
  11114. error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
  11115. }
  11116. if (typeof ctor.getSnapshotBeforeUpdate === 'function') {
  11117. error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name);
  11118. }
  11119. var _state = instance.state;
  11120. if (_state && (typeof _state !== 'object' || isArray(_state))) {
  11121. error('%s.state: must be set to an object or null', name);
  11122. }
  11123. if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') {
  11124. error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name);
  11125. }
  11126. }
  11127. }
  11128. function adoptClassInstance(workInProgress, instance) {
  11129. instance.updater = classComponentUpdater;
  11130. workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates
  11131. set(instance, workInProgress);
  11132. {
  11133. instance._reactInternalInstance = fakeInternalInstance;
  11134. }
  11135. }
  11136. function constructClassInstance(workInProgress, ctor, props) {
  11137. var isLegacyContextConsumer = false;
  11138. var unmaskedContext = emptyContextObject;
  11139. var context = emptyContextObject;
  11140. var contextType = ctor.contextType;
  11141. {
  11142. if ('contextType' in ctor) {
  11143. var isValid = // Allow null for conditional declaration
  11144. contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
  11145. if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
  11146. didWarnAboutInvalidateContextType.add(ctor);
  11147. var addendum = '';
  11148. if (contextType === undefined) {
  11149. addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.';
  11150. } else if (typeof contextType !== 'object') {
  11151. addendum = ' However, it is set to a ' + typeof contextType + '.';
  11152. } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
  11153. addendum = ' Did you accidentally pass the Context.Provider instead?';
  11154. } else if (contextType._context !== undefined) {
  11155. // <Context.Consumer>
  11156. addendum = ' Did you accidentally pass the Context.Consumer instead?';
  11157. } else {
  11158. addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
  11159. }
  11160. error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
  11161. }
  11162. }
  11163. }
  11164. if (typeof contextType === 'object' && contextType !== null) {
  11165. context = readContext(contextType);
  11166. } else {
  11167. unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  11168. var contextTypes = ctor.contextTypes;
  11169. isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
  11170. context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
  11171. } // Instantiate twice to help detect side-effects.
  11172. {
  11173. if ( workInProgress.mode & StrictMode) {
  11174. new ctor(props, context); // eslint-disable-line no-new
  11175. }
  11176. }
  11177. var instance = new ctor(props, context);
  11178. var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
  11179. adoptClassInstance(workInProgress, instance);
  11180. {
  11181. if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
  11182. var componentName = getComponentName(ctor) || 'Component';
  11183. if (!didWarnAboutUninitializedState.has(componentName)) {
  11184. didWarnAboutUninitializedState.add(componentName);
  11185. error('`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName);
  11186. }
  11187. } // If new component APIs are defined, "unsafe" lifecycles won't be called.
  11188. // Warn about these lifecycles if they are present.
  11189. // Don't warn about react-lifecycles-compat polyfilled methods though.
  11190. if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
  11191. var foundWillMountName = null;
  11192. var foundWillReceivePropsName = null;
  11193. var foundWillUpdateName = null;
  11194. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
  11195. foundWillMountName = 'componentWillMount';
  11196. } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
  11197. foundWillMountName = 'UNSAFE_componentWillMount';
  11198. }
  11199. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  11200. foundWillReceivePropsName = 'componentWillReceiveProps';
  11201. } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  11202. foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
  11203. }
  11204. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  11205. foundWillUpdateName = 'componentWillUpdate';
  11206. } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  11207. foundWillUpdateName = 'UNSAFE_componentWillUpdate';
  11208. }
  11209. if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
  11210. var _componentName = getComponentName(ctor) || 'Component';
  11211. var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
  11212. if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
  11213. didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
  11214. error('Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : '');
  11215. }
  11216. }
  11217. }
  11218. } // Cache unmasked context so we can avoid recreating masked context unless necessary.
  11219. // ReactFiberContext usually updates this cache but can't for newly-created instances.
  11220. if (isLegacyContextConsumer) {
  11221. cacheContext(workInProgress, unmaskedContext, context);
  11222. }
  11223. return instance;
  11224. }
  11225. function callComponentWillMount(workInProgress, instance) {
  11226. startPhaseTimer(workInProgress, 'componentWillMount');
  11227. var oldState = instance.state;
  11228. if (typeof instance.componentWillMount === 'function') {
  11229. instance.componentWillMount();
  11230. }
  11231. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  11232. instance.UNSAFE_componentWillMount();
  11233. }
  11234. stopPhaseTimer();
  11235. if (oldState !== instance.state) {
  11236. {
  11237. error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component');
  11238. }
  11239. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  11240. }
  11241. }
  11242. function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
  11243. var oldState = instance.state;
  11244. startPhaseTimer(workInProgress, 'componentWillReceiveProps');
  11245. if (typeof instance.componentWillReceiveProps === 'function') {
  11246. instance.componentWillReceiveProps(newProps, nextContext);
  11247. }
  11248. if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  11249. instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
  11250. }
  11251. stopPhaseTimer();
  11252. if (instance.state !== oldState) {
  11253. {
  11254. var componentName = getComponentName(workInProgress.type) || 'Component';
  11255. if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
  11256. didWarnAboutStateAssignmentForComponent.add(componentName);
  11257. error('%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
  11258. }
  11259. }
  11260. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  11261. }
  11262. } // Invokes the mount life-cycles on a previously never rendered instance.
  11263. function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
  11264. {
  11265. checkClassInstance(workInProgress, ctor, newProps);
  11266. }
  11267. var instance = workInProgress.stateNode;
  11268. instance.props = newProps;
  11269. instance.state = workInProgress.memoizedState;
  11270. instance.refs = emptyRefsObject;
  11271. initializeUpdateQueue(workInProgress);
  11272. var contextType = ctor.contextType;
  11273. if (typeof contextType === 'object' && contextType !== null) {
  11274. instance.context = readContext(contextType);
  11275. } else {
  11276. var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  11277. instance.context = getMaskedContext(workInProgress, unmaskedContext);
  11278. }
  11279. {
  11280. if (instance.state === newProps) {
  11281. var componentName = getComponentName(ctor) || 'Component';
  11282. if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
  11283. didWarnAboutDirectlyAssigningPropsToState.add(componentName);
  11284. error('%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName);
  11285. }
  11286. }
  11287. if (workInProgress.mode & StrictMode) {
  11288. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
  11289. }
  11290. {
  11291. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
  11292. }
  11293. }
  11294. processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
  11295. instance.state = workInProgress.memoizedState;
  11296. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  11297. if (typeof getDerivedStateFromProps === 'function') {
  11298. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  11299. instance.state = workInProgress.memoizedState;
  11300. } // In order to support react-lifecycles-compat polyfilled components,
  11301. // Unsafe lifecycles should not be invoked for components using the new APIs.
  11302. if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  11303. callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's
  11304. // process them now.
  11305. processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
  11306. instance.state = workInProgress.memoizedState;
  11307. }
  11308. if (typeof instance.componentDidMount === 'function') {
  11309. workInProgress.effectTag |= Update;
  11310. }
  11311. }
  11312. function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
  11313. var instance = workInProgress.stateNode;
  11314. var oldProps = workInProgress.memoizedProps;
  11315. instance.props = oldProps;
  11316. var oldContext = instance.context;
  11317. var contextType = ctor.contextType;
  11318. var nextContext = emptyContextObject;
  11319. if (typeof contextType === 'object' && contextType !== null) {
  11320. nextContext = readContext(contextType);
  11321. } else {
  11322. var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  11323. nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
  11324. }
  11325. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  11326. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
  11327. // ever the previously attempted to render - not the "current". However,
  11328. // during componentDidUpdate we pass the "current" props.
  11329. // In order to support react-lifecycles-compat polyfilled components,
  11330. // Unsafe lifecycles should not be invoked for components using the new APIs.
  11331. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  11332. if (oldProps !== newProps || oldContext !== nextContext) {
  11333. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  11334. }
  11335. }
  11336. resetHasForceUpdateBeforeProcessing();
  11337. var oldState = workInProgress.memoizedState;
  11338. var newState = instance.state = oldState;
  11339. processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
  11340. newState = workInProgress.memoizedState;
  11341. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  11342. // If an update was already in progress, we should schedule an Update
  11343. // effect even though we're bailing out, so that cWU/cDU are called.
  11344. if (typeof instance.componentDidMount === 'function') {
  11345. workInProgress.effectTag |= Update;
  11346. }
  11347. return false;
  11348. }
  11349. if (typeof getDerivedStateFromProps === 'function') {
  11350. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  11351. newState = workInProgress.memoizedState;
  11352. }
  11353. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  11354. if (shouldUpdate) {
  11355. // In order to support react-lifecycles-compat polyfilled components,
  11356. // Unsafe lifecycles should not be invoked for components using the new APIs.
  11357. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  11358. startPhaseTimer(workInProgress, 'componentWillMount');
  11359. if (typeof instance.componentWillMount === 'function') {
  11360. instance.componentWillMount();
  11361. }
  11362. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  11363. instance.UNSAFE_componentWillMount();
  11364. }
  11365. stopPhaseTimer();
  11366. }
  11367. if (typeof instance.componentDidMount === 'function') {
  11368. workInProgress.effectTag |= Update;
  11369. }
  11370. } else {
  11371. // If an update was already in progress, we should schedule an Update
  11372. // effect even though we're bailing out, so that cWU/cDU are called.
  11373. if (typeof instance.componentDidMount === 'function') {
  11374. workInProgress.effectTag |= Update;
  11375. } // If shouldComponentUpdate returned false, we should still update the
  11376. // memoized state to indicate that this work can be reused.
  11377. workInProgress.memoizedProps = newProps;
  11378. workInProgress.memoizedState = newState;
  11379. } // Update the existing instance's state, props, and context pointers even
  11380. // if shouldComponentUpdate returns false.
  11381. instance.props = newProps;
  11382. instance.state = newState;
  11383. instance.context = nextContext;
  11384. return shouldUpdate;
  11385. } // Invokes the update life-cycles and returns false if it shouldn't rerender.
  11386. function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
  11387. var instance = workInProgress.stateNode;
  11388. cloneUpdateQueue(current, workInProgress);
  11389. var oldProps = workInProgress.memoizedProps;
  11390. instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
  11391. var oldContext = instance.context;
  11392. var contextType = ctor.contextType;
  11393. var nextContext = emptyContextObject;
  11394. if (typeof contextType === 'object' && contextType !== null) {
  11395. nextContext = readContext(contextType);
  11396. } else {
  11397. var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  11398. nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
  11399. }
  11400. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  11401. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
  11402. // ever the previously attempted to render - not the "current". However,
  11403. // during componentDidUpdate we pass the "current" props.
  11404. // In order to support react-lifecycles-compat polyfilled components,
  11405. // Unsafe lifecycles should not be invoked for components using the new APIs.
  11406. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  11407. if (oldProps !== newProps || oldContext !== nextContext) {
  11408. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  11409. }
  11410. }
  11411. resetHasForceUpdateBeforeProcessing();
  11412. var oldState = workInProgress.memoizedState;
  11413. var newState = instance.state = oldState;
  11414. processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
  11415. newState = workInProgress.memoizedState;
  11416. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  11417. // If an update was already in progress, we should schedule an Update
  11418. // effect even though we're bailing out, so that cWU/cDU are called.
  11419. if (typeof instance.componentDidUpdate === 'function') {
  11420. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  11421. workInProgress.effectTag |= Update;
  11422. }
  11423. }
  11424. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  11425. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  11426. workInProgress.effectTag |= Snapshot;
  11427. }
  11428. }
  11429. return false;
  11430. }
  11431. if (typeof getDerivedStateFromProps === 'function') {
  11432. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  11433. newState = workInProgress.memoizedState;
  11434. }
  11435. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  11436. if (shouldUpdate) {
  11437. // In order to support react-lifecycles-compat polyfilled components,
  11438. // Unsafe lifecycles should not be invoked for components using the new APIs.
  11439. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
  11440. startPhaseTimer(workInProgress, 'componentWillUpdate');
  11441. if (typeof instance.componentWillUpdate === 'function') {
  11442. instance.componentWillUpdate(newProps, newState, nextContext);
  11443. }
  11444. if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  11445. instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
  11446. }
  11447. stopPhaseTimer();
  11448. }
  11449. if (typeof instance.componentDidUpdate === 'function') {
  11450. workInProgress.effectTag |= Update;
  11451. }
  11452. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  11453. workInProgress.effectTag |= Snapshot;
  11454. }
  11455. } else {
  11456. // If an update was already in progress, we should schedule an Update
  11457. // effect even though we're bailing out, so that cWU/cDU are called.
  11458. if (typeof instance.componentDidUpdate === 'function') {
  11459. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  11460. workInProgress.effectTag |= Update;
  11461. }
  11462. }
  11463. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  11464. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  11465. workInProgress.effectTag |= Snapshot;
  11466. }
  11467. } // If shouldComponentUpdate returned false, we should still update the
  11468. // memoized props/state to indicate that this work can be reused.
  11469. workInProgress.memoizedProps = newProps;
  11470. workInProgress.memoizedState = newState;
  11471. } // Update the existing instance's state, props, and context pointers even
  11472. // if shouldComponentUpdate returns false.
  11473. instance.props = newProps;
  11474. instance.state = newState;
  11475. instance.context = nextContext;
  11476. return shouldUpdate;
  11477. }
  11478. var didWarnAboutMaps;
  11479. var didWarnAboutGenerators;
  11480. var didWarnAboutStringRefs;
  11481. var ownerHasKeyUseWarning;
  11482. var ownerHasFunctionTypeWarning;
  11483. var warnForMissingKey = function (child) {};
  11484. {
  11485. didWarnAboutMaps = false;
  11486. didWarnAboutGenerators = false;
  11487. didWarnAboutStringRefs = {};
  11488. /**
  11489. * Warn if there's no key explicitly set on dynamic arrays of children or
  11490. * object keys are not valid. This allows us to keep track of children between
  11491. * updates.
  11492. */
  11493. ownerHasKeyUseWarning = {};
  11494. ownerHasFunctionTypeWarning = {};
  11495. warnForMissingKey = function (child) {
  11496. if (child === null || typeof child !== 'object') {
  11497. return;
  11498. }
  11499. if (!child._store || child._store.validated || child.key != null) {
  11500. return;
  11501. }
  11502. if (!(typeof child._store === 'object')) {
  11503. {
  11504. throw Error( "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." );
  11505. }
  11506. }
  11507. child._store.validated = true;
  11508. var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
  11509. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  11510. return;
  11511. }
  11512. ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
  11513. error('Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
  11514. };
  11515. }
  11516. var isArray$1 = Array.isArray;
  11517. function coerceRef(returnFiber, current, element) {
  11518. var mixedRef = element.ref;
  11519. if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
  11520. {
  11521. // TODO: Clean this up once we turn on the string ref warning for
  11522. // everyone, because the strict mode case will no longer be relevant
  11523. if ((returnFiber.mode & StrictMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs
  11524. // because these cannot be automatically converted to an arrow function
  11525. // using a codemod. Therefore, we don't have to warn about string refs again.
  11526. !(element._owner && element._self && element._owner.stateNode !== element._self)) {
  11527. var componentName = getComponentName(returnFiber.type) || 'Component';
  11528. if (!didWarnAboutStringRefs[componentName]) {
  11529. {
  11530. error('A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', mixedRef, getStackByFiberInDevAndProd(returnFiber));
  11531. }
  11532. didWarnAboutStringRefs[componentName] = true;
  11533. }
  11534. }
  11535. }
  11536. if (element._owner) {
  11537. var owner = element._owner;
  11538. var inst;
  11539. if (owner) {
  11540. var ownerFiber = owner;
  11541. if (!(ownerFiber.tag === ClassComponent)) {
  11542. {
  11543. throw Error( "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref" );
  11544. }
  11545. }
  11546. inst = ownerFiber.stateNode;
  11547. }
  11548. if (!inst) {
  11549. {
  11550. throw Error( "Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue." );
  11551. }
  11552. }
  11553. var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref
  11554. if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) {
  11555. return current.ref;
  11556. }
  11557. var ref = function (value) {
  11558. var refs = inst.refs;
  11559. if (refs === emptyRefsObject) {
  11560. // This is a lazy pooled frozen object, so we need to initialize.
  11561. refs = inst.refs = {};
  11562. }
  11563. if (value === null) {
  11564. delete refs[stringRef];
  11565. } else {
  11566. refs[stringRef] = value;
  11567. }
  11568. };
  11569. ref._stringRef = stringRef;
  11570. return ref;
  11571. } else {
  11572. if (!(typeof mixedRef === 'string')) {
  11573. {
  11574. throw Error( "Expected ref to be a function, a string, an object returned by React.createRef(), or null." );
  11575. }
  11576. }
  11577. if (!element._owner) {
  11578. {
  11579. throw Error( "Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." );
  11580. }
  11581. }
  11582. }
  11583. }
  11584. return mixedRef;
  11585. }
  11586. function throwOnInvalidObjectType(returnFiber, newChild) {
  11587. if (returnFiber.type !== 'textarea') {
  11588. var addendum = '';
  11589. {
  11590. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
  11591. }
  11592. {
  11593. {
  11594. throw Error( "Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + ")." + addendum );
  11595. }
  11596. }
  11597. }
  11598. }
  11599. function warnOnFunctionType() {
  11600. {
  11601. var currentComponentErrorInfo = 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + getCurrentFiberStackInDev();
  11602. if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
  11603. return;
  11604. }
  11605. ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
  11606. error('Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.');
  11607. }
  11608. } // This wrapper function exists because I expect to clone the code in each path
  11609. // to be able to optimize each path individually by branching early. This needs
  11610. // a compiler or we can do it manually. Helpers that don't need this branching
  11611. // live outside of this function.
  11612. function ChildReconciler(shouldTrackSideEffects) {
  11613. function deleteChild(returnFiber, childToDelete) {
  11614. if (!shouldTrackSideEffects) {
  11615. // Noop.
  11616. return;
  11617. } // Deletions are added in reversed order so we add it to the front.
  11618. // At this point, the return fiber's effect list is empty except for
  11619. // deletions, so we can just append the deletion to the list. The remaining
  11620. // effects aren't added until the complete phase. Once we implement
  11621. // resuming, this may not be true.
  11622. var last = returnFiber.lastEffect;
  11623. if (last !== null) {
  11624. last.nextEffect = childToDelete;
  11625. returnFiber.lastEffect = childToDelete;
  11626. } else {
  11627. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  11628. }
  11629. childToDelete.nextEffect = null;
  11630. childToDelete.effectTag = Deletion;
  11631. }
  11632. function deleteRemainingChildren(returnFiber, currentFirstChild) {
  11633. if (!shouldTrackSideEffects) {
  11634. // Noop.
  11635. return null;
  11636. } // TODO: For the shouldClone case, this could be micro-optimized a bit by
  11637. // assuming that after the first child we've already added everything.
  11638. var childToDelete = currentFirstChild;
  11639. while (childToDelete !== null) {
  11640. deleteChild(returnFiber, childToDelete);
  11641. childToDelete = childToDelete.sibling;
  11642. }
  11643. return null;
  11644. }
  11645. function mapRemainingChildren(returnFiber, currentFirstChild) {
  11646. // Add the remaining children to a temporary map so that we can find them by
  11647. // keys quickly. Implicit (null) keys get added to this set with their index
  11648. // instead.
  11649. var existingChildren = new Map();
  11650. var existingChild = currentFirstChild;
  11651. while (existingChild !== null) {
  11652. if (existingChild.key !== null) {
  11653. existingChildren.set(existingChild.key, existingChild);
  11654. } else {
  11655. existingChildren.set(existingChild.index, existingChild);
  11656. }
  11657. existingChild = existingChild.sibling;
  11658. }
  11659. return existingChildren;
  11660. }
  11661. function useFiber(fiber, pendingProps) {
  11662. // We currently set sibling to null and index to 0 here because it is easy
  11663. // to forget to do before returning it. E.g. for the single child case.
  11664. var clone = createWorkInProgress(fiber, pendingProps);
  11665. clone.index = 0;
  11666. clone.sibling = null;
  11667. return clone;
  11668. }
  11669. function placeChild(newFiber, lastPlacedIndex, newIndex) {
  11670. newFiber.index = newIndex;
  11671. if (!shouldTrackSideEffects) {
  11672. // Noop.
  11673. return lastPlacedIndex;
  11674. }
  11675. var current = newFiber.alternate;
  11676. if (current !== null) {
  11677. var oldIndex = current.index;
  11678. if (oldIndex < lastPlacedIndex) {
  11679. // This is a move.
  11680. newFiber.effectTag = Placement;
  11681. return lastPlacedIndex;
  11682. } else {
  11683. // This item can stay in place.
  11684. return oldIndex;
  11685. }
  11686. } else {
  11687. // This is an insertion.
  11688. newFiber.effectTag = Placement;
  11689. return lastPlacedIndex;
  11690. }
  11691. }
  11692. function placeSingleChild(newFiber) {
  11693. // This is simpler for the single child case. We only need to do a
  11694. // placement for inserting new children.
  11695. if (shouldTrackSideEffects && newFiber.alternate === null) {
  11696. newFiber.effectTag = Placement;
  11697. }
  11698. return newFiber;
  11699. }
  11700. function updateTextNode(returnFiber, current, textContent, expirationTime) {
  11701. if (current === null || current.tag !== HostText) {
  11702. // Insert
  11703. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  11704. created.return = returnFiber;
  11705. return created;
  11706. } else {
  11707. // Update
  11708. var existing = useFiber(current, textContent);
  11709. existing.return = returnFiber;
  11710. return existing;
  11711. }
  11712. }
  11713. function updateElement(returnFiber, current, element, expirationTime) {
  11714. if (current !== null) {
  11715. if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
  11716. isCompatibleFamilyForHotReloading(current, element) )) {
  11717. // Move based on index
  11718. var existing = useFiber(current, element.props);
  11719. existing.ref = coerceRef(returnFiber, current, element);
  11720. existing.return = returnFiber;
  11721. {
  11722. existing._debugSource = element._source;
  11723. existing._debugOwner = element._owner;
  11724. }
  11725. return existing;
  11726. }
  11727. } // Insert
  11728. var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
  11729. created.ref = coerceRef(returnFiber, current, element);
  11730. created.return = returnFiber;
  11731. return created;
  11732. }
  11733. function updatePortal(returnFiber, current, portal, expirationTime) {
  11734. if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {
  11735. // Insert
  11736. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  11737. created.return = returnFiber;
  11738. return created;
  11739. } else {
  11740. // Update
  11741. var existing = useFiber(current, portal.children || []);
  11742. existing.return = returnFiber;
  11743. return existing;
  11744. }
  11745. }
  11746. function updateFragment(returnFiber, current, fragment, expirationTime, key) {
  11747. if (current === null || current.tag !== Fragment) {
  11748. // Insert
  11749. var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
  11750. created.return = returnFiber;
  11751. return created;
  11752. } else {
  11753. // Update
  11754. var existing = useFiber(current, fragment);
  11755. existing.return = returnFiber;
  11756. return existing;
  11757. }
  11758. }
  11759. function createChild(returnFiber, newChild, expirationTime) {
  11760. if (typeof newChild === 'string' || typeof newChild === 'number') {
  11761. // Text nodes don't have keys. If the previous node is implicitly keyed
  11762. // we can continue to replace it without aborting even if it is not a text
  11763. // node.
  11764. var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
  11765. created.return = returnFiber;
  11766. return created;
  11767. }
  11768. if (typeof newChild === 'object' && newChild !== null) {
  11769. switch (newChild.$$typeof) {
  11770. case REACT_ELEMENT_TYPE:
  11771. {
  11772. var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
  11773. _created.ref = coerceRef(returnFiber, null, newChild);
  11774. _created.return = returnFiber;
  11775. return _created;
  11776. }
  11777. case REACT_PORTAL_TYPE:
  11778. {
  11779. var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
  11780. _created2.return = returnFiber;
  11781. return _created2;
  11782. }
  11783. }
  11784. if (isArray$1(newChild) || getIteratorFn(newChild)) {
  11785. var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
  11786. _created3.return = returnFiber;
  11787. return _created3;
  11788. }
  11789. throwOnInvalidObjectType(returnFiber, newChild);
  11790. }
  11791. {
  11792. if (typeof newChild === 'function') {
  11793. warnOnFunctionType();
  11794. }
  11795. }
  11796. return null;
  11797. }
  11798. function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
  11799. // Update the fiber if the keys match, otherwise return null.
  11800. var key = oldFiber !== null ? oldFiber.key : null;
  11801. if (typeof newChild === 'string' || typeof newChild === 'number') {
  11802. // Text nodes don't have keys. If the previous node is implicitly keyed
  11803. // we can continue to replace it without aborting even if it is not a text
  11804. // node.
  11805. if (key !== null) {
  11806. return null;
  11807. }
  11808. return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
  11809. }
  11810. if (typeof newChild === 'object' && newChild !== null) {
  11811. switch (newChild.$$typeof) {
  11812. case REACT_ELEMENT_TYPE:
  11813. {
  11814. if (newChild.key === key) {
  11815. if (newChild.type === REACT_FRAGMENT_TYPE) {
  11816. return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
  11817. }
  11818. return updateElement(returnFiber, oldFiber, newChild, expirationTime);
  11819. } else {
  11820. return null;
  11821. }
  11822. }
  11823. case REACT_PORTAL_TYPE:
  11824. {
  11825. if (newChild.key === key) {
  11826. return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
  11827. } else {
  11828. return null;
  11829. }
  11830. }
  11831. }
  11832. if (isArray$1(newChild) || getIteratorFn(newChild)) {
  11833. if (key !== null) {
  11834. return null;
  11835. }
  11836. return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
  11837. }
  11838. throwOnInvalidObjectType(returnFiber, newChild);
  11839. }
  11840. {
  11841. if (typeof newChild === 'function') {
  11842. warnOnFunctionType();
  11843. }
  11844. }
  11845. return null;
  11846. }
  11847. function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
  11848. if (typeof newChild === 'string' || typeof newChild === 'number') {
  11849. // Text nodes don't have keys, so we neither have to check the old nor
  11850. // new node for the key. If both are text nodes, they match.
  11851. var matchedFiber = existingChildren.get(newIdx) || null;
  11852. return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
  11853. }
  11854. if (typeof newChild === 'object' && newChild !== null) {
  11855. switch (newChild.$$typeof) {
  11856. case REACT_ELEMENT_TYPE:
  11857. {
  11858. var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  11859. if (newChild.type === REACT_FRAGMENT_TYPE) {
  11860. return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
  11861. }
  11862. return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
  11863. }
  11864. case REACT_PORTAL_TYPE:
  11865. {
  11866. var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  11867. return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
  11868. }
  11869. }
  11870. if (isArray$1(newChild) || getIteratorFn(newChild)) {
  11871. var _matchedFiber3 = existingChildren.get(newIdx) || null;
  11872. return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
  11873. }
  11874. throwOnInvalidObjectType(returnFiber, newChild);
  11875. }
  11876. {
  11877. if (typeof newChild === 'function') {
  11878. warnOnFunctionType();
  11879. }
  11880. }
  11881. return null;
  11882. }
  11883. /**
  11884. * Warns if there is a duplicate or missing key
  11885. */
  11886. function warnOnInvalidKey(child, knownKeys) {
  11887. {
  11888. if (typeof child !== 'object' || child === null) {
  11889. return knownKeys;
  11890. }
  11891. switch (child.$$typeof) {
  11892. case REACT_ELEMENT_TYPE:
  11893. case REACT_PORTAL_TYPE:
  11894. warnForMissingKey(child);
  11895. var key = child.key;
  11896. if (typeof key !== 'string') {
  11897. break;
  11898. }
  11899. if (knownKeys === null) {
  11900. knownKeys = new Set();
  11901. knownKeys.add(key);
  11902. break;
  11903. }
  11904. if (!knownKeys.has(key)) {
  11905. knownKeys.add(key);
  11906. break;
  11907. }
  11908. error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);
  11909. break;
  11910. }
  11911. }
  11912. return knownKeys;
  11913. }
  11914. function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
  11915. // This algorithm can't optimize by searching from both ends since we
  11916. // don't have backpointers on fibers. I'm trying to see how far we can get
  11917. // with that model. If it ends up not being worth the tradeoffs, we can
  11918. // add it later.
  11919. // Even with a two ended optimization, we'd want to optimize for the case
  11920. // where there are few changes and brute force the comparison instead of
  11921. // going for the Map. It'd like to explore hitting that path first in
  11922. // forward-only mode and only go for the Map once we notice that we need
  11923. // lots of look ahead. This doesn't handle reversal as well as two ended
  11924. // search but that's unusual. Besides, for the two ended optimization to
  11925. // work on Iterables, we'd need to copy the whole set.
  11926. // In this first iteration, we'll just live with hitting the bad case
  11927. // (adding everything to a Map) in for every insert/move.
  11928. // If you change this code, also update reconcileChildrenIterator() which
  11929. // uses the same algorithm.
  11930. {
  11931. // First, validate keys.
  11932. var knownKeys = null;
  11933. for (var i = 0; i < newChildren.length; i++) {
  11934. var child = newChildren[i];
  11935. knownKeys = warnOnInvalidKey(child, knownKeys);
  11936. }
  11937. }
  11938. var resultingFirstChild = null;
  11939. var previousNewFiber = null;
  11940. var oldFiber = currentFirstChild;
  11941. var lastPlacedIndex = 0;
  11942. var newIdx = 0;
  11943. var nextOldFiber = null;
  11944. for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
  11945. if (oldFiber.index > newIdx) {
  11946. nextOldFiber = oldFiber;
  11947. oldFiber = null;
  11948. } else {
  11949. nextOldFiber = oldFiber.sibling;
  11950. }
  11951. var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
  11952. if (newFiber === null) {
  11953. // TODO: This breaks on empty slots like null children. That's
  11954. // unfortunate because it triggers the slow path all the time. We need
  11955. // a better way to communicate whether this was a miss or null,
  11956. // boolean, undefined, etc.
  11957. if (oldFiber === null) {
  11958. oldFiber = nextOldFiber;
  11959. }
  11960. break;
  11961. }
  11962. if (shouldTrackSideEffects) {
  11963. if (oldFiber && newFiber.alternate === null) {
  11964. // We matched the slot, but we didn't reuse the existing fiber, so we
  11965. // need to delete the existing child.
  11966. deleteChild(returnFiber, oldFiber);
  11967. }
  11968. }
  11969. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  11970. if (previousNewFiber === null) {
  11971. // TODO: Move out of the loop. This only happens for the first run.
  11972. resultingFirstChild = newFiber;
  11973. } else {
  11974. // TODO: Defer siblings if we're not at the right index for this slot.
  11975. // I.e. if we had null values before, then we want to defer this
  11976. // for each null value. However, we also don't want to call updateSlot
  11977. // with the previous one.
  11978. previousNewFiber.sibling = newFiber;
  11979. }
  11980. previousNewFiber = newFiber;
  11981. oldFiber = nextOldFiber;
  11982. }
  11983. if (newIdx === newChildren.length) {
  11984. // We've reached the end of the new children. We can delete the rest.
  11985. deleteRemainingChildren(returnFiber, oldFiber);
  11986. return resultingFirstChild;
  11987. }
  11988. if (oldFiber === null) {
  11989. // If we don't have any more existing children we can choose a fast path
  11990. // since the rest will all be insertions.
  11991. for (; newIdx < newChildren.length; newIdx++) {
  11992. var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
  11993. if (_newFiber === null) {
  11994. continue;
  11995. }
  11996. lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
  11997. if (previousNewFiber === null) {
  11998. // TODO: Move out of the loop. This only happens for the first run.
  11999. resultingFirstChild = _newFiber;
  12000. } else {
  12001. previousNewFiber.sibling = _newFiber;
  12002. }
  12003. previousNewFiber = _newFiber;
  12004. }
  12005. return resultingFirstChild;
  12006. } // Add all children to a key map for quick lookups.
  12007. var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
  12008. for (; newIdx < newChildren.length; newIdx++) {
  12009. var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
  12010. if (_newFiber2 !== null) {
  12011. if (shouldTrackSideEffects) {
  12012. if (_newFiber2.alternate !== null) {
  12013. // The new fiber is a work in progress, but if there exists a
  12014. // current, that means that we reused the fiber. We need to delete
  12015. // it from the child list so that we don't add it to the deletion
  12016. // list.
  12017. existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
  12018. }
  12019. }
  12020. lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
  12021. if (previousNewFiber === null) {
  12022. resultingFirstChild = _newFiber2;
  12023. } else {
  12024. previousNewFiber.sibling = _newFiber2;
  12025. }
  12026. previousNewFiber = _newFiber2;
  12027. }
  12028. }
  12029. if (shouldTrackSideEffects) {
  12030. // Any existing children that weren't consumed above were deleted. We need
  12031. // to add them to the deletion list.
  12032. existingChildren.forEach(function (child) {
  12033. return deleteChild(returnFiber, child);
  12034. });
  12035. }
  12036. return resultingFirstChild;
  12037. }
  12038. function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
  12039. // This is the same implementation as reconcileChildrenArray(),
  12040. // but using the iterator instead.
  12041. var iteratorFn = getIteratorFn(newChildrenIterable);
  12042. if (!(typeof iteratorFn === 'function')) {
  12043. {
  12044. throw Error( "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." );
  12045. }
  12046. }
  12047. {
  12048. // We don't support rendering Generators because it's a mutation.
  12049. // See https://github.com/facebook/react/issues/12995
  12050. if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag
  12051. newChildrenIterable[Symbol.toStringTag] === 'Generator') {
  12052. if (!didWarnAboutGenerators) {
  12053. error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');
  12054. }
  12055. didWarnAboutGenerators = true;
  12056. } // Warn about using Maps as children
  12057. if (newChildrenIterable.entries === iteratorFn) {
  12058. if (!didWarnAboutMaps) {
  12059. error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');
  12060. }
  12061. didWarnAboutMaps = true;
  12062. } // First, validate keys.
  12063. // We'll get a different iterator later for the main pass.
  12064. var _newChildren = iteratorFn.call(newChildrenIterable);
  12065. if (_newChildren) {
  12066. var knownKeys = null;
  12067. var _step = _newChildren.next();
  12068. for (; !_step.done; _step = _newChildren.next()) {
  12069. var child = _step.value;
  12070. knownKeys = warnOnInvalidKey(child, knownKeys);
  12071. }
  12072. }
  12073. }
  12074. var newChildren = iteratorFn.call(newChildrenIterable);
  12075. if (!(newChildren != null)) {
  12076. {
  12077. throw Error( "An iterable object provided no iterator." );
  12078. }
  12079. }
  12080. var resultingFirstChild = null;
  12081. var previousNewFiber = null;
  12082. var oldFiber = currentFirstChild;
  12083. var lastPlacedIndex = 0;
  12084. var newIdx = 0;
  12085. var nextOldFiber = null;
  12086. var step = newChildren.next();
  12087. for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
  12088. if (oldFiber.index > newIdx) {
  12089. nextOldFiber = oldFiber;
  12090. oldFiber = null;
  12091. } else {
  12092. nextOldFiber = oldFiber.sibling;
  12093. }
  12094. var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
  12095. if (newFiber === null) {
  12096. // TODO: This breaks on empty slots like null children. That's
  12097. // unfortunate because it triggers the slow path all the time. We need
  12098. // a better way to communicate whether this was a miss or null,
  12099. // boolean, undefined, etc.
  12100. if (oldFiber === null) {
  12101. oldFiber = nextOldFiber;
  12102. }
  12103. break;
  12104. }
  12105. if (shouldTrackSideEffects) {
  12106. if (oldFiber && newFiber.alternate === null) {
  12107. // We matched the slot, but we didn't reuse the existing fiber, so we
  12108. // need to delete the existing child.
  12109. deleteChild(returnFiber, oldFiber);
  12110. }
  12111. }
  12112. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  12113. if (previousNewFiber === null) {
  12114. // TODO: Move out of the loop. This only happens for the first run.
  12115. resultingFirstChild = newFiber;
  12116. } else {
  12117. // TODO: Defer siblings if we're not at the right index for this slot.
  12118. // I.e. if we had null values before, then we want to defer this
  12119. // for each null value. However, we also don't want to call updateSlot
  12120. // with the previous one.
  12121. previousNewFiber.sibling = newFiber;
  12122. }
  12123. previousNewFiber = newFiber;
  12124. oldFiber = nextOldFiber;
  12125. }
  12126. if (step.done) {
  12127. // We've reached the end of the new children. We can delete the rest.
  12128. deleteRemainingChildren(returnFiber, oldFiber);
  12129. return resultingFirstChild;
  12130. }
  12131. if (oldFiber === null) {
  12132. // If we don't have any more existing children we can choose a fast path
  12133. // since the rest will all be insertions.
  12134. for (; !step.done; newIdx++, step = newChildren.next()) {
  12135. var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
  12136. if (_newFiber3 === null) {
  12137. continue;
  12138. }
  12139. lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
  12140. if (previousNewFiber === null) {
  12141. // TODO: Move out of the loop. This only happens for the first run.
  12142. resultingFirstChild = _newFiber3;
  12143. } else {
  12144. previousNewFiber.sibling = _newFiber3;
  12145. }
  12146. previousNewFiber = _newFiber3;
  12147. }
  12148. return resultingFirstChild;
  12149. } // Add all children to a key map for quick lookups.
  12150. var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
  12151. for (; !step.done; newIdx++, step = newChildren.next()) {
  12152. var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
  12153. if (_newFiber4 !== null) {
  12154. if (shouldTrackSideEffects) {
  12155. if (_newFiber4.alternate !== null) {
  12156. // The new fiber is a work in progress, but if there exists a
  12157. // current, that means that we reused the fiber. We need to delete
  12158. // it from the child list so that we don't add it to the deletion
  12159. // list.
  12160. existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
  12161. }
  12162. }
  12163. lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
  12164. if (previousNewFiber === null) {
  12165. resultingFirstChild = _newFiber4;
  12166. } else {
  12167. previousNewFiber.sibling = _newFiber4;
  12168. }
  12169. previousNewFiber = _newFiber4;
  12170. }
  12171. }
  12172. if (shouldTrackSideEffects) {
  12173. // Any existing children that weren't consumed above were deleted. We need
  12174. // to add them to the deletion list.
  12175. existingChildren.forEach(function (child) {
  12176. return deleteChild(returnFiber, child);
  12177. });
  12178. }
  12179. return resultingFirstChild;
  12180. }
  12181. function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
  12182. // There's no need to check for keys on text nodes since we don't have a
  12183. // way to define them.
  12184. if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
  12185. // We already have an existing node so let's just update it and delete
  12186. // the rest.
  12187. deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
  12188. var existing = useFiber(currentFirstChild, textContent);
  12189. existing.return = returnFiber;
  12190. return existing;
  12191. } // The existing first child is not a text node so we need to create one
  12192. // and delete the existing ones.
  12193. deleteRemainingChildren(returnFiber, currentFirstChild);
  12194. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  12195. created.return = returnFiber;
  12196. return created;
  12197. }
  12198. function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
  12199. var key = element.key;
  12200. var child = currentFirstChild;
  12201. while (child !== null) {
  12202. // TODO: If key === null and child.key === null, then this only applies to
  12203. // the first item in the list.
  12204. if (child.key === key) {
  12205. switch (child.tag) {
  12206. case Fragment:
  12207. {
  12208. if (element.type === REACT_FRAGMENT_TYPE) {
  12209. deleteRemainingChildren(returnFiber, child.sibling);
  12210. var existing = useFiber(child, element.props.children);
  12211. existing.return = returnFiber;
  12212. {
  12213. existing._debugSource = element._source;
  12214. existing._debugOwner = element._owner;
  12215. }
  12216. return existing;
  12217. }
  12218. break;
  12219. }
  12220. case Block:
  12221. // We intentionally fallthrough here if enableBlocksAPI is not on.
  12222. // eslint-disable-next-lined no-fallthrough
  12223. default:
  12224. {
  12225. if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
  12226. isCompatibleFamilyForHotReloading(child, element) )) {
  12227. deleteRemainingChildren(returnFiber, child.sibling);
  12228. var _existing3 = useFiber(child, element.props);
  12229. _existing3.ref = coerceRef(returnFiber, child, element);
  12230. _existing3.return = returnFiber;
  12231. {
  12232. _existing3._debugSource = element._source;
  12233. _existing3._debugOwner = element._owner;
  12234. }
  12235. return _existing3;
  12236. }
  12237. break;
  12238. }
  12239. } // Didn't match.
  12240. deleteRemainingChildren(returnFiber, child);
  12241. break;
  12242. } else {
  12243. deleteChild(returnFiber, child);
  12244. }
  12245. child = child.sibling;
  12246. }
  12247. if (element.type === REACT_FRAGMENT_TYPE) {
  12248. var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
  12249. created.return = returnFiber;
  12250. return created;
  12251. } else {
  12252. var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
  12253. _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
  12254. _created4.return = returnFiber;
  12255. return _created4;
  12256. }
  12257. }
  12258. function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
  12259. var key = portal.key;
  12260. var child = currentFirstChild;
  12261. while (child !== null) {
  12262. // TODO: If key === null and child.key === null, then this only applies to
  12263. // the first item in the list.
  12264. if (child.key === key) {
  12265. if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
  12266. deleteRemainingChildren(returnFiber, child.sibling);
  12267. var existing = useFiber(child, portal.children || []);
  12268. existing.return = returnFiber;
  12269. return existing;
  12270. } else {
  12271. deleteRemainingChildren(returnFiber, child);
  12272. break;
  12273. }
  12274. } else {
  12275. deleteChild(returnFiber, child);
  12276. }
  12277. child = child.sibling;
  12278. }
  12279. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  12280. created.return = returnFiber;
  12281. return created;
  12282. } // This API will tag the children with the side-effect of the reconciliation
  12283. // itself. They will be added to the side-effect list as we pass through the
  12284. // children and the parent.
  12285. function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
  12286. // This function is not recursive.
  12287. // If the top level item is an array, we treat it as a set of children,
  12288. // not as a fragment. Nested arrays on the other hand will be treated as
  12289. // fragment nodes. Recursion happens at the normal flow.
  12290. // Handle top level unkeyed fragments as if they were arrays.
  12291. // This leads to an ambiguity between <>{[...]}</> and <>...</>.
  12292. // We treat the ambiguous cases above the same.
  12293. var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
  12294. if (isUnkeyedTopLevelFragment) {
  12295. newChild = newChild.props.children;
  12296. } // Handle object types
  12297. var isObject = typeof newChild === 'object' && newChild !== null;
  12298. if (isObject) {
  12299. switch (newChild.$$typeof) {
  12300. case REACT_ELEMENT_TYPE:
  12301. return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
  12302. case REACT_PORTAL_TYPE:
  12303. return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
  12304. }
  12305. }
  12306. if (typeof newChild === 'string' || typeof newChild === 'number') {
  12307. return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
  12308. }
  12309. if (isArray$1(newChild)) {
  12310. return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
  12311. }
  12312. if (getIteratorFn(newChild)) {
  12313. return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
  12314. }
  12315. if (isObject) {
  12316. throwOnInvalidObjectType(returnFiber, newChild);
  12317. }
  12318. {
  12319. if (typeof newChild === 'function') {
  12320. warnOnFunctionType();
  12321. }
  12322. }
  12323. if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
  12324. // If the new child is undefined, and the return fiber is a composite
  12325. // component, throw an error. If Fiber return types are disabled,
  12326. // we already threw above.
  12327. switch (returnFiber.tag) {
  12328. case ClassComponent:
  12329. {
  12330. {
  12331. var instance = returnFiber.stateNode;
  12332. if (instance.render._isMockFunction) {
  12333. // We allow auto-mocks to proceed as if they're returning null.
  12334. break;
  12335. }
  12336. }
  12337. }
  12338. // Intentionally fall through to the next case, which handles both
  12339. // functions and classes
  12340. // eslint-disable-next-lined no-fallthrough
  12341. case FunctionComponent:
  12342. {
  12343. var Component = returnFiber.type;
  12344. {
  12345. {
  12346. throw Error( (Component.displayName || Component.name || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." );
  12347. }
  12348. }
  12349. }
  12350. }
  12351. } // Remaining cases are all treated as empty.
  12352. return deleteRemainingChildren(returnFiber, currentFirstChild);
  12353. }
  12354. return reconcileChildFibers;
  12355. }
  12356. var reconcileChildFibers = ChildReconciler(true);
  12357. var mountChildFibers = ChildReconciler(false);
  12358. function cloneChildFibers(current, workInProgress) {
  12359. if (!(current === null || workInProgress.child === current.child)) {
  12360. {
  12361. throw Error( "Resuming work not yet implemented." );
  12362. }
  12363. }
  12364. if (workInProgress.child === null) {
  12365. return;
  12366. }
  12367. var currentChild = workInProgress.child;
  12368. var newChild = createWorkInProgress(currentChild, currentChild.pendingProps);
  12369. workInProgress.child = newChild;
  12370. newChild.return = workInProgress;
  12371. while (currentChild.sibling !== null) {
  12372. currentChild = currentChild.sibling;
  12373. newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps);
  12374. newChild.return = workInProgress;
  12375. }
  12376. newChild.sibling = null;
  12377. } // Reset a workInProgress child set to prepare it for a second pass.
  12378. function resetChildFibers(workInProgress, renderExpirationTime) {
  12379. var child = workInProgress.child;
  12380. while (child !== null) {
  12381. resetWorkInProgress(child, renderExpirationTime);
  12382. child = child.sibling;
  12383. }
  12384. }
  12385. var NO_CONTEXT = {};
  12386. var contextStackCursor$1 = createCursor(NO_CONTEXT);
  12387. var contextFiberStackCursor = createCursor(NO_CONTEXT);
  12388. var rootInstanceStackCursor = createCursor(NO_CONTEXT);
  12389. function requiredContext(c) {
  12390. if (!(c !== NO_CONTEXT)) {
  12391. {
  12392. throw Error( "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." );
  12393. }
  12394. }
  12395. return c;
  12396. }
  12397. function getRootHostContainer() {
  12398. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  12399. return rootInstance;
  12400. }
  12401. function pushHostContainer(fiber, nextRootInstance) {
  12402. // Push current root instance onto the stack;
  12403. // This allows us to reset root when portals are popped.
  12404. push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it.
  12405. // This enables us to pop only Fibers that provide unique contexts.
  12406. push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack.
  12407. // However, we can't just call getRootHostContext() and push it because
  12408. // we'd have a different number of entries on the stack depending on
  12409. // whether getRootHostContext() throws somewhere in renderer code or not.
  12410. // So we push an empty value first. This lets us safely unwind on errors.
  12411. push(contextStackCursor$1, NO_CONTEXT, fiber);
  12412. var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it.
  12413. pop(contextStackCursor$1, fiber);
  12414. push(contextStackCursor$1, nextRootContext, fiber);
  12415. }
  12416. function popHostContainer(fiber) {
  12417. pop(contextStackCursor$1, fiber);
  12418. pop(contextFiberStackCursor, fiber);
  12419. pop(rootInstanceStackCursor, fiber);
  12420. }
  12421. function getHostContext() {
  12422. var context = requiredContext(contextStackCursor$1.current);
  12423. return context;
  12424. }
  12425. function pushHostContext(fiber) {
  12426. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  12427. var context = requiredContext(contextStackCursor$1.current);
  12428. var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique.
  12429. if (context === nextContext) {
  12430. return;
  12431. } // Track the context and the Fiber that provided it.
  12432. // This enables us to pop only Fibers that provide unique contexts.
  12433. push(contextFiberStackCursor, fiber, fiber);
  12434. push(contextStackCursor$1, nextContext, fiber);
  12435. }
  12436. function popHostContext(fiber) {
  12437. // Do not pop unless this Fiber provided the current context.
  12438. // pushHostContext() only pushes Fibers that provide unique contexts.
  12439. if (contextFiberStackCursor.current !== fiber) {
  12440. return;
  12441. }
  12442. pop(contextStackCursor$1, fiber);
  12443. pop(contextFiberStackCursor, fiber);
  12444. }
  12445. var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is
  12446. // inherited deeply down the subtree. The upper bits only affect
  12447. // this immediate suspense boundary and gets reset each new
  12448. // boundary or suspense list.
  12449. var SubtreeSuspenseContextMask = 1; // Subtree Flags:
  12450. // InvisibleParentSuspenseContext indicates that one of our parent Suspense
  12451. // boundaries is not currently showing visible main content.
  12452. // Either because it is already showing a fallback or is not mounted at all.
  12453. // We can use this to determine if it is desirable to trigger a fallback at
  12454. // the parent. If not, then we might need to trigger undesirable boundaries
  12455. // and/or suspend the commit to avoid hiding the parent content.
  12456. var InvisibleParentSuspenseContext = 1; // Shallow Flags:
  12457. // ForceSuspenseFallback can be used by SuspenseList to force newly added
  12458. // items into their fallback state during one of the render passes.
  12459. var ForceSuspenseFallback = 2;
  12460. var suspenseStackCursor = createCursor(DefaultSuspenseContext);
  12461. function hasSuspenseContext(parentContext, flag) {
  12462. return (parentContext & flag) !== 0;
  12463. }
  12464. function setDefaultShallowSuspenseContext(parentContext) {
  12465. return parentContext & SubtreeSuspenseContextMask;
  12466. }
  12467. function setShallowSuspenseContext(parentContext, shallowContext) {
  12468. return parentContext & SubtreeSuspenseContextMask | shallowContext;
  12469. }
  12470. function addSubtreeSuspenseContext(parentContext, subtreeContext) {
  12471. return parentContext | subtreeContext;
  12472. }
  12473. function pushSuspenseContext(fiber, newContext) {
  12474. push(suspenseStackCursor, newContext, fiber);
  12475. }
  12476. function popSuspenseContext(fiber) {
  12477. pop(suspenseStackCursor, fiber);
  12478. }
  12479. function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
  12480. // If it was the primary children that just suspended, capture and render the
  12481. // fallback. Otherwise, don't capture and bubble to the next boundary.
  12482. var nextState = workInProgress.memoizedState;
  12483. if (nextState !== null) {
  12484. if (nextState.dehydrated !== null) {
  12485. // A dehydrated boundary always captures.
  12486. return true;
  12487. }
  12488. return false;
  12489. }
  12490. var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop.
  12491. if (props.fallback === undefined) {
  12492. return false;
  12493. } // Regular boundaries always capture.
  12494. if (props.unstable_avoidThisFallback !== true) {
  12495. return true;
  12496. } // If it's a boundary we should avoid, then we prefer to bubble up to the
  12497. // parent boundary if it is currently invisible.
  12498. if (hasInvisibleParent) {
  12499. return false;
  12500. } // If the parent is not able to handle it, we must handle it.
  12501. return true;
  12502. }
  12503. function findFirstSuspended(row) {
  12504. var node = row;
  12505. while (node !== null) {
  12506. if (node.tag === SuspenseComponent) {
  12507. var state = node.memoizedState;
  12508. if (state !== null) {
  12509. var dehydrated = state.dehydrated;
  12510. if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) {
  12511. return node;
  12512. }
  12513. }
  12514. } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't
  12515. // keep track of whether it suspended or not.
  12516. node.memoizedProps.revealOrder !== undefined) {
  12517. var didSuspend = (node.effectTag & DidCapture) !== NoEffect;
  12518. if (didSuspend) {
  12519. return node;
  12520. }
  12521. } else if (node.child !== null) {
  12522. node.child.return = node;
  12523. node = node.child;
  12524. continue;
  12525. }
  12526. if (node === row) {
  12527. return null;
  12528. }
  12529. while (node.sibling === null) {
  12530. if (node.return === null || node.return === row) {
  12531. return null;
  12532. }
  12533. node = node.return;
  12534. }
  12535. node.sibling.return = node.return;
  12536. node = node.sibling;
  12537. }
  12538. return null;
  12539. }
  12540. function createDeprecatedResponderListener(responder, props) {
  12541. var eventResponderListener = {
  12542. responder: responder,
  12543. props: props
  12544. };
  12545. {
  12546. Object.freeze(eventResponderListener);
  12547. }
  12548. return eventResponderListener;
  12549. }
  12550. var HasEffect =
  12551. /* */
  12552. 1; // Represents the phase in which the effect (not the clean-up) fires.
  12553. var Layout =
  12554. /* */
  12555. 2;
  12556. var Passive$1 =
  12557. /* */
  12558. 4;
  12559. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher,
  12560. ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
  12561. var didWarnAboutMismatchedHooksForComponent;
  12562. {
  12563. didWarnAboutMismatchedHooksForComponent = new Set();
  12564. }
  12565. // These are set right before calling the component.
  12566. var renderExpirationTime = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from
  12567. // the work-in-progress hook.
  12568. var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The
  12569. // current hook list is the list that belongs to the current fiber. The
  12570. // work-in-progress hook list is a new list that will be added to the
  12571. // work-in-progress fiber.
  12572. var currentHook = null;
  12573. var workInProgressHook = null; // Whether an update was scheduled at any point during the render phase. This
  12574. // does not get reset if we do another render pass; only when we're completely
  12575. // finished evaluating this component. This is an optimization so we know
  12576. // whether we need to clear render phase updates after a throw.
  12577. var didScheduleRenderPhaseUpdate = false;
  12578. var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook
  12579. var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders.
  12580. // The list stores the order of hooks used during the initial render (mount).
  12581. // Subsequent renders (updates) reference this list.
  12582. var hookTypesDev = null;
  12583. var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore
  12584. // the dependencies for Hooks that need them (e.g. useEffect or useMemo).
  12585. // When true, such Hooks will always be "remounted". Only used during hot reload.
  12586. var ignorePreviousDependencies = false;
  12587. function mountHookTypesDev() {
  12588. {
  12589. var hookName = currentHookNameInDev;
  12590. if (hookTypesDev === null) {
  12591. hookTypesDev = [hookName];
  12592. } else {
  12593. hookTypesDev.push(hookName);
  12594. }
  12595. }
  12596. }
  12597. function updateHookTypesDev() {
  12598. {
  12599. var hookName = currentHookNameInDev;
  12600. if (hookTypesDev !== null) {
  12601. hookTypesUpdateIndexDev++;
  12602. if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
  12603. warnOnHookMismatchInDev(hookName);
  12604. }
  12605. }
  12606. }
  12607. }
  12608. function checkDepsAreArrayDev(deps) {
  12609. {
  12610. if (deps !== undefined && deps !== null && !Array.isArray(deps)) {
  12611. // Verify deps, but only on mount to avoid extra checks.
  12612. // It's unlikely their type would change as usually you define them inline.
  12613. error('%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps);
  12614. }
  12615. }
  12616. }
  12617. function warnOnHookMismatchInDev(currentHookName) {
  12618. {
  12619. var componentName = getComponentName(currentlyRenderingFiber$1.type);
  12620. if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
  12621. didWarnAboutMismatchedHooksForComponent.add(componentName);
  12622. if (hookTypesDev !== null) {
  12623. var table = '';
  12624. var secondColumnStart = 30;
  12625. for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
  12626. var oldHookName = hookTypesDev[i];
  12627. var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
  12628. var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up
  12629. // lol @ IE not supporting String#repeat
  12630. while (row.length < secondColumnStart) {
  12631. row += ' ';
  12632. }
  12633. row += newHookName + '\n';
  12634. table += row;
  12635. }
  12636. error('React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
  12637. }
  12638. }
  12639. }
  12640. }
  12641. function throwInvalidHookError() {
  12642. {
  12643. {
  12644. throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." );
  12645. }
  12646. }
  12647. }
  12648. function areHookInputsEqual(nextDeps, prevDeps) {
  12649. {
  12650. if (ignorePreviousDependencies) {
  12651. // Only true when this component is being hot reloaded.
  12652. return false;
  12653. }
  12654. }
  12655. if (prevDeps === null) {
  12656. {
  12657. error('%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
  12658. }
  12659. return false;
  12660. }
  12661. {
  12662. // Don't bother comparing lengths in prod because these arrays should be
  12663. // passed inline.
  12664. if (nextDeps.length !== prevDeps.length) {
  12665. error('The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + prevDeps.join(', ') + "]", "[" + nextDeps.join(', ') + "]");
  12666. }
  12667. }
  12668. for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
  12669. if (objectIs(nextDeps[i], prevDeps[i])) {
  12670. continue;
  12671. }
  12672. return false;
  12673. }
  12674. return true;
  12675. }
  12676. function renderWithHooks(current, workInProgress, Component, props, secondArg, nextRenderExpirationTime) {
  12677. renderExpirationTime = nextRenderExpirationTime;
  12678. currentlyRenderingFiber$1 = workInProgress;
  12679. {
  12680. hookTypesDev = current !== null ? current._debugHookTypes : null;
  12681. hookTypesUpdateIndexDev = -1; // Used for hot reloading:
  12682. ignorePreviousDependencies = current !== null && current.type !== workInProgress.type;
  12683. }
  12684. workInProgress.memoizedState = null;
  12685. workInProgress.updateQueue = null;
  12686. workInProgress.expirationTime = NoWork; // The following should have already been reset
  12687. // currentHook = null;
  12688. // workInProgressHook = null;
  12689. // didScheduleRenderPhaseUpdate = false;
  12690. // TODO Warn if no hooks are used at all during mount, then some are used during update.
  12691. // Currently we will identify the update render as a mount because memoizedState === null.
  12692. // This is tricky because it's valid for certain types of components (e.g. React.lazy)
  12693. // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used.
  12694. // Non-stateful hooks (e.g. context) don't get added to memoizedState,
  12695. // so memoizedState would be null during updates and mounts.
  12696. {
  12697. if (current !== null && current.memoizedState !== null) {
  12698. ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV;
  12699. } else if (hookTypesDev !== null) {
  12700. // This dispatcher handles an edge case where a component is updating,
  12701. // but no stateful hooks have been used.
  12702. // We want to match the production code behavior (which will use HooksDispatcherOnMount),
  12703. // but with the extra DEV validation to ensure hooks ordering hasn't changed.
  12704. // This dispatcher does that.
  12705. ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV;
  12706. } else {
  12707. ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV;
  12708. }
  12709. }
  12710. var children = Component(props, secondArg); // Check if there was a render phase update
  12711. if (workInProgress.expirationTime === renderExpirationTime) {
  12712. // Keep rendering in a loop for as long as render phase updates continue to
  12713. // be scheduled. Use a counter to prevent infinite loops.
  12714. var numberOfReRenders = 0;
  12715. do {
  12716. workInProgress.expirationTime = NoWork;
  12717. if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
  12718. {
  12719. throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." );
  12720. }
  12721. }
  12722. numberOfReRenders += 1;
  12723. {
  12724. // Even when hot reloading, allow dependencies to stabilize
  12725. // after first render to prevent infinite render phase updates.
  12726. ignorePreviousDependencies = false;
  12727. } // Start over from the beginning of the list
  12728. currentHook = null;
  12729. workInProgressHook = null;
  12730. workInProgress.updateQueue = null;
  12731. {
  12732. // Also validate hook order for cascading updates.
  12733. hookTypesUpdateIndexDev = -1;
  12734. }
  12735. ReactCurrentDispatcher.current = HooksDispatcherOnRerenderInDEV ;
  12736. children = Component(props, secondArg);
  12737. } while (workInProgress.expirationTime === renderExpirationTime);
  12738. } // We can assume the previous dispatcher is always this one, since we set it
  12739. // at the beginning of the render phase and there's no re-entrancy.
  12740. ReactCurrentDispatcher.current = ContextOnlyDispatcher;
  12741. {
  12742. workInProgress._debugHookTypes = hookTypesDev;
  12743. } // This check uses currentHook so that it works the same in DEV and prod bundles.
  12744. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
  12745. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
  12746. renderExpirationTime = NoWork;
  12747. currentlyRenderingFiber$1 = null;
  12748. currentHook = null;
  12749. workInProgressHook = null;
  12750. {
  12751. currentHookNameInDev = null;
  12752. hookTypesDev = null;
  12753. hookTypesUpdateIndexDev = -1;
  12754. }
  12755. didScheduleRenderPhaseUpdate = false;
  12756. if (!!didRenderTooFewHooks) {
  12757. {
  12758. throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." );
  12759. }
  12760. }
  12761. return children;
  12762. }
  12763. function bailoutHooks(current, workInProgress, expirationTime) {
  12764. workInProgress.updateQueue = current.updateQueue;
  12765. workInProgress.effectTag &= ~(Passive | Update);
  12766. if (current.expirationTime <= expirationTime) {
  12767. current.expirationTime = NoWork;
  12768. }
  12769. }
  12770. function resetHooksAfterThrow() {
  12771. // We can assume the previous dispatcher is always this one, since we set it
  12772. // at the beginning of the render phase and there's no re-entrancy.
  12773. ReactCurrentDispatcher.current = ContextOnlyDispatcher;
  12774. if (didScheduleRenderPhaseUpdate) {
  12775. // There were render phase updates. These are only valid for this render
  12776. // phase, which we are now aborting. Remove the updates from the queues so
  12777. // they do not persist to the next render. Do not remove updates from hooks
  12778. // that weren't processed.
  12779. //
  12780. // Only reset the updates from the queue if it has a clone. If it does
  12781. // not have a clone, that means it wasn't processed, and the updates were
  12782. // scheduled before we entered the render phase.
  12783. var hook = currentlyRenderingFiber$1.memoizedState;
  12784. while (hook !== null) {
  12785. var queue = hook.queue;
  12786. if (queue !== null) {
  12787. queue.pending = null;
  12788. }
  12789. hook = hook.next;
  12790. }
  12791. }
  12792. renderExpirationTime = NoWork;
  12793. currentlyRenderingFiber$1 = null;
  12794. currentHook = null;
  12795. workInProgressHook = null;
  12796. {
  12797. hookTypesDev = null;
  12798. hookTypesUpdateIndexDev = -1;
  12799. currentHookNameInDev = null;
  12800. }
  12801. didScheduleRenderPhaseUpdate = false;
  12802. }
  12803. function mountWorkInProgressHook() {
  12804. var hook = {
  12805. memoizedState: null,
  12806. baseState: null,
  12807. baseQueue: null,
  12808. queue: null,
  12809. next: null
  12810. };
  12811. if (workInProgressHook === null) {
  12812. // This is the first hook in the list
  12813. currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook;
  12814. } else {
  12815. // Append to the end of the list
  12816. workInProgressHook = workInProgressHook.next = hook;
  12817. }
  12818. return workInProgressHook;
  12819. }
  12820. function updateWorkInProgressHook() {
  12821. // This function is used both for updates and for re-renders triggered by a
  12822. // render phase update. It assumes there is either a current hook we can
  12823. // clone, or a work-in-progress hook from a previous render pass that we can
  12824. // use as a base. When we reach the end of the base list, we must switch to
  12825. // the dispatcher used for mounts.
  12826. var nextCurrentHook;
  12827. if (currentHook === null) {
  12828. var current = currentlyRenderingFiber$1.alternate;
  12829. if (current !== null) {
  12830. nextCurrentHook = current.memoizedState;
  12831. } else {
  12832. nextCurrentHook = null;
  12833. }
  12834. } else {
  12835. nextCurrentHook = currentHook.next;
  12836. }
  12837. var nextWorkInProgressHook;
  12838. if (workInProgressHook === null) {
  12839. nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState;
  12840. } else {
  12841. nextWorkInProgressHook = workInProgressHook.next;
  12842. }
  12843. if (nextWorkInProgressHook !== null) {
  12844. // There's already a work-in-progress. Reuse it.
  12845. workInProgressHook = nextWorkInProgressHook;
  12846. nextWorkInProgressHook = workInProgressHook.next;
  12847. currentHook = nextCurrentHook;
  12848. } else {
  12849. // Clone from the current hook.
  12850. if (!(nextCurrentHook !== null)) {
  12851. {
  12852. throw Error( "Rendered more hooks than during the previous render." );
  12853. }
  12854. }
  12855. currentHook = nextCurrentHook;
  12856. var newHook = {
  12857. memoizedState: currentHook.memoizedState,
  12858. baseState: currentHook.baseState,
  12859. baseQueue: currentHook.baseQueue,
  12860. queue: currentHook.queue,
  12861. next: null
  12862. };
  12863. if (workInProgressHook === null) {
  12864. // This is the first hook in the list.
  12865. currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook;
  12866. } else {
  12867. // Append to the end of the list.
  12868. workInProgressHook = workInProgressHook.next = newHook;
  12869. }
  12870. }
  12871. return workInProgressHook;
  12872. }
  12873. function createFunctionComponentUpdateQueue() {
  12874. return {
  12875. lastEffect: null
  12876. };
  12877. }
  12878. function basicStateReducer(state, action) {
  12879. // $FlowFixMe: Flow doesn't like mixed types
  12880. return typeof action === 'function' ? action(state) : action;
  12881. }
  12882. function mountReducer(reducer, initialArg, init) {
  12883. var hook = mountWorkInProgressHook();
  12884. var initialState;
  12885. if (init !== undefined) {
  12886. initialState = init(initialArg);
  12887. } else {
  12888. initialState = initialArg;
  12889. }
  12890. hook.memoizedState = hook.baseState = initialState;
  12891. var queue = hook.queue = {
  12892. pending: null,
  12893. dispatch: null,
  12894. lastRenderedReducer: reducer,
  12895. lastRenderedState: initialState
  12896. };
  12897. var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue);
  12898. return [hook.memoizedState, dispatch];
  12899. }
  12900. function updateReducer(reducer, initialArg, init) {
  12901. var hook = updateWorkInProgressHook();
  12902. var queue = hook.queue;
  12903. if (!(queue !== null)) {
  12904. {
  12905. throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." );
  12906. }
  12907. }
  12908. queue.lastRenderedReducer = reducer;
  12909. var current = currentHook; // The last rebase update that is NOT part of the base state.
  12910. var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet.
  12911. var pendingQueue = queue.pending;
  12912. if (pendingQueue !== null) {
  12913. // We have new updates that haven't been processed yet.
  12914. // We'll add them to the base queue.
  12915. if (baseQueue !== null) {
  12916. // Merge the pending queue and the base queue.
  12917. var baseFirst = baseQueue.next;
  12918. var pendingFirst = pendingQueue.next;
  12919. baseQueue.next = pendingFirst;
  12920. pendingQueue.next = baseFirst;
  12921. }
  12922. current.baseQueue = baseQueue = pendingQueue;
  12923. queue.pending = null;
  12924. }
  12925. if (baseQueue !== null) {
  12926. // We have a queue to process.
  12927. var first = baseQueue.next;
  12928. var newState = current.baseState;
  12929. var newBaseState = null;
  12930. var newBaseQueueFirst = null;
  12931. var newBaseQueueLast = null;
  12932. var update = first;
  12933. do {
  12934. var updateExpirationTime = update.expirationTime;
  12935. if (updateExpirationTime < renderExpirationTime) {
  12936. // Priority is insufficient. Skip this update. If this is the first
  12937. // skipped update, the previous update/state is the new base
  12938. // update/state.
  12939. var clone = {
  12940. expirationTime: update.expirationTime,
  12941. suspenseConfig: update.suspenseConfig,
  12942. action: update.action,
  12943. eagerReducer: update.eagerReducer,
  12944. eagerState: update.eagerState,
  12945. next: null
  12946. };
  12947. if (newBaseQueueLast === null) {
  12948. newBaseQueueFirst = newBaseQueueLast = clone;
  12949. newBaseState = newState;
  12950. } else {
  12951. newBaseQueueLast = newBaseQueueLast.next = clone;
  12952. } // Update the remaining priority in the queue.
  12953. if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) {
  12954. currentlyRenderingFiber$1.expirationTime = updateExpirationTime;
  12955. markUnprocessedUpdateTime(updateExpirationTime);
  12956. }
  12957. } else {
  12958. // This update does have sufficient priority.
  12959. if (newBaseQueueLast !== null) {
  12960. var _clone = {
  12961. expirationTime: Sync,
  12962. // This update is going to be committed so we never want uncommit it.
  12963. suspenseConfig: update.suspenseConfig,
  12964. action: update.action,
  12965. eagerReducer: update.eagerReducer,
  12966. eagerState: update.eagerState,
  12967. next: null
  12968. };
  12969. newBaseQueueLast = newBaseQueueLast.next = _clone;
  12970. } // Mark the event time of this update as relevant to this render pass.
  12971. // TODO: This should ideally use the true event time of this update rather than
  12972. // its priority which is a derived and not reverseable value.
  12973. // TODO: We should skip this update if it was already committed but currently
  12974. // we have no way of detecting the difference between a committed and suspended
  12975. // update here.
  12976. markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process this update.
  12977. if (update.eagerReducer === reducer) {
  12978. // If this update was processed eagerly, and its reducer matches the
  12979. // current reducer, we can use the eagerly computed state.
  12980. newState = update.eagerState;
  12981. } else {
  12982. var action = update.action;
  12983. newState = reducer(newState, action);
  12984. }
  12985. }
  12986. update = update.next;
  12987. } while (update !== null && update !== first);
  12988. if (newBaseQueueLast === null) {
  12989. newBaseState = newState;
  12990. } else {
  12991. newBaseQueueLast.next = newBaseQueueFirst;
  12992. } // Mark that the fiber performed work, but only if the new state is
  12993. // different from the current state.
  12994. if (!objectIs(newState, hook.memoizedState)) {
  12995. markWorkInProgressReceivedUpdate();
  12996. }
  12997. hook.memoizedState = newState;
  12998. hook.baseState = newBaseState;
  12999. hook.baseQueue = newBaseQueueLast;
  13000. queue.lastRenderedState = newState;
  13001. }
  13002. var dispatch = queue.dispatch;
  13003. return [hook.memoizedState, dispatch];
  13004. }
  13005. function rerenderReducer(reducer, initialArg, init) {
  13006. var hook = updateWorkInProgressHook();
  13007. var queue = hook.queue;
  13008. if (!(queue !== null)) {
  13009. {
  13010. throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." );
  13011. }
  13012. }
  13013. queue.lastRenderedReducer = reducer; // This is a re-render. Apply the new render phase updates to the previous
  13014. // work-in-progress hook.
  13015. var dispatch = queue.dispatch;
  13016. var lastRenderPhaseUpdate = queue.pending;
  13017. var newState = hook.memoizedState;
  13018. if (lastRenderPhaseUpdate !== null) {
  13019. // The queue doesn't persist past this render pass.
  13020. queue.pending = null;
  13021. var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next;
  13022. var update = firstRenderPhaseUpdate;
  13023. do {
  13024. // Process this render phase update. We don't have to check the
  13025. // priority because it will always be the same as the current
  13026. // render's.
  13027. var action = update.action;
  13028. newState = reducer(newState, action);
  13029. update = update.next;
  13030. } while (update !== firstRenderPhaseUpdate); // Mark that the fiber performed work, but only if the new state is
  13031. // different from the current state.
  13032. if (!objectIs(newState, hook.memoizedState)) {
  13033. markWorkInProgressReceivedUpdate();
  13034. }
  13035. hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to
  13036. // the base state unless the queue is empty.
  13037. // TODO: Not sure if this is the desired semantics, but it's what we
  13038. // do for gDSFP. I can't remember why.
  13039. if (hook.baseQueue === null) {
  13040. hook.baseState = newState;
  13041. }
  13042. queue.lastRenderedState = newState;
  13043. }
  13044. return [newState, dispatch];
  13045. }
  13046. function mountState(initialState) {
  13047. var hook = mountWorkInProgressHook();
  13048. if (typeof initialState === 'function') {
  13049. // $FlowFixMe: Flow doesn't like mixed types
  13050. initialState = initialState();
  13051. }
  13052. hook.memoizedState = hook.baseState = initialState;
  13053. var queue = hook.queue = {
  13054. pending: null,
  13055. dispatch: null,
  13056. lastRenderedReducer: basicStateReducer,
  13057. lastRenderedState: initialState
  13058. };
  13059. var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue);
  13060. return [hook.memoizedState, dispatch];
  13061. }
  13062. function updateState(initialState) {
  13063. return updateReducer(basicStateReducer);
  13064. }
  13065. function rerenderState(initialState) {
  13066. return rerenderReducer(basicStateReducer);
  13067. }
  13068. function pushEffect(tag, create, destroy, deps) {
  13069. var effect = {
  13070. tag: tag,
  13071. create: create,
  13072. destroy: destroy,
  13073. deps: deps,
  13074. // Circular
  13075. next: null
  13076. };
  13077. var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue;
  13078. if (componentUpdateQueue === null) {
  13079. componentUpdateQueue = createFunctionComponentUpdateQueue();
  13080. currentlyRenderingFiber$1.updateQueue = componentUpdateQueue;
  13081. componentUpdateQueue.lastEffect = effect.next = effect;
  13082. } else {
  13083. var lastEffect = componentUpdateQueue.lastEffect;
  13084. if (lastEffect === null) {
  13085. componentUpdateQueue.lastEffect = effect.next = effect;
  13086. } else {
  13087. var firstEffect = lastEffect.next;
  13088. lastEffect.next = effect;
  13089. effect.next = firstEffect;
  13090. componentUpdateQueue.lastEffect = effect;
  13091. }
  13092. }
  13093. return effect;
  13094. }
  13095. function mountRef(initialValue) {
  13096. var hook = mountWorkInProgressHook();
  13097. var ref = {
  13098. current: initialValue
  13099. };
  13100. {
  13101. Object.seal(ref);
  13102. }
  13103. hook.memoizedState = ref;
  13104. return ref;
  13105. }
  13106. function updateRef(initialValue) {
  13107. var hook = updateWorkInProgressHook();
  13108. return hook.memoizedState;
  13109. }
  13110. function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
  13111. var hook = mountWorkInProgressHook();
  13112. var nextDeps = deps === undefined ? null : deps;
  13113. currentlyRenderingFiber$1.effectTag |= fiberEffectTag;
  13114. hook.memoizedState = pushEffect(HasEffect | hookEffectTag, create, undefined, nextDeps);
  13115. }
  13116. function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
  13117. var hook = updateWorkInProgressHook();
  13118. var nextDeps = deps === undefined ? null : deps;
  13119. var destroy = undefined;
  13120. if (currentHook !== null) {
  13121. var prevEffect = currentHook.memoizedState;
  13122. destroy = prevEffect.destroy;
  13123. if (nextDeps !== null) {
  13124. var prevDeps = prevEffect.deps;
  13125. if (areHookInputsEqual(nextDeps, prevDeps)) {
  13126. pushEffect(hookEffectTag, create, destroy, nextDeps);
  13127. return;
  13128. }
  13129. }
  13130. }
  13131. currentlyRenderingFiber$1.effectTag |= fiberEffectTag;
  13132. hook.memoizedState = pushEffect(HasEffect | hookEffectTag, create, destroy, nextDeps);
  13133. }
  13134. function mountEffect(create, deps) {
  13135. {
  13136. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  13137. if ('undefined' !== typeof jest) {
  13138. warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
  13139. }
  13140. }
  13141. return mountEffectImpl(Update | Passive, Passive$1, create, deps);
  13142. }
  13143. function updateEffect(create, deps) {
  13144. {
  13145. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  13146. if ('undefined' !== typeof jest) {
  13147. warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
  13148. }
  13149. }
  13150. return updateEffectImpl(Update | Passive, Passive$1, create, deps);
  13151. }
  13152. function mountLayoutEffect(create, deps) {
  13153. return mountEffectImpl(Update, Layout, create, deps);
  13154. }
  13155. function updateLayoutEffect(create, deps) {
  13156. return updateEffectImpl(Update, Layout, create, deps);
  13157. }
  13158. function imperativeHandleEffect(create, ref) {
  13159. if (typeof ref === 'function') {
  13160. var refCallback = ref;
  13161. var _inst = create();
  13162. refCallback(_inst);
  13163. return function () {
  13164. refCallback(null);
  13165. };
  13166. } else if (ref !== null && ref !== undefined) {
  13167. var refObject = ref;
  13168. {
  13169. if (!refObject.hasOwnProperty('current')) {
  13170. error('Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}');
  13171. }
  13172. }
  13173. var _inst2 = create();
  13174. refObject.current = _inst2;
  13175. return function () {
  13176. refObject.current = null;
  13177. };
  13178. }
  13179. }
  13180. function mountImperativeHandle(ref, create, deps) {
  13181. {
  13182. if (typeof create !== 'function') {
  13183. error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null');
  13184. }
  13185. } // TODO: If deps are provided, should we skip comparing the ref itself?
  13186. var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
  13187. return mountEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
  13188. }
  13189. function updateImperativeHandle(ref, create, deps) {
  13190. {
  13191. if (typeof create !== 'function') {
  13192. error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null');
  13193. }
  13194. } // TODO: If deps are provided, should we skip comparing the ref itself?
  13195. var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
  13196. return updateEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
  13197. }
  13198. function mountDebugValue(value, formatterFn) {// This hook is normally a no-op.
  13199. // The react-debug-hooks package injects its own implementation
  13200. // so that e.g. DevTools can display custom hook values.
  13201. }
  13202. var updateDebugValue = mountDebugValue;
  13203. function mountCallback(callback, deps) {
  13204. var hook = mountWorkInProgressHook();
  13205. var nextDeps = deps === undefined ? null : deps;
  13206. hook.memoizedState = [callback, nextDeps];
  13207. return callback;
  13208. }
  13209. function updateCallback(callback, deps) {
  13210. var hook = updateWorkInProgressHook();
  13211. var nextDeps = deps === undefined ? null : deps;
  13212. var prevState = hook.memoizedState;
  13213. if (prevState !== null) {
  13214. if (nextDeps !== null) {
  13215. var prevDeps = prevState[1];
  13216. if (areHookInputsEqual(nextDeps, prevDeps)) {
  13217. return prevState[0];
  13218. }
  13219. }
  13220. }
  13221. hook.memoizedState = [callback, nextDeps];
  13222. return callback;
  13223. }
  13224. function mountMemo(nextCreate, deps) {
  13225. var hook = mountWorkInProgressHook();
  13226. var nextDeps = deps === undefined ? null : deps;
  13227. var nextValue = nextCreate();
  13228. hook.memoizedState = [nextValue, nextDeps];
  13229. return nextValue;
  13230. }
  13231. function updateMemo(nextCreate, deps) {
  13232. var hook = updateWorkInProgressHook();
  13233. var nextDeps = deps === undefined ? null : deps;
  13234. var prevState = hook.memoizedState;
  13235. if (prevState !== null) {
  13236. // Assume these are defined. If they're not, areHookInputsEqual will warn.
  13237. if (nextDeps !== null) {
  13238. var prevDeps = prevState[1];
  13239. if (areHookInputsEqual(nextDeps, prevDeps)) {
  13240. return prevState[0];
  13241. }
  13242. }
  13243. }
  13244. var nextValue = nextCreate();
  13245. hook.memoizedState = [nextValue, nextDeps];
  13246. return nextValue;
  13247. }
  13248. function mountDeferredValue(value, config) {
  13249. var _mountState = mountState(value),
  13250. prevValue = _mountState[0],
  13251. setValue = _mountState[1];
  13252. mountEffect(function () {
  13253. var previousConfig = ReactCurrentBatchConfig$1.suspense;
  13254. ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
  13255. try {
  13256. setValue(value);
  13257. } finally {
  13258. ReactCurrentBatchConfig$1.suspense = previousConfig;
  13259. }
  13260. }, [value, config]);
  13261. return prevValue;
  13262. }
  13263. function updateDeferredValue(value, config) {
  13264. var _updateState = updateState(),
  13265. prevValue = _updateState[0],
  13266. setValue = _updateState[1];
  13267. updateEffect(function () {
  13268. var previousConfig = ReactCurrentBatchConfig$1.suspense;
  13269. ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
  13270. try {
  13271. setValue(value);
  13272. } finally {
  13273. ReactCurrentBatchConfig$1.suspense = previousConfig;
  13274. }
  13275. }, [value, config]);
  13276. return prevValue;
  13277. }
  13278. function rerenderDeferredValue(value, config) {
  13279. var _rerenderState = rerenderState(),
  13280. prevValue = _rerenderState[0],
  13281. setValue = _rerenderState[1];
  13282. updateEffect(function () {
  13283. var previousConfig = ReactCurrentBatchConfig$1.suspense;
  13284. ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
  13285. try {
  13286. setValue(value);
  13287. } finally {
  13288. ReactCurrentBatchConfig$1.suspense = previousConfig;
  13289. }
  13290. }, [value, config]);
  13291. return prevValue;
  13292. }
  13293. function startTransition(setPending, config, callback) {
  13294. var priorityLevel = getCurrentPriorityLevel();
  13295. runWithPriority$1(priorityLevel < UserBlockingPriority$1 ? UserBlockingPriority$1 : priorityLevel, function () {
  13296. setPending(true);
  13297. });
  13298. runWithPriority$1(priorityLevel > NormalPriority ? NormalPriority : priorityLevel, function () {
  13299. var previousConfig = ReactCurrentBatchConfig$1.suspense;
  13300. ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
  13301. try {
  13302. setPending(false);
  13303. callback();
  13304. } finally {
  13305. ReactCurrentBatchConfig$1.suspense = previousConfig;
  13306. }
  13307. });
  13308. }
  13309. function mountTransition(config) {
  13310. var _mountState2 = mountState(false),
  13311. isPending = _mountState2[0],
  13312. setPending = _mountState2[1];
  13313. var start = mountCallback(startTransition.bind(null, setPending, config), [setPending, config]);
  13314. return [start, isPending];
  13315. }
  13316. function updateTransition(config) {
  13317. var _updateState2 = updateState(),
  13318. isPending = _updateState2[0],
  13319. setPending = _updateState2[1];
  13320. var start = updateCallback(startTransition.bind(null, setPending, config), [setPending, config]);
  13321. return [start, isPending];
  13322. }
  13323. function rerenderTransition(config) {
  13324. var _rerenderState2 = rerenderState(),
  13325. isPending = _rerenderState2[0],
  13326. setPending = _rerenderState2[1];
  13327. var start = updateCallback(startTransition.bind(null, setPending, config), [setPending, config]);
  13328. return [start, isPending];
  13329. }
  13330. function dispatchAction(fiber, queue, action) {
  13331. {
  13332. if (typeof arguments[3] === 'function') {
  13333. error("State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().');
  13334. }
  13335. }
  13336. var currentTime = requestCurrentTimeForUpdate();
  13337. var suspenseConfig = requestCurrentSuspenseConfig();
  13338. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  13339. var update = {
  13340. expirationTime: expirationTime,
  13341. suspenseConfig: suspenseConfig,
  13342. action: action,
  13343. eagerReducer: null,
  13344. eagerState: null,
  13345. next: null
  13346. };
  13347. {
  13348. update.priority = getCurrentPriorityLevel();
  13349. } // Append the update to the end of the list.
  13350. var pending = queue.pending;
  13351. if (pending === null) {
  13352. // This is the first update. Create a circular list.
  13353. update.next = update;
  13354. } else {
  13355. update.next = pending.next;
  13356. pending.next = update;
  13357. }
  13358. queue.pending = update;
  13359. var alternate = fiber.alternate;
  13360. if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
  13361. // This is a render phase update. Stash it in a lazily-created map of
  13362. // queue -> linked list of updates. After this render pass, we'll restart
  13363. // and apply the stashed updates on top of the work-in-progress hook.
  13364. didScheduleRenderPhaseUpdate = true;
  13365. update.expirationTime = renderExpirationTime;
  13366. currentlyRenderingFiber$1.expirationTime = renderExpirationTime;
  13367. } else {
  13368. if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) {
  13369. // The queue is currently empty, which means we can eagerly compute the
  13370. // next state before entering the render phase. If the new state is the
  13371. // same as the current state, we may be able to bail out entirely.
  13372. var lastRenderedReducer = queue.lastRenderedReducer;
  13373. if (lastRenderedReducer !== null) {
  13374. var prevDispatcher;
  13375. {
  13376. prevDispatcher = ReactCurrentDispatcher.current;
  13377. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13378. }
  13379. try {
  13380. var currentState = queue.lastRenderedState;
  13381. var eagerState = lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute
  13382. // it, on the update object. If the reducer hasn't changed by the
  13383. // time we enter the render phase, then the eager state can be used
  13384. // without calling the reducer again.
  13385. update.eagerReducer = lastRenderedReducer;
  13386. update.eagerState = eagerState;
  13387. if (objectIs(eagerState, currentState)) {
  13388. // Fast path. We can bail out without scheduling React to re-render.
  13389. // It's still possible that we'll need to rebase this update later,
  13390. // if the component re-renders for a different reason and by that
  13391. // time the reducer has changed.
  13392. return;
  13393. }
  13394. } catch (error) {// Suppress the error. It will throw again in the render phase.
  13395. } finally {
  13396. {
  13397. ReactCurrentDispatcher.current = prevDispatcher;
  13398. }
  13399. }
  13400. }
  13401. }
  13402. {
  13403. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  13404. if ('undefined' !== typeof jest) {
  13405. warnIfNotScopedWithMatchingAct(fiber);
  13406. warnIfNotCurrentlyActingUpdatesInDev(fiber);
  13407. }
  13408. }
  13409. scheduleWork(fiber, expirationTime);
  13410. }
  13411. }
  13412. var ContextOnlyDispatcher = {
  13413. readContext: readContext,
  13414. useCallback: throwInvalidHookError,
  13415. useContext: throwInvalidHookError,
  13416. useEffect: throwInvalidHookError,
  13417. useImperativeHandle: throwInvalidHookError,
  13418. useLayoutEffect: throwInvalidHookError,
  13419. useMemo: throwInvalidHookError,
  13420. useReducer: throwInvalidHookError,
  13421. useRef: throwInvalidHookError,
  13422. useState: throwInvalidHookError,
  13423. useDebugValue: throwInvalidHookError,
  13424. useResponder: throwInvalidHookError,
  13425. useDeferredValue: throwInvalidHookError,
  13426. useTransition: throwInvalidHookError
  13427. };
  13428. var HooksDispatcherOnMountInDEV = null;
  13429. var HooksDispatcherOnMountWithHookTypesInDEV = null;
  13430. var HooksDispatcherOnUpdateInDEV = null;
  13431. var HooksDispatcherOnRerenderInDEV = null;
  13432. var InvalidNestedHooksDispatcherOnMountInDEV = null;
  13433. var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
  13434. var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
  13435. {
  13436. var warnInvalidContextAccess = function () {
  13437. error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
  13438. };
  13439. var warnInvalidHookAccess = function () {
  13440. error('Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks');
  13441. };
  13442. HooksDispatcherOnMountInDEV = {
  13443. readContext: function (context, observedBits) {
  13444. return readContext(context, observedBits);
  13445. },
  13446. useCallback: function (callback, deps) {
  13447. currentHookNameInDev = 'useCallback';
  13448. mountHookTypesDev();
  13449. checkDepsAreArrayDev(deps);
  13450. return mountCallback(callback, deps);
  13451. },
  13452. useContext: function (context, observedBits) {
  13453. currentHookNameInDev = 'useContext';
  13454. mountHookTypesDev();
  13455. return readContext(context, observedBits);
  13456. },
  13457. useEffect: function (create, deps) {
  13458. currentHookNameInDev = 'useEffect';
  13459. mountHookTypesDev();
  13460. checkDepsAreArrayDev(deps);
  13461. return mountEffect(create, deps);
  13462. },
  13463. useImperativeHandle: function (ref, create, deps) {
  13464. currentHookNameInDev = 'useImperativeHandle';
  13465. mountHookTypesDev();
  13466. checkDepsAreArrayDev(deps);
  13467. return mountImperativeHandle(ref, create, deps);
  13468. },
  13469. useLayoutEffect: function (create, deps) {
  13470. currentHookNameInDev = 'useLayoutEffect';
  13471. mountHookTypesDev();
  13472. checkDepsAreArrayDev(deps);
  13473. return mountLayoutEffect(create, deps);
  13474. },
  13475. useMemo: function (create, deps) {
  13476. currentHookNameInDev = 'useMemo';
  13477. mountHookTypesDev();
  13478. checkDepsAreArrayDev(deps);
  13479. var prevDispatcher = ReactCurrentDispatcher.current;
  13480. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13481. try {
  13482. return mountMemo(create, deps);
  13483. } finally {
  13484. ReactCurrentDispatcher.current = prevDispatcher;
  13485. }
  13486. },
  13487. useReducer: function (reducer, initialArg, init) {
  13488. currentHookNameInDev = 'useReducer';
  13489. mountHookTypesDev();
  13490. var prevDispatcher = ReactCurrentDispatcher.current;
  13491. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13492. try {
  13493. return mountReducer(reducer, initialArg, init);
  13494. } finally {
  13495. ReactCurrentDispatcher.current = prevDispatcher;
  13496. }
  13497. },
  13498. useRef: function (initialValue) {
  13499. currentHookNameInDev = 'useRef';
  13500. mountHookTypesDev();
  13501. return mountRef(initialValue);
  13502. },
  13503. useState: function (initialState) {
  13504. currentHookNameInDev = 'useState';
  13505. mountHookTypesDev();
  13506. var prevDispatcher = ReactCurrentDispatcher.current;
  13507. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13508. try {
  13509. return mountState(initialState);
  13510. } finally {
  13511. ReactCurrentDispatcher.current = prevDispatcher;
  13512. }
  13513. },
  13514. useDebugValue: function (value, formatterFn) {
  13515. currentHookNameInDev = 'useDebugValue';
  13516. mountHookTypesDev();
  13517. return mountDebugValue();
  13518. },
  13519. useResponder: function (responder, props) {
  13520. currentHookNameInDev = 'useResponder';
  13521. mountHookTypesDev();
  13522. return createDeprecatedResponderListener(responder, props);
  13523. },
  13524. useDeferredValue: function (value, config) {
  13525. currentHookNameInDev = 'useDeferredValue';
  13526. mountHookTypesDev();
  13527. return mountDeferredValue(value, config);
  13528. },
  13529. useTransition: function (config) {
  13530. currentHookNameInDev = 'useTransition';
  13531. mountHookTypesDev();
  13532. return mountTransition(config);
  13533. }
  13534. };
  13535. HooksDispatcherOnMountWithHookTypesInDEV = {
  13536. readContext: function (context, observedBits) {
  13537. return readContext(context, observedBits);
  13538. },
  13539. useCallback: function (callback, deps) {
  13540. currentHookNameInDev = 'useCallback';
  13541. updateHookTypesDev();
  13542. return mountCallback(callback, deps);
  13543. },
  13544. useContext: function (context, observedBits) {
  13545. currentHookNameInDev = 'useContext';
  13546. updateHookTypesDev();
  13547. return readContext(context, observedBits);
  13548. },
  13549. useEffect: function (create, deps) {
  13550. currentHookNameInDev = 'useEffect';
  13551. updateHookTypesDev();
  13552. return mountEffect(create, deps);
  13553. },
  13554. useImperativeHandle: function (ref, create, deps) {
  13555. currentHookNameInDev = 'useImperativeHandle';
  13556. updateHookTypesDev();
  13557. return mountImperativeHandle(ref, create, deps);
  13558. },
  13559. useLayoutEffect: function (create, deps) {
  13560. currentHookNameInDev = 'useLayoutEffect';
  13561. updateHookTypesDev();
  13562. return mountLayoutEffect(create, deps);
  13563. },
  13564. useMemo: function (create, deps) {
  13565. currentHookNameInDev = 'useMemo';
  13566. updateHookTypesDev();
  13567. var prevDispatcher = ReactCurrentDispatcher.current;
  13568. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13569. try {
  13570. return mountMemo(create, deps);
  13571. } finally {
  13572. ReactCurrentDispatcher.current = prevDispatcher;
  13573. }
  13574. },
  13575. useReducer: function (reducer, initialArg, init) {
  13576. currentHookNameInDev = 'useReducer';
  13577. updateHookTypesDev();
  13578. var prevDispatcher = ReactCurrentDispatcher.current;
  13579. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13580. try {
  13581. return mountReducer(reducer, initialArg, init);
  13582. } finally {
  13583. ReactCurrentDispatcher.current = prevDispatcher;
  13584. }
  13585. },
  13586. useRef: function (initialValue) {
  13587. currentHookNameInDev = 'useRef';
  13588. updateHookTypesDev();
  13589. return mountRef(initialValue);
  13590. },
  13591. useState: function (initialState) {
  13592. currentHookNameInDev = 'useState';
  13593. updateHookTypesDev();
  13594. var prevDispatcher = ReactCurrentDispatcher.current;
  13595. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13596. try {
  13597. return mountState(initialState);
  13598. } finally {
  13599. ReactCurrentDispatcher.current = prevDispatcher;
  13600. }
  13601. },
  13602. useDebugValue: function (value, formatterFn) {
  13603. currentHookNameInDev = 'useDebugValue';
  13604. updateHookTypesDev();
  13605. return mountDebugValue();
  13606. },
  13607. useResponder: function (responder, props) {
  13608. currentHookNameInDev = 'useResponder';
  13609. updateHookTypesDev();
  13610. return createDeprecatedResponderListener(responder, props);
  13611. },
  13612. useDeferredValue: function (value, config) {
  13613. currentHookNameInDev = 'useDeferredValue';
  13614. updateHookTypesDev();
  13615. return mountDeferredValue(value, config);
  13616. },
  13617. useTransition: function (config) {
  13618. currentHookNameInDev = 'useTransition';
  13619. updateHookTypesDev();
  13620. return mountTransition(config);
  13621. }
  13622. };
  13623. HooksDispatcherOnUpdateInDEV = {
  13624. readContext: function (context, observedBits) {
  13625. return readContext(context, observedBits);
  13626. },
  13627. useCallback: function (callback, deps) {
  13628. currentHookNameInDev = 'useCallback';
  13629. updateHookTypesDev();
  13630. return updateCallback(callback, deps);
  13631. },
  13632. useContext: function (context, observedBits) {
  13633. currentHookNameInDev = 'useContext';
  13634. updateHookTypesDev();
  13635. return readContext(context, observedBits);
  13636. },
  13637. useEffect: function (create, deps) {
  13638. currentHookNameInDev = 'useEffect';
  13639. updateHookTypesDev();
  13640. return updateEffect(create, deps);
  13641. },
  13642. useImperativeHandle: function (ref, create, deps) {
  13643. currentHookNameInDev = 'useImperativeHandle';
  13644. updateHookTypesDev();
  13645. return updateImperativeHandle(ref, create, deps);
  13646. },
  13647. useLayoutEffect: function (create, deps) {
  13648. currentHookNameInDev = 'useLayoutEffect';
  13649. updateHookTypesDev();
  13650. return updateLayoutEffect(create, deps);
  13651. },
  13652. useMemo: function (create, deps) {
  13653. currentHookNameInDev = 'useMemo';
  13654. updateHookTypesDev();
  13655. var prevDispatcher = ReactCurrentDispatcher.current;
  13656. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13657. try {
  13658. return updateMemo(create, deps);
  13659. } finally {
  13660. ReactCurrentDispatcher.current = prevDispatcher;
  13661. }
  13662. },
  13663. useReducer: function (reducer, initialArg, init) {
  13664. currentHookNameInDev = 'useReducer';
  13665. updateHookTypesDev();
  13666. var prevDispatcher = ReactCurrentDispatcher.current;
  13667. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13668. try {
  13669. return updateReducer(reducer, initialArg, init);
  13670. } finally {
  13671. ReactCurrentDispatcher.current = prevDispatcher;
  13672. }
  13673. },
  13674. useRef: function (initialValue) {
  13675. currentHookNameInDev = 'useRef';
  13676. updateHookTypesDev();
  13677. return updateRef();
  13678. },
  13679. useState: function (initialState) {
  13680. currentHookNameInDev = 'useState';
  13681. updateHookTypesDev();
  13682. var prevDispatcher = ReactCurrentDispatcher.current;
  13683. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13684. try {
  13685. return updateState(initialState);
  13686. } finally {
  13687. ReactCurrentDispatcher.current = prevDispatcher;
  13688. }
  13689. },
  13690. useDebugValue: function (value, formatterFn) {
  13691. currentHookNameInDev = 'useDebugValue';
  13692. updateHookTypesDev();
  13693. return updateDebugValue();
  13694. },
  13695. useResponder: function (responder, props) {
  13696. currentHookNameInDev = 'useResponder';
  13697. updateHookTypesDev();
  13698. return createDeprecatedResponderListener(responder, props);
  13699. },
  13700. useDeferredValue: function (value, config) {
  13701. currentHookNameInDev = 'useDeferredValue';
  13702. updateHookTypesDev();
  13703. return updateDeferredValue(value, config);
  13704. },
  13705. useTransition: function (config) {
  13706. currentHookNameInDev = 'useTransition';
  13707. updateHookTypesDev();
  13708. return updateTransition(config);
  13709. }
  13710. };
  13711. HooksDispatcherOnRerenderInDEV = {
  13712. readContext: function (context, observedBits) {
  13713. return readContext(context, observedBits);
  13714. },
  13715. useCallback: function (callback, deps) {
  13716. currentHookNameInDev = 'useCallback';
  13717. updateHookTypesDev();
  13718. return updateCallback(callback, deps);
  13719. },
  13720. useContext: function (context, observedBits) {
  13721. currentHookNameInDev = 'useContext';
  13722. updateHookTypesDev();
  13723. return readContext(context, observedBits);
  13724. },
  13725. useEffect: function (create, deps) {
  13726. currentHookNameInDev = 'useEffect';
  13727. updateHookTypesDev();
  13728. return updateEffect(create, deps);
  13729. },
  13730. useImperativeHandle: function (ref, create, deps) {
  13731. currentHookNameInDev = 'useImperativeHandle';
  13732. updateHookTypesDev();
  13733. return updateImperativeHandle(ref, create, deps);
  13734. },
  13735. useLayoutEffect: function (create, deps) {
  13736. currentHookNameInDev = 'useLayoutEffect';
  13737. updateHookTypesDev();
  13738. return updateLayoutEffect(create, deps);
  13739. },
  13740. useMemo: function (create, deps) {
  13741. currentHookNameInDev = 'useMemo';
  13742. updateHookTypesDev();
  13743. var prevDispatcher = ReactCurrentDispatcher.current;
  13744. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
  13745. try {
  13746. return updateMemo(create, deps);
  13747. } finally {
  13748. ReactCurrentDispatcher.current = prevDispatcher;
  13749. }
  13750. },
  13751. useReducer: function (reducer, initialArg, init) {
  13752. currentHookNameInDev = 'useReducer';
  13753. updateHookTypesDev();
  13754. var prevDispatcher = ReactCurrentDispatcher.current;
  13755. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
  13756. try {
  13757. return rerenderReducer(reducer, initialArg, init);
  13758. } finally {
  13759. ReactCurrentDispatcher.current = prevDispatcher;
  13760. }
  13761. },
  13762. useRef: function (initialValue) {
  13763. currentHookNameInDev = 'useRef';
  13764. updateHookTypesDev();
  13765. return updateRef();
  13766. },
  13767. useState: function (initialState) {
  13768. currentHookNameInDev = 'useState';
  13769. updateHookTypesDev();
  13770. var prevDispatcher = ReactCurrentDispatcher.current;
  13771. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
  13772. try {
  13773. return rerenderState(initialState);
  13774. } finally {
  13775. ReactCurrentDispatcher.current = prevDispatcher;
  13776. }
  13777. },
  13778. useDebugValue: function (value, formatterFn) {
  13779. currentHookNameInDev = 'useDebugValue';
  13780. updateHookTypesDev();
  13781. return updateDebugValue();
  13782. },
  13783. useResponder: function (responder, props) {
  13784. currentHookNameInDev = 'useResponder';
  13785. updateHookTypesDev();
  13786. return createDeprecatedResponderListener(responder, props);
  13787. },
  13788. useDeferredValue: function (value, config) {
  13789. currentHookNameInDev = 'useDeferredValue';
  13790. updateHookTypesDev();
  13791. return rerenderDeferredValue(value, config);
  13792. },
  13793. useTransition: function (config) {
  13794. currentHookNameInDev = 'useTransition';
  13795. updateHookTypesDev();
  13796. return rerenderTransition(config);
  13797. }
  13798. };
  13799. InvalidNestedHooksDispatcherOnMountInDEV = {
  13800. readContext: function (context, observedBits) {
  13801. warnInvalidContextAccess();
  13802. return readContext(context, observedBits);
  13803. },
  13804. useCallback: function (callback, deps) {
  13805. currentHookNameInDev = 'useCallback';
  13806. warnInvalidHookAccess();
  13807. mountHookTypesDev();
  13808. return mountCallback(callback, deps);
  13809. },
  13810. useContext: function (context, observedBits) {
  13811. currentHookNameInDev = 'useContext';
  13812. warnInvalidHookAccess();
  13813. mountHookTypesDev();
  13814. return readContext(context, observedBits);
  13815. },
  13816. useEffect: function (create, deps) {
  13817. currentHookNameInDev = 'useEffect';
  13818. warnInvalidHookAccess();
  13819. mountHookTypesDev();
  13820. return mountEffect(create, deps);
  13821. },
  13822. useImperativeHandle: function (ref, create, deps) {
  13823. currentHookNameInDev = 'useImperativeHandle';
  13824. warnInvalidHookAccess();
  13825. mountHookTypesDev();
  13826. return mountImperativeHandle(ref, create, deps);
  13827. },
  13828. useLayoutEffect: function (create, deps) {
  13829. currentHookNameInDev = 'useLayoutEffect';
  13830. warnInvalidHookAccess();
  13831. mountHookTypesDev();
  13832. return mountLayoutEffect(create, deps);
  13833. },
  13834. useMemo: function (create, deps) {
  13835. currentHookNameInDev = 'useMemo';
  13836. warnInvalidHookAccess();
  13837. mountHookTypesDev();
  13838. var prevDispatcher = ReactCurrentDispatcher.current;
  13839. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13840. try {
  13841. return mountMemo(create, deps);
  13842. } finally {
  13843. ReactCurrentDispatcher.current = prevDispatcher;
  13844. }
  13845. },
  13846. useReducer: function (reducer, initialArg, init) {
  13847. currentHookNameInDev = 'useReducer';
  13848. warnInvalidHookAccess();
  13849. mountHookTypesDev();
  13850. var prevDispatcher = ReactCurrentDispatcher.current;
  13851. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13852. try {
  13853. return mountReducer(reducer, initialArg, init);
  13854. } finally {
  13855. ReactCurrentDispatcher.current = prevDispatcher;
  13856. }
  13857. },
  13858. useRef: function (initialValue) {
  13859. currentHookNameInDev = 'useRef';
  13860. warnInvalidHookAccess();
  13861. mountHookTypesDev();
  13862. return mountRef(initialValue);
  13863. },
  13864. useState: function (initialState) {
  13865. currentHookNameInDev = 'useState';
  13866. warnInvalidHookAccess();
  13867. mountHookTypesDev();
  13868. var prevDispatcher = ReactCurrentDispatcher.current;
  13869. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13870. try {
  13871. return mountState(initialState);
  13872. } finally {
  13873. ReactCurrentDispatcher.current = prevDispatcher;
  13874. }
  13875. },
  13876. useDebugValue: function (value, formatterFn) {
  13877. currentHookNameInDev = 'useDebugValue';
  13878. warnInvalidHookAccess();
  13879. mountHookTypesDev();
  13880. return mountDebugValue();
  13881. },
  13882. useResponder: function (responder, props) {
  13883. currentHookNameInDev = 'useResponder';
  13884. warnInvalidHookAccess();
  13885. mountHookTypesDev();
  13886. return createDeprecatedResponderListener(responder, props);
  13887. },
  13888. useDeferredValue: function (value, config) {
  13889. currentHookNameInDev = 'useDeferredValue';
  13890. warnInvalidHookAccess();
  13891. mountHookTypesDev();
  13892. return mountDeferredValue(value, config);
  13893. },
  13894. useTransition: function (config) {
  13895. currentHookNameInDev = 'useTransition';
  13896. warnInvalidHookAccess();
  13897. mountHookTypesDev();
  13898. return mountTransition(config);
  13899. }
  13900. };
  13901. InvalidNestedHooksDispatcherOnUpdateInDEV = {
  13902. readContext: function (context, observedBits) {
  13903. warnInvalidContextAccess();
  13904. return readContext(context, observedBits);
  13905. },
  13906. useCallback: function (callback, deps) {
  13907. currentHookNameInDev = 'useCallback';
  13908. warnInvalidHookAccess();
  13909. updateHookTypesDev();
  13910. return updateCallback(callback, deps);
  13911. },
  13912. useContext: function (context, observedBits) {
  13913. currentHookNameInDev = 'useContext';
  13914. warnInvalidHookAccess();
  13915. updateHookTypesDev();
  13916. return readContext(context, observedBits);
  13917. },
  13918. useEffect: function (create, deps) {
  13919. currentHookNameInDev = 'useEffect';
  13920. warnInvalidHookAccess();
  13921. updateHookTypesDev();
  13922. return updateEffect(create, deps);
  13923. },
  13924. useImperativeHandle: function (ref, create, deps) {
  13925. currentHookNameInDev = 'useImperativeHandle';
  13926. warnInvalidHookAccess();
  13927. updateHookTypesDev();
  13928. return updateImperativeHandle(ref, create, deps);
  13929. },
  13930. useLayoutEffect: function (create, deps) {
  13931. currentHookNameInDev = 'useLayoutEffect';
  13932. warnInvalidHookAccess();
  13933. updateHookTypesDev();
  13934. return updateLayoutEffect(create, deps);
  13935. },
  13936. useMemo: function (create, deps) {
  13937. currentHookNameInDev = 'useMemo';
  13938. warnInvalidHookAccess();
  13939. updateHookTypesDev();
  13940. var prevDispatcher = ReactCurrentDispatcher.current;
  13941. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13942. try {
  13943. return updateMemo(create, deps);
  13944. } finally {
  13945. ReactCurrentDispatcher.current = prevDispatcher;
  13946. }
  13947. },
  13948. useReducer: function (reducer, initialArg, init) {
  13949. currentHookNameInDev = 'useReducer';
  13950. warnInvalidHookAccess();
  13951. updateHookTypesDev();
  13952. var prevDispatcher = ReactCurrentDispatcher.current;
  13953. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13954. try {
  13955. return updateReducer(reducer, initialArg, init);
  13956. } finally {
  13957. ReactCurrentDispatcher.current = prevDispatcher;
  13958. }
  13959. },
  13960. useRef: function (initialValue) {
  13961. currentHookNameInDev = 'useRef';
  13962. warnInvalidHookAccess();
  13963. updateHookTypesDev();
  13964. return updateRef();
  13965. },
  13966. useState: function (initialState) {
  13967. currentHookNameInDev = 'useState';
  13968. warnInvalidHookAccess();
  13969. updateHookTypesDev();
  13970. var prevDispatcher = ReactCurrentDispatcher.current;
  13971. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13972. try {
  13973. return updateState(initialState);
  13974. } finally {
  13975. ReactCurrentDispatcher.current = prevDispatcher;
  13976. }
  13977. },
  13978. useDebugValue: function (value, formatterFn) {
  13979. currentHookNameInDev = 'useDebugValue';
  13980. warnInvalidHookAccess();
  13981. updateHookTypesDev();
  13982. return updateDebugValue();
  13983. },
  13984. useResponder: function (responder, props) {
  13985. currentHookNameInDev = 'useResponder';
  13986. warnInvalidHookAccess();
  13987. updateHookTypesDev();
  13988. return createDeprecatedResponderListener(responder, props);
  13989. },
  13990. useDeferredValue: function (value, config) {
  13991. currentHookNameInDev = 'useDeferredValue';
  13992. warnInvalidHookAccess();
  13993. updateHookTypesDev();
  13994. return updateDeferredValue(value, config);
  13995. },
  13996. useTransition: function (config) {
  13997. currentHookNameInDev = 'useTransition';
  13998. warnInvalidHookAccess();
  13999. updateHookTypesDev();
  14000. return updateTransition(config);
  14001. }
  14002. };
  14003. InvalidNestedHooksDispatcherOnRerenderInDEV = {
  14004. readContext: function (context, observedBits) {
  14005. warnInvalidContextAccess();
  14006. return readContext(context, observedBits);
  14007. },
  14008. useCallback: function (callback, deps) {
  14009. currentHookNameInDev = 'useCallback';
  14010. warnInvalidHookAccess();
  14011. updateHookTypesDev();
  14012. return updateCallback(callback, deps);
  14013. },
  14014. useContext: function (context, observedBits) {
  14015. currentHookNameInDev = 'useContext';
  14016. warnInvalidHookAccess();
  14017. updateHookTypesDev();
  14018. return readContext(context, observedBits);
  14019. },
  14020. useEffect: function (create, deps) {
  14021. currentHookNameInDev = 'useEffect';
  14022. warnInvalidHookAccess();
  14023. updateHookTypesDev();
  14024. return updateEffect(create, deps);
  14025. },
  14026. useImperativeHandle: function (ref, create, deps) {
  14027. currentHookNameInDev = 'useImperativeHandle';
  14028. warnInvalidHookAccess();
  14029. updateHookTypesDev();
  14030. return updateImperativeHandle(ref, create, deps);
  14031. },
  14032. useLayoutEffect: function (create, deps) {
  14033. currentHookNameInDev = 'useLayoutEffect';
  14034. warnInvalidHookAccess();
  14035. updateHookTypesDev();
  14036. return updateLayoutEffect(create, deps);
  14037. },
  14038. useMemo: function (create, deps) {
  14039. currentHookNameInDev = 'useMemo';
  14040. warnInvalidHookAccess();
  14041. updateHookTypesDev();
  14042. var prevDispatcher = ReactCurrentDispatcher.current;
  14043. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14044. try {
  14045. return updateMemo(create, deps);
  14046. } finally {
  14047. ReactCurrentDispatcher.current = prevDispatcher;
  14048. }
  14049. },
  14050. useReducer: function (reducer, initialArg, init) {
  14051. currentHookNameInDev = 'useReducer';
  14052. warnInvalidHookAccess();
  14053. updateHookTypesDev();
  14054. var prevDispatcher = ReactCurrentDispatcher.current;
  14055. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14056. try {
  14057. return rerenderReducer(reducer, initialArg, init);
  14058. } finally {
  14059. ReactCurrentDispatcher.current = prevDispatcher;
  14060. }
  14061. },
  14062. useRef: function (initialValue) {
  14063. currentHookNameInDev = 'useRef';
  14064. warnInvalidHookAccess();
  14065. updateHookTypesDev();
  14066. return updateRef();
  14067. },
  14068. useState: function (initialState) {
  14069. currentHookNameInDev = 'useState';
  14070. warnInvalidHookAccess();
  14071. updateHookTypesDev();
  14072. var prevDispatcher = ReactCurrentDispatcher.current;
  14073. ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14074. try {
  14075. return rerenderState(initialState);
  14076. } finally {
  14077. ReactCurrentDispatcher.current = prevDispatcher;
  14078. }
  14079. },
  14080. useDebugValue: function (value, formatterFn) {
  14081. currentHookNameInDev = 'useDebugValue';
  14082. warnInvalidHookAccess();
  14083. updateHookTypesDev();
  14084. return updateDebugValue();
  14085. },
  14086. useResponder: function (responder, props) {
  14087. currentHookNameInDev = 'useResponder';
  14088. warnInvalidHookAccess();
  14089. updateHookTypesDev();
  14090. return createDeprecatedResponderListener(responder, props);
  14091. },
  14092. useDeferredValue: function (value, config) {
  14093. currentHookNameInDev = 'useDeferredValue';
  14094. warnInvalidHookAccess();
  14095. updateHookTypesDev();
  14096. return rerenderDeferredValue(value, config);
  14097. },
  14098. useTransition: function (config) {
  14099. currentHookNameInDev = 'useTransition';
  14100. warnInvalidHookAccess();
  14101. updateHookTypesDev();
  14102. return rerenderTransition(config);
  14103. }
  14104. };
  14105. }
  14106. var now$1 = Scheduler.unstable_now;
  14107. var commitTime = 0;
  14108. var profilerStartTime = -1;
  14109. function getCommitTime() {
  14110. return commitTime;
  14111. }
  14112. function recordCommitTime() {
  14113. commitTime = now$1();
  14114. }
  14115. function startProfilerTimer(fiber) {
  14116. profilerStartTime = now$1();
  14117. if (fiber.actualStartTime < 0) {
  14118. fiber.actualStartTime = now$1();
  14119. }
  14120. }
  14121. function stopProfilerTimerIfRunning(fiber) {
  14122. profilerStartTime = -1;
  14123. }
  14124. function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
  14125. if (profilerStartTime >= 0) {
  14126. var elapsedTime = now$1() - profilerStartTime;
  14127. fiber.actualDuration += elapsedTime;
  14128. if (overrideBaseTime) {
  14129. fiber.selfBaseDuration = elapsedTime;
  14130. }
  14131. profilerStartTime = -1;
  14132. }
  14133. }
  14134. // This may have been an insertion or a hydration.
  14135. var hydrationParentFiber = null;
  14136. var nextHydratableInstance = null;
  14137. var isHydrating = false;
  14138. function enterHydrationState(fiber) {
  14139. var parentInstance = fiber.stateNode.containerInfo;
  14140. nextHydratableInstance = getFirstHydratableChild(parentInstance);
  14141. hydrationParentFiber = fiber;
  14142. isHydrating = true;
  14143. return true;
  14144. }
  14145. function deleteHydratableInstance(returnFiber, instance) {
  14146. {
  14147. switch (returnFiber.tag) {
  14148. case HostRoot:
  14149. didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
  14150. break;
  14151. case HostComponent:
  14152. didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
  14153. break;
  14154. }
  14155. }
  14156. var childToDelete = createFiberFromHostInstanceForDeletion();
  14157. childToDelete.stateNode = instance;
  14158. childToDelete.return = returnFiber;
  14159. childToDelete.effectTag = Deletion; // This might seem like it belongs on progressedFirstDeletion. However,
  14160. // these children are not part of the reconciliation list of children.
  14161. // Even if we abort and rereconcile the children, that will try to hydrate
  14162. // again and the nodes are still in the host tree so these will be
  14163. // recreated.
  14164. if (returnFiber.lastEffect !== null) {
  14165. returnFiber.lastEffect.nextEffect = childToDelete;
  14166. returnFiber.lastEffect = childToDelete;
  14167. } else {
  14168. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  14169. }
  14170. }
  14171. function insertNonHydratedInstance(returnFiber, fiber) {
  14172. fiber.effectTag = fiber.effectTag & ~Hydrating | Placement;
  14173. {
  14174. switch (returnFiber.tag) {
  14175. case HostRoot:
  14176. {
  14177. var parentContainer = returnFiber.stateNode.containerInfo;
  14178. switch (fiber.tag) {
  14179. case HostComponent:
  14180. var type = fiber.type;
  14181. var props = fiber.pendingProps;
  14182. didNotFindHydratableContainerInstance(parentContainer, type);
  14183. break;
  14184. case HostText:
  14185. var text = fiber.pendingProps;
  14186. didNotFindHydratableContainerTextInstance(parentContainer, text);
  14187. break;
  14188. }
  14189. break;
  14190. }
  14191. case HostComponent:
  14192. {
  14193. var parentType = returnFiber.type;
  14194. var parentProps = returnFiber.memoizedProps;
  14195. var parentInstance = returnFiber.stateNode;
  14196. switch (fiber.tag) {
  14197. case HostComponent:
  14198. var _type = fiber.type;
  14199. var _props = fiber.pendingProps;
  14200. didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type);
  14201. break;
  14202. case HostText:
  14203. var _text = fiber.pendingProps;
  14204. didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
  14205. break;
  14206. case SuspenseComponent:
  14207. didNotFindHydratableSuspenseInstance(parentType, parentProps);
  14208. break;
  14209. }
  14210. break;
  14211. }
  14212. default:
  14213. return;
  14214. }
  14215. }
  14216. }
  14217. function tryHydrate(fiber, nextInstance) {
  14218. switch (fiber.tag) {
  14219. case HostComponent:
  14220. {
  14221. var type = fiber.type;
  14222. var props = fiber.pendingProps;
  14223. var instance = canHydrateInstance(nextInstance, type);
  14224. if (instance !== null) {
  14225. fiber.stateNode = instance;
  14226. return true;
  14227. }
  14228. return false;
  14229. }
  14230. case HostText:
  14231. {
  14232. var text = fiber.pendingProps;
  14233. var textInstance = canHydrateTextInstance(nextInstance, text);
  14234. if (textInstance !== null) {
  14235. fiber.stateNode = textInstance;
  14236. return true;
  14237. }
  14238. return false;
  14239. }
  14240. case SuspenseComponent:
  14241. {
  14242. return false;
  14243. }
  14244. default:
  14245. return false;
  14246. }
  14247. }
  14248. function tryToClaimNextHydratableInstance(fiber) {
  14249. if (!isHydrating) {
  14250. return;
  14251. }
  14252. var nextInstance = nextHydratableInstance;
  14253. if (!nextInstance) {
  14254. // Nothing to hydrate. Make it an insertion.
  14255. insertNonHydratedInstance(hydrationParentFiber, fiber);
  14256. isHydrating = false;
  14257. hydrationParentFiber = fiber;
  14258. return;
  14259. }
  14260. var firstAttemptedInstance = nextInstance;
  14261. if (!tryHydrate(fiber, nextInstance)) {
  14262. // If we can't hydrate this instance let's try the next one.
  14263. // We use this as a heuristic. It's based on intuition and not data so it
  14264. // might be flawed or unnecessary.
  14265. nextInstance = getNextHydratableSibling(firstAttemptedInstance);
  14266. if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
  14267. // Nothing to hydrate. Make it an insertion.
  14268. insertNonHydratedInstance(hydrationParentFiber, fiber);
  14269. isHydrating = false;
  14270. hydrationParentFiber = fiber;
  14271. return;
  14272. } // We matched the next one, we'll now assume that the first one was
  14273. // superfluous and we'll delete it. Since we can't eagerly delete it
  14274. // we'll have to schedule a deletion. To do that, this node needs a dummy
  14275. // fiber associated with it.
  14276. deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
  14277. }
  14278. hydrationParentFiber = fiber;
  14279. nextHydratableInstance = getFirstHydratableChild(nextInstance);
  14280. }
  14281. function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
  14282. var instance = fiber.stateNode;
  14283. var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); // TODO: Type this specific to this type of component.
  14284. fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
  14285. // is a new ref we mark this as an update.
  14286. if (updatePayload !== null) {
  14287. return true;
  14288. }
  14289. return false;
  14290. }
  14291. function prepareToHydrateHostTextInstance(fiber) {
  14292. var textInstance = fiber.stateNode;
  14293. var textContent = fiber.memoizedProps;
  14294. var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
  14295. {
  14296. if (shouldUpdate) {
  14297. // We assume that prepareToHydrateHostTextInstance is called in a context where the
  14298. // hydration parent is the parent host component of this host text.
  14299. var returnFiber = hydrationParentFiber;
  14300. if (returnFiber !== null) {
  14301. switch (returnFiber.tag) {
  14302. case HostRoot:
  14303. {
  14304. var parentContainer = returnFiber.stateNode.containerInfo;
  14305. didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
  14306. break;
  14307. }
  14308. case HostComponent:
  14309. {
  14310. var parentType = returnFiber.type;
  14311. var parentProps = returnFiber.memoizedProps;
  14312. var parentInstance = returnFiber.stateNode;
  14313. didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
  14314. break;
  14315. }
  14316. }
  14317. }
  14318. }
  14319. }
  14320. return shouldUpdate;
  14321. }
  14322. function skipPastDehydratedSuspenseInstance(fiber) {
  14323. var suspenseState = fiber.memoizedState;
  14324. var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
  14325. if (!suspenseInstance) {
  14326. {
  14327. throw Error( "Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue." );
  14328. }
  14329. }
  14330. return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
  14331. }
  14332. function popToNextHostParent(fiber) {
  14333. var parent = fiber.return;
  14334. while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) {
  14335. parent = parent.return;
  14336. }
  14337. hydrationParentFiber = parent;
  14338. }
  14339. function popHydrationState(fiber) {
  14340. if (fiber !== hydrationParentFiber) {
  14341. // We're deeper than the current hydration context, inside an inserted
  14342. // tree.
  14343. return false;
  14344. }
  14345. if (!isHydrating) {
  14346. // If we're not currently hydrating but we're in a hydration context, then
  14347. // we were an insertion and now need to pop up reenter hydration of our
  14348. // siblings.
  14349. popToNextHostParent(fiber);
  14350. isHydrating = true;
  14351. return false;
  14352. }
  14353. var type = fiber.type; // If we have any remaining hydratable nodes, we need to delete them now.
  14354. // We only do this deeper than head and body since they tend to have random
  14355. // other nodes in them. We also ignore components with pure text content in
  14356. // side of them.
  14357. // TODO: Better heuristic.
  14358. if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
  14359. var nextInstance = nextHydratableInstance;
  14360. while (nextInstance) {
  14361. deleteHydratableInstance(fiber, nextInstance);
  14362. nextInstance = getNextHydratableSibling(nextInstance);
  14363. }
  14364. }
  14365. popToNextHostParent(fiber);
  14366. if (fiber.tag === SuspenseComponent) {
  14367. nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber);
  14368. } else {
  14369. nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
  14370. }
  14371. return true;
  14372. }
  14373. function resetHydrationState() {
  14374. hydrationParentFiber = null;
  14375. nextHydratableInstance = null;
  14376. isHydrating = false;
  14377. }
  14378. var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
  14379. var didReceiveUpdate = false;
  14380. var didWarnAboutBadClass;
  14381. var didWarnAboutModulePatternComponent;
  14382. var didWarnAboutContextTypeOnFunctionComponent;
  14383. var didWarnAboutGetDerivedStateOnFunctionComponent;
  14384. var didWarnAboutFunctionRefs;
  14385. var didWarnAboutReassigningProps;
  14386. var didWarnAboutRevealOrder;
  14387. var didWarnAboutTailOptions;
  14388. {
  14389. didWarnAboutBadClass = {};
  14390. didWarnAboutModulePatternComponent = {};
  14391. didWarnAboutContextTypeOnFunctionComponent = {};
  14392. didWarnAboutGetDerivedStateOnFunctionComponent = {};
  14393. didWarnAboutFunctionRefs = {};
  14394. didWarnAboutReassigningProps = false;
  14395. didWarnAboutRevealOrder = {};
  14396. didWarnAboutTailOptions = {};
  14397. }
  14398. function reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime) {
  14399. if (current === null) {
  14400. // If this is a fresh new component that hasn't been rendered yet, we
  14401. // won't update its child set by applying minimal side-effects. Instead,
  14402. // we will add them all to the child before it gets rendered. That means
  14403. // we can optimize this reconciliation pass by not tracking side-effects.
  14404. workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  14405. } else {
  14406. // If the current child is the same as the work in progress, it means that
  14407. // we haven't yet started any work on these children. Therefore, we use
  14408. // the clone algorithm to create a copy of all the current children.
  14409. // If we had any progressed work already, that is invalid at this point so
  14410. // let's throw it out.
  14411. workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderExpirationTime);
  14412. }
  14413. }
  14414. function forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime) {
  14415. // This function is fork of reconcileChildren. It's used in cases where we
  14416. // want to reconcile without matching against the existing set. This has the
  14417. // effect of all current children being unmounted; even if the type and key
  14418. // are the same, the old child is unmounted and a new child is created.
  14419. //
  14420. // To do this, we're going to go through the reconcile algorithm twice. In
  14421. // the first pass, we schedule a deletion for all the current children by
  14422. // passing null.
  14423. workInProgress.child = reconcileChildFibers(workInProgress, current.child, null, renderExpirationTime); // In the second pass, we mount the new children. The trick here is that we
  14424. // pass null in place of where we usually pass the current child set. This has
  14425. // the effect of remounting all children regardless of whether their
  14426. // identities match.
  14427. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  14428. }
  14429. function updateForwardRef(current, workInProgress, Component, nextProps, renderExpirationTime) {
  14430. // TODO: current can be non-null here even if the component
  14431. // hasn't yet mounted. This happens after the first render suspends.
  14432. // We'll need to figure out if this is fine or can cause issues.
  14433. {
  14434. if (workInProgress.type !== workInProgress.elementType) {
  14435. // Lazy component props can't be validated in createElement
  14436. // because they're only guaranteed to be resolved here.
  14437. var innerPropTypes = Component.propTypes;
  14438. if (innerPropTypes) {
  14439. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  14440. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  14441. }
  14442. }
  14443. }
  14444. var render = Component.render;
  14445. var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
  14446. var nextChildren;
  14447. prepareToReadContext(workInProgress, renderExpirationTime);
  14448. {
  14449. ReactCurrentOwner$1.current = workInProgress;
  14450. setIsRendering(true);
  14451. nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderExpirationTime);
  14452. if ( workInProgress.mode & StrictMode) {
  14453. // Only double-render components with Hooks
  14454. if (workInProgress.memoizedState !== null) {
  14455. nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderExpirationTime);
  14456. }
  14457. }
  14458. setIsRendering(false);
  14459. }
  14460. if (current !== null && !didReceiveUpdate) {
  14461. bailoutHooks(current, workInProgress, renderExpirationTime);
  14462. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
  14463. } // React DevTools reads this flag.
  14464. workInProgress.effectTag |= PerformedWork;
  14465. reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
  14466. return workInProgress.child;
  14467. }
  14468. function updateMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
  14469. if (current === null) {
  14470. var type = Component.type;
  14471. if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either.
  14472. Component.defaultProps === undefined) {
  14473. var resolvedType = type;
  14474. {
  14475. resolvedType = resolveFunctionForHotReloading(type);
  14476. } // If this is a plain function component without default props,
  14477. // and with only the default shallow comparison, we upgrade it
  14478. // to a SimpleMemoComponent to allow fast path updates.
  14479. workInProgress.tag = SimpleMemoComponent;
  14480. workInProgress.type = resolvedType;
  14481. {
  14482. validateFunctionComponentInDev(workInProgress, type);
  14483. }
  14484. return updateSimpleMemoComponent(current, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime);
  14485. }
  14486. {
  14487. var innerPropTypes = type.propTypes;
  14488. if (innerPropTypes) {
  14489. // Inner memo component props aren't currently validated in createElement.
  14490. // We could move it there, but we'd still need this for lazy code path.
  14491. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  14492. 'prop', getComponentName(type), getCurrentFiberStackInDev);
  14493. }
  14494. }
  14495. var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
  14496. child.ref = workInProgress.ref;
  14497. child.return = workInProgress;
  14498. workInProgress.child = child;
  14499. return child;
  14500. }
  14501. {
  14502. var _type = Component.type;
  14503. var _innerPropTypes = _type.propTypes;
  14504. if (_innerPropTypes) {
  14505. // Inner memo component props aren't currently validated in createElement.
  14506. // We could move it there, but we'd still need this for lazy code path.
  14507. checkPropTypes(_innerPropTypes, nextProps, // Resolved props
  14508. 'prop', getComponentName(_type), getCurrentFiberStackInDev);
  14509. }
  14510. }
  14511. var currentChild = current.child; // This is always exactly one child
  14512. if (updateExpirationTime < renderExpirationTime) {
  14513. // This will be the props with resolved defaultProps,
  14514. // unlike current.memoizedProps which will be the unresolved ones.
  14515. var prevProps = currentChild.memoizedProps; // Default to shallow comparison
  14516. var compare = Component.compare;
  14517. compare = compare !== null ? compare : shallowEqual;
  14518. if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
  14519. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
  14520. }
  14521. } // React DevTools reads this flag.
  14522. workInProgress.effectTag |= PerformedWork;
  14523. var newChild = createWorkInProgress(currentChild, nextProps);
  14524. newChild.ref = workInProgress.ref;
  14525. newChild.return = workInProgress;
  14526. workInProgress.child = newChild;
  14527. return newChild;
  14528. }
  14529. function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
  14530. // TODO: current can be non-null here even if the component
  14531. // hasn't yet mounted. This happens when the inner render suspends.
  14532. // We'll need to figure out if this is fine or can cause issues.
  14533. {
  14534. if (workInProgress.type !== workInProgress.elementType) {
  14535. // Lazy component props can't be validated in createElement
  14536. // because they're only guaranteed to be resolved here.
  14537. var outerMemoType = workInProgress.elementType;
  14538. if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
  14539. // We warn when you define propTypes on lazy()
  14540. // so let's just skip over it to find memo() outer wrapper.
  14541. // Inner props for memo are validated later.
  14542. outerMemoType = refineResolvedLazyComponent(outerMemoType);
  14543. }
  14544. var outerPropTypes = outerMemoType && outerMemoType.propTypes;
  14545. if (outerPropTypes) {
  14546. checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
  14547. 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
  14548. } // Inner propTypes will be validated in the function component path.
  14549. }
  14550. }
  14551. if (current !== null) {
  14552. var prevProps = current.memoizedProps;
  14553. if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload.
  14554. workInProgress.type === current.type )) {
  14555. didReceiveUpdate = false;
  14556. if (updateExpirationTime < renderExpirationTime) {
  14557. // The pending update priority was cleared at the beginning of
  14558. // beginWork. We're about to bail out, but there might be additional
  14559. // updates at a lower priority. Usually, the priority level of the
  14560. // remaining updates is accumlated during the evaluation of the
  14561. // component (i.e. when processing the update queue). But since since
  14562. // we're bailing out early *without* evaluating the component, we need
  14563. // to account for it here, too. Reset to the value of the current fiber.
  14564. // NOTE: This only applies to SimpleMemoComponent, not MemoComponent,
  14565. // because a MemoComponent fiber does not have hooks or an update queue;
  14566. // rather, it wraps around an inner component, which may or may not
  14567. // contains hooks.
  14568. // TODO: Move the reset at in beginWork out of the common path so that
  14569. // this is no longer necessary.
  14570. workInProgress.expirationTime = current.expirationTime;
  14571. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
  14572. }
  14573. }
  14574. }
  14575. return updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime);
  14576. }
  14577. function updateFragment(current, workInProgress, renderExpirationTime) {
  14578. var nextChildren = workInProgress.pendingProps;
  14579. reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
  14580. return workInProgress.child;
  14581. }
  14582. function updateMode(current, workInProgress, renderExpirationTime) {
  14583. var nextChildren = workInProgress.pendingProps.children;
  14584. reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
  14585. return workInProgress.child;
  14586. }
  14587. function updateProfiler(current, workInProgress, renderExpirationTime) {
  14588. {
  14589. workInProgress.effectTag |= Update;
  14590. }
  14591. var nextProps = workInProgress.pendingProps;
  14592. var nextChildren = nextProps.children;
  14593. reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
  14594. return workInProgress.child;
  14595. }
  14596. function markRef(current, workInProgress) {
  14597. var ref = workInProgress.ref;
  14598. if (current === null && ref !== null || current !== null && current.ref !== ref) {
  14599. // Schedule a Ref effect
  14600. workInProgress.effectTag |= Ref;
  14601. }
  14602. }
  14603. function updateFunctionComponent(current, workInProgress, Component, nextProps, renderExpirationTime) {
  14604. {
  14605. if (workInProgress.type !== workInProgress.elementType) {
  14606. // Lazy component props can't be validated in createElement
  14607. // because they're only guaranteed to be resolved here.
  14608. var innerPropTypes = Component.propTypes;
  14609. if (innerPropTypes) {
  14610. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  14611. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  14612. }
  14613. }
  14614. }
  14615. var context;
  14616. {
  14617. var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
  14618. context = getMaskedContext(workInProgress, unmaskedContext);
  14619. }
  14620. var nextChildren;
  14621. prepareToReadContext(workInProgress, renderExpirationTime);
  14622. {
  14623. ReactCurrentOwner$1.current = workInProgress;
  14624. setIsRendering(true);
  14625. nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderExpirationTime);
  14626. if ( workInProgress.mode & StrictMode) {
  14627. // Only double-render components with Hooks
  14628. if (workInProgress.memoizedState !== null) {
  14629. nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderExpirationTime);
  14630. }
  14631. }
  14632. setIsRendering(false);
  14633. }
  14634. if (current !== null && !didReceiveUpdate) {
  14635. bailoutHooks(current, workInProgress, renderExpirationTime);
  14636. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
  14637. } // React DevTools reads this flag.
  14638. workInProgress.effectTag |= PerformedWork;
  14639. reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
  14640. return workInProgress.child;
  14641. }
  14642. function updateClassComponent(current, workInProgress, Component, nextProps, renderExpirationTime) {
  14643. {
  14644. if (workInProgress.type !== workInProgress.elementType) {
  14645. // Lazy component props can't be validated in createElement
  14646. // because they're only guaranteed to be resolved here.
  14647. var innerPropTypes = Component.propTypes;
  14648. if (innerPropTypes) {
  14649. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  14650. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  14651. }
  14652. }
  14653. } // Push context providers early to prevent context stack mismatches.
  14654. // During mounting we don't know the child context yet as the instance doesn't exist.
  14655. // We will invalidate the child context in finishClassComponent() right after rendering.
  14656. var hasContext;
  14657. if (isContextProvider(Component)) {
  14658. hasContext = true;
  14659. pushContextProvider(workInProgress);
  14660. } else {
  14661. hasContext = false;
  14662. }
  14663. prepareToReadContext(workInProgress, renderExpirationTime);
  14664. var instance = workInProgress.stateNode;
  14665. var shouldUpdate;
  14666. if (instance === null) {
  14667. if (current !== null) {
  14668. // A class component without an instance only mounts if it suspended
  14669. // inside a non-concurrent tree, in an inconsistent state. We want to
  14670. // treat it like a new mount, even though an empty version of it already
  14671. // committed. Disconnect the alternate pointers.
  14672. current.alternate = null;
  14673. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  14674. workInProgress.effectTag |= Placement;
  14675. } // In the initial pass we might need to construct the instance.
  14676. constructClassInstance(workInProgress, Component, nextProps);
  14677. mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  14678. shouldUpdate = true;
  14679. } else if (current === null) {
  14680. // In a resume, we'll already have an instance we can reuse.
  14681. shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  14682. } else {
  14683. shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderExpirationTime);
  14684. }
  14685. var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
  14686. {
  14687. var inst = workInProgress.stateNode;
  14688. if (inst.props !== nextProps) {
  14689. if (!didWarnAboutReassigningProps) {
  14690. error('It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component');
  14691. }
  14692. didWarnAboutReassigningProps = true;
  14693. }
  14694. }
  14695. return nextUnitOfWork;
  14696. }
  14697. function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
  14698. // Refs should update even if shouldComponentUpdate returns false
  14699. markRef(current, workInProgress);
  14700. var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
  14701. if (!shouldUpdate && !didCaptureError) {
  14702. // Context providers should defer to sCU for rendering
  14703. if (hasContext) {
  14704. invalidateContextProvider(workInProgress, Component, false);
  14705. }
  14706. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
  14707. }
  14708. var instance = workInProgress.stateNode; // Rerender
  14709. ReactCurrentOwner$1.current = workInProgress;
  14710. var nextChildren;
  14711. if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
  14712. // If we captured an error, but getDerivedStateFromError is not defined,
  14713. // unmount all the children. componentDidCatch will schedule an update to
  14714. // re-render a fallback. This is temporary until we migrate everyone to
  14715. // the new API.
  14716. // TODO: Warn in a future release.
  14717. nextChildren = null;
  14718. {
  14719. stopProfilerTimerIfRunning();
  14720. }
  14721. } else {
  14722. {
  14723. setIsRendering(true);
  14724. nextChildren = instance.render();
  14725. if ( workInProgress.mode & StrictMode) {
  14726. instance.render();
  14727. }
  14728. setIsRendering(false);
  14729. }
  14730. } // React DevTools reads this flag.
  14731. workInProgress.effectTag |= PerformedWork;
  14732. if (current !== null && didCaptureError) {
  14733. // If we're recovering from an error, reconcile without reusing any of
  14734. // the existing children. Conceptually, the normal children and the children
  14735. // that are shown on error are two different sets, so we shouldn't reuse
  14736. // normal children even if their identities match.
  14737. forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime);
  14738. } else {
  14739. reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
  14740. } // Memoize state using the values we just used to render.
  14741. // TODO: Restructure so we never read values from the instance.
  14742. workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it.
  14743. if (hasContext) {
  14744. invalidateContextProvider(workInProgress, Component, true);
  14745. }
  14746. return workInProgress.child;
  14747. }
  14748. function pushHostRootContext(workInProgress) {
  14749. var root = workInProgress.stateNode;
  14750. if (root.pendingContext) {
  14751. pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
  14752. } else if (root.context) {
  14753. // Should always be set
  14754. pushTopLevelContextObject(workInProgress, root.context, false);
  14755. }
  14756. pushHostContainer(workInProgress, root.containerInfo);
  14757. }
  14758. function updateHostRoot(current, workInProgress, renderExpirationTime) {
  14759. pushHostRootContext(workInProgress);
  14760. var updateQueue = workInProgress.updateQueue;
  14761. if (!(current !== null && updateQueue !== null)) {
  14762. {
  14763. throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." );
  14764. }
  14765. }
  14766. var nextProps = workInProgress.pendingProps;
  14767. var prevState = workInProgress.memoizedState;
  14768. var prevChildren = prevState !== null ? prevState.element : null;
  14769. cloneUpdateQueue(current, workInProgress);
  14770. processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime);
  14771. var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property
  14772. // being called "element".
  14773. var nextChildren = nextState.element;
  14774. if (nextChildren === prevChildren) {
  14775. // If the state is the same as before, that's a bailout because we had
  14776. // no work that expires at this time.
  14777. resetHydrationState();
  14778. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
  14779. }
  14780. var root = workInProgress.stateNode;
  14781. if (root.hydrate && enterHydrationState(workInProgress)) {
  14782. // If we don't have any current children this might be the first pass.
  14783. // We always try to hydrate. If this isn't a hydration pass there won't
  14784. // be any children to hydrate which is effectively the same thing as
  14785. // not hydrating.
  14786. var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  14787. workInProgress.child = child;
  14788. var node = child;
  14789. while (node) {
  14790. // Mark each child as hydrating. This is a fast path to know whether this
  14791. // tree is part of a hydrating tree. This is used to determine if a child
  14792. // node has fully mounted yet, and for scheduling event replaying.
  14793. // Conceptually this is similar to Placement in that a new subtree is
  14794. // inserted into the React tree here. It just happens to not need DOM
  14795. // mutations because it already exists.
  14796. node.effectTag = node.effectTag & ~Placement | Hydrating;
  14797. node = node.sibling;
  14798. }
  14799. } else {
  14800. // Otherwise reset hydration state in case we aborted and resumed another
  14801. // root.
  14802. reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
  14803. resetHydrationState();
  14804. }
  14805. return workInProgress.child;
  14806. }
  14807. function updateHostComponent(current, workInProgress, renderExpirationTime) {
  14808. pushHostContext(workInProgress);
  14809. if (current === null) {
  14810. tryToClaimNextHydratableInstance(workInProgress);
  14811. }
  14812. var type = workInProgress.type;
  14813. var nextProps = workInProgress.pendingProps;
  14814. var prevProps = current !== null ? current.memoizedProps : null;
  14815. var nextChildren = nextProps.children;
  14816. var isDirectTextChild = shouldSetTextContent(type, nextProps);
  14817. if (isDirectTextChild) {
  14818. // We special case a direct text child of a host node. This is a common
  14819. // case. We won't handle it as a reified child. We will instead handle
  14820. // this in the host environment that also has access to this prop. That
  14821. // avoids allocating another HostText fiber and traversing it.
  14822. nextChildren = null;
  14823. } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
  14824. // If we're switching from a direct text child to a normal child, or to
  14825. // empty, we need to schedule the text content to be reset.
  14826. workInProgress.effectTag |= ContentReset;
  14827. }
  14828. markRef(current, workInProgress); // Check the host config to see if the children are offscreen/hidden.
  14829. if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(type, nextProps)) {
  14830. {
  14831. markSpawnedWork(Never);
  14832. } // Schedule this fiber to re-render at offscreen priority. Then bailout.
  14833. workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
  14834. return null;
  14835. }
  14836. reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
  14837. return workInProgress.child;
  14838. }
  14839. function updateHostText(current, workInProgress) {
  14840. if (current === null) {
  14841. tryToClaimNextHydratableInstance(workInProgress);
  14842. } // Nothing to do here. This is terminal. We'll do the completion step
  14843. // immediately after.
  14844. return null;
  14845. }
  14846. function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
  14847. if (_current !== null) {
  14848. // A lazy component only mounts if it suspended inside a non-
  14849. // concurrent tree, in an inconsistent state. We want to treat it like
  14850. // a new mount, even though an empty version of it already committed.
  14851. // Disconnect the alternate pointers.
  14852. _current.alternate = null;
  14853. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  14854. workInProgress.effectTag |= Placement;
  14855. }
  14856. var props = workInProgress.pendingProps; // We can't start a User Timing measurement with correct label yet.
  14857. // Cancel and resume right after we know the tag.
  14858. cancelWorkTimer(workInProgress);
  14859. var Component = readLazyComponentType(elementType); // Store the unwrapped component in the type.
  14860. workInProgress.type = Component;
  14861. var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
  14862. startWorkTimer(workInProgress);
  14863. var resolvedProps = resolveDefaultProps(Component, props);
  14864. var child;
  14865. switch (resolvedTag) {
  14866. case FunctionComponent:
  14867. {
  14868. {
  14869. validateFunctionComponentInDev(workInProgress, Component);
  14870. workInProgress.type = Component = resolveFunctionForHotReloading(Component);
  14871. }
  14872. child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  14873. return child;
  14874. }
  14875. case ClassComponent:
  14876. {
  14877. {
  14878. workInProgress.type = Component = resolveClassForHotReloading(Component);
  14879. }
  14880. child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  14881. return child;
  14882. }
  14883. case ForwardRef:
  14884. {
  14885. {
  14886. workInProgress.type = Component = resolveForwardRefForHotReloading(Component);
  14887. }
  14888. child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  14889. return child;
  14890. }
  14891. case MemoComponent:
  14892. {
  14893. {
  14894. if (workInProgress.type !== workInProgress.elementType) {
  14895. var outerPropTypes = Component.propTypes;
  14896. if (outerPropTypes) {
  14897. checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only
  14898. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  14899. }
  14900. }
  14901. }
  14902. child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
  14903. updateExpirationTime, renderExpirationTime);
  14904. return child;
  14905. }
  14906. }
  14907. var hint = '';
  14908. {
  14909. if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
  14910. hint = ' Did you wrap a component in React.lazy() more than once?';
  14911. }
  14912. } // This message intentionally doesn't mention ForwardRef or MemoComponent
  14913. // because the fact that it's a separate type of work is an
  14914. // implementation detail.
  14915. {
  14916. {
  14917. throw Error( "Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint );
  14918. }
  14919. }
  14920. }
  14921. function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
  14922. if (_current !== null) {
  14923. // An incomplete component only mounts if it suspended inside a non-
  14924. // concurrent tree, in an inconsistent state. We want to treat it like
  14925. // a new mount, even though an empty version of it already committed.
  14926. // Disconnect the alternate pointers.
  14927. _current.alternate = null;
  14928. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  14929. workInProgress.effectTag |= Placement;
  14930. } // Promote the fiber to a class and try rendering again.
  14931. workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent`
  14932. // Push context providers early to prevent context stack mismatches.
  14933. // During mounting we don't know the child context yet as the instance doesn't exist.
  14934. // We will invalidate the child context in finishClassComponent() right after rendering.
  14935. var hasContext;
  14936. if (isContextProvider(Component)) {
  14937. hasContext = true;
  14938. pushContextProvider(workInProgress);
  14939. } else {
  14940. hasContext = false;
  14941. }
  14942. prepareToReadContext(workInProgress, renderExpirationTime);
  14943. constructClassInstance(workInProgress, Component, nextProps);
  14944. mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  14945. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
  14946. }
  14947. function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
  14948. if (_current !== null) {
  14949. // An indeterminate component only mounts if it suspended inside a non-
  14950. // concurrent tree, in an inconsistent state. We want to treat it like
  14951. // a new mount, even though an empty version of it already committed.
  14952. // Disconnect the alternate pointers.
  14953. _current.alternate = null;
  14954. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  14955. workInProgress.effectTag |= Placement;
  14956. }
  14957. var props = workInProgress.pendingProps;
  14958. var context;
  14959. {
  14960. var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
  14961. context = getMaskedContext(workInProgress, unmaskedContext);
  14962. }
  14963. prepareToReadContext(workInProgress, renderExpirationTime);
  14964. var value;
  14965. {
  14966. if (Component.prototype && typeof Component.prototype.render === 'function') {
  14967. var componentName = getComponentName(Component) || 'Unknown';
  14968. if (!didWarnAboutBadClass[componentName]) {
  14969. error("The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName);
  14970. didWarnAboutBadClass[componentName] = true;
  14971. }
  14972. }
  14973. if (workInProgress.mode & StrictMode) {
  14974. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
  14975. }
  14976. setIsRendering(true);
  14977. ReactCurrentOwner$1.current = workInProgress;
  14978. value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
  14979. setIsRendering(false);
  14980. } // React DevTools reads this flag.
  14981. workInProgress.effectTag |= PerformedWork;
  14982. if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  14983. {
  14984. var _componentName = getComponentName(Component) || 'Unknown';
  14985. if (!didWarnAboutModulePatternComponent[_componentName]) {
  14986. error('The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName);
  14987. didWarnAboutModulePatternComponent[_componentName] = true;
  14988. }
  14989. } // Proceed under the assumption that this is a class instance
  14990. workInProgress.tag = ClassComponent; // Throw out any hooks that were used.
  14991. workInProgress.memoizedState = null;
  14992. workInProgress.updateQueue = null; // Push context providers early to prevent context stack mismatches.
  14993. // During mounting we don't know the child context yet as the instance doesn't exist.
  14994. // We will invalidate the child context in finishClassComponent() right after rendering.
  14995. var hasContext = false;
  14996. if (isContextProvider(Component)) {
  14997. hasContext = true;
  14998. pushContextProvider(workInProgress);
  14999. } else {
  15000. hasContext = false;
  15001. }
  15002. workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
  15003. initializeUpdateQueue(workInProgress);
  15004. var getDerivedStateFromProps = Component.getDerivedStateFromProps;
  15005. if (typeof getDerivedStateFromProps === 'function') {
  15006. applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
  15007. }
  15008. adoptClassInstance(workInProgress, value);
  15009. mountClassInstance(workInProgress, Component, props, renderExpirationTime);
  15010. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
  15011. } else {
  15012. // Proceed under the assumption that this is a function component
  15013. workInProgress.tag = FunctionComponent;
  15014. {
  15015. if ( workInProgress.mode & StrictMode) {
  15016. // Only double-render components with Hooks
  15017. if (workInProgress.memoizedState !== null) {
  15018. value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
  15019. }
  15020. }
  15021. }
  15022. reconcileChildren(null, workInProgress, value, renderExpirationTime);
  15023. {
  15024. validateFunctionComponentInDev(workInProgress, Component);
  15025. }
  15026. return workInProgress.child;
  15027. }
  15028. }
  15029. function validateFunctionComponentInDev(workInProgress, Component) {
  15030. {
  15031. if (Component) {
  15032. if (Component.childContextTypes) {
  15033. error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component');
  15034. }
  15035. }
  15036. if (workInProgress.ref !== null) {
  15037. var info = '';
  15038. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  15039. if (ownerName) {
  15040. info += '\n\nCheck the render method of `' + ownerName + '`.';
  15041. }
  15042. var warningKey = ownerName || workInProgress._debugID || '';
  15043. var debugSource = workInProgress._debugSource;
  15044. if (debugSource) {
  15045. warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
  15046. }
  15047. if (!didWarnAboutFunctionRefs[warningKey]) {
  15048. didWarnAboutFunctionRefs[warningKey] = true;
  15049. error('Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
  15050. }
  15051. }
  15052. if (typeof Component.getDerivedStateFromProps === 'function') {
  15053. var _componentName2 = getComponentName(Component) || 'Unknown';
  15054. if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) {
  15055. error('%s: Function components do not support getDerivedStateFromProps.', _componentName2);
  15056. didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true;
  15057. }
  15058. }
  15059. if (typeof Component.contextType === 'object' && Component.contextType !== null) {
  15060. var _componentName3 = getComponentName(Component) || 'Unknown';
  15061. if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) {
  15062. error('%s: Function components do not support contextType.', _componentName3);
  15063. didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true;
  15064. }
  15065. }
  15066. }
  15067. }
  15068. var SUSPENDED_MARKER = {
  15069. dehydrated: null,
  15070. retryTime: NoWork
  15071. };
  15072. function shouldRemainOnFallback(suspenseContext, current, workInProgress) {
  15073. // If the context is telling us that we should show a fallback, and we're not
  15074. // already showing content, then we should show the fallback instead.
  15075. return hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && (current === null || current.memoizedState !== null);
  15076. }
  15077. function updateSuspenseComponent(current, workInProgress, renderExpirationTime) {
  15078. var mode = workInProgress.mode;
  15079. var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend.
  15080. {
  15081. if (shouldSuspend(workInProgress)) {
  15082. workInProgress.effectTag |= DidCapture;
  15083. }
  15084. }
  15085. var suspenseContext = suspenseStackCursor.current;
  15086. var nextDidTimeout = false;
  15087. var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect;
  15088. if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) {
  15089. // Something in this boundary's subtree already suspended. Switch to
  15090. // rendering the fallback children.
  15091. nextDidTimeout = true;
  15092. workInProgress.effectTag &= ~DidCapture;
  15093. } else {
  15094. // Attempting the main content
  15095. if (current === null || current.memoizedState !== null) {
  15096. // This is a new mount or this boundary is already showing a fallback state.
  15097. // Mark this subtree context as having at least one invisible parent that could
  15098. // handle the fallback state.
  15099. // Boundaries without fallbacks or should be avoided are not considered since
  15100. // they cannot handle preferred fallback states.
  15101. if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) {
  15102. suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
  15103. }
  15104. }
  15105. }
  15106. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  15107. pushSuspenseContext(workInProgress, suspenseContext); // This next part is a bit confusing. If the children timeout, we switch to
  15108. // showing the fallback children in place of the "primary" children.
  15109. // However, we don't want to delete the primary children because then their
  15110. // state will be lost (both the React state and the host state, e.g.
  15111. // uncontrolled form inputs). Instead we keep them mounted and hide them.
  15112. // Both the fallback children AND the primary children are rendered at the
  15113. // same time. Once the primary children are un-suspended, we can delete
  15114. // the fallback children — don't need to preserve their state.
  15115. //
  15116. // The two sets of children are siblings in the host environment, but
  15117. // semantically, for purposes of reconciliation, they are two separate sets.
  15118. // So we store them using two fragment fibers.
  15119. //
  15120. // However, we want to avoid allocating extra fibers for every placeholder.
  15121. // They're only necessary when the children time out, because that's the
  15122. // only time when both sets are mounted.
  15123. //
  15124. // So, the extra fragment fibers are only used if the children time out.
  15125. // Otherwise, we render the primary children directly. This requires some
  15126. // custom reconciliation logic to preserve the state of the primary
  15127. // children. It's essentially a very basic form of re-parenting.
  15128. if (current === null) {
  15129. // If we're currently hydrating, try to hydrate this boundary.
  15130. // But only if this has a fallback.
  15131. if (nextProps.fallback !== undefined) {
  15132. tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component.
  15133. } // This is the initial mount. This branch is pretty simple because there's
  15134. // no previous state that needs to be preserved.
  15135. if (nextDidTimeout) {
  15136. // Mount separate fragments for primary and fallback children.
  15137. var nextFallbackChildren = nextProps.fallback;
  15138. var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
  15139. primaryChildFragment.return = workInProgress;
  15140. if ((workInProgress.mode & BlockingMode) === NoMode) {
  15141. // Outside of blocking mode, we commit the effects from the
  15142. // partially completed, timed-out tree, too.
  15143. var progressedState = workInProgress.memoizedState;
  15144. var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
  15145. primaryChildFragment.child = progressedPrimaryChild;
  15146. var progressedChild = progressedPrimaryChild;
  15147. while (progressedChild !== null) {
  15148. progressedChild.return = primaryChildFragment;
  15149. progressedChild = progressedChild.sibling;
  15150. }
  15151. }
  15152. var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
  15153. fallbackChildFragment.return = workInProgress;
  15154. primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the
  15155. // fallback children.
  15156. workInProgress.memoizedState = SUSPENDED_MARKER;
  15157. workInProgress.child = primaryChildFragment;
  15158. return fallbackChildFragment;
  15159. } else {
  15160. // Mount the primary children without an intermediate fragment fiber.
  15161. var nextPrimaryChildren = nextProps.children;
  15162. workInProgress.memoizedState = null;
  15163. return workInProgress.child = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
  15164. }
  15165. } else {
  15166. // This is an update. This branch is more complicated because we need to
  15167. // ensure the state of the primary children is preserved.
  15168. var prevState = current.memoizedState;
  15169. if (prevState !== null) {
  15170. // wrapped in a fragment fiber.
  15171. var currentPrimaryChildFragment = current.child;
  15172. var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
  15173. if (nextDidTimeout) {
  15174. // Still timed out. Reuse the current primary children by cloning
  15175. // its fragment. We're going to skip over these entirely.
  15176. var _nextFallbackChildren2 = nextProps.fallback;
  15177. var _primaryChildFragment2 = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps);
  15178. _primaryChildFragment2.return = workInProgress;
  15179. if ((workInProgress.mode & BlockingMode) === NoMode) {
  15180. // Outside of blocking mode, we commit the effects from the
  15181. // partially completed, timed-out tree, too.
  15182. var _progressedState = workInProgress.memoizedState;
  15183. var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
  15184. if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
  15185. _primaryChildFragment2.child = _progressedPrimaryChild;
  15186. var _progressedChild2 = _progressedPrimaryChild;
  15187. while (_progressedChild2 !== null) {
  15188. _progressedChild2.return = _primaryChildFragment2;
  15189. _progressedChild2 = _progressedChild2.sibling;
  15190. }
  15191. }
  15192. } // Because primaryChildFragment is a new fiber that we're inserting as the
  15193. // parent of a new tree, we need to set its treeBaseDuration.
  15194. if ( workInProgress.mode & ProfileMode) {
  15195. // treeBaseDuration is the sum of all the child tree base durations.
  15196. var _treeBaseDuration = 0;
  15197. var _hiddenChild = _primaryChildFragment2.child;
  15198. while (_hiddenChild !== null) {
  15199. _treeBaseDuration += _hiddenChild.treeBaseDuration;
  15200. _hiddenChild = _hiddenChild.sibling;
  15201. }
  15202. _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
  15203. } // Clone the fallback child fragment, too. These we'll continue
  15204. // working on.
  15205. var _fallbackChildFragment2 = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren2);
  15206. _fallbackChildFragment2.return = workInProgress;
  15207. _primaryChildFragment2.sibling = _fallbackChildFragment2;
  15208. _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
  15209. // fallback children.
  15210. workInProgress.memoizedState = SUSPENDED_MARKER;
  15211. workInProgress.child = _primaryChildFragment2;
  15212. return _fallbackChildFragment2;
  15213. } else {
  15214. // No longer suspended. Switch back to showing the primary children,
  15215. // and remove the intermediate fragment fiber.
  15216. var _nextPrimaryChildren = nextProps.children;
  15217. var currentPrimaryChild = currentPrimaryChildFragment.child;
  15218. var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime); // If this render doesn't suspend, we need to delete the fallback
  15219. // children. Wait until the complete phase, after we've confirmed the
  15220. // fallback is no longer needed.
  15221. // TODO: Would it be better to store the fallback fragment on
  15222. // the stateNode?
  15223. // Continue rendering the children, like we normally do.
  15224. workInProgress.memoizedState = null;
  15225. return workInProgress.child = primaryChild;
  15226. }
  15227. } else {
  15228. // The current tree has not already timed out. That means the primary
  15229. // children are not wrapped in a fragment fiber.
  15230. var _currentPrimaryChild = current.child;
  15231. if (nextDidTimeout) {
  15232. // Timed out. Wrap the children in a fragment fiber to keep them
  15233. // separate from the fallback children.
  15234. var _nextFallbackChildren3 = nextProps.fallback;
  15235. var _primaryChildFragment3 = createFiberFromFragment( // It shouldn't matter what the pending props are because we aren't
  15236. // going to render this fragment.
  15237. null, mode, NoWork, null);
  15238. _primaryChildFragment3.return = workInProgress;
  15239. _primaryChildFragment3.child = _currentPrimaryChild;
  15240. if (_currentPrimaryChild !== null) {
  15241. _currentPrimaryChild.return = _primaryChildFragment3;
  15242. } // Even though we're creating a new fiber, there are no new children,
  15243. // because we're reusing an already mounted tree. So we don't need to
  15244. // schedule a placement.
  15245. // primaryChildFragment.effectTag |= Placement;
  15246. if ((workInProgress.mode & BlockingMode) === NoMode) {
  15247. // Outside of blocking mode, we commit the effects from the
  15248. // partially completed, timed-out tree, too.
  15249. var _progressedState2 = workInProgress.memoizedState;
  15250. var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
  15251. _primaryChildFragment3.child = _progressedPrimaryChild2;
  15252. var _progressedChild3 = _progressedPrimaryChild2;
  15253. while (_progressedChild3 !== null) {
  15254. _progressedChild3.return = _primaryChildFragment3;
  15255. _progressedChild3 = _progressedChild3.sibling;
  15256. }
  15257. } // Because primaryChildFragment is a new fiber that we're inserting as the
  15258. // parent of a new tree, we need to set its treeBaseDuration.
  15259. if ( workInProgress.mode & ProfileMode) {
  15260. // treeBaseDuration is the sum of all the child tree base durations.
  15261. var _treeBaseDuration2 = 0;
  15262. var _hiddenChild2 = _primaryChildFragment3.child;
  15263. while (_hiddenChild2 !== null) {
  15264. _treeBaseDuration2 += _hiddenChild2.treeBaseDuration;
  15265. _hiddenChild2 = _hiddenChild2.sibling;
  15266. }
  15267. _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2;
  15268. } // Create a fragment from the fallback children, too.
  15269. var _fallbackChildFragment3 = createFiberFromFragment(_nextFallbackChildren3, mode, renderExpirationTime, null);
  15270. _fallbackChildFragment3.return = workInProgress;
  15271. _primaryChildFragment3.sibling = _fallbackChildFragment3;
  15272. _fallbackChildFragment3.effectTag |= Placement;
  15273. _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
  15274. // fallback children.
  15275. workInProgress.memoizedState = SUSPENDED_MARKER;
  15276. workInProgress.child = _primaryChildFragment3;
  15277. return _fallbackChildFragment3;
  15278. } else {
  15279. // Still haven't timed out. Continue rendering the children, like we
  15280. // normally do.
  15281. workInProgress.memoizedState = null;
  15282. var _nextPrimaryChildren2 = nextProps.children;
  15283. return workInProgress.child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
  15284. }
  15285. }
  15286. }
  15287. }
  15288. function scheduleWorkOnFiber(fiber, renderExpirationTime) {
  15289. if (fiber.expirationTime < renderExpirationTime) {
  15290. fiber.expirationTime = renderExpirationTime;
  15291. }
  15292. var alternate = fiber.alternate;
  15293. if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
  15294. alternate.expirationTime = renderExpirationTime;
  15295. }
  15296. scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
  15297. }
  15298. function propagateSuspenseContextChange(workInProgress, firstChild, renderExpirationTime) {
  15299. // Mark any Suspense boundaries with fallbacks as having work to do.
  15300. // If they were previously forced into fallbacks, they may now be able
  15301. // to unblock.
  15302. var node = firstChild;
  15303. while (node !== null) {
  15304. if (node.tag === SuspenseComponent) {
  15305. var state = node.memoizedState;
  15306. if (state !== null) {
  15307. scheduleWorkOnFiber(node, renderExpirationTime);
  15308. }
  15309. } else if (node.tag === SuspenseListComponent) {
  15310. // If the tail is hidden there might not be an Suspense boundaries
  15311. // to schedule work on. In this case we have to schedule it on the
  15312. // list itself.
  15313. // We don't have to traverse to the children of the list since
  15314. // the list will propagate the change when it rerenders.
  15315. scheduleWorkOnFiber(node, renderExpirationTime);
  15316. } else if (node.child !== null) {
  15317. node.child.return = node;
  15318. node = node.child;
  15319. continue;
  15320. }
  15321. if (node === workInProgress) {
  15322. return;
  15323. }
  15324. while (node.sibling === null) {
  15325. if (node.return === null || node.return === workInProgress) {
  15326. return;
  15327. }
  15328. node = node.return;
  15329. }
  15330. node.sibling.return = node.return;
  15331. node = node.sibling;
  15332. }
  15333. }
  15334. function findLastContentRow(firstChild) {
  15335. // This is going to find the last row among these children that is already
  15336. // showing content on the screen, as opposed to being in fallback state or
  15337. // new. If a row has multiple Suspense boundaries, any of them being in the
  15338. // fallback state, counts as the whole row being in a fallback state.
  15339. // Note that the "rows" will be workInProgress, but any nested children
  15340. // will still be current since we haven't rendered them yet. The mounted
  15341. // order may not be the same as the new order. We use the new order.
  15342. var row = firstChild;
  15343. var lastContentRow = null;
  15344. while (row !== null) {
  15345. var currentRow = row.alternate; // New rows can't be content rows.
  15346. if (currentRow !== null && findFirstSuspended(currentRow) === null) {
  15347. lastContentRow = row;
  15348. }
  15349. row = row.sibling;
  15350. }
  15351. return lastContentRow;
  15352. }
  15353. function validateRevealOrder(revealOrder) {
  15354. {
  15355. if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) {
  15356. didWarnAboutRevealOrder[revealOrder] = true;
  15357. if (typeof revealOrder === 'string') {
  15358. switch (revealOrder.toLowerCase()) {
  15359. case 'together':
  15360. case 'forwards':
  15361. case 'backwards':
  15362. {
  15363. error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
  15364. break;
  15365. }
  15366. case 'forward':
  15367. case 'backward':
  15368. {
  15369. error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
  15370. break;
  15371. }
  15372. default:
  15373. error('"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
  15374. break;
  15375. }
  15376. } else {
  15377. error('%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
  15378. }
  15379. }
  15380. }
  15381. }
  15382. function validateTailOptions(tailMode, revealOrder) {
  15383. {
  15384. if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
  15385. if (tailMode !== 'collapsed' && tailMode !== 'hidden') {
  15386. didWarnAboutTailOptions[tailMode] = true;
  15387. error('"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode);
  15388. } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') {
  15389. didWarnAboutTailOptions[tailMode] = true;
  15390. error('<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode);
  15391. }
  15392. }
  15393. }
  15394. }
  15395. function validateSuspenseListNestedChild(childSlot, index) {
  15396. {
  15397. var isArray = Array.isArray(childSlot);
  15398. var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function';
  15399. if (isArray || isIterable) {
  15400. var type = isArray ? 'array' : 'iterable';
  15401. error('A nested %s was passed to row #%s in <SuspenseList />. Wrap it in ' + 'an additional SuspenseList to configure its revealOrder: ' + '<SuspenseList revealOrder=...> ... ' + '<SuspenseList revealOrder=...>{%s}</SuspenseList> ... ' + '</SuspenseList>', type, index, type);
  15402. return false;
  15403. }
  15404. }
  15405. return true;
  15406. }
  15407. function validateSuspenseListChildren(children, revealOrder) {
  15408. {
  15409. if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) {
  15410. if (Array.isArray(children)) {
  15411. for (var i = 0; i < children.length; i++) {
  15412. if (!validateSuspenseListNestedChild(children[i], i)) {
  15413. return;
  15414. }
  15415. }
  15416. } else {
  15417. var iteratorFn = getIteratorFn(children);
  15418. if (typeof iteratorFn === 'function') {
  15419. var childrenIterator = iteratorFn.call(children);
  15420. if (childrenIterator) {
  15421. var step = childrenIterator.next();
  15422. var _i = 0;
  15423. for (; !step.done; step = childrenIterator.next()) {
  15424. if (!validateSuspenseListNestedChild(step.value, _i)) {
  15425. return;
  15426. }
  15427. _i++;
  15428. }
  15429. }
  15430. } else {
  15431. error('A single row was passed to a <SuspenseList revealOrder="%s" />. ' + 'This is not useful since it needs multiple rows. ' + 'Did you mean to pass multiple children or an array?', revealOrder);
  15432. }
  15433. }
  15434. }
  15435. }
  15436. }
  15437. function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) {
  15438. var renderState = workInProgress.memoizedState;
  15439. if (renderState === null) {
  15440. workInProgress.memoizedState = {
  15441. isBackwards: isBackwards,
  15442. rendering: null,
  15443. renderingStartTime: 0,
  15444. last: lastContentRow,
  15445. tail: tail,
  15446. tailExpiration: 0,
  15447. tailMode: tailMode,
  15448. lastEffect: lastEffectBeforeRendering
  15449. };
  15450. } else {
  15451. // We can reuse the existing object from previous renders.
  15452. renderState.isBackwards = isBackwards;
  15453. renderState.rendering = null;
  15454. renderState.renderingStartTime = 0;
  15455. renderState.last = lastContentRow;
  15456. renderState.tail = tail;
  15457. renderState.tailExpiration = 0;
  15458. renderState.tailMode = tailMode;
  15459. renderState.lastEffect = lastEffectBeforeRendering;
  15460. }
  15461. } // This can end up rendering this component multiple passes.
  15462. // The first pass splits the children fibers into two sets. A head and tail.
  15463. // We first render the head. If anything is in fallback state, we do another
  15464. // pass through beginWork to rerender all children (including the tail) with
  15465. // the force suspend context. If the first render didn't have anything in
  15466. // in fallback state. Then we render each row in the tail one-by-one.
  15467. // That happens in the completeWork phase without going back to beginWork.
  15468. function updateSuspenseListComponent(current, workInProgress, renderExpirationTime) {
  15469. var nextProps = workInProgress.pendingProps;
  15470. var revealOrder = nextProps.revealOrder;
  15471. var tailMode = nextProps.tail;
  15472. var newChildren = nextProps.children;
  15473. validateRevealOrder(revealOrder);
  15474. validateTailOptions(tailMode, revealOrder);
  15475. validateSuspenseListChildren(newChildren, revealOrder);
  15476. reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
  15477. var suspenseContext = suspenseStackCursor.current;
  15478. var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
  15479. if (shouldForceFallback) {
  15480. suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
  15481. workInProgress.effectTag |= DidCapture;
  15482. } else {
  15483. var didSuspendBefore = current !== null && (current.effectTag & DidCapture) !== NoEffect;
  15484. if (didSuspendBefore) {
  15485. // If we previously forced a fallback, we need to schedule work
  15486. // on any nested boundaries to let them know to try to render
  15487. // again. This is the same as context updating.
  15488. propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime);
  15489. }
  15490. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  15491. }
  15492. pushSuspenseContext(workInProgress, suspenseContext);
  15493. if ((workInProgress.mode & BlockingMode) === NoMode) {
  15494. // Outside of blocking mode, SuspenseList doesn't work so we just
  15495. // use make it a noop by treating it as the default revealOrder.
  15496. workInProgress.memoizedState = null;
  15497. } else {
  15498. switch (revealOrder) {
  15499. case 'forwards':
  15500. {
  15501. var lastContentRow = findLastContentRow(workInProgress.child);
  15502. var tail;
  15503. if (lastContentRow === null) {
  15504. // The whole list is part of the tail.
  15505. // TODO: We could fast path by just rendering the tail now.
  15506. tail = workInProgress.child;
  15507. workInProgress.child = null;
  15508. } else {
  15509. // Disconnect the tail rows after the content row.
  15510. // We're going to render them separately later.
  15511. tail = lastContentRow.sibling;
  15512. lastContentRow.sibling = null;
  15513. }
  15514. initSuspenseListRenderState(workInProgress, false, // isBackwards
  15515. tail, lastContentRow, tailMode, workInProgress.lastEffect);
  15516. break;
  15517. }
  15518. case 'backwards':
  15519. {
  15520. // We're going to find the first row that has existing content.
  15521. // At the same time we're going to reverse the list of everything
  15522. // we pass in the meantime. That's going to be our tail in reverse
  15523. // order.
  15524. var _tail = null;
  15525. var row = workInProgress.child;
  15526. workInProgress.child = null;
  15527. while (row !== null) {
  15528. var currentRow = row.alternate; // New rows can't be content rows.
  15529. if (currentRow !== null && findFirstSuspended(currentRow) === null) {
  15530. // This is the beginning of the main content.
  15531. workInProgress.child = row;
  15532. break;
  15533. }
  15534. var nextRow = row.sibling;
  15535. row.sibling = _tail;
  15536. _tail = row;
  15537. row = nextRow;
  15538. } // TODO: If workInProgress.child is null, we can continue on the tail immediately.
  15539. initSuspenseListRenderState(workInProgress, true, // isBackwards
  15540. _tail, null, // last
  15541. tailMode, workInProgress.lastEffect);
  15542. break;
  15543. }
  15544. case 'together':
  15545. {
  15546. initSuspenseListRenderState(workInProgress, false, // isBackwards
  15547. null, // tail
  15548. null, // last
  15549. undefined, workInProgress.lastEffect);
  15550. break;
  15551. }
  15552. default:
  15553. {
  15554. // The default reveal order is the same as not having
  15555. // a boundary.
  15556. workInProgress.memoizedState = null;
  15557. }
  15558. }
  15559. }
  15560. return workInProgress.child;
  15561. }
  15562. function updatePortalComponent(current, workInProgress, renderExpirationTime) {
  15563. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  15564. var nextChildren = workInProgress.pendingProps;
  15565. if (current === null) {
  15566. // Portals are special because we don't append the children during mount
  15567. // but at commit. Therefore we need to track insertions which the normal
  15568. // flow doesn't do during mount. This doesn't happen at the root because
  15569. // the root always starts with a "current" with a null child.
  15570. // TODO: Consider unifying this with how the root works.
  15571. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  15572. } else {
  15573. reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
  15574. }
  15575. return workInProgress.child;
  15576. }
  15577. function updateContextProvider(current, workInProgress, renderExpirationTime) {
  15578. var providerType = workInProgress.type;
  15579. var context = providerType._context;
  15580. var newProps = workInProgress.pendingProps;
  15581. var oldProps = workInProgress.memoizedProps;
  15582. var newValue = newProps.value;
  15583. {
  15584. var providerPropTypes = workInProgress.type.propTypes;
  15585. if (providerPropTypes) {
  15586. checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
  15587. }
  15588. }
  15589. pushProvider(workInProgress, newValue);
  15590. if (oldProps !== null) {
  15591. var oldValue = oldProps.value;
  15592. var changedBits = calculateChangedBits(context, newValue, oldValue);
  15593. if (changedBits === 0) {
  15594. // No change. Bailout early if children are the same.
  15595. if (oldProps.children === newProps.children && !hasContextChanged()) {
  15596. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
  15597. }
  15598. } else {
  15599. // The context value changed. Search for matching consumers and schedule
  15600. // them to update.
  15601. propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
  15602. }
  15603. }
  15604. var newChildren = newProps.children;
  15605. reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
  15606. return workInProgress.child;
  15607. }
  15608. var hasWarnedAboutUsingContextAsConsumer = false;
  15609. function updateContextConsumer(current, workInProgress, renderExpirationTime) {
  15610. var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In
  15611. // DEV mode, we create a separate object for Context.Consumer that acts
  15612. // like a proxy to Context. This proxy object adds unnecessary code in PROD
  15613. // so we use the old behaviour (Context.Consumer references Context) to
  15614. // reduce size and overhead. The separate object references context via
  15615. // a property called "_context", which also gives us the ability to check
  15616. // in DEV mode if this property exists or not and warn if it does not.
  15617. {
  15618. if (context._context === undefined) {
  15619. // This may be because it's a Context (rather than a Consumer).
  15620. // Or it may be because it's older React where they're the same thing.
  15621. // We only want to warn if we're sure it's a new React.
  15622. if (context !== context.Consumer) {
  15623. if (!hasWarnedAboutUsingContextAsConsumer) {
  15624. hasWarnedAboutUsingContextAsConsumer = true;
  15625. error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
  15626. }
  15627. }
  15628. } else {
  15629. context = context._context;
  15630. }
  15631. }
  15632. var newProps = workInProgress.pendingProps;
  15633. var render = newProps.children;
  15634. {
  15635. if (typeof render !== 'function') {
  15636. error('A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.');
  15637. }
  15638. }
  15639. prepareToReadContext(workInProgress, renderExpirationTime);
  15640. var newValue = readContext(context, newProps.unstable_observedBits);
  15641. var newChildren;
  15642. {
  15643. ReactCurrentOwner$1.current = workInProgress;
  15644. setIsRendering(true);
  15645. newChildren = render(newValue);
  15646. setIsRendering(false);
  15647. } // React DevTools reads this flag.
  15648. workInProgress.effectTag |= PerformedWork;
  15649. reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
  15650. return workInProgress.child;
  15651. }
  15652. function markWorkInProgressReceivedUpdate() {
  15653. didReceiveUpdate = true;
  15654. }
  15655. function bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime) {
  15656. cancelWorkTimer(workInProgress);
  15657. if (current !== null) {
  15658. // Reuse previous dependencies
  15659. workInProgress.dependencies = current.dependencies;
  15660. }
  15661. {
  15662. // Don't update "base" render times for bailouts.
  15663. stopProfilerTimerIfRunning();
  15664. }
  15665. var updateExpirationTime = workInProgress.expirationTime;
  15666. if (updateExpirationTime !== NoWork) {
  15667. markUnprocessedUpdateTime(updateExpirationTime);
  15668. } // Check if the children have any pending work.
  15669. var childExpirationTime = workInProgress.childExpirationTime;
  15670. if (childExpirationTime < renderExpirationTime) {
  15671. // The children don't have any work either. We can skip them.
  15672. // TODO: Once we add back resuming, we should check if the children are
  15673. // a work-in-progress set. If so, we need to transfer their effects.
  15674. return null;
  15675. } else {
  15676. // This fiber doesn't have work, but its subtree does. Clone the child
  15677. // fibers and continue.
  15678. cloneChildFibers(current, workInProgress);
  15679. return workInProgress.child;
  15680. }
  15681. }
  15682. function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
  15683. {
  15684. var returnFiber = oldWorkInProgress.return;
  15685. if (returnFiber === null) {
  15686. throw new Error('Cannot swap the root fiber.');
  15687. } // Disconnect from the old current.
  15688. // It will get deleted.
  15689. current.alternate = null;
  15690. oldWorkInProgress.alternate = null; // Connect to the new tree.
  15691. newWorkInProgress.index = oldWorkInProgress.index;
  15692. newWorkInProgress.sibling = oldWorkInProgress.sibling;
  15693. newWorkInProgress.return = oldWorkInProgress.return;
  15694. newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it.
  15695. if (oldWorkInProgress === returnFiber.child) {
  15696. returnFiber.child = newWorkInProgress;
  15697. } else {
  15698. var prevSibling = returnFiber.child;
  15699. if (prevSibling === null) {
  15700. throw new Error('Expected parent to have a child.');
  15701. }
  15702. while (prevSibling.sibling !== oldWorkInProgress) {
  15703. prevSibling = prevSibling.sibling;
  15704. if (prevSibling === null) {
  15705. throw new Error('Expected to find the previous sibling.');
  15706. }
  15707. }
  15708. prevSibling.sibling = newWorkInProgress;
  15709. } // Delete the old fiber and place the new one.
  15710. // Since the old fiber is disconnected, we have to schedule it manually.
  15711. var last = returnFiber.lastEffect;
  15712. if (last !== null) {
  15713. last.nextEffect = current;
  15714. returnFiber.lastEffect = current;
  15715. } else {
  15716. returnFiber.firstEffect = returnFiber.lastEffect = current;
  15717. }
  15718. current.nextEffect = null;
  15719. current.effectTag = Deletion;
  15720. newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber.
  15721. return newWorkInProgress;
  15722. }
  15723. }
  15724. function beginWork(current, workInProgress, renderExpirationTime) {
  15725. var updateExpirationTime = workInProgress.expirationTime;
  15726. {
  15727. if (workInProgress._debugNeedsRemount && current !== null) {
  15728. // This will restart the begin phase with a new fiber.
  15729. return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime));
  15730. }
  15731. }
  15732. if (current !== null) {
  15733. var oldProps = current.memoizedProps;
  15734. var newProps = workInProgress.pendingProps;
  15735. if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload:
  15736. workInProgress.type !== current.type )) {
  15737. // If props or context changed, mark the fiber as having performed work.
  15738. // This may be unset if the props are determined to be equal later (memo).
  15739. didReceiveUpdate = true;
  15740. } else if (updateExpirationTime < renderExpirationTime) {
  15741. didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering
  15742. // the begin phase. There's still some bookkeeping we that needs to be done
  15743. // in this optimized path, mostly pushing stuff onto the stack.
  15744. switch (workInProgress.tag) {
  15745. case HostRoot:
  15746. pushHostRootContext(workInProgress);
  15747. resetHydrationState();
  15748. break;
  15749. case HostComponent:
  15750. pushHostContext(workInProgress);
  15751. if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type, newProps)) {
  15752. {
  15753. markSpawnedWork(Never);
  15754. } // Schedule this fiber to re-render at offscreen priority. Then bailout.
  15755. workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
  15756. return null;
  15757. }
  15758. break;
  15759. case ClassComponent:
  15760. {
  15761. var Component = workInProgress.type;
  15762. if (isContextProvider(Component)) {
  15763. pushContextProvider(workInProgress);
  15764. }
  15765. break;
  15766. }
  15767. case HostPortal:
  15768. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  15769. break;
  15770. case ContextProvider:
  15771. {
  15772. var newValue = workInProgress.memoizedProps.value;
  15773. pushProvider(workInProgress, newValue);
  15774. break;
  15775. }
  15776. case Profiler:
  15777. {
  15778. // Profiler should only call onRender when one of its descendants actually rendered.
  15779. var hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
  15780. if (hasChildWork) {
  15781. workInProgress.effectTag |= Update;
  15782. }
  15783. }
  15784. break;
  15785. case SuspenseComponent:
  15786. {
  15787. var state = workInProgress.memoizedState;
  15788. if (state !== null) {
  15789. // whether to retry the primary children, or to skip over it and
  15790. // go straight to the fallback. Check the priority of the primary
  15791. // child fragment.
  15792. var primaryChildFragment = workInProgress.child;
  15793. var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
  15794. if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
  15795. // The primary children have pending work. Use the normal path
  15796. // to attempt to render the primary children again.
  15797. return updateSuspenseComponent(current, workInProgress, renderExpirationTime);
  15798. } else {
  15799. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient
  15800. // priority. Bailout.
  15801. var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
  15802. if (child !== null) {
  15803. // The fallback children have pending work. Skip over the
  15804. // primary children and work on the fallback.
  15805. return child.sibling;
  15806. } else {
  15807. return null;
  15808. }
  15809. }
  15810. } else {
  15811. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
  15812. }
  15813. break;
  15814. }
  15815. case SuspenseListComponent:
  15816. {
  15817. var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect;
  15818. var _hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
  15819. if (didSuspendBefore) {
  15820. if (_hasChildWork) {
  15821. // If something was in fallback state last time, and we have all the
  15822. // same children then we're still in progressive loading state.
  15823. // Something might get unblocked by state updates or retries in the
  15824. // tree which will affect the tail. So we need to use the normal
  15825. // path to compute the correct tail.
  15826. return updateSuspenseListComponent(current, workInProgress, renderExpirationTime);
  15827. } // If none of the children had any work, that means that none of
  15828. // them got retried so they'll still be blocked in the same way
  15829. // as before. We can fast bail out.
  15830. workInProgress.effectTag |= DidCapture;
  15831. } // If nothing suspended before and we're rendering the same children,
  15832. // then the tail doesn't matter. Anything new that suspends will work
  15833. // in the "together" mode, so we can continue from the state we had.
  15834. var renderState = workInProgress.memoizedState;
  15835. if (renderState !== null) {
  15836. // Reset to the "together" mode in case we've started a different
  15837. // update in the past but didn't complete it.
  15838. renderState.rendering = null;
  15839. renderState.tail = null;
  15840. }
  15841. pushSuspenseContext(workInProgress, suspenseStackCursor.current);
  15842. if (_hasChildWork) {
  15843. break;
  15844. } else {
  15845. // If none of the children had any work, that means that none of
  15846. // them got retried so they'll still be blocked in the same way
  15847. // as before. We can fast bail out.
  15848. return null;
  15849. }
  15850. }
  15851. }
  15852. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
  15853. } else {
  15854. // An update was scheduled on this fiber, but there are no new props
  15855. // nor legacy context. Set this to false. If an update queue or context
  15856. // consumer produces a changed value, it will set this to true. Otherwise,
  15857. // the component will assume the children have not changed and bail out.
  15858. didReceiveUpdate = false;
  15859. }
  15860. } else {
  15861. didReceiveUpdate = false;
  15862. } // Before entering the begin phase, clear pending update priority.
  15863. // TODO: This assumes that we're about to evaluate the component and process
  15864. // the update queue. However, there's an exception: SimpleMemoComponent
  15865. // sometimes bails out later in the begin phase. This indicates that we should
  15866. // move this assignment out of the common path and into each branch.
  15867. workInProgress.expirationTime = NoWork;
  15868. switch (workInProgress.tag) {
  15869. case IndeterminateComponent:
  15870. {
  15871. return mountIndeterminateComponent(current, workInProgress, workInProgress.type, renderExpirationTime);
  15872. }
  15873. case LazyComponent:
  15874. {
  15875. var elementType = workInProgress.elementType;
  15876. return mountLazyComponent(current, workInProgress, elementType, updateExpirationTime, renderExpirationTime);
  15877. }
  15878. case FunctionComponent:
  15879. {
  15880. var _Component = workInProgress.type;
  15881. var unresolvedProps = workInProgress.pendingProps;
  15882. var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
  15883. return updateFunctionComponent(current, workInProgress, _Component, resolvedProps, renderExpirationTime);
  15884. }
  15885. case ClassComponent:
  15886. {
  15887. var _Component2 = workInProgress.type;
  15888. var _unresolvedProps = workInProgress.pendingProps;
  15889. var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
  15890. return updateClassComponent(current, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
  15891. }
  15892. case HostRoot:
  15893. return updateHostRoot(current, workInProgress, renderExpirationTime);
  15894. case HostComponent:
  15895. return updateHostComponent(current, workInProgress, renderExpirationTime);
  15896. case HostText:
  15897. return updateHostText(current, workInProgress);
  15898. case SuspenseComponent:
  15899. return updateSuspenseComponent(current, workInProgress, renderExpirationTime);
  15900. case HostPortal:
  15901. return updatePortalComponent(current, workInProgress, renderExpirationTime);
  15902. case ForwardRef:
  15903. {
  15904. var type = workInProgress.type;
  15905. var _unresolvedProps2 = workInProgress.pendingProps;
  15906. var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
  15907. return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderExpirationTime);
  15908. }
  15909. case Fragment:
  15910. return updateFragment(current, workInProgress, renderExpirationTime);
  15911. case Mode:
  15912. return updateMode(current, workInProgress, renderExpirationTime);
  15913. case Profiler:
  15914. return updateProfiler(current, workInProgress, renderExpirationTime);
  15915. case ContextProvider:
  15916. return updateContextProvider(current, workInProgress, renderExpirationTime);
  15917. case ContextConsumer:
  15918. return updateContextConsumer(current, workInProgress, renderExpirationTime);
  15919. case MemoComponent:
  15920. {
  15921. var _type2 = workInProgress.type;
  15922. var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.
  15923. var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
  15924. {
  15925. if (workInProgress.type !== workInProgress.elementType) {
  15926. var outerPropTypes = _type2.propTypes;
  15927. if (outerPropTypes) {
  15928. checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only
  15929. 'prop', getComponentName(_type2), getCurrentFiberStackInDev);
  15930. }
  15931. }
  15932. }
  15933. _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
  15934. return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);
  15935. }
  15936. case SimpleMemoComponent:
  15937. {
  15938. return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
  15939. }
  15940. case IncompleteClassComponent:
  15941. {
  15942. var _Component3 = workInProgress.type;
  15943. var _unresolvedProps4 = workInProgress.pendingProps;
  15944. var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
  15945. return mountIncompleteClassComponent(current, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
  15946. }
  15947. case SuspenseListComponent:
  15948. {
  15949. return updateSuspenseListComponent(current, workInProgress, renderExpirationTime);
  15950. }
  15951. }
  15952. {
  15953. {
  15954. throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." );
  15955. }
  15956. }
  15957. }
  15958. function markUpdate(workInProgress) {
  15959. // Tag the fiber with an update effect. This turns a Placement into
  15960. // a PlacementAndUpdate.
  15961. workInProgress.effectTag |= Update;
  15962. }
  15963. function markRef$1(workInProgress) {
  15964. workInProgress.effectTag |= Ref;
  15965. }
  15966. var appendAllChildren;
  15967. var updateHostContainer;
  15968. var updateHostComponent$1;
  15969. var updateHostText$1;
  15970. {
  15971. // Mutation mode
  15972. appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
  15973. // We only have the top Fiber that was created but we need recurse down its
  15974. // children to find all the terminal nodes.
  15975. var node = workInProgress.child;
  15976. while (node !== null) {
  15977. if (node.tag === HostComponent || node.tag === HostText) {
  15978. appendInitialChild(parent, node.stateNode);
  15979. } else if (node.tag === HostPortal) ; else if (node.child !== null) {
  15980. node.child.return = node;
  15981. node = node.child;
  15982. continue;
  15983. }
  15984. if (node === workInProgress) {
  15985. return;
  15986. }
  15987. while (node.sibling === null) {
  15988. if (node.return === null || node.return === workInProgress) {
  15989. return;
  15990. }
  15991. node = node.return;
  15992. }
  15993. node.sibling.return = node.return;
  15994. node = node.sibling;
  15995. }
  15996. };
  15997. updateHostContainer = function (workInProgress) {// Noop
  15998. };
  15999. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  16000. // If we have an alternate, that means this is an update and we need to
  16001. // schedule a side-effect to do the updates.
  16002. var oldProps = current.memoizedProps;
  16003. if (oldProps === newProps) {
  16004. // In mutation mode, this is sufficient for a bailout because
  16005. // we won't touch this node even if children changed.
  16006. return;
  16007. } // If we get updated because one of our children updated, we don't
  16008. // have newProps so we'll have to reuse them.
  16009. // TODO: Split the update API as separate for the props vs. children.
  16010. // Even better would be if children weren't special cased at all tho.
  16011. var instance = workInProgress.stateNode;
  16012. var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host
  16013. // component is hitting the resume path. Figure out why. Possibly
  16014. // related to `hidden`.
  16015. var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); // TODO: Type this specific to this type of component.
  16016. workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
  16017. // is a new ref we mark this as an update. All the work is done in commitWork.
  16018. if (updatePayload) {
  16019. markUpdate(workInProgress);
  16020. }
  16021. };
  16022. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  16023. // If the text differs, mark it as an update. All the work in done in commitWork.
  16024. if (oldText !== newText) {
  16025. markUpdate(workInProgress);
  16026. }
  16027. };
  16028. }
  16029. function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
  16030. switch (renderState.tailMode) {
  16031. case 'hidden':
  16032. {
  16033. // Any insertions at the end of the tail list after this point
  16034. // should be invisible. If there are already mounted boundaries
  16035. // anything before them are not considered for collapsing.
  16036. // Therefore we need to go through the whole tail to find if
  16037. // there are any.
  16038. var tailNode = renderState.tail;
  16039. var lastTailNode = null;
  16040. while (tailNode !== null) {
  16041. if (tailNode.alternate !== null) {
  16042. lastTailNode = tailNode;
  16043. }
  16044. tailNode = tailNode.sibling;
  16045. } // Next we're simply going to delete all insertions after the
  16046. // last rendered item.
  16047. if (lastTailNode === null) {
  16048. // All remaining items in the tail are insertions.
  16049. renderState.tail = null;
  16050. } else {
  16051. // Detach the insertion after the last node that was already
  16052. // inserted.
  16053. lastTailNode.sibling = null;
  16054. }
  16055. break;
  16056. }
  16057. case 'collapsed':
  16058. {
  16059. // Any insertions at the end of the tail list after this point
  16060. // should be invisible. If there are already mounted boundaries
  16061. // anything before them are not considered for collapsing.
  16062. // Therefore we need to go through the whole tail to find if
  16063. // there are any.
  16064. var _tailNode = renderState.tail;
  16065. var _lastTailNode = null;
  16066. while (_tailNode !== null) {
  16067. if (_tailNode.alternate !== null) {
  16068. _lastTailNode = _tailNode;
  16069. }
  16070. _tailNode = _tailNode.sibling;
  16071. } // Next we're simply going to delete all insertions after the
  16072. // last rendered item.
  16073. if (_lastTailNode === null) {
  16074. // All remaining items in the tail are insertions.
  16075. if (!hasRenderedATailFallback && renderState.tail !== null) {
  16076. // We suspended during the head. We want to show at least one
  16077. // row at the tail. So we'll keep on and cut off the rest.
  16078. renderState.tail.sibling = null;
  16079. } else {
  16080. renderState.tail = null;
  16081. }
  16082. } else {
  16083. // Detach the insertion after the last node that was already
  16084. // inserted.
  16085. _lastTailNode.sibling = null;
  16086. }
  16087. break;
  16088. }
  16089. }
  16090. }
  16091. function completeWork(current, workInProgress, renderExpirationTime) {
  16092. var newProps = workInProgress.pendingProps;
  16093. switch (workInProgress.tag) {
  16094. case IndeterminateComponent:
  16095. case LazyComponent:
  16096. case SimpleMemoComponent:
  16097. case FunctionComponent:
  16098. case ForwardRef:
  16099. case Fragment:
  16100. case Mode:
  16101. case Profiler:
  16102. case ContextConsumer:
  16103. case MemoComponent:
  16104. return null;
  16105. case ClassComponent:
  16106. {
  16107. var Component = workInProgress.type;
  16108. if (isContextProvider(Component)) {
  16109. popContext(workInProgress);
  16110. }
  16111. return null;
  16112. }
  16113. case HostRoot:
  16114. {
  16115. popHostContainer(workInProgress);
  16116. popTopLevelContextObject(workInProgress);
  16117. var fiberRoot = workInProgress.stateNode;
  16118. if (fiberRoot.pendingContext) {
  16119. fiberRoot.context = fiberRoot.pendingContext;
  16120. fiberRoot.pendingContext = null;
  16121. }
  16122. if (current === null || current.child === null) {
  16123. // If we hydrated, pop so that we can delete any remaining children
  16124. // that weren't hydrated.
  16125. var wasHydrated = popHydrationState(workInProgress);
  16126. if (wasHydrated) {
  16127. // If we hydrated, then we'll need to schedule an update for
  16128. // the commit side-effects on the root.
  16129. markUpdate(workInProgress);
  16130. }
  16131. }
  16132. updateHostContainer(workInProgress);
  16133. return null;
  16134. }
  16135. case HostComponent:
  16136. {
  16137. popHostContext(workInProgress);
  16138. var rootContainerInstance = getRootHostContainer();
  16139. var type = workInProgress.type;
  16140. if (current !== null && workInProgress.stateNode != null) {
  16141. updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
  16142. if (current.ref !== workInProgress.ref) {
  16143. markRef$1(workInProgress);
  16144. }
  16145. } else {
  16146. if (!newProps) {
  16147. if (!(workInProgress.stateNode !== null)) {
  16148. {
  16149. throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." );
  16150. }
  16151. } // This can happen when we abort work.
  16152. return null;
  16153. }
  16154. var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context
  16155. // "stack" as the parent. Then append children as we go in beginWork
  16156. // or completeWork depending on whether we want to add them top->down or
  16157. // bottom->up. Top->down is faster in IE11.
  16158. var _wasHydrated = popHydrationState(workInProgress);
  16159. if (_wasHydrated) {
  16160. // TODO: Move this and createInstance step into the beginPhase
  16161. // to consolidate.
  16162. if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
  16163. // If changes to the hydrated node need to be applied at the
  16164. // commit-phase we mark this as such.
  16165. markUpdate(workInProgress);
  16166. }
  16167. } else {
  16168. var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
  16169. appendAllChildren(instance, workInProgress, false, false); // This needs to be set before we mount Flare event listeners
  16170. workInProgress.stateNode = instance;
  16171. // (eg DOM renderer supports auto-focus for certain elements).
  16172. // Make sure such renderers get scheduled for later work.
  16173. if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) {
  16174. markUpdate(workInProgress);
  16175. }
  16176. }
  16177. if (workInProgress.ref !== null) {
  16178. // If there is a ref on a host node we need to schedule a callback
  16179. markRef$1(workInProgress);
  16180. }
  16181. }
  16182. return null;
  16183. }
  16184. case HostText:
  16185. {
  16186. var newText = newProps;
  16187. if (current && workInProgress.stateNode != null) {
  16188. var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need
  16189. // to schedule a side-effect to do the updates.
  16190. updateHostText$1(current, workInProgress, oldText, newText);
  16191. } else {
  16192. if (typeof newText !== 'string') {
  16193. if (!(workInProgress.stateNode !== null)) {
  16194. {
  16195. throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." );
  16196. }
  16197. } // This can happen when we abort work.
  16198. }
  16199. var _rootContainerInstance = getRootHostContainer();
  16200. var _currentHostContext = getHostContext();
  16201. var _wasHydrated2 = popHydrationState(workInProgress);
  16202. if (_wasHydrated2) {
  16203. if (prepareToHydrateHostTextInstance(workInProgress)) {
  16204. markUpdate(workInProgress);
  16205. }
  16206. } else {
  16207. workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
  16208. }
  16209. }
  16210. return null;
  16211. }
  16212. case SuspenseComponent:
  16213. {
  16214. popSuspenseContext(workInProgress);
  16215. var nextState = workInProgress.memoizedState;
  16216. if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
  16217. // Something suspended. Re-render with the fallback children.
  16218. workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list.
  16219. return workInProgress;
  16220. }
  16221. var nextDidTimeout = nextState !== null;
  16222. var prevDidTimeout = false;
  16223. if (current === null) {
  16224. if (workInProgress.memoizedProps.fallback !== undefined) {
  16225. popHydrationState(workInProgress);
  16226. }
  16227. } else {
  16228. var prevState = current.memoizedState;
  16229. prevDidTimeout = prevState !== null;
  16230. if (!nextDidTimeout && prevState !== null) {
  16231. // We just switched from the fallback to the normal children.
  16232. // Delete the fallback.
  16233. // TODO: Would it be better to store the fallback fragment on
  16234. // the stateNode during the begin phase?
  16235. var currentFallbackChild = current.child.sibling;
  16236. if (currentFallbackChild !== null) {
  16237. // Deletions go at the beginning of the return fiber's effect list
  16238. var first = workInProgress.firstEffect;
  16239. if (first !== null) {
  16240. workInProgress.firstEffect = currentFallbackChild;
  16241. currentFallbackChild.nextEffect = first;
  16242. } else {
  16243. workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
  16244. currentFallbackChild.nextEffect = null;
  16245. }
  16246. currentFallbackChild.effectTag = Deletion;
  16247. }
  16248. }
  16249. }
  16250. if (nextDidTimeout && !prevDidTimeout) {
  16251. // If this subtreee is running in blocking mode we can suspend,
  16252. // otherwise we won't suspend.
  16253. // TODO: This will still suspend a synchronous tree if anything
  16254. // in the concurrent tree already suspended during this render.
  16255. // This is a known bug.
  16256. if ((workInProgress.mode & BlockingMode) !== NoMode) {
  16257. // TODO: Move this back to throwException because this is too late
  16258. // if this is a large tree which is common for initial loads. We
  16259. // don't know if we should restart a render or not until we get
  16260. // this marker, and this is too late.
  16261. // If this render already had a ping or lower pri updates,
  16262. // and this is the first time we know we're going to suspend we
  16263. // should be able to immediately restart from within throwException.
  16264. var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
  16265. if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
  16266. // If this was in an invisible tree or a new render, then showing
  16267. // this boundary is ok.
  16268. renderDidSuspend();
  16269. } else {
  16270. // Otherwise, we're going to have to hide content so we should
  16271. // suspend for longer if possible.
  16272. renderDidSuspendDelayIfPossible();
  16273. }
  16274. }
  16275. }
  16276. {
  16277. // TODO: Only schedule updates if these values are non equal, i.e. it changed.
  16278. if (nextDidTimeout || prevDidTimeout) {
  16279. // If this boundary just timed out, schedule an effect to attach a
  16280. // retry listener to the promise. This flag is also used to hide the
  16281. // primary children. In mutation mode, we also need the flag to
  16282. // *unhide* children that were previously hidden, so check if this
  16283. // is currently timed out, too.
  16284. workInProgress.effectTag |= Update;
  16285. }
  16286. }
  16287. return null;
  16288. }
  16289. case HostPortal:
  16290. popHostContainer(workInProgress);
  16291. updateHostContainer(workInProgress);
  16292. return null;
  16293. case ContextProvider:
  16294. // Pop provider fiber
  16295. popProvider(workInProgress);
  16296. return null;
  16297. case IncompleteClassComponent:
  16298. {
  16299. // Same as class component case. I put it down here so that the tags are
  16300. // sequential to ensure this switch is compiled to a jump table.
  16301. var _Component = workInProgress.type;
  16302. if (isContextProvider(_Component)) {
  16303. popContext(workInProgress);
  16304. }
  16305. return null;
  16306. }
  16307. case SuspenseListComponent:
  16308. {
  16309. popSuspenseContext(workInProgress);
  16310. var renderState = workInProgress.memoizedState;
  16311. if (renderState === null) {
  16312. // We're running in the default, "independent" mode.
  16313. // We don't do anything in this mode.
  16314. return null;
  16315. }
  16316. var didSuspendAlready = (workInProgress.effectTag & DidCapture) !== NoEffect;
  16317. var renderedTail = renderState.rendering;
  16318. if (renderedTail === null) {
  16319. // We just rendered the head.
  16320. if (!didSuspendAlready) {
  16321. // This is the first pass. We need to figure out if anything is still
  16322. // suspended in the rendered set.
  16323. // If new content unsuspended, but there's still some content that
  16324. // didn't. Then we need to do a second pass that forces everything
  16325. // to keep showing their fallbacks.
  16326. // We might be suspended if something in this render pass suspended, or
  16327. // something in the previous committed pass suspended. Otherwise,
  16328. // there's no chance so we can skip the expensive call to
  16329. // findFirstSuspended.
  16330. var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.effectTag & DidCapture) === NoEffect);
  16331. if (!cannotBeSuspended) {
  16332. var row = workInProgress.child;
  16333. while (row !== null) {
  16334. var suspended = findFirstSuspended(row);
  16335. if (suspended !== null) {
  16336. didSuspendAlready = true;
  16337. workInProgress.effectTag |= DidCapture;
  16338. cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as
  16339. // part of the second pass. In that case nothing will subscribe to
  16340. // its thennables. Instead, we'll transfer its thennables to the
  16341. // SuspenseList so that it can retry if they resolve.
  16342. // There might be multiple of these in the list but since we're
  16343. // going to wait for all of them anyway, it doesn't really matter
  16344. // which ones gets to ping. In theory we could get clever and keep
  16345. // track of how many dependencies remain but it gets tricky because
  16346. // in the meantime, we can add/remove/change items and dependencies.
  16347. // We might bail out of the loop before finding any but that
  16348. // doesn't matter since that means that the other boundaries that
  16349. // we did find already has their listeners attached.
  16350. var newThennables = suspended.updateQueue;
  16351. if (newThennables !== null) {
  16352. workInProgress.updateQueue = newThennables;
  16353. workInProgress.effectTag |= Update;
  16354. } // Rerender the whole list, but this time, we'll force fallbacks
  16355. // to stay in place.
  16356. // Reset the effect list before doing the second pass since that's now invalid.
  16357. if (renderState.lastEffect === null) {
  16358. workInProgress.firstEffect = null;
  16359. }
  16360. workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state.
  16361. resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately
  16362. // rerender the children.
  16363. pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
  16364. return workInProgress.child;
  16365. }
  16366. row = row.sibling;
  16367. }
  16368. }
  16369. } else {
  16370. cutOffTailIfNeeded(renderState, false);
  16371. } // Next we're going to render the tail.
  16372. } else {
  16373. // Append the rendered row to the child list.
  16374. if (!didSuspendAlready) {
  16375. var _suspended = findFirstSuspended(renderedTail);
  16376. if (_suspended !== null) {
  16377. workInProgress.effectTag |= DidCapture;
  16378. didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't
  16379. // get lost if this row ends up dropped during a second pass.
  16380. var _newThennables = _suspended.updateQueue;
  16381. if (_newThennables !== null) {
  16382. workInProgress.updateQueue = _newThennables;
  16383. workInProgress.effectTag |= Update;
  16384. }
  16385. cutOffTailIfNeeded(renderState, true); // This might have been modified.
  16386. if (renderState.tail === null && renderState.tailMode === 'hidden' && !renderedTail.alternate) {
  16387. // We need to delete the row we just rendered.
  16388. // Reset the effect list to what it was before we rendered this
  16389. // child. The nested children have already appended themselves.
  16390. var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point.
  16391. if (lastEffect !== null) {
  16392. lastEffect.nextEffect = null;
  16393. } // We're done.
  16394. return null;
  16395. }
  16396. } else if ( // The time it took to render last row is greater than time until
  16397. // the expiration.
  16398. now() * 2 - renderState.renderingStartTime > renderState.tailExpiration && renderExpirationTime > Never) {
  16399. // We have now passed our CPU deadline and we'll just give up further
  16400. // attempts to render the main content and only render fallbacks.
  16401. // The assumption is that this is usually faster.
  16402. workInProgress.effectTag |= DidCapture;
  16403. didSuspendAlready = true;
  16404. cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
  16405. // to get it started back up to attempt the next item. If we can show
  16406. // them, then they really have the same priority as this render.
  16407. // So we'll pick it back up the very next render pass once we've had
  16408. // an opportunity to yield for paint.
  16409. var nextPriority = renderExpirationTime - 1;
  16410. workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority;
  16411. {
  16412. markSpawnedWork(nextPriority);
  16413. }
  16414. }
  16415. }
  16416. if (renderState.isBackwards) {
  16417. // The effect list of the backwards tail will have been added
  16418. // to the end. This breaks the guarantee that life-cycles fire in
  16419. // sibling order but that isn't a strong guarantee promised by React.
  16420. // Especially since these might also just pop in during future commits.
  16421. // Append to the beginning of the list.
  16422. renderedTail.sibling = workInProgress.child;
  16423. workInProgress.child = renderedTail;
  16424. } else {
  16425. var previousSibling = renderState.last;
  16426. if (previousSibling !== null) {
  16427. previousSibling.sibling = renderedTail;
  16428. } else {
  16429. workInProgress.child = renderedTail;
  16430. }
  16431. renderState.last = renderedTail;
  16432. }
  16433. }
  16434. if (renderState.tail !== null) {
  16435. // We still have tail rows to render.
  16436. if (renderState.tailExpiration === 0) {
  16437. // Heuristic for how long we're willing to spend rendering rows
  16438. // until we just give up and show what we have so far.
  16439. var TAIL_EXPIRATION_TIMEOUT_MS = 500;
  16440. renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS; // TODO: This is meant to mimic the train model or JND but this
  16441. // is a per component value. It should really be since the start
  16442. // of the total render or last commit. Consider using something like
  16443. // globalMostRecentFallbackTime. That doesn't account for being
  16444. // suspended for part of the time or when it's a new render.
  16445. // It should probably use a global start time value instead.
  16446. } // Pop a row.
  16447. var next = renderState.tail;
  16448. renderState.rendering = next;
  16449. renderState.tail = next.sibling;
  16450. renderState.lastEffect = workInProgress.lastEffect;
  16451. renderState.renderingStartTime = now();
  16452. next.sibling = null; // Restore the context.
  16453. // TODO: We can probably just avoid popping it instead and only
  16454. // setting it the first time we go from not suspended to suspended.
  16455. var suspenseContext = suspenseStackCursor.current;
  16456. if (didSuspendAlready) {
  16457. suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
  16458. } else {
  16459. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  16460. }
  16461. pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row.
  16462. return next;
  16463. }
  16464. return null;
  16465. }
  16466. }
  16467. {
  16468. {
  16469. throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." );
  16470. }
  16471. }
  16472. }
  16473. function unwindWork(workInProgress, renderExpirationTime) {
  16474. switch (workInProgress.tag) {
  16475. case ClassComponent:
  16476. {
  16477. var Component = workInProgress.type;
  16478. if (isContextProvider(Component)) {
  16479. popContext(workInProgress);
  16480. }
  16481. var effectTag = workInProgress.effectTag;
  16482. if (effectTag & ShouldCapture) {
  16483. workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
  16484. return workInProgress;
  16485. }
  16486. return null;
  16487. }
  16488. case HostRoot:
  16489. {
  16490. popHostContainer(workInProgress);
  16491. popTopLevelContextObject(workInProgress);
  16492. var _effectTag = workInProgress.effectTag;
  16493. if (!((_effectTag & DidCapture) === NoEffect)) {
  16494. {
  16495. throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." );
  16496. }
  16497. }
  16498. workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
  16499. return workInProgress;
  16500. }
  16501. case HostComponent:
  16502. {
  16503. // TODO: popHydrationState
  16504. popHostContext(workInProgress);
  16505. return null;
  16506. }
  16507. case SuspenseComponent:
  16508. {
  16509. popSuspenseContext(workInProgress);
  16510. var _effectTag2 = workInProgress.effectTag;
  16511. if (_effectTag2 & ShouldCapture) {
  16512. workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture; // Captured a suspense effect. Re-render the boundary.
  16513. return workInProgress;
  16514. }
  16515. return null;
  16516. }
  16517. case SuspenseListComponent:
  16518. {
  16519. popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been
  16520. // caught by a nested boundary. If not, it should bubble through.
  16521. return null;
  16522. }
  16523. case HostPortal:
  16524. popHostContainer(workInProgress);
  16525. return null;
  16526. case ContextProvider:
  16527. popProvider(workInProgress);
  16528. return null;
  16529. default:
  16530. return null;
  16531. }
  16532. }
  16533. function unwindInterruptedWork(interruptedWork) {
  16534. switch (interruptedWork.tag) {
  16535. case ClassComponent:
  16536. {
  16537. var childContextTypes = interruptedWork.type.childContextTypes;
  16538. if (childContextTypes !== null && childContextTypes !== undefined) {
  16539. popContext(interruptedWork);
  16540. }
  16541. break;
  16542. }
  16543. case HostRoot:
  16544. {
  16545. popHostContainer(interruptedWork);
  16546. popTopLevelContextObject(interruptedWork);
  16547. break;
  16548. }
  16549. case HostComponent:
  16550. {
  16551. popHostContext(interruptedWork);
  16552. break;
  16553. }
  16554. case HostPortal:
  16555. popHostContainer(interruptedWork);
  16556. break;
  16557. case SuspenseComponent:
  16558. popSuspenseContext(interruptedWork);
  16559. break;
  16560. case SuspenseListComponent:
  16561. popSuspenseContext(interruptedWork);
  16562. break;
  16563. case ContextProvider:
  16564. popProvider(interruptedWork);
  16565. break;
  16566. }
  16567. }
  16568. function createCapturedValue(value, source) {
  16569. // If the value is an error, call this function immediately after it is thrown
  16570. // so the stack is accurate.
  16571. return {
  16572. value: value,
  16573. source: source,
  16574. stack: getStackByFiberInDevAndProd(source)
  16575. };
  16576. }
  16577. function logCapturedError(capturedError) {
  16578. var error = capturedError.error;
  16579. {
  16580. var componentName = capturedError.componentName,
  16581. componentStack = capturedError.componentStack,
  16582. errorBoundaryName = capturedError.errorBoundaryName,
  16583. errorBoundaryFound = capturedError.errorBoundaryFound,
  16584. willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling
  16585. // `preventDefault()` in window `error` handler.
  16586. // We record this information as an expando on the error.
  16587. if (error != null && error._suppressLogging) {
  16588. if (errorBoundaryFound && willRetry) {
  16589. // The error is recoverable and was silenced.
  16590. // Ignore it and don't print the stack addendum.
  16591. // This is handy for testing error boundaries without noise.
  16592. return;
  16593. } // The error is fatal. Since the silencing might have
  16594. // been accidental, we'll surface it anyway.
  16595. // However, the browser would have silenced the original error
  16596. // so we'll print it first, and then print the stack addendum.
  16597. console['error'](error); // Don't transform to our wrapper
  16598. // For a more detailed description of this block, see:
  16599. // https://github.com/facebook/react/pull/13384
  16600. }
  16601. var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:';
  16602. var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
  16603. if (errorBoundaryFound && errorBoundaryName) {
  16604. if (willRetry) {
  16605. errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
  16606. } else {
  16607. errorBoundaryMessage = "This error was initially handled by the error boundary " + errorBoundaryName + ".\n" + "Recreating the tree from scratch failed so React will unmount the tree.";
  16608. }
  16609. } else {
  16610. errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://fb.me/react-error-boundaries to learn more about error boundaries.';
  16611. }
  16612. var combinedMessage = "" + componentNameMessage + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack.
  16613. // We don't include the original error message and JS stack because the browser
  16614. // has already printed it. Even if the application swallows the error, it is still
  16615. // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
  16616. console['error'](combinedMessage); // Don't transform to our wrapper
  16617. }
  16618. }
  16619. var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
  16620. {
  16621. didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
  16622. }
  16623. var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
  16624. function logError(boundary, errorInfo) {
  16625. var source = errorInfo.source;
  16626. var stack = errorInfo.stack;
  16627. if (stack === null && source !== null) {
  16628. stack = getStackByFiberInDevAndProd(source);
  16629. }
  16630. var capturedError = {
  16631. componentName: source !== null ? getComponentName(source.type) : null,
  16632. componentStack: stack !== null ? stack : '',
  16633. error: errorInfo.value,
  16634. errorBoundary: null,
  16635. errorBoundaryName: null,
  16636. errorBoundaryFound: false,
  16637. willRetry: false
  16638. };
  16639. if (boundary !== null && boundary.tag === ClassComponent) {
  16640. capturedError.errorBoundary = boundary.stateNode;
  16641. capturedError.errorBoundaryName = getComponentName(boundary.type);
  16642. capturedError.errorBoundaryFound = true;
  16643. capturedError.willRetry = true;
  16644. }
  16645. try {
  16646. logCapturedError(capturedError);
  16647. } catch (e) {
  16648. // This method must not throw, or React internal state will get messed up.
  16649. // If console.error is overridden, or logCapturedError() shows a dialog that throws,
  16650. // we want to report this error outside of the normal stack as a last resort.
  16651. // https://github.com/facebook/react/issues/13188
  16652. setTimeout(function () {
  16653. throw e;
  16654. });
  16655. }
  16656. }
  16657. var callComponentWillUnmountWithTimer = function (current, instance) {
  16658. startPhaseTimer(current, 'componentWillUnmount');
  16659. instance.props = current.memoizedProps;
  16660. instance.state = current.memoizedState;
  16661. instance.componentWillUnmount();
  16662. stopPhaseTimer();
  16663. }; // Capture errors so they don't interrupt unmounting.
  16664. function safelyCallComponentWillUnmount(current, instance) {
  16665. {
  16666. invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance);
  16667. if (hasCaughtError()) {
  16668. var unmountError = clearCaughtError();
  16669. captureCommitPhaseError(current, unmountError);
  16670. }
  16671. }
  16672. }
  16673. function safelyDetachRef(current) {
  16674. var ref = current.ref;
  16675. if (ref !== null) {
  16676. if (typeof ref === 'function') {
  16677. {
  16678. invokeGuardedCallback(null, ref, null, null);
  16679. if (hasCaughtError()) {
  16680. var refError = clearCaughtError();
  16681. captureCommitPhaseError(current, refError);
  16682. }
  16683. }
  16684. } else {
  16685. ref.current = null;
  16686. }
  16687. }
  16688. }
  16689. function safelyCallDestroy(current, destroy) {
  16690. {
  16691. invokeGuardedCallback(null, destroy, null);
  16692. if (hasCaughtError()) {
  16693. var error = clearCaughtError();
  16694. captureCommitPhaseError(current, error);
  16695. }
  16696. }
  16697. }
  16698. function commitBeforeMutationLifeCycles(current, finishedWork) {
  16699. switch (finishedWork.tag) {
  16700. case FunctionComponent:
  16701. case ForwardRef:
  16702. case SimpleMemoComponent:
  16703. case Block:
  16704. {
  16705. return;
  16706. }
  16707. case ClassComponent:
  16708. {
  16709. if (finishedWork.effectTag & Snapshot) {
  16710. if (current !== null) {
  16711. var prevProps = current.memoizedProps;
  16712. var prevState = current.memoizedState;
  16713. startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
  16714. var instance = finishedWork.stateNode; // We could update instance props and state here,
  16715. // but instead we rely on them being set during last render.
  16716. // TODO: revisit this when we implement resuming.
  16717. {
  16718. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  16719. if (instance.props !== finishedWork.memoizedProps) {
  16720. error('Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  16721. }
  16722. if (instance.state !== finishedWork.memoizedState) {
  16723. error('Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  16724. }
  16725. }
  16726. }
  16727. var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
  16728. {
  16729. var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
  16730. if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
  16731. didWarnSet.add(finishedWork.type);
  16732. error('%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
  16733. }
  16734. }
  16735. instance.__reactInternalSnapshotBeforeUpdate = snapshot;
  16736. stopPhaseTimer();
  16737. }
  16738. }
  16739. return;
  16740. }
  16741. case HostRoot:
  16742. case HostComponent:
  16743. case HostText:
  16744. case HostPortal:
  16745. case IncompleteClassComponent:
  16746. // Nothing to do for these component types
  16747. return;
  16748. }
  16749. {
  16750. {
  16751. throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." );
  16752. }
  16753. }
  16754. }
  16755. function commitHookEffectListUnmount(tag, finishedWork) {
  16756. var updateQueue = finishedWork.updateQueue;
  16757. var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
  16758. if (lastEffect !== null) {
  16759. var firstEffect = lastEffect.next;
  16760. var effect = firstEffect;
  16761. do {
  16762. if ((effect.tag & tag) === tag) {
  16763. // Unmount
  16764. var destroy = effect.destroy;
  16765. effect.destroy = undefined;
  16766. if (destroy !== undefined) {
  16767. destroy();
  16768. }
  16769. }
  16770. effect = effect.next;
  16771. } while (effect !== firstEffect);
  16772. }
  16773. }
  16774. function commitHookEffectListMount(tag, finishedWork) {
  16775. var updateQueue = finishedWork.updateQueue;
  16776. var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
  16777. if (lastEffect !== null) {
  16778. var firstEffect = lastEffect.next;
  16779. var effect = firstEffect;
  16780. do {
  16781. if ((effect.tag & tag) === tag) {
  16782. // Mount
  16783. var create = effect.create;
  16784. effect.destroy = create();
  16785. {
  16786. var destroy = effect.destroy;
  16787. if (destroy !== undefined && typeof destroy !== 'function') {
  16788. var addendum = void 0;
  16789. if (destroy === null) {
  16790. addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
  16791. } else if (typeof destroy.then === 'function') {
  16792. addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching';
  16793. } else {
  16794. addendum = ' You returned: ' + destroy;
  16795. }
  16796. error('An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
  16797. }
  16798. }
  16799. }
  16800. effect = effect.next;
  16801. } while (effect !== firstEffect);
  16802. }
  16803. }
  16804. function commitPassiveHookEffects(finishedWork) {
  16805. if ((finishedWork.effectTag & Passive) !== NoEffect) {
  16806. switch (finishedWork.tag) {
  16807. case FunctionComponent:
  16808. case ForwardRef:
  16809. case SimpleMemoComponent:
  16810. case Block:
  16811. {
  16812. // TODO (#17945) We should call all passive destroy functions (for all fibers)
  16813. // before calling any create functions. The current approach only serializes
  16814. // these for a single fiber.
  16815. commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork);
  16816. commitHookEffectListMount(Passive$1 | HasEffect, finishedWork);
  16817. break;
  16818. }
  16819. }
  16820. }
  16821. }
  16822. function commitLifeCycles(finishedRoot, current, finishedWork, committedExpirationTime) {
  16823. switch (finishedWork.tag) {
  16824. case FunctionComponent:
  16825. case ForwardRef:
  16826. case SimpleMemoComponent:
  16827. case Block:
  16828. {
  16829. // At this point layout effects have already been destroyed (during mutation phase).
  16830. // This is done to prevent sibling component effects from interfering with each other,
  16831. // e.g. a destroy function in one component should never override a ref set
  16832. // by a create function in another component during the same commit.
  16833. commitHookEffectListMount(Layout | HasEffect, finishedWork);
  16834. return;
  16835. }
  16836. case ClassComponent:
  16837. {
  16838. var instance = finishedWork.stateNode;
  16839. if (finishedWork.effectTag & Update) {
  16840. if (current === null) {
  16841. startPhaseTimer(finishedWork, 'componentDidMount'); // We could update instance props and state here,
  16842. // but instead we rely on them being set during last render.
  16843. // TODO: revisit this when we implement resuming.
  16844. {
  16845. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  16846. if (instance.props !== finishedWork.memoizedProps) {
  16847. error('Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  16848. }
  16849. if (instance.state !== finishedWork.memoizedState) {
  16850. error('Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  16851. }
  16852. }
  16853. }
  16854. instance.componentDidMount();
  16855. stopPhaseTimer();
  16856. } else {
  16857. var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps);
  16858. var prevState = current.memoizedState;
  16859. startPhaseTimer(finishedWork, 'componentDidUpdate'); // We could update instance props and state here,
  16860. // but instead we rely on them being set during last render.
  16861. // TODO: revisit this when we implement resuming.
  16862. {
  16863. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  16864. if (instance.props !== finishedWork.memoizedProps) {
  16865. error('Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  16866. }
  16867. if (instance.state !== finishedWork.memoizedState) {
  16868. error('Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  16869. }
  16870. }
  16871. }
  16872. instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
  16873. stopPhaseTimer();
  16874. }
  16875. }
  16876. var updateQueue = finishedWork.updateQueue;
  16877. if (updateQueue !== null) {
  16878. {
  16879. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  16880. if (instance.props !== finishedWork.memoizedProps) {
  16881. error('Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  16882. }
  16883. if (instance.state !== finishedWork.memoizedState) {
  16884. error('Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  16885. }
  16886. }
  16887. } // We could update instance props and state here,
  16888. // but instead we rely on them being set during last render.
  16889. // TODO: revisit this when we implement resuming.
  16890. commitUpdateQueue(finishedWork, updateQueue, instance);
  16891. }
  16892. return;
  16893. }
  16894. case HostRoot:
  16895. {
  16896. var _updateQueue = finishedWork.updateQueue;
  16897. if (_updateQueue !== null) {
  16898. var _instance = null;
  16899. if (finishedWork.child !== null) {
  16900. switch (finishedWork.child.tag) {
  16901. case HostComponent:
  16902. _instance = getPublicInstance(finishedWork.child.stateNode);
  16903. break;
  16904. case ClassComponent:
  16905. _instance = finishedWork.child.stateNode;
  16906. break;
  16907. }
  16908. }
  16909. commitUpdateQueue(finishedWork, _updateQueue, _instance);
  16910. }
  16911. return;
  16912. }
  16913. case HostComponent:
  16914. {
  16915. var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted
  16916. // (eg DOM renderer may schedule auto-focus for inputs and form controls).
  16917. // These effects should only be committed when components are first mounted,
  16918. // aka when there is no current/alternate.
  16919. if (current === null && finishedWork.effectTag & Update) {
  16920. var type = finishedWork.type;
  16921. var props = finishedWork.memoizedProps;
  16922. commitMount(_instance2, type, props);
  16923. }
  16924. return;
  16925. }
  16926. case HostText:
  16927. {
  16928. // We have no life-cycles associated with text.
  16929. return;
  16930. }
  16931. case HostPortal:
  16932. {
  16933. // We have no life-cycles associated with portals.
  16934. return;
  16935. }
  16936. case Profiler:
  16937. {
  16938. {
  16939. var onRender = finishedWork.memoizedProps.onRender;
  16940. if (typeof onRender === 'function') {
  16941. {
  16942. onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
  16943. }
  16944. }
  16945. }
  16946. return;
  16947. }
  16948. case SuspenseComponent:
  16949. {
  16950. commitSuspenseHydrationCallbacks(finishedRoot, finishedWork);
  16951. return;
  16952. }
  16953. case SuspenseListComponent:
  16954. case IncompleteClassComponent:
  16955. case FundamentalComponent:
  16956. case ScopeComponent:
  16957. return;
  16958. }
  16959. {
  16960. {
  16961. throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." );
  16962. }
  16963. }
  16964. }
  16965. function hideOrUnhideAllChildren(finishedWork, isHidden) {
  16966. {
  16967. // We only have the top Fiber that was inserted but we need to recurse down its
  16968. // children to find all the terminal nodes.
  16969. var node = finishedWork;
  16970. while (true) {
  16971. if (node.tag === HostComponent) {
  16972. var instance = node.stateNode;
  16973. if (isHidden) {
  16974. hideInstance(instance);
  16975. } else {
  16976. unhideInstance(node.stateNode, node.memoizedProps);
  16977. }
  16978. } else if (node.tag === HostText) {
  16979. var _instance3 = node.stateNode;
  16980. if (isHidden) {
  16981. hideTextInstance(_instance3);
  16982. } else {
  16983. unhideTextInstance(_instance3, node.memoizedProps);
  16984. }
  16985. } else if (node.tag === SuspenseComponent && node.memoizedState !== null && node.memoizedState.dehydrated === null) {
  16986. // Found a nested Suspense component that timed out. Skip over the
  16987. // primary child fragment, which should remain hidden.
  16988. var fallbackChildFragment = node.child.sibling;
  16989. fallbackChildFragment.return = node;
  16990. node = fallbackChildFragment;
  16991. continue;
  16992. } else if (node.child !== null) {
  16993. node.child.return = node;
  16994. node = node.child;
  16995. continue;
  16996. }
  16997. if (node === finishedWork) {
  16998. return;
  16999. }
  17000. while (node.sibling === null) {
  17001. if (node.return === null || node.return === finishedWork) {
  17002. return;
  17003. }
  17004. node = node.return;
  17005. }
  17006. node.sibling.return = node.return;
  17007. node = node.sibling;
  17008. }
  17009. }
  17010. }
  17011. function commitAttachRef(finishedWork) {
  17012. var ref = finishedWork.ref;
  17013. if (ref !== null) {
  17014. var instance = finishedWork.stateNode;
  17015. var instanceToUse;
  17016. switch (finishedWork.tag) {
  17017. case HostComponent:
  17018. instanceToUse = getPublicInstance(instance);
  17019. break;
  17020. default:
  17021. instanceToUse = instance;
  17022. } // Moved outside to ensure DCE works with this flag
  17023. if (typeof ref === 'function') {
  17024. ref(instanceToUse);
  17025. } else {
  17026. {
  17027. if (!ref.hasOwnProperty('current')) {
  17028. error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
  17029. }
  17030. }
  17031. ref.current = instanceToUse;
  17032. }
  17033. }
  17034. }
  17035. function commitDetachRef(current) {
  17036. var currentRef = current.ref;
  17037. if (currentRef !== null) {
  17038. if (typeof currentRef === 'function') {
  17039. currentRef(null);
  17040. } else {
  17041. currentRef.current = null;
  17042. }
  17043. }
  17044. } // User-originating errors (lifecycles and refs) should not interrupt
  17045. // deletion, so don't let them throw. Host-originating errors should
  17046. // interrupt deletion, so it's okay
  17047. function commitUnmount(finishedRoot, current, renderPriorityLevel) {
  17048. onCommitUnmount(current);
  17049. switch (current.tag) {
  17050. case FunctionComponent:
  17051. case ForwardRef:
  17052. case MemoComponent:
  17053. case SimpleMemoComponent:
  17054. case Block:
  17055. {
  17056. var updateQueue = current.updateQueue;
  17057. if (updateQueue !== null) {
  17058. var lastEffect = updateQueue.lastEffect;
  17059. if (lastEffect !== null) {
  17060. var firstEffect = lastEffect.next;
  17061. {
  17062. // When the owner fiber is deleted, the destroy function of a passive
  17063. // effect hook is called during the synchronous commit phase. This is
  17064. // a concession to implementation complexity. Calling it in the
  17065. // passive effect phase (like they usually are, when dependencies
  17066. // change during an update) would require either traversing the
  17067. // children of the deleted fiber again, or including unmount effects
  17068. // as part of the fiber effect list.
  17069. //
  17070. // Because this is during the sync commit phase, we need to change
  17071. // the priority.
  17072. //
  17073. // TODO: Reconsider this implementation trade off.
  17074. var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel;
  17075. runWithPriority$1(priorityLevel, function () {
  17076. var effect = firstEffect;
  17077. do {
  17078. var _destroy = effect.destroy;
  17079. if (_destroy !== undefined) {
  17080. safelyCallDestroy(current, _destroy);
  17081. }
  17082. effect = effect.next;
  17083. } while (effect !== firstEffect);
  17084. });
  17085. }
  17086. }
  17087. }
  17088. return;
  17089. }
  17090. case ClassComponent:
  17091. {
  17092. safelyDetachRef(current);
  17093. var instance = current.stateNode;
  17094. if (typeof instance.componentWillUnmount === 'function') {
  17095. safelyCallComponentWillUnmount(current, instance);
  17096. }
  17097. return;
  17098. }
  17099. case HostComponent:
  17100. {
  17101. safelyDetachRef(current);
  17102. return;
  17103. }
  17104. case HostPortal:
  17105. {
  17106. // TODO: this is recursive.
  17107. // We are also not using this parent because
  17108. // the portal will get pushed immediately.
  17109. {
  17110. unmountHostComponents(finishedRoot, current, renderPriorityLevel);
  17111. }
  17112. return;
  17113. }
  17114. case FundamentalComponent:
  17115. {
  17116. return;
  17117. }
  17118. case DehydratedFragment:
  17119. {
  17120. return;
  17121. }
  17122. case ScopeComponent:
  17123. {
  17124. return;
  17125. }
  17126. }
  17127. }
  17128. function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
  17129. // While we're inside a removed host node we don't want to call
  17130. // removeChild on the inner nodes because they're removed by the top
  17131. // call anyway. We also want to call componentWillUnmount on all
  17132. // composites before this host node is removed from the tree. Therefore
  17133. // we do an inner loop while we're still inside the host node.
  17134. var node = root;
  17135. while (true) {
  17136. commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes.
  17137. // Skip portals because commitUnmount() currently visits them recursively.
  17138. if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above.
  17139. // If we don't use mutation we drill down into portals here instead.
  17140. node.tag !== HostPortal)) {
  17141. node.child.return = node;
  17142. node = node.child;
  17143. continue;
  17144. }
  17145. if (node === root) {
  17146. return;
  17147. }
  17148. while (node.sibling === null) {
  17149. if (node.return === null || node.return === root) {
  17150. return;
  17151. }
  17152. node = node.return;
  17153. }
  17154. node.sibling.return = node.return;
  17155. node = node.sibling;
  17156. }
  17157. }
  17158. function detachFiber(current) {
  17159. var alternate = current.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we
  17160. // should clear the child pointer of the parent alternate to let this
  17161. // get GC:ed but we don't know which for sure which parent is the current
  17162. // one so we'll settle for GC:ing the subtree of this child. This child
  17163. // itself will be GC:ed when the parent updates the next time.
  17164. current.return = null;
  17165. current.child = null;
  17166. current.memoizedState = null;
  17167. current.updateQueue = null;
  17168. current.dependencies = null;
  17169. current.alternate = null;
  17170. current.firstEffect = null;
  17171. current.lastEffect = null;
  17172. current.pendingProps = null;
  17173. current.memoizedProps = null;
  17174. current.stateNode = null;
  17175. if (alternate !== null) {
  17176. detachFiber(alternate);
  17177. }
  17178. }
  17179. function getHostParentFiber(fiber) {
  17180. var parent = fiber.return;
  17181. while (parent !== null) {
  17182. if (isHostParent(parent)) {
  17183. return parent;
  17184. }
  17185. parent = parent.return;
  17186. }
  17187. {
  17188. {
  17189. throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." );
  17190. }
  17191. }
  17192. }
  17193. function isHostParent(fiber) {
  17194. return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
  17195. }
  17196. function getHostSibling(fiber) {
  17197. // We're going to search forward into the tree until we find a sibling host
  17198. // node. Unfortunately, if multiple insertions are done in a row we have to
  17199. // search past them. This leads to exponential search for the next sibling.
  17200. // TODO: Find a more efficient way to do this.
  17201. var node = fiber;
  17202. siblings: while (true) {
  17203. // If we didn't find anything, let's try the next sibling.
  17204. while (node.sibling === null) {
  17205. if (node.return === null || isHostParent(node.return)) {
  17206. // If we pop out of the root or hit the parent the fiber we are the
  17207. // last sibling.
  17208. return null;
  17209. }
  17210. node = node.return;
  17211. }
  17212. node.sibling.return = node.return;
  17213. node = node.sibling;
  17214. while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) {
  17215. // If it is not host node and, we might have a host node inside it.
  17216. // Try to search down until we find one.
  17217. if (node.effectTag & Placement) {
  17218. // If we don't have a child, try the siblings instead.
  17219. continue siblings;
  17220. } // If we don't have a child, try the siblings instead.
  17221. // We also skip portals because they are not part of this host tree.
  17222. if (node.child === null || node.tag === HostPortal) {
  17223. continue siblings;
  17224. } else {
  17225. node.child.return = node;
  17226. node = node.child;
  17227. }
  17228. } // Check if this host node is stable or about to be placed.
  17229. if (!(node.effectTag & Placement)) {
  17230. // Found it!
  17231. return node.stateNode;
  17232. }
  17233. }
  17234. }
  17235. function commitPlacement(finishedWork) {
  17236. var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together.
  17237. var parent;
  17238. var isContainer;
  17239. var parentStateNode = parentFiber.stateNode;
  17240. switch (parentFiber.tag) {
  17241. case HostComponent:
  17242. parent = parentStateNode;
  17243. isContainer = false;
  17244. break;
  17245. case HostRoot:
  17246. parent = parentStateNode.containerInfo;
  17247. isContainer = true;
  17248. break;
  17249. case HostPortal:
  17250. parent = parentStateNode.containerInfo;
  17251. isContainer = true;
  17252. break;
  17253. case FundamentalComponent:
  17254. // eslint-disable-next-line-no-fallthrough
  17255. default:
  17256. {
  17257. {
  17258. throw Error( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." );
  17259. }
  17260. }
  17261. }
  17262. if (parentFiber.effectTag & ContentReset) {
  17263. // Reset the text content of the parent before doing any insertions
  17264. resetTextContent(parent); // Clear ContentReset from the effect tag
  17265. parentFiber.effectTag &= ~ContentReset;
  17266. }
  17267. var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its
  17268. // children to find all the terminal nodes.
  17269. if (isContainer) {
  17270. insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent);
  17271. } else {
  17272. insertOrAppendPlacementNode(finishedWork, before, parent);
  17273. }
  17274. }
  17275. function insertOrAppendPlacementNodeIntoContainer(node, before, parent) {
  17276. var tag = node.tag;
  17277. var isHost = tag === HostComponent || tag === HostText;
  17278. if (isHost || enableFundamentalAPI ) {
  17279. var stateNode = isHost ? node.stateNode : node.stateNode.instance;
  17280. if (before) {
  17281. insertInContainerBefore(parent, stateNode, before);
  17282. } else {
  17283. appendChildToContainer(parent, stateNode);
  17284. }
  17285. } else if (tag === HostPortal) ; else {
  17286. var child = node.child;
  17287. if (child !== null) {
  17288. insertOrAppendPlacementNodeIntoContainer(child, before, parent);
  17289. var sibling = child.sibling;
  17290. while (sibling !== null) {
  17291. insertOrAppendPlacementNodeIntoContainer(sibling, before, parent);
  17292. sibling = sibling.sibling;
  17293. }
  17294. }
  17295. }
  17296. }
  17297. function insertOrAppendPlacementNode(node, before, parent) {
  17298. var tag = node.tag;
  17299. var isHost = tag === HostComponent || tag === HostText;
  17300. if (isHost || enableFundamentalAPI ) {
  17301. var stateNode = isHost ? node.stateNode : node.stateNode.instance;
  17302. if (before) {
  17303. insertBefore(parent, stateNode, before);
  17304. } else {
  17305. appendChild(parent, stateNode);
  17306. }
  17307. } else if (tag === HostPortal) ; else {
  17308. var child = node.child;
  17309. if (child !== null) {
  17310. insertOrAppendPlacementNode(child, before, parent);
  17311. var sibling = child.sibling;
  17312. while (sibling !== null) {
  17313. insertOrAppendPlacementNode(sibling, before, parent);
  17314. sibling = sibling.sibling;
  17315. }
  17316. }
  17317. }
  17318. }
  17319. function unmountHostComponents(finishedRoot, current, renderPriorityLevel) {
  17320. // We only have the top Fiber that was deleted but we need to recurse down its
  17321. // children to find all the terminal nodes.
  17322. var node = current; // Each iteration, currentParent is populated with node's host parent if not
  17323. // currentParentIsValid.
  17324. var currentParentIsValid = false; // Note: these two variables *must* always be updated together.
  17325. var currentParent;
  17326. var currentParentIsContainer;
  17327. while (true) {
  17328. if (!currentParentIsValid) {
  17329. var parent = node.return;
  17330. findParent: while (true) {
  17331. if (!(parent !== null)) {
  17332. {
  17333. throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." );
  17334. }
  17335. }
  17336. var parentStateNode = parent.stateNode;
  17337. switch (parent.tag) {
  17338. case HostComponent:
  17339. currentParent = parentStateNode;
  17340. currentParentIsContainer = false;
  17341. break findParent;
  17342. case HostRoot:
  17343. currentParent = parentStateNode.containerInfo;
  17344. currentParentIsContainer = true;
  17345. break findParent;
  17346. case HostPortal:
  17347. currentParent = parentStateNode.containerInfo;
  17348. currentParentIsContainer = true;
  17349. break findParent;
  17350. }
  17351. parent = parent.return;
  17352. }
  17353. currentParentIsValid = true;
  17354. }
  17355. if (node.tag === HostComponent || node.tag === HostText) {
  17356. commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the
  17357. // node from the tree.
  17358. if (currentParentIsContainer) {
  17359. removeChildFromContainer(currentParent, node.stateNode);
  17360. } else {
  17361. removeChild(currentParent, node.stateNode);
  17362. } // Don't visit children because we already visited them.
  17363. } else if (node.tag === HostPortal) {
  17364. if (node.child !== null) {
  17365. // When we go into a portal, it becomes the parent to remove from.
  17366. // We will reassign it back when we pop the portal on the way up.
  17367. currentParent = node.stateNode.containerInfo;
  17368. currentParentIsContainer = true; // Visit children because portals might contain host components.
  17369. node.child.return = node;
  17370. node = node.child;
  17371. continue;
  17372. }
  17373. } else {
  17374. commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because we may find more host components below.
  17375. if (node.child !== null) {
  17376. node.child.return = node;
  17377. node = node.child;
  17378. continue;
  17379. }
  17380. }
  17381. if (node === current) {
  17382. return;
  17383. }
  17384. while (node.sibling === null) {
  17385. if (node.return === null || node.return === current) {
  17386. return;
  17387. }
  17388. node = node.return;
  17389. if (node.tag === HostPortal) {
  17390. // When we go out of the portal, we need to restore the parent.
  17391. // Since we don't keep a stack of them, we will search for it.
  17392. currentParentIsValid = false;
  17393. }
  17394. }
  17395. node.sibling.return = node.return;
  17396. node = node.sibling;
  17397. }
  17398. }
  17399. function commitDeletion(finishedRoot, current, renderPriorityLevel) {
  17400. {
  17401. // Recursively delete all host nodes from the parent.
  17402. // Detach refs and call componentWillUnmount() on the whole subtree.
  17403. unmountHostComponents(finishedRoot, current, renderPriorityLevel);
  17404. }
  17405. detachFiber(current);
  17406. }
  17407. function commitWork(current, finishedWork) {
  17408. switch (finishedWork.tag) {
  17409. case FunctionComponent:
  17410. case ForwardRef:
  17411. case MemoComponent:
  17412. case SimpleMemoComponent:
  17413. case Block:
  17414. {
  17415. // Layout effects are destroyed during the mutation phase so that all
  17416. // destroy functions for all fibers are called before any create functions.
  17417. // This prevents sibling component effects from interfering with each other,
  17418. // e.g. a destroy function in one component should never override a ref set
  17419. // by a create function in another component during the same commit.
  17420. commitHookEffectListUnmount(Layout | HasEffect, finishedWork);
  17421. return;
  17422. }
  17423. case ClassComponent:
  17424. {
  17425. return;
  17426. }
  17427. case HostComponent:
  17428. {
  17429. var instance = finishedWork.stateNode;
  17430. if (instance != null) {
  17431. // Commit the work prepared earlier.
  17432. var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
  17433. // as the newProps. The updatePayload will contain the real change in
  17434. // this case.
  17435. var oldProps = current !== null ? current.memoizedProps : newProps;
  17436. var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components.
  17437. var updatePayload = finishedWork.updateQueue;
  17438. finishedWork.updateQueue = null;
  17439. if (updatePayload !== null) {
  17440. commitUpdate(instance, updatePayload, type, oldProps, newProps);
  17441. }
  17442. }
  17443. return;
  17444. }
  17445. case HostText:
  17446. {
  17447. if (!(finishedWork.stateNode !== null)) {
  17448. {
  17449. throw Error( "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." );
  17450. }
  17451. }
  17452. var textInstance = finishedWork.stateNode;
  17453. var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
  17454. // as the newProps. The updatePayload will contain the real change in
  17455. // this case.
  17456. var oldText = current !== null ? current.memoizedProps : newText;
  17457. commitTextUpdate(textInstance, oldText, newText);
  17458. return;
  17459. }
  17460. case HostRoot:
  17461. {
  17462. {
  17463. var _root = finishedWork.stateNode;
  17464. if (_root.hydrate) {
  17465. // We've just hydrated. No need to hydrate again.
  17466. _root.hydrate = false;
  17467. commitHydratedContainer(_root.containerInfo);
  17468. }
  17469. }
  17470. return;
  17471. }
  17472. case Profiler:
  17473. {
  17474. return;
  17475. }
  17476. case SuspenseComponent:
  17477. {
  17478. commitSuspenseComponent(finishedWork);
  17479. attachSuspenseRetryListeners(finishedWork);
  17480. return;
  17481. }
  17482. case SuspenseListComponent:
  17483. {
  17484. attachSuspenseRetryListeners(finishedWork);
  17485. return;
  17486. }
  17487. case IncompleteClassComponent:
  17488. {
  17489. return;
  17490. }
  17491. }
  17492. {
  17493. {
  17494. throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." );
  17495. }
  17496. }
  17497. }
  17498. function commitSuspenseComponent(finishedWork) {
  17499. var newState = finishedWork.memoizedState;
  17500. var newDidTimeout;
  17501. var primaryChildParent = finishedWork;
  17502. if (newState === null) {
  17503. newDidTimeout = false;
  17504. } else {
  17505. newDidTimeout = true;
  17506. primaryChildParent = finishedWork.child;
  17507. markCommitTimeOfFallback();
  17508. }
  17509. if ( primaryChildParent !== null) {
  17510. hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
  17511. }
  17512. }
  17513. function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) {
  17514. var newState = finishedWork.memoizedState;
  17515. if (newState === null) {
  17516. var current = finishedWork.alternate;
  17517. if (current !== null) {
  17518. var prevState = current.memoizedState;
  17519. if (prevState !== null) {
  17520. var suspenseInstance = prevState.dehydrated;
  17521. if (suspenseInstance !== null) {
  17522. commitHydratedSuspenseInstance(suspenseInstance);
  17523. }
  17524. }
  17525. }
  17526. }
  17527. }
  17528. function attachSuspenseRetryListeners(finishedWork) {
  17529. // If this boundary just timed out, then it will have a set of thenables.
  17530. // For each thenable, attach a listener so that when it resolves, React
  17531. // attempts to re-render the boundary in the primary (pre-timeout) state.
  17532. var thenables = finishedWork.updateQueue;
  17533. if (thenables !== null) {
  17534. finishedWork.updateQueue = null;
  17535. var retryCache = finishedWork.stateNode;
  17536. if (retryCache === null) {
  17537. retryCache = finishedWork.stateNode = new PossiblyWeakSet();
  17538. }
  17539. thenables.forEach(function (thenable) {
  17540. // Memoize using the boundary fiber to prevent redundant listeners.
  17541. var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
  17542. if (!retryCache.has(thenable)) {
  17543. {
  17544. if (thenable.__reactDoNotTraceInteractions !== true) {
  17545. retry = tracing.unstable_wrap(retry);
  17546. }
  17547. }
  17548. retryCache.add(thenable);
  17549. thenable.then(retry, retry);
  17550. }
  17551. });
  17552. }
  17553. }
  17554. function commitResetTextContent(current) {
  17555. resetTextContent(current.stateNode);
  17556. }
  17557. var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map;
  17558. function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
  17559. var update = createUpdate(expirationTime, null); // Unmount the root by rendering null.
  17560. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property
  17561. // being called "element".
  17562. update.payload = {
  17563. element: null
  17564. };
  17565. var error = errorInfo.value;
  17566. update.callback = function () {
  17567. onUncaughtError(error);
  17568. logError(fiber, errorInfo);
  17569. };
  17570. return update;
  17571. }
  17572. function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
  17573. var update = createUpdate(expirationTime, null);
  17574. update.tag = CaptureUpdate;
  17575. var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
  17576. if (typeof getDerivedStateFromError === 'function') {
  17577. var error$1 = errorInfo.value;
  17578. update.payload = function () {
  17579. logError(fiber, errorInfo);
  17580. return getDerivedStateFromError(error$1);
  17581. };
  17582. }
  17583. var inst = fiber.stateNode;
  17584. if (inst !== null && typeof inst.componentDidCatch === 'function') {
  17585. update.callback = function callback() {
  17586. {
  17587. markFailedErrorBoundaryForHotReloading(fiber);
  17588. }
  17589. if (typeof getDerivedStateFromError !== 'function') {
  17590. // To preserve the preexisting retry behavior of error boundaries,
  17591. // we keep track of which ones already failed during this batch.
  17592. // This gets reset before we yield back to the browser.
  17593. // TODO: Warn in strict mode if getDerivedStateFromError is
  17594. // not defined.
  17595. markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined
  17596. logError(fiber, errorInfo);
  17597. }
  17598. var error$1 = errorInfo.value;
  17599. var stack = errorInfo.stack;
  17600. this.componentDidCatch(error$1, {
  17601. componentStack: stack !== null ? stack : ''
  17602. });
  17603. {
  17604. if (typeof getDerivedStateFromError !== 'function') {
  17605. // If componentDidCatch is the only error boundary method defined,
  17606. // then it needs to call setState to recover from errors.
  17607. // If no state update is scheduled then the boundary will swallow the error.
  17608. if (fiber.expirationTime !== Sync) {
  17609. error('%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown');
  17610. }
  17611. }
  17612. }
  17613. };
  17614. } else {
  17615. update.callback = function () {
  17616. markFailedErrorBoundaryForHotReloading(fiber);
  17617. };
  17618. }
  17619. return update;
  17620. }
  17621. function attachPingListener(root, renderExpirationTime, thenable) {
  17622. // Attach a listener to the promise to "ping" the root and retry. But
  17623. // only if one does not already exist for the current render expiration
  17624. // time (which acts like a "thread ID" here).
  17625. var pingCache = root.pingCache;
  17626. var threadIDs;
  17627. if (pingCache === null) {
  17628. pingCache = root.pingCache = new PossiblyWeakMap$1();
  17629. threadIDs = new Set();
  17630. pingCache.set(thenable, threadIDs);
  17631. } else {
  17632. threadIDs = pingCache.get(thenable);
  17633. if (threadIDs === undefined) {
  17634. threadIDs = new Set();
  17635. pingCache.set(thenable, threadIDs);
  17636. }
  17637. }
  17638. if (!threadIDs.has(renderExpirationTime)) {
  17639. // Memoize using the thread ID to prevent redundant listeners.
  17640. threadIDs.add(renderExpirationTime);
  17641. var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
  17642. thenable.then(ping, ping);
  17643. }
  17644. }
  17645. function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
  17646. // The source fiber did not complete.
  17647. sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid.
  17648. sourceFiber.firstEffect = sourceFiber.lastEffect = null;
  17649. if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
  17650. // This is a thenable.
  17651. var thenable = value;
  17652. if ((sourceFiber.mode & BlockingMode) === NoMode) {
  17653. // Reset the memoizedState to what it was before we attempted
  17654. // to render it.
  17655. var currentSource = sourceFiber.alternate;
  17656. if (currentSource) {
  17657. sourceFiber.updateQueue = currentSource.updateQueue;
  17658. sourceFiber.memoizedState = currentSource.memoizedState;
  17659. sourceFiber.expirationTime = currentSource.expirationTime;
  17660. } else {
  17661. sourceFiber.updateQueue = null;
  17662. sourceFiber.memoizedState = null;
  17663. }
  17664. }
  17665. var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext); // Schedule the nearest Suspense to re-render the timed out view.
  17666. var _workInProgress = returnFiber;
  17667. do {
  17668. if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) {
  17669. // Found the nearest boundary.
  17670. // Stash the promise on the boundary fiber. If the boundary times out, we'll
  17671. // attach another listener to flip the boundary back to its normal state.
  17672. var thenables = _workInProgress.updateQueue;
  17673. if (thenables === null) {
  17674. var updateQueue = new Set();
  17675. updateQueue.add(thenable);
  17676. _workInProgress.updateQueue = updateQueue;
  17677. } else {
  17678. thenables.add(thenable);
  17679. } // If the boundary is outside of blocking mode, we should *not*
  17680. // suspend the commit. Pretend as if the suspended component rendered
  17681. // null and keep rendering. In the commit phase, we'll schedule a
  17682. // subsequent synchronous update to re-render the Suspense.
  17683. //
  17684. // Note: It doesn't matter whether the component that suspended was
  17685. // inside a blocking mode tree. If the Suspense is outside of it, we
  17686. // should *not* suspend the commit.
  17687. if ((_workInProgress.mode & BlockingMode) === NoMode) {
  17688. _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete.
  17689. // But we shouldn't call any lifecycle methods or callbacks. Remove
  17690. // all lifecycle effect tags.
  17691. sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
  17692. if (sourceFiber.tag === ClassComponent) {
  17693. var currentSourceFiber = sourceFiber.alternate;
  17694. if (currentSourceFiber === null) {
  17695. // This is a new mount. Change the tag so it's not mistaken for a
  17696. // completed class component. For example, we should not call
  17697. // componentWillUnmount if it is deleted.
  17698. sourceFiber.tag = IncompleteClassComponent;
  17699. } else {
  17700. // When we try rendering again, we should not reuse the current fiber,
  17701. // since it's known to be in an inconsistent state. Use a force update to
  17702. // prevent a bail out.
  17703. var update = createUpdate(Sync, null);
  17704. update.tag = ForceUpdate;
  17705. enqueueUpdate(sourceFiber, update);
  17706. }
  17707. } // The source fiber did not complete. Mark it with Sync priority to
  17708. // indicate that it still has pending work.
  17709. sourceFiber.expirationTime = Sync; // Exit without suspending.
  17710. return;
  17711. } // Confirmed that the boundary is in a concurrent mode tree. Continue
  17712. // with the normal suspend path.
  17713. //
  17714. // After this we'll use a set of heuristics to determine whether this
  17715. // render pass will run to completion or restart or "suspend" the commit.
  17716. // The actual logic for this is spread out in different places.
  17717. //
  17718. // This first principle is that if we're going to suspend when we complete
  17719. // a root, then we should also restart if we get an update or ping that
  17720. // might unsuspend it, and vice versa. The only reason to suspend is
  17721. // because you think you might want to restart before committing. However,
  17722. // it doesn't make sense to restart only while in the period we're suspended.
  17723. //
  17724. // Restarting too aggressively is also not good because it starves out any
  17725. // intermediate loading state. So we use heuristics to determine when.
  17726. // Suspense Heuristics
  17727. //
  17728. // If nothing threw a Promise or all the same fallbacks are already showing,
  17729. // then don't suspend/restart.
  17730. //
  17731. // If this is an initial render of a new tree of Suspense boundaries and
  17732. // those trigger a fallback, then don't suspend/restart. We want to ensure
  17733. // that we can show the initial loading state as quickly as possible.
  17734. //
  17735. // If we hit a "Delayed" case, such as when we'd switch from content back into
  17736. // a fallback, then we should always suspend/restart. SuspenseConfig applies to
  17737. // this case. If none is defined, JND is used instead.
  17738. //
  17739. // If we're already showing a fallback and it gets "retried", allowing us to show
  17740. // another level, but there's still an inner boundary that would show a fallback,
  17741. // then we suspend/restart for 500ms since the last time we showed a fallback
  17742. // anywhere in the tree. This effectively throttles progressive loading into a
  17743. // consistent train of commits. This also gives us an opportunity to restart to
  17744. // get to the completed state slightly earlier.
  17745. //
  17746. // If there's ambiguity due to batching it's resolved in preference of:
  17747. // 1) "delayed", 2) "initial render", 3) "retry".
  17748. //
  17749. // We want to ensure that a "busy" state doesn't get force committed. We want to
  17750. // ensure that new initial loading states can commit as soon as possible.
  17751. attachPingListener(root, renderExpirationTime, thenable);
  17752. _workInProgress.effectTag |= ShouldCapture;
  17753. _workInProgress.expirationTime = renderExpirationTime;
  17754. return;
  17755. } // This boundary already captured during this render. Continue to the next
  17756. // boundary.
  17757. _workInProgress = _workInProgress.return;
  17758. } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode.
  17759. // TODO: Use invariant so the message is stripped in prod?
  17760. value = new Error((getComponentName(sourceFiber.type) || 'A React component') + ' suspended while rendering, but no fallback UI was specified.\n' + '\n' + 'Add a <Suspense fallback=...> component higher in the tree to ' + 'provide a loading indicator or placeholder to display.' + getStackByFiberInDevAndProd(sourceFiber));
  17761. } // We didn't find a boundary that could handle this type of exception. Start
  17762. // over and traverse parent path again, this time treating the exception
  17763. // as an error.
  17764. renderDidError();
  17765. value = createCapturedValue(value, sourceFiber);
  17766. var workInProgress = returnFiber;
  17767. do {
  17768. switch (workInProgress.tag) {
  17769. case HostRoot:
  17770. {
  17771. var _errorInfo = value;
  17772. workInProgress.effectTag |= ShouldCapture;
  17773. workInProgress.expirationTime = renderExpirationTime;
  17774. var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
  17775. enqueueCapturedUpdate(workInProgress, _update);
  17776. return;
  17777. }
  17778. case ClassComponent:
  17779. // Capture and retry
  17780. var errorInfo = value;
  17781. var ctor = workInProgress.type;
  17782. var instance = workInProgress.stateNode;
  17783. if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
  17784. workInProgress.effectTag |= ShouldCapture;
  17785. workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state
  17786. var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
  17787. enqueueCapturedUpdate(workInProgress, _update2);
  17788. return;
  17789. }
  17790. break;
  17791. }
  17792. workInProgress = workInProgress.return;
  17793. } while (workInProgress !== null);
  17794. }
  17795. var ceil = Math.ceil;
  17796. var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
  17797. ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
  17798. IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
  17799. var NoContext =
  17800. /* */
  17801. 0;
  17802. var BatchedContext =
  17803. /* */
  17804. 1;
  17805. var EventContext =
  17806. /* */
  17807. 2;
  17808. var DiscreteEventContext =
  17809. /* */
  17810. 4;
  17811. var LegacyUnbatchedContext =
  17812. /* */
  17813. 8;
  17814. var RenderContext =
  17815. /* */
  17816. 16;
  17817. var CommitContext =
  17818. /* */
  17819. 32;
  17820. var RootIncomplete = 0;
  17821. var RootFatalErrored = 1;
  17822. var RootErrored = 2;
  17823. var RootSuspended = 3;
  17824. var RootSuspendedWithDelay = 4;
  17825. var RootCompleted = 5;
  17826. // Describes where we are in the React execution stack
  17827. var executionContext = NoContext; // The root we're working on
  17828. var workInProgressRoot = null; // The fiber we're working on
  17829. var workInProgress = null; // The expiration time we're rendering
  17830. var renderExpirationTime$1 = NoWork; // Whether to root completed, errored, suspended, etc.
  17831. var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown
  17832. var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render.
  17833. // This is conceptually a time stamp but expressed in terms of an ExpirationTime
  17834. // because we deal mostly with expiration times in the hot path, so this avoids
  17835. // the conversion happening in the hot path.
  17836. var workInProgressRootLatestProcessedExpirationTime = Sync;
  17837. var workInProgressRootLatestSuspenseTimeout = Sync;
  17838. var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only
  17839. // includes unprocessed updates, not work in bailed out children.
  17840. var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately.
  17841. // This flag determines if it might be worthwhile to restart if an opportunity
  17842. // happens latere.
  17843. var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train
  17844. // model where we don't commit new loading states in too quick succession.
  17845. var globalMostRecentFallbackTime = 0;
  17846. var FALLBACK_THROTTLE_MS = 500;
  17847. var nextEffect = null;
  17848. var hasUncaughtError = false;
  17849. var firstUncaughtError = null;
  17850. var legacyErrorBoundariesThatAlreadyFailed = null;
  17851. var rootDoesHavePassiveEffects = false;
  17852. var rootWithPendingPassiveEffects = null;
  17853. var pendingPassiveEffectsRenderPriority = NoPriority;
  17854. var pendingPassiveEffectsExpirationTime = NoWork;
  17855. var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates
  17856. var NESTED_UPDATE_LIMIT = 50;
  17857. var nestedUpdateCount = 0;
  17858. var rootWithNestedUpdates = null;
  17859. var NESTED_PASSIVE_UPDATE_LIMIT = 50;
  17860. var nestedPassiveUpdateCount = 0;
  17861. var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times
  17862. // during the commit phase. This enables them to be traced across components
  17863. // that spawn new work during render. E.g. hidden boundaries, suspended SSR
  17864. // hydration or SuspenseList.
  17865. var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start
  17866. // time). However, if two updates are scheduled within the same event, we
  17867. // should treat their start times as simultaneous, even if the actual clock
  17868. // time has advanced between the first and second call.
  17869. // In other words, because expiration times determine how updates are batched,
  17870. // we want all updates of like priority that occur within the same event to
  17871. // receive the same expiration time. Otherwise we get tearing.
  17872. var currentEventTime = NoWork;
  17873. function requestCurrentTimeForUpdate() {
  17874. if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
  17875. // We're inside React, so it's fine to read the actual time.
  17876. return msToExpirationTime(now());
  17877. } // We're not inside React, so we may be in the middle of a browser event.
  17878. if (currentEventTime !== NoWork) {
  17879. // Use the same start time for all updates until we enter React again.
  17880. return currentEventTime;
  17881. } // This is the first update since React yielded. Compute a new start time.
  17882. currentEventTime = msToExpirationTime(now());
  17883. return currentEventTime;
  17884. }
  17885. function getCurrentTime() {
  17886. return msToExpirationTime(now());
  17887. }
  17888. function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
  17889. var mode = fiber.mode;
  17890. if ((mode & BlockingMode) === NoMode) {
  17891. return Sync;
  17892. }
  17893. var priorityLevel = getCurrentPriorityLevel();
  17894. if ((mode & ConcurrentMode) === NoMode) {
  17895. return priorityLevel === ImmediatePriority ? Sync : Batched;
  17896. }
  17897. if ((executionContext & RenderContext) !== NoContext) {
  17898. // Use whatever time we're already rendering
  17899. // TODO: Should there be a way to opt out, like with `runWithPriority`?
  17900. return renderExpirationTime$1;
  17901. }
  17902. var expirationTime;
  17903. if (suspenseConfig !== null) {
  17904. // Compute an expiration time based on the Suspense timeout.
  17905. expirationTime = computeSuspenseExpiration(currentTime, suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
  17906. } else {
  17907. // Compute an expiration time based on the Scheduler priority.
  17908. switch (priorityLevel) {
  17909. case ImmediatePriority:
  17910. expirationTime = Sync;
  17911. break;
  17912. case UserBlockingPriority$1:
  17913. // TODO: Rename this to computeUserBlockingExpiration
  17914. expirationTime = computeInteractiveExpiration(currentTime);
  17915. break;
  17916. case NormalPriority:
  17917. case LowPriority:
  17918. // TODO: Handle LowPriority
  17919. // TODO: Rename this to... something better.
  17920. expirationTime = computeAsyncExpiration(currentTime);
  17921. break;
  17922. case IdlePriority:
  17923. expirationTime = Idle;
  17924. break;
  17925. default:
  17926. {
  17927. {
  17928. throw Error( "Expected a valid priority level" );
  17929. }
  17930. }
  17931. }
  17932. } // If we're in the middle of rendering a tree, do not update at the same
  17933. // expiration time that is already rendering.
  17934. // TODO: We shouldn't have to do this if the update is on a different root.
  17935. // Refactor computeExpirationForFiber + scheduleUpdate so we have access to
  17936. // the root when we check for this condition.
  17937. if (workInProgressRoot !== null && expirationTime === renderExpirationTime$1) {
  17938. // This is a trick to move this update into a separate batch
  17939. expirationTime -= 1;
  17940. }
  17941. return expirationTime;
  17942. }
  17943. function scheduleUpdateOnFiber(fiber, expirationTime) {
  17944. checkForNestedUpdates();
  17945. warnAboutRenderPhaseUpdatesInDEV(fiber);
  17946. var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
  17947. if (root === null) {
  17948. warnAboutUpdateOnUnmountedFiberInDEV(fiber);
  17949. return;
  17950. }
  17951. checkForInterruption(fiber, expirationTime);
  17952. recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the
  17953. // priority as an argument to that function and this one.
  17954. var priorityLevel = getCurrentPriorityLevel();
  17955. if (expirationTime === Sync) {
  17956. if ( // Check if we're inside unbatchedUpdates
  17957. (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
  17958. (executionContext & (RenderContext | CommitContext)) === NoContext) {
  17959. // Register pending interactions on the root to avoid losing traced interaction data.
  17960. schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
  17961. // root inside of batchedUpdates should be synchronous, but layout updates
  17962. // should be deferred until the end of the batch.
  17963. performSyncWorkOnRoot(root);
  17964. } else {
  17965. ensureRootIsScheduled(root);
  17966. schedulePendingInteractions(root, expirationTime);
  17967. if (executionContext === NoContext) {
  17968. // Flush the synchronous work now, unless we're already working or inside
  17969. // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
  17970. // scheduleCallbackForFiber to preserve the ability to schedule a callback
  17971. // without immediately flushing it. We only do this for user-initiated
  17972. // updates, to preserve historical behavior of legacy mode.
  17973. flushSyncCallbackQueue();
  17974. }
  17975. }
  17976. } else {
  17977. ensureRootIsScheduled(root);
  17978. schedulePendingInteractions(root, expirationTime);
  17979. }
  17980. if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered
  17981. // discrete, even inside a discrete event.
  17982. priorityLevel === UserBlockingPriority$1 || priorityLevel === ImmediatePriority)) {
  17983. // This is the result of a discrete event. Track the lowest priority
  17984. // discrete update per root so we can flush them early, if needed.
  17985. if (rootsWithPendingDiscreteUpdates === null) {
  17986. rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
  17987. } else {
  17988. var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
  17989. if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
  17990. rootsWithPendingDiscreteUpdates.set(root, expirationTime);
  17991. }
  17992. }
  17993. }
  17994. }
  17995. var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending
  17996. // work without treating it as a typical update that originates from an event;
  17997. // e.g. retrying a Suspense boundary isn't an update, but it does schedule work
  17998. // on a fiber.
  17999. function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
  18000. // Update the source fiber's expiration time
  18001. if (fiber.expirationTime < expirationTime) {
  18002. fiber.expirationTime = expirationTime;
  18003. }
  18004. var alternate = fiber.alternate;
  18005. if (alternate !== null && alternate.expirationTime < expirationTime) {
  18006. alternate.expirationTime = expirationTime;
  18007. } // Walk the parent path to the root and update the child expiration time.
  18008. var node = fiber.return;
  18009. var root = null;
  18010. if (node === null && fiber.tag === HostRoot) {
  18011. root = fiber.stateNode;
  18012. } else {
  18013. while (node !== null) {
  18014. alternate = node.alternate;
  18015. if (node.childExpirationTime < expirationTime) {
  18016. node.childExpirationTime = expirationTime;
  18017. if (alternate !== null && alternate.childExpirationTime < expirationTime) {
  18018. alternate.childExpirationTime = expirationTime;
  18019. }
  18020. } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
  18021. alternate.childExpirationTime = expirationTime;
  18022. }
  18023. if (node.return === null && node.tag === HostRoot) {
  18024. root = node.stateNode;
  18025. break;
  18026. }
  18027. node = node.return;
  18028. }
  18029. }
  18030. if (root !== null) {
  18031. if (workInProgressRoot === root) {
  18032. // Received an update to a tree that's in the middle of rendering. Mark
  18033. // that's unprocessed work on this root.
  18034. markUnprocessedUpdateTime(expirationTime);
  18035. if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
  18036. // The root already suspended with a delay, which means this render
  18037. // definitely won't finish. Since we have a new update, let's mark it as
  18038. // suspended now, right before marking the incoming update. This has the
  18039. // effect of interrupting the current render and switching to the update.
  18040. // TODO: This happens to work when receiving an update during the render
  18041. // phase, because of the trick inside computeExpirationForFiber to
  18042. // subtract 1 from `renderExpirationTime` to move it into a
  18043. // separate bucket. But we should probably model it with an exception,
  18044. // using the same mechanism we use to force hydration of a subtree.
  18045. // TODO: This does not account for low pri updates that were already
  18046. // scheduled before the root started rendering. Need to track the next
  18047. // pending expiration time (perhaps by backtracking the return path) and
  18048. // then trigger a restart in the `renderDidSuspendDelayIfPossible` path.
  18049. markRootSuspendedAtTime(root, renderExpirationTime$1);
  18050. }
  18051. } // Mark that the root has a pending update.
  18052. markRootUpdatedAtTime(root, expirationTime);
  18053. }
  18054. return root;
  18055. }
  18056. function getNextRootExpirationTimeToWorkOn(root) {
  18057. // Determines the next expiration time that the root should render, taking
  18058. // into account levels that may be suspended, or levels that may have
  18059. // received a ping.
  18060. var lastExpiredTime = root.lastExpiredTime;
  18061. if (lastExpiredTime !== NoWork) {
  18062. return lastExpiredTime;
  18063. } // "Pending" refers to any update that hasn't committed yet, including if it
  18064. // suspended. The "suspended" range is therefore a subset.
  18065. var firstPendingTime = root.firstPendingTime;
  18066. if (!isRootSuspendedAtTime(root, firstPendingTime)) {
  18067. // The highest priority pending time is not suspended. Let's work on that.
  18068. return firstPendingTime;
  18069. } // If the first pending time is suspended, check if there's a lower priority
  18070. // pending level that we know about. Or check if we received a ping. Work
  18071. // on whichever is higher priority.
  18072. var lastPingedTime = root.lastPingedTime;
  18073. var nextKnownPendingLevel = root.nextKnownPendingLevel;
  18074. var nextLevel = lastPingedTime > nextKnownPendingLevel ? lastPingedTime : nextKnownPendingLevel;
  18075. if ( nextLevel <= Idle && firstPendingTime !== nextLevel) {
  18076. // Don't work on Idle/Never priority unless everything else is committed.
  18077. return NoWork;
  18078. }
  18079. return nextLevel;
  18080. } // Use this function to schedule a task for a root. There's only one task per
  18081. // root; if a task was already scheduled, we'll check to make sure the
  18082. // expiration time of the existing task is the same as the expiration time of
  18083. // the next level that the root has work on. This function is called on every
  18084. // update, and right before exiting a task.
  18085. function ensureRootIsScheduled(root) {
  18086. var lastExpiredTime = root.lastExpiredTime;
  18087. if (lastExpiredTime !== NoWork) {
  18088. // Special case: Expired work should flush synchronously.
  18089. root.callbackExpirationTime = Sync;
  18090. root.callbackPriority = ImmediatePriority;
  18091. root.callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
  18092. return;
  18093. }
  18094. var expirationTime = getNextRootExpirationTimeToWorkOn(root);
  18095. var existingCallbackNode = root.callbackNode;
  18096. if (expirationTime === NoWork) {
  18097. // There's nothing to work on.
  18098. if (existingCallbackNode !== null) {
  18099. root.callbackNode = null;
  18100. root.callbackExpirationTime = NoWork;
  18101. root.callbackPriority = NoPriority;
  18102. }
  18103. return;
  18104. } // TODO: If this is an update, we already read the current time. Pass the
  18105. // time as an argument.
  18106. var currentTime = requestCurrentTimeForUpdate();
  18107. var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime); // If there's an existing render task, confirm it has the correct priority and
  18108. // expiration time. Otherwise, we'll cancel it and schedule a new one.
  18109. if (existingCallbackNode !== null) {
  18110. var existingCallbackPriority = root.callbackPriority;
  18111. var existingCallbackExpirationTime = root.callbackExpirationTime;
  18112. if ( // Callback must have the exact same expiration time.
  18113. existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority.
  18114. existingCallbackPriority >= priorityLevel) {
  18115. // Existing callback is sufficient.
  18116. return;
  18117. } // Need to schedule a new task.
  18118. // TODO: Instead of scheduling a new task, we should be able to change the
  18119. // priority of the existing one.
  18120. cancelCallback(existingCallbackNode);
  18121. }
  18122. root.callbackExpirationTime = expirationTime;
  18123. root.callbackPriority = priorityLevel;
  18124. var callbackNode;
  18125. if (expirationTime === Sync) {
  18126. // Sync React callbacks are scheduled on a special internal queue
  18127. callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
  18128. } else {
  18129. callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects
  18130. // ordering because tasks are processed in timeout order.
  18131. {
  18132. timeout: expirationTimeToMs(expirationTime) - now()
  18133. });
  18134. }
  18135. root.callbackNode = callbackNode;
  18136. } // This is the entry point for every concurrent task, i.e. anything that
  18137. // goes through Scheduler.
  18138. function performConcurrentWorkOnRoot(root, didTimeout) {
  18139. // Since we know we're in a React event, we can clear the current
  18140. // event time. The next update will compute a new event time.
  18141. currentEventTime = NoWork;
  18142. if (didTimeout) {
  18143. // The render task took too long to complete. Mark the current time as
  18144. // expired to synchronously render all expired work in a single batch.
  18145. var currentTime = requestCurrentTimeForUpdate();
  18146. markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback.
  18147. ensureRootIsScheduled(root);
  18148. return null;
  18149. } // Determine the next expiration time to work on, using the fields stored
  18150. // on the root.
  18151. var expirationTime = getNextRootExpirationTimeToWorkOn(root);
  18152. if (expirationTime !== NoWork) {
  18153. var originalCallbackNode = root.callbackNode;
  18154. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  18155. {
  18156. throw Error( "Should not already be working." );
  18157. }
  18158. }
  18159. flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack
  18160. // and prepare a fresh one. Otherwise we'll continue where we left off.
  18161. if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) {
  18162. prepareFreshStack(root, expirationTime);
  18163. startWorkOnPendingInteractions(root, expirationTime);
  18164. } // If we have a work-in-progress fiber, it means there's still work to do
  18165. // in this root.
  18166. if (workInProgress !== null) {
  18167. var prevExecutionContext = executionContext;
  18168. executionContext |= RenderContext;
  18169. var prevDispatcher = pushDispatcher();
  18170. var prevInteractions = pushInteractions(root);
  18171. startWorkLoopTimer(workInProgress);
  18172. do {
  18173. try {
  18174. workLoopConcurrent();
  18175. break;
  18176. } catch (thrownValue) {
  18177. handleError(root, thrownValue);
  18178. }
  18179. } while (true);
  18180. resetContextDependencies();
  18181. executionContext = prevExecutionContext;
  18182. popDispatcher(prevDispatcher);
  18183. {
  18184. popInteractions(prevInteractions);
  18185. }
  18186. if (workInProgressRootExitStatus === RootFatalErrored) {
  18187. var fatalError = workInProgressRootFatalError;
  18188. stopInterruptedWorkLoopTimer();
  18189. prepareFreshStack(root, expirationTime);
  18190. markRootSuspendedAtTime(root, expirationTime);
  18191. ensureRootIsScheduled(root);
  18192. throw fatalError;
  18193. }
  18194. if (workInProgress !== null) {
  18195. // There's still work left over. Exit without committing.
  18196. stopInterruptedWorkLoopTimer();
  18197. } else {
  18198. // We now have a consistent tree. The next step is either to commit it,
  18199. // or, if something suspended, wait to commit it after a timeout.
  18200. stopFinishedWorkLoopTimer();
  18201. var finishedWork = root.finishedWork = root.current.alternate;
  18202. root.finishedExpirationTime = expirationTime;
  18203. finishConcurrentRender(root, finishedWork, workInProgressRootExitStatus, expirationTime);
  18204. }
  18205. ensureRootIsScheduled(root);
  18206. if (root.callbackNode === originalCallbackNode) {
  18207. // The task node scheduled for this root is the same one that's
  18208. // currently executed. Need to return a continuation.
  18209. return performConcurrentWorkOnRoot.bind(null, root);
  18210. }
  18211. }
  18212. }
  18213. return null;
  18214. }
  18215. function finishConcurrentRender(root, finishedWork, exitStatus, expirationTime) {
  18216. // Set this to null to indicate there's no in-progress render.
  18217. workInProgressRoot = null;
  18218. switch (exitStatus) {
  18219. case RootIncomplete:
  18220. case RootFatalErrored:
  18221. {
  18222. {
  18223. {
  18224. throw Error( "Root did not complete. This is a bug in React." );
  18225. }
  18226. }
  18227. }
  18228. // Flow knows about invariant, so it complains if I add a break
  18229. // statement, but eslint doesn't know about invariant, so it complains
  18230. // if I do. eslint-disable-next-line no-fallthrough
  18231. case RootErrored:
  18232. {
  18233. // If this was an async render, the error may have happened due to
  18234. // a mutation in a concurrent event. Try rendering one more time,
  18235. // synchronously, to see if the error goes away. If there are
  18236. // lower priority updates, let's include those, too, in case they
  18237. // fix the inconsistency. Render at Idle to include all updates.
  18238. // If it was Idle or Never or some not-yet-invented time, render
  18239. // at that time.
  18240. markRootExpiredAtTime(root, expirationTime > Idle ? Idle : expirationTime); // We assume that this second render pass will be synchronous
  18241. // and therefore not hit this path again.
  18242. break;
  18243. }
  18244. case RootSuspended:
  18245. {
  18246. markRootSuspendedAtTime(root, expirationTime);
  18247. var lastSuspendedTime = root.lastSuspendedTime;
  18248. if (expirationTime === lastSuspendedTime) {
  18249. root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
  18250. } // We have an acceptable loading state. We need to figure out if we
  18251. // should immediately commit it or wait a bit.
  18252. // If we have processed new updates during this render, we may now
  18253. // have a new loading state ready. We want to ensure that we commit
  18254. // that as soon as possible.
  18255. var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync;
  18256. if (hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope
  18257. !( IsThisRendererActing.current)) {
  18258. // If we have not processed any new updates during this pass, then
  18259. // this is either a retry of an existing fallback state or a
  18260. // hidden tree. Hidden trees shouldn't be batched with other work
  18261. // and after that's fixed it can only be a retry. We're going to
  18262. // throttle committing retries so that we don't show too many
  18263. // loading states too quickly.
  18264. var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time.
  18265. if (msUntilTimeout > 10) {
  18266. if (workInProgressRootHasPendingPing) {
  18267. var lastPingedTime = root.lastPingedTime;
  18268. if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) {
  18269. // This render was pinged but we didn't get to restart
  18270. // earlier so try restarting now instead.
  18271. root.lastPingedTime = expirationTime;
  18272. prepareFreshStack(root, expirationTime);
  18273. break;
  18274. }
  18275. }
  18276. var nextTime = getNextRootExpirationTimeToWorkOn(root);
  18277. if (nextTime !== NoWork && nextTime !== expirationTime) {
  18278. // There's additional work on this root.
  18279. break;
  18280. }
  18281. if (lastSuspendedTime !== NoWork && lastSuspendedTime !== expirationTime) {
  18282. // We should prefer to render the fallback of at the last
  18283. // suspended level. Ping the last suspended level to try
  18284. // rendering it again.
  18285. root.lastPingedTime = lastSuspendedTime;
  18286. break;
  18287. } // The render is suspended, it hasn't timed out, and there's no
  18288. // lower priority work to do. Instead of committing the fallback
  18289. // immediately, wait for more data to arrive.
  18290. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout);
  18291. break;
  18292. }
  18293. } // The work expired. Commit immediately.
  18294. commitRoot(root);
  18295. break;
  18296. }
  18297. case RootSuspendedWithDelay:
  18298. {
  18299. markRootSuspendedAtTime(root, expirationTime);
  18300. var _lastSuspendedTime = root.lastSuspendedTime;
  18301. if (expirationTime === _lastSuspendedTime) {
  18302. root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
  18303. }
  18304. if ( // do not delay if we're inside an act() scope
  18305. !( IsThisRendererActing.current)) {
  18306. // We're suspended in a state that should be avoided. We'll try to
  18307. // avoid committing it for as long as the timeouts let us.
  18308. if (workInProgressRootHasPendingPing) {
  18309. var _lastPingedTime = root.lastPingedTime;
  18310. if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) {
  18311. // This render was pinged but we didn't get to restart earlier
  18312. // so try restarting now instead.
  18313. root.lastPingedTime = expirationTime;
  18314. prepareFreshStack(root, expirationTime);
  18315. break;
  18316. }
  18317. }
  18318. var _nextTime = getNextRootExpirationTimeToWorkOn(root);
  18319. if (_nextTime !== NoWork && _nextTime !== expirationTime) {
  18320. // There's additional work on this root.
  18321. break;
  18322. }
  18323. if (_lastSuspendedTime !== NoWork && _lastSuspendedTime !== expirationTime) {
  18324. // We should prefer to render the fallback of at the last
  18325. // suspended level. Ping the last suspended level to try
  18326. // rendering it again.
  18327. root.lastPingedTime = _lastSuspendedTime;
  18328. break;
  18329. }
  18330. var _msUntilTimeout;
  18331. if (workInProgressRootLatestSuspenseTimeout !== Sync) {
  18332. // We have processed a suspense config whose expiration time we
  18333. // can use as the timeout.
  18334. _msUntilTimeout = expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now();
  18335. } else if (workInProgressRootLatestProcessedExpirationTime === Sync) {
  18336. // This should never normally happen because only new updates
  18337. // cause delayed states, so we should have processed something.
  18338. // However, this could also happen in an offscreen tree.
  18339. _msUntilTimeout = 0;
  18340. } else {
  18341. // If we don't have a suspense config, we're going to use a
  18342. // heuristic to determine how long we can suspend.
  18343. var eventTimeMs = inferTimeFromExpirationTime(workInProgressRootLatestProcessedExpirationTime);
  18344. var currentTimeMs = now();
  18345. var timeUntilExpirationMs = expirationTimeToMs(expirationTime) - currentTimeMs;
  18346. var timeElapsed = currentTimeMs - eventTimeMs;
  18347. if (timeElapsed < 0) {
  18348. // We get this wrong some time since we estimate the time.
  18349. timeElapsed = 0;
  18350. }
  18351. _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the
  18352. // event time is exact instead of inferred from expiration time
  18353. // we don't need this.
  18354. if (timeUntilExpirationMs < _msUntilTimeout) {
  18355. _msUntilTimeout = timeUntilExpirationMs;
  18356. }
  18357. } // Don't bother with a very short suspense time.
  18358. if (_msUntilTimeout > 10) {
  18359. // The render is suspended, it hasn't timed out, and there's no
  18360. // lower priority work to do. Instead of committing the fallback
  18361. // immediately, wait for more data to arrive.
  18362. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout);
  18363. break;
  18364. }
  18365. } // The work expired. Commit immediately.
  18366. commitRoot(root);
  18367. break;
  18368. }
  18369. case RootCompleted:
  18370. {
  18371. // The work completed. Ready to commit.
  18372. if ( // do not delay if we're inside an act() scope
  18373. !( IsThisRendererActing.current) && workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null) {
  18374. // If we have exceeded the minimum loading delay, which probably
  18375. // means we have shown a spinner already, we might have to suspend
  18376. // a bit longer to ensure that the spinner is shown for
  18377. // enough time.
  18378. var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(workInProgressRootLatestProcessedExpirationTime, expirationTime, workInProgressRootCanSuspendUsingConfig);
  18379. if (_msUntilTimeout2 > 10) {
  18380. markRootSuspendedAtTime(root, expirationTime);
  18381. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout2);
  18382. break;
  18383. }
  18384. }
  18385. commitRoot(root);
  18386. break;
  18387. }
  18388. default:
  18389. {
  18390. {
  18391. {
  18392. throw Error( "Unknown root exit status." );
  18393. }
  18394. }
  18395. }
  18396. }
  18397. } // This is the entry point for synchronous tasks that don't go
  18398. // through Scheduler
  18399. function performSyncWorkOnRoot(root) {
  18400. // Check if there's expired work on this root. Otherwise, render at Sync.
  18401. var lastExpiredTime = root.lastExpiredTime;
  18402. var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync;
  18403. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  18404. {
  18405. throw Error( "Should not already be working." );
  18406. }
  18407. }
  18408. flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack
  18409. // and prepare a fresh one. Otherwise we'll continue where we left off.
  18410. if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) {
  18411. prepareFreshStack(root, expirationTime);
  18412. startWorkOnPendingInteractions(root, expirationTime);
  18413. } // If we have a work-in-progress fiber, it means there's still work to do
  18414. // in this root.
  18415. if (workInProgress !== null) {
  18416. var prevExecutionContext = executionContext;
  18417. executionContext |= RenderContext;
  18418. var prevDispatcher = pushDispatcher();
  18419. var prevInteractions = pushInteractions(root);
  18420. startWorkLoopTimer(workInProgress);
  18421. do {
  18422. try {
  18423. workLoopSync();
  18424. break;
  18425. } catch (thrownValue) {
  18426. handleError(root, thrownValue);
  18427. }
  18428. } while (true);
  18429. resetContextDependencies();
  18430. executionContext = prevExecutionContext;
  18431. popDispatcher(prevDispatcher);
  18432. {
  18433. popInteractions(prevInteractions);
  18434. }
  18435. if (workInProgressRootExitStatus === RootFatalErrored) {
  18436. var fatalError = workInProgressRootFatalError;
  18437. stopInterruptedWorkLoopTimer();
  18438. prepareFreshStack(root, expirationTime);
  18439. markRootSuspendedAtTime(root, expirationTime);
  18440. ensureRootIsScheduled(root);
  18441. throw fatalError;
  18442. }
  18443. if (workInProgress !== null) {
  18444. // This is a sync render, so we should have finished the whole tree.
  18445. {
  18446. {
  18447. throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." );
  18448. }
  18449. }
  18450. } else {
  18451. // We now have a consistent tree. Because this is a sync render, we
  18452. // will commit it even if something suspended.
  18453. stopFinishedWorkLoopTimer();
  18454. root.finishedWork = root.current.alternate;
  18455. root.finishedExpirationTime = expirationTime;
  18456. finishSyncRender(root);
  18457. } // Before exiting, make sure there's a callback scheduled for the next
  18458. // pending level.
  18459. ensureRootIsScheduled(root);
  18460. }
  18461. return null;
  18462. }
  18463. function finishSyncRender(root) {
  18464. // Set this to null to indicate there's no in-progress render.
  18465. workInProgressRoot = null;
  18466. commitRoot(root);
  18467. }
  18468. function flushDiscreteUpdates() {
  18469. // TODO: Should be able to flush inside batchedUpdates, but not inside `act`.
  18470. // However, `act` uses `batchedUpdates`, so there's no way to distinguish
  18471. // those two cases. Need to fix this before exposing flushDiscreteUpdates
  18472. // as a public API.
  18473. if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) {
  18474. {
  18475. if ((executionContext & RenderContext) !== NoContext) {
  18476. error('unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.');
  18477. }
  18478. } // We're already rendering, so we can't synchronously flush pending work.
  18479. // This is probably a nested event dispatch triggered by a lifecycle/effect,
  18480. // like `el.focus()`. Exit.
  18481. return;
  18482. }
  18483. flushPendingDiscreteUpdates(); // If the discrete updates scheduled passive effects, flush them now so that
  18484. // they fire before the next serial event.
  18485. flushPassiveEffects();
  18486. }
  18487. function syncUpdates(fn, a, b, c) {
  18488. return runWithPriority$1(ImmediatePriority, fn.bind(null, a, b, c));
  18489. }
  18490. function flushPendingDiscreteUpdates() {
  18491. if (rootsWithPendingDiscreteUpdates !== null) {
  18492. // For each root with pending discrete updates, schedule a callback to
  18493. // immediately flush them.
  18494. var roots = rootsWithPendingDiscreteUpdates;
  18495. rootsWithPendingDiscreteUpdates = null;
  18496. roots.forEach(function (expirationTime, root) {
  18497. markRootExpiredAtTime(root, expirationTime);
  18498. ensureRootIsScheduled(root);
  18499. }); // Now flush the immediate queue.
  18500. flushSyncCallbackQueue();
  18501. }
  18502. }
  18503. function batchedUpdates$1(fn, a) {
  18504. var prevExecutionContext = executionContext;
  18505. executionContext |= BatchedContext;
  18506. try {
  18507. return fn(a);
  18508. } finally {
  18509. executionContext = prevExecutionContext;
  18510. if (executionContext === NoContext) {
  18511. // Flush the immediate callbacks that were scheduled during this batch
  18512. flushSyncCallbackQueue();
  18513. }
  18514. }
  18515. }
  18516. function batchedEventUpdates$1(fn, a) {
  18517. var prevExecutionContext = executionContext;
  18518. executionContext |= EventContext;
  18519. try {
  18520. return fn(a);
  18521. } finally {
  18522. executionContext = prevExecutionContext;
  18523. if (executionContext === NoContext) {
  18524. // Flush the immediate callbacks that were scheduled during this batch
  18525. flushSyncCallbackQueue();
  18526. }
  18527. }
  18528. }
  18529. function discreteUpdates$1(fn, a, b, c, d) {
  18530. var prevExecutionContext = executionContext;
  18531. executionContext |= DiscreteEventContext;
  18532. try {
  18533. // Should this
  18534. return runWithPriority$1(UserBlockingPriority$1, fn.bind(null, a, b, c, d));
  18535. } finally {
  18536. executionContext = prevExecutionContext;
  18537. if (executionContext === NoContext) {
  18538. // Flush the immediate callbacks that were scheduled during this batch
  18539. flushSyncCallbackQueue();
  18540. }
  18541. }
  18542. }
  18543. function unbatchedUpdates(fn, a) {
  18544. var prevExecutionContext = executionContext;
  18545. executionContext &= ~BatchedContext;
  18546. executionContext |= LegacyUnbatchedContext;
  18547. try {
  18548. return fn(a);
  18549. } finally {
  18550. executionContext = prevExecutionContext;
  18551. if (executionContext === NoContext) {
  18552. // Flush the immediate callbacks that were scheduled during this batch
  18553. flushSyncCallbackQueue();
  18554. }
  18555. }
  18556. }
  18557. function flushSync(fn, a) {
  18558. if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
  18559. {
  18560. {
  18561. throw Error( "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." );
  18562. }
  18563. }
  18564. }
  18565. var prevExecutionContext = executionContext;
  18566. executionContext |= BatchedContext;
  18567. try {
  18568. return runWithPriority$1(ImmediatePriority, fn.bind(null, a));
  18569. } finally {
  18570. executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch.
  18571. // Note that this will happen even if batchedUpdates is higher up
  18572. // the stack.
  18573. flushSyncCallbackQueue();
  18574. }
  18575. }
  18576. function prepareFreshStack(root, expirationTime) {
  18577. root.finishedWork = null;
  18578. root.finishedExpirationTime = NoWork;
  18579. var timeoutHandle = root.timeoutHandle;
  18580. if (timeoutHandle !== noTimeout) {
  18581. // The root previous suspended and scheduled a timeout to commit a fallback
  18582. // state. Now that we have additional work, cancel the timeout.
  18583. root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
  18584. cancelTimeout(timeoutHandle);
  18585. }
  18586. if (workInProgress !== null) {
  18587. var interruptedWork = workInProgress.return;
  18588. while (interruptedWork !== null) {
  18589. unwindInterruptedWork(interruptedWork);
  18590. interruptedWork = interruptedWork.return;
  18591. }
  18592. }
  18593. workInProgressRoot = root;
  18594. workInProgress = createWorkInProgress(root.current, null);
  18595. renderExpirationTime$1 = expirationTime;
  18596. workInProgressRootExitStatus = RootIncomplete;
  18597. workInProgressRootFatalError = null;
  18598. workInProgressRootLatestProcessedExpirationTime = Sync;
  18599. workInProgressRootLatestSuspenseTimeout = Sync;
  18600. workInProgressRootCanSuspendUsingConfig = null;
  18601. workInProgressRootNextUnprocessedUpdateTime = NoWork;
  18602. workInProgressRootHasPendingPing = false;
  18603. {
  18604. spawnedWorkDuringRender = null;
  18605. }
  18606. {
  18607. ReactStrictModeWarnings.discardPendingWarnings();
  18608. }
  18609. }
  18610. function handleError(root, thrownValue) {
  18611. do {
  18612. try {
  18613. // Reset module-level state that was set during the render phase.
  18614. resetContextDependencies();
  18615. resetHooksAfterThrow();
  18616. resetCurrentFiber();
  18617. if (workInProgress === null || workInProgress.return === null) {
  18618. // Expected to be working on a non-root fiber. This is a fatal error
  18619. // because there's no ancestor that can handle it; the root is
  18620. // supposed to capture all errors that weren't caught by an error
  18621. // boundary.
  18622. workInProgressRootExitStatus = RootFatalErrored;
  18623. workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next
  18624. // sibling, or the parent if there are no siblings. But since the root
  18625. // has no siblings nor a parent, we set it to null. Usually this is
  18626. // handled by `completeUnitOfWork` or `unwindWork`, but since we're
  18627. // interntionally not calling those, we need set it here.
  18628. // TODO: Consider calling `unwindWork` to pop the contexts.
  18629. workInProgress = null;
  18630. return null;
  18631. }
  18632. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  18633. // Record the time spent rendering before an error was thrown. This
  18634. // avoids inaccurate Profiler durations in the case of a
  18635. // suspended render.
  18636. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
  18637. }
  18638. throwException(root, workInProgress.return, workInProgress, thrownValue, renderExpirationTime$1);
  18639. workInProgress = completeUnitOfWork(workInProgress);
  18640. } catch (yetAnotherThrownValue) {
  18641. // Something in the return path also threw.
  18642. thrownValue = yetAnotherThrownValue;
  18643. continue;
  18644. } // Return to the normal work loop.
  18645. return;
  18646. } while (true);
  18647. }
  18648. function pushDispatcher(root) {
  18649. var prevDispatcher = ReactCurrentDispatcher$1.current;
  18650. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
  18651. if (prevDispatcher === null) {
  18652. // The React isomorphic package does not include a default dispatcher.
  18653. // Instead the first renderer will lazily attach one, in order to give
  18654. // nicer error messages.
  18655. return ContextOnlyDispatcher;
  18656. } else {
  18657. return prevDispatcher;
  18658. }
  18659. }
  18660. function popDispatcher(prevDispatcher) {
  18661. ReactCurrentDispatcher$1.current = prevDispatcher;
  18662. }
  18663. function pushInteractions(root) {
  18664. {
  18665. var prevInteractions = tracing.__interactionsRef.current;
  18666. tracing.__interactionsRef.current = root.memoizedInteractions;
  18667. return prevInteractions;
  18668. }
  18669. }
  18670. function popInteractions(prevInteractions) {
  18671. {
  18672. tracing.__interactionsRef.current = prevInteractions;
  18673. }
  18674. }
  18675. function markCommitTimeOfFallback() {
  18676. globalMostRecentFallbackTime = now();
  18677. }
  18678. function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
  18679. if (expirationTime < workInProgressRootLatestProcessedExpirationTime && expirationTime > Idle) {
  18680. workInProgressRootLatestProcessedExpirationTime = expirationTime;
  18681. }
  18682. if (suspenseConfig !== null) {
  18683. if (expirationTime < workInProgressRootLatestSuspenseTimeout && expirationTime > Idle) {
  18684. workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad.
  18685. workInProgressRootCanSuspendUsingConfig = suspenseConfig;
  18686. }
  18687. }
  18688. }
  18689. function markUnprocessedUpdateTime(expirationTime) {
  18690. if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) {
  18691. workInProgressRootNextUnprocessedUpdateTime = expirationTime;
  18692. }
  18693. }
  18694. function renderDidSuspend() {
  18695. if (workInProgressRootExitStatus === RootIncomplete) {
  18696. workInProgressRootExitStatus = RootSuspended;
  18697. }
  18698. }
  18699. function renderDidSuspendDelayIfPossible() {
  18700. if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
  18701. workInProgressRootExitStatus = RootSuspendedWithDelay;
  18702. } // Check if there's a lower priority update somewhere else in the tree.
  18703. if (workInProgressRootNextUnprocessedUpdateTime !== NoWork && workInProgressRoot !== null) {
  18704. // Mark the current render as suspended, and then mark that there's a
  18705. // pending update.
  18706. // TODO: This should immediately interrupt the current render, instead
  18707. // of waiting until the next time we yield.
  18708. markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime$1);
  18709. markRootUpdatedAtTime(workInProgressRoot, workInProgressRootNextUnprocessedUpdateTime);
  18710. }
  18711. }
  18712. function renderDidError() {
  18713. if (workInProgressRootExitStatus !== RootCompleted) {
  18714. workInProgressRootExitStatus = RootErrored;
  18715. }
  18716. } // Called during render to determine if anything has suspended.
  18717. // Returns false if we're not sure.
  18718. function renderHasNotSuspendedYet() {
  18719. // If something errored or completed, we can't really be sure,
  18720. // so those are false.
  18721. return workInProgressRootExitStatus === RootIncomplete;
  18722. }
  18723. function inferTimeFromExpirationTime(expirationTime) {
  18724. // We don't know exactly when the update was scheduled, but we can infer an
  18725. // approximate start time from the expiration time.
  18726. var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
  18727. return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
  18728. }
  18729. function inferTimeFromExpirationTimeWithSuspenseConfig(expirationTime, suspenseConfig) {
  18730. // We don't know exactly when the update was scheduled, but we can infer an
  18731. // approximate start time from the expiration time by subtracting the timeout
  18732. // that was added to the event time.
  18733. var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
  18734. return earliestExpirationTimeMs - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
  18735. } // The work loop is an extremely hot path. Tell Closure not to inline it.
  18736. /** @noinline */
  18737. function workLoopSync() {
  18738. // Already timed out, so perform work without checking if we need to yield.
  18739. while (workInProgress !== null) {
  18740. workInProgress = performUnitOfWork(workInProgress);
  18741. }
  18742. }
  18743. /** @noinline */
  18744. function workLoopConcurrent() {
  18745. // Perform work until Scheduler asks us to yield
  18746. while (workInProgress !== null && !shouldYield()) {
  18747. workInProgress = performUnitOfWork(workInProgress);
  18748. }
  18749. }
  18750. function performUnitOfWork(unitOfWork) {
  18751. // The current, flushed, state of this fiber is the alternate. Ideally
  18752. // nothing should rely on this, but relying on it here means that we don't
  18753. // need an additional field on the work in progress.
  18754. var current = unitOfWork.alternate;
  18755. startWorkTimer(unitOfWork);
  18756. setCurrentFiber(unitOfWork);
  18757. var next;
  18758. if ( (unitOfWork.mode & ProfileMode) !== NoMode) {
  18759. startProfilerTimer(unitOfWork);
  18760. next = beginWork$1(current, unitOfWork, renderExpirationTime$1);
  18761. stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
  18762. } else {
  18763. next = beginWork$1(current, unitOfWork, renderExpirationTime$1);
  18764. }
  18765. resetCurrentFiber();
  18766. unitOfWork.memoizedProps = unitOfWork.pendingProps;
  18767. if (next === null) {
  18768. // If this doesn't spawn new work, complete the current work.
  18769. next = completeUnitOfWork(unitOfWork);
  18770. }
  18771. ReactCurrentOwner$2.current = null;
  18772. return next;
  18773. }
  18774. function completeUnitOfWork(unitOfWork) {
  18775. // Attempt to complete the current unit of work, then move to the next
  18776. // sibling. If there are no more siblings, return to the parent fiber.
  18777. workInProgress = unitOfWork;
  18778. do {
  18779. // The current, flushed, state of this fiber is the alternate. Ideally
  18780. // nothing should rely on this, but relying on it here means that we don't
  18781. // need an additional field on the work in progress.
  18782. var current = workInProgress.alternate;
  18783. var returnFiber = workInProgress.return; // Check if the work completed or if something threw.
  18784. if ((workInProgress.effectTag & Incomplete) === NoEffect) {
  18785. setCurrentFiber(workInProgress);
  18786. var next = void 0;
  18787. if ( (workInProgress.mode & ProfileMode) === NoMode) {
  18788. next = completeWork(current, workInProgress, renderExpirationTime$1);
  18789. } else {
  18790. startProfilerTimer(workInProgress);
  18791. next = completeWork(current, workInProgress, renderExpirationTime$1); // Update render duration assuming we didn't error.
  18792. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
  18793. }
  18794. stopWorkTimer(workInProgress);
  18795. resetCurrentFiber();
  18796. resetChildExpirationTime(workInProgress);
  18797. if (next !== null) {
  18798. // Completing this fiber spawned new work. Work on that next.
  18799. return next;
  18800. }
  18801. if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete
  18802. (returnFiber.effectTag & Incomplete) === NoEffect) {
  18803. // Append all the effects of the subtree and this fiber onto the effect
  18804. // list of the parent. The completion order of the children affects the
  18805. // side-effect order.
  18806. if (returnFiber.firstEffect === null) {
  18807. returnFiber.firstEffect = workInProgress.firstEffect;
  18808. }
  18809. if (workInProgress.lastEffect !== null) {
  18810. if (returnFiber.lastEffect !== null) {
  18811. returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
  18812. }
  18813. returnFiber.lastEffect = workInProgress.lastEffect;
  18814. } // If this fiber had side-effects, we append it AFTER the children's
  18815. // side-effects. We can perform certain side-effects earlier if needed,
  18816. // by doing multiple passes over the effect list. We don't want to
  18817. // schedule our own side-effect on our own list because if end up
  18818. // reusing children we'll schedule this effect onto itself since we're
  18819. // at the end.
  18820. var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect
  18821. // list. PerformedWork effect is read by React DevTools but shouldn't be
  18822. // committed.
  18823. if (effectTag > PerformedWork) {
  18824. if (returnFiber.lastEffect !== null) {
  18825. returnFiber.lastEffect.nextEffect = workInProgress;
  18826. } else {
  18827. returnFiber.firstEffect = workInProgress;
  18828. }
  18829. returnFiber.lastEffect = workInProgress;
  18830. }
  18831. }
  18832. } else {
  18833. // This fiber did not complete because something threw. Pop values off
  18834. // the stack without entering the complete phase. If this is a boundary,
  18835. // capture values if possible.
  18836. var _next = unwindWork(workInProgress); // Because this fiber did not complete, don't reset its expiration time.
  18837. if ( (workInProgress.mode & ProfileMode) !== NoMode) {
  18838. // Record the render duration for the fiber that errored.
  18839. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing.
  18840. var actualDuration = workInProgress.actualDuration;
  18841. var child = workInProgress.child;
  18842. while (child !== null) {
  18843. actualDuration += child.actualDuration;
  18844. child = child.sibling;
  18845. }
  18846. workInProgress.actualDuration = actualDuration;
  18847. }
  18848. if (_next !== null) {
  18849. // If completing this work spawned new work, do that next. We'll come
  18850. // back here again.
  18851. // Since we're restarting, remove anything that is not a host effect
  18852. // from the effect tag.
  18853. // TODO: The name stopFailedWorkTimer is misleading because Suspense
  18854. // also captures and restarts.
  18855. stopFailedWorkTimer(workInProgress);
  18856. _next.effectTag &= HostEffectMask;
  18857. return _next;
  18858. }
  18859. stopWorkTimer(workInProgress);
  18860. if (returnFiber !== null) {
  18861. // Mark the parent fiber as incomplete and clear its effect list.
  18862. returnFiber.firstEffect = returnFiber.lastEffect = null;
  18863. returnFiber.effectTag |= Incomplete;
  18864. }
  18865. }
  18866. var siblingFiber = workInProgress.sibling;
  18867. if (siblingFiber !== null) {
  18868. // If there is more work to do in this returnFiber, do that next.
  18869. return siblingFiber;
  18870. } // Otherwise, return to the parent
  18871. workInProgress = returnFiber;
  18872. } while (workInProgress !== null); // We've reached the root.
  18873. if (workInProgressRootExitStatus === RootIncomplete) {
  18874. workInProgressRootExitStatus = RootCompleted;
  18875. }
  18876. return null;
  18877. }
  18878. function getRemainingExpirationTime(fiber) {
  18879. var updateExpirationTime = fiber.expirationTime;
  18880. var childExpirationTime = fiber.childExpirationTime;
  18881. return updateExpirationTime > childExpirationTime ? updateExpirationTime : childExpirationTime;
  18882. }
  18883. function resetChildExpirationTime(completedWork) {
  18884. if (renderExpirationTime$1 !== Never && completedWork.childExpirationTime === Never) {
  18885. // The children of this component are hidden. Don't bubble their
  18886. // expiration times.
  18887. return;
  18888. }
  18889. var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time.
  18890. if ( (completedWork.mode & ProfileMode) !== NoMode) {
  18891. // In profiling mode, resetChildExpirationTime is also used to reset
  18892. // profiler durations.
  18893. var actualDuration = completedWork.actualDuration;
  18894. var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will
  18895. // only be updated if work is done on the fiber (i.e. it doesn't bailout).
  18896. // When work is done, it should bubble to the parent's actualDuration. If
  18897. // the fiber has not been cloned though, (meaning no work was done), then
  18898. // this value will reflect the amount of time spent working on a previous
  18899. // render. In that case it should not bubble. We determine whether it was
  18900. // cloned by comparing the child pointer.
  18901. var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
  18902. var child = completedWork.child;
  18903. while (child !== null) {
  18904. var childUpdateExpirationTime = child.expirationTime;
  18905. var childChildExpirationTime = child.childExpirationTime;
  18906. if (childUpdateExpirationTime > newChildExpirationTime) {
  18907. newChildExpirationTime = childUpdateExpirationTime;
  18908. }
  18909. if (childChildExpirationTime > newChildExpirationTime) {
  18910. newChildExpirationTime = childChildExpirationTime;
  18911. }
  18912. if (shouldBubbleActualDurations) {
  18913. actualDuration += child.actualDuration;
  18914. }
  18915. treeBaseDuration += child.treeBaseDuration;
  18916. child = child.sibling;
  18917. }
  18918. completedWork.actualDuration = actualDuration;
  18919. completedWork.treeBaseDuration = treeBaseDuration;
  18920. } else {
  18921. var _child = completedWork.child;
  18922. while (_child !== null) {
  18923. var _childUpdateExpirationTime = _child.expirationTime;
  18924. var _childChildExpirationTime = _child.childExpirationTime;
  18925. if (_childUpdateExpirationTime > newChildExpirationTime) {
  18926. newChildExpirationTime = _childUpdateExpirationTime;
  18927. }
  18928. if (_childChildExpirationTime > newChildExpirationTime) {
  18929. newChildExpirationTime = _childChildExpirationTime;
  18930. }
  18931. _child = _child.sibling;
  18932. }
  18933. }
  18934. completedWork.childExpirationTime = newChildExpirationTime;
  18935. }
  18936. function commitRoot(root) {
  18937. var renderPriorityLevel = getCurrentPriorityLevel();
  18938. runWithPriority$1(ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel));
  18939. return null;
  18940. }
  18941. function commitRootImpl(root, renderPriorityLevel) {
  18942. do {
  18943. // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
  18944. // means `flushPassiveEffects` will sometimes result in additional
  18945. // passive effects. So we need to keep flushing in a loop until there are
  18946. // no more pending effects.
  18947. // TODO: Might be better if `flushPassiveEffects` did not automatically
  18948. // flush synchronous work at the end, to avoid factoring hazards like this.
  18949. flushPassiveEffects();
  18950. } while (rootWithPendingPassiveEffects !== null);
  18951. flushRenderPhaseStrictModeWarningsInDEV();
  18952. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  18953. {
  18954. throw Error( "Should not already be working." );
  18955. }
  18956. }
  18957. var finishedWork = root.finishedWork;
  18958. var expirationTime = root.finishedExpirationTime;
  18959. if (finishedWork === null) {
  18960. return null;
  18961. }
  18962. root.finishedWork = null;
  18963. root.finishedExpirationTime = NoWork;
  18964. if (!(finishedWork !== root.current)) {
  18965. {
  18966. throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." );
  18967. }
  18968. } // commitRoot never returns a continuation; it always finishes synchronously.
  18969. // So we can clear these now to allow a new callback to be scheduled.
  18970. root.callbackNode = null;
  18971. root.callbackExpirationTime = NoWork;
  18972. root.callbackPriority = NoPriority;
  18973. root.nextKnownPendingLevel = NoWork;
  18974. startCommitTimer(); // Update the first and last pending times on this root. The new first
  18975. // pending time is whatever is left on the root fiber.
  18976. var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(finishedWork);
  18977. markRootFinishedAtTime(root, expirationTime, remainingExpirationTimeBeforeCommit);
  18978. if (root === workInProgressRoot) {
  18979. // We can reset these now that they are finished.
  18980. workInProgressRoot = null;
  18981. workInProgress = null;
  18982. renderExpirationTime$1 = NoWork;
  18983. } // This indicates that the last root we worked on is not the same one that
  18984. // we're committing now. This most commonly happens when a suspended root
  18985. // times out.
  18986. // Get the list of effects.
  18987. var firstEffect;
  18988. if (finishedWork.effectTag > PerformedWork) {
  18989. // A fiber's effect list consists only of its children, not itself. So if
  18990. // the root has an effect, we need to add it to the end of the list. The
  18991. // resulting list is the set that would belong to the root's parent, if it
  18992. // had one; that is, all the effects in the tree including the root.
  18993. if (finishedWork.lastEffect !== null) {
  18994. finishedWork.lastEffect.nextEffect = finishedWork;
  18995. firstEffect = finishedWork.firstEffect;
  18996. } else {
  18997. firstEffect = finishedWork;
  18998. }
  18999. } else {
  19000. // There is no effect on the root.
  19001. firstEffect = finishedWork.firstEffect;
  19002. }
  19003. if (firstEffect !== null) {
  19004. var prevExecutionContext = executionContext;
  19005. executionContext |= CommitContext;
  19006. var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles
  19007. ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass
  19008. // of the effect list for each phase: all mutation effects come before all
  19009. // layout effects, and so on.
  19010. // The first phase a "before mutation" phase. We use this phase to read the
  19011. // state of the host tree right before we mutate it. This is where
  19012. // getSnapshotBeforeUpdate is called.
  19013. startCommitSnapshotEffectsTimer();
  19014. prepareForCommit(root.containerInfo);
  19015. nextEffect = firstEffect;
  19016. do {
  19017. {
  19018. invokeGuardedCallback(null, commitBeforeMutationEffects, null);
  19019. if (hasCaughtError()) {
  19020. if (!(nextEffect !== null)) {
  19021. {
  19022. throw Error( "Should be working on an effect." );
  19023. }
  19024. }
  19025. var error = clearCaughtError();
  19026. captureCommitPhaseError(nextEffect, error);
  19027. nextEffect = nextEffect.nextEffect;
  19028. }
  19029. }
  19030. } while (nextEffect !== null);
  19031. stopCommitSnapshotEffectsTimer();
  19032. {
  19033. // Mark the current commit time to be shared by all Profilers in this
  19034. // batch. This enables them to be grouped later.
  19035. recordCommitTime();
  19036. } // The next phase is the mutation phase, where we mutate the host tree.
  19037. startCommitHostEffectsTimer();
  19038. nextEffect = firstEffect;
  19039. do {
  19040. {
  19041. invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel);
  19042. if (hasCaughtError()) {
  19043. if (!(nextEffect !== null)) {
  19044. {
  19045. throw Error( "Should be working on an effect." );
  19046. }
  19047. }
  19048. var _error = clearCaughtError();
  19049. captureCommitPhaseError(nextEffect, _error);
  19050. nextEffect = nextEffect.nextEffect;
  19051. }
  19052. }
  19053. } while (nextEffect !== null);
  19054. stopCommitHostEffectsTimer();
  19055. resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after
  19056. // the mutation phase, so that the previous tree is still current during
  19057. // componentWillUnmount, but before the layout phase, so that the finished
  19058. // work is current during componentDidMount/Update.
  19059. root.current = finishedWork; // The next phase is the layout phase, where we call effects that read
  19060. // the host tree after it's been mutated. The idiomatic use case for this is
  19061. // layout, but class component lifecycles also fire here for legacy reasons.
  19062. startCommitLifeCyclesTimer();
  19063. nextEffect = firstEffect;
  19064. do {
  19065. {
  19066. invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime);
  19067. if (hasCaughtError()) {
  19068. if (!(nextEffect !== null)) {
  19069. {
  19070. throw Error( "Should be working on an effect." );
  19071. }
  19072. }
  19073. var _error2 = clearCaughtError();
  19074. captureCommitPhaseError(nextEffect, _error2);
  19075. nextEffect = nextEffect.nextEffect;
  19076. }
  19077. }
  19078. } while (nextEffect !== null);
  19079. stopCommitLifeCyclesTimer();
  19080. nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an
  19081. // opportunity to paint.
  19082. requestPaint();
  19083. {
  19084. popInteractions(prevInteractions);
  19085. }
  19086. executionContext = prevExecutionContext;
  19087. } else {
  19088. // No effects.
  19089. root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were
  19090. // no effects.
  19091. // TODO: Maybe there's a better way to report this.
  19092. startCommitSnapshotEffectsTimer();
  19093. stopCommitSnapshotEffectsTimer();
  19094. {
  19095. recordCommitTime();
  19096. }
  19097. startCommitHostEffectsTimer();
  19098. stopCommitHostEffectsTimer();
  19099. startCommitLifeCyclesTimer();
  19100. stopCommitLifeCyclesTimer();
  19101. }
  19102. stopCommitTimer();
  19103. var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
  19104. if (rootDoesHavePassiveEffects) {
  19105. // This commit has passive effects. Stash a reference to them. But don't
  19106. // schedule a callback until after flushing layout work.
  19107. rootDoesHavePassiveEffects = false;
  19108. rootWithPendingPassiveEffects = root;
  19109. pendingPassiveEffectsExpirationTime = expirationTime;
  19110. pendingPassiveEffectsRenderPriority = renderPriorityLevel;
  19111. } else {
  19112. // We are done with the effect chain at this point so let's clear the
  19113. // nextEffect pointers to assist with GC. If we have passive effects, we'll
  19114. // clear this in flushPassiveEffects.
  19115. nextEffect = firstEffect;
  19116. while (nextEffect !== null) {
  19117. var nextNextEffect = nextEffect.nextEffect;
  19118. nextEffect.nextEffect = null;
  19119. nextEffect = nextNextEffect;
  19120. }
  19121. } // Check if there's remaining work on this root
  19122. var remainingExpirationTime = root.firstPendingTime;
  19123. if (remainingExpirationTime !== NoWork) {
  19124. {
  19125. if (spawnedWorkDuringRender !== null) {
  19126. var expirationTimes = spawnedWorkDuringRender;
  19127. spawnedWorkDuringRender = null;
  19128. for (var i = 0; i < expirationTimes.length; i++) {
  19129. scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions);
  19130. }
  19131. }
  19132. schedulePendingInteractions(root, remainingExpirationTime);
  19133. }
  19134. } else {
  19135. // If there's no remaining work, we can clear the set of already failed
  19136. // error boundaries.
  19137. legacyErrorBoundariesThatAlreadyFailed = null;
  19138. }
  19139. {
  19140. if (!rootDidHavePassiveEffects) {
  19141. // If there are no passive effects, then we can complete the pending interactions.
  19142. // Otherwise, we'll wait until after the passive effects are flushed.
  19143. // Wait to do this until after remaining work has been scheduled,
  19144. // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
  19145. finishPendingInteractions(root, expirationTime);
  19146. }
  19147. }
  19148. if (remainingExpirationTime === Sync) {
  19149. // Count the number of times the root synchronously re-renders without
  19150. // finishing. If there are too many, it indicates an infinite update loop.
  19151. if (root === rootWithNestedUpdates) {
  19152. nestedUpdateCount++;
  19153. } else {
  19154. nestedUpdateCount = 0;
  19155. rootWithNestedUpdates = root;
  19156. }
  19157. } else {
  19158. nestedUpdateCount = 0;
  19159. }
  19160. onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any
  19161. // additional work on this root is scheduled.
  19162. ensureRootIsScheduled(root);
  19163. if (hasUncaughtError) {
  19164. hasUncaughtError = false;
  19165. var _error3 = firstUncaughtError;
  19166. firstUncaughtError = null;
  19167. throw _error3;
  19168. }
  19169. if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
  19170. // This is a legacy edge case. We just committed the initial mount of
  19171. // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
  19172. // synchronously, but layout updates should be deferred until the end
  19173. // of the batch.
  19174. return null;
  19175. } // If layout work was scheduled, flush it now.
  19176. flushSyncCallbackQueue();
  19177. return null;
  19178. }
  19179. function commitBeforeMutationEffects() {
  19180. while (nextEffect !== null) {
  19181. var effectTag = nextEffect.effectTag;
  19182. if ((effectTag & Snapshot) !== NoEffect) {
  19183. setCurrentFiber(nextEffect);
  19184. recordEffect();
  19185. var current = nextEffect.alternate;
  19186. commitBeforeMutationLifeCycles(current, nextEffect);
  19187. resetCurrentFiber();
  19188. }
  19189. if ((effectTag & Passive) !== NoEffect) {
  19190. // If there are passive effects, schedule a callback to flush at
  19191. // the earliest opportunity.
  19192. if (!rootDoesHavePassiveEffects) {
  19193. rootDoesHavePassiveEffects = true;
  19194. scheduleCallback(NormalPriority, function () {
  19195. flushPassiveEffects();
  19196. return null;
  19197. });
  19198. }
  19199. }
  19200. nextEffect = nextEffect.nextEffect;
  19201. }
  19202. }
  19203. function commitMutationEffects(root, renderPriorityLevel) {
  19204. // TODO: Should probably move the bulk of this function to commitWork.
  19205. while (nextEffect !== null) {
  19206. setCurrentFiber(nextEffect);
  19207. var effectTag = nextEffect.effectTag;
  19208. if (effectTag & ContentReset) {
  19209. commitResetTextContent(nextEffect);
  19210. }
  19211. if (effectTag & Ref) {
  19212. var current = nextEffect.alternate;
  19213. if (current !== null) {
  19214. commitDetachRef(current);
  19215. }
  19216. } // The following switch statement is only concerned about placement,
  19217. // updates, and deletions. To avoid needing to add a case for every possible
  19218. // bitmap value, we remove the secondary effects from the effect tag and
  19219. // switch on that value.
  19220. var primaryEffectTag = effectTag & (Placement | Update | Deletion | Hydrating);
  19221. switch (primaryEffectTag) {
  19222. case Placement:
  19223. {
  19224. commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
  19225. // inserted, before any life-cycles like componentDidMount gets called.
  19226. // TODO: findDOMNode doesn't rely on this any more but isMounted does
  19227. // and isMounted is deprecated anyway so we should be able to kill this.
  19228. nextEffect.effectTag &= ~Placement;
  19229. break;
  19230. }
  19231. case PlacementAndUpdate:
  19232. {
  19233. // Placement
  19234. commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
  19235. // inserted, before any life-cycles like componentDidMount gets called.
  19236. nextEffect.effectTag &= ~Placement; // Update
  19237. var _current = nextEffect.alternate;
  19238. commitWork(_current, nextEffect);
  19239. break;
  19240. }
  19241. case Hydrating:
  19242. {
  19243. nextEffect.effectTag &= ~Hydrating;
  19244. break;
  19245. }
  19246. case HydratingAndUpdate:
  19247. {
  19248. nextEffect.effectTag &= ~Hydrating; // Update
  19249. var _current2 = nextEffect.alternate;
  19250. commitWork(_current2, nextEffect);
  19251. break;
  19252. }
  19253. case Update:
  19254. {
  19255. var _current3 = nextEffect.alternate;
  19256. commitWork(_current3, nextEffect);
  19257. break;
  19258. }
  19259. case Deletion:
  19260. {
  19261. commitDeletion(root, nextEffect, renderPriorityLevel);
  19262. break;
  19263. }
  19264. } // TODO: Only record a mutation effect if primaryEffectTag is non-zero.
  19265. recordEffect();
  19266. resetCurrentFiber();
  19267. nextEffect = nextEffect.nextEffect;
  19268. }
  19269. }
  19270. function commitLayoutEffects(root, committedExpirationTime) {
  19271. // TODO: Should probably move the bulk of this function to commitWork.
  19272. while (nextEffect !== null) {
  19273. setCurrentFiber(nextEffect);
  19274. var effectTag = nextEffect.effectTag;
  19275. if (effectTag & (Update | Callback)) {
  19276. recordEffect();
  19277. var current = nextEffect.alternate;
  19278. commitLifeCycles(root, current, nextEffect);
  19279. }
  19280. if (effectTag & Ref) {
  19281. recordEffect();
  19282. commitAttachRef(nextEffect);
  19283. }
  19284. resetCurrentFiber();
  19285. nextEffect = nextEffect.nextEffect;
  19286. }
  19287. }
  19288. function flushPassiveEffects() {
  19289. if (pendingPassiveEffectsRenderPriority !== NoPriority) {
  19290. var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority ? NormalPriority : pendingPassiveEffectsRenderPriority;
  19291. pendingPassiveEffectsRenderPriority = NoPriority;
  19292. return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl);
  19293. }
  19294. }
  19295. function flushPassiveEffectsImpl() {
  19296. if (rootWithPendingPassiveEffects === null) {
  19297. return false;
  19298. }
  19299. var root = rootWithPendingPassiveEffects;
  19300. var expirationTime = pendingPassiveEffectsExpirationTime;
  19301. rootWithPendingPassiveEffects = null;
  19302. pendingPassiveEffectsExpirationTime = NoWork;
  19303. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  19304. {
  19305. throw Error( "Cannot flush passive effects while already rendering." );
  19306. }
  19307. }
  19308. var prevExecutionContext = executionContext;
  19309. executionContext |= CommitContext;
  19310. var prevInteractions = pushInteractions(root);
  19311. {
  19312. // Note: This currently assumes there are no passive effects on the root fiber
  19313. // because the root is not part of its own effect list.
  19314. // This could change in the future.
  19315. var _effect2 = root.current.firstEffect;
  19316. while (_effect2 !== null) {
  19317. {
  19318. setCurrentFiber(_effect2);
  19319. invokeGuardedCallback(null, commitPassiveHookEffects, null, _effect2);
  19320. if (hasCaughtError()) {
  19321. if (!(_effect2 !== null)) {
  19322. {
  19323. throw Error( "Should be working on an effect." );
  19324. }
  19325. }
  19326. var _error5 = clearCaughtError();
  19327. captureCommitPhaseError(_effect2, _error5);
  19328. }
  19329. resetCurrentFiber();
  19330. }
  19331. var nextNextEffect = _effect2.nextEffect; // Remove nextEffect pointer to assist GC
  19332. _effect2.nextEffect = null;
  19333. _effect2 = nextNextEffect;
  19334. }
  19335. }
  19336. {
  19337. popInteractions(prevInteractions);
  19338. finishPendingInteractions(root, expirationTime);
  19339. }
  19340. executionContext = prevExecutionContext;
  19341. flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this
  19342. // exceeds the limit, we'll fire a warning.
  19343. nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
  19344. return true;
  19345. }
  19346. function isAlreadyFailedLegacyErrorBoundary(instance) {
  19347. return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
  19348. }
  19349. function markLegacyErrorBoundaryAsFailed(instance) {
  19350. if (legacyErrorBoundariesThatAlreadyFailed === null) {
  19351. legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
  19352. } else {
  19353. legacyErrorBoundariesThatAlreadyFailed.add(instance);
  19354. }
  19355. }
  19356. function prepareToThrowUncaughtError(error) {
  19357. if (!hasUncaughtError) {
  19358. hasUncaughtError = true;
  19359. firstUncaughtError = error;
  19360. }
  19361. }
  19362. var onUncaughtError = prepareToThrowUncaughtError;
  19363. function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
  19364. var errorInfo = createCapturedValue(error, sourceFiber);
  19365. var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
  19366. enqueueUpdate(rootFiber, update);
  19367. var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
  19368. if (root !== null) {
  19369. ensureRootIsScheduled(root);
  19370. schedulePendingInteractions(root, Sync);
  19371. }
  19372. }
  19373. function captureCommitPhaseError(sourceFiber, error) {
  19374. if (sourceFiber.tag === HostRoot) {
  19375. // Error was thrown at the root. There is no parent, so the root
  19376. // itself should capture it.
  19377. captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
  19378. return;
  19379. }
  19380. var fiber = sourceFiber.return;
  19381. while (fiber !== null) {
  19382. if (fiber.tag === HostRoot) {
  19383. captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
  19384. return;
  19385. } else if (fiber.tag === ClassComponent) {
  19386. var ctor = fiber.type;
  19387. var instance = fiber.stateNode;
  19388. if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
  19389. var errorInfo = createCapturedValue(error, sourceFiber);
  19390. var update = createClassErrorUpdate(fiber, errorInfo, // TODO: This is always sync
  19391. Sync);
  19392. enqueueUpdate(fiber, update);
  19393. var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
  19394. if (root !== null) {
  19395. ensureRootIsScheduled(root);
  19396. schedulePendingInteractions(root, Sync);
  19397. }
  19398. return;
  19399. }
  19400. }
  19401. fiber = fiber.return;
  19402. }
  19403. }
  19404. function pingSuspendedRoot(root, thenable, suspendedTime) {
  19405. var pingCache = root.pingCache;
  19406. if (pingCache !== null) {
  19407. // The thenable resolved, so we no longer need to memoize, because it will
  19408. // never be thrown again.
  19409. pingCache.delete(thenable);
  19410. }
  19411. if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) {
  19412. // Received a ping at the same priority level at which we're currently
  19413. // rendering. We might want to restart this render. This should mirror
  19414. // the logic of whether or not a root suspends once it completes.
  19415. // TODO: If we're rendering sync either due to Sync, Batched or expired,
  19416. // we should probably never restart.
  19417. // If we're suspended with delay, we'll always suspend so we can always
  19418. // restart. If we're suspended without any updates, it might be a retry.
  19419. // If it's early in the retry we can restart. We can't know for sure
  19420. // whether we'll eventually process an update during this render pass,
  19421. // but it's somewhat unlikely that we get to a ping before that, since
  19422. // getting to the root most update is usually very fast.
  19423. if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
  19424. // Restart from the root. Don't need to schedule a ping because
  19425. // we're already working on this tree.
  19426. prepareFreshStack(root, renderExpirationTime$1);
  19427. } else {
  19428. // Even though we can't restart right now, we might get an
  19429. // opportunity later. So we mark this render as having a ping.
  19430. workInProgressRootHasPendingPing = true;
  19431. }
  19432. return;
  19433. }
  19434. if (!isRootSuspendedAtTime(root, suspendedTime)) {
  19435. // The root is no longer suspended at this time.
  19436. return;
  19437. }
  19438. var lastPingedTime = root.lastPingedTime;
  19439. if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) {
  19440. // There's already a lower priority ping scheduled.
  19441. return;
  19442. } // Mark the time at which this ping was scheduled.
  19443. root.lastPingedTime = suspendedTime;
  19444. ensureRootIsScheduled(root);
  19445. schedulePendingInteractions(root, suspendedTime);
  19446. }
  19447. function retryTimedOutBoundary(boundaryFiber, retryTime) {
  19448. // The boundary fiber (a Suspense component or SuspenseList component)
  19449. // previously was rendered in its fallback state. One of the promises that
  19450. // suspended it has resolved, which means at least part of the tree was
  19451. // likely unblocked. Try rendering again, at a new expiration time.
  19452. if (retryTime === NoWork) {
  19453. var suspenseConfig = null; // Retries don't carry over the already committed update.
  19454. var currentTime = requestCurrentTimeForUpdate();
  19455. retryTime = computeExpirationForFiber(currentTime, boundaryFiber, suspenseConfig);
  19456. } // TODO: Special case idle priority?
  19457. var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
  19458. if (root !== null) {
  19459. ensureRootIsScheduled(root);
  19460. schedulePendingInteractions(root, retryTime);
  19461. }
  19462. }
  19463. function resolveRetryThenable(boundaryFiber, thenable) {
  19464. var retryTime = NoWork; // Default
  19465. var retryCache;
  19466. {
  19467. retryCache = boundaryFiber.stateNode;
  19468. }
  19469. if (retryCache !== null) {
  19470. // The thenable resolved, so we no longer need to memoize, because it will
  19471. // never be thrown again.
  19472. retryCache.delete(thenable);
  19473. }
  19474. retryTimedOutBoundary(boundaryFiber, retryTime);
  19475. } // Computes the next Just Noticeable Difference (JND) boundary.
  19476. // The theory is that a person can't tell the difference between small differences in time.
  19477. // Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
  19478. // difference in the experience. However, waiting for longer might mean that we can avoid
  19479. // showing an intermediate loading state. The longer we have already waited, the harder it
  19480. // is to tell small differences in time. Therefore, the longer we've already waited,
  19481. // the longer we can wait additionally. At some point we have to give up though.
  19482. // We pick a train model where the next boundary commits at a consistent schedule.
  19483. // These particular numbers are vague estimates. We expect to adjust them based on research.
  19484. function jnd(timeElapsed) {
  19485. return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
  19486. }
  19487. function computeMsUntilSuspenseLoadingDelay(mostRecentEventTime, committedExpirationTime, suspenseConfig) {
  19488. var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
  19489. if (busyMinDurationMs <= 0) {
  19490. return 0;
  19491. }
  19492. var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire.
  19493. var currentTimeMs = now();
  19494. var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(mostRecentEventTime, suspenseConfig);
  19495. var timeElapsed = currentTimeMs - eventTimeMs;
  19496. if (timeElapsed <= busyDelayMs) {
  19497. // If we haven't yet waited longer than the initial delay, we don't
  19498. // have to wait any additional time.
  19499. return 0;
  19500. }
  19501. var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`.
  19502. return msUntilTimeout;
  19503. }
  19504. function checkForNestedUpdates() {
  19505. if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
  19506. nestedUpdateCount = 0;
  19507. rootWithNestedUpdates = null;
  19508. {
  19509. {
  19510. throw Error( "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." );
  19511. }
  19512. }
  19513. }
  19514. {
  19515. if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
  19516. nestedPassiveUpdateCount = 0;
  19517. error('Maximum update depth exceeded. This can happen when a component ' + "calls setState inside useEffect, but useEffect either doesn't " + 'have a dependency array, or one of the dependencies changes on ' + 'every render.');
  19518. }
  19519. }
  19520. }
  19521. function flushRenderPhaseStrictModeWarningsInDEV() {
  19522. {
  19523. ReactStrictModeWarnings.flushLegacyContextWarning();
  19524. {
  19525. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
  19526. }
  19527. }
  19528. }
  19529. function stopFinishedWorkLoopTimer() {
  19530. var didCompleteRoot = true;
  19531. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  19532. interruptedBy = null;
  19533. }
  19534. function stopInterruptedWorkLoopTimer() {
  19535. // TODO: Track which fiber caused the interruption.
  19536. var didCompleteRoot = false;
  19537. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  19538. interruptedBy = null;
  19539. }
  19540. function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
  19541. if ( workInProgressRoot !== null && updateExpirationTime > renderExpirationTime$1) {
  19542. interruptedBy = fiberThatReceivedUpdate;
  19543. }
  19544. }
  19545. var didWarnStateUpdateForUnmountedComponent = null;
  19546. function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
  19547. {
  19548. var tag = fiber.tag;
  19549. if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) {
  19550. // Only warn for user-defined components, not internal ones like Suspense.
  19551. return;
  19552. }
  19553. // the problematic code almost always lies inside that component.
  19554. var componentName = getComponentName(fiber.type) || 'ReactComponent';
  19555. if (didWarnStateUpdateForUnmountedComponent !== null) {
  19556. if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
  19557. return;
  19558. }
  19559. didWarnStateUpdateForUnmountedComponent.add(componentName);
  19560. } else {
  19561. didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
  19562. }
  19563. error("Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.%s', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber));
  19564. }
  19565. }
  19566. var beginWork$1;
  19567. {
  19568. var dummyFiber = null;
  19569. beginWork$1 = function (current, unitOfWork, expirationTime) {
  19570. // If a component throws an error, we replay it again in a synchronously
  19571. // dispatched event, so that the debugger will treat it as an uncaught
  19572. // error See ReactErrorUtils for more information.
  19573. // Before entering the begin phase, copy the work-in-progress onto a dummy
  19574. // fiber. If beginWork throws, we'll use this to reset the state.
  19575. var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
  19576. try {
  19577. return beginWork(current, unitOfWork, expirationTime);
  19578. } catch (originalError) {
  19579. if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') {
  19580. // Don't replay promises. Treat everything else like an error.
  19581. throw originalError;
  19582. } // Keep this code in sync with handleError; any changes here must have
  19583. // corresponding changes there.
  19584. resetContextDependencies();
  19585. resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the
  19586. // same fiber again.
  19587. // Unwind the failed stack frame
  19588. unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
  19589. assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
  19590. if ( unitOfWork.mode & ProfileMode) {
  19591. // Reset the profiler timer.
  19592. startProfilerTimer(unitOfWork);
  19593. } // Run beginWork again.
  19594. invokeGuardedCallback(null, beginWork, null, current, unitOfWork, expirationTime);
  19595. if (hasCaughtError()) {
  19596. var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
  19597. // Rethrow this error instead of the original one.
  19598. throw replayError;
  19599. } else {
  19600. // This branch is reachable if the render phase is impure.
  19601. throw originalError;
  19602. }
  19603. }
  19604. };
  19605. }
  19606. var didWarnAboutUpdateInRender = false;
  19607. var didWarnAboutUpdateInRenderForAnotherComponent;
  19608. {
  19609. didWarnAboutUpdateInRenderForAnotherComponent = new Set();
  19610. }
  19611. function warnAboutRenderPhaseUpdatesInDEV(fiber) {
  19612. {
  19613. if (isRendering && (executionContext & RenderContext) !== NoContext) {
  19614. switch (fiber.tag) {
  19615. case FunctionComponent:
  19616. case ForwardRef:
  19617. case SimpleMemoComponent:
  19618. {
  19619. var renderingComponentName = workInProgress && getComponentName(workInProgress.type) || 'Unknown'; // Dedupe by the rendering component because it's the one that needs to be fixed.
  19620. var dedupeKey = renderingComponentName;
  19621. if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) {
  19622. didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey);
  19623. var setStateComponentName = getComponentName(fiber.type) || 'Unknown';
  19624. error('Cannot update a component (`%s`) while rendering a ' + 'different component (`%s`). To locate the bad setState() call inside `%s`, ' + 'follow the stack trace as described in https://fb.me/setstate-in-render', setStateComponentName, renderingComponentName, renderingComponentName);
  19625. }
  19626. break;
  19627. }
  19628. case ClassComponent:
  19629. {
  19630. if (!didWarnAboutUpdateInRender) {
  19631. error('Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure ' + 'function of props and state.');
  19632. didWarnAboutUpdateInRender = true;
  19633. }
  19634. break;
  19635. }
  19636. }
  19637. }
  19638. }
  19639. } // a 'shared' variable that changes when act() opens/closes in tests.
  19640. var IsThisRendererActing = {
  19641. current: false
  19642. };
  19643. function warnIfNotScopedWithMatchingAct(fiber) {
  19644. {
  19645. if ( IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) {
  19646. error("It looks like you're using the wrong act() around your test interactions.\n" + 'Be sure to use the matching version of act() corresponding to your renderer:\n\n' + '// for react-dom:\n' + "import {act} from 'react-dom/test-utils';\n" + '// ...\n' + 'act(() => ...);\n\n' + '// for react-test-renderer:\n' + "import TestRenderer from 'react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '// ...\n' + 'act(() => ...);' + '%s', getStackByFiberInDevAndProd(fiber));
  19647. }
  19648. }
  19649. }
  19650. function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
  19651. {
  19652. if ( (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
  19653. error('An update to %s ran an effect, but was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
  19654. }
  19655. }
  19656. }
  19657. function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
  19658. {
  19659. if ( executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
  19660. error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
  19661. }
  19662. }
  19663. }
  19664. var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler.
  19665. var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked
  19666. // scheduler is the actual recommendation. The alternative could be a testing build,
  19667. // a new lib, or whatever; we dunno just yet. This message is for early adopters
  19668. // to get their tests right.
  19669. function warnIfUnmockedScheduler(fiber) {
  19670. {
  19671. if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) {
  19672. if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
  19673. didWarnAboutUnmockedScheduler = true;
  19674. error('In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler');
  19675. }
  19676. }
  19677. }
  19678. }
  19679. function computeThreadID(root, expirationTime) {
  19680. // Interaction threads are unique per root and expiration time.
  19681. return expirationTime * 1000 + root.interactionThreadID;
  19682. }
  19683. function markSpawnedWork(expirationTime) {
  19684. if (spawnedWorkDuringRender === null) {
  19685. spawnedWorkDuringRender = [expirationTime];
  19686. } else {
  19687. spawnedWorkDuringRender.push(expirationTime);
  19688. }
  19689. }
  19690. function scheduleInteractions(root, expirationTime, interactions) {
  19691. if (interactions.size > 0) {
  19692. var pendingInteractionMap = root.pendingInteractionMap;
  19693. var pendingInteractions = pendingInteractionMap.get(expirationTime);
  19694. if (pendingInteractions != null) {
  19695. interactions.forEach(function (interaction) {
  19696. if (!pendingInteractions.has(interaction)) {
  19697. // Update the pending async work count for previously unscheduled interaction.
  19698. interaction.__count++;
  19699. }
  19700. pendingInteractions.add(interaction);
  19701. });
  19702. } else {
  19703. pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions.
  19704. interactions.forEach(function (interaction) {
  19705. interaction.__count++;
  19706. });
  19707. }
  19708. var subscriber = tracing.__subscriberRef.current;
  19709. if (subscriber !== null) {
  19710. var threadID = computeThreadID(root, expirationTime);
  19711. subscriber.onWorkScheduled(interactions, threadID);
  19712. }
  19713. }
  19714. }
  19715. function schedulePendingInteractions(root, expirationTime) {
  19716. scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current);
  19717. }
  19718. function startWorkOnPendingInteractions(root, expirationTime) {
  19719. // we can accurately attribute time spent working on it, And so that cascading
  19720. // work triggered during the render phase will be associated with it.
  19721. var interactions = new Set();
  19722. root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
  19723. if (scheduledExpirationTime >= expirationTime) {
  19724. scheduledInteractions.forEach(function (interaction) {
  19725. return interactions.add(interaction);
  19726. });
  19727. }
  19728. }); // Store the current set of interactions on the FiberRoot for a few reasons:
  19729. // We can re-use it in hot functions like performConcurrentWorkOnRoot()
  19730. // without having to recalculate it. We will also use it in commitWork() to
  19731. // pass to any Profiler onRender() hooks. This also provides DevTools with a
  19732. // way to access it when the onCommitRoot() hook is called.
  19733. root.memoizedInteractions = interactions;
  19734. if (interactions.size > 0) {
  19735. var subscriber = tracing.__subscriberRef.current;
  19736. if (subscriber !== null) {
  19737. var threadID = computeThreadID(root, expirationTime);
  19738. try {
  19739. subscriber.onWorkStarted(interactions, threadID);
  19740. } catch (error) {
  19741. // If the subscriber throws, rethrow it in a separate task
  19742. scheduleCallback(ImmediatePriority, function () {
  19743. throw error;
  19744. });
  19745. }
  19746. }
  19747. }
  19748. }
  19749. function finishPendingInteractions(root, committedExpirationTime) {
  19750. var earliestRemainingTimeAfterCommit = root.firstPendingTime;
  19751. var subscriber;
  19752. try {
  19753. subscriber = tracing.__subscriberRef.current;
  19754. if (subscriber !== null && root.memoizedInteractions.size > 0) {
  19755. var threadID = computeThreadID(root, committedExpirationTime);
  19756. subscriber.onWorkStopped(root.memoizedInteractions, threadID);
  19757. }
  19758. } catch (error) {
  19759. // If the subscriber throws, rethrow it in a separate task
  19760. scheduleCallback(ImmediatePriority, function () {
  19761. throw error;
  19762. });
  19763. } finally {
  19764. // Clear completed interactions from the pending Map.
  19765. // Unless the render was suspended or cascading work was scheduled,
  19766. // In which case– leave pending interactions until the subsequent render.
  19767. var pendingInteractionMap = root.pendingInteractionMap;
  19768. pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
  19769. // Only decrement the pending interaction count if we're done.
  19770. // If there's still work at the current priority,
  19771. // That indicates that we are waiting for suspense data.
  19772. if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
  19773. pendingInteractionMap.delete(scheduledExpirationTime);
  19774. scheduledInteractions.forEach(function (interaction) {
  19775. interaction.__count--;
  19776. if (subscriber !== null && interaction.__count === 0) {
  19777. try {
  19778. subscriber.onInteractionScheduledWorkCompleted(interaction);
  19779. } catch (error) {
  19780. // If the subscriber throws, rethrow it in a separate task
  19781. scheduleCallback(ImmediatePriority, function () {
  19782. throw error;
  19783. });
  19784. }
  19785. }
  19786. });
  19787. }
  19788. });
  19789. }
  19790. }
  19791. var onScheduleFiberRoot = null;
  19792. var onCommitFiberRoot = null;
  19793. var onCommitFiberUnmount = null;
  19794. var hasLoggedError = false;
  19795. var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
  19796. function injectInternals(internals) {
  19797. if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
  19798. // No DevTools
  19799. return false;
  19800. }
  19801. var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
  19802. if (hook.isDisabled) {
  19803. // This isn't a real property on the hook, but it can be set to opt out
  19804. // of DevTools integration and associated warnings and logs.
  19805. // https://github.com/facebook/react/issues/3877
  19806. return true;
  19807. }
  19808. if (!hook.supportsFiber) {
  19809. {
  19810. error('The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://fb.me/react-devtools');
  19811. } // DevTools exists, even though it doesn't support Fiber.
  19812. return true;
  19813. }
  19814. try {
  19815. var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
  19816. if (true) {
  19817. // Only used by Fast Refresh
  19818. if (typeof hook.onScheduleFiberRoot === 'function') {
  19819. onScheduleFiberRoot = function (root, children) {
  19820. try {
  19821. hook.onScheduleFiberRoot(rendererID, root, children);
  19822. } catch (err) {
  19823. if ( true && !hasLoggedError) {
  19824. hasLoggedError = true;
  19825. error('React instrumentation encountered an error: %s', err);
  19826. }
  19827. }
  19828. };
  19829. }
  19830. }
  19831. onCommitFiberRoot = function (root, expirationTime) {
  19832. try {
  19833. var didError = (root.current.effectTag & DidCapture) === DidCapture;
  19834. if (enableProfilerTimer) {
  19835. var currentTime = getCurrentTime();
  19836. var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime);
  19837. hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
  19838. } else {
  19839. hook.onCommitFiberRoot(rendererID, root, undefined, didError);
  19840. }
  19841. } catch (err) {
  19842. if (true) {
  19843. if (!hasLoggedError) {
  19844. hasLoggedError = true;
  19845. error('React instrumentation encountered an error: %s', err);
  19846. }
  19847. }
  19848. }
  19849. };
  19850. onCommitFiberUnmount = function (fiber) {
  19851. try {
  19852. hook.onCommitFiberUnmount(rendererID, fiber);
  19853. } catch (err) {
  19854. if (true) {
  19855. if (!hasLoggedError) {
  19856. hasLoggedError = true;
  19857. error('React instrumentation encountered an error: %s', err);
  19858. }
  19859. }
  19860. }
  19861. };
  19862. } catch (err) {
  19863. // Catch all errors because it is unsafe to throw during initialization.
  19864. {
  19865. error('React instrumentation encountered an error: %s.', err);
  19866. }
  19867. } // DevTools exists
  19868. return true;
  19869. }
  19870. function onScheduleRoot(root, children) {
  19871. if (typeof onScheduleFiberRoot === 'function') {
  19872. onScheduleFiberRoot(root, children);
  19873. }
  19874. }
  19875. function onCommitRoot(root, expirationTime) {
  19876. if (typeof onCommitFiberRoot === 'function') {
  19877. onCommitFiberRoot(root, expirationTime);
  19878. }
  19879. }
  19880. function onCommitUnmount(fiber) {
  19881. if (typeof onCommitFiberUnmount === 'function') {
  19882. onCommitFiberUnmount(fiber);
  19883. }
  19884. }
  19885. var hasBadMapPolyfill;
  19886. {
  19887. hasBadMapPolyfill = false;
  19888. try {
  19889. var nonExtensibleObject = Object.preventExtensions({});
  19890. var testMap = new Map([[nonExtensibleObject, null]]);
  19891. var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused.
  19892. // https://github.com/rollup/rollup/issues/1771
  19893. // TODO: we can remove these if Rollup fixes the bug.
  19894. testMap.set(0, 0);
  19895. testSet.add(0);
  19896. } catch (e) {
  19897. // TODO: Consider warning about bad polyfills
  19898. hasBadMapPolyfill = true;
  19899. }
  19900. }
  19901. var debugCounter = 1;
  19902. function FiberNode(tag, pendingProps, key, mode) {
  19903. // Instance
  19904. this.tag = tag;
  19905. this.key = key;
  19906. this.elementType = null;
  19907. this.type = null;
  19908. this.stateNode = null; // Fiber
  19909. this.return = null;
  19910. this.child = null;
  19911. this.sibling = null;
  19912. this.index = 0;
  19913. this.ref = null;
  19914. this.pendingProps = pendingProps;
  19915. this.memoizedProps = null;
  19916. this.updateQueue = null;
  19917. this.memoizedState = null;
  19918. this.dependencies = null;
  19919. this.mode = mode; // Effects
  19920. this.effectTag = NoEffect;
  19921. this.nextEffect = null;
  19922. this.firstEffect = null;
  19923. this.lastEffect = null;
  19924. this.expirationTime = NoWork;
  19925. this.childExpirationTime = NoWork;
  19926. this.alternate = null;
  19927. {
  19928. // Note: The following is done to avoid a v8 performance cliff.
  19929. //
  19930. // Initializing the fields below to smis and later updating them with
  19931. // double values will cause Fibers to end up having separate shapes.
  19932. // This behavior/bug has something to do with Object.preventExtension().
  19933. // Fortunately this only impacts DEV builds.
  19934. // Unfortunately it makes React unusably slow for some applications.
  19935. // To work around this, initialize the fields below with doubles.
  19936. //
  19937. // Learn more about this here:
  19938. // https://github.com/facebook/react/issues/14365
  19939. // https://bugs.chromium.org/p/v8/issues/detail?id=8538
  19940. this.actualDuration = Number.NaN;
  19941. this.actualStartTime = Number.NaN;
  19942. this.selfBaseDuration = Number.NaN;
  19943. this.treeBaseDuration = Number.NaN; // It's okay to replace the initial doubles with smis after initialization.
  19944. // This won't trigger the performance cliff mentioned above,
  19945. // and it simplifies other profiler code (including DevTools).
  19946. this.actualDuration = 0;
  19947. this.actualStartTime = -1;
  19948. this.selfBaseDuration = 0;
  19949. this.treeBaseDuration = 0;
  19950. } // This is normally DEV-only except www when it adds listeners.
  19951. // TODO: remove the User Timing integration in favor of Root Events.
  19952. {
  19953. this._debugID = debugCounter++;
  19954. this._debugIsCurrentlyTiming = false;
  19955. }
  19956. {
  19957. this._debugSource = null;
  19958. this._debugOwner = null;
  19959. this._debugNeedsRemount = false;
  19960. this._debugHookTypes = null;
  19961. if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
  19962. Object.preventExtensions(this);
  19963. }
  19964. }
  19965. } // This is a constructor function, rather than a POJO constructor, still
  19966. // please ensure we do the following:
  19967. // 1) Nobody should add any instance methods on this. Instance methods can be
  19968. // more difficult to predict when they get optimized and they are almost
  19969. // never inlined properly in static compilers.
  19970. // 2) Nobody should rely on `instanceof Fiber` for type testing. We should
  19971. // always know when it is a fiber.
  19972. // 3) We might want to experiment with using numeric keys since they are easier
  19973. // to optimize in a non-JIT environment.
  19974. // 4) We can easily go from a constructor to a createFiber object literal if that
  19975. // is faster.
  19976. // 5) It should be easy to port this to a C struct and keep a C implementation
  19977. // compatible.
  19978. var createFiber = function (tag, pendingProps, key, mode) {
  19979. // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
  19980. return new FiberNode(tag, pendingProps, key, mode);
  19981. };
  19982. function shouldConstruct(Component) {
  19983. var prototype = Component.prototype;
  19984. return !!(prototype && prototype.isReactComponent);
  19985. }
  19986. function isSimpleFunctionComponent(type) {
  19987. return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
  19988. }
  19989. function resolveLazyComponentTag(Component) {
  19990. if (typeof Component === 'function') {
  19991. return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
  19992. } else if (Component !== undefined && Component !== null) {
  19993. var $$typeof = Component.$$typeof;
  19994. if ($$typeof === REACT_FORWARD_REF_TYPE) {
  19995. return ForwardRef;
  19996. }
  19997. if ($$typeof === REACT_MEMO_TYPE) {
  19998. return MemoComponent;
  19999. }
  20000. }
  20001. return IndeterminateComponent;
  20002. } // This is used to create an alternate fiber to do work on.
  20003. function createWorkInProgress(current, pendingProps) {
  20004. var workInProgress = current.alternate;
  20005. if (workInProgress === null) {
  20006. // We use a double buffering pooling technique because we know that we'll
  20007. // only ever need at most two versions of a tree. We pool the "other" unused
  20008. // node that we're free to reuse. This is lazily created to avoid allocating
  20009. // extra objects for things that are never updated. It also allow us to
  20010. // reclaim the extra memory if needed.
  20011. workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
  20012. workInProgress.elementType = current.elementType;
  20013. workInProgress.type = current.type;
  20014. workInProgress.stateNode = current.stateNode;
  20015. {
  20016. // DEV-only fields
  20017. {
  20018. workInProgress._debugID = current._debugID;
  20019. }
  20020. workInProgress._debugSource = current._debugSource;
  20021. workInProgress._debugOwner = current._debugOwner;
  20022. workInProgress._debugHookTypes = current._debugHookTypes;
  20023. }
  20024. workInProgress.alternate = current;
  20025. current.alternate = workInProgress;
  20026. } else {
  20027. workInProgress.pendingProps = pendingProps; // We already have an alternate.
  20028. // Reset the effect tag.
  20029. workInProgress.effectTag = NoEffect; // The effect list is no longer valid.
  20030. workInProgress.nextEffect = null;
  20031. workInProgress.firstEffect = null;
  20032. workInProgress.lastEffect = null;
  20033. {
  20034. // We intentionally reset, rather than copy, actualDuration & actualStartTime.
  20035. // This prevents time from endlessly accumulating in new commits.
  20036. // This has the downside of resetting values for different priority renders,
  20037. // But works for yielding (the common case) and should support resuming.
  20038. workInProgress.actualDuration = 0;
  20039. workInProgress.actualStartTime = -1;
  20040. }
  20041. }
  20042. workInProgress.childExpirationTime = current.childExpirationTime;
  20043. workInProgress.expirationTime = current.expirationTime;
  20044. workInProgress.child = current.child;
  20045. workInProgress.memoizedProps = current.memoizedProps;
  20046. workInProgress.memoizedState = current.memoizedState;
  20047. workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
  20048. // it cannot be shared with the current fiber.
  20049. var currentDependencies = current.dependencies;
  20050. workInProgress.dependencies = currentDependencies === null ? null : {
  20051. expirationTime: currentDependencies.expirationTime,
  20052. firstContext: currentDependencies.firstContext,
  20053. responders: currentDependencies.responders
  20054. }; // These will be overridden during the parent's reconciliation
  20055. workInProgress.sibling = current.sibling;
  20056. workInProgress.index = current.index;
  20057. workInProgress.ref = current.ref;
  20058. {
  20059. workInProgress.selfBaseDuration = current.selfBaseDuration;
  20060. workInProgress.treeBaseDuration = current.treeBaseDuration;
  20061. }
  20062. {
  20063. workInProgress._debugNeedsRemount = current._debugNeedsRemount;
  20064. switch (workInProgress.tag) {
  20065. case IndeterminateComponent:
  20066. case FunctionComponent:
  20067. case SimpleMemoComponent:
  20068. workInProgress.type = resolveFunctionForHotReloading(current.type);
  20069. break;
  20070. case ClassComponent:
  20071. workInProgress.type = resolveClassForHotReloading(current.type);
  20072. break;
  20073. case ForwardRef:
  20074. workInProgress.type = resolveForwardRefForHotReloading(current.type);
  20075. break;
  20076. }
  20077. }
  20078. return workInProgress;
  20079. } // Used to reuse a Fiber for a second pass.
  20080. function resetWorkInProgress(workInProgress, renderExpirationTime) {
  20081. // This resets the Fiber to what createFiber or createWorkInProgress would
  20082. // have set the values to before during the first pass. Ideally this wouldn't
  20083. // be necessary but unfortunately many code paths reads from the workInProgress
  20084. // when they should be reading from current and writing to workInProgress.
  20085. // We assume pendingProps, index, key, ref, return are still untouched to
  20086. // avoid doing another reconciliation.
  20087. // Reset the effect tag but keep any Placement tags, since that's something
  20088. // that child fiber is setting, not the reconciliation.
  20089. workInProgress.effectTag &= Placement; // The effect list is no longer valid.
  20090. workInProgress.nextEffect = null;
  20091. workInProgress.firstEffect = null;
  20092. workInProgress.lastEffect = null;
  20093. var current = workInProgress.alternate;
  20094. if (current === null) {
  20095. // Reset to createFiber's initial values.
  20096. workInProgress.childExpirationTime = NoWork;
  20097. workInProgress.expirationTime = renderExpirationTime;
  20098. workInProgress.child = null;
  20099. workInProgress.memoizedProps = null;
  20100. workInProgress.memoizedState = null;
  20101. workInProgress.updateQueue = null;
  20102. workInProgress.dependencies = null;
  20103. {
  20104. // Note: We don't reset the actualTime counts. It's useful to accumulate
  20105. // actual time across multiple render passes.
  20106. workInProgress.selfBaseDuration = 0;
  20107. workInProgress.treeBaseDuration = 0;
  20108. }
  20109. } else {
  20110. // Reset to the cloned values that createWorkInProgress would've.
  20111. workInProgress.childExpirationTime = current.childExpirationTime;
  20112. workInProgress.expirationTime = current.expirationTime;
  20113. workInProgress.child = current.child;
  20114. workInProgress.memoizedProps = current.memoizedProps;
  20115. workInProgress.memoizedState = current.memoizedState;
  20116. workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
  20117. // it cannot be shared with the current fiber.
  20118. var currentDependencies = current.dependencies;
  20119. workInProgress.dependencies = currentDependencies === null ? null : {
  20120. expirationTime: currentDependencies.expirationTime,
  20121. firstContext: currentDependencies.firstContext,
  20122. responders: currentDependencies.responders
  20123. };
  20124. {
  20125. // Note: We don't reset the actualTime counts. It's useful to accumulate
  20126. // actual time across multiple render passes.
  20127. workInProgress.selfBaseDuration = current.selfBaseDuration;
  20128. workInProgress.treeBaseDuration = current.treeBaseDuration;
  20129. }
  20130. }
  20131. return workInProgress;
  20132. }
  20133. function createHostRootFiber(tag) {
  20134. var mode;
  20135. if (tag === ConcurrentRoot) {
  20136. mode = ConcurrentMode | BlockingMode | StrictMode;
  20137. } else if (tag === BlockingRoot) {
  20138. mode = BlockingMode | StrictMode;
  20139. } else {
  20140. mode = NoMode;
  20141. }
  20142. if ( isDevToolsPresent) {
  20143. // Always collect profile timings when DevTools are present.
  20144. // This enables DevTools to start capturing timing at any point–
  20145. // Without some nodes in the tree having empty base times.
  20146. mode |= ProfileMode;
  20147. }
  20148. return createFiber(HostRoot, null, null, mode);
  20149. }
  20150. function createFiberFromTypeAndProps(type, // React$ElementType
  20151. key, pendingProps, owner, mode, expirationTime) {
  20152. var fiber;
  20153. var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
  20154. var resolvedType = type;
  20155. if (typeof type === 'function') {
  20156. if (shouldConstruct(type)) {
  20157. fiberTag = ClassComponent;
  20158. {
  20159. resolvedType = resolveClassForHotReloading(resolvedType);
  20160. }
  20161. } else {
  20162. {
  20163. resolvedType = resolveFunctionForHotReloading(resolvedType);
  20164. }
  20165. }
  20166. } else if (typeof type === 'string') {
  20167. fiberTag = HostComponent;
  20168. } else {
  20169. getTag: switch (type) {
  20170. case REACT_FRAGMENT_TYPE:
  20171. return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
  20172. case REACT_CONCURRENT_MODE_TYPE:
  20173. fiberTag = Mode;
  20174. mode |= ConcurrentMode | BlockingMode | StrictMode;
  20175. break;
  20176. case REACT_STRICT_MODE_TYPE:
  20177. fiberTag = Mode;
  20178. mode |= StrictMode;
  20179. break;
  20180. case REACT_PROFILER_TYPE:
  20181. return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
  20182. case REACT_SUSPENSE_TYPE:
  20183. return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
  20184. case REACT_SUSPENSE_LIST_TYPE:
  20185. return createFiberFromSuspenseList(pendingProps, mode, expirationTime, key);
  20186. default:
  20187. {
  20188. if (typeof type === 'object' && type !== null) {
  20189. switch (type.$$typeof) {
  20190. case REACT_PROVIDER_TYPE:
  20191. fiberTag = ContextProvider;
  20192. break getTag;
  20193. case REACT_CONTEXT_TYPE:
  20194. // This is a consumer
  20195. fiberTag = ContextConsumer;
  20196. break getTag;
  20197. case REACT_FORWARD_REF_TYPE:
  20198. fiberTag = ForwardRef;
  20199. {
  20200. resolvedType = resolveForwardRefForHotReloading(resolvedType);
  20201. }
  20202. break getTag;
  20203. case REACT_MEMO_TYPE:
  20204. fiberTag = MemoComponent;
  20205. break getTag;
  20206. case REACT_LAZY_TYPE:
  20207. fiberTag = LazyComponent;
  20208. resolvedType = null;
  20209. break getTag;
  20210. case REACT_BLOCK_TYPE:
  20211. fiberTag = Block;
  20212. break getTag;
  20213. }
  20214. }
  20215. var info = '';
  20216. {
  20217. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  20218. info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and " + 'named imports.';
  20219. }
  20220. var ownerName = owner ? getComponentName(owner.type) : null;
  20221. if (ownerName) {
  20222. info += '\n\nCheck the render method of `' + ownerName + '`.';
  20223. }
  20224. }
  20225. {
  20226. {
  20227. throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info );
  20228. }
  20229. }
  20230. }
  20231. }
  20232. }
  20233. fiber = createFiber(fiberTag, pendingProps, key, mode);
  20234. fiber.elementType = type;
  20235. fiber.type = resolvedType;
  20236. fiber.expirationTime = expirationTime;
  20237. return fiber;
  20238. }
  20239. function createFiberFromElement(element, mode, expirationTime) {
  20240. var owner = null;
  20241. {
  20242. owner = element._owner;
  20243. }
  20244. var type = element.type;
  20245. var key = element.key;
  20246. var pendingProps = element.props;
  20247. var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
  20248. {
  20249. fiber._debugSource = element._source;
  20250. fiber._debugOwner = element._owner;
  20251. }
  20252. return fiber;
  20253. }
  20254. function createFiberFromFragment(elements, mode, expirationTime, key) {
  20255. var fiber = createFiber(Fragment, elements, key, mode);
  20256. fiber.expirationTime = expirationTime;
  20257. return fiber;
  20258. }
  20259. function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
  20260. {
  20261. if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
  20262. error('Profiler must specify an "id" string and "onRender" function as props');
  20263. }
  20264. }
  20265. var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); // TODO: The Profiler fiber shouldn't have a type. It has a tag.
  20266. fiber.elementType = REACT_PROFILER_TYPE;
  20267. fiber.type = REACT_PROFILER_TYPE;
  20268. fiber.expirationTime = expirationTime;
  20269. return fiber;
  20270. }
  20271. function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
  20272. var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
  20273. // This needs to be fixed in getComponentName so that it relies on the tag
  20274. // instead.
  20275. fiber.type = REACT_SUSPENSE_TYPE;
  20276. fiber.elementType = REACT_SUSPENSE_TYPE;
  20277. fiber.expirationTime = expirationTime;
  20278. return fiber;
  20279. }
  20280. function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
  20281. var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
  20282. {
  20283. // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag.
  20284. // This needs to be fixed in getComponentName so that it relies on the tag
  20285. // instead.
  20286. fiber.type = REACT_SUSPENSE_LIST_TYPE;
  20287. }
  20288. fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
  20289. fiber.expirationTime = expirationTime;
  20290. return fiber;
  20291. }
  20292. function createFiberFromText(content, mode, expirationTime) {
  20293. var fiber = createFiber(HostText, content, null, mode);
  20294. fiber.expirationTime = expirationTime;
  20295. return fiber;
  20296. }
  20297. function createFiberFromHostInstanceForDeletion() {
  20298. var fiber = createFiber(HostComponent, null, null, NoMode); // TODO: These should not need a type.
  20299. fiber.elementType = 'DELETED';
  20300. fiber.type = 'DELETED';
  20301. return fiber;
  20302. }
  20303. function createFiberFromPortal(portal, mode, expirationTime) {
  20304. var pendingProps = portal.children !== null ? portal.children : [];
  20305. var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
  20306. fiber.expirationTime = expirationTime;
  20307. fiber.stateNode = {
  20308. containerInfo: portal.containerInfo,
  20309. pendingChildren: null,
  20310. // Used by persistent updates
  20311. implementation: portal.implementation
  20312. };
  20313. return fiber;
  20314. } // Used for stashing WIP properties to replay failed work in DEV.
  20315. function assignFiberPropertiesInDEV(target, source) {
  20316. if (target === null) {
  20317. // This Fiber's initial properties will always be overwritten.
  20318. // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
  20319. target = createFiber(IndeterminateComponent, null, null, NoMode);
  20320. } // This is intentionally written as a list of all properties.
  20321. // We tried to use Object.assign() instead but this is called in
  20322. // the hottest path, and Object.assign() was too slow:
  20323. // https://github.com/facebook/react/issues/12502
  20324. // This code is DEV-only so size is not a concern.
  20325. target.tag = source.tag;
  20326. target.key = source.key;
  20327. target.elementType = source.elementType;
  20328. target.type = source.type;
  20329. target.stateNode = source.stateNode;
  20330. target.return = source.return;
  20331. target.child = source.child;
  20332. target.sibling = source.sibling;
  20333. target.index = source.index;
  20334. target.ref = source.ref;
  20335. target.pendingProps = source.pendingProps;
  20336. target.memoizedProps = source.memoizedProps;
  20337. target.updateQueue = source.updateQueue;
  20338. target.memoizedState = source.memoizedState;
  20339. target.dependencies = source.dependencies;
  20340. target.mode = source.mode;
  20341. target.effectTag = source.effectTag;
  20342. target.nextEffect = source.nextEffect;
  20343. target.firstEffect = source.firstEffect;
  20344. target.lastEffect = source.lastEffect;
  20345. target.expirationTime = source.expirationTime;
  20346. target.childExpirationTime = source.childExpirationTime;
  20347. target.alternate = source.alternate;
  20348. {
  20349. target.actualDuration = source.actualDuration;
  20350. target.actualStartTime = source.actualStartTime;
  20351. target.selfBaseDuration = source.selfBaseDuration;
  20352. target.treeBaseDuration = source.treeBaseDuration;
  20353. }
  20354. {
  20355. target._debugID = source._debugID;
  20356. }
  20357. target._debugSource = source._debugSource;
  20358. target._debugOwner = source._debugOwner;
  20359. target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
  20360. target._debugNeedsRemount = source._debugNeedsRemount;
  20361. target._debugHookTypes = source._debugHookTypes;
  20362. return target;
  20363. }
  20364. function FiberRootNode(containerInfo, tag, hydrate) {
  20365. this.tag = tag;
  20366. this.current = null;
  20367. this.containerInfo = containerInfo;
  20368. this.pendingChildren = null;
  20369. this.pingCache = null;
  20370. this.finishedExpirationTime = NoWork;
  20371. this.finishedWork = null;
  20372. this.timeoutHandle = noTimeout;
  20373. this.context = null;
  20374. this.pendingContext = null;
  20375. this.hydrate = hydrate;
  20376. this.callbackNode = null;
  20377. this.callbackPriority = NoPriority;
  20378. this.firstPendingTime = NoWork;
  20379. this.firstSuspendedTime = NoWork;
  20380. this.lastSuspendedTime = NoWork;
  20381. this.nextKnownPendingLevel = NoWork;
  20382. this.lastPingedTime = NoWork;
  20383. this.lastExpiredTime = NoWork;
  20384. {
  20385. this.interactionThreadID = tracing.unstable_getThreadID();
  20386. this.memoizedInteractions = new Set();
  20387. this.pendingInteractionMap = new Map();
  20388. }
  20389. }
  20390. function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
  20391. var root = new FiberRootNode(containerInfo, tag, hydrate);
  20392. // stateNode is any.
  20393. var uninitializedFiber = createHostRootFiber(tag);
  20394. root.current = uninitializedFiber;
  20395. uninitializedFiber.stateNode = root;
  20396. initializeUpdateQueue(uninitializedFiber);
  20397. return root;
  20398. }
  20399. function isRootSuspendedAtTime(root, expirationTime) {
  20400. var firstSuspendedTime = root.firstSuspendedTime;
  20401. var lastSuspendedTime = root.lastSuspendedTime;
  20402. return firstSuspendedTime !== NoWork && firstSuspendedTime >= expirationTime && lastSuspendedTime <= expirationTime;
  20403. }
  20404. function markRootSuspendedAtTime(root, expirationTime) {
  20405. var firstSuspendedTime = root.firstSuspendedTime;
  20406. var lastSuspendedTime = root.lastSuspendedTime;
  20407. if (firstSuspendedTime < expirationTime) {
  20408. root.firstSuspendedTime = expirationTime;
  20409. }
  20410. if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) {
  20411. root.lastSuspendedTime = expirationTime;
  20412. }
  20413. if (expirationTime <= root.lastPingedTime) {
  20414. root.lastPingedTime = NoWork;
  20415. }
  20416. if (expirationTime <= root.lastExpiredTime) {
  20417. root.lastExpiredTime = NoWork;
  20418. }
  20419. }
  20420. function markRootUpdatedAtTime(root, expirationTime) {
  20421. // Update the range of pending times
  20422. var firstPendingTime = root.firstPendingTime;
  20423. if (expirationTime > firstPendingTime) {
  20424. root.firstPendingTime = expirationTime;
  20425. } // Update the range of suspended times. Treat everything lower priority or
  20426. // equal to this update as unsuspended.
  20427. var firstSuspendedTime = root.firstSuspendedTime;
  20428. if (firstSuspendedTime !== NoWork) {
  20429. if (expirationTime >= firstSuspendedTime) {
  20430. // The entire suspended range is now unsuspended.
  20431. root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
  20432. } else if (expirationTime >= root.lastSuspendedTime) {
  20433. root.lastSuspendedTime = expirationTime + 1;
  20434. } // This is a pending level. Check if it's higher priority than the next
  20435. // known pending level.
  20436. if (expirationTime > root.nextKnownPendingLevel) {
  20437. root.nextKnownPendingLevel = expirationTime;
  20438. }
  20439. }
  20440. }
  20441. function markRootFinishedAtTime(root, finishedExpirationTime, remainingExpirationTime) {
  20442. // Update the range of pending times
  20443. root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or
  20444. // equal to this update as unsuspended.
  20445. if (finishedExpirationTime <= root.lastSuspendedTime) {
  20446. // The entire suspended range is now unsuspended.
  20447. root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
  20448. } else if (finishedExpirationTime <= root.firstSuspendedTime) {
  20449. // Part of the suspended range is now unsuspended. Narrow the range to
  20450. // include everything between the unsuspended time (non-inclusive) and the
  20451. // last suspended time.
  20452. root.firstSuspendedTime = finishedExpirationTime - 1;
  20453. }
  20454. if (finishedExpirationTime <= root.lastPingedTime) {
  20455. // Clear the pinged time
  20456. root.lastPingedTime = NoWork;
  20457. }
  20458. if (finishedExpirationTime <= root.lastExpiredTime) {
  20459. // Clear the expired time
  20460. root.lastExpiredTime = NoWork;
  20461. }
  20462. }
  20463. function markRootExpiredAtTime(root, expirationTime) {
  20464. var lastExpiredTime = root.lastExpiredTime;
  20465. if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) {
  20466. root.lastExpiredTime = expirationTime;
  20467. }
  20468. }
  20469. var didWarnAboutNestedUpdates;
  20470. var didWarnAboutFindNodeInStrictMode;
  20471. {
  20472. didWarnAboutNestedUpdates = false;
  20473. didWarnAboutFindNodeInStrictMode = {};
  20474. }
  20475. function getContextForSubtree(parentComponent) {
  20476. if (!parentComponent) {
  20477. return emptyContextObject;
  20478. }
  20479. var fiber = get(parentComponent);
  20480. var parentContext = findCurrentUnmaskedContext(fiber);
  20481. if (fiber.tag === ClassComponent) {
  20482. var Component = fiber.type;
  20483. if (isContextProvider(Component)) {
  20484. return processChildContext(fiber, Component, parentContext);
  20485. }
  20486. }
  20487. return parentContext;
  20488. }
  20489. function findHostInstanceWithWarning(component, methodName) {
  20490. {
  20491. var fiber = get(component);
  20492. if (fiber === undefined) {
  20493. if (typeof component.render === 'function') {
  20494. {
  20495. {
  20496. throw Error( "Unable to find node on an unmounted component." );
  20497. }
  20498. }
  20499. } else {
  20500. {
  20501. {
  20502. throw Error( "Argument appears to not be a ReactComponent. Keys: " + Object.keys(component) );
  20503. }
  20504. }
  20505. }
  20506. }
  20507. var hostFiber = findCurrentHostFiber(fiber);
  20508. if (hostFiber === null) {
  20509. return null;
  20510. }
  20511. if (hostFiber.mode & StrictMode) {
  20512. var componentName = getComponentName(fiber.type) || 'Component';
  20513. if (!didWarnAboutFindNodeInStrictMode[componentName]) {
  20514. didWarnAboutFindNodeInStrictMode[componentName] = true;
  20515. if (fiber.mode & StrictMode) {
  20516. error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber));
  20517. } else {
  20518. error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber));
  20519. }
  20520. }
  20521. }
  20522. return hostFiber.stateNode;
  20523. }
  20524. }
  20525. function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) {
  20526. return createFiberRoot(containerInfo, tag, hydrate);
  20527. }
  20528. function updateContainer(element, container, parentComponent, callback) {
  20529. {
  20530. onScheduleRoot(container, element);
  20531. }
  20532. var current$1 = container.current;
  20533. var currentTime = requestCurrentTimeForUpdate();
  20534. {
  20535. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  20536. if ('undefined' !== typeof jest) {
  20537. warnIfUnmockedScheduler(current$1);
  20538. warnIfNotScopedWithMatchingAct(current$1);
  20539. }
  20540. }
  20541. var suspenseConfig = requestCurrentSuspenseConfig();
  20542. var expirationTime = computeExpirationForFiber(currentTime, current$1, suspenseConfig);
  20543. var context = getContextForSubtree(parentComponent);
  20544. if (container.context === null) {
  20545. container.context = context;
  20546. } else {
  20547. container.pendingContext = context;
  20548. }
  20549. {
  20550. if (isRendering && current !== null && !didWarnAboutNestedUpdates) {
  20551. didWarnAboutNestedUpdates = true;
  20552. error('Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(current.type) || 'Unknown');
  20553. }
  20554. }
  20555. var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property
  20556. // being called "element".
  20557. update.payload = {
  20558. element: element
  20559. };
  20560. callback = callback === undefined ? null : callback;
  20561. if (callback !== null) {
  20562. {
  20563. if (typeof callback !== 'function') {
  20564. error('render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback);
  20565. }
  20566. }
  20567. update.callback = callback;
  20568. }
  20569. enqueueUpdate(current$1, update);
  20570. scheduleWork(current$1, expirationTime);
  20571. return expirationTime;
  20572. }
  20573. function getPublicRootInstance(container) {
  20574. var containerFiber = container.current;
  20575. if (!containerFiber.child) {
  20576. return null;
  20577. }
  20578. switch (containerFiber.child.tag) {
  20579. case HostComponent:
  20580. return getPublicInstance(containerFiber.child.stateNode);
  20581. default:
  20582. return containerFiber.child.stateNode;
  20583. }
  20584. }
  20585. function markRetryTimeImpl(fiber, retryTime) {
  20586. var suspenseState = fiber.memoizedState;
  20587. if (suspenseState !== null && suspenseState.dehydrated !== null) {
  20588. if (suspenseState.retryTime < retryTime) {
  20589. suspenseState.retryTime = retryTime;
  20590. }
  20591. }
  20592. } // Increases the priority of thennables when they resolve within this boundary.
  20593. function markRetryTimeIfNotHydrated(fiber, retryTime) {
  20594. markRetryTimeImpl(fiber, retryTime);
  20595. var alternate = fiber.alternate;
  20596. if (alternate) {
  20597. markRetryTimeImpl(alternate, retryTime);
  20598. }
  20599. }
  20600. function attemptUserBlockingHydration$1(fiber) {
  20601. if (fiber.tag !== SuspenseComponent) {
  20602. // We ignore HostRoots here because we can't increase
  20603. // their priority and they should not suspend on I/O,
  20604. // since you have to wrap anything that might suspend in
  20605. // Suspense.
  20606. return;
  20607. }
  20608. var expTime = computeInteractiveExpiration(requestCurrentTimeForUpdate());
  20609. scheduleWork(fiber, expTime);
  20610. markRetryTimeIfNotHydrated(fiber, expTime);
  20611. }
  20612. function attemptContinuousHydration$1(fiber) {
  20613. if (fiber.tag !== SuspenseComponent) {
  20614. // We ignore HostRoots here because we can't increase
  20615. // their priority and they should not suspend on I/O,
  20616. // since you have to wrap anything that might suspend in
  20617. // Suspense.
  20618. return;
  20619. }
  20620. scheduleWork(fiber, ContinuousHydration);
  20621. markRetryTimeIfNotHydrated(fiber, ContinuousHydration);
  20622. }
  20623. function attemptHydrationAtCurrentPriority$1(fiber) {
  20624. if (fiber.tag !== SuspenseComponent) {
  20625. // We ignore HostRoots here because we can't increase
  20626. // their priority other than synchronously flush it.
  20627. return;
  20628. }
  20629. var currentTime = requestCurrentTimeForUpdate();
  20630. var expTime = computeExpirationForFiber(currentTime, fiber, null);
  20631. scheduleWork(fiber, expTime);
  20632. markRetryTimeIfNotHydrated(fiber, expTime);
  20633. }
  20634. function findHostInstanceWithNoPortals(fiber) {
  20635. var hostFiber = findCurrentHostFiberWithNoPortals(fiber);
  20636. if (hostFiber === null) {
  20637. return null;
  20638. }
  20639. if (hostFiber.tag === FundamentalComponent) {
  20640. return hostFiber.stateNode.instance;
  20641. }
  20642. return hostFiber.stateNode;
  20643. }
  20644. var shouldSuspendImpl = function (fiber) {
  20645. return false;
  20646. };
  20647. function shouldSuspend(fiber) {
  20648. return shouldSuspendImpl(fiber);
  20649. }
  20650. var overrideHookState = null;
  20651. var overrideProps = null;
  20652. var scheduleUpdate = null;
  20653. var setSuspenseHandler = null;
  20654. {
  20655. var copyWithSetImpl = function (obj, path, idx, value) {
  20656. if (idx >= path.length) {
  20657. return value;
  20658. }
  20659. var key = path[idx];
  20660. var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); // $FlowFixMe number or string is fine here
  20661. updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
  20662. return updated;
  20663. };
  20664. var copyWithSet = function (obj, path, value) {
  20665. return copyWithSetImpl(obj, path, 0, value);
  20666. }; // Support DevTools editable values for useState and useReducer.
  20667. overrideHookState = function (fiber, id, path, value) {
  20668. // For now, the "id" of stateful hooks is just the stateful hook index.
  20669. // This may change in the future with e.g. nested hooks.
  20670. var currentHook = fiber.memoizedState;
  20671. while (currentHook !== null && id > 0) {
  20672. currentHook = currentHook.next;
  20673. id--;
  20674. }
  20675. if (currentHook !== null) {
  20676. var newState = copyWithSet(currentHook.memoizedState, path, value);
  20677. currentHook.memoizedState = newState;
  20678. currentHook.baseState = newState; // We aren't actually adding an update to the queue,
  20679. // because there is no update we can add for useReducer hooks that won't trigger an error.
  20680. // (There's no appropriate action type for DevTools overrides.)
  20681. // As a result though, React will see the scheduled update as a noop and bailout.
  20682. // Shallow cloning props works as a workaround for now to bypass the bailout check.
  20683. fiber.memoizedProps = _assign({}, fiber.memoizedProps);
  20684. scheduleWork(fiber, Sync);
  20685. }
  20686. }; // Support DevTools props for function components, forwardRef, memo, host components, etc.
  20687. overrideProps = function (fiber, path, value) {
  20688. fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
  20689. if (fiber.alternate) {
  20690. fiber.alternate.pendingProps = fiber.pendingProps;
  20691. }
  20692. scheduleWork(fiber, Sync);
  20693. };
  20694. scheduleUpdate = function (fiber) {
  20695. scheduleWork(fiber, Sync);
  20696. };
  20697. setSuspenseHandler = function (newShouldSuspendImpl) {
  20698. shouldSuspendImpl = newShouldSuspendImpl;
  20699. };
  20700. }
  20701. function injectIntoDevTools(devToolsConfig) {
  20702. var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
  20703. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  20704. return injectInternals(_assign({}, devToolsConfig, {
  20705. overrideHookState: overrideHookState,
  20706. overrideProps: overrideProps,
  20707. setSuspenseHandler: setSuspenseHandler,
  20708. scheduleUpdate: scheduleUpdate,
  20709. currentDispatcherRef: ReactCurrentDispatcher,
  20710. findHostInstanceByFiber: function (fiber) {
  20711. var hostFiber = findCurrentHostFiber(fiber);
  20712. if (hostFiber === null) {
  20713. return null;
  20714. }
  20715. return hostFiber.stateNode;
  20716. },
  20717. findFiberByHostInstance: function (instance) {
  20718. if (!findFiberByHostInstance) {
  20719. // Might not be implemented by the renderer.
  20720. return null;
  20721. }
  20722. return findFiberByHostInstance(instance);
  20723. },
  20724. // React Refresh
  20725. findHostInstancesForRefresh: findHostInstancesForRefresh ,
  20726. scheduleRefresh: scheduleRefresh ,
  20727. scheduleRoot: scheduleRoot ,
  20728. setRefreshHandler: setRefreshHandler ,
  20729. // Enables DevTools to append owner stacks to error messages in DEV mode.
  20730. getCurrentFiber: function () {
  20731. return current;
  20732. }
  20733. }));
  20734. }
  20735. var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing;
  20736. function ReactDOMRoot(container, options) {
  20737. this._internalRoot = createRootImpl(container, ConcurrentRoot, options);
  20738. }
  20739. function ReactDOMBlockingRoot(container, tag, options) {
  20740. this._internalRoot = createRootImpl(container, tag, options);
  20741. }
  20742. ReactDOMRoot.prototype.render = ReactDOMBlockingRoot.prototype.render = function (children) {
  20743. var root = this._internalRoot;
  20744. {
  20745. if (typeof arguments[1] === 'function') {
  20746. error('render(...): does not support the second callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().');
  20747. }
  20748. var container = root.containerInfo;
  20749. if (container.nodeType !== COMMENT_NODE) {
  20750. var hostInstance = findHostInstanceWithNoPortals(root.current);
  20751. if (hostInstance) {
  20752. if (hostInstance.parentNode !== container) {
  20753. error('render(...): It looks like the React-rendered content of the ' + 'root container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + "root.unmount() to empty a root's container.");
  20754. }
  20755. }
  20756. }
  20757. }
  20758. updateContainer(children, root, null, null);
  20759. };
  20760. ReactDOMRoot.prototype.unmount = ReactDOMBlockingRoot.prototype.unmount = function () {
  20761. {
  20762. if (typeof arguments[0] === 'function') {
  20763. error('unmount(...): does not support a callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().');
  20764. }
  20765. }
  20766. var root = this._internalRoot;
  20767. var container = root.containerInfo;
  20768. updateContainer(null, root, null, function () {
  20769. unmarkContainerAsRoot(container);
  20770. });
  20771. };
  20772. function createRootImpl(container, tag, options) {
  20773. // Tag is either LegacyRoot or Concurrent Root
  20774. var hydrate = options != null && options.hydrate === true;
  20775. var hydrationCallbacks = options != null && options.hydrationOptions || null;
  20776. var root = createContainer(container, tag, hydrate);
  20777. markContainerAsRoot(root.current, container);
  20778. if (hydrate && tag !== LegacyRoot) {
  20779. var doc = container.nodeType === DOCUMENT_NODE ? container : container.ownerDocument;
  20780. eagerlyTrapReplayableEvents(container, doc);
  20781. }
  20782. return root;
  20783. }
  20784. function createLegacyRoot(container, options) {
  20785. return new ReactDOMBlockingRoot(container, LegacyRoot, options);
  20786. }
  20787. function isValidContainer(node) {
  20788. return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || node.nodeType === COMMENT_NODE && node.nodeValue === ' react-mount-point-unstable '));
  20789. }
  20790. var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner;
  20791. var topLevelUpdateWarnings;
  20792. var warnedAboutHydrateAPI = false;
  20793. {
  20794. topLevelUpdateWarnings = function (container) {
  20795. if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
  20796. var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current);
  20797. if (hostInstance) {
  20798. if (hostInstance.parentNode !== container) {
  20799. error('render(...): It looks like the React-rendered content of this ' + 'container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + 'ReactDOM.unmountComponentAtNode to empty a container.');
  20800. }
  20801. }
  20802. }
  20803. var isRootRenderedBySomeReact = !!container._reactRootContainer;
  20804. var rootEl = getReactRootElementInContainer(container);
  20805. var hasNonRootReactChild = !!(rootEl && getInstanceFromNode$1(rootEl));
  20806. if (hasNonRootReactChild && !isRootRenderedBySomeReact) {
  20807. error('render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.');
  20808. }
  20809. if (container.nodeType === ELEMENT_NODE && container.tagName && container.tagName.toUpperCase() === 'BODY') {
  20810. error('render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.');
  20811. }
  20812. };
  20813. }
  20814. function getReactRootElementInContainer(container) {
  20815. if (!container) {
  20816. return null;
  20817. }
  20818. if (container.nodeType === DOCUMENT_NODE) {
  20819. return container.documentElement;
  20820. } else {
  20821. return container.firstChild;
  20822. }
  20823. }
  20824. function shouldHydrateDueToLegacyHeuristic(container) {
  20825. var rootElement = getReactRootElementInContainer(container);
  20826. return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME));
  20827. }
  20828. function legacyCreateRootFromDOMContainer(container, forceHydrate) {
  20829. var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container); // First clear any existing content.
  20830. if (!shouldHydrate) {
  20831. var warned = false;
  20832. var rootSibling;
  20833. while (rootSibling = container.lastChild) {
  20834. {
  20835. if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) {
  20836. warned = true;
  20837. error('render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.');
  20838. }
  20839. }
  20840. container.removeChild(rootSibling);
  20841. }
  20842. }
  20843. {
  20844. if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) {
  20845. warnedAboutHydrateAPI = true;
  20846. warn('render(): Calling ReactDOM.render() to hydrate server-rendered markup ' + 'will stop working in React v17. Replace the ReactDOM.render() call ' + 'with ReactDOM.hydrate() if you want React to attach to the server HTML.');
  20847. }
  20848. }
  20849. return createLegacyRoot(container, shouldHydrate ? {
  20850. hydrate: true
  20851. } : undefined);
  20852. }
  20853. function warnOnInvalidCallback$1(callback, callerName) {
  20854. {
  20855. if (callback !== null && typeof callback !== 'function') {
  20856. error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
  20857. }
  20858. }
  20859. }
  20860. function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) {
  20861. {
  20862. topLevelUpdateWarnings(container);
  20863. warnOnInvalidCallback$1(callback === undefined ? null : callback, 'render');
  20864. } // TODO: Without `any` type, Flow says "Property cannot be accessed on any
  20865. // member of intersection type." Whyyyyyy.
  20866. var root = container._reactRootContainer;
  20867. var fiberRoot;
  20868. if (!root) {
  20869. // Initial mount
  20870. root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate);
  20871. fiberRoot = root._internalRoot;
  20872. if (typeof callback === 'function') {
  20873. var originalCallback = callback;
  20874. callback = function () {
  20875. var instance = getPublicRootInstance(fiberRoot);
  20876. originalCallback.call(instance);
  20877. };
  20878. } // Initial mount should not be batched.
  20879. unbatchedUpdates(function () {
  20880. updateContainer(children, fiberRoot, parentComponent, callback);
  20881. });
  20882. } else {
  20883. fiberRoot = root._internalRoot;
  20884. if (typeof callback === 'function') {
  20885. var _originalCallback = callback;
  20886. callback = function () {
  20887. var instance = getPublicRootInstance(fiberRoot);
  20888. _originalCallback.call(instance);
  20889. };
  20890. } // Update
  20891. updateContainer(children, fiberRoot, parentComponent, callback);
  20892. }
  20893. return getPublicRootInstance(fiberRoot);
  20894. }
  20895. function findDOMNode(componentOrElement) {
  20896. {
  20897. var owner = ReactCurrentOwner$3.current;
  20898. if (owner !== null && owner.stateNode !== null) {
  20899. var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender;
  20900. if (!warnedAboutRefsInRender) {
  20901. error('%s is accessing findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(owner.type) || 'A component');
  20902. }
  20903. owner.stateNode._warnedAboutRefsInRender = true;
  20904. }
  20905. }
  20906. if (componentOrElement == null) {
  20907. return null;
  20908. }
  20909. if (componentOrElement.nodeType === ELEMENT_NODE) {
  20910. return componentOrElement;
  20911. }
  20912. {
  20913. return findHostInstanceWithWarning(componentOrElement, 'findDOMNode');
  20914. }
  20915. }
  20916. function hydrate(element, container, callback) {
  20917. if (!isValidContainer(container)) {
  20918. {
  20919. throw Error( "Target container is not a DOM element." );
  20920. }
  20921. }
  20922. {
  20923. var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined;
  20924. if (isModernRoot) {
  20925. error('You are calling ReactDOM.hydrate() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call createRoot(container, {hydrate: true}).render(element)?');
  20926. }
  20927. } // TODO: throw or warn if we couldn't hydrate?
  20928. return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);
  20929. }
  20930. function render(element, container, callback) {
  20931. if (!isValidContainer(container)) {
  20932. {
  20933. throw Error( "Target container is not a DOM element." );
  20934. }
  20935. }
  20936. {
  20937. var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined;
  20938. if (isModernRoot) {
  20939. error('You are calling ReactDOM.render() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call root.render(element)?');
  20940. }
  20941. }
  20942. return legacyRenderSubtreeIntoContainer(null, element, container, false, callback);
  20943. }
  20944. function unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) {
  20945. if (!isValidContainer(containerNode)) {
  20946. {
  20947. throw Error( "Target container is not a DOM element." );
  20948. }
  20949. }
  20950. if (!(parentComponent != null && has(parentComponent))) {
  20951. {
  20952. throw Error( "parentComponent must be a valid React Component" );
  20953. }
  20954. }
  20955. return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback);
  20956. }
  20957. function unmountComponentAtNode(container) {
  20958. if (!isValidContainer(container)) {
  20959. {
  20960. throw Error( "unmountComponentAtNode(...): Target container is not a DOM element." );
  20961. }
  20962. }
  20963. {
  20964. var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined;
  20965. if (isModernRoot) {
  20966. error('You are calling ReactDOM.unmountComponentAtNode() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. Did you mean to call root.unmount()?');
  20967. }
  20968. }
  20969. if (container._reactRootContainer) {
  20970. {
  20971. var rootEl = getReactRootElementInContainer(container);
  20972. var renderedByDifferentReact = rootEl && !getInstanceFromNode$1(rootEl);
  20973. if (renderedByDifferentReact) {
  20974. error("unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.');
  20975. }
  20976. } // Unmount should not be batched.
  20977. unbatchedUpdates(function () {
  20978. legacyRenderSubtreeIntoContainer(null, null, container, false, function () {
  20979. // $FlowFixMe This should probably use `delete container._reactRootContainer`
  20980. container._reactRootContainer = null;
  20981. unmarkContainerAsRoot(container);
  20982. });
  20983. }); // If you call unmountComponentAtNode twice in quick succession, you'll
  20984. // get `true` twice. That's probably fine?
  20985. return true;
  20986. } else {
  20987. {
  20988. var _rootEl = getReactRootElementInContainer(container);
  20989. var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode$1(_rootEl)); // Check if the container itself is a React root node.
  20990. var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer;
  20991. if (hasNonRootReactChild) {
  20992. error("unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.');
  20993. }
  20994. }
  20995. return false;
  20996. }
  20997. }
  20998. function createPortal(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
  20999. implementation) {
  21000. var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  21001. return {
  21002. // This tag allow us to uniquely identify this as a React Portal
  21003. $$typeof: REACT_PORTAL_TYPE,
  21004. key: key == null ? null : '' + key,
  21005. children: children,
  21006. containerInfo: containerInfo,
  21007. implementation: implementation
  21008. };
  21009. }
  21010. var ReactVersion = '16.13.1';
  21011. setAttemptUserBlockingHydration(attemptUserBlockingHydration$1);
  21012. setAttemptContinuousHydration(attemptContinuousHydration$1);
  21013. setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority$1);
  21014. var didWarnAboutUnstableCreatePortal = false;
  21015. {
  21016. if (typeof Map !== 'function' || // $FlowIssue Flow incorrectly thinks Map has no prototype
  21017. Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || // $FlowIssue Flow incorrectly thinks Set has no prototype
  21018. Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') {
  21019. error('React depends on Map and Set built-in types. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  21020. }
  21021. }
  21022. setRestoreImplementation(restoreControlledState$3);
  21023. setBatchingImplementation(batchedUpdates$1, discreteUpdates$1, flushDiscreteUpdates, batchedEventUpdates$1);
  21024. function createPortal$1(children, container) {
  21025. var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  21026. if (!isValidContainer(container)) {
  21027. {
  21028. throw Error( "Target container is not a DOM element." );
  21029. }
  21030. } // TODO: pass ReactDOM portal implementation as third argument
  21031. // $FlowFixMe The Flow type is opaque but there's no way to actually create it.
  21032. return createPortal(children, container, null, key);
  21033. }
  21034. function renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) {
  21035. return unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback);
  21036. }
  21037. function unstable_createPortal(children, container) {
  21038. var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  21039. {
  21040. if (!didWarnAboutUnstableCreatePortal) {
  21041. didWarnAboutUnstableCreatePortal = true;
  21042. warn('The ReactDOM.unstable_createPortal() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactDOM.createPortal() instead. It has the exact same API, ' + 'but without the "unstable_" prefix.');
  21043. }
  21044. }
  21045. return createPortal$1(children, container, key);
  21046. }
  21047. var Internals = {
  21048. // Keep in sync with ReactDOMUnstableNativeDependencies.js
  21049. // ReactTestUtils.js, and ReactTestUtilsAct.js. This is an array for better minification.
  21050. Events: [getInstanceFromNode$1, getNodeFromInstance$1, getFiberCurrentPropsFromNode$1, injectEventPluginsByName, eventNameDispatchConfigs, accumulateTwoPhaseDispatches, accumulateDirectDispatches, enqueueStateRestore, restoreStateIfNeeded, dispatchEvent, runEventsInBatch, flushPassiveEffects, IsThisRendererActing]
  21051. };
  21052. var foundDevTools = injectIntoDevTools({
  21053. findFiberByHostInstance: getClosestInstanceFromNode,
  21054. bundleType: 1 ,
  21055. version: ReactVersion,
  21056. rendererPackageName: 'react-dom'
  21057. });
  21058. {
  21059. if (!foundDevTools && canUseDOM && window.top === window.self) {
  21060. // If we're in Chrome or Firefox, provide a download link if not installed.
  21061. if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) {
  21062. var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension://.
  21063. if (/^(https?|file):$/.test(protocol)) {
  21064. // eslint-disable-next-line react-internal/no-production-logging
  21065. console.info('%cDownload the React DevTools ' + 'for a better development experience: ' + 'https://fb.me/react-devtools' + (protocol === 'file:' ? '\nYou might need to use a local HTTP server (instead of file://): ' + 'https://fb.me/react-devtools-faq' : ''), 'font-weight:bold');
  21066. }
  21067. }
  21068. }
  21069. }
  21070. exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
  21071. exports.createPortal = createPortal$1;
  21072. exports.findDOMNode = findDOMNode;
  21073. exports.flushSync = flushSync;
  21074. exports.hydrate = hydrate;
  21075. exports.render = render;
  21076. exports.unmountComponentAtNode = unmountComponentAtNode;
  21077. exports.unstable_batchedUpdates = batchedUpdates$1;
  21078. exports.unstable_createPortal = unstable_createPortal;
  21079. exports.unstable_renderSubtreeIntoContainer = renderSubtreeIntoContainer;
  21080. exports.version = ReactVersion;
  21081. })();
  21082. }
  21083. /***/ }),
  21084. /***/ "../../node_modules/react-dom/index.js":
  21085. /*!*****************************************************************!*\
  21086. !*** C:/Dev/Babylon/Babylon.js/node_modules/react-dom/index.js ***!
  21087. \*****************************************************************/
  21088. /*! no static exports found */
  21089. /***/ (function(module, exports, __webpack_require__) {
  21090. "use strict";
  21091. function checkDCE() {
  21092. /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
  21093. if (
  21094. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' ||
  21095. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function'
  21096. ) {
  21097. return;
  21098. }
  21099. if (true) {
  21100. // This branch is unreachable because this function is only called
  21101. // in production, but the condition is true only in development.
  21102. // Therefore if the branch is still here, dead code elimination wasn't
  21103. // properly applied.
  21104. // Don't change the message. React DevTools relies on it. Also make sure
  21105. // this message doesn't occur elsewhere in this function, or it will cause
  21106. // a false positive.
  21107. throw new Error('^_^');
  21108. }
  21109. try {
  21110. // Verify that the code above has been dead code eliminated (DCE'd).
  21111. __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);
  21112. } catch (err) {
  21113. // DevTools shouldn't crash React, no matter what.
  21114. // We should still report in case we break this code.
  21115. console.error(err);
  21116. }
  21117. }
  21118. if (false) {} else {
  21119. module.exports = __webpack_require__(/*! ./cjs/react-dom.development.js */ "../../node_modules/react-dom/cjs/react-dom.development.js");
  21120. }
  21121. /***/ }),
  21122. /***/ "../../node_modules/react/cjs/react.development.js":
  21123. /*!*****************************************************************************!*\
  21124. !*** C:/Dev/Babylon/Babylon.js/node_modules/react/cjs/react.development.js ***!
  21125. \*****************************************************************************/
  21126. /*! no static exports found */
  21127. /***/ (function(module, exports, __webpack_require__) {
  21128. "use strict";
  21129. /** @license React v16.13.1
  21130. * react.development.js
  21131. *
  21132. * Copyright (c) Facebook, Inc. and its affiliates.
  21133. *
  21134. * This source code is licensed under the MIT license found in the
  21135. * LICENSE file in the root directory of this source tree.
  21136. */
  21137. if (true) {
  21138. (function() {
  21139. 'use strict';
  21140. var _assign = __webpack_require__(/*! object-assign */ "../../node_modules/object-assign/index.js");
  21141. var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "../../node_modules/prop-types/checkPropTypes.js");
  21142. var ReactVersion = '16.13.1';
  21143. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  21144. // nor polyfill, then a plain number is used for performance.
  21145. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  21146. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  21147. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  21148. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  21149. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  21150. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  21151. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  21152. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  21153. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  21154. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  21155. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  21156. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  21157. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  21158. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  21159. var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
  21160. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  21161. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  21162. var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
  21163. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  21164. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  21165. function getIteratorFn(maybeIterable) {
  21166. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  21167. return null;
  21168. }
  21169. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  21170. if (typeof maybeIterator === 'function') {
  21171. return maybeIterator;
  21172. }
  21173. return null;
  21174. }
  21175. /**
  21176. * Keeps track of the current dispatcher.
  21177. */
  21178. var ReactCurrentDispatcher = {
  21179. /**
  21180. * @internal
  21181. * @type {ReactComponent}
  21182. */
  21183. current: null
  21184. };
  21185. /**
  21186. * Keeps track of the current batch's configuration such as how long an update
  21187. * should suspend for if it needs to.
  21188. */
  21189. var ReactCurrentBatchConfig = {
  21190. suspense: null
  21191. };
  21192. /**
  21193. * Keeps track of the current owner.
  21194. *
  21195. * The current owner is the component who should own any components that are
  21196. * currently being constructed.
  21197. */
  21198. var ReactCurrentOwner = {
  21199. /**
  21200. * @internal
  21201. * @type {ReactComponent}
  21202. */
  21203. current: null
  21204. };
  21205. var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
  21206. function describeComponentFrame (name, source, ownerName) {
  21207. var sourceInfo = '';
  21208. if (source) {
  21209. var path = source.fileName;
  21210. var fileName = path.replace(BEFORE_SLASH_RE, '');
  21211. {
  21212. // In DEV, include code for a common special case:
  21213. // prefer "folder/index.js" instead of just "index.js".
  21214. if (/^index\./.test(fileName)) {
  21215. var match = path.match(BEFORE_SLASH_RE);
  21216. if (match) {
  21217. var pathBeforeSlash = match[1];
  21218. if (pathBeforeSlash) {
  21219. var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
  21220. fileName = folderName + '/' + fileName;
  21221. }
  21222. }
  21223. }
  21224. }
  21225. sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
  21226. } else if (ownerName) {
  21227. sourceInfo = ' (created by ' + ownerName + ')';
  21228. }
  21229. return '\n in ' + (name || 'Unknown') + sourceInfo;
  21230. }
  21231. var Resolved = 1;
  21232. function refineResolvedLazyComponent(lazyComponent) {
  21233. return lazyComponent._status === Resolved ? lazyComponent._result : null;
  21234. }
  21235. function getWrappedName(outerType, innerType, wrapperName) {
  21236. var functionName = innerType.displayName || innerType.name || '';
  21237. return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
  21238. }
  21239. function getComponentName(type) {
  21240. if (type == null) {
  21241. // Host root, text node or just invalid type.
  21242. return null;
  21243. }
  21244. {
  21245. if (typeof type.tag === 'number') {
  21246. error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  21247. }
  21248. }
  21249. if (typeof type === 'function') {
  21250. return type.displayName || type.name || null;
  21251. }
  21252. if (typeof type === 'string') {
  21253. return type;
  21254. }
  21255. switch (type) {
  21256. case REACT_FRAGMENT_TYPE:
  21257. return 'Fragment';
  21258. case REACT_PORTAL_TYPE:
  21259. return 'Portal';
  21260. case REACT_PROFILER_TYPE:
  21261. return "Profiler";
  21262. case REACT_STRICT_MODE_TYPE:
  21263. return 'StrictMode';
  21264. case REACT_SUSPENSE_TYPE:
  21265. return 'Suspense';
  21266. case REACT_SUSPENSE_LIST_TYPE:
  21267. return 'SuspenseList';
  21268. }
  21269. if (typeof type === 'object') {
  21270. switch (type.$$typeof) {
  21271. case REACT_CONTEXT_TYPE:
  21272. return 'Context.Consumer';
  21273. case REACT_PROVIDER_TYPE:
  21274. return 'Context.Provider';
  21275. case REACT_FORWARD_REF_TYPE:
  21276. return getWrappedName(type, type.render, 'ForwardRef');
  21277. case REACT_MEMO_TYPE:
  21278. return getComponentName(type.type);
  21279. case REACT_BLOCK_TYPE:
  21280. return getComponentName(type.render);
  21281. case REACT_LAZY_TYPE:
  21282. {
  21283. var thenable = type;
  21284. var resolvedThenable = refineResolvedLazyComponent(thenable);
  21285. if (resolvedThenable) {
  21286. return getComponentName(resolvedThenable);
  21287. }
  21288. break;
  21289. }
  21290. }
  21291. }
  21292. return null;
  21293. }
  21294. var ReactDebugCurrentFrame = {};
  21295. var currentlyValidatingElement = null;
  21296. function setCurrentlyValidatingElement(element) {
  21297. {
  21298. currentlyValidatingElement = element;
  21299. }
  21300. }
  21301. {
  21302. // Stack implementation injected by the current renderer.
  21303. ReactDebugCurrentFrame.getCurrentStack = null;
  21304. ReactDebugCurrentFrame.getStackAddendum = function () {
  21305. var stack = ''; // Add an extra top frame while an element is being validated
  21306. if (currentlyValidatingElement) {
  21307. var name = getComponentName(currentlyValidatingElement.type);
  21308. var owner = currentlyValidatingElement._owner;
  21309. stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
  21310. } // Delegate to the injected renderer-specific implementation
  21311. var impl = ReactDebugCurrentFrame.getCurrentStack;
  21312. if (impl) {
  21313. stack += impl() || '';
  21314. }
  21315. return stack;
  21316. };
  21317. }
  21318. /**
  21319. * Used by act() to track whether you're inside an act() scope.
  21320. */
  21321. var IsSomeRendererActing = {
  21322. current: false
  21323. };
  21324. var ReactSharedInternals = {
  21325. ReactCurrentDispatcher: ReactCurrentDispatcher,
  21326. ReactCurrentBatchConfig: ReactCurrentBatchConfig,
  21327. ReactCurrentOwner: ReactCurrentOwner,
  21328. IsSomeRendererActing: IsSomeRendererActing,
  21329. // Used by renderers to avoid bundling object-assign twice in UMD bundles:
  21330. assign: _assign
  21331. };
  21332. {
  21333. _assign(ReactSharedInternals, {
  21334. // These should not be included in production.
  21335. ReactDebugCurrentFrame: ReactDebugCurrentFrame,
  21336. // Shim for React DOM 16.0.0 which still destructured (but not used) this.
  21337. // TODO: remove in React 17.0.
  21338. ReactComponentTreeHook: {}
  21339. });
  21340. }
  21341. // by calls to these methods by a Babel plugin.
  21342. //
  21343. // In PROD (or in packages without access to React internals),
  21344. // they are left as they are instead.
  21345. function warn(format) {
  21346. {
  21347. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  21348. args[_key - 1] = arguments[_key];
  21349. }
  21350. printWarning('warn', format, args);
  21351. }
  21352. }
  21353. function error(format) {
  21354. {
  21355. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  21356. args[_key2 - 1] = arguments[_key2];
  21357. }
  21358. printWarning('error', format, args);
  21359. }
  21360. }
  21361. function printWarning(level, format, args) {
  21362. // When changing this logic, you might want to also
  21363. // update consoleWithStackDev.www.js as well.
  21364. {
  21365. var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0;
  21366. if (!hasExistingStack) {
  21367. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  21368. var stack = ReactDebugCurrentFrame.getStackAddendum();
  21369. if (stack !== '') {
  21370. format += '%s';
  21371. args = args.concat([stack]);
  21372. }
  21373. }
  21374. var argsWithFormat = args.map(function (item) {
  21375. return '' + item;
  21376. }); // Careful: RN currently depends on this prefix
  21377. argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
  21378. // breaks IE9: https://github.com/facebook/react/issues/13610
  21379. // eslint-disable-next-line react-internal/no-production-logging
  21380. Function.prototype.apply.call(console[level], console, argsWithFormat);
  21381. try {
  21382. // --- Welcome to debugging React ---
  21383. // This error was thrown as a convenience so that you can use this stack
  21384. // to find the callsite that caused this warning to fire.
  21385. var argIndex = 0;
  21386. var message = 'Warning: ' + format.replace(/%s/g, function () {
  21387. return args[argIndex++];
  21388. });
  21389. throw new Error(message);
  21390. } catch (x) {}
  21391. }
  21392. }
  21393. var didWarnStateUpdateForUnmountedComponent = {};
  21394. function warnNoop(publicInstance, callerName) {
  21395. {
  21396. var _constructor = publicInstance.constructor;
  21397. var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
  21398. var warningKey = componentName + "." + callerName;
  21399. if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
  21400. return;
  21401. }
  21402. error("Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
  21403. didWarnStateUpdateForUnmountedComponent[warningKey] = true;
  21404. }
  21405. }
  21406. /**
  21407. * This is the abstract API for an update queue.
  21408. */
  21409. var ReactNoopUpdateQueue = {
  21410. /**
  21411. * Checks whether or not this composite component is mounted.
  21412. * @param {ReactClass} publicInstance The instance we want to test.
  21413. * @return {boolean} True if mounted, false otherwise.
  21414. * @protected
  21415. * @final
  21416. */
  21417. isMounted: function (publicInstance) {
  21418. return false;
  21419. },
  21420. /**
  21421. * Forces an update. This should only be invoked when it is known with
  21422. * certainty that we are **not** in a DOM transaction.
  21423. *
  21424. * You may want to call this when you know that some deeper aspect of the
  21425. * component's state has changed but `setState` was not called.
  21426. *
  21427. * This will not invoke `shouldComponentUpdate`, but it will invoke
  21428. * `componentWillUpdate` and `componentDidUpdate`.
  21429. *
  21430. * @param {ReactClass} publicInstance The instance that should rerender.
  21431. * @param {?function} callback Called after component is updated.
  21432. * @param {?string} callerName name of the calling function in the public API.
  21433. * @internal
  21434. */
  21435. enqueueForceUpdate: function (publicInstance, callback, callerName) {
  21436. warnNoop(publicInstance, 'forceUpdate');
  21437. },
  21438. /**
  21439. * Replaces all of the state. Always use this or `setState` to mutate state.
  21440. * You should treat `this.state` as immutable.
  21441. *
  21442. * There is no guarantee that `this.state` will be immediately updated, so
  21443. * accessing `this.state` after calling this method may return the old value.
  21444. *
  21445. * @param {ReactClass} publicInstance The instance that should rerender.
  21446. * @param {object} completeState Next state.
  21447. * @param {?function} callback Called after component is updated.
  21448. * @param {?string} callerName name of the calling function in the public API.
  21449. * @internal
  21450. */
  21451. enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
  21452. warnNoop(publicInstance, 'replaceState');
  21453. },
  21454. /**
  21455. * Sets a subset of the state. This only exists because _pendingState is
  21456. * internal. This provides a merging strategy that is not available to deep
  21457. * properties which is confusing. TODO: Expose pendingState or don't use it
  21458. * during the merge.
  21459. *
  21460. * @param {ReactClass} publicInstance The instance that should rerender.
  21461. * @param {object} partialState Next partial state to be merged with state.
  21462. * @param {?function} callback Called after component is updated.
  21463. * @param {?string} Name of the calling function in the public API.
  21464. * @internal
  21465. */
  21466. enqueueSetState: function (publicInstance, partialState, callback, callerName) {
  21467. warnNoop(publicInstance, 'setState');
  21468. }
  21469. };
  21470. var emptyObject = {};
  21471. {
  21472. Object.freeze(emptyObject);
  21473. }
  21474. /**
  21475. * Base class helpers for the updating state of a component.
  21476. */
  21477. function Component(props, context, updater) {
  21478. this.props = props;
  21479. this.context = context; // If a component has string refs, we will assign a different object later.
  21480. this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
  21481. // renderer.
  21482. this.updater = updater || ReactNoopUpdateQueue;
  21483. }
  21484. Component.prototype.isReactComponent = {};
  21485. /**
  21486. * Sets a subset of the state. Always use this to mutate
  21487. * state. You should treat `this.state` as immutable.
  21488. *
  21489. * There is no guarantee that `this.state` will be immediately updated, so
  21490. * accessing `this.state` after calling this method may return the old value.
  21491. *
  21492. * There is no guarantee that calls to `setState` will run synchronously,
  21493. * as they may eventually be batched together. You can provide an optional
  21494. * callback that will be executed when the call to setState is actually
  21495. * completed.
  21496. *
  21497. * When a function is provided to setState, it will be called at some point in
  21498. * the future (not synchronously). It will be called with the up to date
  21499. * component arguments (state, props, context). These values can be different
  21500. * from this.* because your function may be called after receiveProps but before
  21501. * shouldComponentUpdate, and this new state, props, and context will not yet be
  21502. * assigned to this.
  21503. *
  21504. * @param {object|function} partialState Next partial state or function to
  21505. * produce next partial state to be merged with current state.
  21506. * @param {?function} callback Called after state is updated.
  21507. * @final
  21508. * @protected
  21509. */
  21510. Component.prototype.setState = function (partialState, callback) {
  21511. if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) {
  21512. {
  21513. throw Error( "setState(...): takes an object of state variables to update or a function which returns an object of state variables." );
  21514. }
  21515. }
  21516. this.updater.enqueueSetState(this, partialState, callback, 'setState');
  21517. };
  21518. /**
  21519. * Forces an update. This should only be invoked when it is known with
  21520. * certainty that we are **not** in a DOM transaction.
  21521. *
  21522. * You may want to call this when you know that some deeper aspect of the
  21523. * component's state has changed but `setState` was not called.
  21524. *
  21525. * This will not invoke `shouldComponentUpdate`, but it will invoke
  21526. * `componentWillUpdate` and `componentDidUpdate`.
  21527. *
  21528. * @param {?function} callback Called after update is complete.
  21529. * @final
  21530. * @protected
  21531. */
  21532. Component.prototype.forceUpdate = function (callback) {
  21533. this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
  21534. };
  21535. /**
  21536. * Deprecated APIs. These APIs used to exist on classic React classes but since
  21537. * we would like to deprecate them, we're not going to move them over to this
  21538. * modern base class. Instead, we define a getter that warns if it's accessed.
  21539. */
  21540. {
  21541. var deprecatedAPIs = {
  21542. isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
  21543. replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
  21544. };
  21545. var defineDeprecationWarning = function (methodName, info) {
  21546. Object.defineProperty(Component.prototype, methodName, {
  21547. get: function () {
  21548. warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
  21549. return undefined;
  21550. }
  21551. });
  21552. };
  21553. for (var fnName in deprecatedAPIs) {
  21554. if (deprecatedAPIs.hasOwnProperty(fnName)) {
  21555. defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
  21556. }
  21557. }
  21558. }
  21559. function ComponentDummy() {}
  21560. ComponentDummy.prototype = Component.prototype;
  21561. /**
  21562. * Convenience component with default shallow equality check for sCU.
  21563. */
  21564. function PureComponent(props, context, updater) {
  21565. this.props = props;
  21566. this.context = context; // If a component has string refs, we will assign a different object later.
  21567. this.refs = emptyObject;
  21568. this.updater = updater || ReactNoopUpdateQueue;
  21569. }
  21570. var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
  21571. pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.
  21572. _assign(pureComponentPrototype, Component.prototype);
  21573. pureComponentPrototype.isPureReactComponent = true;
  21574. // an immutable object with a single mutable value
  21575. function createRef() {
  21576. var refObject = {
  21577. current: null
  21578. };
  21579. {
  21580. Object.seal(refObject);
  21581. }
  21582. return refObject;
  21583. }
  21584. var hasOwnProperty = Object.prototype.hasOwnProperty;
  21585. var RESERVED_PROPS = {
  21586. key: true,
  21587. ref: true,
  21588. __self: true,
  21589. __source: true
  21590. };
  21591. var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;
  21592. {
  21593. didWarnAboutStringRefs = {};
  21594. }
  21595. function hasValidRef(config) {
  21596. {
  21597. if (hasOwnProperty.call(config, 'ref')) {
  21598. var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
  21599. if (getter && getter.isReactWarning) {
  21600. return false;
  21601. }
  21602. }
  21603. }
  21604. return config.ref !== undefined;
  21605. }
  21606. function hasValidKey(config) {
  21607. {
  21608. if (hasOwnProperty.call(config, 'key')) {
  21609. var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
  21610. if (getter && getter.isReactWarning) {
  21611. return false;
  21612. }
  21613. }
  21614. }
  21615. return config.key !== undefined;
  21616. }
  21617. function defineKeyPropWarningGetter(props, displayName) {
  21618. var warnAboutAccessingKey = function () {
  21619. {
  21620. if (!specialPropKeyWarningShown) {
  21621. specialPropKeyWarningShown = true;
  21622. error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
  21623. }
  21624. }
  21625. };
  21626. warnAboutAccessingKey.isReactWarning = true;
  21627. Object.defineProperty(props, 'key', {
  21628. get: warnAboutAccessingKey,
  21629. configurable: true
  21630. });
  21631. }
  21632. function defineRefPropWarningGetter(props, displayName) {
  21633. var warnAboutAccessingRef = function () {
  21634. {
  21635. if (!specialPropRefWarningShown) {
  21636. specialPropRefWarningShown = true;
  21637. error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
  21638. }
  21639. }
  21640. };
  21641. warnAboutAccessingRef.isReactWarning = true;
  21642. Object.defineProperty(props, 'ref', {
  21643. get: warnAboutAccessingRef,
  21644. configurable: true
  21645. });
  21646. }
  21647. function warnIfStringRefCannotBeAutoConverted(config) {
  21648. {
  21649. if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
  21650. var componentName = getComponentName(ReactCurrentOwner.current.type);
  21651. if (!didWarnAboutStringRefs[componentName]) {
  21652. error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref);
  21653. didWarnAboutStringRefs[componentName] = true;
  21654. }
  21655. }
  21656. }
  21657. }
  21658. /**
  21659. * Factory method to create a new React element. This no longer adheres to
  21660. * the class pattern, so do not use new to call it. Also, instanceof check
  21661. * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
  21662. * if something is a React Element.
  21663. *
  21664. * @param {*} type
  21665. * @param {*} props
  21666. * @param {*} key
  21667. * @param {string|object} ref
  21668. * @param {*} owner
  21669. * @param {*} self A *temporary* helper to detect places where `this` is
  21670. * different from the `owner` when React.createElement is called, so that we
  21671. * can warn. We want to get rid of owner and replace string `ref`s with arrow
  21672. * functions, and as long as `this` and owner are the same, there will be no
  21673. * change in behavior.
  21674. * @param {*} source An annotation object (added by a transpiler or otherwise)
  21675. * indicating filename, line number, and/or other information.
  21676. * @internal
  21677. */
  21678. var ReactElement = function (type, key, ref, self, source, owner, props) {
  21679. var element = {
  21680. // This tag allows us to uniquely identify this as a React Element
  21681. $$typeof: REACT_ELEMENT_TYPE,
  21682. // Built-in properties that belong on the element
  21683. type: type,
  21684. key: key,
  21685. ref: ref,
  21686. props: props,
  21687. // Record the component responsible for creating this element.
  21688. _owner: owner
  21689. };
  21690. {
  21691. // The validation flag is currently mutative. We put it on
  21692. // an external backing store so that we can freeze the whole object.
  21693. // This can be replaced with a WeakMap once they are implemented in
  21694. // commonly used development environments.
  21695. element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
  21696. // the validation flag non-enumerable (where possible, which should
  21697. // include every environment we run tests in), so the test framework
  21698. // ignores it.
  21699. Object.defineProperty(element._store, 'validated', {
  21700. configurable: false,
  21701. enumerable: false,
  21702. writable: true,
  21703. value: false
  21704. }); // self and source are DEV only properties.
  21705. Object.defineProperty(element, '_self', {
  21706. configurable: false,
  21707. enumerable: false,
  21708. writable: false,
  21709. value: self
  21710. }); // Two elements created in two different places should be considered
  21711. // equal for testing purposes and therefore we hide it from enumeration.
  21712. Object.defineProperty(element, '_source', {
  21713. configurable: false,
  21714. enumerable: false,
  21715. writable: false,
  21716. value: source
  21717. });
  21718. if (Object.freeze) {
  21719. Object.freeze(element.props);
  21720. Object.freeze(element);
  21721. }
  21722. }
  21723. return element;
  21724. };
  21725. /**
  21726. * Create and return a new ReactElement of the given type.
  21727. * See https://reactjs.org/docs/react-api.html#createelement
  21728. */
  21729. function createElement(type, config, children) {
  21730. var propName; // Reserved names are extracted
  21731. var props = {};
  21732. var key = null;
  21733. var ref = null;
  21734. var self = null;
  21735. var source = null;
  21736. if (config != null) {
  21737. if (hasValidRef(config)) {
  21738. ref = config.ref;
  21739. {
  21740. warnIfStringRefCannotBeAutoConverted(config);
  21741. }
  21742. }
  21743. if (hasValidKey(config)) {
  21744. key = '' + config.key;
  21745. }
  21746. self = config.__self === undefined ? null : config.__self;
  21747. source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object
  21748. for (propName in config) {
  21749. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  21750. props[propName] = config[propName];
  21751. }
  21752. }
  21753. } // Children can be more than one argument, and those are transferred onto
  21754. // the newly allocated props object.
  21755. var childrenLength = arguments.length - 2;
  21756. if (childrenLength === 1) {
  21757. props.children = children;
  21758. } else if (childrenLength > 1) {
  21759. var childArray = Array(childrenLength);
  21760. for (var i = 0; i < childrenLength; i++) {
  21761. childArray[i] = arguments[i + 2];
  21762. }
  21763. {
  21764. if (Object.freeze) {
  21765. Object.freeze(childArray);
  21766. }
  21767. }
  21768. props.children = childArray;
  21769. } // Resolve default props
  21770. if (type && type.defaultProps) {
  21771. var defaultProps = type.defaultProps;
  21772. for (propName in defaultProps) {
  21773. if (props[propName] === undefined) {
  21774. props[propName] = defaultProps[propName];
  21775. }
  21776. }
  21777. }
  21778. {
  21779. if (key || ref) {
  21780. var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
  21781. if (key) {
  21782. defineKeyPropWarningGetter(props, displayName);
  21783. }
  21784. if (ref) {
  21785. defineRefPropWarningGetter(props, displayName);
  21786. }
  21787. }
  21788. }
  21789. return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
  21790. }
  21791. function cloneAndReplaceKey(oldElement, newKey) {
  21792. var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
  21793. return newElement;
  21794. }
  21795. /**
  21796. * Clone and return a new ReactElement using element as the starting point.
  21797. * See https://reactjs.org/docs/react-api.html#cloneelement
  21798. */
  21799. function cloneElement(element, config, children) {
  21800. if (!!(element === null || element === undefined)) {
  21801. {
  21802. throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." );
  21803. }
  21804. }
  21805. var propName; // Original props are copied
  21806. var props = _assign({}, element.props); // Reserved names are extracted
  21807. var key = element.key;
  21808. var ref = element.ref; // Self is preserved since the owner is preserved.
  21809. var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a
  21810. // transpiler, and the original source is probably a better indicator of the
  21811. // true owner.
  21812. var source = element._source; // Owner will be preserved, unless ref is overridden
  21813. var owner = element._owner;
  21814. if (config != null) {
  21815. if (hasValidRef(config)) {
  21816. // Silently steal the ref from the parent.
  21817. ref = config.ref;
  21818. owner = ReactCurrentOwner.current;
  21819. }
  21820. if (hasValidKey(config)) {
  21821. key = '' + config.key;
  21822. } // Remaining properties override existing props
  21823. var defaultProps;
  21824. if (element.type && element.type.defaultProps) {
  21825. defaultProps = element.type.defaultProps;
  21826. }
  21827. for (propName in config) {
  21828. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  21829. if (config[propName] === undefined && defaultProps !== undefined) {
  21830. // Resolve default props
  21831. props[propName] = defaultProps[propName];
  21832. } else {
  21833. props[propName] = config[propName];
  21834. }
  21835. }
  21836. }
  21837. } // Children can be more than one argument, and those are transferred onto
  21838. // the newly allocated props object.
  21839. var childrenLength = arguments.length - 2;
  21840. if (childrenLength === 1) {
  21841. props.children = children;
  21842. } else if (childrenLength > 1) {
  21843. var childArray = Array(childrenLength);
  21844. for (var i = 0; i < childrenLength; i++) {
  21845. childArray[i] = arguments[i + 2];
  21846. }
  21847. props.children = childArray;
  21848. }
  21849. return ReactElement(element.type, key, ref, self, source, owner, props);
  21850. }
  21851. /**
  21852. * Verifies the object is a ReactElement.
  21853. * See https://reactjs.org/docs/react-api.html#isvalidelement
  21854. * @param {?object} object
  21855. * @return {boolean} True if `object` is a ReactElement.
  21856. * @final
  21857. */
  21858. function isValidElement(object) {
  21859. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  21860. }
  21861. var SEPARATOR = '.';
  21862. var SUBSEPARATOR = ':';
  21863. /**
  21864. * Escape and wrap key so it is safe to use as a reactid
  21865. *
  21866. * @param {string} key to be escaped.
  21867. * @return {string} the escaped key.
  21868. */
  21869. function escape(key) {
  21870. var escapeRegex = /[=:]/g;
  21871. var escaperLookup = {
  21872. '=': '=0',
  21873. ':': '=2'
  21874. };
  21875. var escapedString = ('' + key).replace(escapeRegex, function (match) {
  21876. return escaperLookup[match];
  21877. });
  21878. return '$' + escapedString;
  21879. }
  21880. /**
  21881. * TODO: Test that a single child and an array with one item have the same key
  21882. * pattern.
  21883. */
  21884. var didWarnAboutMaps = false;
  21885. var userProvidedKeyEscapeRegex = /\/+/g;
  21886. function escapeUserProvidedKey(text) {
  21887. return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
  21888. }
  21889. var POOL_SIZE = 10;
  21890. var traverseContextPool = [];
  21891. function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
  21892. if (traverseContextPool.length) {
  21893. var traverseContext = traverseContextPool.pop();
  21894. traverseContext.result = mapResult;
  21895. traverseContext.keyPrefix = keyPrefix;
  21896. traverseContext.func = mapFunction;
  21897. traverseContext.context = mapContext;
  21898. traverseContext.count = 0;
  21899. return traverseContext;
  21900. } else {
  21901. return {
  21902. result: mapResult,
  21903. keyPrefix: keyPrefix,
  21904. func: mapFunction,
  21905. context: mapContext,
  21906. count: 0
  21907. };
  21908. }
  21909. }
  21910. function releaseTraverseContext(traverseContext) {
  21911. traverseContext.result = null;
  21912. traverseContext.keyPrefix = null;
  21913. traverseContext.func = null;
  21914. traverseContext.context = null;
  21915. traverseContext.count = 0;
  21916. if (traverseContextPool.length < POOL_SIZE) {
  21917. traverseContextPool.push(traverseContext);
  21918. }
  21919. }
  21920. /**
  21921. * @param {?*} children Children tree container.
  21922. * @param {!string} nameSoFar Name of the key path so far.
  21923. * @param {!function} callback Callback to invoke with each child found.
  21924. * @param {?*} traverseContext Used to pass information throughout the traversal
  21925. * process.
  21926. * @return {!number} The number of children in this subtree.
  21927. */
  21928. function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
  21929. var type = typeof children;
  21930. if (type === 'undefined' || type === 'boolean') {
  21931. // All of the above are perceived as null.
  21932. children = null;
  21933. }
  21934. var invokeCallback = false;
  21935. if (children === null) {
  21936. invokeCallback = true;
  21937. } else {
  21938. switch (type) {
  21939. case 'string':
  21940. case 'number':
  21941. invokeCallback = true;
  21942. break;
  21943. case 'object':
  21944. switch (children.$$typeof) {
  21945. case REACT_ELEMENT_TYPE:
  21946. case REACT_PORTAL_TYPE:
  21947. invokeCallback = true;
  21948. }
  21949. }
  21950. }
  21951. if (invokeCallback) {
  21952. callback(traverseContext, children, // If it's the only child, treat the name as if it was wrapped in an array
  21953. // so that it's consistent if the number of children grows.
  21954. nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
  21955. return 1;
  21956. }
  21957. var child;
  21958. var nextName;
  21959. var subtreeCount = 0; // Count of children found in the current subtree.
  21960. var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
  21961. if (Array.isArray(children)) {
  21962. for (var i = 0; i < children.length; i++) {
  21963. child = children[i];
  21964. nextName = nextNamePrefix + getComponentKey(child, i);
  21965. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  21966. }
  21967. } else {
  21968. var iteratorFn = getIteratorFn(children);
  21969. if (typeof iteratorFn === 'function') {
  21970. {
  21971. // Warn about using Maps as children
  21972. if (iteratorFn === children.entries) {
  21973. if (!didWarnAboutMaps) {
  21974. warn('Using Maps as children is deprecated and will be removed in ' + 'a future major release. Consider converting children to ' + 'an array of keyed ReactElements instead.');
  21975. }
  21976. didWarnAboutMaps = true;
  21977. }
  21978. }
  21979. var iterator = iteratorFn.call(children);
  21980. var step;
  21981. var ii = 0;
  21982. while (!(step = iterator.next()).done) {
  21983. child = step.value;
  21984. nextName = nextNamePrefix + getComponentKey(child, ii++);
  21985. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  21986. }
  21987. } else if (type === 'object') {
  21988. var addendum = '';
  21989. {
  21990. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
  21991. }
  21992. var childrenString = '' + children;
  21993. {
  21994. {
  21995. throw Error( "Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ")." + addendum );
  21996. }
  21997. }
  21998. }
  21999. }
  22000. return subtreeCount;
  22001. }
  22002. /**
  22003. * Traverses children that are typically specified as `props.children`, but
  22004. * might also be specified through attributes:
  22005. *
  22006. * - `traverseAllChildren(this.props.children, ...)`
  22007. * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
  22008. *
  22009. * The `traverseContext` is an optional argument that is passed through the
  22010. * entire traversal. It can be used to store accumulations or anything else that
  22011. * the callback might find relevant.
  22012. *
  22013. * @param {?*} children Children tree object.
  22014. * @param {!function} callback To invoke upon traversing each child.
  22015. * @param {?*} traverseContext Context for traversal.
  22016. * @return {!number} The number of children in this subtree.
  22017. */
  22018. function traverseAllChildren(children, callback, traverseContext) {
  22019. if (children == null) {
  22020. return 0;
  22021. }
  22022. return traverseAllChildrenImpl(children, '', callback, traverseContext);
  22023. }
  22024. /**
  22025. * Generate a key string that identifies a component within a set.
  22026. *
  22027. * @param {*} component A component that could contain a manual key.
  22028. * @param {number} index Index that is used if a manual key is not provided.
  22029. * @return {string}
  22030. */
  22031. function getComponentKey(component, index) {
  22032. // Do some typechecking here since we call this blindly. We want to ensure
  22033. // that we don't block potential future ES APIs.
  22034. if (typeof component === 'object' && component !== null && component.key != null) {
  22035. // Explicit key
  22036. return escape(component.key);
  22037. } // Implicit key determined by the index in the set
  22038. return index.toString(36);
  22039. }
  22040. function forEachSingleChild(bookKeeping, child, name) {
  22041. var func = bookKeeping.func,
  22042. context = bookKeeping.context;
  22043. func.call(context, child, bookKeeping.count++);
  22044. }
  22045. /**
  22046. * Iterates through children that are typically specified as `props.children`.
  22047. *
  22048. * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
  22049. *
  22050. * The provided forEachFunc(child, index) will be called for each
  22051. * leaf child.
  22052. *
  22053. * @param {?*} children Children tree container.
  22054. * @param {function(*, int)} forEachFunc
  22055. * @param {*} forEachContext Context for forEachContext.
  22056. */
  22057. function forEachChildren(children, forEachFunc, forEachContext) {
  22058. if (children == null) {
  22059. return children;
  22060. }
  22061. var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
  22062. traverseAllChildren(children, forEachSingleChild, traverseContext);
  22063. releaseTraverseContext(traverseContext);
  22064. }
  22065. function mapSingleChildIntoContext(bookKeeping, child, childKey) {
  22066. var result = bookKeeping.result,
  22067. keyPrefix = bookKeeping.keyPrefix,
  22068. func = bookKeeping.func,
  22069. context = bookKeeping.context;
  22070. var mappedChild = func.call(context, child, bookKeeping.count++);
  22071. if (Array.isArray(mappedChild)) {
  22072. mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
  22073. return c;
  22074. });
  22075. } else if (mappedChild != null) {
  22076. if (isValidElement(mappedChild)) {
  22077. mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
  22078. // traverseAllChildren used to do for objects as children
  22079. keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
  22080. }
  22081. result.push(mappedChild);
  22082. }
  22083. }
  22084. function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
  22085. var escapedPrefix = '';
  22086. if (prefix != null) {
  22087. escapedPrefix = escapeUserProvidedKey(prefix) + '/';
  22088. }
  22089. var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
  22090. traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
  22091. releaseTraverseContext(traverseContext);
  22092. }
  22093. /**
  22094. * Maps children that are typically specified as `props.children`.
  22095. *
  22096. * See https://reactjs.org/docs/react-api.html#reactchildrenmap
  22097. *
  22098. * The provided mapFunction(child, key, index) will be called for each
  22099. * leaf child.
  22100. *
  22101. * @param {?*} children Children tree container.
  22102. * @param {function(*, int)} func The map function.
  22103. * @param {*} context Context for mapFunction.
  22104. * @return {object} Object containing the ordered map of results.
  22105. */
  22106. function mapChildren(children, func, context) {
  22107. if (children == null) {
  22108. return children;
  22109. }
  22110. var result = [];
  22111. mapIntoWithKeyPrefixInternal(children, result, null, func, context);
  22112. return result;
  22113. }
  22114. /**
  22115. * Count the number of children that are typically specified as
  22116. * `props.children`.
  22117. *
  22118. * See https://reactjs.org/docs/react-api.html#reactchildrencount
  22119. *
  22120. * @param {?*} children Children tree container.
  22121. * @return {number} The number of children.
  22122. */
  22123. function countChildren(children) {
  22124. return traverseAllChildren(children, function () {
  22125. return null;
  22126. }, null);
  22127. }
  22128. /**
  22129. * Flatten a children object (typically specified as `props.children`) and
  22130. * return an array with appropriately re-keyed children.
  22131. *
  22132. * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
  22133. */
  22134. function toArray(children) {
  22135. var result = [];
  22136. mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
  22137. return child;
  22138. });
  22139. return result;
  22140. }
  22141. /**
  22142. * Returns the first child in a collection of children and verifies that there
  22143. * is only one child in the collection.
  22144. *
  22145. * See https://reactjs.org/docs/react-api.html#reactchildrenonly
  22146. *
  22147. * The current implementation of this function assumes that a single child gets
  22148. * passed without a wrapper, but the purpose of this helper function is to
  22149. * abstract away the particular structure of children.
  22150. *
  22151. * @param {?object} children Child collection structure.
  22152. * @return {ReactElement} The first and only `ReactElement` contained in the
  22153. * structure.
  22154. */
  22155. function onlyChild(children) {
  22156. if (!isValidElement(children)) {
  22157. {
  22158. throw Error( "React.Children.only expected to receive a single React element child." );
  22159. }
  22160. }
  22161. return children;
  22162. }
  22163. function createContext(defaultValue, calculateChangedBits) {
  22164. if (calculateChangedBits === undefined) {
  22165. calculateChangedBits = null;
  22166. } else {
  22167. {
  22168. if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') {
  22169. error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits);
  22170. }
  22171. }
  22172. }
  22173. var context = {
  22174. $$typeof: REACT_CONTEXT_TYPE,
  22175. _calculateChangedBits: calculateChangedBits,
  22176. // As a workaround to support multiple concurrent renderers, we categorize
  22177. // some renderers as primary and others as secondary. We only expect
  22178. // there to be two concurrent renderers at most: React Native (primary) and
  22179. // Fabric (secondary); React DOM (primary) and React ART (secondary).
  22180. // Secondary renderers store their context values on separate fields.
  22181. _currentValue: defaultValue,
  22182. _currentValue2: defaultValue,
  22183. // Used to track how many concurrent renderers this context currently
  22184. // supports within in a single renderer. Such as parallel server rendering.
  22185. _threadCount: 0,
  22186. // These are circular
  22187. Provider: null,
  22188. Consumer: null
  22189. };
  22190. context.Provider = {
  22191. $$typeof: REACT_PROVIDER_TYPE,
  22192. _context: context
  22193. };
  22194. var hasWarnedAboutUsingNestedContextConsumers = false;
  22195. var hasWarnedAboutUsingConsumerProvider = false;
  22196. {
  22197. // A separate object, but proxies back to the original context object for
  22198. // backwards compatibility. It has a different $$typeof, so we can properly
  22199. // warn for the incorrect usage of Context as a Consumer.
  22200. var Consumer = {
  22201. $$typeof: REACT_CONTEXT_TYPE,
  22202. _context: context,
  22203. _calculateChangedBits: context._calculateChangedBits
  22204. }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
  22205. Object.defineProperties(Consumer, {
  22206. Provider: {
  22207. get: function () {
  22208. if (!hasWarnedAboutUsingConsumerProvider) {
  22209. hasWarnedAboutUsingConsumerProvider = true;
  22210. error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
  22211. }
  22212. return context.Provider;
  22213. },
  22214. set: function (_Provider) {
  22215. context.Provider = _Provider;
  22216. }
  22217. },
  22218. _currentValue: {
  22219. get: function () {
  22220. return context._currentValue;
  22221. },
  22222. set: function (_currentValue) {
  22223. context._currentValue = _currentValue;
  22224. }
  22225. },
  22226. _currentValue2: {
  22227. get: function () {
  22228. return context._currentValue2;
  22229. },
  22230. set: function (_currentValue2) {
  22231. context._currentValue2 = _currentValue2;
  22232. }
  22233. },
  22234. _threadCount: {
  22235. get: function () {
  22236. return context._threadCount;
  22237. },
  22238. set: function (_threadCount) {
  22239. context._threadCount = _threadCount;
  22240. }
  22241. },
  22242. Consumer: {
  22243. get: function () {
  22244. if (!hasWarnedAboutUsingNestedContextConsumers) {
  22245. hasWarnedAboutUsingNestedContextConsumers = true;
  22246. error('Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
  22247. }
  22248. return context.Consumer;
  22249. }
  22250. }
  22251. }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
  22252. context.Consumer = Consumer;
  22253. }
  22254. {
  22255. context._currentRenderer = null;
  22256. context._currentRenderer2 = null;
  22257. }
  22258. return context;
  22259. }
  22260. function lazy(ctor) {
  22261. var lazyType = {
  22262. $$typeof: REACT_LAZY_TYPE,
  22263. _ctor: ctor,
  22264. // React uses these fields to store the result.
  22265. _status: -1,
  22266. _result: null
  22267. };
  22268. {
  22269. // In production, this would just set it on the object.
  22270. var defaultProps;
  22271. var propTypes;
  22272. Object.defineProperties(lazyType, {
  22273. defaultProps: {
  22274. configurable: true,
  22275. get: function () {
  22276. return defaultProps;
  22277. },
  22278. set: function (newDefaultProps) {
  22279. error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
  22280. defaultProps = newDefaultProps; // Match production behavior more closely:
  22281. Object.defineProperty(lazyType, 'defaultProps', {
  22282. enumerable: true
  22283. });
  22284. }
  22285. },
  22286. propTypes: {
  22287. configurable: true,
  22288. get: function () {
  22289. return propTypes;
  22290. },
  22291. set: function (newPropTypes) {
  22292. error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
  22293. propTypes = newPropTypes; // Match production behavior more closely:
  22294. Object.defineProperty(lazyType, 'propTypes', {
  22295. enumerable: true
  22296. });
  22297. }
  22298. }
  22299. });
  22300. }
  22301. return lazyType;
  22302. }
  22303. function forwardRef(render) {
  22304. {
  22305. if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
  22306. error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
  22307. } else if (typeof render !== 'function') {
  22308. error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
  22309. } else {
  22310. if (render.length !== 0 && render.length !== 2) {
  22311. error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.');
  22312. }
  22313. }
  22314. if (render != null) {
  22315. if (render.defaultProps != null || render.propTypes != null) {
  22316. error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?');
  22317. }
  22318. }
  22319. }
  22320. return {
  22321. $$typeof: REACT_FORWARD_REF_TYPE,
  22322. render: render
  22323. };
  22324. }
  22325. function isValidElementType(type) {
  22326. return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  22327. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
  22328. }
  22329. function memo(type, compare) {
  22330. {
  22331. if (!isValidElementType(type)) {
  22332. error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
  22333. }
  22334. }
  22335. return {
  22336. $$typeof: REACT_MEMO_TYPE,
  22337. type: type,
  22338. compare: compare === undefined ? null : compare
  22339. };
  22340. }
  22341. function resolveDispatcher() {
  22342. var dispatcher = ReactCurrentDispatcher.current;
  22343. if (!(dispatcher !== null)) {
  22344. {
  22345. throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." );
  22346. }
  22347. }
  22348. return dispatcher;
  22349. }
  22350. function useContext(Context, unstable_observedBits) {
  22351. var dispatcher = resolveDispatcher();
  22352. {
  22353. if (unstable_observedBits !== undefined) {
  22354. error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '');
  22355. } // TODO: add a more generic warning for invalid values.
  22356. if (Context._context !== undefined) {
  22357. var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
  22358. // and nobody should be using this in existing code.
  22359. if (realContext.Consumer === Context) {
  22360. error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
  22361. } else if (realContext.Provider === Context) {
  22362. error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
  22363. }
  22364. }
  22365. }
  22366. return dispatcher.useContext(Context, unstable_observedBits);
  22367. }
  22368. function useState(initialState) {
  22369. var dispatcher = resolveDispatcher();
  22370. return dispatcher.useState(initialState);
  22371. }
  22372. function useReducer(reducer, initialArg, init) {
  22373. var dispatcher = resolveDispatcher();
  22374. return dispatcher.useReducer(reducer, initialArg, init);
  22375. }
  22376. function useRef(initialValue) {
  22377. var dispatcher = resolveDispatcher();
  22378. return dispatcher.useRef(initialValue);
  22379. }
  22380. function useEffect(create, deps) {
  22381. var dispatcher = resolveDispatcher();
  22382. return dispatcher.useEffect(create, deps);
  22383. }
  22384. function useLayoutEffect(create, deps) {
  22385. var dispatcher = resolveDispatcher();
  22386. return dispatcher.useLayoutEffect(create, deps);
  22387. }
  22388. function useCallback(callback, deps) {
  22389. var dispatcher = resolveDispatcher();
  22390. return dispatcher.useCallback(callback, deps);
  22391. }
  22392. function useMemo(create, deps) {
  22393. var dispatcher = resolveDispatcher();
  22394. return dispatcher.useMemo(create, deps);
  22395. }
  22396. function useImperativeHandle(ref, create, deps) {
  22397. var dispatcher = resolveDispatcher();
  22398. return dispatcher.useImperativeHandle(ref, create, deps);
  22399. }
  22400. function useDebugValue(value, formatterFn) {
  22401. {
  22402. var dispatcher = resolveDispatcher();
  22403. return dispatcher.useDebugValue(value, formatterFn);
  22404. }
  22405. }
  22406. var propTypesMisspellWarningShown;
  22407. {
  22408. propTypesMisspellWarningShown = false;
  22409. }
  22410. function getDeclarationErrorAddendum() {
  22411. if (ReactCurrentOwner.current) {
  22412. var name = getComponentName(ReactCurrentOwner.current.type);
  22413. if (name) {
  22414. return '\n\nCheck the render method of `' + name + '`.';
  22415. }
  22416. }
  22417. return '';
  22418. }
  22419. function getSourceInfoErrorAddendum(source) {
  22420. if (source !== undefined) {
  22421. var fileName = source.fileName.replace(/^.*[\\\/]/, '');
  22422. var lineNumber = source.lineNumber;
  22423. return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
  22424. }
  22425. return '';
  22426. }
  22427. function getSourceInfoErrorAddendumForProps(elementProps) {
  22428. if (elementProps !== null && elementProps !== undefined) {
  22429. return getSourceInfoErrorAddendum(elementProps.__source);
  22430. }
  22431. return '';
  22432. }
  22433. /**
  22434. * Warn if there's no key explicitly set on dynamic arrays of children or
  22435. * object keys are not valid. This allows us to keep track of children between
  22436. * updates.
  22437. */
  22438. var ownerHasKeyUseWarning = {};
  22439. function getCurrentComponentErrorInfo(parentType) {
  22440. var info = getDeclarationErrorAddendum();
  22441. if (!info) {
  22442. var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
  22443. if (parentName) {
  22444. info = "\n\nCheck the top-level render call using <" + parentName + ">.";
  22445. }
  22446. }
  22447. return info;
  22448. }
  22449. /**
  22450. * Warn if the element doesn't have an explicit key assigned to it.
  22451. * This element is in an array. The array could grow and shrink or be
  22452. * reordered. All children that haven't already been validated are required to
  22453. * have a "key" property assigned to it. Error statuses are cached so a warning
  22454. * will only be shown once.
  22455. *
  22456. * @internal
  22457. * @param {ReactElement} element Element that requires a key.
  22458. * @param {*} parentType element's parent's type.
  22459. */
  22460. function validateExplicitKey(element, parentType) {
  22461. if (!element._store || element._store.validated || element.key != null) {
  22462. return;
  22463. }
  22464. element._store.validated = true;
  22465. var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
  22466. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  22467. return;
  22468. }
  22469. ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
  22470. // property, it may be the creator of the child that's responsible for
  22471. // assigning it a key.
  22472. var childOwner = '';
  22473. if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
  22474. // Give the component that originally created this child.
  22475. childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
  22476. }
  22477. setCurrentlyValidatingElement(element);
  22478. {
  22479. error('Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
  22480. }
  22481. setCurrentlyValidatingElement(null);
  22482. }
  22483. /**
  22484. * Ensure that every element either is passed in a static location, in an
  22485. * array with an explicit keys property defined, or in an object literal
  22486. * with valid key property.
  22487. *
  22488. * @internal
  22489. * @param {ReactNode} node Statically passed child of any type.
  22490. * @param {*} parentType node's parent's type.
  22491. */
  22492. function validateChildKeys(node, parentType) {
  22493. if (typeof node !== 'object') {
  22494. return;
  22495. }
  22496. if (Array.isArray(node)) {
  22497. for (var i = 0; i < node.length; i++) {
  22498. var child = node[i];
  22499. if (isValidElement(child)) {
  22500. validateExplicitKey(child, parentType);
  22501. }
  22502. }
  22503. } else if (isValidElement(node)) {
  22504. // This element was passed in a valid location.
  22505. if (node._store) {
  22506. node._store.validated = true;
  22507. }
  22508. } else if (node) {
  22509. var iteratorFn = getIteratorFn(node);
  22510. if (typeof iteratorFn === 'function') {
  22511. // Entry iterators used to provide implicit keys,
  22512. // but now we print a separate warning for them later.
  22513. if (iteratorFn !== node.entries) {
  22514. var iterator = iteratorFn.call(node);
  22515. var step;
  22516. while (!(step = iterator.next()).done) {
  22517. if (isValidElement(step.value)) {
  22518. validateExplicitKey(step.value, parentType);
  22519. }
  22520. }
  22521. }
  22522. }
  22523. }
  22524. }
  22525. /**
  22526. * Given an element, validate that its props follow the propTypes definition,
  22527. * provided by the type.
  22528. *
  22529. * @param {ReactElement} element
  22530. */
  22531. function validatePropTypes(element) {
  22532. {
  22533. var type = element.type;
  22534. if (type === null || type === undefined || typeof type === 'string') {
  22535. return;
  22536. }
  22537. var name = getComponentName(type);
  22538. var propTypes;
  22539. if (typeof type === 'function') {
  22540. propTypes = type.propTypes;
  22541. } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
  22542. // Inner props are checked in the reconciler.
  22543. type.$$typeof === REACT_MEMO_TYPE)) {
  22544. propTypes = type.propTypes;
  22545. } else {
  22546. return;
  22547. }
  22548. if (propTypes) {
  22549. setCurrentlyValidatingElement(element);
  22550. checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
  22551. setCurrentlyValidatingElement(null);
  22552. } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
  22553. propTypesMisspellWarningShown = true;
  22554. error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
  22555. }
  22556. if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
  22557. error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
  22558. }
  22559. }
  22560. }
  22561. /**
  22562. * Given a fragment, validate that it can only be provided with fragment props
  22563. * @param {ReactElement} fragment
  22564. */
  22565. function validateFragmentProps(fragment) {
  22566. {
  22567. setCurrentlyValidatingElement(fragment);
  22568. var keys = Object.keys(fragment.props);
  22569. for (var i = 0; i < keys.length; i++) {
  22570. var key = keys[i];
  22571. if (key !== 'children' && key !== 'key') {
  22572. error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
  22573. break;
  22574. }
  22575. }
  22576. if (fragment.ref !== null) {
  22577. error('Invalid attribute `ref` supplied to `React.Fragment`.');
  22578. }
  22579. setCurrentlyValidatingElement(null);
  22580. }
  22581. }
  22582. function createElementWithValidation(type, props, children) {
  22583. var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
  22584. // succeed and there will likely be errors in render.
  22585. if (!validType) {
  22586. var info = '';
  22587. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  22588. info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
  22589. }
  22590. var sourceInfo = getSourceInfoErrorAddendumForProps(props);
  22591. if (sourceInfo) {
  22592. info += sourceInfo;
  22593. } else {
  22594. info += getDeclarationErrorAddendum();
  22595. }
  22596. var typeString;
  22597. if (type === null) {
  22598. typeString = 'null';
  22599. } else if (Array.isArray(type)) {
  22600. typeString = 'array';
  22601. } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
  22602. typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
  22603. info = ' Did you accidentally export a JSX literal instead of a component?';
  22604. } else {
  22605. typeString = typeof type;
  22606. }
  22607. {
  22608. error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
  22609. }
  22610. }
  22611. var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
  22612. // TODO: Drop this when these are no longer allowed as the type argument.
  22613. if (element == null) {
  22614. return element;
  22615. } // Skip key warning if the type isn't valid since our key validation logic
  22616. // doesn't expect a non-string/function type and can throw confusing errors.
  22617. // We don't want exception behavior to differ between dev and prod.
  22618. // (Rendering will throw with a helpful message and as soon as the type is
  22619. // fixed, the key warnings will appear.)
  22620. if (validType) {
  22621. for (var i = 2; i < arguments.length; i++) {
  22622. validateChildKeys(arguments[i], type);
  22623. }
  22624. }
  22625. if (type === REACT_FRAGMENT_TYPE) {
  22626. validateFragmentProps(element);
  22627. } else {
  22628. validatePropTypes(element);
  22629. }
  22630. return element;
  22631. }
  22632. var didWarnAboutDeprecatedCreateFactory = false;
  22633. function createFactoryWithValidation(type) {
  22634. var validatedFactory = createElementWithValidation.bind(null, type);
  22635. validatedFactory.type = type;
  22636. {
  22637. if (!didWarnAboutDeprecatedCreateFactory) {
  22638. didWarnAboutDeprecatedCreateFactory = true;
  22639. warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.');
  22640. } // Legacy hook: remove it
  22641. Object.defineProperty(validatedFactory, 'type', {
  22642. enumerable: false,
  22643. get: function () {
  22644. warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
  22645. Object.defineProperty(this, 'type', {
  22646. value: type
  22647. });
  22648. return type;
  22649. }
  22650. });
  22651. }
  22652. return validatedFactory;
  22653. }
  22654. function cloneElementWithValidation(element, props, children) {
  22655. var newElement = cloneElement.apply(this, arguments);
  22656. for (var i = 2; i < arguments.length; i++) {
  22657. validateChildKeys(arguments[i], newElement.type);
  22658. }
  22659. validatePropTypes(newElement);
  22660. return newElement;
  22661. }
  22662. {
  22663. try {
  22664. var frozenObject = Object.freeze({});
  22665. var testMap = new Map([[frozenObject, null]]);
  22666. var testSet = new Set([frozenObject]); // This is necessary for Rollup to not consider these unused.
  22667. // https://github.com/rollup/rollup/issues/1771
  22668. // TODO: we can remove these if Rollup fixes the bug.
  22669. testMap.set(0, 0);
  22670. testSet.add(0);
  22671. } catch (e) {
  22672. }
  22673. }
  22674. var createElement$1 = createElementWithValidation ;
  22675. var cloneElement$1 = cloneElementWithValidation ;
  22676. var createFactory = createFactoryWithValidation ;
  22677. var Children = {
  22678. map: mapChildren,
  22679. forEach: forEachChildren,
  22680. count: countChildren,
  22681. toArray: toArray,
  22682. only: onlyChild
  22683. };
  22684. exports.Children = Children;
  22685. exports.Component = Component;
  22686. exports.Fragment = REACT_FRAGMENT_TYPE;
  22687. exports.Profiler = REACT_PROFILER_TYPE;
  22688. exports.PureComponent = PureComponent;
  22689. exports.StrictMode = REACT_STRICT_MODE_TYPE;
  22690. exports.Suspense = REACT_SUSPENSE_TYPE;
  22691. exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;
  22692. exports.cloneElement = cloneElement$1;
  22693. exports.createContext = createContext;
  22694. exports.createElement = createElement$1;
  22695. exports.createFactory = createFactory;
  22696. exports.createRef = createRef;
  22697. exports.forwardRef = forwardRef;
  22698. exports.isValidElement = isValidElement;
  22699. exports.lazy = lazy;
  22700. exports.memo = memo;
  22701. exports.useCallback = useCallback;
  22702. exports.useContext = useContext;
  22703. exports.useDebugValue = useDebugValue;
  22704. exports.useEffect = useEffect;
  22705. exports.useImperativeHandle = useImperativeHandle;
  22706. exports.useLayoutEffect = useLayoutEffect;
  22707. exports.useMemo = useMemo;
  22708. exports.useReducer = useReducer;
  22709. exports.useRef = useRef;
  22710. exports.useState = useState;
  22711. exports.version = ReactVersion;
  22712. })();
  22713. }
  22714. /***/ }),
  22715. /***/ "../../node_modules/react/index.js":
  22716. /*!*************************************************************!*\
  22717. !*** C:/Dev/Babylon/Babylon.js/node_modules/react/index.js ***!
  22718. \*************************************************************/
  22719. /*! no static exports found */
  22720. /***/ (function(module, exports, __webpack_require__) {
  22721. "use strict";
  22722. if (false) {} else {
  22723. module.exports = __webpack_require__(/*! ./cjs/react.development.js */ "../../node_modules/react/cjs/react.development.js");
  22724. }
  22725. /***/ }),
  22726. /***/ "../../node_modules/scheduler/cjs/scheduler-tracing.development.js":
  22727. /*!*********************************************************************************************!*\
  22728. !*** C:/Dev/Babylon/Babylon.js/node_modules/scheduler/cjs/scheduler-tracing.development.js ***!
  22729. \*********************************************************************************************/
  22730. /*! no static exports found */
  22731. /***/ (function(module, exports, __webpack_require__) {
  22732. "use strict";
  22733. /** @license React v0.19.1
  22734. * scheduler-tracing.development.js
  22735. *
  22736. * Copyright (c) Facebook, Inc. and its affiliates.
  22737. *
  22738. * This source code is licensed under the MIT license found in the
  22739. * LICENSE file in the root directory of this source tree.
  22740. */
  22741. if (true) {
  22742. (function() {
  22743. 'use strict';
  22744. var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs.
  22745. var interactionIDCounter = 0;
  22746. var threadIDCounter = 0; // Set of currently traced interactions.
  22747. // Interactions "stack"–
  22748. // Meaning that newly traced interactions are appended to the previously active set.
  22749. // When an interaction goes out of scope, the previous set (if any) is restored.
  22750. exports.__interactionsRef = null; // Listener(s) to notify when interactions begin and end.
  22751. exports.__subscriberRef = null;
  22752. {
  22753. exports.__interactionsRef = {
  22754. current: new Set()
  22755. };
  22756. exports.__subscriberRef = {
  22757. current: null
  22758. };
  22759. }
  22760. function unstable_clear(callback) {
  22761. var prevInteractions = exports.__interactionsRef.current;
  22762. exports.__interactionsRef.current = new Set();
  22763. try {
  22764. return callback();
  22765. } finally {
  22766. exports.__interactionsRef.current = prevInteractions;
  22767. }
  22768. }
  22769. function unstable_getCurrent() {
  22770. {
  22771. return exports.__interactionsRef.current;
  22772. }
  22773. }
  22774. function unstable_getThreadID() {
  22775. return ++threadIDCounter;
  22776. }
  22777. function unstable_trace(name, timestamp, callback) {
  22778. var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
  22779. var interaction = {
  22780. __count: 1,
  22781. id: interactionIDCounter++,
  22782. name: name,
  22783. timestamp: timestamp
  22784. };
  22785. var prevInteractions = exports.__interactionsRef.current; // Traced interactions should stack/accumulate.
  22786. // To do that, clone the current interactions.
  22787. // The previous set will be restored upon completion.
  22788. var interactions = new Set(prevInteractions);
  22789. interactions.add(interaction);
  22790. exports.__interactionsRef.current = interactions;
  22791. var subscriber = exports.__subscriberRef.current;
  22792. var returnValue;
  22793. try {
  22794. if (subscriber !== null) {
  22795. subscriber.onInteractionTraced(interaction);
  22796. }
  22797. } finally {
  22798. try {
  22799. if (subscriber !== null) {
  22800. subscriber.onWorkStarted(interactions, threadID);
  22801. }
  22802. } finally {
  22803. try {
  22804. returnValue = callback();
  22805. } finally {
  22806. exports.__interactionsRef.current = prevInteractions;
  22807. try {
  22808. if (subscriber !== null) {
  22809. subscriber.onWorkStopped(interactions, threadID);
  22810. }
  22811. } finally {
  22812. interaction.__count--; // If no async work was scheduled for this interaction,
  22813. // Notify subscribers that it's completed.
  22814. if (subscriber !== null && interaction.__count === 0) {
  22815. subscriber.onInteractionScheduledWorkCompleted(interaction);
  22816. }
  22817. }
  22818. }
  22819. }
  22820. }
  22821. return returnValue;
  22822. }
  22823. function unstable_wrap(callback) {
  22824. var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
  22825. var wrappedInteractions = exports.__interactionsRef.current;
  22826. var subscriber = exports.__subscriberRef.current;
  22827. if (subscriber !== null) {
  22828. subscriber.onWorkScheduled(wrappedInteractions, threadID);
  22829. } // Update the pending async work count for the current interactions.
  22830. // Update after calling subscribers in case of error.
  22831. wrappedInteractions.forEach(function (interaction) {
  22832. interaction.__count++;
  22833. });
  22834. var hasRun = false;
  22835. function wrapped() {
  22836. var prevInteractions = exports.__interactionsRef.current;
  22837. exports.__interactionsRef.current = wrappedInteractions;
  22838. subscriber = exports.__subscriberRef.current;
  22839. try {
  22840. var returnValue;
  22841. try {
  22842. if (subscriber !== null) {
  22843. subscriber.onWorkStarted(wrappedInteractions, threadID);
  22844. }
  22845. } finally {
  22846. try {
  22847. returnValue = callback.apply(undefined, arguments);
  22848. } finally {
  22849. exports.__interactionsRef.current = prevInteractions;
  22850. if (subscriber !== null) {
  22851. subscriber.onWorkStopped(wrappedInteractions, threadID);
  22852. }
  22853. }
  22854. }
  22855. return returnValue;
  22856. } finally {
  22857. if (!hasRun) {
  22858. // We only expect a wrapped function to be executed once,
  22859. // But in the event that it's executed more than once–
  22860. // Only decrement the outstanding interaction counts once.
  22861. hasRun = true; // Update pending async counts for all wrapped interactions.
  22862. // If this was the last scheduled async work for any of them,
  22863. // Mark them as completed.
  22864. wrappedInteractions.forEach(function (interaction) {
  22865. interaction.__count--;
  22866. if (subscriber !== null && interaction.__count === 0) {
  22867. subscriber.onInteractionScheduledWorkCompleted(interaction);
  22868. }
  22869. });
  22870. }
  22871. }
  22872. }
  22873. wrapped.cancel = function cancel() {
  22874. subscriber = exports.__subscriberRef.current;
  22875. try {
  22876. if (subscriber !== null) {
  22877. subscriber.onWorkCanceled(wrappedInteractions, threadID);
  22878. }
  22879. } finally {
  22880. // Update pending async counts for all wrapped interactions.
  22881. // If this was the last scheduled async work for any of them,
  22882. // Mark them as completed.
  22883. wrappedInteractions.forEach(function (interaction) {
  22884. interaction.__count--;
  22885. if (subscriber && interaction.__count === 0) {
  22886. subscriber.onInteractionScheduledWorkCompleted(interaction);
  22887. }
  22888. });
  22889. }
  22890. };
  22891. return wrapped;
  22892. }
  22893. var subscribers = null;
  22894. {
  22895. subscribers = new Set();
  22896. }
  22897. function unstable_subscribe(subscriber) {
  22898. {
  22899. subscribers.add(subscriber);
  22900. if (subscribers.size === 1) {
  22901. exports.__subscriberRef.current = {
  22902. onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
  22903. onInteractionTraced: onInteractionTraced,
  22904. onWorkCanceled: onWorkCanceled,
  22905. onWorkScheduled: onWorkScheduled,
  22906. onWorkStarted: onWorkStarted,
  22907. onWorkStopped: onWorkStopped
  22908. };
  22909. }
  22910. }
  22911. }
  22912. function unstable_unsubscribe(subscriber) {
  22913. {
  22914. subscribers.delete(subscriber);
  22915. if (subscribers.size === 0) {
  22916. exports.__subscriberRef.current = null;
  22917. }
  22918. }
  22919. }
  22920. function onInteractionTraced(interaction) {
  22921. var didCatchError = false;
  22922. var caughtError = null;
  22923. subscribers.forEach(function (subscriber) {
  22924. try {
  22925. subscriber.onInteractionTraced(interaction);
  22926. } catch (error) {
  22927. if (!didCatchError) {
  22928. didCatchError = true;
  22929. caughtError = error;
  22930. }
  22931. }
  22932. });
  22933. if (didCatchError) {
  22934. throw caughtError;
  22935. }
  22936. }
  22937. function onInteractionScheduledWorkCompleted(interaction) {
  22938. var didCatchError = false;
  22939. var caughtError = null;
  22940. subscribers.forEach(function (subscriber) {
  22941. try {
  22942. subscriber.onInteractionScheduledWorkCompleted(interaction);
  22943. } catch (error) {
  22944. if (!didCatchError) {
  22945. didCatchError = true;
  22946. caughtError = error;
  22947. }
  22948. }
  22949. });
  22950. if (didCatchError) {
  22951. throw caughtError;
  22952. }
  22953. }
  22954. function onWorkScheduled(interactions, threadID) {
  22955. var didCatchError = false;
  22956. var caughtError = null;
  22957. subscribers.forEach(function (subscriber) {
  22958. try {
  22959. subscriber.onWorkScheduled(interactions, threadID);
  22960. } catch (error) {
  22961. if (!didCatchError) {
  22962. didCatchError = true;
  22963. caughtError = error;
  22964. }
  22965. }
  22966. });
  22967. if (didCatchError) {
  22968. throw caughtError;
  22969. }
  22970. }
  22971. function onWorkStarted(interactions, threadID) {
  22972. var didCatchError = false;
  22973. var caughtError = null;
  22974. subscribers.forEach(function (subscriber) {
  22975. try {
  22976. subscriber.onWorkStarted(interactions, threadID);
  22977. } catch (error) {
  22978. if (!didCatchError) {
  22979. didCatchError = true;
  22980. caughtError = error;
  22981. }
  22982. }
  22983. });
  22984. if (didCatchError) {
  22985. throw caughtError;
  22986. }
  22987. }
  22988. function onWorkStopped(interactions, threadID) {
  22989. var didCatchError = false;
  22990. var caughtError = null;
  22991. subscribers.forEach(function (subscriber) {
  22992. try {
  22993. subscriber.onWorkStopped(interactions, threadID);
  22994. } catch (error) {
  22995. if (!didCatchError) {
  22996. didCatchError = true;
  22997. caughtError = error;
  22998. }
  22999. }
  23000. });
  23001. if (didCatchError) {
  23002. throw caughtError;
  23003. }
  23004. }
  23005. function onWorkCanceled(interactions, threadID) {
  23006. var didCatchError = false;
  23007. var caughtError = null;
  23008. subscribers.forEach(function (subscriber) {
  23009. try {
  23010. subscriber.onWorkCanceled(interactions, threadID);
  23011. } catch (error) {
  23012. if (!didCatchError) {
  23013. didCatchError = true;
  23014. caughtError = error;
  23015. }
  23016. }
  23017. });
  23018. if (didCatchError) {
  23019. throw caughtError;
  23020. }
  23021. }
  23022. exports.unstable_clear = unstable_clear;
  23023. exports.unstable_getCurrent = unstable_getCurrent;
  23024. exports.unstable_getThreadID = unstable_getThreadID;
  23025. exports.unstable_subscribe = unstable_subscribe;
  23026. exports.unstable_trace = unstable_trace;
  23027. exports.unstable_unsubscribe = unstable_unsubscribe;
  23028. exports.unstable_wrap = unstable_wrap;
  23029. })();
  23030. }
  23031. /***/ }),
  23032. /***/ "../../node_modules/scheduler/cjs/scheduler.development.js":
  23033. /*!*************************************************************************************!*\
  23034. !*** C:/Dev/Babylon/Babylon.js/node_modules/scheduler/cjs/scheduler.development.js ***!
  23035. \*************************************************************************************/
  23036. /*! no static exports found */
  23037. /***/ (function(module, exports, __webpack_require__) {
  23038. "use strict";
  23039. /** @license React v0.19.1
  23040. * scheduler.development.js
  23041. *
  23042. * Copyright (c) Facebook, Inc. and its affiliates.
  23043. *
  23044. * This source code is licensed under the MIT license found in the
  23045. * LICENSE file in the root directory of this source tree.
  23046. */
  23047. if (true) {
  23048. (function() {
  23049. 'use strict';
  23050. var enableSchedulerDebugging = false;
  23051. var enableProfiling = true;
  23052. var requestHostCallback;
  23053. var requestHostTimeout;
  23054. var cancelHostTimeout;
  23055. var shouldYieldToHost;
  23056. var requestPaint;
  23057. if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive
  23058. // implementation using setTimeout.
  23059. typeof window === 'undefined' || // Check if MessageChannel is supported, too.
  23060. typeof MessageChannel !== 'function') {
  23061. // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
  23062. // fallback to a naive implementation.
  23063. var _callback = null;
  23064. var _timeoutID = null;
  23065. var _flushCallback = function () {
  23066. if (_callback !== null) {
  23067. try {
  23068. var currentTime = exports.unstable_now();
  23069. var hasRemainingTime = true;
  23070. _callback(hasRemainingTime, currentTime);
  23071. _callback = null;
  23072. } catch (e) {
  23073. setTimeout(_flushCallback, 0);
  23074. throw e;
  23075. }
  23076. }
  23077. };
  23078. var initialTime = Date.now();
  23079. exports.unstable_now = function () {
  23080. return Date.now() - initialTime;
  23081. };
  23082. requestHostCallback = function (cb) {
  23083. if (_callback !== null) {
  23084. // Protect against re-entrancy.
  23085. setTimeout(requestHostCallback, 0, cb);
  23086. } else {
  23087. _callback = cb;
  23088. setTimeout(_flushCallback, 0);
  23089. }
  23090. };
  23091. requestHostTimeout = function (cb, ms) {
  23092. _timeoutID = setTimeout(cb, ms);
  23093. };
  23094. cancelHostTimeout = function () {
  23095. clearTimeout(_timeoutID);
  23096. };
  23097. shouldYieldToHost = function () {
  23098. return false;
  23099. };
  23100. requestPaint = exports.unstable_forceFrameRate = function () {};
  23101. } else {
  23102. // Capture local references to native APIs, in case a polyfill overrides them.
  23103. var performance = window.performance;
  23104. var _Date = window.Date;
  23105. var _setTimeout = window.setTimeout;
  23106. var _clearTimeout = window.clearTimeout;
  23107. if (typeof console !== 'undefined') {
  23108. // TODO: Scheduler no longer requires these methods to be polyfilled. But
  23109. // maybe we want to continue warning if they don't exist, to preserve the
  23110. // option to rely on it in the future?
  23111. var requestAnimationFrame = window.requestAnimationFrame;
  23112. var cancelAnimationFrame = window.cancelAnimationFrame; // TODO: Remove fb.me link
  23113. if (typeof requestAnimationFrame !== 'function') {
  23114. // Using console['error'] to evade Babel and ESLint
  23115. console['error']("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  23116. }
  23117. if (typeof cancelAnimationFrame !== 'function') {
  23118. // Using console['error'] to evade Babel and ESLint
  23119. console['error']("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  23120. }
  23121. }
  23122. if (typeof performance === 'object' && typeof performance.now === 'function') {
  23123. exports.unstable_now = function () {
  23124. return performance.now();
  23125. };
  23126. } else {
  23127. var _initialTime = _Date.now();
  23128. exports.unstable_now = function () {
  23129. return _Date.now() - _initialTime;
  23130. };
  23131. }
  23132. var isMessageLoopRunning = false;
  23133. var scheduledHostCallback = null;
  23134. var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main
  23135. // thread, like user events. By default, it yields multiple times per frame.
  23136. // It does not attempt to align with frame boundaries, since most tasks don't
  23137. // need to be frame aligned; for those that do, use requestAnimationFrame.
  23138. var yieldInterval = 5;
  23139. var deadline = 0; // TODO: Make this configurable
  23140. {
  23141. // `isInputPending` is not available. Since we have no way of knowing if
  23142. // there's pending input, always yield at the end of the frame.
  23143. shouldYieldToHost = function () {
  23144. return exports.unstable_now() >= deadline;
  23145. }; // Since we yield every frame regardless, `requestPaint` has no effect.
  23146. requestPaint = function () {};
  23147. }
  23148. exports.unstable_forceFrameRate = function (fps) {
  23149. if (fps < 0 || fps > 125) {
  23150. // Using console['error'] to evade Babel and ESLint
  23151. console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing framerates higher than 125 fps is not unsupported');
  23152. return;
  23153. }
  23154. if (fps > 0) {
  23155. yieldInterval = Math.floor(1000 / fps);
  23156. } else {
  23157. // reset the framerate
  23158. yieldInterval = 5;
  23159. }
  23160. };
  23161. var performWorkUntilDeadline = function () {
  23162. if (scheduledHostCallback !== null) {
  23163. var currentTime = exports.unstable_now(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync
  23164. // cycle. This means there's always time remaining at the beginning of
  23165. // the message event.
  23166. deadline = currentTime + yieldInterval;
  23167. var hasTimeRemaining = true;
  23168. try {
  23169. var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
  23170. if (!hasMoreWork) {
  23171. isMessageLoopRunning = false;
  23172. scheduledHostCallback = null;
  23173. } else {
  23174. // If there's more work, schedule the next message event at the end
  23175. // of the preceding one.
  23176. port.postMessage(null);
  23177. }
  23178. } catch (error) {
  23179. // If a scheduler task throws, exit the current browser task so the
  23180. // error can be observed.
  23181. port.postMessage(null);
  23182. throw error;
  23183. }
  23184. } else {
  23185. isMessageLoopRunning = false;
  23186. } // Yielding to the browser will give it a chance to paint, so we can
  23187. };
  23188. var channel = new MessageChannel();
  23189. var port = channel.port2;
  23190. channel.port1.onmessage = performWorkUntilDeadline;
  23191. requestHostCallback = function (callback) {
  23192. scheduledHostCallback = callback;
  23193. if (!isMessageLoopRunning) {
  23194. isMessageLoopRunning = true;
  23195. port.postMessage(null);
  23196. }
  23197. };
  23198. requestHostTimeout = function (callback, ms) {
  23199. taskTimeoutID = _setTimeout(function () {
  23200. callback(exports.unstable_now());
  23201. }, ms);
  23202. };
  23203. cancelHostTimeout = function () {
  23204. _clearTimeout(taskTimeoutID);
  23205. taskTimeoutID = -1;
  23206. };
  23207. }
  23208. function push(heap, node) {
  23209. var index = heap.length;
  23210. heap.push(node);
  23211. siftUp(heap, node, index);
  23212. }
  23213. function peek(heap) {
  23214. var first = heap[0];
  23215. return first === undefined ? null : first;
  23216. }
  23217. function pop(heap) {
  23218. var first = heap[0];
  23219. if (first !== undefined) {
  23220. var last = heap.pop();
  23221. if (last !== first) {
  23222. heap[0] = last;
  23223. siftDown(heap, last, 0);
  23224. }
  23225. return first;
  23226. } else {
  23227. return null;
  23228. }
  23229. }
  23230. function siftUp(heap, node, i) {
  23231. var index = i;
  23232. while (true) {
  23233. var parentIndex = index - 1 >>> 1;
  23234. var parent = heap[parentIndex];
  23235. if (parent !== undefined && compare(parent, node) > 0) {
  23236. // The parent is larger. Swap positions.
  23237. heap[parentIndex] = node;
  23238. heap[index] = parent;
  23239. index = parentIndex;
  23240. } else {
  23241. // The parent is smaller. Exit.
  23242. return;
  23243. }
  23244. }
  23245. }
  23246. function siftDown(heap, node, i) {
  23247. var index = i;
  23248. var length = heap.length;
  23249. while (index < length) {
  23250. var leftIndex = (index + 1) * 2 - 1;
  23251. var left = heap[leftIndex];
  23252. var rightIndex = leftIndex + 1;
  23253. var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
  23254. if (left !== undefined && compare(left, node) < 0) {
  23255. if (right !== undefined && compare(right, left) < 0) {
  23256. heap[index] = right;
  23257. heap[rightIndex] = node;
  23258. index = rightIndex;
  23259. } else {
  23260. heap[index] = left;
  23261. heap[leftIndex] = node;
  23262. index = leftIndex;
  23263. }
  23264. } else if (right !== undefined && compare(right, node) < 0) {
  23265. heap[index] = right;
  23266. heap[rightIndex] = node;
  23267. index = rightIndex;
  23268. } else {
  23269. // Neither child is smaller. Exit.
  23270. return;
  23271. }
  23272. }
  23273. }
  23274. function compare(a, b) {
  23275. // Compare sort index first, then task id.
  23276. var diff = a.sortIndex - b.sortIndex;
  23277. return diff !== 0 ? diff : a.id - b.id;
  23278. }
  23279. // TODO: Use symbols?
  23280. var NoPriority = 0;
  23281. var ImmediatePriority = 1;
  23282. var UserBlockingPriority = 2;
  23283. var NormalPriority = 3;
  23284. var LowPriority = 4;
  23285. var IdlePriority = 5;
  23286. var runIdCounter = 0;
  23287. var mainThreadIdCounter = 0;
  23288. var profilingStateSize = 4;
  23289. var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer
  23290. typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
  23291. typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
  23292. ;
  23293. var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
  23294. var PRIORITY = 0;
  23295. var CURRENT_TASK_ID = 1;
  23296. var CURRENT_RUN_ID = 2;
  23297. var QUEUE_SIZE = 3;
  23298. {
  23299. profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
  23300. // array might include canceled tasks.
  23301. profilingState[QUEUE_SIZE] = 0;
  23302. profilingState[CURRENT_TASK_ID] = 0;
  23303. } // Bytes per element is 4
  23304. var INITIAL_EVENT_LOG_SIZE = 131072;
  23305. var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
  23306. var eventLogSize = 0;
  23307. var eventLogBuffer = null;
  23308. var eventLog = null;
  23309. var eventLogIndex = 0;
  23310. var TaskStartEvent = 1;
  23311. var TaskCompleteEvent = 2;
  23312. var TaskErrorEvent = 3;
  23313. var TaskCancelEvent = 4;
  23314. var TaskRunEvent = 5;
  23315. var TaskYieldEvent = 6;
  23316. var SchedulerSuspendEvent = 7;
  23317. var SchedulerResumeEvent = 8;
  23318. function logEvent(entries) {
  23319. if (eventLog !== null) {
  23320. var offset = eventLogIndex;
  23321. eventLogIndex += entries.length;
  23322. if (eventLogIndex + 1 > eventLogSize) {
  23323. eventLogSize *= 2;
  23324. if (eventLogSize > MAX_EVENT_LOG_SIZE) {
  23325. // Using console['error'] to evade Babel and ESLint
  23326. console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
  23327. stopLoggingProfilingEvents();
  23328. return;
  23329. }
  23330. var newEventLog = new Int32Array(eventLogSize * 4);
  23331. newEventLog.set(eventLog);
  23332. eventLogBuffer = newEventLog.buffer;
  23333. eventLog = newEventLog;
  23334. }
  23335. eventLog.set(entries, offset);
  23336. }
  23337. }
  23338. function startLoggingProfilingEvents() {
  23339. eventLogSize = INITIAL_EVENT_LOG_SIZE;
  23340. eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
  23341. eventLog = new Int32Array(eventLogBuffer);
  23342. eventLogIndex = 0;
  23343. }
  23344. function stopLoggingProfilingEvents() {
  23345. var buffer = eventLogBuffer;
  23346. eventLogSize = 0;
  23347. eventLogBuffer = null;
  23348. eventLog = null;
  23349. eventLogIndex = 0;
  23350. return buffer;
  23351. }
  23352. function markTaskStart(task, ms) {
  23353. {
  23354. profilingState[QUEUE_SIZE]++;
  23355. if (eventLog !== null) {
  23356. // performance.now returns a float, representing milliseconds. When the
  23357. // event is logged, it's coerced to an int. Convert to microseconds to
  23358. // maintain extra degrees of precision.
  23359. logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
  23360. }
  23361. }
  23362. }
  23363. function markTaskCompleted(task, ms) {
  23364. {
  23365. profilingState[PRIORITY] = NoPriority;
  23366. profilingState[CURRENT_TASK_ID] = 0;
  23367. profilingState[QUEUE_SIZE]--;
  23368. if (eventLog !== null) {
  23369. logEvent([TaskCompleteEvent, ms * 1000, task.id]);
  23370. }
  23371. }
  23372. }
  23373. function markTaskCanceled(task, ms) {
  23374. {
  23375. profilingState[QUEUE_SIZE]--;
  23376. if (eventLog !== null) {
  23377. logEvent([TaskCancelEvent, ms * 1000, task.id]);
  23378. }
  23379. }
  23380. }
  23381. function markTaskErrored(task, ms) {
  23382. {
  23383. profilingState[PRIORITY] = NoPriority;
  23384. profilingState[CURRENT_TASK_ID] = 0;
  23385. profilingState[QUEUE_SIZE]--;
  23386. if (eventLog !== null) {
  23387. logEvent([TaskErrorEvent, ms * 1000, task.id]);
  23388. }
  23389. }
  23390. }
  23391. function markTaskRun(task, ms) {
  23392. {
  23393. runIdCounter++;
  23394. profilingState[PRIORITY] = task.priorityLevel;
  23395. profilingState[CURRENT_TASK_ID] = task.id;
  23396. profilingState[CURRENT_RUN_ID] = runIdCounter;
  23397. if (eventLog !== null) {
  23398. logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
  23399. }
  23400. }
  23401. }
  23402. function markTaskYield(task, ms) {
  23403. {
  23404. profilingState[PRIORITY] = NoPriority;
  23405. profilingState[CURRENT_TASK_ID] = 0;
  23406. profilingState[CURRENT_RUN_ID] = 0;
  23407. if (eventLog !== null) {
  23408. logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
  23409. }
  23410. }
  23411. }
  23412. function markSchedulerSuspended(ms) {
  23413. {
  23414. mainThreadIdCounter++;
  23415. if (eventLog !== null) {
  23416. logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
  23417. }
  23418. }
  23419. }
  23420. function markSchedulerUnsuspended(ms) {
  23421. {
  23422. if (eventLog !== null) {
  23423. logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
  23424. }
  23425. }
  23426. }
  23427. /* eslint-disable no-var */
  23428. // Math.pow(2, 30) - 1
  23429. // 0b111111111111111111111111111111
  23430. var maxSigned31BitInt = 1073741823; // Times out immediately
  23431. var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out
  23432. var USER_BLOCKING_PRIORITY = 250;
  23433. var NORMAL_PRIORITY_TIMEOUT = 5000;
  23434. var LOW_PRIORITY_TIMEOUT = 10000; // Never times out
  23435. var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap
  23436. var taskQueue = [];
  23437. var timerQueue = []; // Incrementing id counter. Used to maintain insertion order.
  23438. var taskIdCounter = 1; // Pausing the scheduler is useful for debugging.
  23439. var currentTask = null;
  23440. var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy.
  23441. var isPerformingWork = false;
  23442. var isHostCallbackScheduled = false;
  23443. var isHostTimeoutScheduled = false;
  23444. function advanceTimers(currentTime) {
  23445. // Check for tasks that are no longer delayed and add them to the queue.
  23446. var timer = peek(timerQueue);
  23447. while (timer !== null) {
  23448. if (timer.callback === null) {
  23449. // Timer was cancelled.
  23450. pop(timerQueue);
  23451. } else if (timer.startTime <= currentTime) {
  23452. // Timer fired. Transfer to the task queue.
  23453. pop(timerQueue);
  23454. timer.sortIndex = timer.expirationTime;
  23455. push(taskQueue, timer);
  23456. {
  23457. markTaskStart(timer, currentTime);
  23458. timer.isQueued = true;
  23459. }
  23460. } else {
  23461. // Remaining timers are pending.
  23462. return;
  23463. }
  23464. timer = peek(timerQueue);
  23465. }
  23466. }
  23467. function handleTimeout(currentTime) {
  23468. isHostTimeoutScheduled = false;
  23469. advanceTimers(currentTime);
  23470. if (!isHostCallbackScheduled) {
  23471. if (peek(taskQueue) !== null) {
  23472. isHostCallbackScheduled = true;
  23473. requestHostCallback(flushWork);
  23474. } else {
  23475. var firstTimer = peek(timerQueue);
  23476. if (firstTimer !== null) {
  23477. requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
  23478. }
  23479. }
  23480. }
  23481. }
  23482. function flushWork(hasTimeRemaining, initialTime) {
  23483. {
  23484. markSchedulerUnsuspended(initialTime);
  23485. } // We'll need a host callback the next time work is scheduled.
  23486. isHostCallbackScheduled = false;
  23487. if (isHostTimeoutScheduled) {
  23488. // We scheduled a timeout but it's no longer needed. Cancel it.
  23489. isHostTimeoutScheduled = false;
  23490. cancelHostTimeout();
  23491. }
  23492. isPerformingWork = true;
  23493. var previousPriorityLevel = currentPriorityLevel;
  23494. try {
  23495. if (enableProfiling) {
  23496. try {
  23497. return workLoop(hasTimeRemaining, initialTime);
  23498. } catch (error) {
  23499. if (currentTask !== null) {
  23500. var currentTime = exports.unstable_now();
  23501. markTaskErrored(currentTask, currentTime);
  23502. currentTask.isQueued = false;
  23503. }
  23504. throw error;
  23505. }
  23506. } else {
  23507. // No catch in prod codepath.
  23508. return workLoop(hasTimeRemaining, initialTime);
  23509. }
  23510. } finally {
  23511. currentTask = null;
  23512. currentPriorityLevel = previousPriorityLevel;
  23513. isPerformingWork = false;
  23514. {
  23515. var _currentTime = exports.unstable_now();
  23516. markSchedulerSuspended(_currentTime);
  23517. }
  23518. }
  23519. }
  23520. function workLoop(hasTimeRemaining, initialTime) {
  23521. var currentTime = initialTime;
  23522. advanceTimers(currentTime);
  23523. currentTask = peek(taskQueue);
  23524. while (currentTask !== null && !(enableSchedulerDebugging )) {
  23525. if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {
  23526. // This currentTask hasn't expired, and we've reached the deadline.
  23527. break;
  23528. }
  23529. var callback = currentTask.callback;
  23530. if (callback !== null) {
  23531. currentTask.callback = null;
  23532. currentPriorityLevel = currentTask.priorityLevel;
  23533. var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
  23534. markTaskRun(currentTask, currentTime);
  23535. var continuationCallback = callback(didUserCallbackTimeout);
  23536. currentTime = exports.unstable_now();
  23537. if (typeof continuationCallback === 'function') {
  23538. currentTask.callback = continuationCallback;
  23539. markTaskYield(currentTask, currentTime);
  23540. } else {
  23541. {
  23542. markTaskCompleted(currentTask, currentTime);
  23543. currentTask.isQueued = false;
  23544. }
  23545. if (currentTask === peek(taskQueue)) {
  23546. pop(taskQueue);
  23547. }
  23548. }
  23549. advanceTimers(currentTime);
  23550. } else {
  23551. pop(taskQueue);
  23552. }
  23553. currentTask = peek(taskQueue);
  23554. } // Return whether there's additional work
  23555. if (currentTask !== null) {
  23556. return true;
  23557. } else {
  23558. var firstTimer = peek(timerQueue);
  23559. if (firstTimer !== null) {
  23560. requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
  23561. }
  23562. return false;
  23563. }
  23564. }
  23565. function unstable_runWithPriority(priorityLevel, eventHandler) {
  23566. switch (priorityLevel) {
  23567. case ImmediatePriority:
  23568. case UserBlockingPriority:
  23569. case NormalPriority:
  23570. case LowPriority:
  23571. case IdlePriority:
  23572. break;
  23573. default:
  23574. priorityLevel = NormalPriority;
  23575. }
  23576. var previousPriorityLevel = currentPriorityLevel;
  23577. currentPriorityLevel = priorityLevel;
  23578. try {
  23579. return eventHandler();
  23580. } finally {
  23581. currentPriorityLevel = previousPriorityLevel;
  23582. }
  23583. }
  23584. function unstable_next(eventHandler) {
  23585. var priorityLevel;
  23586. switch (currentPriorityLevel) {
  23587. case ImmediatePriority:
  23588. case UserBlockingPriority:
  23589. case NormalPriority:
  23590. // Shift down to normal priority
  23591. priorityLevel = NormalPriority;
  23592. break;
  23593. default:
  23594. // Anything lower than normal priority should remain at the current level.
  23595. priorityLevel = currentPriorityLevel;
  23596. break;
  23597. }
  23598. var previousPriorityLevel = currentPriorityLevel;
  23599. currentPriorityLevel = priorityLevel;
  23600. try {
  23601. return eventHandler();
  23602. } finally {
  23603. currentPriorityLevel = previousPriorityLevel;
  23604. }
  23605. }
  23606. function unstable_wrapCallback(callback) {
  23607. var parentPriorityLevel = currentPriorityLevel;
  23608. return function () {
  23609. // This is a fork of runWithPriority, inlined for performance.
  23610. var previousPriorityLevel = currentPriorityLevel;
  23611. currentPriorityLevel = parentPriorityLevel;
  23612. try {
  23613. return callback.apply(this, arguments);
  23614. } finally {
  23615. currentPriorityLevel = previousPriorityLevel;
  23616. }
  23617. };
  23618. }
  23619. function timeoutForPriorityLevel(priorityLevel) {
  23620. switch (priorityLevel) {
  23621. case ImmediatePriority:
  23622. return IMMEDIATE_PRIORITY_TIMEOUT;
  23623. case UserBlockingPriority:
  23624. return USER_BLOCKING_PRIORITY;
  23625. case IdlePriority:
  23626. return IDLE_PRIORITY;
  23627. case LowPriority:
  23628. return LOW_PRIORITY_TIMEOUT;
  23629. case NormalPriority:
  23630. default:
  23631. return NORMAL_PRIORITY_TIMEOUT;
  23632. }
  23633. }
  23634. function unstable_scheduleCallback(priorityLevel, callback, options) {
  23635. var currentTime = exports.unstable_now();
  23636. var startTime;
  23637. var timeout;
  23638. if (typeof options === 'object' && options !== null) {
  23639. var delay = options.delay;
  23640. if (typeof delay === 'number' && delay > 0) {
  23641. startTime = currentTime + delay;
  23642. } else {
  23643. startTime = currentTime;
  23644. }
  23645. timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel);
  23646. } else {
  23647. timeout = timeoutForPriorityLevel(priorityLevel);
  23648. startTime = currentTime;
  23649. }
  23650. var expirationTime = startTime + timeout;
  23651. var newTask = {
  23652. id: taskIdCounter++,
  23653. callback: callback,
  23654. priorityLevel: priorityLevel,
  23655. startTime: startTime,
  23656. expirationTime: expirationTime,
  23657. sortIndex: -1
  23658. };
  23659. {
  23660. newTask.isQueued = false;
  23661. }
  23662. if (startTime > currentTime) {
  23663. // This is a delayed task.
  23664. newTask.sortIndex = startTime;
  23665. push(timerQueue, newTask);
  23666. if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
  23667. // All tasks are delayed, and this is the task with the earliest delay.
  23668. if (isHostTimeoutScheduled) {
  23669. // Cancel an existing timeout.
  23670. cancelHostTimeout();
  23671. } else {
  23672. isHostTimeoutScheduled = true;
  23673. } // Schedule a timeout.
  23674. requestHostTimeout(handleTimeout, startTime - currentTime);
  23675. }
  23676. } else {
  23677. newTask.sortIndex = expirationTime;
  23678. push(taskQueue, newTask);
  23679. {
  23680. markTaskStart(newTask, currentTime);
  23681. newTask.isQueued = true;
  23682. } // Schedule a host callback, if needed. If we're already performing work,
  23683. // wait until the next time we yield.
  23684. if (!isHostCallbackScheduled && !isPerformingWork) {
  23685. isHostCallbackScheduled = true;
  23686. requestHostCallback(flushWork);
  23687. }
  23688. }
  23689. return newTask;
  23690. }
  23691. function unstable_pauseExecution() {
  23692. }
  23693. function unstable_continueExecution() {
  23694. if (!isHostCallbackScheduled && !isPerformingWork) {
  23695. isHostCallbackScheduled = true;
  23696. requestHostCallback(flushWork);
  23697. }
  23698. }
  23699. function unstable_getFirstCallbackNode() {
  23700. return peek(taskQueue);
  23701. }
  23702. function unstable_cancelCallback(task) {
  23703. {
  23704. if (task.isQueued) {
  23705. var currentTime = exports.unstable_now();
  23706. markTaskCanceled(task, currentTime);
  23707. task.isQueued = false;
  23708. }
  23709. } // Null out the callback to indicate the task has been canceled. (Can't
  23710. // remove from the queue because you can't remove arbitrary nodes from an
  23711. // array based heap, only the first one.)
  23712. task.callback = null;
  23713. }
  23714. function unstable_getCurrentPriorityLevel() {
  23715. return currentPriorityLevel;
  23716. }
  23717. function unstable_shouldYield() {
  23718. var currentTime = exports.unstable_now();
  23719. advanceTimers(currentTime);
  23720. var firstTask = peek(taskQueue);
  23721. return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost();
  23722. }
  23723. var unstable_requestPaint = requestPaint;
  23724. var unstable_Profiling = {
  23725. startLoggingProfilingEvents: startLoggingProfilingEvents,
  23726. stopLoggingProfilingEvents: stopLoggingProfilingEvents,
  23727. sharedProfilingBuffer: sharedProfilingBuffer
  23728. } ;
  23729. exports.unstable_IdlePriority = IdlePriority;
  23730. exports.unstable_ImmediatePriority = ImmediatePriority;
  23731. exports.unstable_LowPriority = LowPriority;
  23732. exports.unstable_NormalPriority = NormalPriority;
  23733. exports.unstable_Profiling = unstable_Profiling;
  23734. exports.unstable_UserBlockingPriority = UserBlockingPriority;
  23735. exports.unstable_cancelCallback = unstable_cancelCallback;
  23736. exports.unstable_continueExecution = unstable_continueExecution;
  23737. exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;
  23738. exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode;
  23739. exports.unstable_next = unstable_next;
  23740. exports.unstable_pauseExecution = unstable_pauseExecution;
  23741. exports.unstable_requestPaint = unstable_requestPaint;
  23742. exports.unstable_runWithPriority = unstable_runWithPriority;
  23743. exports.unstable_scheduleCallback = unstable_scheduleCallback;
  23744. exports.unstable_shouldYield = unstable_shouldYield;
  23745. exports.unstable_wrapCallback = unstable_wrapCallback;
  23746. })();
  23747. }
  23748. /***/ }),
  23749. /***/ "../../node_modules/scheduler/index.js":
  23750. /*!*****************************************************************!*\
  23751. !*** C:/Dev/Babylon/Babylon.js/node_modules/scheduler/index.js ***!
  23752. \*****************************************************************/
  23753. /*! no static exports found */
  23754. /***/ (function(module, exports, __webpack_require__) {
  23755. "use strict";
  23756. if (false) {} else {
  23757. module.exports = __webpack_require__(/*! ./cjs/scheduler.development.js */ "../../node_modules/scheduler/cjs/scheduler.development.js");
  23758. }
  23759. /***/ }),
  23760. /***/ "../../node_modules/scheduler/tracing.js":
  23761. /*!*******************************************************************!*\
  23762. !*** C:/Dev/Babylon/Babylon.js/node_modules/scheduler/tracing.js ***!
  23763. \*******************************************************************/
  23764. /*! no static exports found */
  23765. /***/ (function(module, exports, __webpack_require__) {
  23766. "use strict";
  23767. if (false) {} else {
  23768. module.exports = __webpack_require__(/*! ./cjs/scheduler-tracing.development.js */ "../../node_modules/scheduler/cjs/scheduler-tracing.development.js");
  23769. }
  23770. /***/ }),
  23771. /***/ "../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js":
  23772. /*!****************************************************************************************************!*\
  23773. !*** C:/Dev/Babylon/Babylon.js/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
  23774. \****************************************************************************************************/
  23775. /*! no static exports found */
  23776. /***/ (function(module, exports, __webpack_require__) {
  23777. "use strict";
  23778. var isOldIE = function isOldIE() {
  23779. var memo;
  23780. return function memorize() {
  23781. if (typeof memo === 'undefined') {
  23782. // Test for IE <= 9 as proposed by Browserhacks
  23783. // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
  23784. // Tests for existence of standard globals is to allow style-loader
  23785. // to operate correctly into non-standard environments
  23786. // @see https://github.com/webpack-contrib/style-loader/issues/177
  23787. memo = Boolean(window && document && document.all && !window.atob);
  23788. }
  23789. return memo;
  23790. };
  23791. }();
  23792. var getTarget = function getTarget() {
  23793. var memo = {};
  23794. return function memorize(target) {
  23795. if (typeof memo[target] === 'undefined') {
  23796. var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
  23797. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  23798. try {
  23799. // This will throw an exception if access to iframe is blocked
  23800. // due to cross-origin restrictions
  23801. styleTarget = styleTarget.contentDocument.head;
  23802. } catch (e) {
  23803. // istanbul ignore next
  23804. styleTarget = null;
  23805. }
  23806. }
  23807. memo[target] = styleTarget;
  23808. }
  23809. return memo[target];
  23810. };
  23811. }();
  23812. var stylesInDom = [];
  23813. function getIndexByIdentifier(identifier) {
  23814. var result = -1;
  23815. for (var i = 0; i < stylesInDom.length; i++) {
  23816. if (stylesInDom[i].identifier === identifier) {
  23817. result = i;
  23818. break;
  23819. }
  23820. }
  23821. return result;
  23822. }
  23823. function modulesToDom(list, options) {
  23824. var idCountMap = {};
  23825. var identifiers = [];
  23826. for (var i = 0; i < list.length; i++) {
  23827. var item = list[i];
  23828. var id = options.base ? item[0] + options.base : item[0];
  23829. var count = idCountMap[id] || 0;
  23830. var identifier = "".concat(id, " ").concat(count);
  23831. idCountMap[id] = count + 1;
  23832. var index = getIndexByIdentifier(identifier);
  23833. var obj = {
  23834. css: item[1],
  23835. media: item[2],
  23836. sourceMap: item[3]
  23837. };
  23838. if (index !== -1) {
  23839. stylesInDom[index].references++;
  23840. stylesInDom[index].updater(obj);
  23841. } else {
  23842. stylesInDom.push({
  23843. identifier: identifier,
  23844. updater: addStyle(obj, options),
  23845. references: 1
  23846. });
  23847. }
  23848. identifiers.push(identifier);
  23849. }
  23850. return identifiers;
  23851. }
  23852. function insertStyleElement(options) {
  23853. var style = document.createElement('style');
  23854. var attributes = options.attributes || {};
  23855. if (typeof attributes.nonce === 'undefined') {
  23856. var nonce = true ? __webpack_require__.nc : undefined;
  23857. if (nonce) {
  23858. attributes.nonce = nonce;
  23859. }
  23860. }
  23861. Object.keys(attributes).forEach(function (key) {
  23862. style.setAttribute(key, attributes[key]);
  23863. });
  23864. if (typeof options.insert === 'function') {
  23865. options.insert(style);
  23866. } else {
  23867. var target = getTarget(options.insert || 'head');
  23868. if (!target) {
  23869. throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
  23870. }
  23871. target.appendChild(style);
  23872. }
  23873. return style;
  23874. }
  23875. function removeStyleElement(style) {
  23876. // istanbul ignore if
  23877. if (style.parentNode === null) {
  23878. return false;
  23879. }
  23880. style.parentNode.removeChild(style);
  23881. }
  23882. /* istanbul ignore next */
  23883. var replaceText = function replaceText() {
  23884. var textStore = [];
  23885. return function replace(index, replacement) {
  23886. textStore[index] = replacement;
  23887. return textStore.filter(Boolean).join('\n');
  23888. };
  23889. }();
  23890. function applyToSingletonTag(style, index, remove, obj) {
  23891. var css = remove ? '' : obj.media ? "@media ".concat(obj.media, " {").concat(obj.css, "}") : obj.css; // For old IE
  23892. /* istanbul ignore if */
  23893. if (style.styleSheet) {
  23894. style.styleSheet.cssText = replaceText(index, css);
  23895. } else {
  23896. var cssNode = document.createTextNode(css);
  23897. var childNodes = style.childNodes;
  23898. if (childNodes[index]) {
  23899. style.removeChild(childNodes[index]);
  23900. }
  23901. if (childNodes.length) {
  23902. style.insertBefore(cssNode, childNodes[index]);
  23903. } else {
  23904. style.appendChild(cssNode);
  23905. }
  23906. }
  23907. }
  23908. function applyToTag(style, options, obj) {
  23909. var css = obj.css;
  23910. var media = obj.media;
  23911. var sourceMap = obj.sourceMap;
  23912. if (media) {
  23913. style.setAttribute('media', media);
  23914. } else {
  23915. style.removeAttribute('media');
  23916. }
  23917. if (sourceMap && btoa) {
  23918. css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
  23919. } // For old IE
  23920. /* istanbul ignore if */
  23921. if (style.styleSheet) {
  23922. style.styleSheet.cssText = css;
  23923. } else {
  23924. while (style.firstChild) {
  23925. style.removeChild(style.firstChild);
  23926. }
  23927. style.appendChild(document.createTextNode(css));
  23928. }
  23929. }
  23930. var singleton = null;
  23931. var singletonCounter = 0;
  23932. function addStyle(obj, options) {
  23933. var style;
  23934. var update;
  23935. var remove;
  23936. if (options.singleton) {
  23937. var styleIndex = singletonCounter++;
  23938. style = singleton || (singleton = insertStyleElement(options));
  23939. update = applyToSingletonTag.bind(null, style, styleIndex, false);
  23940. remove = applyToSingletonTag.bind(null, style, styleIndex, true);
  23941. } else {
  23942. style = insertStyleElement(options);
  23943. update = applyToTag.bind(null, style, options);
  23944. remove = function remove() {
  23945. removeStyleElement(style);
  23946. };
  23947. }
  23948. update(obj);
  23949. return function updateStyle(newObj) {
  23950. if (newObj) {
  23951. if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {
  23952. return;
  23953. }
  23954. update(obj = newObj);
  23955. } else {
  23956. remove();
  23957. }
  23958. };
  23959. }
  23960. module.exports = function (list, options) {
  23961. options = options || {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  23962. // tags it will allow on a page
  23963. if (!options.singleton && typeof options.singleton !== 'boolean') {
  23964. options.singleton = isOldIE();
  23965. }
  23966. list = list || [];
  23967. var lastIdentifiers = modulesToDom(list, options);
  23968. return function update(newList) {
  23969. newList = newList || [];
  23970. if (Object.prototype.toString.call(newList) !== '[object Array]') {
  23971. return;
  23972. }
  23973. for (var i = 0; i < lastIdentifiers.length; i++) {
  23974. var identifier = lastIdentifiers[i];
  23975. var index = getIndexByIdentifier(identifier);
  23976. stylesInDom[index].references--;
  23977. }
  23978. var newLastIdentifiers = modulesToDom(newList, options);
  23979. for (var _i = 0; _i < lastIdentifiers.length; _i++) {
  23980. var _identifier = lastIdentifiers[_i];
  23981. var _index = getIndexByIdentifier(_identifier);
  23982. if (stylesInDom[_index].references === 0) {
  23983. stylesInDom[_index].updater();
  23984. stylesInDom.splice(_index, 1);
  23985. }
  23986. }
  23987. lastIdentifiers = newLastIdentifiers;
  23988. };
  23989. };
  23990. /***/ }),
  23991. /***/ "../../node_modules/tslib/tslib.es6.js":
  23992. /*!*****************************************************************!*\
  23993. !*** C:/Dev/Babylon/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  23994. \*****************************************************************/
  23995. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet */
  23996. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23997. "use strict";
  23998. __webpack_require__.r(__webpack_exports__);
  23999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  24000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  24001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  24002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  24003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  24004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  24005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  24006. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  24007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__createBinding", function() { return __createBinding; });
  24008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  24009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  24010. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  24011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  24012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  24013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  24014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  24015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  24016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  24017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  24018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  24019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  24020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
  24021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
  24022. /*! *****************************************************************************
  24023. Copyright (c) Microsoft Corporation.
  24024. Permission to use, copy, modify, and/or distribute this software for any
  24025. purpose with or without fee is hereby granted.
  24026. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  24027. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  24028. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  24029. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  24030. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  24031. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  24032. PERFORMANCE OF THIS SOFTWARE.
  24033. ***************************************************************************** */
  24034. /* global Reflect, Promise */
  24035. var extendStatics = function(d, b) {
  24036. extendStatics = Object.setPrototypeOf ||
  24037. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  24038. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  24039. return extendStatics(d, b);
  24040. };
  24041. function __extends(d, b) {
  24042. extendStatics(d, b);
  24043. function __() { this.constructor = d; }
  24044. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24045. }
  24046. var __assign = function() {
  24047. __assign = Object.assign || function __assign(t) {
  24048. for (var s, i = 1, n = arguments.length; i < n; i++) {
  24049. s = arguments[i];
  24050. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  24051. }
  24052. return t;
  24053. }
  24054. return __assign.apply(this, arguments);
  24055. }
  24056. function __rest(s, e) {
  24057. var t = {};
  24058. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  24059. t[p] = s[p];
  24060. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  24061. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  24062. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  24063. t[p[i]] = s[p[i]];
  24064. }
  24065. return t;
  24066. }
  24067. function __decorate(decorators, target, key, desc) {
  24068. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  24069. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  24070. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  24071. return c > 3 && r && Object.defineProperty(target, key, r), r;
  24072. }
  24073. function __param(paramIndex, decorator) {
  24074. return function (target, key) { decorator(target, key, paramIndex); }
  24075. }
  24076. function __metadata(metadataKey, metadataValue) {
  24077. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  24078. }
  24079. function __awaiter(thisArg, _arguments, P, generator) {
  24080. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  24081. return new (P || (P = Promise))(function (resolve, reject) {
  24082. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  24083. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  24084. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  24085. step((generator = generator.apply(thisArg, _arguments || [])).next());
  24086. });
  24087. }
  24088. function __generator(thisArg, body) {
  24089. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  24090. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  24091. function verb(n) { return function (v) { return step([n, v]); }; }
  24092. function step(op) {
  24093. if (f) throw new TypeError("Generator is already executing.");
  24094. while (_) try {
  24095. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  24096. if (y = 0, t) op = [op[0] & 2, t.value];
  24097. switch (op[0]) {
  24098. case 0: case 1: t = op; break;
  24099. case 4: _.label++; return { value: op[1], done: false };
  24100. case 5: _.label++; y = op[1]; op = [0]; continue;
  24101. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  24102. default:
  24103. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  24104. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  24105. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  24106. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  24107. if (t[2]) _.ops.pop();
  24108. _.trys.pop(); continue;
  24109. }
  24110. op = body.call(thisArg, _);
  24111. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  24112. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  24113. }
  24114. }
  24115. var __createBinding = Object.create ? (function(o, m, k, k2) {
  24116. if (k2 === undefined) k2 = k;
  24117. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  24118. }) : (function(o, m, k, k2) {
  24119. if (k2 === undefined) k2 = k;
  24120. o[k2] = m[k];
  24121. });
  24122. function __exportStar(m, exports) {
  24123. for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
  24124. }
  24125. function __values(o) {
  24126. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  24127. if (m) return m.call(o);
  24128. if (o && typeof o.length === "number") return {
  24129. next: function () {
  24130. if (o && i >= o.length) o = void 0;
  24131. return { value: o && o[i++], done: !o };
  24132. }
  24133. };
  24134. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  24135. }
  24136. function __read(o, n) {
  24137. var m = typeof Symbol === "function" && o[Symbol.iterator];
  24138. if (!m) return o;
  24139. var i = m.call(o), r, ar = [], e;
  24140. try {
  24141. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  24142. }
  24143. catch (error) { e = { error: error }; }
  24144. finally {
  24145. try {
  24146. if (r && !r.done && (m = i["return"])) m.call(i);
  24147. }
  24148. finally { if (e) throw e.error; }
  24149. }
  24150. return ar;
  24151. }
  24152. function __spread() {
  24153. for (var ar = [], i = 0; i < arguments.length; i++)
  24154. ar = ar.concat(__read(arguments[i]));
  24155. return ar;
  24156. }
  24157. function __spreadArrays() {
  24158. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  24159. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  24160. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  24161. r[k] = a[j];
  24162. return r;
  24163. };
  24164. function __await(v) {
  24165. return this instanceof __await ? (this.v = v, this) : new __await(v);
  24166. }
  24167. function __asyncGenerator(thisArg, _arguments, generator) {
  24168. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  24169. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  24170. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  24171. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  24172. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  24173. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  24174. function fulfill(value) { resume("next", value); }
  24175. function reject(value) { resume("throw", value); }
  24176. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  24177. }
  24178. function __asyncDelegator(o) {
  24179. var i, p;
  24180. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  24181. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  24182. }
  24183. function __asyncValues(o) {
  24184. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  24185. var m = o[Symbol.asyncIterator], i;
  24186. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  24187. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  24188. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  24189. }
  24190. function __makeTemplateObject(cooked, raw) {
  24191. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  24192. return cooked;
  24193. };
  24194. var __setModuleDefault = Object.create ? (function(o, v) {
  24195. Object.defineProperty(o, "default", { enumerable: true, value: v });
  24196. }) : function(o, v) {
  24197. o["default"] = v;
  24198. };
  24199. function __importStar(mod) {
  24200. if (mod && mod.__esModule) return mod;
  24201. var result = {};
  24202. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  24203. __setModuleDefault(result, mod);
  24204. return result;
  24205. }
  24206. function __importDefault(mod) {
  24207. return (mod && mod.__esModule) ? mod : { default: mod };
  24208. }
  24209. function __classPrivateFieldGet(receiver, privateMap) {
  24210. if (!privateMap.has(receiver)) {
  24211. throw new TypeError("attempted to get private field on non-instance");
  24212. }
  24213. return privateMap.get(receiver);
  24214. }
  24215. function __classPrivateFieldSet(receiver, privateMap, value) {
  24216. if (!privateMap.has(receiver)) {
  24217. throw new TypeError("attempted to set private field on non-instance");
  24218. }
  24219. privateMap.set(receiver, value);
  24220. return value;
  24221. }
  24222. /***/ }),
  24223. /***/ "../../node_modules/webpack/buildin/global.js":
  24224. /*!***********************************!*\
  24225. !*** (webpack)/buildin/global.js ***!
  24226. \***********************************/
  24227. /*! no static exports found */
  24228. /***/ (function(module, exports) {
  24229. var g;
  24230. // This works in non-strict mode
  24231. g = (function() {
  24232. return this;
  24233. })();
  24234. try {
  24235. // This works if eval is allowed (see CSP)
  24236. g = g || new Function("return this")();
  24237. } catch (e) {
  24238. // This works if the window reference is available
  24239. if (typeof window === "object") g = window;
  24240. }
  24241. // g can still be undefined, but nothing to do about it...
  24242. // We return undefined, instead of nothing here, so it's
  24243. // easier to handle this case. if(!global) { ...}
  24244. module.exports = g;
  24245. /***/ }),
  24246. /***/ "./components/animationBar.tsx":
  24247. /*!*************************************!*\
  24248. !*** ./components/animationBar.tsx ***!
  24249. \*************************************/
  24250. /*! exports provided: AnimationBar */
  24251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24252. "use strict";
  24253. __webpack_require__.r(__webpack_exports__);
  24254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationBar", function() { return AnimationBar; });
  24255. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  24256. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  24257. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  24258. /* harmony import */ var _dropUpButton__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dropUpButton */ "./components/dropUpButton.tsx");
  24259. var iconPlay = __webpack_require__(/*! ../img/icon-play.svg */ "./img/icon-play.svg");
  24260. var iconPause = __webpack_require__(/*! ../img/icon-pause.svg */ "./img/icon-pause.svg");
  24261. __webpack_require__(/*! ../scss/animationBar.scss */ "./scss/animationBar.scss");
  24262. var AnimationBar = /** @class */ (function (_super) {
  24263. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AnimationBar, _super);
  24264. function AnimationBar(props) {
  24265. var _this = _super.call(this, props) || this;
  24266. _this._sliderRef = react__WEBPACK_IMPORTED_MODULE_1__["createRef"]();
  24267. _this.state = { groupIndex: 0 };
  24268. props.globalState.onSceneLoaded.add(function (info) {
  24269. _this.registerBeforeRender(info.scene);
  24270. });
  24271. if (_this.props.globalState.currentScene) {
  24272. _this.registerBeforeRender(_this.props.globalState.currentScene);
  24273. }
  24274. return _this;
  24275. }
  24276. AnimationBar.prototype.getCurrentPosition = function () {
  24277. if (!this._currentGroup) {
  24278. return "0";
  24279. }
  24280. var targetedAnimations = this._currentGroup.targetedAnimations;
  24281. if (targetedAnimations.length > 0) {
  24282. var runtimeAnimations = this._currentGroup.targetedAnimations[0].animation.runtimeAnimations;
  24283. if (runtimeAnimations.length > 0) {
  24284. return runtimeAnimations[0].currentFrame.toString();
  24285. }
  24286. }
  24287. return "0";
  24288. };
  24289. AnimationBar.prototype.registerBeforeRender = function (newScene) {
  24290. var _this = this;
  24291. if (this._currentScene) {
  24292. this._currentScene.onBeforeRenderObservable.remove(this._sliderSyncObserver);
  24293. }
  24294. this._currentScene = newScene;
  24295. this._sliderSyncObserver = this._currentScene.onBeforeRenderObservable.add(function () {
  24296. if (_this._currentGroup && _this._sliderRef.current) {
  24297. _this._sliderRef.current.value = _this.getCurrentPosition();
  24298. if (_this._currentPlayingState !== _this._currentGroup.isPlaying) {
  24299. _this.forceUpdate();
  24300. }
  24301. }
  24302. });
  24303. };
  24304. AnimationBar.prototype.pause = function () {
  24305. if (!this._currentGroup) {
  24306. return;
  24307. }
  24308. this._currentGroup.pause();
  24309. this.forceUpdate();
  24310. };
  24311. AnimationBar.prototype.play = function () {
  24312. if (!this._currentGroup) {
  24313. return;
  24314. }
  24315. this._currentGroup.play();
  24316. this.forceUpdate();
  24317. };
  24318. AnimationBar.prototype.sliderInput = function (evt) {
  24319. if (!this._currentGroup) {
  24320. return;
  24321. }
  24322. var value = parseFloat(evt.target.value);
  24323. if (!this._currentGroup.isPlaying) {
  24324. this._currentGroup.play(true);
  24325. this._currentGroup.goToFrame(value);
  24326. this._currentGroup.pause();
  24327. }
  24328. else {
  24329. this._currentGroup.goToFrame(value);
  24330. }
  24331. };
  24332. AnimationBar.prototype.render = function () {
  24333. var _this = this;
  24334. if (!this.props.enabled) {
  24335. this._currentGroup = null;
  24336. return null;
  24337. }
  24338. var scene = this.props.globalState.currentScene;
  24339. if (scene.animationGroups.length === 0) {
  24340. this._currentGroup = null;
  24341. return null;
  24342. }
  24343. var groupNames = scene.animationGroups.map(function (g) { return g.name; });
  24344. this._currentGroup = scene.animationGroups[this.state.groupIndex];
  24345. this._currentPlayingState = this._currentGroup.isPlaying;
  24346. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "animationBar" },
  24347. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "row" },
  24348. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("button", { id: "playBtn" },
  24349. this._currentGroup.isPlaying &&
  24350. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { id: "pauseImg", src: iconPause, onClick: function () { return _this.pause(); } }),
  24351. !this._currentGroup.isPlaying &&
  24352. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { id: "playImg", src: iconPlay, onClick: function () { return _this.play(); } })),
  24353. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("input", { ref: this._sliderRef, className: "slider", type: "range", onInput: function (evt) { return _this.sliderInput(evt); }, min: this._currentGroup.from, max: this._currentGroup.to, onChange: function () { }, value: this.getCurrentPosition(), step: "any" })),
  24354. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_dropUpButton__WEBPACK_IMPORTED_MODULE_2__["DropUpButton"], { globalState: this.props.globalState, label: "Active animation group", options: groupNames, selectedOption: this._currentGroup.name, onOptionPicked: function (option) {
  24355. _this._currentGroup.stop();
  24356. var newIndex = groupNames.indexOf(option);
  24357. _this.setState({ groupIndex: newIndex });
  24358. scene.animationGroups[newIndex].play(true);
  24359. }, enabled: true })));
  24360. };
  24361. return AnimationBar;
  24362. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  24363. /***/ }),
  24364. /***/ "./components/dropUpButton.tsx":
  24365. /*!*************************************!*\
  24366. !*** ./components/dropUpButton.tsx ***!
  24367. \*************************************/
  24368. /*! exports provided: DropUpButton */
  24369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24370. "use strict";
  24371. __webpack_require__.r(__webpack_exports__);
  24372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DropUpButton", function() { return DropUpButton; });
  24373. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  24374. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  24375. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  24376. var iconUp = __webpack_require__(/*! ../img/icon-up.svg */ "./img/icon-up.svg");
  24377. var iconDown = __webpack_require__(/*! ../img/icon-down.svg */ "./img/icon-down.svg");
  24378. var DropUpButton = /** @class */ (function (_super) {
  24379. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DropUpButton, _super);
  24380. function DropUpButton(props) {
  24381. var _this = _super.call(this, props) || this;
  24382. _this.state = { isOpen: false };
  24383. _this._onClickInterceptorClickedObserver = props.globalState.onClickInterceptorClicked.add(function () {
  24384. _this.setState({ isOpen: false });
  24385. });
  24386. return _this;
  24387. }
  24388. DropUpButton.prototype.componentWillUnmount = function () {
  24389. this.props.globalState.onClickInterceptorClicked.remove(this._onClickInterceptorClickedObserver);
  24390. };
  24391. DropUpButton.prototype.switchDropUp = function () {
  24392. this.props.globalState.onRequestClickInterceptor.notifyObservers();
  24393. this.setState({ isOpen: !this.state.isOpen });
  24394. };
  24395. DropUpButton.prototype.clickOption = function (option) {
  24396. this.switchDropUp();
  24397. this.props.onOptionPicked(option);
  24398. };
  24399. DropUpButton.prototype.render = function () {
  24400. var _this = this;
  24401. if (!this.props.enabled) {
  24402. return null;
  24403. }
  24404. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "dropup" },
  24405. this.props.icon &&
  24406. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "button" + (this.state.isOpen ? " active" : ""), onClick: function () { return _this.switchDropUp(); } },
  24407. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { src: this.props.icon, alt: this.props.label, title: this.props.label })),
  24408. this.props.selectedOption &&
  24409. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "button long" + (this.state.isOpen ? " active" : ""), onClick: function () { return _this.switchDropUp(); } },
  24410. this.state.isOpen &&
  24411. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { className: "button-icon", src: iconDown, alt: "Close the list", title: "Close the list" }),
  24412. !this.state.isOpen &&
  24413. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { className: "button-icon", src: iconUp, alt: "Open the list", title: "Open the list" }),
  24414. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "button-text", title: this.props.selectedOption }, this.props.selectedOption)),
  24415. this.state.isOpen &&
  24416. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "dropup-content" + (this.props.selectedOption ? " long-mode" : "") }, this.props.options.map(function (o) {
  24417. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { key: o, onClick: function () { return _this.clickOption(o); } }, o));
  24418. }))));
  24419. };
  24420. return DropUpButton;
  24421. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  24422. /***/ }),
  24423. /***/ "./components/footer.tsx":
  24424. /*!*******************************!*\
  24425. !*** ./components/footer.tsx ***!
  24426. \*******************************/
  24427. /*! exports provided: Footer */
  24428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24429. "use strict";
  24430. __webpack_require__.r(__webpack_exports__);
  24431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Footer", function() { return Footer; });
  24432. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  24433. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  24434. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  24435. /* harmony import */ var _footerButton__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./footerButton */ "./components/footerButton.tsx");
  24436. /* harmony import */ var _dropUpButton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dropUpButton */ "./components/dropUpButton.tsx");
  24437. /* harmony import */ var _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../tools/environmentTools */ "./tools/environmentTools.ts");
  24438. /* harmony import */ var _footerFileButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./footerFileButton */ "./components/footerFileButton.tsx");
  24439. /* harmony import */ var _animationBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationBar */ "./components/animationBar.tsx");
  24440. __webpack_require__(/*! ../scss/footer.scss */ "./scss/footer.scss");
  24441. var babylonIdentity = __webpack_require__(/*! ../img/babylon-identity.svg */ "./img/babylon-identity.svg");
  24442. var iconEdit = __webpack_require__(/*! ../img/icon-edit.svg */ "./img/icon-edit.svg");
  24443. var iconOpen = __webpack_require__(/*! ../img/icon-open.svg */ "./img/icon-open.svg");
  24444. var iconIBL = __webpack_require__(/*! ../img/icon-ibl.svg */ "./img/icon-ibl.svg");
  24445. var Footer = /** @class */ (function (_super) {
  24446. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Footer, _super);
  24447. function Footer(props) {
  24448. var _this = _super.call(this, props) || this;
  24449. props.globalState.onSceneLoaded.add(function (info) {
  24450. _this.forceUpdate();
  24451. });
  24452. return _this;
  24453. }
  24454. Footer.prototype.showInspector = function () {
  24455. if (this.props.globalState.currentScene) {
  24456. if (this.props.globalState.currentScene.debugLayer.isVisible()) {
  24457. this.props.globalState.hideDebugLayer();
  24458. }
  24459. else {
  24460. this.props.globalState.showDebugLayer();
  24461. }
  24462. }
  24463. };
  24464. Footer.prototype.render = function () {
  24465. var _this = this;
  24466. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { id: "footer", className: "footer" },
  24467. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "footerLeft" },
  24468. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { id: "logoImg", src: babylonIdentity })),
  24469. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_animationBar__WEBPACK_IMPORTED_MODULE_6__["AnimationBar"], { globalState: this.props.globalState, enabled: !!this.props.globalState.currentScene }),
  24470. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "footerRight" },
  24471. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_footerFileButton__WEBPACK_IMPORTED_MODULE_5__["FooterFileButton"], { globalState: this.props.globalState, enabled: true, icon: iconOpen, onFilesPicked: function (evt, files) {
  24472. _this.props.globalState.filesInput.loadFiles(evt);
  24473. }, label: "Open your scene from your hard drive (.babylon, .gltf, .glb, .obj)" }),
  24474. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_dropUpButton__WEBPACK_IMPORTED_MODULE_3__["DropUpButton"], { globalState: this.props.globalState, icon: iconIBL, label: "Select environment", options: _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__["EnvironmentTools"].SkyboxesNames, onOptionPicked: function (option) { return _this.props.globalState.onEnvironmentChanged.notifyObservers(option); }, enabled: !!this.props.globalState.currentScene }),
  24475. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_footerButton__WEBPACK_IMPORTED_MODULE_2__["FooterButton"], { globalState: this.props.globalState, icon: iconEdit, label: "Display inspector", onClick: function () { return _this.showInspector(); }, enabled: !!this.props.globalState.currentScene }))));
  24476. };
  24477. return Footer;
  24478. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  24479. /***/ }),
  24480. /***/ "./components/footerButton.tsx":
  24481. /*!*************************************!*\
  24482. !*** ./components/footerButton.tsx ***!
  24483. \*************************************/
  24484. /*! exports provided: FooterButton */
  24485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24486. "use strict";
  24487. __webpack_require__.r(__webpack_exports__);
  24488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FooterButton", function() { return FooterButton; });
  24489. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  24490. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  24491. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  24492. var FooterButton = /** @class */ (function (_super) {
  24493. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FooterButton, _super);
  24494. function FooterButton() {
  24495. return _super !== null && _super.apply(this, arguments) || this;
  24496. }
  24497. FooterButton.prototype.render = function () {
  24498. var _this = this;
  24499. if (!this.props.enabled) {
  24500. return null;
  24501. }
  24502. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "button", onClick: function () { return _this.props.onClick(); } },
  24503. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { src: this.props.icon, alt: this.props.label, title: this.props.label })));
  24504. };
  24505. return FooterButton;
  24506. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  24507. /***/ }),
  24508. /***/ "./components/footerFileButton.tsx":
  24509. /*!*****************************************!*\
  24510. !*** ./components/footerFileButton.tsx ***!
  24511. \*****************************************/
  24512. /*! exports provided: FooterFileButton */
  24513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24514. "use strict";
  24515. __webpack_require__.r(__webpack_exports__);
  24516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FooterFileButton", function() { return FooterFileButton; });
  24517. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  24518. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  24519. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  24520. var FooterFileButton = /** @class */ (function (_super) {
  24521. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FooterFileButton, _super);
  24522. function FooterFileButton() {
  24523. return _super !== null && _super.apply(this, arguments) || this;
  24524. }
  24525. FooterFileButton.prototype.onFilePicked = function (evt) {
  24526. this.props.onFilesPicked(evt.nativeEvent, evt.target.files);
  24527. };
  24528. FooterFileButton.prototype.render = function () {
  24529. var _this = this;
  24530. if (!this.props.enabled) {
  24531. return null;
  24532. }
  24533. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "custom-upload", title: this.props.label },
  24534. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { src: this.props.icon }),
  24535. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("input", { type: "file", id: "files", multiple: true, onChange: function (evt) { return _this.onFilePicked(evt); } })));
  24536. };
  24537. return FooterFileButton;
  24538. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  24539. /***/ }),
  24540. /***/ "./components/renderingZone.tsx":
  24541. /*!**************************************!*\
  24542. !*** ./components/renderingZone.tsx ***!
  24543. \**************************************/
  24544. /*! exports provided: RenderingZone */
  24545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24546. "use strict";
  24547. __webpack_require__.r(__webpack_exports__);
  24548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingZone", function() { return RenderingZone; });
  24549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  24550. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  24551. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  24552. /* harmony import */ var babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Engines/engine */ "babylonjs/Maths/math.vector");
  24553. /* harmony import */ var babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__);
  24554. /* harmony import */ var babylonjs_loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs-loaders/glTF/glTFFileLoader */ "babylonjs-loaders/glTF/glTFFileLoader");
  24555. /* harmony import */ var babylonjs_loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__);
  24556. /* harmony import */ var _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../tools/environmentTools */ "./tools/environmentTools.ts");
  24557. __webpack_require__(/*! ../scss/renderingZone.scss */ "./scss/renderingZone.scss");
  24558. var RenderingZone = /** @class */ (function (_super) {
  24559. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RenderingZone, _super);
  24560. function RenderingZone(props) {
  24561. return _super.call(this, props) || this;
  24562. }
  24563. RenderingZone.prototype.initEngine = function () {
  24564. var _this = this;
  24565. this._canvas = document.getElementById("renderCanvas");
  24566. this._engine = new babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"](this._canvas, true, { premultipliedAlpha: false, preserveDrawingBuffer: true });
  24567. this._engine.loadingUIBackgroundColor = "#2A2342";
  24568. // Resize
  24569. window.addEventListener("resize", function () {
  24570. _this._engine.resize();
  24571. });
  24572. this.loadAsset();
  24573. // File inputs
  24574. var filesInput = new babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["FilesInput"](this._engine, null, function (sceneFile, scene) {
  24575. _this._scene = scene;
  24576. _this.onSceneLoaded(sceneFile.name);
  24577. }, null, null, null, function () {
  24578. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Tools"].ClearLogCache();
  24579. if (_this._scene) {
  24580. _this.props.globalState.isDebugLayerEnabled = _this.props.globalState.currentScene.debugLayer.isVisible();
  24581. if (_this.props.globalState.isDebugLayerEnabled) {
  24582. _this._scene.debugLayer.hide();
  24583. }
  24584. }
  24585. }, null, null);
  24586. filesInput.onProcessFileCallback = function (file, name, extension) {
  24587. if (filesInput.filesToLoad && filesInput.filesToLoad.length === 1 && extension) {
  24588. if (extension.toLowerCase() === "dds" ||
  24589. extension.toLowerCase() === "env" ||
  24590. extension.toLowerCase() === "hdr") {
  24591. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["FilesInput"].FilesToLoad[name] = file;
  24592. _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__["EnvironmentTools"].SkyboxPath = "file:" + file.correctName;
  24593. return false;
  24594. }
  24595. }
  24596. return true;
  24597. };
  24598. filesInput.monitorElementForDragNDrop(this._canvas);
  24599. this.props.globalState.filesInput = filesInput;
  24600. };
  24601. RenderingZone.prototype.prepareCamera = function () {
  24602. var camera;
  24603. // Attach camera to canvas inputs
  24604. if (!this._scene.activeCamera || this._scene.lights.length === 0) {
  24605. this._scene.createDefaultCamera(true);
  24606. camera = this._scene.activeCamera;
  24607. if (this.props.cameraPosition) {
  24608. camera.setPosition(this.props.cameraPosition);
  24609. }
  24610. else {
  24611. if (this._currentPluginName === "gltf") {
  24612. // glTF assets use a +Z forward convention while the default camera faces +Z. Rotate the camera to look at the front of the asset.
  24613. camera.alpha += Math.PI;
  24614. }
  24615. // Enable camera's behaviors
  24616. camera.useFramingBehavior = true;
  24617. var framingBehavior = camera.getBehaviorByName("Framing");
  24618. framingBehavior.framingTime = 0;
  24619. framingBehavior.elevationReturnTime = -1;
  24620. if (this._scene.meshes.length) {
  24621. camera.lowerRadiusLimit = null;
  24622. var worldExtends = this._scene.getWorldExtends(function (mesh) {
  24623. return mesh.isVisible && mesh.isEnabled();
  24624. });
  24625. framingBehavior.zoomOnBoundingInfo(worldExtends.min, worldExtends.max);
  24626. }
  24627. }
  24628. camera.pinchPrecision = 200 / camera.radius;
  24629. camera.upperRadiusLimit = 5 * camera.radius;
  24630. camera.wheelDeltaPercentage = 0.01;
  24631. camera.pinchDeltaPercentage = 0.01;
  24632. }
  24633. this._scene.activeCamera.attachControl(this._canvas);
  24634. };
  24635. RenderingZone.prototype.handleErrors = function () {
  24636. // In case of error during loading, meshes will be empty and clearColor is set to red
  24637. if (this._scene.meshes.length === 0 && this._scene.clearColor.r === 1 && this._scene.clearColor.g === 0 && this._scene.clearColor.b === 0) {
  24638. this._canvas.style.opacity = "0";
  24639. this.props.globalState.onError.notifyObservers({ scene: this._scene, message: "No mesh found in your scene" });
  24640. }
  24641. else {
  24642. if (babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Tools"].errorsCount > 0) {
  24643. this.props.globalState.onError.notifyObservers({ scene: this._scene, message: "Scene loaded but several errors were found" });
  24644. }
  24645. // this._canvas.style.opacity = "1";
  24646. var camera = this._scene.activeCamera;
  24647. if (camera.keysUp) {
  24648. camera.keysUp.push(90); // Z
  24649. camera.keysUp.push(87); // W
  24650. camera.keysDown.push(83); // S
  24651. camera.keysLeft.push(65); // A
  24652. camera.keysLeft.push(81); // Q
  24653. camera.keysRight.push(69); // E
  24654. camera.keysRight.push(68); // D
  24655. }
  24656. }
  24657. };
  24658. RenderingZone.prototype.prepareLighting = function () {
  24659. if (this._currentPluginName === "gltf") {
  24660. if (!this._scene.environmentTexture) {
  24661. this._scene.environmentTexture = _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__["EnvironmentTools"].LoadSkyboxPathTexture(this._scene);
  24662. }
  24663. if (this._scene.environmentTexture) {
  24664. this._scene.createDefaultSkybox(this._scene.environmentTexture, true, (this._scene.activeCamera.maxZ - this._scene.activeCamera.minZ) / 2, 0.3, false);
  24665. }
  24666. }
  24667. else {
  24668. var pbrPresent = false;
  24669. for (var i = 0; i < this._scene.materials.length; i++) {
  24670. if (this._scene.materials[i].transparencyMode !== undefined) {
  24671. pbrPresent = true;
  24672. break;
  24673. }
  24674. }
  24675. if (pbrPresent) {
  24676. if (!this._scene.environmentTexture) {
  24677. this._scene.environmentTexture = _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__["EnvironmentTools"].LoadSkyboxPathTexture(this._scene);
  24678. }
  24679. }
  24680. else {
  24681. this._scene.createDefaultLight();
  24682. }
  24683. }
  24684. };
  24685. RenderingZone.prototype.onSceneLoaded = function (filename) {
  24686. this._engine.clearInternalTexturesCache();
  24687. this._scene.skipFrustumClipping = true;
  24688. this.props.globalState.onSceneLoaded.notifyObservers({ scene: this._scene, filename: filename });
  24689. this.prepareCamera();
  24690. this.prepareLighting();
  24691. this.handleErrors();
  24692. if (this.props.globalState.isDebugLayerEnabled) {
  24693. this.props.globalState.showDebugLayer();
  24694. }
  24695. };
  24696. RenderingZone.prototype.loadAssetFromUrl = function () {
  24697. var _this = this;
  24698. var assetUrl = this.props.assetUrl;
  24699. var rootUrl = babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetFolderPath(assetUrl);
  24700. var fileName = babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetFilename(assetUrl);
  24701. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].LoadAsync(rootUrl, fileName, this._engine).then(function (scene) {
  24702. if (_this._scene) {
  24703. _this._scene.dispose();
  24704. }
  24705. _this._scene = scene;
  24706. _this.onSceneLoaded(fileName);
  24707. scene.whenReadyAsync().then(function () {
  24708. _this._engine.runRenderLoop(function () {
  24709. scene.render();
  24710. });
  24711. });
  24712. }).catch(function (reason) {
  24713. _this.props.globalState.onError.notifyObservers({ message: reason.message });
  24714. //TODO sceneError({ name: fileName }, null, reason.message || reason);
  24715. });
  24716. };
  24717. RenderingZone.prototype.loadAsset = function () {
  24718. if (this.props.assetUrl) {
  24719. this.loadAssetFromUrl();
  24720. return;
  24721. }
  24722. };
  24723. RenderingZone.prototype.componentDidMount = function () {
  24724. var _this = this;
  24725. if (!babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].isSupported()) {
  24726. return;
  24727. }
  24728. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].ShadersRepository = "/src/Shaders/";
  24729. // This is really important to tell Babylon.js to use decomposeLerp and matrix interpolation
  24730. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Animation"].AllowMatricesInterpolation = true;
  24731. // Setting up some GLTF values
  24732. babylonjs_loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__["GLTFFileLoader"].IncrementalLoading = false;
  24733. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].OnPluginActivatedObservable.add(function (plugin) {
  24734. _this._currentPluginName = plugin.name;
  24735. if (_this._currentPluginName === "gltf") {
  24736. plugin.onValidatedObservable.add(function (results) {
  24737. if (results.issues.numErrors > 0) {
  24738. _this.props.globalState.showDebugLayer();
  24739. }
  24740. });
  24741. }
  24742. });
  24743. this.initEngine();
  24744. };
  24745. RenderingZone.prototype.shouldComponentUpdate = function (nextProps) {
  24746. var _this = this;
  24747. if (nextProps.expanded !== this.props.expanded) {
  24748. setTimeout(function () { return _this._engine.resize(); });
  24749. return true;
  24750. }
  24751. return false;
  24752. };
  24753. RenderingZone.prototype.render = function () {
  24754. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { id: "canvasZone", className: this.props.expanded ? "expanded" : "" },
  24755. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("canvas", { id: "renderCanvas", "touch-action": "none", onContextMenu: function (evt) { return evt.preventDefault(); } })));
  24756. };
  24757. return RenderingZone;
  24758. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  24759. /***/ }),
  24760. /***/ "./globalState.ts":
  24761. /*!************************!*\
  24762. !*** ./globalState.ts ***!
  24763. \************************/
  24764. /*! exports provided: GlobalState */
  24765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24766. "use strict";
  24767. __webpack_require__.r(__webpack_exports__);
  24768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlobalState", function() { return GlobalState; });
  24769. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  24770. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  24771. var GlobalState = /** @class */ (function () {
  24772. function GlobalState() {
  24773. this.onSceneLoaded = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  24774. this.onError = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  24775. this.onEnvironmentChanged = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  24776. this.onRequestClickInterceptor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  24777. this.onClickInterceptorClicked = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  24778. this.isDebugLayerEnabled = false;
  24779. }
  24780. GlobalState.prototype.showDebugLayer = function () {
  24781. this.isDebugLayerEnabled = true;
  24782. if (this.currentScene) {
  24783. this.currentScene.debugLayer.show();
  24784. }
  24785. };
  24786. GlobalState.prototype.hideDebugLayer = function () {
  24787. this.isDebugLayerEnabled = false;
  24788. if (this.currentScene) {
  24789. this.currentScene.debugLayer.hide();
  24790. }
  24791. };
  24792. return GlobalState;
  24793. }());
  24794. /***/ }),
  24795. /***/ "./img/babylon-identity.svg":
  24796. /*!**********************************!*\
  24797. !*** ./img/babylon-identity.svg ***!
  24798. \**********************************/
  24799. /*! no static exports found */
  24800. /***/ (function(module, exports) {
  24801. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160.63 40.18'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23d5d2ca;%7D.cls-2%7Bfill:%23fff;%7D.cls-3%7Bfill:%23e0684b;%7D.cls-4%7Bfill:%23bb464b;%7D.cls-5%7Bfill:%23e0ded8;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EBabylonIdentity%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Page_Elements' data-name='Page Elements'%3E%3Cpath class='cls-1' d='M41.27,10h3.41v7.65c.61-1,1.82-2,4.21-2,3.74,0,5.78,3.08,5.78,7.13s-2.12,7.68-6.16,7.68c-2.15,0-3.17-.72-3.85-1.85a11.47,11.47,0,0,1-.14,1.52H41.24c0-1.55,0-3.11,0-4.68Zm6.63,8.42c-2.47,0-3.38,1.65-3.38,4.68,0,2.59.8,4.59,3.33,4.59,2.14,0,3.33-1.92,3.33-4.84C51.18,20.27,50.13,18.43,47.9,18.43Z'/%3E%3Cpath class='cls-1' d='M68.59,26.66a26.61,26.61,0,0,0,.2,3.47H65.51a7.37,7.37,0,0,1-.22-1.55c-.49.86-1.51,1.88-4.1,1.88-3.38,0-4.81-2.23-4.81-4.41,0-3.19,2.56-4.67,6.71-4.67h2.15v-1c0-1.1-.36-2.25-2.48-2.25-1.87,0-2.26.85-2.45,1.89H57c.19-2.31,1.65-4.43,5.86-4.4,3.68,0,5.69,1.49,5.69,4.79Zm-3.33-3.14H63.42c-2.5,0-3.6.74-3.6,2.34A2,2,0,0,0,62.1,28c2.81,0,3.16-1.92,3.16-4Z'/%3E%3Cpath class='cls-1' d='M71.67,10h3.42v7.65c.6-1,1.81-2,4.21-2,3.74,0,5.77,3.08,5.77,7.13S83,30.46,78.91,30.46c-2.15,0-3.16-.72-3.85-1.85a10,10,0,0,1-.14,1.52H71.65c0-1.55,0-3.11,0-4.68Zm6.64,8.42c-2.48,0-3.39,1.65-3.39,4.68,0,2.59.8,4.59,3.33,4.59,2.15,0,3.33-1.92,3.33-4.84C81.58,20.27,80.53,18.43,78.31,18.43Z'/%3E%3Cpath class='cls-1' d='M89.37,16c1.76,5.53,3,9.66,3.3,11h0c.35-1.49,1.23-4.68,3.13-11h3.41L94.37,30.62c-1.37,4.1-2.47,5.26-5.69,5.26A15.34,15.34,0,0,1,87,35.77V33c.3,0,.71,0,1.07,0,1.54,0,2.25-.57,2.89-2.42L85.71,16Z'/%3E%3Cpath class='cls-1' d='M100.76,30.13V10h3.41V30.13Z'/%3E%3Cpath class='cls-1' d='M120.32,23c0,4.21-2.48,7.43-6.91,7.43s-6.79-3.14-6.79-7.38,2.56-7.43,7-7.43C117.68,15.65,120.32,18.6,120.32,23Zm-10.23,0c0,2.87,1.29,4.68,3.41,4.68s3.33-1.79,3.33-4.65c0-3-1.19-4.7-3.39-4.7S110.09,20,110.09,23.05Z'/%3E%3Cpath class='cls-1' d='M122.8,19.53c0-1.21,0-2.47,0-3.55h3.3a15.77,15.77,0,0,1,.14,2,4.32,4.32,0,0,1,4.21-2.31c2.78,0,4.7,1.82,4.7,5.45v9h-3.41V21.49c0-1.77-.63-3-2.5-3s-3,1.29-3,3.91v7.76H122.8Z'/%3E%3Cpath class='cls-1' d='M138.37,30.13V25.56H142v4.57Z'/%3E%3Cpath class='cls-1' d='M147.67,16.28V30.87c0,3.77-.91,5-3.6,5-.11,0-.66,0-.86,0V34.2c.2,0,.42,0,.58,0,1.84,0,2-1,2-3.08V16.28Zm-1.84-3.57V9.87h1.84v2.84Z'/%3E%3Cpath class='cls-1' d='M151.85,26.25a3.45,3.45,0,0,0,3.69,2.66c2.26,0,3.16-1,3.16-2.44s-.63-2.15-3.52-2.84c-3.77-.91-4.62-2.06-4.62-3.91S152,16,155.32,16s4.81,2,5,3.94h-1.81a3,3,0,0,0-3.28-2.39c-2.2,0-2.83,1.07-2.83,2.09s.61,1.73,3.25,2.36c4,1,4.95,2.31,4.95,4.38,0,2.47-2,4.13-5.15,4.13-3.35,0-5.11-1.74-5.47-4.21Z'/%3E%3Cpolygon class='cls-2' points='17.4 0 0 10.04 0 30.13 17.4 40.18 34.8 30.13 34.8 10.04 17.4 0'/%3E%3Cpolygon class='cls-3' points='34.8 10.04 29.35 6.9 24.11 9.93 29.56 13.07 34.8 10.04'/%3E%3Cpolygon class='cls-3' points='5.24 13.07 22.64 3.02 17.4 0 0 10.04 5.24 13.07'/%3E%3Cpolygon class='cls-3' points='11.95 23.23 17.4 26.38 22.84 23.23 17.4 20.09 11.95 23.23'/%3E%3Cpolygon class='cls-4' points='29.56 13.07 29.56 27.11 17.4 34.13 5.24 27.11 5.24 13.07 0 10.04 0 30.13 17.4 40.18 34.8 30.13 34.8 10.04 29.56 13.07'/%3E%3Cpolygon class='cls-4' points='17.4 13.8 11.95 16.95 11.95 23.23 17.4 20.09 22.84 23.23 22.84 16.95 17.4 13.8'/%3E%3Cpolygon class='cls-5' points='29.56 13.07 22.84 16.95 22.84 23.23 17.4 26.38 17.4 34.13 29.56 27.11 29.56 13.07'/%3E%3Cpolygon class='cls-1' points='5.24 13.07 11.95 16.95 11.95 23.23 17.4 26.38 17.4 34.13 5.24 27.11 5.24 13.07'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  24802. /***/ }),
  24803. /***/ "./img/icon-down.svg":
  24804. /*!***************************!*\
  24805. !*** ./img/icon-down.svg ***!
  24806. \***************************/
  24807. /*! no static exports found */
  24808. /***/ (function(module, exports) {
  24809. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:none;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EDownArrowIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Redlines'%3E%3Cpath class='cls-1' d='M23.14,30.07l1.42-1.42L34.85,38.94,45.14,28.65l1.41,1.42L34.85,41.78Z'/%3E%3Crect class='cls-2' width='70' height='70'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  24810. /***/ }),
  24811. /***/ "./img/icon-edit.svg":
  24812. /*!***************************!*\
  24813. !*** ./img/icon-edit.svg ***!
  24814. \***************************/
  24815. /*! no static exports found */
  24816. /***/ (function(module, exports) {
  24817. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:none;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EEditIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Page_Elements' data-name='Page Elements'%3E%3Cpath class='cls-1' d='M44.25,30.78a2.56,2.56,0,0,1,1-.64,3.64,3.64,0,0,1,1.17-.2,3.29,3.29,0,0,1,1.21.23,2.73,2.73,0,0,1,1,.62,3,3,0,0,1,.65,1A2.84,2.84,0,0,1,49.5,33a3.14,3.14,0,0,1-.23,1.18,2.84,2.84,0,0,1-.67,1L37.52,46.25l-5.85,1.46,1.46-5.84Zm3,3a1.06,1.06,0,0,0,.33-.79,1,1,0,0,0-.32-.78,1.16,1.16,0,0,0-.8-.29A1.23,1.23,0,0,0,46,32a.88.88,0,0,0-.36.21L34.93,42.89,34.4,45l2.09-.52Z'/%3E%3Cpath class='cls-1' d='M31.94,41.2l1-1V31.9l5.94-3v5.32l2-2V26.73L32,22.27l-8.92,4.46V38.5l8.5,4.26Zm0-16.7,5.7,2.85L32,30.18l-5.71-2.83ZM25,37.27V28.94l5.94,3v8.34Z'/%3E%3Crect class='cls-2' width='70' height='70'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  24818. /***/ }),
  24819. /***/ "./img/icon-ibl.svg":
  24820. /*!**************************!*\
  24821. !*** ./img/icon-ibl.svg ***!
  24822. \**************************/
  24823. /*! no static exports found */
  24824. /***/ (function(module, exports) {
  24825. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:none;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EEnvironmentIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Page_Elements' data-name='Page Elements'%3E%3Cpath class='cls-1' d='M34.89,21.24A13.19,13.19,0,1,0,48.07,34.42,13.19,13.19,0,0,0,34.89,21.24ZM34,33.43a.31.31,0,0,0,.44,0l1.13-1.14a.29.29,0,0,0,0-.32h.46a2.38,2.38,0,0,0,2.6.12l.61,0a.36.36,0,0,0,.07.17l1.14,1.14a.31.31,0,0,0,.22.09.3.3,0,0,0,.21-.09A.3.3,0,0,0,41,33l-.78-.79c3.69.41,6.21,1.23,6.21,2.18,0,1.36-5.14,2.46-11.49,2.46S23.4,35.78,23.4,34.42,28.54,32,34.89,32h.17l-1,1A.32.32,0,0,0,34,33.43Zm3.48-1.61A1.84,1.84,0,1,1,39.34,30,1.84,1.84,0,0,1,37.5,31.82Zm-2.61-8.9A11.5,11.5,0,0,1,46.35,33.54c-1.13-1-4.17-1.56-7.14-1.81A2.42,2.42,0,0,0,40,30a2.45,2.45,0,1,0-4.89,0,2.41,2.41,0,0,0,.58,1.57h-.75c-3.53,0-9.76.45-11.46,2A11.5,11.5,0,0,1,34.89,22.92Zm0,23a11.48,11.48,0,0,1-11.4-10.07c2.68,1.81,10.36,1.87,11.4,1.87s8.72-.06,11.4-1.87A11.48,11.48,0,0,1,34.89,45.92Z'/%3E%3Cpath class='cls-1' d='M37.52,27.3h0a.31.31,0,0,0,.31-.3V24.89a.3.3,0,0,0-.3-.31h0a.31.31,0,0,0-.31.31V27A.31.31,0,0,0,37.52,27.3Z'/%3E%3Cpath class='cls-1' d='M35.19,28.07a.31.31,0,0,0,.22.09.27.27,0,0,0,.21-.09.3.3,0,0,0,0-.43L34.49,26.5a.3.3,0,0,0-.43,0,.31.31,0,0,0,0,.43Z'/%3E%3Cpath class='cls-1' d='M39.63,28.19a.31.31,0,0,0,.22-.09L41,27a.3.3,0,1,0-.43-.43l-1.14,1.14a.3.3,0,0,0,0,.43A.31.31,0,0,0,39.63,28.19Z'/%3E%3Cpath class='cls-1' d='M38.6,27.4l.07,0a.19.19,0,0,0,.17-.12l.25-.61a.2.2,0,0,0-.1-.25.2.2,0,0,0-.25.11l-.25.61A.19.19,0,0,0,38.6,27.4Z'/%3E%3Cpath class='cls-1' d='M36.21,27.29a.18.18,0,0,0,.17.11l.07,0a.17.17,0,0,0,.1-.24l-.26-.61a.18.18,0,0,0-.24-.1.19.19,0,0,0-.1.24Z'/%3E%3Cpath class='cls-1' d='M34.82,28.65l-.61-.25a.18.18,0,0,0-.24.1.19.19,0,0,0,.1.24l.61.25h.07a.18.18,0,0,0,.07-.35Z'/%3E%3Cpath class='cls-1' d='M34.67,30.93l-.61.26a.18.18,0,0,0-.1.24.18.18,0,0,0,.17.11h.07l.61-.26a.18.18,0,0,0,.1-.24A.19.19,0,0,0,34.67,30.93Z'/%3E%3Cpath class='cls-1' d='M36,33.51l.07,0a.18.18,0,0,0,.17-.12l.25-.61a.18.18,0,0,0-.1-.24.18.18,0,0,0-.24.1l-.25.61A.18.18,0,0,0,36,33.51Z'/%3E%3Cpath class='cls-1' d='M38.71,33.43a.18.18,0,0,0,.17.11H39a.18.18,0,0,0,.09-.25l-.25-.61a.19.19,0,1,0-.34.15Z'/%3E%3Cpath class='cls-1' d='M40.94,31.22,40.32,31a.19.19,0,0,0-.24.1.18.18,0,0,0,.1.24l.62.25.07,0a.19.19,0,0,0,.17-.12A.19.19,0,0,0,40.94,31.22Z'/%3E%3Cpath class='cls-1' d='M40.27,29h.07l.61-.26a.18.18,0,0,0-.14-.34l-.61.26a.18.18,0,0,0-.1.24A.18.18,0,0,0,40.27,29Z'/%3E%3Cpath class='cls-1' d='M32.41,30.26h2.11a.31.31,0,1,0,0-.61H32.41a.31.31,0,0,0,0,.61Z'/%3E%3Cpath class='cls-1' d='M37.48,35.38h0a.32.32,0,0,0,.31-.31V33a.31.31,0,0,0-.31-.3h0a.3.3,0,0,0-.3.3v2.11A.31.31,0,0,0,37.48,35.38Z'/%3E%3Cpath class='cls-1' d='M40.49,29.69a.31.31,0,1,0,0,.62H42.6a.31.31,0,0,0,.3-.31.3.3,0,0,0-.3-.3Z'/%3E%3Crect class='cls-2' width='70' height='70'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  24826. /***/ }),
  24827. /***/ "./img/icon-open.svg":
  24828. /*!***************************!*\
  24829. !*** ./img/icon-open.svg ***!
  24830. \***************************/
  24831. /*! no static exports found */
  24832. /***/ (function(module, exports) {
  24833. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:none;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EAsset 11%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Page_Elements' data-name='Page Elements'%3E%3Cpath class='cls-1' d='M26.67,44.77H41.88v1.52H25.15V22H38.4l6.52,6.52v5.64H43.4V29.56H37.31V23.48H26.67ZM38.83,28h3.49l-3.49-3.48Zm8,12.13-1.93-1.92v8H43.4v-8l-1.94,1.92L40.39,39.1l3.77-3.77,3.76,3.77Z'/%3E%3Crect class='cls-2' width='70' height='70'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  24834. /***/ }),
  24835. /***/ "./img/icon-pause.svg":
  24836. /*!****************************!*\
  24837. !*** ./img/icon-pause.svg ***!
  24838. \****************************/
  24839. /*! no static exports found */
  24840. /***/ (function(module, exports) {
  24841. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:none;%7D.cls-2%7Bfill:%23fff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EPauseIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Redlines'%3E%3Crect class='cls-1' width='70' height='70'/%3E%3Cpath class='cls-2' d='M28.83,44.37v-20h2v20Zm10-20h2v20h-2Z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  24842. /***/ }),
  24843. /***/ "./img/icon-play.svg":
  24844. /*!***************************!*\
  24845. !*** ./img/icon-play.svg ***!
  24846. \***************************/
  24847. /*! no static exports found */
  24848. /***/ (function(module, exports) {
  24849. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:none;%7D.cls-2%7Bfill:%23fff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EPlayIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Redlines'%3E%3Crect class='cls-1' width='70' height='70'/%3E%3Cpath class='cls-2' d='M28.83,25.13l16,10-16,10Zm2,3.61V41.52l10.22-6.39Z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  24850. /***/ }),
  24851. /***/ "./img/icon-up.svg":
  24852. /*!*************************!*\
  24853. !*** ./img/icon-up.svg ***!
  24854. \*************************/
  24855. /*! no static exports found */
  24856. /***/ (function(module, exports) {
  24857. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:none;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EUpArrowIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Redlines'%3E%3Cpath class='cls-1' d='M34.85,29.78,24.56,40.06l-1.42-1.41L34.85,26.94l11.7,11.71-1.42,1.41Z'/%3E%3Crect class='cls-2' width='70' height='70'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  24858. /***/ }),
  24859. /***/ "./img/logo-fullscreen.svg":
  24860. /*!*********************************!*\
  24861. !*** ./img/logo-fullscreen.svg ***!
  24862. \*********************************/
  24863. /*! no static exports found */
  24864. /***/ (function(module, exports) {
  24865. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180.17 208.04'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:%23e0684b;%7D.cls-3%7Bfill:%23bb464b;%7D.cls-4%7Bfill:%23e0ded8;%7D.cls-5%7Bfill:%23d5d2ca;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EBabylonLogo%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Page_Elements' data-name='Page Elements'%3E%3Cpath class='cls-1' d='M90.09,0,0,52V156l90.09,52,90.08-52V52Z'/%3E%3Cpolygon class='cls-2' points='180.17 52.01 151.97 35.73 124.85 51.39 153.05 67.67 180.17 52.01'/%3E%3Cpolygon class='cls-2' points='27.12 67.67 117.21 15.66 90.08 0 0 52.01 27.12 67.67'/%3E%3Cpolygon class='cls-2' points='61.89 120.3 90.08 136.58 118.28 120.3 90.08 104.02 61.89 120.3'/%3E%3Cpolygon class='cls-3' points='153.05 67.67 153.05 140.37 90.08 176.72 27.12 140.37 27.12 67.67 0 52.01 0 156.03 90.08 208.04 180.17 156.03 180.17 52.01 153.05 67.67'/%3E%3Cpolygon class='cls-3' points='90.08 71.46 61.89 87.74 61.89 120.3 90.08 104.02 118.28 120.3 118.28 87.74 90.08 71.46'/%3E%3Cpolygon class='cls-4' points='153.05 67.67 118.28 87.74 118.28 120.3 90.08 136.58 90.08 176.72 153.05 140.37 153.05 67.67'/%3E%3Cpolygon class='cls-5' points='27.12 67.67 61.89 87.74 61.89 120.3 90.08 136.58 90.08 176.72 27.12 140.37 27.12 67.67'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  24866. /***/ }),
  24867. /***/ "./index.ts":
  24868. /*!******************!*\
  24869. !*** ./index.ts ***!
  24870. \******************/
  24871. /*! exports provided: Sandbox */
  24872. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24873. "use strict";
  24874. __webpack_require__.r(__webpack_exports__);
  24875. /* harmony import */ var _sandbox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sandbox */ "./sandbox.tsx");
  24876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sandbox", function() { return _sandbox__WEBPACK_IMPORTED_MODULE_0__["Sandbox"]; });
  24877. /***/ }),
  24878. /***/ "./legacy/legacy.ts":
  24879. /*!**************************!*\
  24880. !*** ./legacy/legacy.ts ***!
  24881. \**************************/
  24882. /*! exports provided: Sandbox */
  24883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24884. "use strict";
  24885. __webpack_require__.r(__webpack_exports__);
  24886. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  24887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sandbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sandbox"]; });
  24888. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  24889. if (typeof globalObject !== "undefined") {
  24890. globalObject.BABYLON = globalObject.BABYLON || {};
  24891. globalObject.BABYLON.Sandbox = _index__WEBPACK_IMPORTED_MODULE_0__["Sandbox"];
  24892. }
  24893. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  24894. /***/ }),
  24895. /***/ "./sandbox.tsx":
  24896. /*!*********************!*\
  24897. !*** ./sandbox.tsx ***!
  24898. \*********************/
  24899. /*! exports provided: Sandbox */
  24900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24901. "use strict";
  24902. __webpack_require__.r(__webpack_exports__);
  24903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sandbox", function() { return Sandbox; });
  24904. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  24905. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  24906. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  24907. /* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-dom */ "../../node_modules/react-dom/index.js");
  24908. /* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_2__);
  24909. /* harmony import */ var _globalState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./globalState */ "./globalState.ts");
  24910. /* harmony import */ var _components_renderingZone__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/renderingZone */ "./components/renderingZone.tsx");
  24911. /* harmony import */ var _components_footer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/footer */ "./components/footer.tsx");
  24912. /* harmony import */ var _tools_environmentTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./tools/environmentTools */ "./tools/environmentTools.ts");
  24913. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  24914. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__);
  24915. __webpack_require__(/*! ./scss/main.scss */ "./scss/main.scss");
  24916. var fullScreenLogo = __webpack_require__(/*! ./img/logo-fullscreen.svg */ "./img/logo-fullscreen.svg");
  24917. var Sandbox = /** @class */ (function (_super) {
  24918. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Sandbox, _super);
  24919. function Sandbox(props) {
  24920. var _this = _super.call(this, props) || this;
  24921. _this._globalState = new _globalState__WEBPACK_IMPORTED_MODULE_3__["GlobalState"]();
  24922. _this._logoRef = react__WEBPACK_IMPORTED_MODULE_1__["createRef"]();
  24923. _this._dropTextRef = react__WEBPACK_IMPORTED_MODULE_1__["createRef"]();
  24924. _this._clickInterceptorRef = react__WEBPACK_IMPORTED_MODULE_1__["createRef"]();
  24925. _this.state = { isFooterVisible: true, errorMessage: "" };
  24926. _this.checkUrl();
  24927. _tools_environmentTools__WEBPACK_IMPORTED_MODULE_6__["EnvironmentTools"].HookWithEnvironmentChange(_this._globalState);
  24928. // Events
  24929. _this._globalState.onSceneLoaded.add(function (info) {
  24930. document.title = "Babylon.js - " + info.filename;
  24931. _this._globalState.currentScene = info.scene;
  24932. if (_this._globalState.currentScene.meshes.length === 0 && _this._globalState.currentScene.clearColor.r === 1 && _this._globalState.currentScene.clearColor.g === 0 && _this._globalState.currentScene.clearColor.b === 0) {
  24933. _this._logoRef.current.className = "";
  24934. }
  24935. else {
  24936. _this._logoRef.current.className = "hidden";
  24937. _this._dropTextRef.current.className = "hidden";
  24938. }
  24939. });
  24940. _this._globalState.onError.add(function (error) {
  24941. if (error.scene) {
  24942. _this._globalState.showDebugLayer();
  24943. }
  24944. if (error.message) {
  24945. _this.setState({ errorMessage: error.message });
  24946. }
  24947. });
  24948. _this._globalState.onRequestClickInterceptor.add(function () {
  24949. var div = _this._clickInterceptorRef.current;
  24950. if (div.classList.contains("hidden")) {
  24951. div.classList.remove("hidden");
  24952. }
  24953. else {
  24954. div.classList.add("hidden");
  24955. }
  24956. });
  24957. // Keyboard
  24958. window.addEventListener("keydown", function (event) {
  24959. // Press space to toggle footer
  24960. if (event.keyCode === 32 && event.target && event.target.nodeName !== "INPUT") {
  24961. _this.setState({ isFooterVisible: !_this.state.isFooterVisible });
  24962. }
  24963. });
  24964. return _this;
  24965. }
  24966. Sandbox.prototype.checkUrl = function () {
  24967. // Check URL
  24968. var indexOf = location.href.indexOf("?");
  24969. if (indexOf !== -1) {
  24970. var params = location.href.substr(indexOf + 1).split("&");
  24971. for (var index = 0; index < params.length; index++) {
  24972. var param = params[index].split("=");
  24973. var name = param[0];
  24974. var value = param[1];
  24975. switch (name) {
  24976. case "assetUrl": {
  24977. this._assetUrl = value;
  24978. break;
  24979. }
  24980. case "cameraPosition": {
  24981. this._cameraPosition = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"].FromArray(value.split(",").map(function (component) { return +component; }));
  24982. break;
  24983. }
  24984. case "kiosk": {
  24985. this.state = { isFooterVisible: value === "true" ? false : true, errorMessage: "" };
  24986. break;
  24987. }
  24988. }
  24989. }
  24990. }
  24991. };
  24992. Sandbox.prototype.componentDidUpdate = function () {
  24993. this._assetUrl = undefined;
  24994. this._cameraPosition = undefined;
  24995. };
  24996. Sandbox.prototype.render = function () {
  24997. var _this = this;
  24998. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { id: "root" },
  24999. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("p", { id: "droptext", ref: this._dropTextRef }, "Drag and drop gltf, glb, obj or babylon files to view them"),
  25000. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_components_renderingZone__WEBPACK_IMPORTED_MODULE_4__["RenderingZone"], { globalState: this._globalState, assetUrl: this._assetUrl, cameraPosition: this._cameraPosition, expanded: !this.state.isFooterVisible }),
  25001. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { ref: this._clickInterceptorRef, onClick: function () {
  25002. _this._globalState.onClickInterceptorClicked.notifyObservers();
  25003. _this._clickInterceptorRef.current.classList.add("hidden");
  25004. }, className: "clickInterceptor hidden" }),
  25005. this.state.isFooterVisible &&
  25006. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_components_footer__WEBPACK_IMPORTED_MODULE_5__["Footer"], { globalState: this._globalState }),
  25007. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { id: "logoContainer" },
  25008. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { id: "logo", src: fullScreenLogo, ref: this._logoRef })),
  25009. this.state.errorMessage &&
  25010. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { id: "errorZone" },
  25011. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "message" }, this.state.errorMessage),
  25012. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("button", { type: "button", className: "close", onClick: function () { return _this.setState({ errorMessage: "" }); }, "data-dismiss": "alert" }, "\u00D7"))));
  25013. };
  25014. Sandbox.Show = function (hostElement) {
  25015. var sandBox = react__WEBPACK_IMPORTED_MODULE_1__["createElement"](Sandbox, {});
  25016. react_dom__WEBPACK_IMPORTED_MODULE_2__["render"](sandBox, hostElement);
  25017. };
  25018. return Sandbox;
  25019. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  25020. /***/ }),
  25021. /***/ "./scss/animationBar.scss":
  25022. /*!********************************!*\
  25023. !*** ./scss/animationBar.scss ***!
  25024. \********************************/
  25025. /*! no static exports found */
  25026. /***/ (function(module, exports, __webpack_require__) {
  25027. var api = __webpack_require__(/*! ../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
  25028. var content = __webpack_require__(/*! !../../../node_modules/css-loader/dist/cjs.js!../../../node_modules/sass-loader/dist/cjs.js!./animationBar.scss */ "../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/dist/cjs.js!./scss/animationBar.scss");
  25029. content = content.__esModule ? content.default : content;
  25030. if (typeof content === 'string') {
  25031. content = [[module.i, content, '']];
  25032. }
  25033. var options = {};
  25034. options.insert = "head";
  25035. options.singleton = false;
  25036. var update = api(content, options);
  25037. module.exports = content.locals || {};
  25038. /***/ }),
  25039. /***/ "./scss/footer.scss":
  25040. /*!**************************!*\
  25041. !*** ./scss/footer.scss ***!
  25042. \**************************/
  25043. /*! no static exports found */
  25044. /***/ (function(module, exports, __webpack_require__) {
  25045. var api = __webpack_require__(/*! ../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
  25046. var content = __webpack_require__(/*! !../../../node_modules/css-loader/dist/cjs.js!../../../node_modules/sass-loader/dist/cjs.js!./footer.scss */ "../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/dist/cjs.js!./scss/footer.scss");
  25047. content = content.__esModule ? content.default : content;
  25048. if (typeof content === 'string') {
  25049. content = [[module.i, content, '']];
  25050. }
  25051. var options = {};
  25052. options.insert = "head";
  25053. options.singleton = false;
  25054. var update = api(content, options);
  25055. module.exports = content.locals || {};
  25056. /***/ }),
  25057. /***/ "./scss/main.scss":
  25058. /*!************************!*\
  25059. !*** ./scss/main.scss ***!
  25060. \************************/
  25061. /*! no static exports found */
  25062. /***/ (function(module, exports, __webpack_require__) {
  25063. var api = __webpack_require__(/*! ../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
  25064. var content = __webpack_require__(/*! !../../../node_modules/css-loader/dist/cjs.js!../../../node_modules/sass-loader/dist/cjs.js!./main.scss */ "../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/dist/cjs.js!./scss/main.scss");
  25065. content = content.__esModule ? content.default : content;
  25066. if (typeof content === 'string') {
  25067. content = [[module.i, content, '']];
  25068. }
  25069. var options = {};
  25070. options.insert = "head";
  25071. options.singleton = false;
  25072. var update = api(content, options);
  25073. module.exports = content.locals || {};
  25074. /***/ }),
  25075. /***/ "./scss/renderingZone.scss":
  25076. /*!*********************************!*\
  25077. !*** ./scss/renderingZone.scss ***!
  25078. \*********************************/
  25079. /*! no static exports found */
  25080. /***/ (function(module, exports, __webpack_require__) {
  25081. var api = __webpack_require__(/*! ../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
  25082. var content = __webpack_require__(/*! !../../../node_modules/css-loader/dist/cjs.js!../../../node_modules/sass-loader/dist/cjs.js!./renderingZone.scss */ "../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/dist/cjs.js!./scss/renderingZone.scss");
  25083. content = content.__esModule ? content.default : content;
  25084. if (typeof content === 'string') {
  25085. content = [[module.i, content, '']];
  25086. }
  25087. var options = {};
  25088. options.insert = "head";
  25089. options.singleton = false;
  25090. var update = api(content, options);
  25091. module.exports = content.locals || {};
  25092. /***/ }),
  25093. /***/ "./tools/environmentTools.ts":
  25094. /*!***********************************!*\
  25095. !*** ./tools/environmentTools.ts ***!
  25096. \***********************************/
  25097. /*! exports provided: EnvironmentTools */
  25098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25099. "use strict";
  25100. __webpack_require__.r(__webpack_exports__);
  25101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTools", function() { return EnvironmentTools; });
  25102. /* harmony import */ var babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/Textures/hdrCubeTexture */ "babylonjs/Maths/math.vector");
  25103. /* harmony import */ var babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__);
  25104. /* harmony import */ var _localStorageHelper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./localStorageHelper */ "./tools/localStorageHelper.ts");
  25105. var EnvironmentTools = /** @class */ (function () {
  25106. function EnvironmentTools() {
  25107. }
  25108. EnvironmentTools.LoadSkyboxPathTexture = function (scene) {
  25109. var defaultSkyboxIndex = Math.max(0, _localStorageHelper__WEBPACK_IMPORTED_MODULE_1__["LocalStorageHelper"].ReadLocalStorageValue("defaultSkyboxId", 0));
  25110. var path = this.SkyboxPath || this.Skyboxes[defaultSkyboxIndex];
  25111. if (path.indexOf(".hdr") === (path.length - 4)) {
  25112. return new babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"](path, scene, 256, false, true, false, true);
  25113. }
  25114. return babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"].CreateFromPrefilteredData(path, scene);
  25115. };
  25116. EnvironmentTools.HookWithEnvironmentChange = function (globalState) {
  25117. var _this = this;
  25118. globalState.onEnvironmentChanged.add(function (option) {
  25119. _this.SkyboxPath = "";
  25120. var index = EnvironmentTools.SkyboxesNames.indexOf(option);
  25121. if (typeof (Storage) !== "undefined") {
  25122. localStorage.setItem("defaultSkyboxId", index.toString());
  25123. }
  25124. var currentScene = babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__["Engine"].LastCreatedScene;
  25125. currentScene.environmentTexture = _this.LoadSkyboxPathTexture(currentScene);
  25126. for (var i = 0; i < currentScene.materials.length; i++) {
  25127. var material = currentScene.materials[i];
  25128. if (material.name === "skyBox") {
  25129. var reflectionTexture = material.reflectionTexture;
  25130. if (reflectionTexture && reflectionTexture.coordinatesMode === babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__["Texture"].SKYBOX_MODE) {
  25131. material.reflectionTexture = currentScene.environmentTexture.clone();
  25132. if (material.reflectionTexture) {
  25133. material.reflectionTexture.coordinatesMode = babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__["Texture"].SKYBOX_MODE;
  25134. }
  25135. }
  25136. }
  25137. }
  25138. });
  25139. };
  25140. EnvironmentTools.SkyboxPath = "";
  25141. EnvironmentTools.Skyboxes = [
  25142. "https://assets.babylonjs.com/environments/environmentSpecular.env",
  25143. "https://assets.babylonjs.com/environments/studio.env",
  25144. ];
  25145. EnvironmentTools.SkyboxesNames = [
  25146. "Default",
  25147. "Studio",
  25148. ];
  25149. return EnvironmentTools;
  25150. }());
  25151. /***/ }),
  25152. /***/ "./tools/localStorageHelper.ts":
  25153. /*!*************************************!*\
  25154. !*** ./tools/localStorageHelper.ts ***!
  25155. \*************************************/
  25156. /*! exports provided: LocalStorageHelper */
  25157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25158. "use strict";
  25159. __webpack_require__.r(__webpack_exports__);
  25160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocalStorageHelper", function() { return LocalStorageHelper; });
  25161. var LocalStorageHelper = /** @class */ (function () {
  25162. function LocalStorageHelper() {
  25163. }
  25164. LocalStorageHelper.ReadLocalStorageValue = function (key, defaultValue) {
  25165. if (typeof (Storage) !== "undefined" && localStorage.getItem(key) !== null) {
  25166. return parseInt(localStorage.getItem(key));
  25167. }
  25168. return defaultValue;
  25169. };
  25170. return LocalStorageHelper;
  25171. }());
  25172. /***/ }),
  25173. /***/ "babylonjs-loaders/glTF/glTFFileLoader":
  25174. /*!****************************************************************************************************************************!*\
  25175. !*** external {"root":"BABYLON","commonjs":"babylonjs-loaders","commonjs2":"babylonjs-loaders","amd":"babylonjs-loaders"} ***!
  25176. \****************************************************************************************************************************/
  25177. /*! no static exports found */
  25178. /***/ (function(module, exports) {
  25179. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_loaders_glTF_glTFFileLoader__;
  25180. /***/ }),
  25181. /***/ "babylonjs/Maths/math.vector":
  25182. /*!****************************************************************************************************!*\
  25183. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  25184. \****************************************************************************************************/
  25185. /*! no static exports found */
  25186. /***/ (function(module, exports) {
  25187. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__;
  25188. /***/ })
  25189. /******/ });
  25190. });
  25191. //# sourceMappingURL=babylon.sandbox.max.js.map