app.js 2.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "/";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 0);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/axios/index.js":
  89. /*!*************************************!*\
  90. !*** ./node_modules/axios/index.js ***!
  91. \*************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports, __webpack_require__) {
  94. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  95. /***/ }),
  96. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  97. /*!************************************************!*\
  98. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  99. \************************************************/
  100. /*! no static exports found */
  101. /***/ (function(module, exports, __webpack_require__) {
  102. "use strict";
  103. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  104. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  105. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  106. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  107. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  108. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  109. module.exports = function xhrAdapter(config) {
  110. return new Promise(function dispatchXhrRequest(resolve, reject) {
  111. var requestData = config.data;
  112. var requestHeaders = config.headers;
  113. if (utils.isFormData(requestData)) {
  114. delete requestHeaders['Content-Type']; // Let the browser set it
  115. }
  116. var request = new XMLHttpRequest();
  117. // HTTP basic authentication
  118. if (config.auth) {
  119. var username = config.auth.username || '';
  120. var password = config.auth.password || '';
  121. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  122. }
  123. request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
  124. // Set the request timeout in MS
  125. request.timeout = config.timeout;
  126. // Listen for ready state
  127. request.onreadystatechange = function handleLoad() {
  128. if (!request || request.readyState !== 4) {
  129. return;
  130. }
  131. // The request errored out and we didn't get a response, this will be
  132. // handled by onerror instead
  133. // With one exception: request that using file: protocol, most browsers
  134. // will return status as 0 even though it's a successful request
  135. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  136. return;
  137. }
  138. // Prepare the response
  139. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  140. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  141. var response = {
  142. data: responseData,
  143. status: request.status,
  144. statusText: request.statusText,
  145. headers: responseHeaders,
  146. config: config,
  147. request: request
  148. };
  149. settle(resolve, reject, response);
  150. // Clean up request
  151. request = null;
  152. };
  153. // Handle browser request cancellation (as opposed to a manual cancellation)
  154. request.onabort = function handleAbort() {
  155. if (!request) {
  156. return;
  157. }
  158. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  159. // Clean up request
  160. request = null;
  161. };
  162. // Handle low level network errors
  163. request.onerror = function handleError() {
  164. // Real errors are hidden from us by the browser
  165. // onerror should only fire if it's a network error
  166. reject(createError('Network Error', config, null, request));
  167. // Clean up request
  168. request = null;
  169. };
  170. // Handle timeout
  171. request.ontimeout = function handleTimeout() {
  172. reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',
  173. request));
  174. // Clean up request
  175. request = null;
  176. };
  177. // Add xsrf header
  178. // This is only done if running in a standard browser environment.
  179. // Specifically not if we're in a web worker, or react-native.
  180. if (utils.isStandardBrowserEnv()) {
  181. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  182. // Add xsrf header
  183. var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
  184. cookies.read(config.xsrfCookieName) :
  185. undefined;
  186. if (xsrfValue) {
  187. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  188. }
  189. }
  190. // Add headers to the request
  191. if ('setRequestHeader' in request) {
  192. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  193. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  194. // Remove Content-Type if data is undefined
  195. delete requestHeaders[key];
  196. } else {
  197. // Otherwise add header to the request
  198. request.setRequestHeader(key, val);
  199. }
  200. });
  201. }
  202. // Add withCredentials to request if needed
  203. if (config.withCredentials) {
  204. request.withCredentials = true;
  205. }
  206. // Add responseType to request if needed
  207. if (config.responseType) {
  208. try {
  209. request.responseType = config.responseType;
  210. } catch (e) {
  211. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  212. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  213. if (config.responseType !== 'json') {
  214. throw e;
  215. }
  216. }
  217. }
  218. // Handle progress if needed
  219. if (typeof config.onDownloadProgress === 'function') {
  220. request.addEventListener('progress', config.onDownloadProgress);
  221. }
  222. // Not all browsers support upload events
  223. if (typeof config.onUploadProgress === 'function' && request.upload) {
  224. request.upload.addEventListener('progress', config.onUploadProgress);
  225. }
  226. if (config.cancelToken) {
  227. // Handle cancellation
  228. config.cancelToken.promise.then(function onCanceled(cancel) {
  229. if (!request) {
  230. return;
  231. }
  232. request.abort();
  233. reject(cancel);
  234. // Clean up request
  235. request = null;
  236. });
  237. }
  238. if (requestData === undefined) {
  239. requestData = null;
  240. }
  241. // Send the request
  242. request.send(requestData);
  243. });
  244. };
  245. /***/ }),
  246. /***/ "./node_modules/axios/lib/axios.js":
  247. /*!*****************************************!*\
  248. !*** ./node_modules/axios/lib/axios.js ***!
  249. \*****************************************/
  250. /*! no static exports found */
  251. /***/ (function(module, exports, __webpack_require__) {
  252. "use strict";
  253. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  254. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  255. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  256. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  257. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  258. /**
  259. * Create an instance of Axios
  260. *
  261. * @param {Object} defaultConfig The default config for the instance
  262. * @return {Axios} A new instance of Axios
  263. */
  264. function createInstance(defaultConfig) {
  265. var context = new Axios(defaultConfig);
  266. var instance = bind(Axios.prototype.request, context);
  267. // Copy axios.prototype to instance
  268. utils.extend(instance, Axios.prototype, context);
  269. // Copy context to instance
  270. utils.extend(instance, context);
  271. return instance;
  272. }
  273. // Create the default instance to be exported
  274. var axios = createInstance(defaults);
  275. // Expose Axios class to allow class inheritance
  276. axios.Axios = Axios;
  277. // Factory for creating new instances
  278. axios.create = function create(instanceConfig) {
  279. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  280. };
  281. // Expose Cancel & CancelToken
  282. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  283. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  284. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  285. // Expose all/spread
  286. axios.all = function all(promises) {
  287. return Promise.all(promises);
  288. };
  289. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  290. module.exports = axios;
  291. // Allow use of default import syntax in TypeScript
  292. module.exports.default = axios;
  293. /***/ }),
  294. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  295. /*!*************************************************!*\
  296. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  297. \*************************************************/
  298. /*! no static exports found */
  299. /***/ (function(module, exports, __webpack_require__) {
  300. "use strict";
  301. /**
  302. * A `Cancel` is an object that is thrown when an operation is canceled.
  303. *
  304. * @class
  305. * @param {string=} message The message.
  306. */
  307. function Cancel(message) {
  308. this.message = message;
  309. }
  310. Cancel.prototype.toString = function toString() {
  311. return 'Cancel' + (this.message ? ': ' + this.message : '');
  312. };
  313. Cancel.prototype.__CANCEL__ = true;
  314. module.exports = Cancel;
  315. /***/ }),
  316. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  317. /*!******************************************************!*\
  318. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  319. \******************************************************/
  320. /*! no static exports found */
  321. /***/ (function(module, exports, __webpack_require__) {
  322. "use strict";
  323. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  324. /**
  325. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  326. *
  327. * @class
  328. * @param {Function} executor The executor function.
  329. */
  330. function CancelToken(executor) {
  331. if (typeof executor !== 'function') {
  332. throw new TypeError('executor must be a function.');
  333. }
  334. var resolvePromise;
  335. this.promise = new Promise(function promiseExecutor(resolve) {
  336. resolvePromise = resolve;
  337. });
  338. var token = this;
  339. executor(function cancel(message) {
  340. if (token.reason) {
  341. // Cancellation has already been requested
  342. return;
  343. }
  344. token.reason = new Cancel(message);
  345. resolvePromise(token.reason);
  346. });
  347. }
  348. /**
  349. * Throws a `Cancel` if cancellation has been requested.
  350. */
  351. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  352. if (this.reason) {
  353. throw this.reason;
  354. }
  355. };
  356. /**
  357. * Returns an object that contains a new `CancelToken` and a function that, when called,
  358. * cancels the `CancelToken`.
  359. */
  360. CancelToken.source = function source() {
  361. var cancel;
  362. var token = new CancelToken(function executor(c) {
  363. cancel = c;
  364. });
  365. return {
  366. token: token,
  367. cancel: cancel
  368. };
  369. };
  370. module.exports = CancelToken;
  371. /***/ }),
  372. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  373. /*!***************************************************!*\
  374. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  375. \***************************************************/
  376. /*! no static exports found */
  377. /***/ (function(module, exports, __webpack_require__) {
  378. "use strict";
  379. module.exports = function isCancel(value) {
  380. return !!(value && value.__CANCEL__);
  381. };
  382. /***/ }),
  383. /***/ "./node_modules/axios/lib/core/Axios.js":
  384. /*!**********************************************!*\
  385. !*** ./node_modules/axios/lib/core/Axios.js ***!
  386. \**********************************************/
  387. /*! no static exports found */
  388. /***/ (function(module, exports, __webpack_require__) {
  389. "use strict";
  390. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  391. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  392. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  393. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  394. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  395. /**
  396. * Create a new instance of Axios
  397. *
  398. * @param {Object} instanceConfig The default config for the instance
  399. */
  400. function Axios(instanceConfig) {
  401. this.defaults = instanceConfig;
  402. this.interceptors = {
  403. request: new InterceptorManager(),
  404. response: new InterceptorManager()
  405. };
  406. }
  407. /**
  408. * Dispatch a request
  409. *
  410. * @param {Object} config The config specific for this request (merged with this.defaults)
  411. */
  412. Axios.prototype.request = function request(config) {
  413. /*eslint no-param-reassign:0*/
  414. // Allow for axios('example/url'[, config]) a la fetch API
  415. if (typeof config === 'string') {
  416. config = arguments[1] || {};
  417. config.url = arguments[0];
  418. } else {
  419. config = config || {};
  420. }
  421. config = mergeConfig(this.defaults, config);
  422. config.method = config.method ? config.method.toLowerCase() : 'get';
  423. // Hook up interceptors middleware
  424. var chain = [dispatchRequest, undefined];
  425. var promise = Promise.resolve(config);
  426. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  427. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  428. });
  429. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  430. chain.push(interceptor.fulfilled, interceptor.rejected);
  431. });
  432. while (chain.length) {
  433. promise = promise.then(chain.shift(), chain.shift());
  434. }
  435. return promise;
  436. };
  437. Axios.prototype.getUri = function getUri(config) {
  438. config = mergeConfig(this.defaults, config);
  439. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  440. };
  441. // Provide aliases for supported request methods
  442. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  443. /*eslint func-names:0*/
  444. Axios.prototype[method] = function(url, config) {
  445. return this.request(utils.merge(config || {}, {
  446. method: method,
  447. url: url
  448. }));
  449. };
  450. });
  451. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  452. /*eslint func-names:0*/
  453. Axios.prototype[method] = function(url, data, config) {
  454. return this.request(utils.merge(config || {}, {
  455. method: method,
  456. url: url,
  457. data: data
  458. }));
  459. };
  460. });
  461. module.exports = Axios;
  462. /***/ }),
  463. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  464. /*!***********************************************************!*\
  465. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  466. \***********************************************************/
  467. /*! no static exports found */
  468. /***/ (function(module, exports, __webpack_require__) {
  469. "use strict";
  470. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  471. function InterceptorManager() {
  472. this.handlers = [];
  473. }
  474. /**
  475. * Add a new interceptor to the stack
  476. *
  477. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  478. * @param {Function} rejected The function to handle `reject` for a `Promise`
  479. *
  480. * @return {Number} An ID used to remove interceptor later
  481. */
  482. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  483. this.handlers.push({
  484. fulfilled: fulfilled,
  485. rejected: rejected
  486. });
  487. return this.handlers.length - 1;
  488. };
  489. /**
  490. * Remove an interceptor from the stack
  491. *
  492. * @param {Number} id The ID that was returned by `use`
  493. */
  494. InterceptorManager.prototype.eject = function eject(id) {
  495. if (this.handlers[id]) {
  496. this.handlers[id] = null;
  497. }
  498. };
  499. /**
  500. * Iterate over all the registered interceptors
  501. *
  502. * This method is particularly useful for skipping over any
  503. * interceptors that may have become `null` calling `eject`.
  504. *
  505. * @param {Function} fn The function to call for each interceptor
  506. */
  507. InterceptorManager.prototype.forEach = function forEach(fn) {
  508. utils.forEach(this.handlers, function forEachHandler(h) {
  509. if (h !== null) {
  510. fn(h);
  511. }
  512. });
  513. };
  514. module.exports = InterceptorManager;
  515. /***/ }),
  516. /***/ "./node_modules/axios/lib/core/createError.js":
  517. /*!****************************************************!*\
  518. !*** ./node_modules/axios/lib/core/createError.js ***!
  519. \****************************************************/
  520. /*! no static exports found */
  521. /***/ (function(module, exports, __webpack_require__) {
  522. "use strict";
  523. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  524. /**
  525. * Create an Error with the specified message, config, error code, request and response.
  526. *
  527. * @param {string} message The error message.
  528. * @param {Object} config The config.
  529. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  530. * @param {Object} [request] The request.
  531. * @param {Object} [response] The response.
  532. * @returns {Error} The created error.
  533. */
  534. module.exports = function createError(message, config, code, request, response) {
  535. var error = new Error(message);
  536. return enhanceError(error, config, code, request, response);
  537. };
  538. /***/ }),
  539. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  540. /*!********************************************************!*\
  541. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  542. \********************************************************/
  543. /*! no static exports found */
  544. /***/ (function(module, exports, __webpack_require__) {
  545. "use strict";
  546. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  547. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  548. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  549. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  550. var isAbsoluteURL = __webpack_require__(/*! ./../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  551. var combineURLs = __webpack_require__(/*! ./../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  552. /**
  553. * Throws a `Cancel` if cancellation has been requested.
  554. */
  555. function throwIfCancellationRequested(config) {
  556. if (config.cancelToken) {
  557. config.cancelToken.throwIfRequested();
  558. }
  559. }
  560. /**
  561. * Dispatch a request to the server using the configured adapter.
  562. *
  563. * @param {object} config The config that is to be used for the request
  564. * @returns {Promise} The Promise to be fulfilled
  565. */
  566. module.exports = function dispatchRequest(config) {
  567. throwIfCancellationRequested(config);
  568. // Support baseURL config
  569. if (config.baseURL && !isAbsoluteURL(config.url)) {
  570. config.url = combineURLs(config.baseURL, config.url);
  571. }
  572. // Ensure headers exist
  573. config.headers = config.headers || {};
  574. // Transform request data
  575. config.data = transformData(
  576. config.data,
  577. config.headers,
  578. config.transformRequest
  579. );
  580. // Flatten headers
  581. config.headers = utils.merge(
  582. config.headers.common || {},
  583. config.headers[config.method] || {},
  584. config.headers || {}
  585. );
  586. utils.forEach(
  587. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  588. function cleanHeaderConfig(method) {
  589. delete config.headers[method];
  590. }
  591. );
  592. var adapter = config.adapter || defaults.adapter;
  593. return adapter(config).then(function onAdapterResolution(response) {
  594. throwIfCancellationRequested(config);
  595. // Transform response data
  596. response.data = transformData(
  597. response.data,
  598. response.headers,
  599. config.transformResponse
  600. );
  601. return response;
  602. }, function onAdapterRejection(reason) {
  603. if (!isCancel(reason)) {
  604. throwIfCancellationRequested(config);
  605. // Transform response data
  606. if (reason && reason.response) {
  607. reason.response.data = transformData(
  608. reason.response.data,
  609. reason.response.headers,
  610. config.transformResponse
  611. );
  612. }
  613. }
  614. return Promise.reject(reason);
  615. });
  616. };
  617. /***/ }),
  618. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  619. /*!*****************************************************!*\
  620. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  621. \*****************************************************/
  622. /*! no static exports found */
  623. /***/ (function(module, exports, __webpack_require__) {
  624. "use strict";
  625. /**
  626. * Update an Error with the specified config, error code, and response.
  627. *
  628. * @param {Error} error The error to update.
  629. * @param {Object} config The config.
  630. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  631. * @param {Object} [request] The request.
  632. * @param {Object} [response] The response.
  633. * @returns {Error} The error.
  634. */
  635. module.exports = function enhanceError(error, config, code, request, response) {
  636. error.config = config;
  637. if (code) {
  638. error.code = code;
  639. }
  640. error.request = request;
  641. error.response = response;
  642. error.isAxiosError = true;
  643. error.toJSON = function() {
  644. return {
  645. // Standard
  646. message: this.message,
  647. name: this.name,
  648. // Microsoft
  649. description: this.description,
  650. number: this.number,
  651. // Mozilla
  652. fileName: this.fileName,
  653. lineNumber: this.lineNumber,
  654. columnNumber: this.columnNumber,
  655. stack: this.stack,
  656. // Axios
  657. config: this.config,
  658. code: this.code
  659. };
  660. };
  661. return error;
  662. };
  663. /***/ }),
  664. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  665. /*!****************************************************!*\
  666. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  667. \****************************************************/
  668. /*! no static exports found */
  669. /***/ (function(module, exports, __webpack_require__) {
  670. "use strict";
  671. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  672. /**
  673. * Config-specific merge-function which creates a new config-object
  674. * by merging two configuration objects together.
  675. *
  676. * @param {Object} config1
  677. * @param {Object} config2
  678. * @returns {Object} New object resulting from merging config2 to config1
  679. */
  680. module.exports = function mergeConfig(config1, config2) {
  681. // eslint-disable-next-line no-param-reassign
  682. config2 = config2 || {};
  683. var config = {};
  684. utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
  685. if (typeof config2[prop] !== 'undefined') {
  686. config[prop] = config2[prop];
  687. }
  688. });
  689. utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
  690. if (utils.isObject(config2[prop])) {
  691. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  692. } else if (typeof config2[prop] !== 'undefined') {
  693. config[prop] = config2[prop];
  694. } else if (utils.isObject(config1[prop])) {
  695. config[prop] = utils.deepMerge(config1[prop]);
  696. } else if (typeof config1[prop] !== 'undefined') {
  697. config[prop] = config1[prop];
  698. }
  699. });
  700. utils.forEach([
  701. 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
  702. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  703. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
  704. 'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
  705. 'socketPath'
  706. ], function defaultToConfig2(prop) {
  707. if (typeof config2[prop] !== 'undefined') {
  708. config[prop] = config2[prop];
  709. } else if (typeof config1[prop] !== 'undefined') {
  710. config[prop] = config1[prop];
  711. }
  712. });
  713. return config;
  714. };
  715. /***/ }),
  716. /***/ "./node_modules/axios/lib/core/settle.js":
  717. /*!***********************************************!*\
  718. !*** ./node_modules/axios/lib/core/settle.js ***!
  719. \***********************************************/
  720. /*! no static exports found */
  721. /***/ (function(module, exports, __webpack_require__) {
  722. "use strict";
  723. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  724. /**
  725. * Resolve or reject a Promise based on response status.
  726. *
  727. * @param {Function} resolve A function that resolves the promise.
  728. * @param {Function} reject A function that rejects the promise.
  729. * @param {object} response The response.
  730. */
  731. module.exports = function settle(resolve, reject, response) {
  732. var validateStatus = response.config.validateStatus;
  733. if (!validateStatus || validateStatus(response.status)) {
  734. resolve(response);
  735. } else {
  736. reject(createError(
  737. 'Request failed with status code ' + response.status,
  738. response.config,
  739. null,
  740. response.request,
  741. response
  742. ));
  743. }
  744. };
  745. /***/ }),
  746. /***/ "./node_modules/axios/lib/core/transformData.js":
  747. /*!******************************************************!*\
  748. !*** ./node_modules/axios/lib/core/transformData.js ***!
  749. \******************************************************/
  750. /*! no static exports found */
  751. /***/ (function(module, exports, __webpack_require__) {
  752. "use strict";
  753. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  754. /**
  755. * Transform the data for a request or a response
  756. *
  757. * @param {Object|String} data The data to be transformed
  758. * @param {Array} headers The headers for the request or response
  759. * @param {Array|Function} fns A single function or Array of functions
  760. * @returns {*} The resulting transformed data
  761. */
  762. module.exports = function transformData(data, headers, fns) {
  763. /*eslint no-param-reassign:0*/
  764. utils.forEach(fns, function transform(fn) {
  765. data = fn(data, headers);
  766. });
  767. return data;
  768. };
  769. /***/ }),
  770. /***/ "./node_modules/axios/lib/defaults.js":
  771. /*!********************************************!*\
  772. !*** ./node_modules/axios/lib/defaults.js ***!
  773. \********************************************/
  774. /*! no static exports found */
  775. /***/ (function(module, exports, __webpack_require__) {
  776. "use strict";
  777. /* WEBPACK VAR INJECTION */(function(process) {
  778. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  779. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  780. var DEFAULT_CONTENT_TYPE = {
  781. 'Content-Type': 'application/x-www-form-urlencoded'
  782. };
  783. function setContentTypeIfUnset(headers, value) {
  784. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  785. headers['Content-Type'] = value;
  786. }
  787. }
  788. function getDefaultAdapter() {
  789. var adapter;
  790. // Only Node.JS has a process variable that is of [[Class]] process
  791. if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  792. // For node use HTTP adapter
  793. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  794. } else if (typeof XMLHttpRequest !== 'undefined') {
  795. // For browsers use XHR adapter
  796. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  797. }
  798. return adapter;
  799. }
  800. var defaults = {
  801. adapter: getDefaultAdapter(),
  802. transformRequest: [function transformRequest(data, headers) {
  803. normalizeHeaderName(headers, 'Accept');
  804. normalizeHeaderName(headers, 'Content-Type');
  805. if (utils.isFormData(data) ||
  806. utils.isArrayBuffer(data) ||
  807. utils.isBuffer(data) ||
  808. utils.isStream(data) ||
  809. utils.isFile(data) ||
  810. utils.isBlob(data)
  811. ) {
  812. return data;
  813. }
  814. if (utils.isArrayBufferView(data)) {
  815. return data.buffer;
  816. }
  817. if (utils.isURLSearchParams(data)) {
  818. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  819. return data.toString();
  820. }
  821. if (utils.isObject(data)) {
  822. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  823. return JSON.stringify(data);
  824. }
  825. return data;
  826. }],
  827. transformResponse: [function transformResponse(data) {
  828. /*eslint no-param-reassign:0*/
  829. if (typeof data === 'string') {
  830. try {
  831. data = JSON.parse(data);
  832. } catch (e) { /* Ignore */ }
  833. }
  834. return data;
  835. }],
  836. /**
  837. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  838. * timeout is not created.
  839. */
  840. timeout: 0,
  841. xsrfCookieName: 'XSRF-TOKEN',
  842. xsrfHeaderName: 'X-XSRF-TOKEN',
  843. maxContentLength: -1,
  844. validateStatus: function validateStatus(status) {
  845. return status >= 200 && status < 300;
  846. }
  847. };
  848. defaults.headers = {
  849. common: {
  850. 'Accept': 'application/json, text/plain, */*'
  851. }
  852. };
  853. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  854. defaults.headers[method] = {};
  855. });
  856. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  857. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  858. });
  859. module.exports = defaults;
  860. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  861. /***/ }),
  862. /***/ "./node_modules/axios/lib/helpers/bind.js":
  863. /*!************************************************!*\
  864. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  865. \************************************************/
  866. /*! no static exports found */
  867. /***/ (function(module, exports, __webpack_require__) {
  868. "use strict";
  869. module.exports = function bind(fn, thisArg) {
  870. return function wrap() {
  871. var args = new Array(arguments.length);
  872. for (var i = 0; i < args.length; i++) {
  873. args[i] = arguments[i];
  874. }
  875. return fn.apply(thisArg, args);
  876. };
  877. };
  878. /***/ }),
  879. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  880. /*!****************************************************!*\
  881. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  882. \****************************************************/
  883. /*! no static exports found */
  884. /***/ (function(module, exports, __webpack_require__) {
  885. "use strict";
  886. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  887. function encode(val) {
  888. return encodeURIComponent(val).
  889. replace(/%40/gi, '@').
  890. replace(/%3A/gi, ':').
  891. replace(/%24/g, '$').
  892. replace(/%2C/gi, ',').
  893. replace(/%20/g, '+').
  894. replace(/%5B/gi, '[').
  895. replace(/%5D/gi, ']');
  896. }
  897. /**
  898. * Build a URL by appending params to the end
  899. *
  900. * @param {string} url The base of the url (e.g., http://www.google.com)
  901. * @param {object} [params] The params to be appended
  902. * @returns {string} The formatted url
  903. */
  904. module.exports = function buildURL(url, params, paramsSerializer) {
  905. /*eslint no-param-reassign:0*/
  906. if (!params) {
  907. return url;
  908. }
  909. var serializedParams;
  910. if (paramsSerializer) {
  911. serializedParams = paramsSerializer(params);
  912. } else if (utils.isURLSearchParams(params)) {
  913. serializedParams = params.toString();
  914. } else {
  915. var parts = [];
  916. utils.forEach(params, function serialize(val, key) {
  917. if (val === null || typeof val === 'undefined') {
  918. return;
  919. }
  920. if (utils.isArray(val)) {
  921. key = key + '[]';
  922. } else {
  923. val = [val];
  924. }
  925. utils.forEach(val, function parseValue(v) {
  926. if (utils.isDate(v)) {
  927. v = v.toISOString();
  928. } else if (utils.isObject(v)) {
  929. v = JSON.stringify(v);
  930. }
  931. parts.push(encode(key) + '=' + encode(v));
  932. });
  933. });
  934. serializedParams = parts.join('&');
  935. }
  936. if (serializedParams) {
  937. var hashmarkIndex = url.indexOf('#');
  938. if (hashmarkIndex !== -1) {
  939. url = url.slice(0, hashmarkIndex);
  940. }
  941. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  942. }
  943. return url;
  944. };
  945. /***/ }),
  946. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  947. /*!*******************************************************!*\
  948. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  949. \*******************************************************/
  950. /*! no static exports found */
  951. /***/ (function(module, exports, __webpack_require__) {
  952. "use strict";
  953. /**
  954. * Creates a new URL by combining the specified URLs
  955. *
  956. * @param {string} baseURL The base URL
  957. * @param {string} relativeURL The relative URL
  958. * @returns {string} The combined URL
  959. */
  960. module.exports = function combineURLs(baseURL, relativeURL) {
  961. return relativeURL
  962. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  963. : baseURL;
  964. };
  965. /***/ }),
  966. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  967. /*!***************************************************!*\
  968. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  969. \***************************************************/
  970. /*! no static exports found */
  971. /***/ (function(module, exports, __webpack_require__) {
  972. "use strict";
  973. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  974. module.exports = (
  975. utils.isStandardBrowserEnv() ?
  976. // Standard browser envs support document.cookie
  977. (function standardBrowserEnv() {
  978. return {
  979. write: function write(name, value, expires, path, domain, secure) {
  980. var cookie = [];
  981. cookie.push(name + '=' + encodeURIComponent(value));
  982. if (utils.isNumber(expires)) {
  983. cookie.push('expires=' + new Date(expires).toGMTString());
  984. }
  985. if (utils.isString(path)) {
  986. cookie.push('path=' + path);
  987. }
  988. if (utils.isString(domain)) {
  989. cookie.push('domain=' + domain);
  990. }
  991. if (secure === true) {
  992. cookie.push('secure');
  993. }
  994. document.cookie = cookie.join('; ');
  995. },
  996. read: function read(name) {
  997. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  998. return (match ? decodeURIComponent(match[3]) : null);
  999. },
  1000. remove: function remove(name) {
  1001. this.write(name, '', Date.now() - 86400000);
  1002. }
  1003. };
  1004. })() :
  1005. // Non standard browser env (web workers, react-native) lack needed support.
  1006. (function nonStandardBrowserEnv() {
  1007. return {
  1008. write: function write() {},
  1009. read: function read() { return null; },
  1010. remove: function remove() {}
  1011. };
  1012. })()
  1013. );
  1014. /***/ }),
  1015. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1016. /*!*********************************************************!*\
  1017. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1018. \*********************************************************/
  1019. /*! no static exports found */
  1020. /***/ (function(module, exports, __webpack_require__) {
  1021. "use strict";
  1022. /**
  1023. * Determines whether the specified URL is absolute
  1024. *
  1025. * @param {string} url The URL to test
  1026. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1027. */
  1028. module.exports = function isAbsoluteURL(url) {
  1029. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1030. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1031. // by any combination of letters, digits, plus, period, or hyphen.
  1032. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1033. };
  1034. /***/ }),
  1035. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1036. /*!***********************************************************!*\
  1037. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1038. \***********************************************************/
  1039. /*! no static exports found */
  1040. /***/ (function(module, exports, __webpack_require__) {
  1041. "use strict";
  1042. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1043. module.exports = (
  1044. utils.isStandardBrowserEnv() ?
  1045. // Standard browser envs have full support of the APIs needed to test
  1046. // whether the request URL is of the same origin as current location.
  1047. (function standardBrowserEnv() {
  1048. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1049. var urlParsingNode = document.createElement('a');
  1050. var originURL;
  1051. /**
  1052. * Parse a URL to discover it's components
  1053. *
  1054. * @param {String} url The URL to be parsed
  1055. * @returns {Object}
  1056. */
  1057. function resolveURL(url) {
  1058. var href = url;
  1059. if (msie) {
  1060. // IE needs attribute set twice to normalize properties
  1061. urlParsingNode.setAttribute('href', href);
  1062. href = urlParsingNode.href;
  1063. }
  1064. urlParsingNode.setAttribute('href', href);
  1065. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1066. return {
  1067. href: urlParsingNode.href,
  1068. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1069. host: urlParsingNode.host,
  1070. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1071. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1072. hostname: urlParsingNode.hostname,
  1073. port: urlParsingNode.port,
  1074. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1075. urlParsingNode.pathname :
  1076. '/' + urlParsingNode.pathname
  1077. };
  1078. }
  1079. originURL = resolveURL(window.location.href);
  1080. /**
  1081. * Determine if a URL shares the same origin as the current location
  1082. *
  1083. * @param {String} requestURL The URL to test
  1084. * @returns {boolean} True if URL shares the same origin, otherwise false
  1085. */
  1086. return function isURLSameOrigin(requestURL) {
  1087. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1088. return (parsed.protocol === originURL.protocol &&
  1089. parsed.host === originURL.host);
  1090. };
  1091. })() :
  1092. // Non standard browser envs (web workers, react-native) lack needed support.
  1093. (function nonStandardBrowserEnv() {
  1094. return function isURLSameOrigin() {
  1095. return true;
  1096. };
  1097. })()
  1098. );
  1099. /***/ }),
  1100. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1101. /*!***************************************************************!*\
  1102. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1103. \***************************************************************/
  1104. /*! no static exports found */
  1105. /***/ (function(module, exports, __webpack_require__) {
  1106. "use strict";
  1107. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1108. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1109. utils.forEach(headers, function processHeader(value, name) {
  1110. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1111. headers[normalizedName] = value;
  1112. delete headers[name];
  1113. }
  1114. });
  1115. };
  1116. /***/ }),
  1117. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1118. /*!********************************************************!*\
  1119. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1120. \********************************************************/
  1121. /*! no static exports found */
  1122. /***/ (function(module, exports, __webpack_require__) {
  1123. "use strict";
  1124. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1125. // Headers whose duplicates are ignored by node
  1126. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1127. var ignoreDuplicateOf = [
  1128. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1129. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1130. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1131. 'referer', 'retry-after', 'user-agent'
  1132. ];
  1133. /**
  1134. * Parse headers into an object
  1135. *
  1136. * ```
  1137. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1138. * Content-Type: application/json
  1139. * Connection: keep-alive
  1140. * Transfer-Encoding: chunked
  1141. * ```
  1142. *
  1143. * @param {String} headers Headers needing to be parsed
  1144. * @returns {Object} Headers parsed into an object
  1145. */
  1146. module.exports = function parseHeaders(headers) {
  1147. var parsed = {};
  1148. var key;
  1149. var val;
  1150. var i;
  1151. if (!headers) { return parsed; }
  1152. utils.forEach(headers.split('\n'), function parser(line) {
  1153. i = line.indexOf(':');
  1154. key = utils.trim(line.substr(0, i)).toLowerCase();
  1155. val = utils.trim(line.substr(i + 1));
  1156. if (key) {
  1157. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1158. return;
  1159. }
  1160. if (key === 'set-cookie') {
  1161. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1162. } else {
  1163. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1164. }
  1165. }
  1166. });
  1167. return parsed;
  1168. };
  1169. /***/ }),
  1170. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1171. /*!**************************************************!*\
  1172. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1173. \**************************************************/
  1174. /*! no static exports found */
  1175. /***/ (function(module, exports, __webpack_require__) {
  1176. "use strict";
  1177. /**
  1178. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1179. *
  1180. * Common use case would be to use `Function.prototype.apply`.
  1181. *
  1182. * ```js
  1183. * function f(x, y, z) {}
  1184. * var args = [1, 2, 3];
  1185. * f.apply(null, args);
  1186. * ```
  1187. *
  1188. * With `spread` this example can be re-written.
  1189. *
  1190. * ```js
  1191. * spread(function(x, y, z) {})([1, 2, 3]);
  1192. * ```
  1193. *
  1194. * @param {Function} callback
  1195. * @returns {Function}
  1196. */
  1197. module.exports = function spread(callback) {
  1198. return function wrap(arr) {
  1199. return callback.apply(null, arr);
  1200. };
  1201. };
  1202. /***/ }),
  1203. /***/ "./node_modules/axios/lib/utils.js":
  1204. /*!*****************************************!*\
  1205. !*** ./node_modules/axios/lib/utils.js ***!
  1206. \*****************************************/
  1207. /*! no static exports found */
  1208. /***/ (function(module, exports, __webpack_require__) {
  1209. "use strict";
  1210. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1211. var isBuffer = __webpack_require__(/*! is-buffer */ "./node_modules/is-buffer/index.js");
  1212. /*global toString:true*/
  1213. // utils is a library of generic helper functions non-specific to axios
  1214. var toString = Object.prototype.toString;
  1215. /**
  1216. * Determine if a value is an Array
  1217. *
  1218. * @param {Object} val The value to test
  1219. * @returns {boolean} True if value is an Array, otherwise false
  1220. */
  1221. function isArray(val) {
  1222. return toString.call(val) === '[object Array]';
  1223. }
  1224. /**
  1225. * Determine if a value is an ArrayBuffer
  1226. *
  1227. * @param {Object} val The value to test
  1228. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1229. */
  1230. function isArrayBuffer(val) {
  1231. return toString.call(val) === '[object ArrayBuffer]';
  1232. }
  1233. /**
  1234. * Determine if a value is a FormData
  1235. *
  1236. * @param {Object} val The value to test
  1237. * @returns {boolean} True if value is an FormData, otherwise false
  1238. */
  1239. function isFormData(val) {
  1240. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1241. }
  1242. /**
  1243. * Determine if a value is a view on an ArrayBuffer
  1244. *
  1245. * @param {Object} val The value to test
  1246. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1247. */
  1248. function isArrayBufferView(val) {
  1249. var result;
  1250. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1251. result = ArrayBuffer.isView(val);
  1252. } else {
  1253. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1254. }
  1255. return result;
  1256. }
  1257. /**
  1258. * Determine if a value is a String
  1259. *
  1260. * @param {Object} val The value to test
  1261. * @returns {boolean} True if value is a String, otherwise false
  1262. */
  1263. function isString(val) {
  1264. return typeof val === 'string';
  1265. }
  1266. /**
  1267. * Determine if a value is a Number
  1268. *
  1269. * @param {Object} val The value to test
  1270. * @returns {boolean} True if value is a Number, otherwise false
  1271. */
  1272. function isNumber(val) {
  1273. return typeof val === 'number';
  1274. }
  1275. /**
  1276. * Determine if a value is undefined
  1277. *
  1278. * @param {Object} val The value to test
  1279. * @returns {boolean} True if the value is undefined, otherwise false
  1280. */
  1281. function isUndefined(val) {
  1282. return typeof val === 'undefined';
  1283. }
  1284. /**
  1285. * Determine if a value is an Object
  1286. *
  1287. * @param {Object} val The value to test
  1288. * @returns {boolean} True if value is an Object, otherwise false
  1289. */
  1290. function isObject(val) {
  1291. return val !== null && typeof val === 'object';
  1292. }
  1293. /**
  1294. * Determine if a value is a Date
  1295. *
  1296. * @param {Object} val The value to test
  1297. * @returns {boolean} True if value is a Date, otherwise false
  1298. */
  1299. function isDate(val) {
  1300. return toString.call(val) === '[object Date]';
  1301. }
  1302. /**
  1303. * Determine if a value is a File
  1304. *
  1305. * @param {Object} val The value to test
  1306. * @returns {boolean} True if value is a File, otherwise false
  1307. */
  1308. function isFile(val) {
  1309. return toString.call(val) === '[object File]';
  1310. }
  1311. /**
  1312. * Determine if a value is a Blob
  1313. *
  1314. * @param {Object} val The value to test
  1315. * @returns {boolean} True if value is a Blob, otherwise false
  1316. */
  1317. function isBlob(val) {
  1318. return toString.call(val) === '[object Blob]';
  1319. }
  1320. /**
  1321. * Determine if a value is a Function
  1322. *
  1323. * @param {Object} val The value to test
  1324. * @returns {boolean} True if value is a Function, otherwise false
  1325. */
  1326. function isFunction(val) {
  1327. return toString.call(val) === '[object Function]';
  1328. }
  1329. /**
  1330. * Determine if a value is a Stream
  1331. *
  1332. * @param {Object} val The value to test
  1333. * @returns {boolean} True if value is a Stream, otherwise false
  1334. */
  1335. function isStream(val) {
  1336. return isObject(val) && isFunction(val.pipe);
  1337. }
  1338. /**
  1339. * Determine if a value is a URLSearchParams object
  1340. *
  1341. * @param {Object} val The value to test
  1342. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1343. */
  1344. function isURLSearchParams(val) {
  1345. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1346. }
  1347. /**
  1348. * Trim excess whitespace off the beginning and end of a string
  1349. *
  1350. * @param {String} str The String to trim
  1351. * @returns {String} The String freed of excess whitespace
  1352. */
  1353. function trim(str) {
  1354. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1355. }
  1356. /**
  1357. * Determine if we're running in a standard browser environment
  1358. *
  1359. * This allows axios to run in a web worker, and react-native.
  1360. * Both environments support XMLHttpRequest, but not fully standard globals.
  1361. *
  1362. * web workers:
  1363. * typeof window -> undefined
  1364. * typeof document -> undefined
  1365. *
  1366. * react-native:
  1367. * navigator.product -> 'ReactNative'
  1368. * nativescript
  1369. * navigator.product -> 'NativeScript' or 'NS'
  1370. */
  1371. function isStandardBrowserEnv() {
  1372. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1373. navigator.product === 'NativeScript' ||
  1374. navigator.product === 'NS')) {
  1375. return false;
  1376. }
  1377. return (
  1378. typeof window !== 'undefined' &&
  1379. typeof document !== 'undefined'
  1380. );
  1381. }
  1382. /**
  1383. * Iterate over an Array or an Object invoking a function for each item.
  1384. *
  1385. * If `obj` is an Array callback will be called passing
  1386. * the value, index, and complete array for each item.
  1387. *
  1388. * If 'obj' is an Object callback will be called passing
  1389. * the value, key, and complete object for each property.
  1390. *
  1391. * @param {Object|Array} obj The object to iterate
  1392. * @param {Function} fn The callback to invoke for each item
  1393. */
  1394. function forEach(obj, fn) {
  1395. // Don't bother if no value provided
  1396. if (obj === null || typeof obj === 'undefined') {
  1397. return;
  1398. }
  1399. // Force an array if not already something iterable
  1400. if (typeof obj !== 'object') {
  1401. /*eslint no-param-reassign:0*/
  1402. obj = [obj];
  1403. }
  1404. if (isArray(obj)) {
  1405. // Iterate over array values
  1406. for (var i = 0, l = obj.length; i < l; i++) {
  1407. fn.call(null, obj[i], i, obj);
  1408. }
  1409. } else {
  1410. // Iterate over object keys
  1411. for (var key in obj) {
  1412. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1413. fn.call(null, obj[key], key, obj);
  1414. }
  1415. }
  1416. }
  1417. }
  1418. /**
  1419. * Accepts varargs expecting each argument to be an object, then
  1420. * immutably merges the properties of each object and returns result.
  1421. *
  1422. * When multiple objects contain the same key the later object in
  1423. * the arguments list will take precedence.
  1424. *
  1425. * Example:
  1426. *
  1427. * ```js
  1428. * var result = merge({foo: 123}, {foo: 456});
  1429. * console.log(result.foo); // outputs 456
  1430. * ```
  1431. *
  1432. * @param {Object} obj1 Object to merge
  1433. * @returns {Object} Result of all merge properties
  1434. */
  1435. function merge(/* obj1, obj2, obj3, ... */) {
  1436. var result = {};
  1437. function assignValue(val, key) {
  1438. if (typeof result[key] === 'object' && typeof val === 'object') {
  1439. result[key] = merge(result[key], val);
  1440. } else {
  1441. result[key] = val;
  1442. }
  1443. }
  1444. for (var i = 0, l = arguments.length; i < l; i++) {
  1445. forEach(arguments[i], assignValue);
  1446. }
  1447. return result;
  1448. }
  1449. /**
  1450. * Function equal to merge with the difference being that no reference
  1451. * to original objects is kept.
  1452. *
  1453. * @see merge
  1454. * @param {Object} obj1 Object to merge
  1455. * @returns {Object} Result of all merge properties
  1456. */
  1457. function deepMerge(/* obj1, obj2, obj3, ... */) {
  1458. var result = {};
  1459. function assignValue(val, key) {
  1460. if (typeof result[key] === 'object' && typeof val === 'object') {
  1461. result[key] = deepMerge(result[key], val);
  1462. } else if (typeof val === 'object') {
  1463. result[key] = deepMerge({}, val);
  1464. } else {
  1465. result[key] = val;
  1466. }
  1467. }
  1468. for (var i = 0, l = arguments.length; i < l; i++) {
  1469. forEach(arguments[i], assignValue);
  1470. }
  1471. return result;
  1472. }
  1473. /**
  1474. * Extends object a by mutably adding to it the properties of object b.
  1475. *
  1476. * @param {Object} a The object to be extended
  1477. * @param {Object} b The object to copy properties from
  1478. * @param {Object} thisArg The object to bind function to
  1479. * @return {Object} The resulting value of object a
  1480. */
  1481. function extend(a, b, thisArg) {
  1482. forEach(b, function assignValue(val, key) {
  1483. if (thisArg && typeof val === 'function') {
  1484. a[key] = bind(val, thisArg);
  1485. } else {
  1486. a[key] = val;
  1487. }
  1488. });
  1489. return a;
  1490. }
  1491. module.exports = {
  1492. isArray: isArray,
  1493. isArrayBuffer: isArrayBuffer,
  1494. isBuffer: isBuffer,
  1495. isFormData: isFormData,
  1496. isArrayBufferView: isArrayBufferView,
  1497. isString: isString,
  1498. isNumber: isNumber,
  1499. isObject: isObject,
  1500. isUndefined: isUndefined,
  1501. isDate: isDate,
  1502. isFile: isFile,
  1503. isBlob: isBlob,
  1504. isFunction: isFunction,
  1505. isStream: isStream,
  1506. isURLSearchParams: isURLSearchParams,
  1507. isStandardBrowserEnv: isStandardBrowserEnv,
  1508. forEach: forEach,
  1509. merge: merge,
  1510. deepMerge: deepMerge,
  1511. extend: extend,
  1512. trim: trim
  1513. };
  1514. /***/ }),
  1515. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1516. /*!*****************************************************!*\
  1517. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1518. \*****************************************************/
  1519. /*! no static exports found */
  1520. /***/ (function(module, exports, __webpack_require__) {
  1521. /*!
  1522. * Bootstrap v4.3.1 (https://getbootstrap.com/)
  1523. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1524. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1525. */
  1526. (function (global, factory) {
  1527. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1528. undefined;
  1529. }(this, function (exports, $, Popper) { 'use strict';
  1530. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1531. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1532. function _defineProperties(target, props) {
  1533. for (var i = 0; i < props.length; i++) {
  1534. var descriptor = props[i];
  1535. descriptor.enumerable = descriptor.enumerable || false;
  1536. descriptor.configurable = true;
  1537. if ("value" in descriptor) descriptor.writable = true;
  1538. Object.defineProperty(target, descriptor.key, descriptor);
  1539. }
  1540. }
  1541. function _createClass(Constructor, protoProps, staticProps) {
  1542. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1543. if (staticProps) _defineProperties(Constructor, staticProps);
  1544. return Constructor;
  1545. }
  1546. function _defineProperty(obj, key, value) {
  1547. if (key in obj) {
  1548. Object.defineProperty(obj, key, {
  1549. value: value,
  1550. enumerable: true,
  1551. configurable: true,
  1552. writable: true
  1553. });
  1554. } else {
  1555. obj[key] = value;
  1556. }
  1557. return obj;
  1558. }
  1559. function _objectSpread(target) {
  1560. for (var i = 1; i < arguments.length; i++) {
  1561. var source = arguments[i] != null ? arguments[i] : {};
  1562. var ownKeys = Object.keys(source);
  1563. if (typeof Object.getOwnPropertySymbols === 'function') {
  1564. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  1565. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  1566. }));
  1567. }
  1568. ownKeys.forEach(function (key) {
  1569. _defineProperty(target, key, source[key]);
  1570. });
  1571. }
  1572. return target;
  1573. }
  1574. function _inheritsLoose(subClass, superClass) {
  1575. subClass.prototype = Object.create(superClass.prototype);
  1576. subClass.prototype.constructor = subClass;
  1577. subClass.__proto__ = superClass;
  1578. }
  1579. /**
  1580. * --------------------------------------------------------------------------
  1581. * Bootstrap (v4.3.1): util.js
  1582. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1583. * --------------------------------------------------------------------------
  1584. */
  1585. /**
  1586. * ------------------------------------------------------------------------
  1587. * Private TransitionEnd Helpers
  1588. * ------------------------------------------------------------------------
  1589. */
  1590. var TRANSITION_END = 'transitionend';
  1591. var MAX_UID = 1000000;
  1592. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1593. function toType(obj) {
  1594. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1595. }
  1596. function getSpecialTransitionEndEvent() {
  1597. return {
  1598. bindType: TRANSITION_END,
  1599. delegateType: TRANSITION_END,
  1600. handle: function handle(event) {
  1601. if ($(event.target).is(this)) {
  1602. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1603. }
  1604. return undefined; // eslint-disable-line no-undefined
  1605. }
  1606. };
  1607. }
  1608. function transitionEndEmulator(duration) {
  1609. var _this = this;
  1610. var called = false;
  1611. $(this).one(Util.TRANSITION_END, function () {
  1612. called = true;
  1613. });
  1614. setTimeout(function () {
  1615. if (!called) {
  1616. Util.triggerTransitionEnd(_this);
  1617. }
  1618. }, duration);
  1619. return this;
  1620. }
  1621. function setTransitionEndSupport() {
  1622. $.fn.emulateTransitionEnd = transitionEndEmulator;
  1623. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  1624. }
  1625. /**
  1626. * --------------------------------------------------------------------------
  1627. * Public Util Api
  1628. * --------------------------------------------------------------------------
  1629. */
  1630. var Util = {
  1631. TRANSITION_END: 'bsTransitionEnd',
  1632. getUID: function getUID(prefix) {
  1633. do {
  1634. // eslint-disable-next-line no-bitwise
  1635. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  1636. } while (document.getElementById(prefix));
  1637. return prefix;
  1638. },
  1639. getSelectorFromElement: function getSelectorFromElement(element) {
  1640. var selector = element.getAttribute('data-target');
  1641. if (!selector || selector === '#') {
  1642. var hrefAttr = element.getAttribute('href');
  1643. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  1644. }
  1645. try {
  1646. return document.querySelector(selector) ? selector : null;
  1647. } catch (err) {
  1648. return null;
  1649. }
  1650. },
  1651. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  1652. if (!element) {
  1653. return 0;
  1654. } // Get transition-duration of the element
  1655. var transitionDuration = $(element).css('transition-duration');
  1656. var transitionDelay = $(element).css('transition-delay');
  1657. var floatTransitionDuration = parseFloat(transitionDuration);
  1658. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  1659. if (!floatTransitionDuration && !floatTransitionDelay) {
  1660. return 0;
  1661. } // If multiple durations are defined, take the first
  1662. transitionDuration = transitionDuration.split(',')[0];
  1663. transitionDelay = transitionDelay.split(',')[0];
  1664. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  1665. },
  1666. reflow: function reflow(element) {
  1667. return element.offsetHeight;
  1668. },
  1669. triggerTransitionEnd: function triggerTransitionEnd(element) {
  1670. $(element).trigger(TRANSITION_END);
  1671. },
  1672. // TODO: Remove in v5
  1673. supportsTransitionEnd: function supportsTransitionEnd() {
  1674. return Boolean(TRANSITION_END);
  1675. },
  1676. isElement: function isElement(obj) {
  1677. return (obj[0] || obj).nodeType;
  1678. },
  1679. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  1680. for (var property in configTypes) {
  1681. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  1682. var expectedTypes = configTypes[property];
  1683. var value = config[property];
  1684. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  1685. if (!new RegExp(expectedTypes).test(valueType)) {
  1686. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  1687. }
  1688. }
  1689. }
  1690. },
  1691. findShadowRoot: function findShadowRoot(element) {
  1692. if (!document.documentElement.attachShadow) {
  1693. return null;
  1694. } // Can find the shadow root otherwise it'll return the document
  1695. if (typeof element.getRootNode === 'function') {
  1696. var root = element.getRootNode();
  1697. return root instanceof ShadowRoot ? root : null;
  1698. }
  1699. if (element instanceof ShadowRoot) {
  1700. return element;
  1701. } // when we don't find a shadow root
  1702. if (!element.parentNode) {
  1703. return null;
  1704. }
  1705. return Util.findShadowRoot(element.parentNode);
  1706. }
  1707. };
  1708. setTransitionEndSupport();
  1709. /**
  1710. * ------------------------------------------------------------------------
  1711. * Constants
  1712. * ------------------------------------------------------------------------
  1713. */
  1714. var NAME = 'alert';
  1715. var VERSION = '4.3.1';
  1716. var DATA_KEY = 'bs.alert';
  1717. var EVENT_KEY = "." + DATA_KEY;
  1718. var DATA_API_KEY = '.data-api';
  1719. var JQUERY_NO_CONFLICT = $.fn[NAME];
  1720. var Selector = {
  1721. DISMISS: '[data-dismiss="alert"]'
  1722. };
  1723. var Event = {
  1724. CLOSE: "close" + EVENT_KEY,
  1725. CLOSED: "closed" + EVENT_KEY,
  1726. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  1727. };
  1728. var ClassName = {
  1729. ALERT: 'alert',
  1730. FADE: 'fade',
  1731. SHOW: 'show'
  1732. /**
  1733. * ------------------------------------------------------------------------
  1734. * Class Definition
  1735. * ------------------------------------------------------------------------
  1736. */
  1737. };
  1738. var Alert =
  1739. /*#__PURE__*/
  1740. function () {
  1741. function Alert(element) {
  1742. this._element = element;
  1743. } // Getters
  1744. var _proto = Alert.prototype;
  1745. // Public
  1746. _proto.close = function close(element) {
  1747. var rootElement = this._element;
  1748. if (element) {
  1749. rootElement = this._getRootElement(element);
  1750. }
  1751. var customEvent = this._triggerCloseEvent(rootElement);
  1752. if (customEvent.isDefaultPrevented()) {
  1753. return;
  1754. }
  1755. this._removeElement(rootElement);
  1756. };
  1757. _proto.dispose = function dispose() {
  1758. $.removeData(this._element, DATA_KEY);
  1759. this._element = null;
  1760. } // Private
  1761. ;
  1762. _proto._getRootElement = function _getRootElement(element) {
  1763. var selector = Util.getSelectorFromElement(element);
  1764. var parent = false;
  1765. if (selector) {
  1766. parent = document.querySelector(selector);
  1767. }
  1768. if (!parent) {
  1769. parent = $(element).closest("." + ClassName.ALERT)[0];
  1770. }
  1771. return parent;
  1772. };
  1773. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  1774. var closeEvent = $.Event(Event.CLOSE);
  1775. $(element).trigger(closeEvent);
  1776. return closeEvent;
  1777. };
  1778. _proto._removeElement = function _removeElement(element) {
  1779. var _this = this;
  1780. $(element).removeClass(ClassName.SHOW);
  1781. if (!$(element).hasClass(ClassName.FADE)) {
  1782. this._destroyElement(element);
  1783. return;
  1784. }
  1785. var transitionDuration = Util.getTransitionDurationFromElement(element);
  1786. $(element).one(Util.TRANSITION_END, function (event) {
  1787. return _this._destroyElement(element, event);
  1788. }).emulateTransitionEnd(transitionDuration);
  1789. };
  1790. _proto._destroyElement = function _destroyElement(element) {
  1791. $(element).detach().trigger(Event.CLOSED).remove();
  1792. } // Static
  1793. ;
  1794. Alert._jQueryInterface = function _jQueryInterface(config) {
  1795. return this.each(function () {
  1796. var $element = $(this);
  1797. var data = $element.data(DATA_KEY);
  1798. if (!data) {
  1799. data = new Alert(this);
  1800. $element.data(DATA_KEY, data);
  1801. }
  1802. if (config === 'close') {
  1803. data[config](this);
  1804. }
  1805. });
  1806. };
  1807. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  1808. return function (event) {
  1809. if (event) {
  1810. event.preventDefault();
  1811. }
  1812. alertInstance.close(this);
  1813. };
  1814. };
  1815. _createClass(Alert, null, [{
  1816. key: "VERSION",
  1817. get: function get() {
  1818. return VERSION;
  1819. }
  1820. }]);
  1821. return Alert;
  1822. }();
  1823. /**
  1824. * ------------------------------------------------------------------------
  1825. * Data Api implementation
  1826. * ------------------------------------------------------------------------
  1827. */
  1828. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  1829. /**
  1830. * ------------------------------------------------------------------------
  1831. * jQuery
  1832. * ------------------------------------------------------------------------
  1833. */
  1834. $.fn[NAME] = Alert._jQueryInterface;
  1835. $.fn[NAME].Constructor = Alert;
  1836. $.fn[NAME].noConflict = function () {
  1837. $.fn[NAME] = JQUERY_NO_CONFLICT;
  1838. return Alert._jQueryInterface;
  1839. };
  1840. /**
  1841. * ------------------------------------------------------------------------
  1842. * Constants
  1843. * ------------------------------------------------------------------------
  1844. */
  1845. var NAME$1 = 'button';
  1846. var VERSION$1 = '4.3.1';
  1847. var DATA_KEY$1 = 'bs.button';
  1848. var EVENT_KEY$1 = "." + DATA_KEY$1;
  1849. var DATA_API_KEY$1 = '.data-api';
  1850. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  1851. var ClassName$1 = {
  1852. ACTIVE: 'active',
  1853. BUTTON: 'btn',
  1854. FOCUS: 'focus'
  1855. };
  1856. var Selector$1 = {
  1857. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  1858. DATA_TOGGLE: '[data-toggle="buttons"]',
  1859. INPUT: 'input:not([type="hidden"])',
  1860. ACTIVE: '.active',
  1861. BUTTON: '.btn'
  1862. };
  1863. var Event$1 = {
  1864. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  1865. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1)
  1866. /**
  1867. * ------------------------------------------------------------------------
  1868. * Class Definition
  1869. * ------------------------------------------------------------------------
  1870. */
  1871. };
  1872. var Button =
  1873. /*#__PURE__*/
  1874. function () {
  1875. function Button(element) {
  1876. this._element = element;
  1877. } // Getters
  1878. var _proto = Button.prototype;
  1879. // Public
  1880. _proto.toggle = function toggle() {
  1881. var triggerChangeEvent = true;
  1882. var addAriaPressed = true;
  1883. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLE)[0];
  1884. if (rootElement) {
  1885. var input = this._element.querySelector(Selector$1.INPUT);
  1886. if (input) {
  1887. if (input.type === 'radio') {
  1888. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  1889. triggerChangeEvent = false;
  1890. } else {
  1891. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  1892. if (activeElement) {
  1893. $(activeElement).removeClass(ClassName$1.ACTIVE);
  1894. }
  1895. }
  1896. }
  1897. if (triggerChangeEvent) {
  1898. if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) {
  1899. return;
  1900. }
  1901. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  1902. $(input).trigger('change');
  1903. }
  1904. input.focus();
  1905. addAriaPressed = false;
  1906. }
  1907. }
  1908. if (addAriaPressed) {
  1909. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  1910. }
  1911. if (triggerChangeEvent) {
  1912. $(this._element).toggleClass(ClassName$1.ACTIVE);
  1913. }
  1914. };
  1915. _proto.dispose = function dispose() {
  1916. $.removeData(this._element, DATA_KEY$1);
  1917. this._element = null;
  1918. } // Static
  1919. ;
  1920. Button._jQueryInterface = function _jQueryInterface(config) {
  1921. return this.each(function () {
  1922. var data = $(this).data(DATA_KEY$1);
  1923. if (!data) {
  1924. data = new Button(this);
  1925. $(this).data(DATA_KEY$1, data);
  1926. }
  1927. if (config === 'toggle') {
  1928. data[config]();
  1929. }
  1930. });
  1931. };
  1932. _createClass(Button, null, [{
  1933. key: "VERSION",
  1934. get: function get() {
  1935. return VERSION$1;
  1936. }
  1937. }]);
  1938. return Button;
  1939. }();
  1940. /**
  1941. * ------------------------------------------------------------------------
  1942. * Data Api implementation
  1943. * ------------------------------------------------------------------------
  1944. */
  1945. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  1946. event.preventDefault();
  1947. var button = event.target;
  1948. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  1949. button = $(button).closest(Selector$1.BUTTON);
  1950. }
  1951. Button._jQueryInterface.call($(button), 'toggle');
  1952. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  1953. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  1954. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  1955. });
  1956. /**
  1957. * ------------------------------------------------------------------------
  1958. * jQuery
  1959. * ------------------------------------------------------------------------
  1960. */
  1961. $.fn[NAME$1] = Button._jQueryInterface;
  1962. $.fn[NAME$1].Constructor = Button;
  1963. $.fn[NAME$1].noConflict = function () {
  1964. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  1965. return Button._jQueryInterface;
  1966. };
  1967. /**
  1968. * ------------------------------------------------------------------------
  1969. * Constants
  1970. * ------------------------------------------------------------------------
  1971. */
  1972. var NAME$2 = 'carousel';
  1973. var VERSION$2 = '4.3.1';
  1974. var DATA_KEY$2 = 'bs.carousel';
  1975. var EVENT_KEY$2 = "." + DATA_KEY$2;
  1976. var DATA_API_KEY$2 = '.data-api';
  1977. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  1978. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  1979. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  1980. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  1981. var SWIPE_THRESHOLD = 40;
  1982. var Default = {
  1983. interval: 5000,
  1984. keyboard: true,
  1985. slide: false,
  1986. pause: 'hover',
  1987. wrap: true,
  1988. touch: true
  1989. };
  1990. var DefaultType = {
  1991. interval: '(number|boolean)',
  1992. keyboard: 'boolean',
  1993. slide: '(boolean|string)',
  1994. pause: '(string|boolean)',
  1995. wrap: 'boolean',
  1996. touch: 'boolean'
  1997. };
  1998. var Direction = {
  1999. NEXT: 'next',
  2000. PREV: 'prev',
  2001. LEFT: 'left',
  2002. RIGHT: 'right'
  2003. };
  2004. var Event$2 = {
  2005. SLIDE: "slide" + EVENT_KEY$2,
  2006. SLID: "slid" + EVENT_KEY$2,
  2007. KEYDOWN: "keydown" + EVENT_KEY$2,
  2008. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2009. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2010. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2011. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2012. TOUCHEND: "touchend" + EVENT_KEY$2,
  2013. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2014. POINTERUP: "pointerup" + EVENT_KEY$2,
  2015. DRAG_START: "dragstart" + EVENT_KEY$2,
  2016. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2017. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2018. };
  2019. var ClassName$2 = {
  2020. CAROUSEL: 'carousel',
  2021. ACTIVE: 'active',
  2022. SLIDE: 'slide',
  2023. RIGHT: 'carousel-item-right',
  2024. LEFT: 'carousel-item-left',
  2025. NEXT: 'carousel-item-next',
  2026. PREV: 'carousel-item-prev',
  2027. ITEM: 'carousel-item',
  2028. POINTER_EVENT: 'pointer-event'
  2029. };
  2030. var Selector$2 = {
  2031. ACTIVE: '.active',
  2032. ACTIVE_ITEM: '.active.carousel-item',
  2033. ITEM: '.carousel-item',
  2034. ITEM_IMG: '.carousel-item img',
  2035. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2036. INDICATORS: '.carousel-indicators',
  2037. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2038. DATA_RIDE: '[data-ride="carousel"]'
  2039. };
  2040. var PointerType = {
  2041. TOUCH: 'touch',
  2042. PEN: 'pen'
  2043. /**
  2044. * ------------------------------------------------------------------------
  2045. * Class Definition
  2046. * ------------------------------------------------------------------------
  2047. */
  2048. };
  2049. var Carousel =
  2050. /*#__PURE__*/
  2051. function () {
  2052. function Carousel(element, config) {
  2053. this._items = null;
  2054. this._interval = null;
  2055. this._activeElement = null;
  2056. this._isPaused = false;
  2057. this._isSliding = false;
  2058. this.touchTimeout = null;
  2059. this.touchStartX = 0;
  2060. this.touchDeltaX = 0;
  2061. this._config = this._getConfig(config);
  2062. this._element = element;
  2063. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2064. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2065. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2066. this._addEventListeners();
  2067. } // Getters
  2068. var _proto = Carousel.prototype;
  2069. // Public
  2070. _proto.next = function next() {
  2071. if (!this._isSliding) {
  2072. this._slide(Direction.NEXT);
  2073. }
  2074. };
  2075. _proto.nextWhenVisible = function nextWhenVisible() {
  2076. // Don't call next when the page isn't visible
  2077. // or the carousel or its parent isn't visible
  2078. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2079. this.next();
  2080. }
  2081. };
  2082. _proto.prev = function prev() {
  2083. if (!this._isSliding) {
  2084. this._slide(Direction.PREV);
  2085. }
  2086. };
  2087. _proto.pause = function pause(event) {
  2088. if (!event) {
  2089. this._isPaused = true;
  2090. }
  2091. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2092. Util.triggerTransitionEnd(this._element);
  2093. this.cycle(true);
  2094. }
  2095. clearInterval(this._interval);
  2096. this._interval = null;
  2097. };
  2098. _proto.cycle = function cycle(event) {
  2099. if (!event) {
  2100. this._isPaused = false;
  2101. }
  2102. if (this._interval) {
  2103. clearInterval(this._interval);
  2104. this._interval = null;
  2105. }
  2106. if (this._config.interval && !this._isPaused) {
  2107. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2108. }
  2109. };
  2110. _proto.to = function to(index) {
  2111. var _this = this;
  2112. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2113. var activeIndex = this._getItemIndex(this._activeElement);
  2114. if (index > this._items.length - 1 || index < 0) {
  2115. return;
  2116. }
  2117. if (this._isSliding) {
  2118. $(this._element).one(Event$2.SLID, function () {
  2119. return _this.to(index);
  2120. });
  2121. return;
  2122. }
  2123. if (activeIndex === index) {
  2124. this.pause();
  2125. this.cycle();
  2126. return;
  2127. }
  2128. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2129. this._slide(direction, this._items[index]);
  2130. };
  2131. _proto.dispose = function dispose() {
  2132. $(this._element).off(EVENT_KEY$2);
  2133. $.removeData(this._element, DATA_KEY$2);
  2134. this._items = null;
  2135. this._config = null;
  2136. this._element = null;
  2137. this._interval = null;
  2138. this._isPaused = null;
  2139. this._isSliding = null;
  2140. this._activeElement = null;
  2141. this._indicatorsElement = null;
  2142. } // Private
  2143. ;
  2144. _proto._getConfig = function _getConfig(config) {
  2145. config = _objectSpread({}, Default, config);
  2146. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2147. return config;
  2148. };
  2149. _proto._handleSwipe = function _handleSwipe() {
  2150. var absDeltax = Math.abs(this.touchDeltaX);
  2151. if (absDeltax <= SWIPE_THRESHOLD) {
  2152. return;
  2153. }
  2154. var direction = absDeltax / this.touchDeltaX; // swipe left
  2155. if (direction > 0) {
  2156. this.prev();
  2157. } // swipe right
  2158. if (direction < 0) {
  2159. this.next();
  2160. }
  2161. };
  2162. _proto._addEventListeners = function _addEventListeners() {
  2163. var _this2 = this;
  2164. if (this._config.keyboard) {
  2165. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2166. return _this2._keydown(event);
  2167. });
  2168. }
  2169. if (this._config.pause === 'hover') {
  2170. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2171. return _this2.pause(event);
  2172. }).on(Event$2.MOUSELEAVE, function (event) {
  2173. return _this2.cycle(event);
  2174. });
  2175. }
  2176. if (this._config.touch) {
  2177. this._addTouchEventListeners();
  2178. }
  2179. };
  2180. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2181. var _this3 = this;
  2182. if (!this._touchSupported) {
  2183. return;
  2184. }
  2185. var start = function start(event) {
  2186. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2187. _this3.touchStartX = event.originalEvent.clientX;
  2188. } else if (!_this3._pointerEvent) {
  2189. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2190. }
  2191. };
  2192. var move = function move(event) {
  2193. // ensure swiping with one touch and not pinching
  2194. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2195. _this3.touchDeltaX = 0;
  2196. } else {
  2197. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2198. }
  2199. };
  2200. var end = function end(event) {
  2201. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2202. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2203. }
  2204. _this3._handleSwipe();
  2205. if (_this3._config.pause === 'hover') {
  2206. // If it's a touch-enabled device, mouseenter/leave are fired as
  2207. // part of the mouse compatibility events on first tap - the carousel
  2208. // would stop cycling until user tapped out of it;
  2209. // here, we listen for touchend, explicitly pause the carousel
  2210. // (as if it's the second time we tap on it, mouseenter compat event
  2211. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2212. // events to fire) we explicitly restart cycling
  2213. _this3.pause();
  2214. if (_this3.touchTimeout) {
  2215. clearTimeout(_this3.touchTimeout);
  2216. }
  2217. _this3.touchTimeout = setTimeout(function (event) {
  2218. return _this3.cycle(event);
  2219. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2220. }
  2221. };
  2222. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2223. return e.preventDefault();
  2224. });
  2225. if (this._pointerEvent) {
  2226. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2227. return start(event);
  2228. });
  2229. $(this._element).on(Event$2.POINTERUP, function (event) {
  2230. return end(event);
  2231. });
  2232. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2233. } else {
  2234. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2235. return start(event);
  2236. });
  2237. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2238. return move(event);
  2239. });
  2240. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2241. return end(event);
  2242. });
  2243. }
  2244. };
  2245. _proto._keydown = function _keydown(event) {
  2246. if (/input|textarea/i.test(event.target.tagName)) {
  2247. return;
  2248. }
  2249. switch (event.which) {
  2250. case ARROW_LEFT_KEYCODE:
  2251. event.preventDefault();
  2252. this.prev();
  2253. break;
  2254. case ARROW_RIGHT_KEYCODE:
  2255. event.preventDefault();
  2256. this.next();
  2257. break;
  2258. default:
  2259. }
  2260. };
  2261. _proto._getItemIndex = function _getItemIndex(element) {
  2262. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2263. return this._items.indexOf(element);
  2264. };
  2265. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2266. var isNextDirection = direction === Direction.NEXT;
  2267. var isPrevDirection = direction === Direction.PREV;
  2268. var activeIndex = this._getItemIndex(activeElement);
  2269. var lastItemIndex = this._items.length - 1;
  2270. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2271. if (isGoingToWrap && !this._config.wrap) {
  2272. return activeElement;
  2273. }
  2274. var delta = direction === Direction.PREV ? -1 : 1;
  2275. var itemIndex = (activeIndex + delta) % this._items.length;
  2276. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2277. };
  2278. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2279. var targetIndex = this._getItemIndex(relatedTarget);
  2280. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2281. var slideEvent = $.Event(Event$2.SLIDE, {
  2282. relatedTarget: relatedTarget,
  2283. direction: eventDirectionName,
  2284. from: fromIndex,
  2285. to: targetIndex
  2286. });
  2287. $(this._element).trigger(slideEvent);
  2288. return slideEvent;
  2289. };
  2290. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2291. if (this._indicatorsElement) {
  2292. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2293. $(indicators).removeClass(ClassName$2.ACTIVE);
  2294. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2295. if (nextIndicator) {
  2296. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2297. }
  2298. }
  2299. };
  2300. _proto._slide = function _slide(direction, element) {
  2301. var _this4 = this;
  2302. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2303. var activeElementIndex = this._getItemIndex(activeElement);
  2304. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2305. var nextElementIndex = this._getItemIndex(nextElement);
  2306. var isCycling = Boolean(this._interval);
  2307. var directionalClassName;
  2308. var orderClassName;
  2309. var eventDirectionName;
  2310. if (direction === Direction.NEXT) {
  2311. directionalClassName = ClassName$2.LEFT;
  2312. orderClassName = ClassName$2.NEXT;
  2313. eventDirectionName = Direction.LEFT;
  2314. } else {
  2315. directionalClassName = ClassName$2.RIGHT;
  2316. orderClassName = ClassName$2.PREV;
  2317. eventDirectionName = Direction.RIGHT;
  2318. }
  2319. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2320. this._isSliding = false;
  2321. return;
  2322. }
  2323. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2324. if (slideEvent.isDefaultPrevented()) {
  2325. return;
  2326. }
  2327. if (!activeElement || !nextElement) {
  2328. // Some weirdness is happening, so we bail
  2329. return;
  2330. }
  2331. this._isSliding = true;
  2332. if (isCycling) {
  2333. this.pause();
  2334. }
  2335. this._setActiveIndicatorElement(nextElement);
  2336. var slidEvent = $.Event(Event$2.SLID, {
  2337. relatedTarget: nextElement,
  2338. direction: eventDirectionName,
  2339. from: activeElementIndex,
  2340. to: nextElementIndex
  2341. });
  2342. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2343. $(nextElement).addClass(orderClassName);
  2344. Util.reflow(nextElement);
  2345. $(activeElement).addClass(directionalClassName);
  2346. $(nextElement).addClass(directionalClassName);
  2347. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2348. if (nextElementInterval) {
  2349. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2350. this._config.interval = nextElementInterval;
  2351. } else {
  2352. this._config.interval = this._config.defaultInterval || this._config.interval;
  2353. }
  2354. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2355. $(activeElement).one(Util.TRANSITION_END, function () {
  2356. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2357. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2358. _this4._isSliding = false;
  2359. setTimeout(function () {
  2360. return $(_this4._element).trigger(slidEvent);
  2361. }, 0);
  2362. }).emulateTransitionEnd(transitionDuration);
  2363. } else {
  2364. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2365. $(nextElement).addClass(ClassName$2.ACTIVE);
  2366. this._isSliding = false;
  2367. $(this._element).trigger(slidEvent);
  2368. }
  2369. if (isCycling) {
  2370. this.cycle();
  2371. }
  2372. } // Static
  2373. ;
  2374. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2375. return this.each(function () {
  2376. var data = $(this).data(DATA_KEY$2);
  2377. var _config = _objectSpread({}, Default, $(this).data());
  2378. if (typeof config === 'object') {
  2379. _config = _objectSpread({}, _config, config);
  2380. }
  2381. var action = typeof config === 'string' ? config : _config.slide;
  2382. if (!data) {
  2383. data = new Carousel(this, _config);
  2384. $(this).data(DATA_KEY$2, data);
  2385. }
  2386. if (typeof config === 'number') {
  2387. data.to(config);
  2388. } else if (typeof action === 'string') {
  2389. if (typeof data[action] === 'undefined') {
  2390. throw new TypeError("No method named \"" + action + "\"");
  2391. }
  2392. data[action]();
  2393. } else if (_config.interval && _config.ride) {
  2394. data.pause();
  2395. data.cycle();
  2396. }
  2397. });
  2398. };
  2399. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2400. var selector = Util.getSelectorFromElement(this);
  2401. if (!selector) {
  2402. return;
  2403. }
  2404. var target = $(selector)[0];
  2405. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2406. return;
  2407. }
  2408. var config = _objectSpread({}, $(target).data(), $(this).data());
  2409. var slideIndex = this.getAttribute('data-slide-to');
  2410. if (slideIndex) {
  2411. config.interval = false;
  2412. }
  2413. Carousel._jQueryInterface.call($(target), config);
  2414. if (slideIndex) {
  2415. $(target).data(DATA_KEY$2).to(slideIndex);
  2416. }
  2417. event.preventDefault();
  2418. };
  2419. _createClass(Carousel, null, [{
  2420. key: "VERSION",
  2421. get: function get() {
  2422. return VERSION$2;
  2423. }
  2424. }, {
  2425. key: "Default",
  2426. get: function get() {
  2427. return Default;
  2428. }
  2429. }]);
  2430. return Carousel;
  2431. }();
  2432. /**
  2433. * ------------------------------------------------------------------------
  2434. * Data Api implementation
  2435. * ------------------------------------------------------------------------
  2436. */
  2437. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2438. $(window).on(Event$2.LOAD_DATA_API, function () {
  2439. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2440. for (var i = 0, len = carousels.length; i < len; i++) {
  2441. var $carousel = $(carousels[i]);
  2442. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2443. }
  2444. });
  2445. /**
  2446. * ------------------------------------------------------------------------
  2447. * jQuery
  2448. * ------------------------------------------------------------------------
  2449. */
  2450. $.fn[NAME$2] = Carousel._jQueryInterface;
  2451. $.fn[NAME$2].Constructor = Carousel;
  2452. $.fn[NAME$2].noConflict = function () {
  2453. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2454. return Carousel._jQueryInterface;
  2455. };
  2456. /**
  2457. * ------------------------------------------------------------------------
  2458. * Constants
  2459. * ------------------------------------------------------------------------
  2460. */
  2461. var NAME$3 = 'collapse';
  2462. var VERSION$3 = '4.3.1';
  2463. var DATA_KEY$3 = 'bs.collapse';
  2464. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2465. var DATA_API_KEY$3 = '.data-api';
  2466. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2467. var Default$1 = {
  2468. toggle: true,
  2469. parent: ''
  2470. };
  2471. var DefaultType$1 = {
  2472. toggle: 'boolean',
  2473. parent: '(string|element)'
  2474. };
  2475. var Event$3 = {
  2476. SHOW: "show" + EVENT_KEY$3,
  2477. SHOWN: "shown" + EVENT_KEY$3,
  2478. HIDE: "hide" + EVENT_KEY$3,
  2479. HIDDEN: "hidden" + EVENT_KEY$3,
  2480. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2481. };
  2482. var ClassName$3 = {
  2483. SHOW: 'show',
  2484. COLLAPSE: 'collapse',
  2485. COLLAPSING: 'collapsing',
  2486. COLLAPSED: 'collapsed'
  2487. };
  2488. var Dimension = {
  2489. WIDTH: 'width',
  2490. HEIGHT: 'height'
  2491. };
  2492. var Selector$3 = {
  2493. ACTIVES: '.show, .collapsing',
  2494. DATA_TOGGLE: '[data-toggle="collapse"]'
  2495. /**
  2496. * ------------------------------------------------------------------------
  2497. * Class Definition
  2498. * ------------------------------------------------------------------------
  2499. */
  2500. };
  2501. var Collapse =
  2502. /*#__PURE__*/
  2503. function () {
  2504. function Collapse(element, config) {
  2505. this._isTransitioning = false;
  2506. this._element = element;
  2507. this._config = this._getConfig(config);
  2508. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2509. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2510. for (var i = 0, len = toggleList.length; i < len; i++) {
  2511. var elem = toggleList[i];
  2512. var selector = Util.getSelectorFromElement(elem);
  2513. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2514. return foundElem === element;
  2515. });
  2516. if (selector !== null && filterElement.length > 0) {
  2517. this._selector = selector;
  2518. this._triggerArray.push(elem);
  2519. }
  2520. }
  2521. this._parent = this._config.parent ? this._getParent() : null;
  2522. if (!this._config.parent) {
  2523. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2524. }
  2525. if (this._config.toggle) {
  2526. this.toggle();
  2527. }
  2528. } // Getters
  2529. var _proto = Collapse.prototype;
  2530. // Public
  2531. _proto.toggle = function toggle() {
  2532. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2533. this.hide();
  2534. } else {
  2535. this.show();
  2536. }
  2537. };
  2538. _proto.show = function show() {
  2539. var _this = this;
  2540. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  2541. return;
  2542. }
  2543. var actives;
  2544. var activesData;
  2545. if (this._parent) {
  2546. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  2547. if (typeof _this._config.parent === 'string') {
  2548. return elem.getAttribute('data-parent') === _this._config.parent;
  2549. }
  2550. return elem.classList.contains(ClassName$3.COLLAPSE);
  2551. });
  2552. if (actives.length === 0) {
  2553. actives = null;
  2554. }
  2555. }
  2556. if (actives) {
  2557. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  2558. if (activesData && activesData._isTransitioning) {
  2559. return;
  2560. }
  2561. }
  2562. var startEvent = $.Event(Event$3.SHOW);
  2563. $(this._element).trigger(startEvent);
  2564. if (startEvent.isDefaultPrevented()) {
  2565. return;
  2566. }
  2567. if (actives) {
  2568. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  2569. if (!activesData) {
  2570. $(actives).data(DATA_KEY$3, null);
  2571. }
  2572. }
  2573. var dimension = this._getDimension();
  2574. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  2575. this._element.style[dimension] = 0;
  2576. if (this._triggerArray.length) {
  2577. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  2578. }
  2579. this.setTransitioning(true);
  2580. var complete = function complete() {
  2581. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  2582. _this._element.style[dimension] = '';
  2583. _this.setTransitioning(false);
  2584. $(_this._element).trigger(Event$3.SHOWN);
  2585. };
  2586. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  2587. var scrollSize = "scroll" + capitalizedDimension;
  2588. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2589. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2590. this._element.style[dimension] = this._element[scrollSize] + "px";
  2591. };
  2592. _proto.hide = function hide() {
  2593. var _this2 = this;
  2594. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  2595. return;
  2596. }
  2597. var startEvent = $.Event(Event$3.HIDE);
  2598. $(this._element).trigger(startEvent);
  2599. if (startEvent.isDefaultPrevented()) {
  2600. return;
  2601. }
  2602. var dimension = this._getDimension();
  2603. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  2604. Util.reflow(this._element);
  2605. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  2606. var triggerArrayLength = this._triggerArray.length;
  2607. if (triggerArrayLength > 0) {
  2608. for (var i = 0; i < triggerArrayLength; i++) {
  2609. var trigger = this._triggerArray[i];
  2610. var selector = Util.getSelectorFromElement(trigger);
  2611. if (selector !== null) {
  2612. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  2613. if (!$elem.hasClass(ClassName$3.SHOW)) {
  2614. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  2615. }
  2616. }
  2617. }
  2618. }
  2619. this.setTransitioning(true);
  2620. var complete = function complete() {
  2621. _this2.setTransitioning(false);
  2622. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  2623. };
  2624. this._element.style[dimension] = '';
  2625. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2626. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2627. };
  2628. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  2629. this._isTransitioning = isTransitioning;
  2630. };
  2631. _proto.dispose = function dispose() {
  2632. $.removeData(this._element, DATA_KEY$3);
  2633. this._config = null;
  2634. this._parent = null;
  2635. this._element = null;
  2636. this._triggerArray = null;
  2637. this._isTransitioning = null;
  2638. } // Private
  2639. ;
  2640. _proto._getConfig = function _getConfig(config) {
  2641. config = _objectSpread({}, Default$1, config);
  2642. config.toggle = Boolean(config.toggle); // Coerce string values
  2643. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  2644. return config;
  2645. };
  2646. _proto._getDimension = function _getDimension() {
  2647. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  2648. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  2649. };
  2650. _proto._getParent = function _getParent() {
  2651. var _this3 = this;
  2652. var parent;
  2653. if (Util.isElement(this._config.parent)) {
  2654. parent = this._config.parent; // It's a jQuery object
  2655. if (typeof this._config.parent.jquery !== 'undefined') {
  2656. parent = this._config.parent[0];
  2657. }
  2658. } else {
  2659. parent = document.querySelector(this._config.parent);
  2660. }
  2661. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  2662. var children = [].slice.call(parent.querySelectorAll(selector));
  2663. $(children).each(function (i, element) {
  2664. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  2665. });
  2666. return parent;
  2667. };
  2668. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  2669. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  2670. if (triggerArray.length) {
  2671. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  2672. }
  2673. } // Static
  2674. ;
  2675. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  2676. var selector = Util.getSelectorFromElement(element);
  2677. return selector ? document.querySelector(selector) : null;
  2678. };
  2679. Collapse._jQueryInterface = function _jQueryInterface(config) {
  2680. return this.each(function () {
  2681. var $this = $(this);
  2682. var data = $this.data(DATA_KEY$3);
  2683. var _config = _objectSpread({}, Default$1, $this.data(), typeof config === 'object' && config ? config : {});
  2684. if (!data && _config.toggle && /show|hide/.test(config)) {
  2685. _config.toggle = false;
  2686. }
  2687. if (!data) {
  2688. data = new Collapse(this, _config);
  2689. $this.data(DATA_KEY$3, data);
  2690. }
  2691. if (typeof config === 'string') {
  2692. if (typeof data[config] === 'undefined') {
  2693. throw new TypeError("No method named \"" + config + "\"");
  2694. }
  2695. data[config]();
  2696. }
  2697. });
  2698. };
  2699. _createClass(Collapse, null, [{
  2700. key: "VERSION",
  2701. get: function get() {
  2702. return VERSION$3;
  2703. }
  2704. }, {
  2705. key: "Default",
  2706. get: function get() {
  2707. return Default$1;
  2708. }
  2709. }]);
  2710. return Collapse;
  2711. }();
  2712. /**
  2713. * ------------------------------------------------------------------------
  2714. * Data Api implementation
  2715. * ------------------------------------------------------------------------
  2716. */
  2717. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  2718. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  2719. if (event.currentTarget.tagName === 'A') {
  2720. event.preventDefault();
  2721. }
  2722. var $trigger = $(this);
  2723. var selector = Util.getSelectorFromElement(this);
  2724. var selectors = [].slice.call(document.querySelectorAll(selector));
  2725. $(selectors).each(function () {
  2726. var $target = $(this);
  2727. var data = $target.data(DATA_KEY$3);
  2728. var config = data ? 'toggle' : $trigger.data();
  2729. Collapse._jQueryInterface.call($target, config);
  2730. });
  2731. });
  2732. /**
  2733. * ------------------------------------------------------------------------
  2734. * jQuery
  2735. * ------------------------------------------------------------------------
  2736. */
  2737. $.fn[NAME$3] = Collapse._jQueryInterface;
  2738. $.fn[NAME$3].Constructor = Collapse;
  2739. $.fn[NAME$3].noConflict = function () {
  2740. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  2741. return Collapse._jQueryInterface;
  2742. };
  2743. /**
  2744. * ------------------------------------------------------------------------
  2745. * Constants
  2746. * ------------------------------------------------------------------------
  2747. */
  2748. var NAME$4 = 'dropdown';
  2749. var VERSION$4 = '4.3.1';
  2750. var DATA_KEY$4 = 'bs.dropdown';
  2751. var EVENT_KEY$4 = "." + DATA_KEY$4;
  2752. var DATA_API_KEY$4 = '.data-api';
  2753. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  2754. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  2755. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  2756. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  2757. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  2758. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  2759. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  2760. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  2761. var Event$4 = {
  2762. HIDE: "hide" + EVENT_KEY$4,
  2763. HIDDEN: "hidden" + EVENT_KEY$4,
  2764. SHOW: "show" + EVENT_KEY$4,
  2765. SHOWN: "shown" + EVENT_KEY$4,
  2766. CLICK: "click" + EVENT_KEY$4,
  2767. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  2768. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  2769. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  2770. };
  2771. var ClassName$4 = {
  2772. DISABLED: 'disabled',
  2773. SHOW: 'show',
  2774. DROPUP: 'dropup',
  2775. DROPRIGHT: 'dropright',
  2776. DROPLEFT: 'dropleft',
  2777. MENURIGHT: 'dropdown-menu-right',
  2778. MENULEFT: 'dropdown-menu-left',
  2779. POSITION_STATIC: 'position-static'
  2780. };
  2781. var Selector$4 = {
  2782. DATA_TOGGLE: '[data-toggle="dropdown"]',
  2783. FORM_CHILD: '.dropdown form',
  2784. MENU: '.dropdown-menu',
  2785. NAVBAR_NAV: '.navbar-nav',
  2786. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  2787. };
  2788. var AttachmentMap = {
  2789. TOP: 'top-start',
  2790. TOPEND: 'top-end',
  2791. BOTTOM: 'bottom-start',
  2792. BOTTOMEND: 'bottom-end',
  2793. RIGHT: 'right-start',
  2794. RIGHTEND: 'right-end',
  2795. LEFT: 'left-start',
  2796. LEFTEND: 'left-end'
  2797. };
  2798. var Default$2 = {
  2799. offset: 0,
  2800. flip: true,
  2801. boundary: 'scrollParent',
  2802. reference: 'toggle',
  2803. display: 'dynamic'
  2804. };
  2805. var DefaultType$2 = {
  2806. offset: '(number|string|function)',
  2807. flip: 'boolean',
  2808. boundary: '(string|element)',
  2809. reference: '(string|element)',
  2810. display: 'string'
  2811. /**
  2812. * ------------------------------------------------------------------------
  2813. * Class Definition
  2814. * ------------------------------------------------------------------------
  2815. */
  2816. };
  2817. var Dropdown =
  2818. /*#__PURE__*/
  2819. function () {
  2820. function Dropdown(element, config) {
  2821. this._element = element;
  2822. this._popper = null;
  2823. this._config = this._getConfig(config);
  2824. this._menu = this._getMenuElement();
  2825. this._inNavbar = this._detectNavbar();
  2826. this._addEventListeners();
  2827. } // Getters
  2828. var _proto = Dropdown.prototype;
  2829. // Public
  2830. _proto.toggle = function toggle() {
  2831. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  2832. return;
  2833. }
  2834. var parent = Dropdown._getParentFromElement(this._element);
  2835. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  2836. Dropdown._clearMenus();
  2837. if (isActive) {
  2838. return;
  2839. }
  2840. var relatedTarget = {
  2841. relatedTarget: this._element
  2842. };
  2843. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  2844. $(parent).trigger(showEvent);
  2845. if (showEvent.isDefaultPrevented()) {
  2846. return;
  2847. } // Disable totally Popper.js for Dropdown in Navbar
  2848. if (!this._inNavbar) {
  2849. /**
  2850. * Check for Popper dependency
  2851. * Popper - https://popper.js.org
  2852. */
  2853. if (typeof Popper === 'undefined') {
  2854. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  2855. }
  2856. var referenceElement = this._element;
  2857. if (this._config.reference === 'parent') {
  2858. referenceElement = parent;
  2859. } else if (Util.isElement(this._config.reference)) {
  2860. referenceElement = this._config.reference; // Check if it's jQuery element
  2861. if (typeof this._config.reference.jquery !== 'undefined') {
  2862. referenceElement = this._config.reference[0];
  2863. }
  2864. } // If boundary is not `scrollParent`, then set position to `static`
  2865. // to allow the menu to "escape" the scroll parent's boundaries
  2866. // https://github.com/twbs/bootstrap/issues/24251
  2867. if (this._config.boundary !== 'scrollParent') {
  2868. $(parent).addClass(ClassName$4.POSITION_STATIC);
  2869. }
  2870. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  2871. } // If this is a touch-enabled device we add extra
  2872. // empty mouseover listeners to the body's immediate children;
  2873. // only needed because of broken event delegation on iOS
  2874. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  2875. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  2876. $(document.body).children().on('mouseover', null, $.noop);
  2877. }
  2878. this._element.focus();
  2879. this._element.setAttribute('aria-expanded', true);
  2880. $(this._menu).toggleClass(ClassName$4.SHOW);
  2881. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  2882. };
  2883. _proto.show = function show() {
  2884. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  2885. return;
  2886. }
  2887. var relatedTarget = {
  2888. relatedTarget: this._element
  2889. };
  2890. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  2891. var parent = Dropdown._getParentFromElement(this._element);
  2892. $(parent).trigger(showEvent);
  2893. if (showEvent.isDefaultPrevented()) {
  2894. return;
  2895. }
  2896. $(this._menu).toggleClass(ClassName$4.SHOW);
  2897. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  2898. };
  2899. _proto.hide = function hide() {
  2900. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  2901. return;
  2902. }
  2903. var relatedTarget = {
  2904. relatedTarget: this._element
  2905. };
  2906. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  2907. var parent = Dropdown._getParentFromElement(this._element);
  2908. $(parent).trigger(hideEvent);
  2909. if (hideEvent.isDefaultPrevented()) {
  2910. return;
  2911. }
  2912. $(this._menu).toggleClass(ClassName$4.SHOW);
  2913. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  2914. };
  2915. _proto.dispose = function dispose() {
  2916. $.removeData(this._element, DATA_KEY$4);
  2917. $(this._element).off(EVENT_KEY$4);
  2918. this._element = null;
  2919. this._menu = null;
  2920. if (this._popper !== null) {
  2921. this._popper.destroy();
  2922. this._popper = null;
  2923. }
  2924. };
  2925. _proto.update = function update() {
  2926. this._inNavbar = this._detectNavbar();
  2927. if (this._popper !== null) {
  2928. this._popper.scheduleUpdate();
  2929. }
  2930. } // Private
  2931. ;
  2932. _proto._addEventListeners = function _addEventListeners() {
  2933. var _this = this;
  2934. $(this._element).on(Event$4.CLICK, function (event) {
  2935. event.preventDefault();
  2936. event.stopPropagation();
  2937. _this.toggle();
  2938. });
  2939. };
  2940. _proto._getConfig = function _getConfig(config) {
  2941. config = _objectSpread({}, this.constructor.Default, $(this._element).data(), config);
  2942. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  2943. return config;
  2944. };
  2945. _proto._getMenuElement = function _getMenuElement() {
  2946. if (!this._menu) {
  2947. var parent = Dropdown._getParentFromElement(this._element);
  2948. if (parent) {
  2949. this._menu = parent.querySelector(Selector$4.MENU);
  2950. }
  2951. }
  2952. return this._menu;
  2953. };
  2954. _proto._getPlacement = function _getPlacement() {
  2955. var $parentDropdown = $(this._element.parentNode);
  2956. var placement = AttachmentMap.BOTTOM; // Handle dropup
  2957. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  2958. placement = AttachmentMap.TOP;
  2959. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  2960. placement = AttachmentMap.TOPEND;
  2961. }
  2962. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  2963. placement = AttachmentMap.RIGHT;
  2964. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  2965. placement = AttachmentMap.LEFT;
  2966. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  2967. placement = AttachmentMap.BOTTOMEND;
  2968. }
  2969. return placement;
  2970. };
  2971. _proto._detectNavbar = function _detectNavbar() {
  2972. return $(this._element).closest('.navbar').length > 0;
  2973. };
  2974. _proto._getOffset = function _getOffset() {
  2975. var _this2 = this;
  2976. var offset = {};
  2977. if (typeof this._config.offset === 'function') {
  2978. offset.fn = function (data) {
  2979. data.offsets = _objectSpread({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {});
  2980. return data;
  2981. };
  2982. } else {
  2983. offset.offset = this._config.offset;
  2984. }
  2985. return offset;
  2986. };
  2987. _proto._getPopperConfig = function _getPopperConfig() {
  2988. var popperConfig = {
  2989. placement: this._getPlacement(),
  2990. modifiers: {
  2991. offset: this._getOffset(),
  2992. flip: {
  2993. enabled: this._config.flip
  2994. },
  2995. preventOverflow: {
  2996. boundariesElement: this._config.boundary
  2997. }
  2998. } // Disable Popper.js if we have a static display
  2999. };
  3000. if (this._config.display === 'static') {
  3001. popperConfig.modifiers.applyStyle = {
  3002. enabled: false
  3003. };
  3004. }
  3005. return popperConfig;
  3006. } // Static
  3007. ;
  3008. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3009. return this.each(function () {
  3010. var data = $(this).data(DATA_KEY$4);
  3011. var _config = typeof config === 'object' ? config : null;
  3012. if (!data) {
  3013. data = new Dropdown(this, _config);
  3014. $(this).data(DATA_KEY$4, data);
  3015. }
  3016. if (typeof config === 'string') {
  3017. if (typeof data[config] === 'undefined') {
  3018. throw new TypeError("No method named \"" + config + "\"");
  3019. }
  3020. data[config]();
  3021. }
  3022. });
  3023. };
  3024. Dropdown._clearMenus = function _clearMenus(event) {
  3025. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3026. return;
  3027. }
  3028. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3029. for (var i = 0, len = toggles.length; i < len; i++) {
  3030. var parent = Dropdown._getParentFromElement(toggles[i]);
  3031. var context = $(toggles[i]).data(DATA_KEY$4);
  3032. var relatedTarget = {
  3033. relatedTarget: toggles[i]
  3034. };
  3035. if (event && event.type === 'click') {
  3036. relatedTarget.clickEvent = event;
  3037. }
  3038. if (!context) {
  3039. continue;
  3040. }
  3041. var dropdownMenu = context._menu;
  3042. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3043. continue;
  3044. }
  3045. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3046. continue;
  3047. }
  3048. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3049. $(parent).trigger(hideEvent);
  3050. if (hideEvent.isDefaultPrevented()) {
  3051. continue;
  3052. } // If this is a touch-enabled device we remove the extra
  3053. // empty mouseover listeners we added for iOS support
  3054. if ('ontouchstart' in document.documentElement) {
  3055. $(document.body).children().off('mouseover', null, $.noop);
  3056. }
  3057. toggles[i].setAttribute('aria-expanded', 'false');
  3058. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3059. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3060. }
  3061. };
  3062. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3063. var parent;
  3064. var selector = Util.getSelectorFromElement(element);
  3065. if (selector) {
  3066. parent = document.querySelector(selector);
  3067. }
  3068. return parent || element.parentNode;
  3069. } // eslint-disable-next-line complexity
  3070. ;
  3071. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3072. // If not input/textarea:
  3073. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3074. // If input/textarea:
  3075. // - If space key => not a dropdown command
  3076. // - If key is other than escape
  3077. // - If key is not up or down => not a dropdown command
  3078. // - If trigger inside the menu => not a dropdown command
  3079. if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(Selector$4.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
  3080. return;
  3081. }
  3082. event.preventDefault();
  3083. event.stopPropagation();
  3084. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3085. return;
  3086. }
  3087. var parent = Dropdown._getParentFromElement(this);
  3088. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3089. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3090. if (event.which === ESCAPE_KEYCODE) {
  3091. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3092. $(toggle).trigger('focus');
  3093. }
  3094. $(this).trigger('click');
  3095. return;
  3096. }
  3097. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS));
  3098. if (items.length === 0) {
  3099. return;
  3100. }
  3101. var index = items.indexOf(event.target);
  3102. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3103. // Up
  3104. index--;
  3105. }
  3106. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3107. // Down
  3108. index++;
  3109. }
  3110. if (index < 0) {
  3111. index = 0;
  3112. }
  3113. items[index].focus();
  3114. };
  3115. _createClass(Dropdown, null, [{
  3116. key: "VERSION",
  3117. get: function get() {
  3118. return VERSION$4;
  3119. }
  3120. }, {
  3121. key: "Default",
  3122. get: function get() {
  3123. return Default$2;
  3124. }
  3125. }, {
  3126. key: "DefaultType",
  3127. get: function get() {
  3128. return DefaultType$2;
  3129. }
  3130. }]);
  3131. return Dropdown;
  3132. }();
  3133. /**
  3134. * ------------------------------------------------------------------------
  3135. * Data Api implementation
  3136. * ------------------------------------------------------------------------
  3137. */
  3138. $(document).on(Event$4.KEYDOWN_DATA_API, Selector$4.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event$4.KEYDOWN_DATA_API, Selector$4.MENU, Dropdown._dataApiKeydownHandler).on(Event$4.CLICK_DATA_API + " " + Event$4.KEYUP_DATA_API, Dropdown._clearMenus).on(Event$4.CLICK_DATA_API, Selector$4.DATA_TOGGLE, function (event) {
  3139. event.preventDefault();
  3140. event.stopPropagation();
  3141. Dropdown._jQueryInterface.call($(this), 'toggle');
  3142. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3143. e.stopPropagation();
  3144. });
  3145. /**
  3146. * ------------------------------------------------------------------------
  3147. * jQuery
  3148. * ------------------------------------------------------------------------
  3149. */
  3150. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3151. $.fn[NAME$4].Constructor = Dropdown;
  3152. $.fn[NAME$4].noConflict = function () {
  3153. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3154. return Dropdown._jQueryInterface;
  3155. };
  3156. /**
  3157. * ------------------------------------------------------------------------
  3158. * Constants
  3159. * ------------------------------------------------------------------------
  3160. */
  3161. var NAME$5 = 'modal';
  3162. var VERSION$5 = '4.3.1';
  3163. var DATA_KEY$5 = 'bs.modal';
  3164. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3165. var DATA_API_KEY$5 = '.data-api';
  3166. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3167. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3168. var Default$3 = {
  3169. backdrop: true,
  3170. keyboard: true,
  3171. focus: true,
  3172. show: true
  3173. };
  3174. var DefaultType$3 = {
  3175. backdrop: '(boolean|string)',
  3176. keyboard: 'boolean',
  3177. focus: 'boolean',
  3178. show: 'boolean'
  3179. };
  3180. var Event$5 = {
  3181. HIDE: "hide" + EVENT_KEY$5,
  3182. HIDDEN: "hidden" + EVENT_KEY$5,
  3183. SHOW: "show" + EVENT_KEY$5,
  3184. SHOWN: "shown" + EVENT_KEY$5,
  3185. FOCUSIN: "focusin" + EVENT_KEY$5,
  3186. RESIZE: "resize" + EVENT_KEY$5,
  3187. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3188. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3189. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3190. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3191. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3192. };
  3193. var ClassName$5 = {
  3194. SCROLLABLE: 'modal-dialog-scrollable',
  3195. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3196. BACKDROP: 'modal-backdrop',
  3197. OPEN: 'modal-open',
  3198. FADE: 'fade',
  3199. SHOW: 'show'
  3200. };
  3201. var Selector$5 = {
  3202. DIALOG: '.modal-dialog',
  3203. MODAL_BODY: '.modal-body',
  3204. DATA_TOGGLE: '[data-toggle="modal"]',
  3205. DATA_DISMISS: '[data-dismiss="modal"]',
  3206. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3207. STICKY_CONTENT: '.sticky-top'
  3208. /**
  3209. * ------------------------------------------------------------------------
  3210. * Class Definition
  3211. * ------------------------------------------------------------------------
  3212. */
  3213. };
  3214. var Modal =
  3215. /*#__PURE__*/
  3216. function () {
  3217. function Modal(element, config) {
  3218. this._config = this._getConfig(config);
  3219. this._element = element;
  3220. this._dialog = element.querySelector(Selector$5.DIALOG);
  3221. this._backdrop = null;
  3222. this._isShown = false;
  3223. this._isBodyOverflowing = false;
  3224. this._ignoreBackdropClick = false;
  3225. this._isTransitioning = false;
  3226. this._scrollbarWidth = 0;
  3227. } // Getters
  3228. var _proto = Modal.prototype;
  3229. // Public
  3230. _proto.toggle = function toggle(relatedTarget) {
  3231. return this._isShown ? this.hide() : this.show(relatedTarget);
  3232. };
  3233. _proto.show = function show(relatedTarget) {
  3234. var _this = this;
  3235. if (this._isShown || this._isTransitioning) {
  3236. return;
  3237. }
  3238. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3239. this._isTransitioning = true;
  3240. }
  3241. var showEvent = $.Event(Event$5.SHOW, {
  3242. relatedTarget: relatedTarget
  3243. });
  3244. $(this._element).trigger(showEvent);
  3245. if (this._isShown || showEvent.isDefaultPrevented()) {
  3246. return;
  3247. }
  3248. this._isShown = true;
  3249. this._checkScrollbar();
  3250. this._setScrollbar();
  3251. this._adjustDialog();
  3252. this._setEscapeEvent();
  3253. this._setResizeEvent();
  3254. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3255. return _this.hide(event);
  3256. });
  3257. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3258. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3259. if ($(event.target).is(_this._element)) {
  3260. _this._ignoreBackdropClick = true;
  3261. }
  3262. });
  3263. });
  3264. this._showBackdrop(function () {
  3265. return _this._showElement(relatedTarget);
  3266. });
  3267. };
  3268. _proto.hide = function hide(event) {
  3269. var _this2 = this;
  3270. if (event) {
  3271. event.preventDefault();
  3272. }
  3273. if (!this._isShown || this._isTransitioning) {
  3274. return;
  3275. }
  3276. var hideEvent = $.Event(Event$5.HIDE);
  3277. $(this._element).trigger(hideEvent);
  3278. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3279. return;
  3280. }
  3281. this._isShown = false;
  3282. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3283. if (transition) {
  3284. this._isTransitioning = true;
  3285. }
  3286. this._setEscapeEvent();
  3287. this._setResizeEvent();
  3288. $(document).off(Event$5.FOCUSIN);
  3289. $(this._element).removeClass(ClassName$5.SHOW);
  3290. $(this._element).off(Event$5.CLICK_DISMISS);
  3291. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3292. if (transition) {
  3293. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3294. $(this._element).one(Util.TRANSITION_END, function (event) {
  3295. return _this2._hideModal(event);
  3296. }).emulateTransitionEnd(transitionDuration);
  3297. } else {
  3298. this._hideModal();
  3299. }
  3300. };
  3301. _proto.dispose = function dispose() {
  3302. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3303. return $(htmlElement).off(EVENT_KEY$5);
  3304. });
  3305. /**
  3306. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3307. * Do not move `document` in `htmlElements` array
  3308. * It will remove `Event.CLICK_DATA_API` event that should remain
  3309. */
  3310. $(document).off(Event$5.FOCUSIN);
  3311. $.removeData(this._element, DATA_KEY$5);
  3312. this._config = null;
  3313. this._element = null;
  3314. this._dialog = null;
  3315. this._backdrop = null;
  3316. this._isShown = null;
  3317. this._isBodyOverflowing = null;
  3318. this._ignoreBackdropClick = null;
  3319. this._isTransitioning = null;
  3320. this._scrollbarWidth = null;
  3321. };
  3322. _proto.handleUpdate = function handleUpdate() {
  3323. this._adjustDialog();
  3324. } // Private
  3325. ;
  3326. _proto._getConfig = function _getConfig(config) {
  3327. config = _objectSpread({}, Default$3, config);
  3328. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3329. return config;
  3330. };
  3331. _proto._showElement = function _showElement(relatedTarget) {
  3332. var _this3 = this;
  3333. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3334. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3335. // Don't move modal's DOM position
  3336. document.body.appendChild(this._element);
  3337. }
  3338. this._element.style.display = 'block';
  3339. this._element.removeAttribute('aria-hidden');
  3340. this._element.setAttribute('aria-modal', true);
  3341. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE)) {
  3342. this._dialog.querySelector(Selector$5.MODAL_BODY).scrollTop = 0;
  3343. } else {
  3344. this._element.scrollTop = 0;
  3345. }
  3346. if (transition) {
  3347. Util.reflow(this._element);
  3348. }
  3349. $(this._element).addClass(ClassName$5.SHOW);
  3350. if (this._config.focus) {
  3351. this._enforceFocus();
  3352. }
  3353. var shownEvent = $.Event(Event$5.SHOWN, {
  3354. relatedTarget: relatedTarget
  3355. });
  3356. var transitionComplete = function transitionComplete() {
  3357. if (_this3._config.focus) {
  3358. _this3._element.focus();
  3359. }
  3360. _this3._isTransitioning = false;
  3361. $(_this3._element).trigger(shownEvent);
  3362. };
  3363. if (transition) {
  3364. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3365. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3366. } else {
  3367. transitionComplete();
  3368. }
  3369. };
  3370. _proto._enforceFocus = function _enforceFocus() {
  3371. var _this4 = this;
  3372. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3373. .on(Event$5.FOCUSIN, function (event) {
  3374. if (document !== event.target && _this4._element !== event.target && $(_this4._element).has(event.target).length === 0) {
  3375. _this4._element.focus();
  3376. }
  3377. });
  3378. };
  3379. _proto._setEscapeEvent = function _setEscapeEvent() {
  3380. var _this5 = this;
  3381. if (this._isShown && this._config.keyboard) {
  3382. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3383. if (event.which === ESCAPE_KEYCODE$1) {
  3384. event.preventDefault();
  3385. _this5.hide();
  3386. }
  3387. });
  3388. } else if (!this._isShown) {
  3389. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3390. }
  3391. };
  3392. _proto._setResizeEvent = function _setResizeEvent() {
  3393. var _this6 = this;
  3394. if (this._isShown) {
  3395. $(window).on(Event$5.RESIZE, function (event) {
  3396. return _this6.handleUpdate(event);
  3397. });
  3398. } else {
  3399. $(window).off(Event$5.RESIZE);
  3400. }
  3401. };
  3402. _proto._hideModal = function _hideModal() {
  3403. var _this7 = this;
  3404. this._element.style.display = 'none';
  3405. this._element.setAttribute('aria-hidden', true);
  3406. this._element.removeAttribute('aria-modal');
  3407. this._isTransitioning = false;
  3408. this._showBackdrop(function () {
  3409. $(document.body).removeClass(ClassName$5.OPEN);
  3410. _this7._resetAdjustments();
  3411. _this7._resetScrollbar();
  3412. $(_this7._element).trigger(Event$5.HIDDEN);
  3413. });
  3414. };
  3415. _proto._removeBackdrop = function _removeBackdrop() {
  3416. if (this._backdrop) {
  3417. $(this._backdrop).remove();
  3418. this._backdrop = null;
  3419. }
  3420. };
  3421. _proto._showBackdrop = function _showBackdrop(callback) {
  3422. var _this8 = this;
  3423. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3424. if (this._isShown && this._config.backdrop) {
  3425. this._backdrop = document.createElement('div');
  3426. this._backdrop.className = ClassName$5.BACKDROP;
  3427. if (animate) {
  3428. this._backdrop.classList.add(animate);
  3429. }
  3430. $(this._backdrop).appendTo(document.body);
  3431. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3432. if (_this8._ignoreBackdropClick) {
  3433. _this8._ignoreBackdropClick = false;
  3434. return;
  3435. }
  3436. if (event.target !== event.currentTarget) {
  3437. return;
  3438. }
  3439. if (_this8._config.backdrop === 'static') {
  3440. _this8._element.focus();
  3441. } else {
  3442. _this8.hide();
  3443. }
  3444. });
  3445. if (animate) {
  3446. Util.reflow(this._backdrop);
  3447. }
  3448. $(this._backdrop).addClass(ClassName$5.SHOW);
  3449. if (!callback) {
  3450. return;
  3451. }
  3452. if (!animate) {
  3453. callback();
  3454. return;
  3455. }
  3456. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3457. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3458. } else if (!this._isShown && this._backdrop) {
  3459. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3460. var callbackRemove = function callbackRemove() {
  3461. _this8._removeBackdrop();
  3462. if (callback) {
  3463. callback();
  3464. }
  3465. };
  3466. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3467. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3468. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3469. } else {
  3470. callbackRemove();
  3471. }
  3472. } else if (callback) {
  3473. callback();
  3474. }
  3475. } // ----------------------------------------------------------------------
  3476. // the following methods are used to handle overflowing modals
  3477. // todo (fat): these should probably be refactored out of modal.js
  3478. // ----------------------------------------------------------------------
  3479. ;
  3480. _proto._adjustDialog = function _adjustDialog() {
  3481. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3482. if (!this._isBodyOverflowing && isModalOverflowing) {
  3483. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3484. }
  3485. if (this._isBodyOverflowing && !isModalOverflowing) {
  3486. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3487. }
  3488. };
  3489. _proto._resetAdjustments = function _resetAdjustments() {
  3490. this._element.style.paddingLeft = '';
  3491. this._element.style.paddingRight = '';
  3492. };
  3493. _proto._checkScrollbar = function _checkScrollbar() {
  3494. var rect = document.body.getBoundingClientRect();
  3495. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3496. this._scrollbarWidth = this._getScrollbarWidth();
  3497. };
  3498. _proto._setScrollbar = function _setScrollbar() {
  3499. var _this9 = this;
  3500. if (this._isBodyOverflowing) {
  3501. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3502. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3503. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3504. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3505. $(fixedContent).each(function (index, element) {
  3506. var actualPadding = element.style.paddingRight;
  3507. var calculatedPadding = $(element).css('padding-right');
  3508. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this9._scrollbarWidth + "px");
  3509. }); // Adjust sticky content margin
  3510. $(stickyContent).each(function (index, element) {
  3511. var actualMargin = element.style.marginRight;
  3512. var calculatedMargin = $(element).css('margin-right');
  3513. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this9._scrollbarWidth + "px");
  3514. }); // Adjust body padding
  3515. var actualPadding = document.body.style.paddingRight;
  3516. var calculatedPadding = $(document.body).css('padding-right');
  3517. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3518. }
  3519. $(document.body).addClass(ClassName$5.OPEN);
  3520. };
  3521. _proto._resetScrollbar = function _resetScrollbar() {
  3522. // Restore fixed content padding
  3523. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3524. $(fixedContent).each(function (index, element) {
  3525. var padding = $(element).data('padding-right');
  3526. $(element).removeData('padding-right');
  3527. element.style.paddingRight = padding ? padding : '';
  3528. }); // Restore sticky content
  3529. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  3530. $(elements).each(function (index, element) {
  3531. var margin = $(element).data('margin-right');
  3532. if (typeof margin !== 'undefined') {
  3533. $(element).css('margin-right', margin).removeData('margin-right');
  3534. }
  3535. }); // Restore body padding
  3536. var padding = $(document.body).data('padding-right');
  3537. $(document.body).removeData('padding-right');
  3538. document.body.style.paddingRight = padding ? padding : '';
  3539. };
  3540. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  3541. // thx d.walsh
  3542. var scrollDiv = document.createElement('div');
  3543. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  3544. document.body.appendChild(scrollDiv);
  3545. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3546. document.body.removeChild(scrollDiv);
  3547. return scrollbarWidth;
  3548. } // Static
  3549. ;
  3550. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  3551. return this.each(function () {
  3552. var data = $(this).data(DATA_KEY$5);
  3553. var _config = _objectSpread({}, Default$3, $(this).data(), typeof config === 'object' && config ? config : {});
  3554. if (!data) {
  3555. data = new Modal(this, _config);
  3556. $(this).data(DATA_KEY$5, data);
  3557. }
  3558. if (typeof config === 'string') {
  3559. if (typeof data[config] === 'undefined') {
  3560. throw new TypeError("No method named \"" + config + "\"");
  3561. }
  3562. data[config](relatedTarget);
  3563. } else if (_config.show) {
  3564. data.show(relatedTarget);
  3565. }
  3566. });
  3567. };
  3568. _createClass(Modal, null, [{
  3569. key: "VERSION",
  3570. get: function get() {
  3571. return VERSION$5;
  3572. }
  3573. }, {
  3574. key: "Default",
  3575. get: function get() {
  3576. return Default$3;
  3577. }
  3578. }]);
  3579. return Modal;
  3580. }();
  3581. /**
  3582. * ------------------------------------------------------------------------
  3583. * Data Api implementation
  3584. * ------------------------------------------------------------------------
  3585. */
  3586. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  3587. var _this10 = this;
  3588. var target;
  3589. var selector = Util.getSelectorFromElement(this);
  3590. if (selector) {
  3591. target = document.querySelector(selector);
  3592. }
  3593. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread({}, $(target).data(), $(this).data());
  3594. if (this.tagName === 'A' || this.tagName === 'AREA') {
  3595. event.preventDefault();
  3596. }
  3597. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  3598. if (showEvent.isDefaultPrevented()) {
  3599. // Only register focus restorer if modal will actually get shown
  3600. return;
  3601. }
  3602. $target.one(Event$5.HIDDEN, function () {
  3603. if ($(_this10).is(':visible')) {
  3604. _this10.focus();
  3605. }
  3606. });
  3607. });
  3608. Modal._jQueryInterface.call($(target), config, this);
  3609. });
  3610. /**
  3611. * ------------------------------------------------------------------------
  3612. * jQuery
  3613. * ------------------------------------------------------------------------
  3614. */
  3615. $.fn[NAME$5] = Modal._jQueryInterface;
  3616. $.fn[NAME$5].Constructor = Modal;
  3617. $.fn[NAME$5].noConflict = function () {
  3618. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  3619. return Modal._jQueryInterface;
  3620. };
  3621. /**
  3622. * --------------------------------------------------------------------------
  3623. * Bootstrap (v4.3.1): tools/sanitizer.js
  3624. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  3625. * --------------------------------------------------------------------------
  3626. */
  3627. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  3628. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  3629. var DefaultWhitelist = {
  3630. // Global attributes allowed on any supplied element below.
  3631. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  3632. a: ['target', 'href', 'title', 'rel'],
  3633. area: [],
  3634. b: [],
  3635. br: [],
  3636. col: [],
  3637. code: [],
  3638. div: [],
  3639. em: [],
  3640. hr: [],
  3641. h1: [],
  3642. h2: [],
  3643. h3: [],
  3644. h4: [],
  3645. h5: [],
  3646. h6: [],
  3647. i: [],
  3648. img: ['src', 'alt', 'title', 'width', 'height'],
  3649. li: [],
  3650. ol: [],
  3651. p: [],
  3652. pre: [],
  3653. s: [],
  3654. small: [],
  3655. span: [],
  3656. sub: [],
  3657. sup: [],
  3658. strong: [],
  3659. u: [],
  3660. ul: []
  3661. /**
  3662. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  3663. *
  3664. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  3665. */
  3666. };
  3667. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  3668. /**
  3669. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  3670. *
  3671. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  3672. */
  3673. var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
  3674. function allowedAttribute(attr, allowedAttributeList) {
  3675. var attrName = attr.nodeName.toLowerCase();
  3676. if (allowedAttributeList.indexOf(attrName) !== -1) {
  3677. if (uriAttrs.indexOf(attrName) !== -1) {
  3678. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  3679. }
  3680. return true;
  3681. }
  3682. var regExp = allowedAttributeList.filter(function (attrRegex) {
  3683. return attrRegex instanceof RegExp;
  3684. }); // Check if a regular expression validates the attribute.
  3685. for (var i = 0, l = regExp.length; i < l; i++) {
  3686. if (attrName.match(regExp[i])) {
  3687. return true;
  3688. }
  3689. }
  3690. return false;
  3691. }
  3692. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  3693. if (unsafeHtml.length === 0) {
  3694. return unsafeHtml;
  3695. }
  3696. if (sanitizeFn && typeof sanitizeFn === 'function') {
  3697. return sanitizeFn(unsafeHtml);
  3698. }
  3699. var domParser = new window.DOMParser();
  3700. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  3701. var whitelistKeys = Object.keys(whiteList);
  3702. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  3703. var _loop = function _loop(i, len) {
  3704. var el = elements[i];
  3705. var elName = el.nodeName.toLowerCase();
  3706. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  3707. el.parentNode.removeChild(el);
  3708. return "continue";
  3709. }
  3710. var attributeList = [].slice.call(el.attributes);
  3711. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  3712. attributeList.forEach(function (attr) {
  3713. if (!allowedAttribute(attr, whitelistedAttributes)) {
  3714. el.removeAttribute(attr.nodeName);
  3715. }
  3716. });
  3717. };
  3718. for (var i = 0, len = elements.length; i < len; i++) {
  3719. var _ret = _loop(i, len);
  3720. if (_ret === "continue") continue;
  3721. }
  3722. return createdDocument.body.innerHTML;
  3723. }
  3724. /**
  3725. * ------------------------------------------------------------------------
  3726. * Constants
  3727. * ------------------------------------------------------------------------
  3728. */
  3729. var NAME$6 = 'tooltip';
  3730. var VERSION$6 = '4.3.1';
  3731. var DATA_KEY$6 = 'bs.tooltip';
  3732. var EVENT_KEY$6 = "." + DATA_KEY$6;
  3733. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  3734. var CLASS_PREFIX = 'bs-tooltip';
  3735. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  3736. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  3737. var DefaultType$4 = {
  3738. animation: 'boolean',
  3739. template: 'string',
  3740. title: '(string|element|function)',
  3741. trigger: 'string',
  3742. delay: '(number|object)',
  3743. html: 'boolean',
  3744. selector: '(string|boolean)',
  3745. placement: '(string|function)',
  3746. offset: '(number|string|function)',
  3747. container: '(string|element|boolean)',
  3748. fallbackPlacement: '(string|array)',
  3749. boundary: '(string|element)',
  3750. sanitize: 'boolean',
  3751. sanitizeFn: '(null|function)',
  3752. whiteList: 'object'
  3753. };
  3754. var AttachmentMap$1 = {
  3755. AUTO: 'auto',
  3756. TOP: 'top',
  3757. RIGHT: 'right',
  3758. BOTTOM: 'bottom',
  3759. LEFT: 'left'
  3760. };
  3761. var Default$4 = {
  3762. animation: true,
  3763. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  3764. trigger: 'hover focus',
  3765. title: '',
  3766. delay: 0,
  3767. html: false,
  3768. selector: false,
  3769. placement: 'top',
  3770. offset: 0,
  3771. container: false,
  3772. fallbackPlacement: 'flip',
  3773. boundary: 'scrollParent',
  3774. sanitize: true,
  3775. sanitizeFn: null,
  3776. whiteList: DefaultWhitelist
  3777. };
  3778. var HoverState = {
  3779. SHOW: 'show',
  3780. OUT: 'out'
  3781. };
  3782. var Event$6 = {
  3783. HIDE: "hide" + EVENT_KEY$6,
  3784. HIDDEN: "hidden" + EVENT_KEY$6,
  3785. SHOW: "show" + EVENT_KEY$6,
  3786. SHOWN: "shown" + EVENT_KEY$6,
  3787. INSERTED: "inserted" + EVENT_KEY$6,
  3788. CLICK: "click" + EVENT_KEY$6,
  3789. FOCUSIN: "focusin" + EVENT_KEY$6,
  3790. FOCUSOUT: "focusout" + EVENT_KEY$6,
  3791. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  3792. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  3793. };
  3794. var ClassName$6 = {
  3795. FADE: 'fade',
  3796. SHOW: 'show'
  3797. };
  3798. var Selector$6 = {
  3799. TOOLTIP: '.tooltip',
  3800. TOOLTIP_INNER: '.tooltip-inner',
  3801. ARROW: '.arrow'
  3802. };
  3803. var Trigger = {
  3804. HOVER: 'hover',
  3805. FOCUS: 'focus',
  3806. CLICK: 'click',
  3807. MANUAL: 'manual'
  3808. /**
  3809. * ------------------------------------------------------------------------
  3810. * Class Definition
  3811. * ------------------------------------------------------------------------
  3812. */
  3813. };
  3814. var Tooltip =
  3815. /*#__PURE__*/
  3816. function () {
  3817. function Tooltip(element, config) {
  3818. /**
  3819. * Check for Popper dependency
  3820. * Popper - https://popper.js.org
  3821. */
  3822. if (typeof Popper === 'undefined') {
  3823. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  3824. } // private
  3825. this._isEnabled = true;
  3826. this._timeout = 0;
  3827. this._hoverState = '';
  3828. this._activeTrigger = {};
  3829. this._popper = null; // Protected
  3830. this.element = element;
  3831. this.config = this._getConfig(config);
  3832. this.tip = null;
  3833. this._setListeners();
  3834. } // Getters
  3835. var _proto = Tooltip.prototype;
  3836. // Public
  3837. _proto.enable = function enable() {
  3838. this._isEnabled = true;
  3839. };
  3840. _proto.disable = function disable() {
  3841. this._isEnabled = false;
  3842. };
  3843. _proto.toggleEnabled = function toggleEnabled() {
  3844. this._isEnabled = !this._isEnabled;
  3845. };
  3846. _proto.toggle = function toggle(event) {
  3847. if (!this._isEnabled) {
  3848. return;
  3849. }
  3850. if (event) {
  3851. var dataKey = this.constructor.DATA_KEY;
  3852. var context = $(event.currentTarget).data(dataKey);
  3853. if (!context) {
  3854. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  3855. $(event.currentTarget).data(dataKey, context);
  3856. }
  3857. context._activeTrigger.click = !context._activeTrigger.click;
  3858. if (context._isWithActiveTrigger()) {
  3859. context._enter(null, context);
  3860. } else {
  3861. context._leave(null, context);
  3862. }
  3863. } else {
  3864. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  3865. this._leave(null, this);
  3866. return;
  3867. }
  3868. this._enter(null, this);
  3869. }
  3870. };
  3871. _proto.dispose = function dispose() {
  3872. clearTimeout(this._timeout);
  3873. $.removeData(this.element, this.constructor.DATA_KEY);
  3874. $(this.element).off(this.constructor.EVENT_KEY);
  3875. $(this.element).closest('.modal').off('hide.bs.modal');
  3876. if (this.tip) {
  3877. $(this.tip).remove();
  3878. }
  3879. this._isEnabled = null;
  3880. this._timeout = null;
  3881. this._hoverState = null;
  3882. this._activeTrigger = null;
  3883. if (this._popper !== null) {
  3884. this._popper.destroy();
  3885. }
  3886. this._popper = null;
  3887. this.element = null;
  3888. this.config = null;
  3889. this.tip = null;
  3890. };
  3891. _proto.show = function show() {
  3892. var _this = this;
  3893. if ($(this.element).css('display') === 'none') {
  3894. throw new Error('Please use show on visible elements');
  3895. }
  3896. var showEvent = $.Event(this.constructor.Event.SHOW);
  3897. if (this.isWithContent() && this._isEnabled) {
  3898. $(this.element).trigger(showEvent);
  3899. var shadowRoot = Util.findShadowRoot(this.element);
  3900. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  3901. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  3902. return;
  3903. }
  3904. var tip = this.getTipElement();
  3905. var tipId = Util.getUID(this.constructor.NAME);
  3906. tip.setAttribute('id', tipId);
  3907. this.element.setAttribute('aria-describedby', tipId);
  3908. this.setContent();
  3909. if (this.config.animation) {
  3910. $(tip).addClass(ClassName$6.FADE);
  3911. }
  3912. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  3913. var attachment = this._getAttachment(placement);
  3914. this.addAttachmentClass(attachment);
  3915. var container = this._getContainer();
  3916. $(tip).data(this.constructor.DATA_KEY, this);
  3917. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  3918. $(tip).appendTo(container);
  3919. }
  3920. $(this.element).trigger(this.constructor.Event.INSERTED);
  3921. this._popper = new Popper(this.element, tip, {
  3922. placement: attachment,
  3923. modifiers: {
  3924. offset: this._getOffset(),
  3925. flip: {
  3926. behavior: this.config.fallbackPlacement
  3927. },
  3928. arrow: {
  3929. element: Selector$6.ARROW
  3930. },
  3931. preventOverflow: {
  3932. boundariesElement: this.config.boundary
  3933. }
  3934. },
  3935. onCreate: function onCreate(data) {
  3936. if (data.originalPlacement !== data.placement) {
  3937. _this._handlePopperPlacementChange(data);
  3938. }
  3939. },
  3940. onUpdate: function onUpdate(data) {
  3941. return _this._handlePopperPlacementChange(data);
  3942. }
  3943. });
  3944. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  3945. // empty mouseover listeners to the body's immediate children;
  3946. // only needed because of broken event delegation on iOS
  3947. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3948. if ('ontouchstart' in document.documentElement) {
  3949. $(document.body).children().on('mouseover', null, $.noop);
  3950. }
  3951. var complete = function complete() {
  3952. if (_this.config.animation) {
  3953. _this._fixTransition();
  3954. }
  3955. var prevHoverState = _this._hoverState;
  3956. _this._hoverState = null;
  3957. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  3958. if (prevHoverState === HoverState.OUT) {
  3959. _this._leave(null, _this);
  3960. }
  3961. };
  3962. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  3963. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  3964. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3965. } else {
  3966. complete();
  3967. }
  3968. }
  3969. };
  3970. _proto.hide = function hide(callback) {
  3971. var _this2 = this;
  3972. var tip = this.getTipElement();
  3973. var hideEvent = $.Event(this.constructor.Event.HIDE);
  3974. var complete = function complete() {
  3975. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  3976. tip.parentNode.removeChild(tip);
  3977. }
  3978. _this2._cleanTipClass();
  3979. _this2.element.removeAttribute('aria-describedby');
  3980. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  3981. if (_this2._popper !== null) {
  3982. _this2._popper.destroy();
  3983. }
  3984. if (callback) {
  3985. callback();
  3986. }
  3987. };
  3988. $(this.element).trigger(hideEvent);
  3989. if (hideEvent.isDefaultPrevented()) {
  3990. return;
  3991. }
  3992. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  3993. // empty mouseover listeners we added for iOS support
  3994. if ('ontouchstart' in document.documentElement) {
  3995. $(document.body).children().off('mouseover', null, $.noop);
  3996. }
  3997. this._activeTrigger[Trigger.CLICK] = false;
  3998. this._activeTrigger[Trigger.FOCUS] = false;
  3999. this._activeTrigger[Trigger.HOVER] = false;
  4000. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4001. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4002. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4003. } else {
  4004. complete();
  4005. }
  4006. this._hoverState = '';
  4007. };
  4008. _proto.update = function update() {
  4009. if (this._popper !== null) {
  4010. this._popper.scheduleUpdate();
  4011. }
  4012. } // Protected
  4013. ;
  4014. _proto.isWithContent = function isWithContent() {
  4015. return Boolean(this.getTitle());
  4016. };
  4017. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4018. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4019. };
  4020. _proto.getTipElement = function getTipElement() {
  4021. this.tip = this.tip || $(this.config.template)[0];
  4022. return this.tip;
  4023. };
  4024. _proto.setContent = function setContent() {
  4025. var tip = this.getTipElement();
  4026. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4027. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4028. };
  4029. _proto.setElementContent = function setElementContent($element, content) {
  4030. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4031. // Content is a DOM node or a jQuery
  4032. if (this.config.html) {
  4033. if (!$(content).parent().is($element)) {
  4034. $element.empty().append(content);
  4035. }
  4036. } else {
  4037. $element.text($(content).text());
  4038. }
  4039. return;
  4040. }
  4041. if (this.config.html) {
  4042. if (this.config.sanitize) {
  4043. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4044. }
  4045. $element.html(content);
  4046. } else {
  4047. $element.text(content);
  4048. }
  4049. };
  4050. _proto.getTitle = function getTitle() {
  4051. var title = this.element.getAttribute('data-original-title');
  4052. if (!title) {
  4053. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4054. }
  4055. return title;
  4056. } // Private
  4057. ;
  4058. _proto._getOffset = function _getOffset() {
  4059. var _this3 = this;
  4060. var offset = {};
  4061. if (typeof this.config.offset === 'function') {
  4062. offset.fn = function (data) {
  4063. data.offsets = _objectSpread({}, data.offsets, _this3.config.offset(data.offsets, _this3.element) || {});
  4064. return data;
  4065. };
  4066. } else {
  4067. offset.offset = this.config.offset;
  4068. }
  4069. return offset;
  4070. };
  4071. _proto._getContainer = function _getContainer() {
  4072. if (this.config.container === false) {
  4073. return document.body;
  4074. }
  4075. if (Util.isElement(this.config.container)) {
  4076. return $(this.config.container);
  4077. }
  4078. return $(document).find(this.config.container);
  4079. };
  4080. _proto._getAttachment = function _getAttachment(placement) {
  4081. return AttachmentMap$1[placement.toUpperCase()];
  4082. };
  4083. _proto._setListeners = function _setListeners() {
  4084. var _this4 = this;
  4085. var triggers = this.config.trigger.split(' ');
  4086. triggers.forEach(function (trigger) {
  4087. if (trigger === 'click') {
  4088. $(_this4.element).on(_this4.constructor.Event.CLICK, _this4.config.selector, function (event) {
  4089. return _this4.toggle(event);
  4090. });
  4091. } else if (trigger !== Trigger.MANUAL) {
  4092. var eventIn = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSEENTER : _this4.constructor.Event.FOCUSIN;
  4093. var eventOut = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSELEAVE : _this4.constructor.Event.FOCUSOUT;
  4094. $(_this4.element).on(eventIn, _this4.config.selector, function (event) {
  4095. return _this4._enter(event);
  4096. }).on(eventOut, _this4.config.selector, function (event) {
  4097. return _this4._leave(event);
  4098. });
  4099. }
  4100. });
  4101. $(this.element).closest('.modal').on('hide.bs.modal', function () {
  4102. if (_this4.element) {
  4103. _this4.hide();
  4104. }
  4105. });
  4106. if (this.config.selector) {
  4107. this.config = _objectSpread({}, this.config, {
  4108. trigger: 'manual',
  4109. selector: ''
  4110. });
  4111. } else {
  4112. this._fixTitle();
  4113. }
  4114. };
  4115. _proto._fixTitle = function _fixTitle() {
  4116. var titleType = typeof this.element.getAttribute('data-original-title');
  4117. if (this.element.getAttribute('title') || titleType !== 'string') {
  4118. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4119. this.element.setAttribute('title', '');
  4120. }
  4121. };
  4122. _proto._enter = function _enter(event, context) {
  4123. var dataKey = this.constructor.DATA_KEY;
  4124. context = context || $(event.currentTarget).data(dataKey);
  4125. if (!context) {
  4126. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4127. $(event.currentTarget).data(dataKey, context);
  4128. }
  4129. if (event) {
  4130. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4131. }
  4132. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4133. context._hoverState = HoverState.SHOW;
  4134. return;
  4135. }
  4136. clearTimeout(context._timeout);
  4137. context._hoverState = HoverState.SHOW;
  4138. if (!context.config.delay || !context.config.delay.show) {
  4139. context.show();
  4140. return;
  4141. }
  4142. context._timeout = setTimeout(function () {
  4143. if (context._hoverState === HoverState.SHOW) {
  4144. context.show();
  4145. }
  4146. }, context.config.delay.show);
  4147. };
  4148. _proto._leave = function _leave(event, context) {
  4149. var dataKey = this.constructor.DATA_KEY;
  4150. context = context || $(event.currentTarget).data(dataKey);
  4151. if (!context) {
  4152. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4153. $(event.currentTarget).data(dataKey, context);
  4154. }
  4155. if (event) {
  4156. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4157. }
  4158. if (context._isWithActiveTrigger()) {
  4159. return;
  4160. }
  4161. clearTimeout(context._timeout);
  4162. context._hoverState = HoverState.OUT;
  4163. if (!context.config.delay || !context.config.delay.hide) {
  4164. context.hide();
  4165. return;
  4166. }
  4167. context._timeout = setTimeout(function () {
  4168. if (context._hoverState === HoverState.OUT) {
  4169. context.hide();
  4170. }
  4171. }, context.config.delay.hide);
  4172. };
  4173. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4174. for (var trigger in this._activeTrigger) {
  4175. if (this._activeTrigger[trigger]) {
  4176. return true;
  4177. }
  4178. }
  4179. return false;
  4180. };
  4181. _proto._getConfig = function _getConfig(config) {
  4182. var dataAttributes = $(this.element).data();
  4183. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4184. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4185. delete dataAttributes[dataAttr];
  4186. }
  4187. });
  4188. config = _objectSpread({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {});
  4189. if (typeof config.delay === 'number') {
  4190. config.delay = {
  4191. show: config.delay,
  4192. hide: config.delay
  4193. };
  4194. }
  4195. if (typeof config.title === 'number') {
  4196. config.title = config.title.toString();
  4197. }
  4198. if (typeof config.content === 'number') {
  4199. config.content = config.content.toString();
  4200. }
  4201. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4202. if (config.sanitize) {
  4203. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4204. }
  4205. return config;
  4206. };
  4207. _proto._getDelegateConfig = function _getDelegateConfig() {
  4208. var config = {};
  4209. if (this.config) {
  4210. for (var key in this.config) {
  4211. if (this.constructor.Default[key] !== this.config[key]) {
  4212. config[key] = this.config[key];
  4213. }
  4214. }
  4215. }
  4216. return config;
  4217. };
  4218. _proto._cleanTipClass = function _cleanTipClass() {
  4219. var $tip = $(this.getTipElement());
  4220. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4221. if (tabClass !== null && tabClass.length) {
  4222. $tip.removeClass(tabClass.join(''));
  4223. }
  4224. };
  4225. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4226. var popperInstance = popperData.instance;
  4227. this.tip = popperInstance.popper;
  4228. this._cleanTipClass();
  4229. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4230. };
  4231. _proto._fixTransition = function _fixTransition() {
  4232. var tip = this.getTipElement();
  4233. var initConfigAnimation = this.config.animation;
  4234. if (tip.getAttribute('x-placement') !== null) {
  4235. return;
  4236. }
  4237. $(tip).removeClass(ClassName$6.FADE);
  4238. this.config.animation = false;
  4239. this.hide();
  4240. this.show();
  4241. this.config.animation = initConfigAnimation;
  4242. } // Static
  4243. ;
  4244. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4245. return this.each(function () {
  4246. var data = $(this).data(DATA_KEY$6);
  4247. var _config = typeof config === 'object' && config;
  4248. if (!data && /dispose|hide/.test(config)) {
  4249. return;
  4250. }
  4251. if (!data) {
  4252. data = new Tooltip(this, _config);
  4253. $(this).data(DATA_KEY$6, data);
  4254. }
  4255. if (typeof config === 'string') {
  4256. if (typeof data[config] === 'undefined') {
  4257. throw new TypeError("No method named \"" + config + "\"");
  4258. }
  4259. data[config]();
  4260. }
  4261. });
  4262. };
  4263. _createClass(Tooltip, null, [{
  4264. key: "VERSION",
  4265. get: function get() {
  4266. return VERSION$6;
  4267. }
  4268. }, {
  4269. key: "Default",
  4270. get: function get() {
  4271. return Default$4;
  4272. }
  4273. }, {
  4274. key: "NAME",
  4275. get: function get() {
  4276. return NAME$6;
  4277. }
  4278. }, {
  4279. key: "DATA_KEY",
  4280. get: function get() {
  4281. return DATA_KEY$6;
  4282. }
  4283. }, {
  4284. key: "Event",
  4285. get: function get() {
  4286. return Event$6;
  4287. }
  4288. }, {
  4289. key: "EVENT_KEY",
  4290. get: function get() {
  4291. return EVENT_KEY$6;
  4292. }
  4293. }, {
  4294. key: "DefaultType",
  4295. get: function get() {
  4296. return DefaultType$4;
  4297. }
  4298. }]);
  4299. return Tooltip;
  4300. }();
  4301. /**
  4302. * ------------------------------------------------------------------------
  4303. * jQuery
  4304. * ------------------------------------------------------------------------
  4305. */
  4306. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4307. $.fn[NAME$6].Constructor = Tooltip;
  4308. $.fn[NAME$6].noConflict = function () {
  4309. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4310. return Tooltip._jQueryInterface;
  4311. };
  4312. /**
  4313. * ------------------------------------------------------------------------
  4314. * Constants
  4315. * ------------------------------------------------------------------------
  4316. */
  4317. var NAME$7 = 'popover';
  4318. var VERSION$7 = '4.3.1';
  4319. var DATA_KEY$7 = 'bs.popover';
  4320. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4321. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4322. var CLASS_PREFIX$1 = 'bs-popover';
  4323. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4324. var Default$5 = _objectSpread({}, Tooltip.Default, {
  4325. placement: 'right',
  4326. trigger: 'click',
  4327. content: '',
  4328. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4329. });
  4330. var DefaultType$5 = _objectSpread({}, Tooltip.DefaultType, {
  4331. content: '(string|element|function)'
  4332. });
  4333. var ClassName$7 = {
  4334. FADE: 'fade',
  4335. SHOW: 'show'
  4336. };
  4337. var Selector$7 = {
  4338. TITLE: '.popover-header',
  4339. CONTENT: '.popover-body'
  4340. };
  4341. var Event$7 = {
  4342. HIDE: "hide" + EVENT_KEY$7,
  4343. HIDDEN: "hidden" + EVENT_KEY$7,
  4344. SHOW: "show" + EVENT_KEY$7,
  4345. SHOWN: "shown" + EVENT_KEY$7,
  4346. INSERTED: "inserted" + EVENT_KEY$7,
  4347. CLICK: "click" + EVENT_KEY$7,
  4348. FOCUSIN: "focusin" + EVENT_KEY$7,
  4349. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4350. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4351. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4352. /**
  4353. * ------------------------------------------------------------------------
  4354. * Class Definition
  4355. * ------------------------------------------------------------------------
  4356. */
  4357. };
  4358. var Popover =
  4359. /*#__PURE__*/
  4360. function (_Tooltip) {
  4361. _inheritsLoose(Popover, _Tooltip);
  4362. function Popover() {
  4363. return _Tooltip.apply(this, arguments) || this;
  4364. }
  4365. var _proto = Popover.prototype;
  4366. // Overrides
  4367. _proto.isWithContent = function isWithContent() {
  4368. return this.getTitle() || this._getContent();
  4369. };
  4370. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4371. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4372. };
  4373. _proto.getTipElement = function getTipElement() {
  4374. this.tip = this.tip || $(this.config.template)[0];
  4375. return this.tip;
  4376. };
  4377. _proto.setContent = function setContent() {
  4378. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4379. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4380. var content = this._getContent();
  4381. if (typeof content === 'function') {
  4382. content = content.call(this.element);
  4383. }
  4384. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4385. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4386. } // Private
  4387. ;
  4388. _proto._getContent = function _getContent() {
  4389. return this.element.getAttribute('data-content') || this.config.content;
  4390. };
  4391. _proto._cleanTipClass = function _cleanTipClass() {
  4392. var $tip = $(this.getTipElement());
  4393. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4394. if (tabClass !== null && tabClass.length > 0) {
  4395. $tip.removeClass(tabClass.join(''));
  4396. }
  4397. } // Static
  4398. ;
  4399. Popover._jQueryInterface = function _jQueryInterface(config) {
  4400. return this.each(function () {
  4401. var data = $(this).data(DATA_KEY$7);
  4402. var _config = typeof config === 'object' ? config : null;
  4403. if (!data && /dispose|hide/.test(config)) {
  4404. return;
  4405. }
  4406. if (!data) {
  4407. data = new Popover(this, _config);
  4408. $(this).data(DATA_KEY$7, data);
  4409. }
  4410. if (typeof config === 'string') {
  4411. if (typeof data[config] === 'undefined') {
  4412. throw new TypeError("No method named \"" + config + "\"");
  4413. }
  4414. data[config]();
  4415. }
  4416. });
  4417. };
  4418. _createClass(Popover, null, [{
  4419. key: "VERSION",
  4420. // Getters
  4421. get: function get() {
  4422. return VERSION$7;
  4423. }
  4424. }, {
  4425. key: "Default",
  4426. get: function get() {
  4427. return Default$5;
  4428. }
  4429. }, {
  4430. key: "NAME",
  4431. get: function get() {
  4432. return NAME$7;
  4433. }
  4434. }, {
  4435. key: "DATA_KEY",
  4436. get: function get() {
  4437. return DATA_KEY$7;
  4438. }
  4439. }, {
  4440. key: "Event",
  4441. get: function get() {
  4442. return Event$7;
  4443. }
  4444. }, {
  4445. key: "EVENT_KEY",
  4446. get: function get() {
  4447. return EVENT_KEY$7;
  4448. }
  4449. }, {
  4450. key: "DefaultType",
  4451. get: function get() {
  4452. return DefaultType$5;
  4453. }
  4454. }]);
  4455. return Popover;
  4456. }(Tooltip);
  4457. /**
  4458. * ------------------------------------------------------------------------
  4459. * jQuery
  4460. * ------------------------------------------------------------------------
  4461. */
  4462. $.fn[NAME$7] = Popover._jQueryInterface;
  4463. $.fn[NAME$7].Constructor = Popover;
  4464. $.fn[NAME$7].noConflict = function () {
  4465. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4466. return Popover._jQueryInterface;
  4467. };
  4468. /**
  4469. * ------------------------------------------------------------------------
  4470. * Constants
  4471. * ------------------------------------------------------------------------
  4472. */
  4473. var NAME$8 = 'scrollspy';
  4474. var VERSION$8 = '4.3.1';
  4475. var DATA_KEY$8 = 'bs.scrollspy';
  4476. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4477. var DATA_API_KEY$6 = '.data-api';
  4478. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4479. var Default$6 = {
  4480. offset: 10,
  4481. method: 'auto',
  4482. target: ''
  4483. };
  4484. var DefaultType$6 = {
  4485. offset: 'number',
  4486. method: 'string',
  4487. target: '(string|element)'
  4488. };
  4489. var Event$8 = {
  4490. ACTIVATE: "activate" + EVENT_KEY$8,
  4491. SCROLL: "scroll" + EVENT_KEY$8,
  4492. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4493. };
  4494. var ClassName$8 = {
  4495. DROPDOWN_ITEM: 'dropdown-item',
  4496. DROPDOWN_MENU: 'dropdown-menu',
  4497. ACTIVE: 'active'
  4498. };
  4499. var Selector$8 = {
  4500. DATA_SPY: '[data-spy="scroll"]',
  4501. ACTIVE: '.active',
  4502. NAV_LIST_GROUP: '.nav, .list-group',
  4503. NAV_LINKS: '.nav-link',
  4504. NAV_ITEMS: '.nav-item',
  4505. LIST_ITEMS: '.list-group-item',
  4506. DROPDOWN: '.dropdown',
  4507. DROPDOWN_ITEMS: '.dropdown-item',
  4508. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4509. };
  4510. var OffsetMethod = {
  4511. OFFSET: 'offset',
  4512. POSITION: 'position'
  4513. /**
  4514. * ------------------------------------------------------------------------
  4515. * Class Definition
  4516. * ------------------------------------------------------------------------
  4517. */
  4518. };
  4519. var ScrollSpy =
  4520. /*#__PURE__*/
  4521. function () {
  4522. function ScrollSpy(element, config) {
  4523. var _this = this;
  4524. this._element = element;
  4525. this._scrollElement = element.tagName === 'BODY' ? window : element;
  4526. this._config = this._getConfig(config);
  4527. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  4528. this._offsets = [];
  4529. this._targets = [];
  4530. this._activeTarget = null;
  4531. this._scrollHeight = 0;
  4532. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  4533. return _this._process(event);
  4534. });
  4535. this.refresh();
  4536. this._process();
  4537. } // Getters
  4538. var _proto = ScrollSpy.prototype;
  4539. // Public
  4540. _proto.refresh = function refresh() {
  4541. var _this2 = this;
  4542. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  4543. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4544. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  4545. this._offsets = [];
  4546. this._targets = [];
  4547. this._scrollHeight = this._getScrollHeight();
  4548. var targets = [].slice.call(document.querySelectorAll(this._selector));
  4549. targets.map(function (element) {
  4550. var target;
  4551. var targetSelector = Util.getSelectorFromElement(element);
  4552. if (targetSelector) {
  4553. target = document.querySelector(targetSelector);
  4554. }
  4555. if (target) {
  4556. var targetBCR = target.getBoundingClientRect();
  4557. if (targetBCR.width || targetBCR.height) {
  4558. // TODO (fat): remove sketch reliance on jQuery position/offset
  4559. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  4560. }
  4561. }
  4562. return null;
  4563. }).filter(function (item) {
  4564. return item;
  4565. }).sort(function (a, b) {
  4566. return a[0] - b[0];
  4567. }).forEach(function (item) {
  4568. _this2._offsets.push(item[0]);
  4569. _this2._targets.push(item[1]);
  4570. });
  4571. };
  4572. _proto.dispose = function dispose() {
  4573. $.removeData(this._element, DATA_KEY$8);
  4574. $(this._scrollElement).off(EVENT_KEY$8);
  4575. this._element = null;
  4576. this._scrollElement = null;
  4577. this._config = null;
  4578. this._selector = null;
  4579. this._offsets = null;
  4580. this._targets = null;
  4581. this._activeTarget = null;
  4582. this._scrollHeight = null;
  4583. } // Private
  4584. ;
  4585. _proto._getConfig = function _getConfig(config) {
  4586. config = _objectSpread({}, Default$6, typeof config === 'object' && config ? config : {});
  4587. if (typeof config.target !== 'string') {
  4588. var id = $(config.target).attr('id');
  4589. if (!id) {
  4590. id = Util.getUID(NAME$8);
  4591. $(config.target).attr('id', id);
  4592. }
  4593. config.target = "#" + id;
  4594. }
  4595. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  4596. return config;
  4597. };
  4598. _proto._getScrollTop = function _getScrollTop() {
  4599. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  4600. };
  4601. _proto._getScrollHeight = function _getScrollHeight() {
  4602. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  4603. };
  4604. _proto._getOffsetHeight = function _getOffsetHeight() {
  4605. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  4606. };
  4607. _proto._process = function _process() {
  4608. var scrollTop = this._getScrollTop() + this._config.offset;
  4609. var scrollHeight = this._getScrollHeight();
  4610. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  4611. if (this._scrollHeight !== scrollHeight) {
  4612. this.refresh();
  4613. }
  4614. if (scrollTop >= maxScroll) {
  4615. var target = this._targets[this._targets.length - 1];
  4616. if (this._activeTarget !== target) {
  4617. this._activate(target);
  4618. }
  4619. return;
  4620. }
  4621. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  4622. this._activeTarget = null;
  4623. this._clear();
  4624. return;
  4625. }
  4626. var offsetLength = this._offsets.length;
  4627. for (var i = offsetLength; i--;) {
  4628. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  4629. if (isActiveTarget) {
  4630. this._activate(this._targets[i]);
  4631. }
  4632. }
  4633. };
  4634. _proto._activate = function _activate(target) {
  4635. this._activeTarget = target;
  4636. this._clear();
  4637. var queries = this._selector.split(',').map(function (selector) {
  4638. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  4639. });
  4640. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  4641. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  4642. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  4643. $link.addClass(ClassName$8.ACTIVE);
  4644. } else {
  4645. // Set triggered link as active
  4646. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  4647. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  4648. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_LINKS + ", " + Selector$8.LIST_ITEMS).addClass(ClassName$8.ACTIVE); // Handle special case when .nav-link is inside .nav-item
  4649. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  4650. }
  4651. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  4652. relatedTarget: target
  4653. });
  4654. };
  4655. _proto._clear = function _clear() {
  4656. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  4657. return node.classList.contains(ClassName$8.ACTIVE);
  4658. }).forEach(function (node) {
  4659. return node.classList.remove(ClassName$8.ACTIVE);
  4660. });
  4661. } // Static
  4662. ;
  4663. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  4664. return this.each(function () {
  4665. var data = $(this).data(DATA_KEY$8);
  4666. var _config = typeof config === 'object' && config;
  4667. if (!data) {
  4668. data = new ScrollSpy(this, _config);
  4669. $(this).data(DATA_KEY$8, data);
  4670. }
  4671. if (typeof config === 'string') {
  4672. if (typeof data[config] === 'undefined') {
  4673. throw new TypeError("No method named \"" + config + "\"");
  4674. }
  4675. data[config]();
  4676. }
  4677. });
  4678. };
  4679. _createClass(ScrollSpy, null, [{
  4680. key: "VERSION",
  4681. get: function get() {
  4682. return VERSION$8;
  4683. }
  4684. }, {
  4685. key: "Default",
  4686. get: function get() {
  4687. return Default$6;
  4688. }
  4689. }]);
  4690. return ScrollSpy;
  4691. }();
  4692. /**
  4693. * ------------------------------------------------------------------------
  4694. * Data Api implementation
  4695. * ------------------------------------------------------------------------
  4696. */
  4697. $(window).on(Event$8.LOAD_DATA_API, function () {
  4698. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  4699. var scrollSpysLength = scrollSpys.length;
  4700. for (var i = scrollSpysLength; i--;) {
  4701. var $spy = $(scrollSpys[i]);
  4702. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  4703. }
  4704. });
  4705. /**
  4706. * ------------------------------------------------------------------------
  4707. * jQuery
  4708. * ------------------------------------------------------------------------
  4709. */
  4710. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  4711. $.fn[NAME$8].Constructor = ScrollSpy;
  4712. $.fn[NAME$8].noConflict = function () {
  4713. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  4714. return ScrollSpy._jQueryInterface;
  4715. };
  4716. /**
  4717. * ------------------------------------------------------------------------
  4718. * Constants
  4719. * ------------------------------------------------------------------------
  4720. */
  4721. var NAME$9 = 'tab';
  4722. var VERSION$9 = '4.3.1';
  4723. var DATA_KEY$9 = 'bs.tab';
  4724. var EVENT_KEY$9 = "." + DATA_KEY$9;
  4725. var DATA_API_KEY$7 = '.data-api';
  4726. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  4727. var Event$9 = {
  4728. HIDE: "hide" + EVENT_KEY$9,
  4729. HIDDEN: "hidden" + EVENT_KEY$9,
  4730. SHOW: "show" + EVENT_KEY$9,
  4731. SHOWN: "shown" + EVENT_KEY$9,
  4732. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  4733. };
  4734. var ClassName$9 = {
  4735. DROPDOWN_MENU: 'dropdown-menu',
  4736. ACTIVE: 'active',
  4737. DISABLED: 'disabled',
  4738. FADE: 'fade',
  4739. SHOW: 'show'
  4740. };
  4741. var Selector$9 = {
  4742. DROPDOWN: '.dropdown',
  4743. NAV_LIST_GROUP: '.nav, .list-group',
  4744. ACTIVE: '.active',
  4745. ACTIVE_UL: '> li > .active',
  4746. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  4747. DROPDOWN_TOGGLE: '.dropdown-toggle',
  4748. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  4749. /**
  4750. * ------------------------------------------------------------------------
  4751. * Class Definition
  4752. * ------------------------------------------------------------------------
  4753. */
  4754. };
  4755. var Tab =
  4756. /*#__PURE__*/
  4757. function () {
  4758. function Tab(element) {
  4759. this._element = element;
  4760. } // Getters
  4761. var _proto = Tab.prototype;
  4762. // Public
  4763. _proto.show = function show() {
  4764. var _this = this;
  4765. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  4766. return;
  4767. }
  4768. var target;
  4769. var previous;
  4770. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  4771. var selector = Util.getSelectorFromElement(this._element);
  4772. if (listElement) {
  4773. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  4774. previous = $.makeArray($(listElement).find(itemSelector));
  4775. previous = previous[previous.length - 1];
  4776. }
  4777. var hideEvent = $.Event(Event$9.HIDE, {
  4778. relatedTarget: this._element
  4779. });
  4780. var showEvent = $.Event(Event$9.SHOW, {
  4781. relatedTarget: previous
  4782. });
  4783. if (previous) {
  4784. $(previous).trigger(hideEvent);
  4785. }
  4786. $(this._element).trigger(showEvent);
  4787. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  4788. return;
  4789. }
  4790. if (selector) {
  4791. target = document.querySelector(selector);
  4792. }
  4793. this._activate(this._element, listElement);
  4794. var complete = function complete() {
  4795. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  4796. relatedTarget: _this._element
  4797. });
  4798. var shownEvent = $.Event(Event$9.SHOWN, {
  4799. relatedTarget: previous
  4800. });
  4801. $(previous).trigger(hiddenEvent);
  4802. $(_this._element).trigger(shownEvent);
  4803. };
  4804. if (target) {
  4805. this._activate(target, target.parentNode, complete);
  4806. } else {
  4807. complete();
  4808. }
  4809. };
  4810. _proto.dispose = function dispose() {
  4811. $.removeData(this._element, DATA_KEY$9);
  4812. this._element = null;
  4813. } // Private
  4814. ;
  4815. _proto._activate = function _activate(element, container, callback) {
  4816. var _this2 = this;
  4817. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  4818. var active = activeElements[0];
  4819. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  4820. var complete = function complete() {
  4821. return _this2._transitionComplete(element, active, callback);
  4822. };
  4823. if (active && isTransitioning) {
  4824. var transitionDuration = Util.getTransitionDurationFromElement(active);
  4825. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4826. } else {
  4827. complete();
  4828. }
  4829. };
  4830. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  4831. if (active) {
  4832. $(active).removeClass(ClassName$9.ACTIVE);
  4833. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  4834. if (dropdownChild) {
  4835. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  4836. }
  4837. if (active.getAttribute('role') === 'tab') {
  4838. active.setAttribute('aria-selected', false);
  4839. }
  4840. }
  4841. $(element).addClass(ClassName$9.ACTIVE);
  4842. if (element.getAttribute('role') === 'tab') {
  4843. element.setAttribute('aria-selected', true);
  4844. }
  4845. Util.reflow(element);
  4846. if (element.classList.contains(ClassName$9.FADE)) {
  4847. element.classList.add(ClassName$9.SHOW);
  4848. }
  4849. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  4850. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  4851. if (dropdownElement) {
  4852. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  4853. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  4854. }
  4855. element.setAttribute('aria-expanded', true);
  4856. }
  4857. if (callback) {
  4858. callback();
  4859. }
  4860. } // Static
  4861. ;
  4862. Tab._jQueryInterface = function _jQueryInterface(config) {
  4863. return this.each(function () {
  4864. var $this = $(this);
  4865. var data = $this.data(DATA_KEY$9);
  4866. if (!data) {
  4867. data = new Tab(this);
  4868. $this.data(DATA_KEY$9, data);
  4869. }
  4870. if (typeof config === 'string') {
  4871. if (typeof data[config] === 'undefined') {
  4872. throw new TypeError("No method named \"" + config + "\"");
  4873. }
  4874. data[config]();
  4875. }
  4876. });
  4877. };
  4878. _createClass(Tab, null, [{
  4879. key: "VERSION",
  4880. get: function get() {
  4881. return VERSION$9;
  4882. }
  4883. }]);
  4884. return Tab;
  4885. }();
  4886. /**
  4887. * ------------------------------------------------------------------------
  4888. * Data Api implementation
  4889. * ------------------------------------------------------------------------
  4890. */
  4891. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  4892. event.preventDefault();
  4893. Tab._jQueryInterface.call($(this), 'show');
  4894. });
  4895. /**
  4896. * ------------------------------------------------------------------------
  4897. * jQuery
  4898. * ------------------------------------------------------------------------
  4899. */
  4900. $.fn[NAME$9] = Tab._jQueryInterface;
  4901. $.fn[NAME$9].Constructor = Tab;
  4902. $.fn[NAME$9].noConflict = function () {
  4903. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  4904. return Tab._jQueryInterface;
  4905. };
  4906. /**
  4907. * ------------------------------------------------------------------------
  4908. * Constants
  4909. * ------------------------------------------------------------------------
  4910. */
  4911. var NAME$a = 'toast';
  4912. var VERSION$a = '4.3.1';
  4913. var DATA_KEY$a = 'bs.toast';
  4914. var EVENT_KEY$a = "." + DATA_KEY$a;
  4915. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  4916. var Event$a = {
  4917. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  4918. HIDE: "hide" + EVENT_KEY$a,
  4919. HIDDEN: "hidden" + EVENT_KEY$a,
  4920. SHOW: "show" + EVENT_KEY$a,
  4921. SHOWN: "shown" + EVENT_KEY$a
  4922. };
  4923. var ClassName$a = {
  4924. FADE: 'fade',
  4925. HIDE: 'hide',
  4926. SHOW: 'show',
  4927. SHOWING: 'showing'
  4928. };
  4929. var DefaultType$7 = {
  4930. animation: 'boolean',
  4931. autohide: 'boolean',
  4932. delay: 'number'
  4933. };
  4934. var Default$7 = {
  4935. animation: true,
  4936. autohide: true,
  4937. delay: 500
  4938. };
  4939. var Selector$a = {
  4940. DATA_DISMISS: '[data-dismiss="toast"]'
  4941. /**
  4942. * ------------------------------------------------------------------------
  4943. * Class Definition
  4944. * ------------------------------------------------------------------------
  4945. */
  4946. };
  4947. var Toast =
  4948. /*#__PURE__*/
  4949. function () {
  4950. function Toast(element, config) {
  4951. this._element = element;
  4952. this._config = this._getConfig(config);
  4953. this._timeout = null;
  4954. this._setListeners();
  4955. } // Getters
  4956. var _proto = Toast.prototype;
  4957. // Public
  4958. _proto.show = function show() {
  4959. var _this = this;
  4960. $(this._element).trigger(Event$a.SHOW);
  4961. if (this._config.animation) {
  4962. this._element.classList.add(ClassName$a.FADE);
  4963. }
  4964. var complete = function complete() {
  4965. _this._element.classList.remove(ClassName$a.SHOWING);
  4966. _this._element.classList.add(ClassName$a.SHOW);
  4967. $(_this._element).trigger(Event$a.SHOWN);
  4968. if (_this._config.autohide) {
  4969. _this.hide();
  4970. }
  4971. };
  4972. this._element.classList.remove(ClassName$a.HIDE);
  4973. this._element.classList.add(ClassName$a.SHOWING);
  4974. if (this._config.animation) {
  4975. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  4976. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4977. } else {
  4978. complete();
  4979. }
  4980. };
  4981. _proto.hide = function hide(withoutTimeout) {
  4982. var _this2 = this;
  4983. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  4984. return;
  4985. }
  4986. $(this._element).trigger(Event$a.HIDE);
  4987. if (withoutTimeout) {
  4988. this._close();
  4989. } else {
  4990. this._timeout = setTimeout(function () {
  4991. _this2._close();
  4992. }, this._config.delay);
  4993. }
  4994. };
  4995. _proto.dispose = function dispose() {
  4996. clearTimeout(this._timeout);
  4997. this._timeout = null;
  4998. if (this._element.classList.contains(ClassName$a.SHOW)) {
  4999. this._element.classList.remove(ClassName$a.SHOW);
  5000. }
  5001. $(this._element).off(Event$a.CLICK_DISMISS);
  5002. $.removeData(this._element, DATA_KEY$a);
  5003. this._element = null;
  5004. this._config = null;
  5005. } // Private
  5006. ;
  5007. _proto._getConfig = function _getConfig(config) {
  5008. config = _objectSpread({}, Default$7, $(this._element).data(), typeof config === 'object' && config ? config : {});
  5009. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5010. return config;
  5011. };
  5012. _proto._setListeners = function _setListeners() {
  5013. var _this3 = this;
  5014. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5015. return _this3.hide(true);
  5016. });
  5017. };
  5018. _proto._close = function _close() {
  5019. var _this4 = this;
  5020. var complete = function complete() {
  5021. _this4._element.classList.add(ClassName$a.HIDE);
  5022. $(_this4._element).trigger(Event$a.HIDDEN);
  5023. };
  5024. this._element.classList.remove(ClassName$a.SHOW);
  5025. if (this._config.animation) {
  5026. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5027. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5028. } else {
  5029. complete();
  5030. }
  5031. } // Static
  5032. ;
  5033. Toast._jQueryInterface = function _jQueryInterface(config) {
  5034. return this.each(function () {
  5035. var $element = $(this);
  5036. var data = $element.data(DATA_KEY$a);
  5037. var _config = typeof config === 'object' && config;
  5038. if (!data) {
  5039. data = new Toast(this, _config);
  5040. $element.data(DATA_KEY$a, data);
  5041. }
  5042. if (typeof config === 'string') {
  5043. if (typeof data[config] === 'undefined') {
  5044. throw new TypeError("No method named \"" + config + "\"");
  5045. }
  5046. data[config](this);
  5047. }
  5048. });
  5049. };
  5050. _createClass(Toast, null, [{
  5051. key: "VERSION",
  5052. get: function get() {
  5053. return VERSION$a;
  5054. }
  5055. }, {
  5056. key: "DefaultType",
  5057. get: function get() {
  5058. return DefaultType$7;
  5059. }
  5060. }, {
  5061. key: "Default",
  5062. get: function get() {
  5063. return Default$7;
  5064. }
  5065. }]);
  5066. return Toast;
  5067. }();
  5068. /**
  5069. * ------------------------------------------------------------------------
  5070. * jQuery
  5071. * ------------------------------------------------------------------------
  5072. */
  5073. $.fn[NAME$a] = Toast._jQueryInterface;
  5074. $.fn[NAME$a].Constructor = Toast;
  5075. $.fn[NAME$a].noConflict = function () {
  5076. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5077. return Toast._jQueryInterface;
  5078. };
  5079. /**
  5080. * --------------------------------------------------------------------------
  5081. * Bootstrap (v4.3.1): index.js
  5082. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  5083. * --------------------------------------------------------------------------
  5084. */
  5085. (function () {
  5086. if (typeof $ === 'undefined') {
  5087. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  5088. }
  5089. var version = $.fn.jquery.split(' ')[0].split('.');
  5090. var minMajor = 1;
  5091. var ltMajor = 2;
  5092. var minMinor = 9;
  5093. var minPatch = 1;
  5094. var maxMajor = 4;
  5095. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  5096. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  5097. }
  5098. })();
  5099. exports.Util = Util;
  5100. exports.Alert = Alert;
  5101. exports.Button = Button;
  5102. exports.Carousel = Carousel;
  5103. exports.Collapse = Collapse;
  5104. exports.Dropdown = Dropdown;
  5105. exports.Modal = Modal;
  5106. exports.Popover = Popover;
  5107. exports.Scrollspy = ScrollSpy;
  5108. exports.Tab = Tab;
  5109. exports.Toast = Toast;
  5110. exports.Tooltip = Tooltip;
  5111. Object.defineProperty(exports, '__esModule', { value: true });
  5112. }));
  5113. //# sourceMappingURL=bootstrap.js.map
  5114. /***/ }),
  5115. /***/ "./node_modules/is-buffer/index.js":
  5116. /*!*****************************************!*\
  5117. !*** ./node_modules/is-buffer/index.js ***!
  5118. \*****************************************/
  5119. /*! no static exports found */
  5120. /***/ (function(module, exports) {
  5121. /*!
  5122. * Determine if an object is a Buffer
  5123. *
  5124. * @author Feross Aboukhadijeh <https://feross.org>
  5125. * @license MIT
  5126. */
  5127. module.exports = function isBuffer (obj) {
  5128. return obj != null && obj.constructor != null &&
  5129. typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  5130. }
  5131. /***/ }),
  5132. /***/ "./node_modules/jquery/dist/jquery.js":
  5133. /*!********************************************!*\
  5134. !*** ./node_modules/jquery/dist/jquery.js ***!
  5135. \********************************************/
  5136. /*! no static exports found */
  5137. /***/ (function(module, exports, __webpack_require__) {
  5138. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  5139. * jQuery JavaScript Library v3.4.1
  5140. * https://jquery.com/
  5141. *
  5142. * Includes Sizzle.js
  5143. * https://sizzlejs.com/
  5144. *
  5145. * Copyright JS Foundation and other contributors
  5146. * Released under the MIT license
  5147. * https://jquery.org/license
  5148. *
  5149. * Date: 2019-05-01T21:04Z
  5150. */
  5151. ( function( global, factory ) {
  5152. "use strict";
  5153. if ( true && typeof module.exports === "object" ) {
  5154. // For CommonJS and CommonJS-like environments where a proper `window`
  5155. // is present, execute the factory and get jQuery.
  5156. // For environments that do not have a `window` with a `document`
  5157. // (such as Node.js), expose a factory as module.exports.
  5158. // This accentuates the need for the creation of a real `window`.
  5159. // e.g. var jQuery = require("jquery")(window);
  5160. // See ticket #14549 for more info.
  5161. module.exports = global.document ?
  5162. factory( global, true ) :
  5163. function( w ) {
  5164. if ( !w.document ) {
  5165. throw new Error( "jQuery requires a window with a document" );
  5166. }
  5167. return factory( w );
  5168. };
  5169. } else {
  5170. factory( global );
  5171. }
  5172. // Pass this if window is not defined yet
  5173. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  5174. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  5175. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  5176. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  5177. // enough that all such attempts are guarded in a try block.
  5178. "use strict";
  5179. var arr = [];
  5180. var document = window.document;
  5181. var getProto = Object.getPrototypeOf;
  5182. var slice = arr.slice;
  5183. var concat = arr.concat;
  5184. var push = arr.push;
  5185. var indexOf = arr.indexOf;
  5186. var class2type = {};
  5187. var toString = class2type.toString;
  5188. var hasOwn = class2type.hasOwnProperty;
  5189. var fnToString = hasOwn.toString;
  5190. var ObjectFunctionString = fnToString.call( Object );
  5191. var support = {};
  5192. var isFunction = function isFunction( obj ) {
  5193. // Support: Chrome <=57, Firefox <=52
  5194. // In some browsers, typeof returns "function" for HTML <object> elements
  5195. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  5196. // We don't want to classify *any* DOM node as a function.
  5197. return typeof obj === "function" && typeof obj.nodeType !== "number";
  5198. };
  5199. var isWindow = function isWindow( obj ) {
  5200. return obj != null && obj === obj.window;
  5201. };
  5202. var preservedScriptAttributes = {
  5203. type: true,
  5204. src: true,
  5205. nonce: true,
  5206. noModule: true
  5207. };
  5208. function DOMEval( code, node, doc ) {
  5209. doc = doc || document;
  5210. var i, val,
  5211. script = doc.createElement( "script" );
  5212. script.text = code;
  5213. if ( node ) {
  5214. for ( i in preservedScriptAttributes ) {
  5215. // Support: Firefox 64+, Edge 18+
  5216. // Some browsers don't support the "nonce" property on scripts.
  5217. // On the other hand, just using `getAttribute` is not enough as
  5218. // the `nonce` attribute is reset to an empty string whenever it
  5219. // becomes browsing-context connected.
  5220. // See https://github.com/whatwg/html/issues/2369
  5221. // See https://html.spec.whatwg.org/#nonce-attributes
  5222. // The `node.getAttribute` check was added for the sake of
  5223. // `jQuery.globalEval` so that it can fake a nonce-containing node
  5224. // via an object.
  5225. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  5226. if ( val ) {
  5227. script.setAttribute( i, val );
  5228. }
  5229. }
  5230. }
  5231. doc.head.appendChild( script ).parentNode.removeChild( script );
  5232. }
  5233. function toType( obj ) {
  5234. if ( obj == null ) {
  5235. return obj + "";
  5236. }
  5237. // Support: Android <=2.3 only (functionish RegExp)
  5238. return typeof obj === "object" || typeof obj === "function" ?
  5239. class2type[ toString.call( obj ) ] || "object" :
  5240. typeof obj;
  5241. }
  5242. /* global Symbol */
  5243. // Defining this global in .eslintrc.json would create a danger of using the global
  5244. // unguarded in another place, it seems safer to define global only for this module
  5245. var
  5246. version = "3.4.1",
  5247. // Define a local copy of jQuery
  5248. jQuery = function( selector, context ) {
  5249. // The jQuery object is actually just the init constructor 'enhanced'
  5250. // Need init if jQuery is called (just allow error to be thrown if not included)
  5251. return new jQuery.fn.init( selector, context );
  5252. },
  5253. // Support: Android <=4.0 only
  5254. // Make sure we trim BOM and NBSP
  5255. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  5256. jQuery.fn = jQuery.prototype = {
  5257. // The current version of jQuery being used
  5258. jquery: version,
  5259. constructor: jQuery,
  5260. // The default length of a jQuery object is 0
  5261. length: 0,
  5262. toArray: function() {
  5263. return slice.call( this );
  5264. },
  5265. // Get the Nth element in the matched element set OR
  5266. // Get the whole matched element set as a clean array
  5267. get: function( num ) {
  5268. // Return all the elements in a clean array
  5269. if ( num == null ) {
  5270. return slice.call( this );
  5271. }
  5272. // Return just the one element from the set
  5273. return num < 0 ? this[ num + this.length ] : this[ num ];
  5274. },
  5275. // Take an array of elements and push it onto the stack
  5276. // (returning the new matched element set)
  5277. pushStack: function( elems ) {
  5278. // Build a new jQuery matched element set
  5279. var ret = jQuery.merge( this.constructor(), elems );
  5280. // Add the old object onto the stack (as a reference)
  5281. ret.prevObject = this;
  5282. // Return the newly-formed element set
  5283. return ret;
  5284. },
  5285. // Execute a callback for every element in the matched set.
  5286. each: function( callback ) {
  5287. return jQuery.each( this, callback );
  5288. },
  5289. map: function( callback ) {
  5290. return this.pushStack( jQuery.map( this, function( elem, i ) {
  5291. return callback.call( elem, i, elem );
  5292. } ) );
  5293. },
  5294. slice: function() {
  5295. return this.pushStack( slice.apply( this, arguments ) );
  5296. },
  5297. first: function() {
  5298. return this.eq( 0 );
  5299. },
  5300. last: function() {
  5301. return this.eq( -1 );
  5302. },
  5303. eq: function( i ) {
  5304. var len = this.length,
  5305. j = +i + ( i < 0 ? len : 0 );
  5306. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  5307. },
  5308. end: function() {
  5309. return this.prevObject || this.constructor();
  5310. },
  5311. // For internal use only.
  5312. // Behaves like an Array's method, not like a jQuery method.
  5313. push: push,
  5314. sort: arr.sort,
  5315. splice: arr.splice
  5316. };
  5317. jQuery.extend = jQuery.fn.extend = function() {
  5318. var options, name, src, copy, copyIsArray, clone,
  5319. target = arguments[ 0 ] || {},
  5320. i = 1,
  5321. length = arguments.length,
  5322. deep = false;
  5323. // Handle a deep copy situation
  5324. if ( typeof target === "boolean" ) {
  5325. deep = target;
  5326. // Skip the boolean and the target
  5327. target = arguments[ i ] || {};
  5328. i++;
  5329. }
  5330. // Handle case when target is a string or something (possible in deep copy)
  5331. if ( typeof target !== "object" && !isFunction( target ) ) {
  5332. target = {};
  5333. }
  5334. // Extend jQuery itself if only one argument is passed
  5335. if ( i === length ) {
  5336. target = this;
  5337. i--;
  5338. }
  5339. for ( ; i < length; i++ ) {
  5340. // Only deal with non-null/undefined values
  5341. if ( ( options = arguments[ i ] ) != null ) {
  5342. // Extend the base object
  5343. for ( name in options ) {
  5344. copy = options[ name ];
  5345. // Prevent Object.prototype pollution
  5346. // Prevent never-ending loop
  5347. if ( name === "__proto__" || target === copy ) {
  5348. continue;
  5349. }
  5350. // Recurse if we're merging plain objects or arrays
  5351. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  5352. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  5353. src = target[ name ];
  5354. // Ensure proper type for the source value
  5355. if ( copyIsArray && !Array.isArray( src ) ) {
  5356. clone = [];
  5357. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  5358. clone = {};
  5359. } else {
  5360. clone = src;
  5361. }
  5362. copyIsArray = false;
  5363. // Never move original objects, clone them
  5364. target[ name ] = jQuery.extend( deep, clone, copy );
  5365. // Don't bring in undefined values
  5366. } else if ( copy !== undefined ) {
  5367. target[ name ] = copy;
  5368. }
  5369. }
  5370. }
  5371. }
  5372. // Return the modified object
  5373. return target;
  5374. };
  5375. jQuery.extend( {
  5376. // Unique for each copy of jQuery on the page
  5377. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  5378. // Assume jQuery is ready without the ready module
  5379. isReady: true,
  5380. error: function( msg ) {
  5381. throw new Error( msg );
  5382. },
  5383. noop: function() {},
  5384. isPlainObject: function( obj ) {
  5385. var proto, Ctor;
  5386. // Detect obvious negatives
  5387. // Use toString instead of jQuery.type to catch host objects
  5388. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  5389. return false;
  5390. }
  5391. proto = getProto( obj );
  5392. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  5393. if ( !proto ) {
  5394. return true;
  5395. }
  5396. // Objects with prototype are plain iff they were constructed by a global Object function
  5397. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  5398. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  5399. },
  5400. isEmptyObject: function( obj ) {
  5401. var name;
  5402. for ( name in obj ) {
  5403. return false;
  5404. }
  5405. return true;
  5406. },
  5407. // Evaluates a script in a global context
  5408. globalEval: function( code, options ) {
  5409. DOMEval( code, { nonce: options && options.nonce } );
  5410. },
  5411. each: function( obj, callback ) {
  5412. var length, i = 0;
  5413. if ( isArrayLike( obj ) ) {
  5414. length = obj.length;
  5415. for ( ; i < length; i++ ) {
  5416. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  5417. break;
  5418. }
  5419. }
  5420. } else {
  5421. for ( i in obj ) {
  5422. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  5423. break;
  5424. }
  5425. }
  5426. }
  5427. return obj;
  5428. },
  5429. // Support: Android <=4.0 only
  5430. trim: function( text ) {
  5431. return text == null ?
  5432. "" :
  5433. ( text + "" ).replace( rtrim, "" );
  5434. },
  5435. // results is for internal usage only
  5436. makeArray: function( arr, results ) {
  5437. var ret = results || [];
  5438. if ( arr != null ) {
  5439. if ( isArrayLike( Object( arr ) ) ) {
  5440. jQuery.merge( ret,
  5441. typeof arr === "string" ?
  5442. [ arr ] : arr
  5443. );
  5444. } else {
  5445. push.call( ret, arr );
  5446. }
  5447. }
  5448. return ret;
  5449. },
  5450. inArray: function( elem, arr, i ) {
  5451. return arr == null ? -1 : indexOf.call( arr, elem, i );
  5452. },
  5453. // Support: Android <=4.0 only, PhantomJS 1 only
  5454. // push.apply(_, arraylike) throws on ancient WebKit
  5455. merge: function( first, second ) {
  5456. var len = +second.length,
  5457. j = 0,
  5458. i = first.length;
  5459. for ( ; j < len; j++ ) {
  5460. first[ i++ ] = second[ j ];
  5461. }
  5462. first.length = i;
  5463. return first;
  5464. },
  5465. grep: function( elems, callback, invert ) {
  5466. var callbackInverse,
  5467. matches = [],
  5468. i = 0,
  5469. length = elems.length,
  5470. callbackExpect = !invert;
  5471. // Go through the array, only saving the items
  5472. // that pass the validator function
  5473. for ( ; i < length; i++ ) {
  5474. callbackInverse = !callback( elems[ i ], i );
  5475. if ( callbackInverse !== callbackExpect ) {
  5476. matches.push( elems[ i ] );
  5477. }
  5478. }
  5479. return matches;
  5480. },
  5481. // arg is for internal usage only
  5482. map: function( elems, callback, arg ) {
  5483. var length, value,
  5484. i = 0,
  5485. ret = [];
  5486. // Go through the array, translating each of the items to their new values
  5487. if ( isArrayLike( elems ) ) {
  5488. length = elems.length;
  5489. for ( ; i < length; i++ ) {
  5490. value = callback( elems[ i ], i, arg );
  5491. if ( value != null ) {
  5492. ret.push( value );
  5493. }
  5494. }
  5495. // Go through every key on the object,
  5496. } else {
  5497. for ( i in elems ) {
  5498. value = callback( elems[ i ], i, arg );
  5499. if ( value != null ) {
  5500. ret.push( value );
  5501. }
  5502. }
  5503. }
  5504. // Flatten any nested arrays
  5505. return concat.apply( [], ret );
  5506. },
  5507. // A global GUID counter for objects
  5508. guid: 1,
  5509. // jQuery.support is not used in Core but other projects attach their
  5510. // properties to it so it needs to exist.
  5511. support: support
  5512. } );
  5513. if ( typeof Symbol === "function" ) {
  5514. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  5515. }
  5516. // Populate the class2type map
  5517. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  5518. function( i, name ) {
  5519. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  5520. } );
  5521. function isArrayLike( obj ) {
  5522. // Support: real iOS 8.2 only (not reproducible in simulator)
  5523. // `in` check used to prevent JIT error (gh-2145)
  5524. // hasOwn isn't used here due to false negatives
  5525. // regarding Nodelist length in IE
  5526. var length = !!obj && "length" in obj && obj.length,
  5527. type = toType( obj );
  5528. if ( isFunction( obj ) || isWindow( obj ) ) {
  5529. return false;
  5530. }
  5531. return type === "array" || length === 0 ||
  5532. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  5533. }
  5534. var Sizzle =
  5535. /*!
  5536. * Sizzle CSS Selector Engine v2.3.4
  5537. * https://sizzlejs.com/
  5538. *
  5539. * Copyright JS Foundation and other contributors
  5540. * Released under the MIT license
  5541. * https://js.foundation/
  5542. *
  5543. * Date: 2019-04-08
  5544. */
  5545. (function( window ) {
  5546. var i,
  5547. support,
  5548. Expr,
  5549. getText,
  5550. isXML,
  5551. tokenize,
  5552. compile,
  5553. select,
  5554. outermostContext,
  5555. sortInput,
  5556. hasDuplicate,
  5557. // Local document vars
  5558. setDocument,
  5559. document,
  5560. docElem,
  5561. documentIsHTML,
  5562. rbuggyQSA,
  5563. rbuggyMatches,
  5564. matches,
  5565. contains,
  5566. // Instance-specific data
  5567. expando = "sizzle" + 1 * new Date(),
  5568. preferredDoc = window.document,
  5569. dirruns = 0,
  5570. done = 0,
  5571. classCache = createCache(),
  5572. tokenCache = createCache(),
  5573. compilerCache = createCache(),
  5574. nonnativeSelectorCache = createCache(),
  5575. sortOrder = function( a, b ) {
  5576. if ( a === b ) {
  5577. hasDuplicate = true;
  5578. }
  5579. return 0;
  5580. },
  5581. // Instance methods
  5582. hasOwn = ({}).hasOwnProperty,
  5583. arr = [],
  5584. pop = arr.pop,
  5585. push_native = arr.push,
  5586. push = arr.push,
  5587. slice = arr.slice,
  5588. // Use a stripped-down indexOf as it's faster than native
  5589. // https://jsperf.com/thor-indexof-vs-for/5
  5590. indexOf = function( list, elem ) {
  5591. var i = 0,
  5592. len = list.length;
  5593. for ( ; i < len; i++ ) {
  5594. if ( list[i] === elem ) {
  5595. return i;
  5596. }
  5597. }
  5598. return -1;
  5599. },
  5600. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  5601. // Regular expressions
  5602. // http://www.w3.org/TR/css3-selectors/#whitespace
  5603. whitespace = "[\\x20\\t\\r\\n\\f]",
  5604. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  5605. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  5606. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  5607. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  5608. // Operator (capture 2)
  5609. "*([*^$|!~]?=)" + whitespace +
  5610. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  5611. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  5612. "*\\]",
  5613. pseudos = ":(" + identifier + ")(?:\\((" +
  5614. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  5615. // 1. quoted (capture 3; capture 4 or capture 5)
  5616. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  5617. // 2. simple (capture 6)
  5618. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  5619. // 3. anything else (capture 2)
  5620. ".*" +
  5621. ")\\)|)",
  5622. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  5623. rwhitespace = new RegExp( whitespace + "+", "g" ),
  5624. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  5625. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  5626. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  5627. rdescend = new RegExp( whitespace + "|>" ),
  5628. rpseudo = new RegExp( pseudos ),
  5629. ridentifier = new RegExp( "^" + identifier + "$" ),
  5630. matchExpr = {
  5631. "ID": new RegExp( "^#(" + identifier + ")" ),
  5632. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  5633. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  5634. "ATTR": new RegExp( "^" + attributes ),
  5635. "PSEUDO": new RegExp( "^" + pseudos ),
  5636. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  5637. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  5638. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  5639. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  5640. // For use in libraries implementing .is()
  5641. // We use this for POS matching in `select`
  5642. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  5643. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  5644. },
  5645. rhtml = /HTML$/i,
  5646. rinputs = /^(?:input|select|textarea|button)$/i,
  5647. rheader = /^h\d$/i,
  5648. rnative = /^[^{]+\{\s*\[native \w/,
  5649. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  5650. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  5651. rsibling = /[+~]/,
  5652. // CSS escapes
  5653. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  5654. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  5655. funescape = function( _, escaped, escapedWhitespace ) {
  5656. var high = "0x" + escaped - 0x10000;
  5657. // NaN means non-codepoint
  5658. // Support: Firefox<24
  5659. // Workaround erroneous numeric interpretation of +"0x"
  5660. return high !== high || escapedWhitespace ?
  5661. escaped :
  5662. high < 0 ?
  5663. // BMP codepoint
  5664. String.fromCharCode( high + 0x10000 ) :
  5665. // Supplemental Plane codepoint (surrogate pair)
  5666. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  5667. },
  5668. // CSS string/identifier serialization
  5669. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  5670. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  5671. fcssescape = function( ch, asCodePoint ) {
  5672. if ( asCodePoint ) {
  5673. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  5674. if ( ch === "\0" ) {
  5675. return "\uFFFD";
  5676. }
  5677. // Control characters and (dependent upon position) numbers get escaped as code points
  5678. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  5679. }
  5680. // Other potentially-special ASCII characters get backslash-escaped
  5681. return "\\" + ch;
  5682. },
  5683. // Used for iframes
  5684. // See setDocument()
  5685. // Removing the function wrapper causes a "Permission Denied"
  5686. // error in IE
  5687. unloadHandler = function() {
  5688. setDocument();
  5689. },
  5690. inDisabledFieldset = addCombinator(
  5691. function( elem ) {
  5692. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  5693. },
  5694. { dir: "parentNode", next: "legend" }
  5695. );
  5696. // Optimize for push.apply( _, NodeList )
  5697. try {
  5698. push.apply(
  5699. (arr = slice.call( preferredDoc.childNodes )),
  5700. preferredDoc.childNodes
  5701. );
  5702. // Support: Android<4.0
  5703. // Detect silently failing push.apply
  5704. arr[ preferredDoc.childNodes.length ].nodeType;
  5705. } catch ( e ) {
  5706. push = { apply: arr.length ?
  5707. // Leverage slice if possible
  5708. function( target, els ) {
  5709. push_native.apply( target, slice.call(els) );
  5710. } :
  5711. // Support: IE<9
  5712. // Otherwise append directly
  5713. function( target, els ) {
  5714. var j = target.length,
  5715. i = 0;
  5716. // Can't trust NodeList.length
  5717. while ( (target[j++] = els[i++]) ) {}
  5718. target.length = j - 1;
  5719. }
  5720. };
  5721. }
  5722. function Sizzle( selector, context, results, seed ) {
  5723. var m, i, elem, nid, match, groups, newSelector,
  5724. newContext = context && context.ownerDocument,
  5725. // nodeType defaults to 9, since context defaults to document
  5726. nodeType = context ? context.nodeType : 9;
  5727. results = results || [];
  5728. // Return early from calls with invalid selector or context
  5729. if ( typeof selector !== "string" || !selector ||
  5730. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  5731. return results;
  5732. }
  5733. // Try to shortcut find operations (as opposed to filters) in HTML documents
  5734. if ( !seed ) {
  5735. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  5736. setDocument( context );
  5737. }
  5738. context = context || document;
  5739. if ( documentIsHTML ) {
  5740. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  5741. // (excepting DocumentFragment context, where the methods don't exist)
  5742. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  5743. // ID selector
  5744. if ( (m = match[1]) ) {
  5745. // Document context
  5746. if ( nodeType === 9 ) {
  5747. if ( (elem = context.getElementById( m )) ) {
  5748. // Support: IE, Opera, Webkit
  5749. // TODO: identify versions
  5750. // getElementById can match elements by name instead of ID
  5751. if ( elem.id === m ) {
  5752. results.push( elem );
  5753. return results;
  5754. }
  5755. } else {
  5756. return results;
  5757. }
  5758. // Element context
  5759. } else {
  5760. // Support: IE, Opera, Webkit
  5761. // TODO: identify versions
  5762. // getElementById can match elements by name instead of ID
  5763. if ( newContext && (elem = newContext.getElementById( m )) &&
  5764. contains( context, elem ) &&
  5765. elem.id === m ) {
  5766. results.push( elem );
  5767. return results;
  5768. }
  5769. }
  5770. // Type selector
  5771. } else if ( match[2] ) {
  5772. push.apply( results, context.getElementsByTagName( selector ) );
  5773. return results;
  5774. // Class selector
  5775. } else if ( (m = match[3]) && support.getElementsByClassName &&
  5776. context.getElementsByClassName ) {
  5777. push.apply( results, context.getElementsByClassName( m ) );
  5778. return results;
  5779. }
  5780. }
  5781. // Take advantage of querySelectorAll
  5782. if ( support.qsa &&
  5783. !nonnativeSelectorCache[ selector + " " ] &&
  5784. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  5785. // Support: IE 8 only
  5786. // Exclude object elements
  5787. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  5788. newSelector = selector;
  5789. newContext = context;
  5790. // qSA considers elements outside a scoping root when evaluating child or
  5791. // descendant combinators, which is not what we want.
  5792. // In such cases, we work around the behavior by prefixing every selector in the
  5793. // list with an ID selector referencing the scope context.
  5794. // Thanks to Andrew Dupont for this technique.
  5795. if ( nodeType === 1 && rdescend.test( selector ) ) {
  5796. // Capture the context ID, setting it first if necessary
  5797. if ( (nid = context.getAttribute( "id" )) ) {
  5798. nid = nid.replace( rcssescape, fcssescape );
  5799. } else {
  5800. context.setAttribute( "id", (nid = expando) );
  5801. }
  5802. // Prefix every selector in the list
  5803. groups = tokenize( selector );
  5804. i = groups.length;
  5805. while ( i-- ) {
  5806. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  5807. }
  5808. newSelector = groups.join( "," );
  5809. // Expand context for sibling selectors
  5810. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  5811. context;
  5812. }
  5813. try {
  5814. push.apply( results,
  5815. newContext.querySelectorAll( newSelector )
  5816. );
  5817. return results;
  5818. } catch ( qsaError ) {
  5819. nonnativeSelectorCache( selector, true );
  5820. } finally {
  5821. if ( nid === expando ) {
  5822. context.removeAttribute( "id" );
  5823. }
  5824. }
  5825. }
  5826. }
  5827. }
  5828. // All others
  5829. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  5830. }
  5831. /**
  5832. * Create key-value caches of limited size
  5833. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  5834. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  5835. * deleting the oldest entry
  5836. */
  5837. function createCache() {
  5838. var keys = [];
  5839. function cache( key, value ) {
  5840. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  5841. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  5842. // Only keep the most recent entries
  5843. delete cache[ keys.shift() ];
  5844. }
  5845. return (cache[ key + " " ] = value);
  5846. }
  5847. return cache;
  5848. }
  5849. /**
  5850. * Mark a function for special use by Sizzle
  5851. * @param {Function} fn The function to mark
  5852. */
  5853. function markFunction( fn ) {
  5854. fn[ expando ] = true;
  5855. return fn;
  5856. }
  5857. /**
  5858. * Support testing using an element
  5859. * @param {Function} fn Passed the created element and returns a boolean result
  5860. */
  5861. function assert( fn ) {
  5862. var el = document.createElement("fieldset");
  5863. try {
  5864. return !!fn( el );
  5865. } catch (e) {
  5866. return false;
  5867. } finally {
  5868. // Remove from its parent by default
  5869. if ( el.parentNode ) {
  5870. el.parentNode.removeChild( el );
  5871. }
  5872. // release memory in IE
  5873. el = null;
  5874. }
  5875. }
  5876. /**
  5877. * Adds the same handler for all of the specified attrs
  5878. * @param {String} attrs Pipe-separated list of attributes
  5879. * @param {Function} handler The method that will be applied
  5880. */
  5881. function addHandle( attrs, handler ) {
  5882. var arr = attrs.split("|"),
  5883. i = arr.length;
  5884. while ( i-- ) {
  5885. Expr.attrHandle[ arr[i] ] = handler;
  5886. }
  5887. }
  5888. /**
  5889. * Checks document order of two siblings
  5890. * @param {Element} a
  5891. * @param {Element} b
  5892. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  5893. */
  5894. function siblingCheck( a, b ) {
  5895. var cur = b && a,
  5896. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  5897. a.sourceIndex - b.sourceIndex;
  5898. // Use IE sourceIndex if available on both nodes
  5899. if ( diff ) {
  5900. return diff;
  5901. }
  5902. // Check if b follows a
  5903. if ( cur ) {
  5904. while ( (cur = cur.nextSibling) ) {
  5905. if ( cur === b ) {
  5906. return -1;
  5907. }
  5908. }
  5909. }
  5910. return a ? 1 : -1;
  5911. }
  5912. /**
  5913. * Returns a function to use in pseudos for input types
  5914. * @param {String} type
  5915. */
  5916. function createInputPseudo( type ) {
  5917. return function( elem ) {
  5918. var name = elem.nodeName.toLowerCase();
  5919. return name === "input" && elem.type === type;
  5920. };
  5921. }
  5922. /**
  5923. * Returns a function to use in pseudos for buttons
  5924. * @param {String} type
  5925. */
  5926. function createButtonPseudo( type ) {
  5927. return function( elem ) {
  5928. var name = elem.nodeName.toLowerCase();
  5929. return (name === "input" || name === "button") && elem.type === type;
  5930. };
  5931. }
  5932. /**
  5933. * Returns a function to use in pseudos for :enabled/:disabled
  5934. * @param {Boolean} disabled true for :disabled; false for :enabled
  5935. */
  5936. function createDisabledPseudo( disabled ) {
  5937. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  5938. return function( elem ) {
  5939. // Only certain elements can match :enabled or :disabled
  5940. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  5941. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  5942. if ( "form" in elem ) {
  5943. // Check for inherited disabledness on relevant non-disabled elements:
  5944. // * listed form-associated elements in a disabled fieldset
  5945. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  5946. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  5947. // * option elements in a disabled optgroup
  5948. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  5949. // All such elements have a "form" property.
  5950. if ( elem.parentNode && elem.disabled === false ) {
  5951. // Option elements defer to a parent optgroup if present
  5952. if ( "label" in elem ) {
  5953. if ( "label" in elem.parentNode ) {
  5954. return elem.parentNode.disabled === disabled;
  5955. } else {
  5956. return elem.disabled === disabled;
  5957. }
  5958. }
  5959. // Support: IE 6 - 11
  5960. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  5961. return elem.isDisabled === disabled ||
  5962. // Where there is no isDisabled, check manually
  5963. /* jshint -W018 */
  5964. elem.isDisabled !== !disabled &&
  5965. inDisabledFieldset( elem ) === disabled;
  5966. }
  5967. return elem.disabled === disabled;
  5968. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  5969. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  5970. // even exist on them, let alone have a boolean value.
  5971. } else if ( "label" in elem ) {
  5972. return elem.disabled === disabled;
  5973. }
  5974. // Remaining elements are neither :enabled nor :disabled
  5975. return false;
  5976. };
  5977. }
  5978. /**
  5979. * Returns a function to use in pseudos for positionals
  5980. * @param {Function} fn
  5981. */
  5982. function createPositionalPseudo( fn ) {
  5983. return markFunction(function( argument ) {
  5984. argument = +argument;
  5985. return markFunction(function( seed, matches ) {
  5986. var j,
  5987. matchIndexes = fn( [], seed.length, argument ),
  5988. i = matchIndexes.length;
  5989. // Match elements found at the specified indexes
  5990. while ( i-- ) {
  5991. if ( seed[ (j = matchIndexes[i]) ] ) {
  5992. seed[j] = !(matches[j] = seed[j]);
  5993. }
  5994. }
  5995. });
  5996. });
  5997. }
  5998. /**
  5999. * Checks a node for validity as a Sizzle context
  6000. * @param {Element|Object=} context
  6001. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  6002. */
  6003. function testContext( context ) {
  6004. return context && typeof context.getElementsByTagName !== "undefined" && context;
  6005. }
  6006. // Expose support vars for convenience
  6007. support = Sizzle.support = {};
  6008. /**
  6009. * Detects XML nodes
  6010. * @param {Element|Object} elem An element or a document
  6011. * @returns {Boolean} True iff elem is a non-HTML XML node
  6012. */
  6013. isXML = Sizzle.isXML = function( elem ) {
  6014. var namespace = elem.namespaceURI,
  6015. docElem = (elem.ownerDocument || elem).documentElement;
  6016. // Support: IE <=8
  6017. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  6018. // https://bugs.jquery.com/ticket/4833
  6019. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  6020. };
  6021. /**
  6022. * Sets document-related variables once based on the current document
  6023. * @param {Element|Object} [doc] An element or document object to use to set the document
  6024. * @returns {Object} Returns the current document
  6025. */
  6026. setDocument = Sizzle.setDocument = function( node ) {
  6027. var hasCompare, subWindow,
  6028. doc = node ? node.ownerDocument || node : preferredDoc;
  6029. // Return early if doc is invalid or already selected
  6030. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  6031. return document;
  6032. }
  6033. // Update global variables
  6034. document = doc;
  6035. docElem = document.documentElement;
  6036. documentIsHTML = !isXML( document );
  6037. // Support: IE 9-11, Edge
  6038. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  6039. if ( preferredDoc !== document &&
  6040. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  6041. // Support: IE 11, Edge
  6042. if ( subWindow.addEventListener ) {
  6043. subWindow.addEventListener( "unload", unloadHandler, false );
  6044. // Support: IE 9 - 10 only
  6045. } else if ( subWindow.attachEvent ) {
  6046. subWindow.attachEvent( "onunload", unloadHandler );
  6047. }
  6048. }
  6049. /* Attributes
  6050. ---------------------------------------------------------------------- */
  6051. // Support: IE<8
  6052. // Verify that getAttribute really returns attributes and not properties
  6053. // (excepting IE8 booleans)
  6054. support.attributes = assert(function( el ) {
  6055. el.className = "i";
  6056. return !el.getAttribute("className");
  6057. });
  6058. /* getElement(s)By*
  6059. ---------------------------------------------------------------------- */
  6060. // Check if getElementsByTagName("*") returns only elements
  6061. support.getElementsByTagName = assert(function( el ) {
  6062. el.appendChild( document.createComment("") );
  6063. return !el.getElementsByTagName("*").length;
  6064. });
  6065. // Support: IE<9
  6066. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  6067. // Support: IE<10
  6068. // Check if getElementById returns elements by name
  6069. // The broken getElementById methods don't pick up programmatically-set names,
  6070. // so use a roundabout getElementsByName test
  6071. support.getById = assert(function( el ) {
  6072. docElem.appendChild( el ).id = expando;
  6073. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  6074. });
  6075. // ID filter and find
  6076. if ( support.getById ) {
  6077. Expr.filter["ID"] = function( id ) {
  6078. var attrId = id.replace( runescape, funescape );
  6079. return function( elem ) {
  6080. return elem.getAttribute("id") === attrId;
  6081. };
  6082. };
  6083. Expr.find["ID"] = function( id, context ) {
  6084. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  6085. var elem = context.getElementById( id );
  6086. return elem ? [ elem ] : [];
  6087. }
  6088. };
  6089. } else {
  6090. Expr.filter["ID"] = function( id ) {
  6091. var attrId = id.replace( runescape, funescape );
  6092. return function( elem ) {
  6093. var node = typeof elem.getAttributeNode !== "undefined" &&
  6094. elem.getAttributeNode("id");
  6095. return node && node.value === attrId;
  6096. };
  6097. };
  6098. // Support: IE 6 - 7 only
  6099. // getElementById is not reliable as a find shortcut
  6100. Expr.find["ID"] = function( id, context ) {
  6101. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  6102. var node, i, elems,
  6103. elem = context.getElementById( id );
  6104. if ( elem ) {
  6105. // Verify the id attribute
  6106. node = elem.getAttributeNode("id");
  6107. if ( node && node.value === id ) {
  6108. return [ elem ];
  6109. }
  6110. // Fall back on getElementsByName
  6111. elems = context.getElementsByName( id );
  6112. i = 0;
  6113. while ( (elem = elems[i++]) ) {
  6114. node = elem.getAttributeNode("id");
  6115. if ( node && node.value === id ) {
  6116. return [ elem ];
  6117. }
  6118. }
  6119. }
  6120. return [];
  6121. }
  6122. };
  6123. }
  6124. // Tag
  6125. Expr.find["TAG"] = support.getElementsByTagName ?
  6126. function( tag, context ) {
  6127. if ( typeof context.getElementsByTagName !== "undefined" ) {
  6128. return context.getElementsByTagName( tag );
  6129. // DocumentFragment nodes don't have gEBTN
  6130. } else if ( support.qsa ) {
  6131. return context.querySelectorAll( tag );
  6132. }
  6133. } :
  6134. function( tag, context ) {
  6135. var elem,
  6136. tmp = [],
  6137. i = 0,
  6138. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  6139. results = context.getElementsByTagName( tag );
  6140. // Filter out possible comments
  6141. if ( tag === "*" ) {
  6142. while ( (elem = results[i++]) ) {
  6143. if ( elem.nodeType === 1 ) {
  6144. tmp.push( elem );
  6145. }
  6146. }
  6147. return tmp;
  6148. }
  6149. return results;
  6150. };
  6151. // Class
  6152. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  6153. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  6154. return context.getElementsByClassName( className );
  6155. }
  6156. };
  6157. /* QSA/matchesSelector
  6158. ---------------------------------------------------------------------- */
  6159. // QSA and matchesSelector support
  6160. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  6161. rbuggyMatches = [];
  6162. // qSa(:focus) reports false when true (Chrome 21)
  6163. // We allow this because of a bug in IE8/9 that throws an error
  6164. // whenever `document.activeElement` is accessed on an iframe
  6165. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  6166. // See https://bugs.jquery.com/ticket/13378
  6167. rbuggyQSA = [];
  6168. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  6169. // Build QSA regex
  6170. // Regex strategy adopted from Diego Perini
  6171. assert(function( el ) {
  6172. // Select is set to empty string on purpose
  6173. // This is to test IE's treatment of not explicitly
  6174. // setting a boolean content attribute,
  6175. // since its presence should be enough
  6176. // https://bugs.jquery.com/ticket/12359
  6177. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  6178. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  6179. "<option selected=''></option></select>";
  6180. // Support: IE8, Opera 11-12.16
  6181. // Nothing should be selected when empty strings follow ^= or $= or *=
  6182. // The test attribute must be unknown in Opera but "safe" for WinRT
  6183. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  6184. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  6185. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  6186. }
  6187. // Support: IE8
  6188. // Boolean attributes and "value" are not treated correctly
  6189. if ( !el.querySelectorAll("[selected]").length ) {
  6190. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  6191. }
  6192. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  6193. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  6194. rbuggyQSA.push("~=");
  6195. }
  6196. // Webkit/Opera - :checked should return selected option elements
  6197. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  6198. // IE8 throws error here and will not see later tests
  6199. if ( !el.querySelectorAll(":checked").length ) {
  6200. rbuggyQSA.push(":checked");
  6201. }
  6202. // Support: Safari 8+, iOS 8+
  6203. // https://bugs.webkit.org/show_bug.cgi?id=136851
  6204. // In-page `selector#id sibling-combinator selector` fails
  6205. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  6206. rbuggyQSA.push(".#.+[+~]");
  6207. }
  6208. });
  6209. assert(function( el ) {
  6210. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  6211. "<select disabled='disabled'><option/></select>";
  6212. // Support: Windows 8 Native Apps
  6213. // The type and name attributes are restricted during .innerHTML assignment
  6214. var input = document.createElement("input");
  6215. input.setAttribute( "type", "hidden" );
  6216. el.appendChild( input ).setAttribute( "name", "D" );
  6217. // Support: IE8
  6218. // Enforce case-sensitivity of name attribute
  6219. if ( el.querySelectorAll("[name=d]").length ) {
  6220. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  6221. }
  6222. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  6223. // IE8 throws error here and will not see later tests
  6224. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  6225. rbuggyQSA.push( ":enabled", ":disabled" );
  6226. }
  6227. // Support: IE9-11+
  6228. // IE's :disabled selector does not pick up the children of disabled fieldsets
  6229. docElem.appendChild( el ).disabled = true;
  6230. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  6231. rbuggyQSA.push( ":enabled", ":disabled" );
  6232. }
  6233. // Opera 10-11 does not throw on post-comma invalid pseudos
  6234. el.querySelectorAll("*,:x");
  6235. rbuggyQSA.push(",.*:");
  6236. });
  6237. }
  6238. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  6239. docElem.webkitMatchesSelector ||
  6240. docElem.mozMatchesSelector ||
  6241. docElem.oMatchesSelector ||
  6242. docElem.msMatchesSelector) )) ) {
  6243. assert(function( el ) {
  6244. // Check to see if it's possible to do matchesSelector
  6245. // on a disconnected node (IE 9)
  6246. support.disconnectedMatch = matches.call( el, "*" );
  6247. // This should fail with an exception
  6248. // Gecko does not error, returns false instead
  6249. matches.call( el, "[s!='']:x" );
  6250. rbuggyMatches.push( "!=", pseudos );
  6251. });
  6252. }
  6253. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  6254. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  6255. /* Contains
  6256. ---------------------------------------------------------------------- */
  6257. hasCompare = rnative.test( docElem.compareDocumentPosition );
  6258. // Element contains another
  6259. // Purposefully self-exclusive
  6260. // As in, an element does not contain itself
  6261. contains = hasCompare || rnative.test( docElem.contains ) ?
  6262. function( a, b ) {
  6263. var adown = a.nodeType === 9 ? a.documentElement : a,
  6264. bup = b && b.parentNode;
  6265. return a === bup || !!( bup && bup.nodeType === 1 && (
  6266. adown.contains ?
  6267. adown.contains( bup ) :
  6268. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  6269. ));
  6270. } :
  6271. function( a, b ) {
  6272. if ( b ) {
  6273. while ( (b = b.parentNode) ) {
  6274. if ( b === a ) {
  6275. return true;
  6276. }
  6277. }
  6278. }
  6279. return false;
  6280. };
  6281. /* Sorting
  6282. ---------------------------------------------------------------------- */
  6283. // Document order sorting
  6284. sortOrder = hasCompare ?
  6285. function( a, b ) {
  6286. // Flag for duplicate removal
  6287. if ( a === b ) {
  6288. hasDuplicate = true;
  6289. return 0;
  6290. }
  6291. // Sort on method existence if only one input has compareDocumentPosition
  6292. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  6293. if ( compare ) {
  6294. return compare;
  6295. }
  6296. // Calculate position if both inputs belong to the same document
  6297. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  6298. a.compareDocumentPosition( b ) :
  6299. // Otherwise we know they are disconnected
  6300. 1;
  6301. // Disconnected nodes
  6302. if ( compare & 1 ||
  6303. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  6304. // Choose the first element that is related to our preferred document
  6305. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  6306. return -1;
  6307. }
  6308. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  6309. return 1;
  6310. }
  6311. // Maintain original order
  6312. return sortInput ?
  6313. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  6314. 0;
  6315. }
  6316. return compare & 4 ? -1 : 1;
  6317. } :
  6318. function( a, b ) {
  6319. // Exit early if the nodes are identical
  6320. if ( a === b ) {
  6321. hasDuplicate = true;
  6322. return 0;
  6323. }
  6324. var cur,
  6325. i = 0,
  6326. aup = a.parentNode,
  6327. bup = b.parentNode,
  6328. ap = [ a ],
  6329. bp = [ b ];
  6330. // Parentless nodes are either documents or disconnected
  6331. if ( !aup || !bup ) {
  6332. return a === document ? -1 :
  6333. b === document ? 1 :
  6334. aup ? -1 :
  6335. bup ? 1 :
  6336. sortInput ?
  6337. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  6338. 0;
  6339. // If the nodes are siblings, we can do a quick check
  6340. } else if ( aup === bup ) {
  6341. return siblingCheck( a, b );
  6342. }
  6343. // Otherwise we need full lists of their ancestors for comparison
  6344. cur = a;
  6345. while ( (cur = cur.parentNode) ) {
  6346. ap.unshift( cur );
  6347. }
  6348. cur = b;
  6349. while ( (cur = cur.parentNode) ) {
  6350. bp.unshift( cur );
  6351. }
  6352. // Walk down the tree looking for a discrepancy
  6353. while ( ap[i] === bp[i] ) {
  6354. i++;
  6355. }
  6356. return i ?
  6357. // Do a sibling check if the nodes have a common ancestor
  6358. siblingCheck( ap[i], bp[i] ) :
  6359. // Otherwise nodes in our document sort first
  6360. ap[i] === preferredDoc ? -1 :
  6361. bp[i] === preferredDoc ? 1 :
  6362. 0;
  6363. };
  6364. return document;
  6365. };
  6366. Sizzle.matches = function( expr, elements ) {
  6367. return Sizzle( expr, null, null, elements );
  6368. };
  6369. Sizzle.matchesSelector = function( elem, expr ) {
  6370. // Set document vars if needed
  6371. if ( ( elem.ownerDocument || elem ) !== document ) {
  6372. setDocument( elem );
  6373. }
  6374. if ( support.matchesSelector && documentIsHTML &&
  6375. !nonnativeSelectorCache[ expr + " " ] &&
  6376. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  6377. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  6378. try {
  6379. var ret = matches.call( elem, expr );
  6380. // IE 9's matchesSelector returns false on disconnected nodes
  6381. if ( ret || support.disconnectedMatch ||
  6382. // As well, disconnected nodes are said to be in a document
  6383. // fragment in IE 9
  6384. elem.document && elem.document.nodeType !== 11 ) {
  6385. return ret;
  6386. }
  6387. } catch (e) {
  6388. nonnativeSelectorCache( expr, true );
  6389. }
  6390. }
  6391. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  6392. };
  6393. Sizzle.contains = function( context, elem ) {
  6394. // Set document vars if needed
  6395. if ( ( context.ownerDocument || context ) !== document ) {
  6396. setDocument( context );
  6397. }
  6398. return contains( context, elem );
  6399. };
  6400. Sizzle.attr = function( elem, name ) {
  6401. // Set document vars if needed
  6402. if ( ( elem.ownerDocument || elem ) !== document ) {
  6403. setDocument( elem );
  6404. }
  6405. var fn = Expr.attrHandle[ name.toLowerCase() ],
  6406. // Don't get fooled by Object.prototype properties (jQuery #13807)
  6407. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  6408. fn( elem, name, !documentIsHTML ) :
  6409. undefined;
  6410. return val !== undefined ?
  6411. val :
  6412. support.attributes || !documentIsHTML ?
  6413. elem.getAttribute( name ) :
  6414. (val = elem.getAttributeNode(name)) && val.specified ?
  6415. val.value :
  6416. null;
  6417. };
  6418. Sizzle.escape = function( sel ) {
  6419. return (sel + "").replace( rcssescape, fcssescape );
  6420. };
  6421. Sizzle.error = function( msg ) {
  6422. throw new Error( "Syntax error, unrecognized expression: " + msg );
  6423. };
  6424. /**
  6425. * Document sorting and removing duplicates
  6426. * @param {ArrayLike} results
  6427. */
  6428. Sizzle.uniqueSort = function( results ) {
  6429. var elem,
  6430. duplicates = [],
  6431. j = 0,
  6432. i = 0;
  6433. // Unless we *know* we can detect duplicates, assume their presence
  6434. hasDuplicate = !support.detectDuplicates;
  6435. sortInput = !support.sortStable && results.slice( 0 );
  6436. results.sort( sortOrder );
  6437. if ( hasDuplicate ) {
  6438. while ( (elem = results[i++]) ) {
  6439. if ( elem === results[ i ] ) {
  6440. j = duplicates.push( i );
  6441. }
  6442. }
  6443. while ( j-- ) {
  6444. results.splice( duplicates[ j ], 1 );
  6445. }
  6446. }
  6447. // Clear input after sorting to release objects
  6448. // See https://github.com/jquery/sizzle/pull/225
  6449. sortInput = null;
  6450. return results;
  6451. };
  6452. /**
  6453. * Utility function for retrieving the text value of an array of DOM nodes
  6454. * @param {Array|Element} elem
  6455. */
  6456. getText = Sizzle.getText = function( elem ) {
  6457. var node,
  6458. ret = "",
  6459. i = 0,
  6460. nodeType = elem.nodeType;
  6461. if ( !nodeType ) {
  6462. // If no nodeType, this is expected to be an array
  6463. while ( (node = elem[i++]) ) {
  6464. // Do not traverse comment nodes
  6465. ret += getText( node );
  6466. }
  6467. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  6468. // Use textContent for elements
  6469. // innerText usage removed for consistency of new lines (jQuery #11153)
  6470. if ( typeof elem.textContent === "string" ) {
  6471. return elem.textContent;
  6472. } else {
  6473. // Traverse its children
  6474. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  6475. ret += getText( elem );
  6476. }
  6477. }
  6478. } else if ( nodeType === 3 || nodeType === 4 ) {
  6479. return elem.nodeValue;
  6480. }
  6481. // Do not include comment or processing instruction nodes
  6482. return ret;
  6483. };
  6484. Expr = Sizzle.selectors = {
  6485. // Can be adjusted by the user
  6486. cacheLength: 50,
  6487. createPseudo: markFunction,
  6488. match: matchExpr,
  6489. attrHandle: {},
  6490. find: {},
  6491. relative: {
  6492. ">": { dir: "parentNode", first: true },
  6493. " ": { dir: "parentNode" },
  6494. "+": { dir: "previousSibling", first: true },
  6495. "~": { dir: "previousSibling" }
  6496. },
  6497. preFilter: {
  6498. "ATTR": function( match ) {
  6499. match[1] = match[1].replace( runescape, funescape );
  6500. // Move the given value to match[3] whether quoted or unquoted
  6501. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  6502. if ( match[2] === "~=" ) {
  6503. match[3] = " " + match[3] + " ";
  6504. }
  6505. return match.slice( 0, 4 );
  6506. },
  6507. "CHILD": function( match ) {
  6508. /* matches from matchExpr["CHILD"]
  6509. 1 type (only|nth|...)
  6510. 2 what (child|of-type)
  6511. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  6512. 4 xn-component of xn+y argument ([+-]?\d*n|)
  6513. 5 sign of xn-component
  6514. 6 x of xn-component
  6515. 7 sign of y-component
  6516. 8 y of y-component
  6517. */
  6518. match[1] = match[1].toLowerCase();
  6519. if ( match[1].slice( 0, 3 ) === "nth" ) {
  6520. // nth-* requires argument
  6521. if ( !match[3] ) {
  6522. Sizzle.error( match[0] );
  6523. }
  6524. // numeric x and y parameters for Expr.filter.CHILD
  6525. // remember that false/true cast respectively to 0/1
  6526. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  6527. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  6528. // other types prohibit arguments
  6529. } else if ( match[3] ) {
  6530. Sizzle.error( match[0] );
  6531. }
  6532. return match;
  6533. },
  6534. "PSEUDO": function( match ) {
  6535. var excess,
  6536. unquoted = !match[6] && match[2];
  6537. if ( matchExpr["CHILD"].test( match[0] ) ) {
  6538. return null;
  6539. }
  6540. // Accept quoted arguments as-is
  6541. if ( match[3] ) {
  6542. match[2] = match[4] || match[5] || "";
  6543. // Strip excess characters from unquoted arguments
  6544. } else if ( unquoted && rpseudo.test( unquoted ) &&
  6545. // Get excess from tokenize (recursively)
  6546. (excess = tokenize( unquoted, true )) &&
  6547. // advance to the next closing parenthesis
  6548. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  6549. // excess is a negative index
  6550. match[0] = match[0].slice( 0, excess );
  6551. match[2] = unquoted.slice( 0, excess );
  6552. }
  6553. // Return only captures needed by the pseudo filter method (type and argument)
  6554. return match.slice( 0, 3 );
  6555. }
  6556. },
  6557. filter: {
  6558. "TAG": function( nodeNameSelector ) {
  6559. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  6560. return nodeNameSelector === "*" ?
  6561. function() { return true; } :
  6562. function( elem ) {
  6563. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  6564. };
  6565. },
  6566. "CLASS": function( className ) {
  6567. var pattern = classCache[ className + " " ];
  6568. return pattern ||
  6569. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  6570. classCache( className, function( elem ) {
  6571. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  6572. });
  6573. },
  6574. "ATTR": function( name, operator, check ) {
  6575. return function( elem ) {
  6576. var result = Sizzle.attr( elem, name );
  6577. if ( result == null ) {
  6578. return operator === "!=";
  6579. }
  6580. if ( !operator ) {
  6581. return true;
  6582. }
  6583. result += "";
  6584. return operator === "=" ? result === check :
  6585. operator === "!=" ? result !== check :
  6586. operator === "^=" ? check && result.indexOf( check ) === 0 :
  6587. operator === "*=" ? check && result.indexOf( check ) > -1 :
  6588. operator === "$=" ? check && result.slice( -check.length ) === check :
  6589. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  6590. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  6591. false;
  6592. };
  6593. },
  6594. "CHILD": function( type, what, argument, first, last ) {
  6595. var simple = type.slice( 0, 3 ) !== "nth",
  6596. forward = type.slice( -4 ) !== "last",
  6597. ofType = what === "of-type";
  6598. return first === 1 && last === 0 ?
  6599. // Shortcut for :nth-*(n)
  6600. function( elem ) {
  6601. return !!elem.parentNode;
  6602. } :
  6603. function( elem, context, xml ) {
  6604. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  6605. dir = simple !== forward ? "nextSibling" : "previousSibling",
  6606. parent = elem.parentNode,
  6607. name = ofType && elem.nodeName.toLowerCase(),
  6608. useCache = !xml && !ofType,
  6609. diff = false;
  6610. if ( parent ) {
  6611. // :(first|last|only)-(child|of-type)
  6612. if ( simple ) {
  6613. while ( dir ) {
  6614. node = elem;
  6615. while ( (node = node[ dir ]) ) {
  6616. if ( ofType ?
  6617. node.nodeName.toLowerCase() === name :
  6618. node.nodeType === 1 ) {
  6619. return false;
  6620. }
  6621. }
  6622. // Reverse direction for :only-* (if we haven't yet done so)
  6623. start = dir = type === "only" && !start && "nextSibling";
  6624. }
  6625. return true;
  6626. }
  6627. start = [ forward ? parent.firstChild : parent.lastChild ];
  6628. // non-xml :nth-child(...) stores cache data on `parent`
  6629. if ( forward && useCache ) {
  6630. // Seek `elem` from a previously-cached index
  6631. // ...in a gzip-friendly way
  6632. node = parent;
  6633. outerCache = node[ expando ] || (node[ expando ] = {});
  6634. // Support: IE <9 only
  6635. // Defend against cloned attroperties (jQuery gh-1709)
  6636. uniqueCache = outerCache[ node.uniqueID ] ||
  6637. (outerCache[ node.uniqueID ] = {});
  6638. cache = uniqueCache[ type ] || [];
  6639. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  6640. diff = nodeIndex && cache[ 2 ];
  6641. node = nodeIndex && parent.childNodes[ nodeIndex ];
  6642. while ( (node = ++nodeIndex && node && node[ dir ] ||
  6643. // Fallback to seeking `elem` from the start
  6644. (diff = nodeIndex = 0) || start.pop()) ) {
  6645. // When found, cache indexes on `parent` and break
  6646. if ( node.nodeType === 1 && ++diff && node === elem ) {
  6647. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  6648. break;
  6649. }
  6650. }
  6651. } else {
  6652. // Use previously-cached element index if available
  6653. if ( useCache ) {
  6654. // ...in a gzip-friendly way
  6655. node = elem;
  6656. outerCache = node[ expando ] || (node[ expando ] = {});
  6657. // Support: IE <9 only
  6658. // Defend against cloned attroperties (jQuery gh-1709)
  6659. uniqueCache = outerCache[ node.uniqueID ] ||
  6660. (outerCache[ node.uniqueID ] = {});
  6661. cache = uniqueCache[ type ] || [];
  6662. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  6663. diff = nodeIndex;
  6664. }
  6665. // xml :nth-child(...)
  6666. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  6667. if ( diff === false ) {
  6668. // Use the same loop as above to seek `elem` from the start
  6669. while ( (node = ++nodeIndex && node && node[ dir ] ||
  6670. (diff = nodeIndex = 0) || start.pop()) ) {
  6671. if ( ( ofType ?
  6672. node.nodeName.toLowerCase() === name :
  6673. node.nodeType === 1 ) &&
  6674. ++diff ) {
  6675. // Cache the index of each encountered element
  6676. if ( useCache ) {
  6677. outerCache = node[ expando ] || (node[ expando ] = {});
  6678. // Support: IE <9 only
  6679. // Defend against cloned attroperties (jQuery gh-1709)
  6680. uniqueCache = outerCache[ node.uniqueID ] ||
  6681. (outerCache[ node.uniqueID ] = {});
  6682. uniqueCache[ type ] = [ dirruns, diff ];
  6683. }
  6684. if ( node === elem ) {
  6685. break;
  6686. }
  6687. }
  6688. }
  6689. }
  6690. }
  6691. // Incorporate the offset, then check against cycle size
  6692. diff -= last;
  6693. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  6694. }
  6695. };
  6696. },
  6697. "PSEUDO": function( pseudo, argument ) {
  6698. // pseudo-class names are case-insensitive
  6699. // http://www.w3.org/TR/selectors/#pseudo-classes
  6700. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  6701. // Remember that setFilters inherits from pseudos
  6702. var args,
  6703. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  6704. Sizzle.error( "unsupported pseudo: " + pseudo );
  6705. // The user may use createPseudo to indicate that
  6706. // arguments are needed to create the filter function
  6707. // just as Sizzle does
  6708. if ( fn[ expando ] ) {
  6709. return fn( argument );
  6710. }
  6711. // But maintain support for old signatures
  6712. if ( fn.length > 1 ) {
  6713. args = [ pseudo, pseudo, "", argument ];
  6714. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  6715. markFunction(function( seed, matches ) {
  6716. var idx,
  6717. matched = fn( seed, argument ),
  6718. i = matched.length;
  6719. while ( i-- ) {
  6720. idx = indexOf( seed, matched[i] );
  6721. seed[ idx ] = !( matches[ idx ] = matched[i] );
  6722. }
  6723. }) :
  6724. function( elem ) {
  6725. return fn( elem, 0, args );
  6726. };
  6727. }
  6728. return fn;
  6729. }
  6730. },
  6731. pseudos: {
  6732. // Potentially complex pseudos
  6733. "not": markFunction(function( selector ) {
  6734. // Trim the selector passed to compile
  6735. // to avoid treating leading and trailing
  6736. // spaces as combinators
  6737. var input = [],
  6738. results = [],
  6739. matcher = compile( selector.replace( rtrim, "$1" ) );
  6740. return matcher[ expando ] ?
  6741. markFunction(function( seed, matches, context, xml ) {
  6742. var elem,
  6743. unmatched = matcher( seed, null, xml, [] ),
  6744. i = seed.length;
  6745. // Match elements unmatched by `matcher`
  6746. while ( i-- ) {
  6747. if ( (elem = unmatched[i]) ) {
  6748. seed[i] = !(matches[i] = elem);
  6749. }
  6750. }
  6751. }) :
  6752. function( elem, context, xml ) {
  6753. input[0] = elem;
  6754. matcher( input, null, xml, results );
  6755. // Don't keep the element (issue #299)
  6756. input[0] = null;
  6757. return !results.pop();
  6758. };
  6759. }),
  6760. "has": markFunction(function( selector ) {
  6761. return function( elem ) {
  6762. return Sizzle( selector, elem ).length > 0;
  6763. };
  6764. }),
  6765. "contains": markFunction(function( text ) {
  6766. text = text.replace( runescape, funescape );
  6767. return function( elem ) {
  6768. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  6769. };
  6770. }),
  6771. // "Whether an element is represented by a :lang() selector
  6772. // is based solely on the element's language value
  6773. // being equal to the identifier C,
  6774. // or beginning with the identifier C immediately followed by "-".
  6775. // The matching of C against the element's language value is performed case-insensitively.
  6776. // The identifier C does not have to be a valid language name."
  6777. // http://www.w3.org/TR/selectors/#lang-pseudo
  6778. "lang": markFunction( function( lang ) {
  6779. // lang value must be a valid identifier
  6780. if ( !ridentifier.test(lang || "") ) {
  6781. Sizzle.error( "unsupported lang: " + lang );
  6782. }
  6783. lang = lang.replace( runescape, funescape ).toLowerCase();
  6784. return function( elem ) {
  6785. var elemLang;
  6786. do {
  6787. if ( (elemLang = documentIsHTML ?
  6788. elem.lang :
  6789. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  6790. elemLang = elemLang.toLowerCase();
  6791. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  6792. }
  6793. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  6794. return false;
  6795. };
  6796. }),
  6797. // Miscellaneous
  6798. "target": function( elem ) {
  6799. var hash = window.location && window.location.hash;
  6800. return hash && hash.slice( 1 ) === elem.id;
  6801. },
  6802. "root": function( elem ) {
  6803. return elem === docElem;
  6804. },
  6805. "focus": function( elem ) {
  6806. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  6807. },
  6808. // Boolean properties
  6809. "enabled": createDisabledPseudo( false ),
  6810. "disabled": createDisabledPseudo( true ),
  6811. "checked": function( elem ) {
  6812. // In CSS3, :checked should return both checked and selected elements
  6813. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  6814. var nodeName = elem.nodeName.toLowerCase();
  6815. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  6816. },
  6817. "selected": function( elem ) {
  6818. // Accessing this property makes selected-by-default
  6819. // options in Safari work properly
  6820. if ( elem.parentNode ) {
  6821. elem.parentNode.selectedIndex;
  6822. }
  6823. return elem.selected === true;
  6824. },
  6825. // Contents
  6826. "empty": function( elem ) {
  6827. // http://www.w3.org/TR/selectors/#empty-pseudo
  6828. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  6829. // but not by others (comment: 8; processing instruction: 7; etc.)
  6830. // nodeType < 6 works because attributes (2) do not appear as children
  6831. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  6832. if ( elem.nodeType < 6 ) {
  6833. return false;
  6834. }
  6835. }
  6836. return true;
  6837. },
  6838. "parent": function( elem ) {
  6839. return !Expr.pseudos["empty"]( elem );
  6840. },
  6841. // Element/input types
  6842. "header": function( elem ) {
  6843. return rheader.test( elem.nodeName );
  6844. },
  6845. "input": function( elem ) {
  6846. return rinputs.test( elem.nodeName );
  6847. },
  6848. "button": function( elem ) {
  6849. var name = elem.nodeName.toLowerCase();
  6850. return name === "input" && elem.type === "button" || name === "button";
  6851. },
  6852. "text": function( elem ) {
  6853. var attr;
  6854. return elem.nodeName.toLowerCase() === "input" &&
  6855. elem.type === "text" &&
  6856. // Support: IE<8
  6857. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  6858. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  6859. },
  6860. // Position-in-collection
  6861. "first": createPositionalPseudo(function() {
  6862. return [ 0 ];
  6863. }),
  6864. "last": createPositionalPseudo(function( matchIndexes, length ) {
  6865. return [ length - 1 ];
  6866. }),
  6867. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  6868. return [ argument < 0 ? argument + length : argument ];
  6869. }),
  6870. "even": createPositionalPseudo(function( matchIndexes, length ) {
  6871. var i = 0;
  6872. for ( ; i < length; i += 2 ) {
  6873. matchIndexes.push( i );
  6874. }
  6875. return matchIndexes;
  6876. }),
  6877. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  6878. var i = 1;
  6879. for ( ; i < length; i += 2 ) {
  6880. matchIndexes.push( i );
  6881. }
  6882. return matchIndexes;
  6883. }),
  6884. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  6885. var i = argument < 0 ?
  6886. argument + length :
  6887. argument > length ?
  6888. length :
  6889. argument;
  6890. for ( ; --i >= 0; ) {
  6891. matchIndexes.push( i );
  6892. }
  6893. return matchIndexes;
  6894. }),
  6895. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  6896. var i = argument < 0 ? argument + length : argument;
  6897. for ( ; ++i < length; ) {
  6898. matchIndexes.push( i );
  6899. }
  6900. return matchIndexes;
  6901. })
  6902. }
  6903. };
  6904. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  6905. // Add button/input type pseudos
  6906. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  6907. Expr.pseudos[ i ] = createInputPseudo( i );
  6908. }
  6909. for ( i in { submit: true, reset: true } ) {
  6910. Expr.pseudos[ i ] = createButtonPseudo( i );
  6911. }
  6912. // Easy API for creating new setFilters
  6913. function setFilters() {}
  6914. setFilters.prototype = Expr.filters = Expr.pseudos;
  6915. Expr.setFilters = new setFilters();
  6916. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  6917. var matched, match, tokens, type,
  6918. soFar, groups, preFilters,
  6919. cached = tokenCache[ selector + " " ];
  6920. if ( cached ) {
  6921. return parseOnly ? 0 : cached.slice( 0 );
  6922. }
  6923. soFar = selector;
  6924. groups = [];
  6925. preFilters = Expr.preFilter;
  6926. while ( soFar ) {
  6927. // Comma and first run
  6928. if ( !matched || (match = rcomma.exec( soFar )) ) {
  6929. if ( match ) {
  6930. // Don't consume trailing commas as valid
  6931. soFar = soFar.slice( match[0].length ) || soFar;
  6932. }
  6933. groups.push( (tokens = []) );
  6934. }
  6935. matched = false;
  6936. // Combinators
  6937. if ( (match = rcombinators.exec( soFar )) ) {
  6938. matched = match.shift();
  6939. tokens.push({
  6940. value: matched,
  6941. // Cast descendant combinators to space
  6942. type: match[0].replace( rtrim, " " )
  6943. });
  6944. soFar = soFar.slice( matched.length );
  6945. }
  6946. // Filters
  6947. for ( type in Expr.filter ) {
  6948. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  6949. (match = preFilters[ type ]( match ))) ) {
  6950. matched = match.shift();
  6951. tokens.push({
  6952. value: matched,
  6953. type: type,
  6954. matches: match
  6955. });
  6956. soFar = soFar.slice( matched.length );
  6957. }
  6958. }
  6959. if ( !matched ) {
  6960. break;
  6961. }
  6962. }
  6963. // Return the length of the invalid excess
  6964. // if we're just parsing
  6965. // Otherwise, throw an error or return tokens
  6966. return parseOnly ?
  6967. soFar.length :
  6968. soFar ?
  6969. Sizzle.error( selector ) :
  6970. // Cache the tokens
  6971. tokenCache( selector, groups ).slice( 0 );
  6972. };
  6973. function toSelector( tokens ) {
  6974. var i = 0,
  6975. len = tokens.length,
  6976. selector = "";
  6977. for ( ; i < len; i++ ) {
  6978. selector += tokens[i].value;
  6979. }
  6980. return selector;
  6981. }
  6982. function addCombinator( matcher, combinator, base ) {
  6983. var dir = combinator.dir,
  6984. skip = combinator.next,
  6985. key = skip || dir,
  6986. checkNonElements = base && key === "parentNode",
  6987. doneName = done++;
  6988. return combinator.first ?
  6989. // Check against closest ancestor/preceding element
  6990. function( elem, context, xml ) {
  6991. while ( (elem = elem[ dir ]) ) {
  6992. if ( elem.nodeType === 1 || checkNonElements ) {
  6993. return matcher( elem, context, xml );
  6994. }
  6995. }
  6996. return false;
  6997. } :
  6998. // Check against all ancestor/preceding elements
  6999. function( elem, context, xml ) {
  7000. var oldCache, uniqueCache, outerCache,
  7001. newCache = [ dirruns, doneName ];
  7002. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  7003. if ( xml ) {
  7004. while ( (elem = elem[ dir ]) ) {
  7005. if ( elem.nodeType === 1 || checkNonElements ) {
  7006. if ( matcher( elem, context, xml ) ) {
  7007. return true;
  7008. }
  7009. }
  7010. }
  7011. } else {
  7012. while ( (elem = elem[ dir ]) ) {
  7013. if ( elem.nodeType === 1 || checkNonElements ) {
  7014. outerCache = elem[ expando ] || (elem[ expando ] = {});
  7015. // Support: IE <9 only
  7016. // Defend against cloned attroperties (jQuery gh-1709)
  7017. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  7018. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  7019. elem = elem[ dir ] || elem;
  7020. } else if ( (oldCache = uniqueCache[ key ]) &&
  7021. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  7022. // Assign to newCache so results back-propagate to previous elements
  7023. return (newCache[ 2 ] = oldCache[ 2 ]);
  7024. } else {
  7025. // Reuse newcache so results back-propagate to previous elements
  7026. uniqueCache[ key ] = newCache;
  7027. // A match means we're done; a fail means we have to keep checking
  7028. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  7029. return true;
  7030. }
  7031. }
  7032. }
  7033. }
  7034. }
  7035. return false;
  7036. };
  7037. }
  7038. function elementMatcher( matchers ) {
  7039. return matchers.length > 1 ?
  7040. function( elem, context, xml ) {
  7041. var i = matchers.length;
  7042. while ( i-- ) {
  7043. if ( !matchers[i]( elem, context, xml ) ) {
  7044. return false;
  7045. }
  7046. }
  7047. return true;
  7048. } :
  7049. matchers[0];
  7050. }
  7051. function multipleContexts( selector, contexts, results ) {
  7052. var i = 0,
  7053. len = contexts.length;
  7054. for ( ; i < len; i++ ) {
  7055. Sizzle( selector, contexts[i], results );
  7056. }
  7057. return results;
  7058. }
  7059. function condense( unmatched, map, filter, context, xml ) {
  7060. var elem,
  7061. newUnmatched = [],
  7062. i = 0,
  7063. len = unmatched.length,
  7064. mapped = map != null;
  7065. for ( ; i < len; i++ ) {
  7066. if ( (elem = unmatched[i]) ) {
  7067. if ( !filter || filter( elem, context, xml ) ) {
  7068. newUnmatched.push( elem );
  7069. if ( mapped ) {
  7070. map.push( i );
  7071. }
  7072. }
  7073. }
  7074. }
  7075. return newUnmatched;
  7076. }
  7077. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  7078. if ( postFilter && !postFilter[ expando ] ) {
  7079. postFilter = setMatcher( postFilter );
  7080. }
  7081. if ( postFinder && !postFinder[ expando ] ) {
  7082. postFinder = setMatcher( postFinder, postSelector );
  7083. }
  7084. return markFunction(function( seed, results, context, xml ) {
  7085. var temp, i, elem,
  7086. preMap = [],
  7087. postMap = [],
  7088. preexisting = results.length,
  7089. // Get initial elements from seed or context
  7090. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  7091. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  7092. matcherIn = preFilter && ( seed || !selector ) ?
  7093. condense( elems, preMap, preFilter, context, xml ) :
  7094. elems,
  7095. matcherOut = matcher ?
  7096. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  7097. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  7098. // ...intermediate processing is necessary
  7099. [] :
  7100. // ...otherwise use results directly
  7101. results :
  7102. matcherIn;
  7103. // Find primary matches
  7104. if ( matcher ) {
  7105. matcher( matcherIn, matcherOut, context, xml );
  7106. }
  7107. // Apply postFilter
  7108. if ( postFilter ) {
  7109. temp = condense( matcherOut, postMap );
  7110. postFilter( temp, [], context, xml );
  7111. // Un-match failing elements by moving them back to matcherIn
  7112. i = temp.length;
  7113. while ( i-- ) {
  7114. if ( (elem = temp[i]) ) {
  7115. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  7116. }
  7117. }
  7118. }
  7119. if ( seed ) {
  7120. if ( postFinder || preFilter ) {
  7121. if ( postFinder ) {
  7122. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  7123. temp = [];
  7124. i = matcherOut.length;
  7125. while ( i-- ) {
  7126. if ( (elem = matcherOut[i]) ) {
  7127. // Restore matcherIn since elem is not yet a final match
  7128. temp.push( (matcherIn[i] = elem) );
  7129. }
  7130. }
  7131. postFinder( null, (matcherOut = []), temp, xml );
  7132. }
  7133. // Move matched elements from seed to results to keep them synchronized
  7134. i = matcherOut.length;
  7135. while ( i-- ) {
  7136. if ( (elem = matcherOut[i]) &&
  7137. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  7138. seed[temp] = !(results[temp] = elem);
  7139. }
  7140. }
  7141. }
  7142. // Add elements to results, through postFinder if defined
  7143. } else {
  7144. matcherOut = condense(
  7145. matcherOut === results ?
  7146. matcherOut.splice( preexisting, matcherOut.length ) :
  7147. matcherOut
  7148. );
  7149. if ( postFinder ) {
  7150. postFinder( null, results, matcherOut, xml );
  7151. } else {
  7152. push.apply( results, matcherOut );
  7153. }
  7154. }
  7155. });
  7156. }
  7157. function matcherFromTokens( tokens ) {
  7158. var checkContext, matcher, j,
  7159. len = tokens.length,
  7160. leadingRelative = Expr.relative[ tokens[0].type ],
  7161. implicitRelative = leadingRelative || Expr.relative[" "],
  7162. i = leadingRelative ? 1 : 0,
  7163. // The foundational matcher ensures that elements are reachable from top-level context(s)
  7164. matchContext = addCombinator( function( elem ) {
  7165. return elem === checkContext;
  7166. }, implicitRelative, true ),
  7167. matchAnyContext = addCombinator( function( elem ) {
  7168. return indexOf( checkContext, elem ) > -1;
  7169. }, implicitRelative, true ),
  7170. matchers = [ function( elem, context, xml ) {
  7171. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  7172. (checkContext = context).nodeType ?
  7173. matchContext( elem, context, xml ) :
  7174. matchAnyContext( elem, context, xml ) );
  7175. // Avoid hanging onto element (issue #299)
  7176. checkContext = null;
  7177. return ret;
  7178. } ];
  7179. for ( ; i < len; i++ ) {
  7180. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  7181. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  7182. } else {
  7183. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  7184. // Return special upon seeing a positional matcher
  7185. if ( matcher[ expando ] ) {
  7186. // Find the next relative operator (if any) for proper handling
  7187. j = ++i;
  7188. for ( ; j < len; j++ ) {
  7189. if ( Expr.relative[ tokens[j].type ] ) {
  7190. break;
  7191. }
  7192. }
  7193. return setMatcher(
  7194. i > 1 && elementMatcher( matchers ),
  7195. i > 1 && toSelector(
  7196. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  7197. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  7198. ).replace( rtrim, "$1" ),
  7199. matcher,
  7200. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  7201. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  7202. j < len && toSelector( tokens )
  7203. );
  7204. }
  7205. matchers.push( matcher );
  7206. }
  7207. }
  7208. return elementMatcher( matchers );
  7209. }
  7210. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  7211. var bySet = setMatchers.length > 0,
  7212. byElement = elementMatchers.length > 0,
  7213. superMatcher = function( seed, context, xml, results, outermost ) {
  7214. var elem, j, matcher,
  7215. matchedCount = 0,
  7216. i = "0",
  7217. unmatched = seed && [],
  7218. setMatched = [],
  7219. contextBackup = outermostContext,
  7220. // We must always have either seed elements or outermost context
  7221. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  7222. // Use integer dirruns iff this is the outermost matcher
  7223. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  7224. len = elems.length;
  7225. if ( outermost ) {
  7226. outermostContext = context === document || context || outermost;
  7227. }
  7228. // Add elements passing elementMatchers directly to results
  7229. // Support: IE<9, Safari
  7230. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  7231. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  7232. if ( byElement && elem ) {
  7233. j = 0;
  7234. if ( !context && elem.ownerDocument !== document ) {
  7235. setDocument( elem );
  7236. xml = !documentIsHTML;
  7237. }
  7238. while ( (matcher = elementMatchers[j++]) ) {
  7239. if ( matcher( elem, context || document, xml) ) {
  7240. results.push( elem );
  7241. break;
  7242. }
  7243. }
  7244. if ( outermost ) {
  7245. dirruns = dirrunsUnique;
  7246. }
  7247. }
  7248. // Track unmatched elements for set filters
  7249. if ( bySet ) {
  7250. // They will have gone through all possible matchers
  7251. if ( (elem = !matcher && elem) ) {
  7252. matchedCount--;
  7253. }
  7254. // Lengthen the array for every element, matched or not
  7255. if ( seed ) {
  7256. unmatched.push( elem );
  7257. }
  7258. }
  7259. }
  7260. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  7261. // makes the latter nonnegative.
  7262. matchedCount += i;
  7263. // Apply set filters to unmatched elements
  7264. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  7265. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  7266. // no element matchers and no seed.
  7267. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  7268. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  7269. // numerically zero.
  7270. if ( bySet && i !== matchedCount ) {
  7271. j = 0;
  7272. while ( (matcher = setMatchers[j++]) ) {
  7273. matcher( unmatched, setMatched, context, xml );
  7274. }
  7275. if ( seed ) {
  7276. // Reintegrate element matches to eliminate the need for sorting
  7277. if ( matchedCount > 0 ) {
  7278. while ( i-- ) {
  7279. if ( !(unmatched[i] || setMatched[i]) ) {
  7280. setMatched[i] = pop.call( results );
  7281. }
  7282. }
  7283. }
  7284. // Discard index placeholder values to get only actual matches
  7285. setMatched = condense( setMatched );
  7286. }
  7287. // Add matches to results
  7288. push.apply( results, setMatched );
  7289. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  7290. if ( outermost && !seed && setMatched.length > 0 &&
  7291. ( matchedCount + setMatchers.length ) > 1 ) {
  7292. Sizzle.uniqueSort( results );
  7293. }
  7294. }
  7295. // Override manipulation of globals by nested matchers
  7296. if ( outermost ) {
  7297. dirruns = dirrunsUnique;
  7298. outermostContext = contextBackup;
  7299. }
  7300. return unmatched;
  7301. };
  7302. return bySet ?
  7303. markFunction( superMatcher ) :
  7304. superMatcher;
  7305. }
  7306. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  7307. var i,
  7308. setMatchers = [],
  7309. elementMatchers = [],
  7310. cached = compilerCache[ selector + " " ];
  7311. if ( !cached ) {
  7312. // Generate a function of recursive functions that can be used to check each element
  7313. if ( !match ) {
  7314. match = tokenize( selector );
  7315. }
  7316. i = match.length;
  7317. while ( i-- ) {
  7318. cached = matcherFromTokens( match[i] );
  7319. if ( cached[ expando ] ) {
  7320. setMatchers.push( cached );
  7321. } else {
  7322. elementMatchers.push( cached );
  7323. }
  7324. }
  7325. // Cache the compiled function
  7326. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  7327. // Save selector and tokenization
  7328. cached.selector = selector;
  7329. }
  7330. return cached;
  7331. };
  7332. /**
  7333. * A low-level selection function that works with Sizzle's compiled
  7334. * selector functions
  7335. * @param {String|Function} selector A selector or a pre-compiled
  7336. * selector function built with Sizzle.compile
  7337. * @param {Element} context
  7338. * @param {Array} [results]
  7339. * @param {Array} [seed] A set of elements to match against
  7340. */
  7341. select = Sizzle.select = function( selector, context, results, seed ) {
  7342. var i, tokens, token, type, find,
  7343. compiled = typeof selector === "function" && selector,
  7344. match = !seed && tokenize( (selector = compiled.selector || selector) );
  7345. results = results || [];
  7346. // Try to minimize operations if there is only one selector in the list and no seed
  7347. // (the latter of which guarantees us context)
  7348. if ( match.length === 1 ) {
  7349. // Reduce context if the leading compound selector is an ID
  7350. tokens = match[0] = match[0].slice( 0 );
  7351. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  7352. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  7353. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  7354. if ( !context ) {
  7355. return results;
  7356. // Precompiled matchers will still verify ancestry, so step up a level
  7357. } else if ( compiled ) {
  7358. context = context.parentNode;
  7359. }
  7360. selector = selector.slice( tokens.shift().value.length );
  7361. }
  7362. // Fetch a seed set for right-to-left matching
  7363. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  7364. while ( i-- ) {
  7365. token = tokens[i];
  7366. // Abort if we hit a combinator
  7367. if ( Expr.relative[ (type = token.type) ] ) {
  7368. break;
  7369. }
  7370. if ( (find = Expr.find[ type ]) ) {
  7371. // Search, expanding context for leading sibling combinators
  7372. if ( (seed = find(
  7373. token.matches[0].replace( runescape, funescape ),
  7374. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  7375. )) ) {
  7376. // If seed is empty or no tokens remain, we can return early
  7377. tokens.splice( i, 1 );
  7378. selector = seed.length && toSelector( tokens );
  7379. if ( !selector ) {
  7380. push.apply( results, seed );
  7381. return results;
  7382. }
  7383. break;
  7384. }
  7385. }
  7386. }
  7387. }
  7388. // Compile and execute a filtering function if one is not provided
  7389. // Provide `match` to avoid retokenization if we modified the selector above
  7390. ( compiled || compile( selector, match ) )(
  7391. seed,
  7392. context,
  7393. !documentIsHTML,
  7394. results,
  7395. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  7396. );
  7397. return results;
  7398. };
  7399. // One-time assignments
  7400. // Sort stability
  7401. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  7402. // Support: Chrome 14-35+
  7403. // Always assume duplicates if they aren't passed to the comparison function
  7404. support.detectDuplicates = !!hasDuplicate;
  7405. // Initialize against the default document
  7406. setDocument();
  7407. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  7408. // Detached nodes confoundingly follow *each other*
  7409. support.sortDetached = assert(function( el ) {
  7410. // Should return 1, but returns 4 (following)
  7411. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  7412. });
  7413. // Support: IE<8
  7414. // Prevent attribute/property "interpolation"
  7415. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  7416. if ( !assert(function( el ) {
  7417. el.innerHTML = "<a href='#'></a>";
  7418. return el.firstChild.getAttribute("href") === "#" ;
  7419. }) ) {
  7420. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  7421. if ( !isXML ) {
  7422. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  7423. }
  7424. });
  7425. }
  7426. // Support: IE<9
  7427. // Use defaultValue in place of getAttribute("value")
  7428. if ( !support.attributes || !assert(function( el ) {
  7429. el.innerHTML = "<input/>";
  7430. el.firstChild.setAttribute( "value", "" );
  7431. return el.firstChild.getAttribute( "value" ) === "";
  7432. }) ) {
  7433. addHandle( "value", function( elem, name, isXML ) {
  7434. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  7435. return elem.defaultValue;
  7436. }
  7437. });
  7438. }
  7439. // Support: IE<9
  7440. // Use getAttributeNode to fetch booleans when getAttribute lies
  7441. if ( !assert(function( el ) {
  7442. return el.getAttribute("disabled") == null;
  7443. }) ) {
  7444. addHandle( booleans, function( elem, name, isXML ) {
  7445. var val;
  7446. if ( !isXML ) {
  7447. return elem[ name ] === true ? name.toLowerCase() :
  7448. (val = elem.getAttributeNode( name )) && val.specified ?
  7449. val.value :
  7450. null;
  7451. }
  7452. });
  7453. }
  7454. return Sizzle;
  7455. })( window );
  7456. jQuery.find = Sizzle;
  7457. jQuery.expr = Sizzle.selectors;
  7458. // Deprecated
  7459. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  7460. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  7461. jQuery.text = Sizzle.getText;
  7462. jQuery.isXMLDoc = Sizzle.isXML;
  7463. jQuery.contains = Sizzle.contains;
  7464. jQuery.escapeSelector = Sizzle.escape;
  7465. var dir = function( elem, dir, until ) {
  7466. var matched = [],
  7467. truncate = until !== undefined;
  7468. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  7469. if ( elem.nodeType === 1 ) {
  7470. if ( truncate && jQuery( elem ).is( until ) ) {
  7471. break;
  7472. }
  7473. matched.push( elem );
  7474. }
  7475. }
  7476. return matched;
  7477. };
  7478. var siblings = function( n, elem ) {
  7479. var matched = [];
  7480. for ( ; n; n = n.nextSibling ) {
  7481. if ( n.nodeType === 1 && n !== elem ) {
  7482. matched.push( n );
  7483. }
  7484. }
  7485. return matched;
  7486. };
  7487. var rneedsContext = jQuery.expr.match.needsContext;
  7488. function nodeName( elem, name ) {
  7489. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  7490. };
  7491. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  7492. // Implement the identical functionality for filter and not
  7493. function winnow( elements, qualifier, not ) {
  7494. if ( isFunction( qualifier ) ) {
  7495. return jQuery.grep( elements, function( elem, i ) {
  7496. return !!qualifier.call( elem, i, elem ) !== not;
  7497. } );
  7498. }
  7499. // Single element
  7500. if ( qualifier.nodeType ) {
  7501. return jQuery.grep( elements, function( elem ) {
  7502. return ( elem === qualifier ) !== not;
  7503. } );
  7504. }
  7505. // Arraylike of elements (jQuery, arguments, Array)
  7506. if ( typeof qualifier !== "string" ) {
  7507. return jQuery.grep( elements, function( elem ) {
  7508. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  7509. } );
  7510. }
  7511. // Filtered directly for both simple and complex selectors
  7512. return jQuery.filter( qualifier, elements, not );
  7513. }
  7514. jQuery.filter = function( expr, elems, not ) {
  7515. var elem = elems[ 0 ];
  7516. if ( not ) {
  7517. expr = ":not(" + expr + ")";
  7518. }
  7519. if ( elems.length === 1 && elem.nodeType === 1 ) {
  7520. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  7521. }
  7522. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  7523. return elem.nodeType === 1;
  7524. } ) );
  7525. };
  7526. jQuery.fn.extend( {
  7527. find: function( selector ) {
  7528. var i, ret,
  7529. len = this.length,
  7530. self = this;
  7531. if ( typeof selector !== "string" ) {
  7532. return this.pushStack( jQuery( selector ).filter( function() {
  7533. for ( i = 0; i < len; i++ ) {
  7534. if ( jQuery.contains( self[ i ], this ) ) {
  7535. return true;
  7536. }
  7537. }
  7538. } ) );
  7539. }
  7540. ret = this.pushStack( [] );
  7541. for ( i = 0; i < len; i++ ) {
  7542. jQuery.find( selector, self[ i ], ret );
  7543. }
  7544. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  7545. },
  7546. filter: function( selector ) {
  7547. return this.pushStack( winnow( this, selector || [], false ) );
  7548. },
  7549. not: function( selector ) {
  7550. return this.pushStack( winnow( this, selector || [], true ) );
  7551. },
  7552. is: function( selector ) {
  7553. return !!winnow(
  7554. this,
  7555. // If this is a positional/relative selector, check membership in the returned set
  7556. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  7557. typeof selector === "string" && rneedsContext.test( selector ) ?
  7558. jQuery( selector ) :
  7559. selector || [],
  7560. false
  7561. ).length;
  7562. }
  7563. } );
  7564. // Initialize a jQuery object
  7565. // A central reference to the root jQuery(document)
  7566. var rootjQuery,
  7567. // A simple way to check for HTML strings
  7568. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  7569. // Strict HTML recognition (#11290: must start with <)
  7570. // Shortcut simple #id case for speed
  7571. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  7572. init = jQuery.fn.init = function( selector, context, root ) {
  7573. var match, elem;
  7574. // HANDLE: $(""), $(null), $(undefined), $(false)
  7575. if ( !selector ) {
  7576. return this;
  7577. }
  7578. // Method init() accepts an alternate rootjQuery
  7579. // so migrate can support jQuery.sub (gh-2101)
  7580. root = root || rootjQuery;
  7581. // Handle HTML strings
  7582. if ( typeof selector === "string" ) {
  7583. if ( selector[ 0 ] === "<" &&
  7584. selector[ selector.length - 1 ] === ">" &&
  7585. selector.length >= 3 ) {
  7586. // Assume that strings that start and end with <> are HTML and skip the regex check
  7587. match = [ null, selector, null ];
  7588. } else {
  7589. match = rquickExpr.exec( selector );
  7590. }
  7591. // Match html or make sure no context is specified for #id
  7592. if ( match && ( match[ 1 ] || !context ) ) {
  7593. // HANDLE: $(html) -> $(array)
  7594. if ( match[ 1 ] ) {
  7595. context = context instanceof jQuery ? context[ 0 ] : context;
  7596. // Option to run scripts is true for back-compat
  7597. // Intentionally let the error be thrown if parseHTML is not present
  7598. jQuery.merge( this, jQuery.parseHTML(
  7599. match[ 1 ],
  7600. context && context.nodeType ? context.ownerDocument || context : document,
  7601. true
  7602. ) );
  7603. // HANDLE: $(html, props)
  7604. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  7605. for ( match in context ) {
  7606. // Properties of context are called as methods if possible
  7607. if ( isFunction( this[ match ] ) ) {
  7608. this[ match ]( context[ match ] );
  7609. // ...and otherwise set as attributes
  7610. } else {
  7611. this.attr( match, context[ match ] );
  7612. }
  7613. }
  7614. }
  7615. return this;
  7616. // HANDLE: $(#id)
  7617. } else {
  7618. elem = document.getElementById( match[ 2 ] );
  7619. if ( elem ) {
  7620. // Inject the element directly into the jQuery object
  7621. this[ 0 ] = elem;
  7622. this.length = 1;
  7623. }
  7624. return this;
  7625. }
  7626. // HANDLE: $(expr, $(...))
  7627. } else if ( !context || context.jquery ) {
  7628. return ( context || root ).find( selector );
  7629. // HANDLE: $(expr, context)
  7630. // (which is just equivalent to: $(context).find(expr)
  7631. } else {
  7632. return this.constructor( context ).find( selector );
  7633. }
  7634. // HANDLE: $(DOMElement)
  7635. } else if ( selector.nodeType ) {
  7636. this[ 0 ] = selector;
  7637. this.length = 1;
  7638. return this;
  7639. // HANDLE: $(function)
  7640. // Shortcut for document ready
  7641. } else if ( isFunction( selector ) ) {
  7642. return root.ready !== undefined ?
  7643. root.ready( selector ) :
  7644. // Execute immediately if ready is not present
  7645. selector( jQuery );
  7646. }
  7647. return jQuery.makeArray( selector, this );
  7648. };
  7649. // Give the init function the jQuery prototype for later instantiation
  7650. init.prototype = jQuery.fn;
  7651. // Initialize central reference
  7652. rootjQuery = jQuery( document );
  7653. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  7654. // Methods guaranteed to produce a unique set when starting from a unique set
  7655. guaranteedUnique = {
  7656. children: true,
  7657. contents: true,
  7658. next: true,
  7659. prev: true
  7660. };
  7661. jQuery.fn.extend( {
  7662. has: function( target ) {
  7663. var targets = jQuery( target, this ),
  7664. l = targets.length;
  7665. return this.filter( function() {
  7666. var i = 0;
  7667. for ( ; i < l; i++ ) {
  7668. if ( jQuery.contains( this, targets[ i ] ) ) {
  7669. return true;
  7670. }
  7671. }
  7672. } );
  7673. },
  7674. closest: function( selectors, context ) {
  7675. var cur,
  7676. i = 0,
  7677. l = this.length,
  7678. matched = [],
  7679. targets = typeof selectors !== "string" && jQuery( selectors );
  7680. // Positional selectors never match, since there's no _selection_ context
  7681. if ( !rneedsContext.test( selectors ) ) {
  7682. for ( ; i < l; i++ ) {
  7683. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  7684. // Always skip document fragments
  7685. if ( cur.nodeType < 11 && ( targets ?
  7686. targets.index( cur ) > -1 :
  7687. // Don't pass non-elements to Sizzle
  7688. cur.nodeType === 1 &&
  7689. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  7690. matched.push( cur );
  7691. break;
  7692. }
  7693. }
  7694. }
  7695. }
  7696. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  7697. },
  7698. // Determine the position of an element within the set
  7699. index: function( elem ) {
  7700. // No argument, return index in parent
  7701. if ( !elem ) {
  7702. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  7703. }
  7704. // Index in selector
  7705. if ( typeof elem === "string" ) {
  7706. return indexOf.call( jQuery( elem ), this[ 0 ] );
  7707. }
  7708. // Locate the position of the desired element
  7709. return indexOf.call( this,
  7710. // If it receives a jQuery object, the first element is used
  7711. elem.jquery ? elem[ 0 ] : elem
  7712. );
  7713. },
  7714. add: function( selector, context ) {
  7715. return this.pushStack(
  7716. jQuery.uniqueSort(
  7717. jQuery.merge( this.get(), jQuery( selector, context ) )
  7718. )
  7719. );
  7720. },
  7721. addBack: function( selector ) {
  7722. return this.add( selector == null ?
  7723. this.prevObject : this.prevObject.filter( selector )
  7724. );
  7725. }
  7726. } );
  7727. function sibling( cur, dir ) {
  7728. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  7729. return cur;
  7730. }
  7731. jQuery.each( {
  7732. parent: function( elem ) {
  7733. var parent = elem.parentNode;
  7734. return parent && parent.nodeType !== 11 ? parent : null;
  7735. },
  7736. parents: function( elem ) {
  7737. return dir( elem, "parentNode" );
  7738. },
  7739. parentsUntil: function( elem, i, until ) {
  7740. return dir( elem, "parentNode", until );
  7741. },
  7742. next: function( elem ) {
  7743. return sibling( elem, "nextSibling" );
  7744. },
  7745. prev: function( elem ) {
  7746. return sibling( elem, "previousSibling" );
  7747. },
  7748. nextAll: function( elem ) {
  7749. return dir( elem, "nextSibling" );
  7750. },
  7751. prevAll: function( elem ) {
  7752. return dir( elem, "previousSibling" );
  7753. },
  7754. nextUntil: function( elem, i, until ) {
  7755. return dir( elem, "nextSibling", until );
  7756. },
  7757. prevUntil: function( elem, i, until ) {
  7758. return dir( elem, "previousSibling", until );
  7759. },
  7760. siblings: function( elem ) {
  7761. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  7762. },
  7763. children: function( elem ) {
  7764. return siblings( elem.firstChild );
  7765. },
  7766. contents: function( elem ) {
  7767. if ( typeof elem.contentDocument !== "undefined" ) {
  7768. return elem.contentDocument;
  7769. }
  7770. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  7771. // Treat the template element as a regular one in browsers that
  7772. // don't support it.
  7773. if ( nodeName( elem, "template" ) ) {
  7774. elem = elem.content || elem;
  7775. }
  7776. return jQuery.merge( [], elem.childNodes );
  7777. }
  7778. }, function( name, fn ) {
  7779. jQuery.fn[ name ] = function( until, selector ) {
  7780. var matched = jQuery.map( this, fn, until );
  7781. if ( name.slice( -5 ) !== "Until" ) {
  7782. selector = until;
  7783. }
  7784. if ( selector && typeof selector === "string" ) {
  7785. matched = jQuery.filter( selector, matched );
  7786. }
  7787. if ( this.length > 1 ) {
  7788. // Remove duplicates
  7789. if ( !guaranteedUnique[ name ] ) {
  7790. jQuery.uniqueSort( matched );
  7791. }
  7792. // Reverse order for parents* and prev-derivatives
  7793. if ( rparentsprev.test( name ) ) {
  7794. matched.reverse();
  7795. }
  7796. }
  7797. return this.pushStack( matched );
  7798. };
  7799. } );
  7800. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  7801. // Convert String-formatted options into Object-formatted ones
  7802. function createOptions( options ) {
  7803. var object = {};
  7804. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  7805. object[ flag ] = true;
  7806. } );
  7807. return object;
  7808. }
  7809. /*
  7810. * Create a callback list using the following parameters:
  7811. *
  7812. * options: an optional list of space-separated options that will change how
  7813. * the callback list behaves or a more traditional option object
  7814. *
  7815. * By default a callback list will act like an event callback list and can be
  7816. * "fired" multiple times.
  7817. *
  7818. * Possible options:
  7819. *
  7820. * once: will ensure the callback list can only be fired once (like a Deferred)
  7821. *
  7822. * memory: will keep track of previous values and will call any callback added
  7823. * after the list has been fired right away with the latest "memorized"
  7824. * values (like a Deferred)
  7825. *
  7826. * unique: will ensure a callback can only be added once (no duplicate in the list)
  7827. *
  7828. * stopOnFalse: interrupt callings when a callback returns false
  7829. *
  7830. */
  7831. jQuery.Callbacks = function( options ) {
  7832. // Convert options from String-formatted to Object-formatted if needed
  7833. // (we check in cache first)
  7834. options = typeof options === "string" ?
  7835. createOptions( options ) :
  7836. jQuery.extend( {}, options );
  7837. var // Flag to know if list is currently firing
  7838. firing,
  7839. // Last fire value for non-forgettable lists
  7840. memory,
  7841. // Flag to know if list was already fired
  7842. fired,
  7843. // Flag to prevent firing
  7844. locked,
  7845. // Actual callback list
  7846. list = [],
  7847. // Queue of execution data for repeatable lists
  7848. queue = [],
  7849. // Index of currently firing callback (modified by add/remove as needed)
  7850. firingIndex = -1,
  7851. // Fire callbacks
  7852. fire = function() {
  7853. // Enforce single-firing
  7854. locked = locked || options.once;
  7855. // Execute callbacks for all pending executions,
  7856. // respecting firingIndex overrides and runtime changes
  7857. fired = firing = true;
  7858. for ( ; queue.length; firingIndex = -1 ) {
  7859. memory = queue.shift();
  7860. while ( ++firingIndex < list.length ) {
  7861. // Run callback and check for early termination
  7862. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  7863. options.stopOnFalse ) {
  7864. // Jump to end and forget the data so .add doesn't re-fire
  7865. firingIndex = list.length;
  7866. memory = false;
  7867. }
  7868. }
  7869. }
  7870. // Forget the data if we're done with it
  7871. if ( !options.memory ) {
  7872. memory = false;
  7873. }
  7874. firing = false;
  7875. // Clean up if we're done firing for good
  7876. if ( locked ) {
  7877. // Keep an empty list if we have data for future add calls
  7878. if ( memory ) {
  7879. list = [];
  7880. // Otherwise, this object is spent
  7881. } else {
  7882. list = "";
  7883. }
  7884. }
  7885. },
  7886. // Actual Callbacks object
  7887. self = {
  7888. // Add a callback or a collection of callbacks to the list
  7889. add: function() {
  7890. if ( list ) {
  7891. // If we have memory from a past run, we should fire after adding
  7892. if ( memory && !firing ) {
  7893. firingIndex = list.length - 1;
  7894. queue.push( memory );
  7895. }
  7896. ( function add( args ) {
  7897. jQuery.each( args, function( _, arg ) {
  7898. if ( isFunction( arg ) ) {
  7899. if ( !options.unique || !self.has( arg ) ) {
  7900. list.push( arg );
  7901. }
  7902. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  7903. // Inspect recursively
  7904. add( arg );
  7905. }
  7906. } );
  7907. } )( arguments );
  7908. if ( memory && !firing ) {
  7909. fire();
  7910. }
  7911. }
  7912. return this;
  7913. },
  7914. // Remove a callback from the list
  7915. remove: function() {
  7916. jQuery.each( arguments, function( _, arg ) {
  7917. var index;
  7918. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  7919. list.splice( index, 1 );
  7920. // Handle firing indexes
  7921. if ( index <= firingIndex ) {
  7922. firingIndex--;
  7923. }
  7924. }
  7925. } );
  7926. return this;
  7927. },
  7928. // Check if a given callback is in the list.
  7929. // If no argument is given, return whether or not list has callbacks attached.
  7930. has: function( fn ) {
  7931. return fn ?
  7932. jQuery.inArray( fn, list ) > -1 :
  7933. list.length > 0;
  7934. },
  7935. // Remove all callbacks from the list
  7936. empty: function() {
  7937. if ( list ) {
  7938. list = [];
  7939. }
  7940. return this;
  7941. },
  7942. // Disable .fire and .add
  7943. // Abort any current/pending executions
  7944. // Clear all callbacks and values
  7945. disable: function() {
  7946. locked = queue = [];
  7947. list = memory = "";
  7948. return this;
  7949. },
  7950. disabled: function() {
  7951. return !list;
  7952. },
  7953. // Disable .fire
  7954. // Also disable .add unless we have memory (since it would have no effect)
  7955. // Abort any pending executions
  7956. lock: function() {
  7957. locked = queue = [];
  7958. if ( !memory && !firing ) {
  7959. list = memory = "";
  7960. }
  7961. return this;
  7962. },
  7963. locked: function() {
  7964. return !!locked;
  7965. },
  7966. // Call all callbacks with the given context and arguments
  7967. fireWith: function( context, args ) {
  7968. if ( !locked ) {
  7969. args = args || [];
  7970. args = [ context, args.slice ? args.slice() : args ];
  7971. queue.push( args );
  7972. if ( !firing ) {
  7973. fire();
  7974. }
  7975. }
  7976. return this;
  7977. },
  7978. // Call all the callbacks with the given arguments
  7979. fire: function() {
  7980. self.fireWith( this, arguments );
  7981. return this;
  7982. },
  7983. // To know if the callbacks have already been called at least once
  7984. fired: function() {
  7985. return !!fired;
  7986. }
  7987. };
  7988. return self;
  7989. };
  7990. function Identity( v ) {
  7991. return v;
  7992. }
  7993. function Thrower( ex ) {
  7994. throw ex;
  7995. }
  7996. function adoptValue( value, resolve, reject, noValue ) {
  7997. var method;
  7998. try {
  7999. // Check for promise aspect first to privilege synchronous behavior
  8000. if ( value && isFunction( ( method = value.promise ) ) ) {
  8001. method.call( value ).done( resolve ).fail( reject );
  8002. // Other thenables
  8003. } else if ( value && isFunction( ( method = value.then ) ) ) {
  8004. method.call( value, resolve, reject );
  8005. // Other non-thenables
  8006. } else {
  8007. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  8008. // * false: [ value ].slice( 0 ) => resolve( value )
  8009. // * true: [ value ].slice( 1 ) => resolve()
  8010. resolve.apply( undefined, [ value ].slice( noValue ) );
  8011. }
  8012. // For Promises/A+, convert exceptions into rejections
  8013. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  8014. // Deferred#then to conditionally suppress rejection.
  8015. } catch ( value ) {
  8016. // Support: Android 4.0 only
  8017. // Strict mode functions invoked without .call/.apply get global-object context
  8018. reject.apply( undefined, [ value ] );
  8019. }
  8020. }
  8021. jQuery.extend( {
  8022. Deferred: function( func ) {
  8023. var tuples = [
  8024. // action, add listener, callbacks,
  8025. // ... .then handlers, argument index, [final state]
  8026. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  8027. jQuery.Callbacks( "memory" ), 2 ],
  8028. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  8029. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  8030. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  8031. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  8032. ],
  8033. state = "pending",
  8034. promise = {
  8035. state: function() {
  8036. return state;
  8037. },
  8038. always: function() {
  8039. deferred.done( arguments ).fail( arguments );
  8040. return this;
  8041. },
  8042. "catch": function( fn ) {
  8043. return promise.then( null, fn );
  8044. },
  8045. // Keep pipe for back-compat
  8046. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  8047. var fns = arguments;
  8048. return jQuery.Deferred( function( newDefer ) {
  8049. jQuery.each( tuples, function( i, tuple ) {
  8050. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  8051. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  8052. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  8053. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  8054. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  8055. deferred[ tuple[ 1 ] ]( function() {
  8056. var returned = fn && fn.apply( this, arguments );
  8057. if ( returned && isFunction( returned.promise ) ) {
  8058. returned.promise()
  8059. .progress( newDefer.notify )
  8060. .done( newDefer.resolve )
  8061. .fail( newDefer.reject );
  8062. } else {
  8063. newDefer[ tuple[ 0 ] + "With" ](
  8064. this,
  8065. fn ? [ returned ] : arguments
  8066. );
  8067. }
  8068. } );
  8069. } );
  8070. fns = null;
  8071. } ).promise();
  8072. },
  8073. then: function( onFulfilled, onRejected, onProgress ) {
  8074. var maxDepth = 0;
  8075. function resolve( depth, deferred, handler, special ) {
  8076. return function() {
  8077. var that = this,
  8078. args = arguments,
  8079. mightThrow = function() {
  8080. var returned, then;
  8081. // Support: Promises/A+ section 2.3.3.3.3
  8082. // https://promisesaplus.com/#point-59
  8083. // Ignore double-resolution attempts
  8084. if ( depth < maxDepth ) {
  8085. return;
  8086. }
  8087. returned = handler.apply( that, args );
  8088. // Support: Promises/A+ section 2.3.1
  8089. // https://promisesaplus.com/#point-48
  8090. if ( returned === deferred.promise() ) {
  8091. throw new TypeError( "Thenable self-resolution" );
  8092. }
  8093. // Support: Promises/A+ sections 2.3.3.1, 3.5
  8094. // https://promisesaplus.com/#point-54
  8095. // https://promisesaplus.com/#point-75
  8096. // Retrieve `then` only once
  8097. then = returned &&
  8098. // Support: Promises/A+ section 2.3.4
  8099. // https://promisesaplus.com/#point-64
  8100. // Only check objects and functions for thenability
  8101. ( typeof returned === "object" ||
  8102. typeof returned === "function" ) &&
  8103. returned.then;
  8104. // Handle a returned thenable
  8105. if ( isFunction( then ) ) {
  8106. // Special processors (notify) just wait for resolution
  8107. if ( special ) {
  8108. then.call(
  8109. returned,
  8110. resolve( maxDepth, deferred, Identity, special ),
  8111. resolve( maxDepth, deferred, Thrower, special )
  8112. );
  8113. // Normal processors (resolve) also hook into progress
  8114. } else {
  8115. // ...and disregard older resolution values
  8116. maxDepth++;
  8117. then.call(
  8118. returned,
  8119. resolve( maxDepth, deferred, Identity, special ),
  8120. resolve( maxDepth, deferred, Thrower, special ),
  8121. resolve( maxDepth, deferred, Identity,
  8122. deferred.notifyWith )
  8123. );
  8124. }
  8125. // Handle all other returned values
  8126. } else {
  8127. // Only substitute handlers pass on context
  8128. // and multiple values (non-spec behavior)
  8129. if ( handler !== Identity ) {
  8130. that = undefined;
  8131. args = [ returned ];
  8132. }
  8133. // Process the value(s)
  8134. // Default process is resolve
  8135. ( special || deferred.resolveWith )( that, args );
  8136. }
  8137. },
  8138. // Only normal processors (resolve) catch and reject exceptions
  8139. process = special ?
  8140. mightThrow :
  8141. function() {
  8142. try {
  8143. mightThrow();
  8144. } catch ( e ) {
  8145. if ( jQuery.Deferred.exceptionHook ) {
  8146. jQuery.Deferred.exceptionHook( e,
  8147. process.stackTrace );
  8148. }
  8149. // Support: Promises/A+ section 2.3.3.3.4.1
  8150. // https://promisesaplus.com/#point-61
  8151. // Ignore post-resolution exceptions
  8152. if ( depth + 1 >= maxDepth ) {
  8153. // Only substitute handlers pass on context
  8154. // and multiple values (non-spec behavior)
  8155. if ( handler !== Thrower ) {
  8156. that = undefined;
  8157. args = [ e ];
  8158. }
  8159. deferred.rejectWith( that, args );
  8160. }
  8161. }
  8162. };
  8163. // Support: Promises/A+ section 2.3.3.3.1
  8164. // https://promisesaplus.com/#point-57
  8165. // Re-resolve promises immediately to dodge false rejection from
  8166. // subsequent errors
  8167. if ( depth ) {
  8168. process();
  8169. } else {
  8170. // Call an optional hook to record the stack, in case of exception
  8171. // since it's otherwise lost when execution goes async
  8172. if ( jQuery.Deferred.getStackHook ) {
  8173. process.stackTrace = jQuery.Deferred.getStackHook();
  8174. }
  8175. window.setTimeout( process );
  8176. }
  8177. };
  8178. }
  8179. return jQuery.Deferred( function( newDefer ) {
  8180. // progress_handlers.add( ... )
  8181. tuples[ 0 ][ 3 ].add(
  8182. resolve(
  8183. 0,
  8184. newDefer,
  8185. isFunction( onProgress ) ?
  8186. onProgress :
  8187. Identity,
  8188. newDefer.notifyWith
  8189. )
  8190. );
  8191. // fulfilled_handlers.add( ... )
  8192. tuples[ 1 ][ 3 ].add(
  8193. resolve(
  8194. 0,
  8195. newDefer,
  8196. isFunction( onFulfilled ) ?
  8197. onFulfilled :
  8198. Identity
  8199. )
  8200. );
  8201. // rejected_handlers.add( ... )
  8202. tuples[ 2 ][ 3 ].add(
  8203. resolve(
  8204. 0,
  8205. newDefer,
  8206. isFunction( onRejected ) ?
  8207. onRejected :
  8208. Thrower
  8209. )
  8210. );
  8211. } ).promise();
  8212. },
  8213. // Get a promise for this deferred
  8214. // If obj is provided, the promise aspect is added to the object
  8215. promise: function( obj ) {
  8216. return obj != null ? jQuery.extend( obj, promise ) : promise;
  8217. }
  8218. },
  8219. deferred = {};
  8220. // Add list-specific methods
  8221. jQuery.each( tuples, function( i, tuple ) {
  8222. var list = tuple[ 2 ],
  8223. stateString = tuple[ 5 ];
  8224. // promise.progress = list.add
  8225. // promise.done = list.add
  8226. // promise.fail = list.add
  8227. promise[ tuple[ 1 ] ] = list.add;
  8228. // Handle state
  8229. if ( stateString ) {
  8230. list.add(
  8231. function() {
  8232. // state = "resolved" (i.e., fulfilled)
  8233. // state = "rejected"
  8234. state = stateString;
  8235. },
  8236. // rejected_callbacks.disable
  8237. // fulfilled_callbacks.disable
  8238. tuples[ 3 - i ][ 2 ].disable,
  8239. // rejected_handlers.disable
  8240. // fulfilled_handlers.disable
  8241. tuples[ 3 - i ][ 3 ].disable,
  8242. // progress_callbacks.lock
  8243. tuples[ 0 ][ 2 ].lock,
  8244. // progress_handlers.lock
  8245. tuples[ 0 ][ 3 ].lock
  8246. );
  8247. }
  8248. // progress_handlers.fire
  8249. // fulfilled_handlers.fire
  8250. // rejected_handlers.fire
  8251. list.add( tuple[ 3 ].fire );
  8252. // deferred.notify = function() { deferred.notifyWith(...) }
  8253. // deferred.resolve = function() { deferred.resolveWith(...) }
  8254. // deferred.reject = function() { deferred.rejectWith(...) }
  8255. deferred[ tuple[ 0 ] ] = function() {
  8256. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  8257. return this;
  8258. };
  8259. // deferred.notifyWith = list.fireWith
  8260. // deferred.resolveWith = list.fireWith
  8261. // deferred.rejectWith = list.fireWith
  8262. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  8263. } );
  8264. // Make the deferred a promise
  8265. promise.promise( deferred );
  8266. // Call given func if any
  8267. if ( func ) {
  8268. func.call( deferred, deferred );
  8269. }
  8270. // All done!
  8271. return deferred;
  8272. },
  8273. // Deferred helper
  8274. when: function( singleValue ) {
  8275. var
  8276. // count of uncompleted subordinates
  8277. remaining = arguments.length,
  8278. // count of unprocessed arguments
  8279. i = remaining,
  8280. // subordinate fulfillment data
  8281. resolveContexts = Array( i ),
  8282. resolveValues = slice.call( arguments ),
  8283. // the master Deferred
  8284. master = jQuery.Deferred(),
  8285. // subordinate callback factory
  8286. updateFunc = function( i ) {
  8287. return function( value ) {
  8288. resolveContexts[ i ] = this;
  8289. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  8290. if ( !( --remaining ) ) {
  8291. master.resolveWith( resolveContexts, resolveValues );
  8292. }
  8293. };
  8294. };
  8295. // Single- and empty arguments are adopted like Promise.resolve
  8296. if ( remaining <= 1 ) {
  8297. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  8298. !remaining );
  8299. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  8300. if ( master.state() === "pending" ||
  8301. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  8302. return master.then();
  8303. }
  8304. }
  8305. // Multiple arguments are aggregated like Promise.all array elements
  8306. while ( i-- ) {
  8307. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  8308. }
  8309. return master.promise();
  8310. }
  8311. } );
  8312. // These usually indicate a programmer mistake during development,
  8313. // warn about them ASAP rather than swallowing them by default.
  8314. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  8315. jQuery.Deferred.exceptionHook = function( error, stack ) {
  8316. // Support: IE 8 - 9 only
  8317. // Console exists when dev tools are open, which can happen at any time
  8318. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  8319. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  8320. }
  8321. };
  8322. jQuery.readyException = function( error ) {
  8323. window.setTimeout( function() {
  8324. throw error;
  8325. } );
  8326. };
  8327. // The deferred used on DOM ready
  8328. var readyList = jQuery.Deferred();
  8329. jQuery.fn.ready = function( fn ) {
  8330. readyList
  8331. .then( fn )
  8332. // Wrap jQuery.readyException in a function so that the lookup
  8333. // happens at the time of error handling instead of callback
  8334. // registration.
  8335. .catch( function( error ) {
  8336. jQuery.readyException( error );
  8337. } );
  8338. return this;
  8339. };
  8340. jQuery.extend( {
  8341. // Is the DOM ready to be used? Set to true once it occurs.
  8342. isReady: false,
  8343. // A counter to track how many items to wait for before
  8344. // the ready event fires. See #6781
  8345. readyWait: 1,
  8346. // Handle when the DOM is ready
  8347. ready: function( wait ) {
  8348. // Abort if there are pending holds or we're already ready
  8349. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  8350. return;
  8351. }
  8352. // Remember that the DOM is ready
  8353. jQuery.isReady = true;
  8354. // If a normal DOM Ready event fired, decrement, and wait if need be
  8355. if ( wait !== true && --jQuery.readyWait > 0 ) {
  8356. return;
  8357. }
  8358. // If there are functions bound, to execute
  8359. readyList.resolveWith( document, [ jQuery ] );
  8360. }
  8361. } );
  8362. jQuery.ready.then = readyList.then;
  8363. // The ready event handler and self cleanup method
  8364. function completed() {
  8365. document.removeEventListener( "DOMContentLoaded", completed );
  8366. window.removeEventListener( "load", completed );
  8367. jQuery.ready();
  8368. }
  8369. // Catch cases where $(document).ready() is called
  8370. // after the browser event has already occurred.
  8371. // Support: IE <=9 - 10 only
  8372. // Older IE sometimes signals "interactive" too soon
  8373. if ( document.readyState === "complete" ||
  8374. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  8375. // Handle it asynchronously to allow scripts the opportunity to delay ready
  8376. window.setTimeout( jQuery.ready );
  8377. } else {
  8378. // Use the handy event callback
  8379. document.addEventListener( "DOMContentLoaded", completed );
  8380. // A fallback to window.onload, that will always work
  8381. window.addEventListener( "load", completed );
  8382. }
  8383. // Multifunctional method to get and set values of a collection
  8384. // The value/s can optionally be executed if it's a function
  8385. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  8386. var i = 0,
  8387. len = elems.length,
  8388. bulk = key == null;
  8389. // Sets many values
  8390. if ( toType( key ) === "object" ) {
  8391. chainable = true;
  8392. for ( i in key ) {
  8393. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  8394. }
  8395. // Sets one value
  8396. } else if ( value !== undefined ) {
  8397. chainable = true;
  8398. if ( !isFunction( value ) ) {
  8399. raw = true;
  8400. }
  8401. if ( bulk ) {
  8402. // Bulk operations run against the entire set
  8403. if ( raw ) {
  8404. fn.call( elems, value );
  8405. fn = null;
  8406. // ...except when executing function values
  8407. } else {
  8408. bulk = fn;
  8409. fn = function( elem, key, value ) {
  8410. return bulk.call( jQuery( elem ), value );
  8411. };
  8412. }
  8413. }
  8414. if ( fn ) {
  8415. for ( ; i < len; i++ ) {
  8416. fn(
  8417. elems[ i ], key, raw ?
  8418. value :
  8419. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  8420. );
  8421. }
  8422. }
  8423. }
  8424. if ( chainable ) {
  8425. return elems;
  8426. }
  8427. // Gets
  8428. if ( bulk ) {
  8429. return fn.call( elems );
  8430. }
  8431. return len ? fn( elems[ 0 ], key ) : emptyGet;
  8432. };
  8433. // Matches dashed string for camelizing
  8434. var rmsPrefix = /^-ms-/,
  8435. rdashAlpha = /-([a-z])/g;
  8436. // Used by camelCase as callback to replace()
  8437. function fcamelCase( all, letter ) {
  8438. return letter.toUpperCase();
  8439. }
  8440. // Convert dashed to camelCase; used by the css and data modules
  8441. // Support: IE <=9 - 11, Edge 12 - 15
  8442. // Microsoft forgot to hump their vendor prefix (#9572)
  8443. function camelCase( string ) {
  8444. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  8445. }
  8446. var acceptData = function( owner ) {
  8447. // Accepts only:
  8448. // - Node
  8449. // - Node.ELEMENT_NODE
  8450. // - Node.DOCUMENT_NODE
  8451. // - Object
  8452. // - Any
  8453. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  8454. };
  8455. function Data() {
  8456. this.expando = jQuery.expando + Data.uid++;
  8457. }
  8458. Data.uid = 1;
  8459. Data.prototype = {
  8460. cache: function( owner ) {
  8461. // Check if the owner object already has a cache
  8462. var value = owner[ this.expando ];
  8463. // If not, create one
  8464. if ( !value ) {
  8465. value = {};
  8466. // We can accept data for non-element nodes in modern browsers,
  8467. // but we should not, see #8335.
  8468. // Always return an empty object.
  8469. if ( acceptData( owner ) ) {
  8470. // If it is a node unlikely to be stringify-ed or looped over
  8471. // use plain assignment
  8472. if ( owner.nodeType ) {
  8473. owner[ this.expando ] = value;
  8474. // Otherwise secure it in a non-enumerable property
  8475. // configurable must be true to allow the property to be
  8476. // deleted when data is removed
  8477. } else {
  8478. Object.defineProperty( owner, this.expando, {
  8479. value: value,
  8480. configurable: true
  8481. } );
  8482. }
  8483. }
  8484. }
  8485. return value;
  8486. },
  8487. set: function( owner, data, value ) {
  8488. var prop,
  8489. cache = this.cache( owner );
  8490. // Handle: [ owner, key, value ] args
  8491. // Always use camelCase key (gh-2257)
  8492. if ( typeof data === "string" ) {
  8493. cache[ camelCase( data ) ] = value;
  8494. // Handle: [ owner, { properties } ] args
  8495. } else {
  8496. // Copy the properties one-by-one to the cache object
  8497. for ( prop in data ) {
  8498. cache[ camelCase( prop ) ] = data[ prop ];
  8499. }
  8500. }
  8501. return cache;
  8502. },
  8503. get: function( owner, key ) {
  8504. return key === undefined ?
  8505. this.cache( owner ) :
  8506. // Always use camelCase key (gh-2257)
  8507. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  8508. },
  8509. access: function( owner, key, value ) {
  8510. // In cases where either:
  8511. //
  8512. // 1. No key was specified
  8513. // 2. A string key was specified, but no value provided
  8514. //
  8515. // Take the "read" path and allow the get method to determine
  8516. // which value to return, respectively either:
  8517. //
  8518. // 1. The entire cache object
  8519. // 2. The data stored at the key
  8520. //
  8521. if ( key === undefined ||
  8522. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  8523. return this.get( owner, key );
  8524. }
  8525. // When the key is not a string, or both a key and value
  8526. // are specified, set or extend (existing objects) with either:
  8527. //
  8528. // 1. An object of properties
  8529. // 2. A key and value
  8530. //
  8531. this.set( owner, key, value );
  8532. // Since the "set" path can have two possible entry points
  8533. // return the expected data based on which path was taken[*]
  8534. return value !== undefined ? value : key;
  8535. },
  8536. remove: function( owner, key ) {
  8537. var i,
  8538. cache = owner[ this.expando ];
  8539. if ( cache === undefined ) {
  8540. return;
  8541. }
  8542. if ( key !== undefined ) {
  8543. // Support array or space separated string of keys
  8544. if ( Array.isArray( key ) ) {
  8545. // If key is an array of keys...
  8546. // We always set camelCase keys, so remove that.
  8547. key = key.map( camelCase );
  8548. } else {
  8549. key = camelCase( key );
  8550. // If a key with the spaces exists, use it.
  8551. // Otherwise, create an array by matching non-whitespace
  8552. key = key in cache ?
  8553. [ key ] :
  8554. ( key.match( rnothtmlwhite ) || [] );
  8555. }
  8556. i = key.length;
  8557. while ( i-- ) {
  8558. delete cache[ key[ i ] ];
  8559. }
  8560. }
  8561. // Remove the expando if there's no more data
  8562. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  8563. // Support: Chrome <=35 - 45
  8564. // Webkit & Blink performance suffers when deleting properties
  8565. // from DOM nodes, so set to undefined instead
  8566. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  8567. if ( owner.nodeType ) {
  8568. owner[ this.expando ] = undefined;
  8569. } else {
  8570. delete owner[ this.expando ];
  8571. }
  8572. }
  8573. },
  8574. hasData: function( owner ) {
  8575. var cache = owner[ this.expando ];
  8576. return cache !== undefined && !jQuery.isEmptyObject( cache );
  8577. }
  8578. };
  8579. var dataPriv = new Data();
  8580. var dataUser = new Data();
  8581. // Implementation Summary
  8582. //
  8583. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  8584. // 2. Improve the module's maintainability by reducing the storage
  8585. // paths to a single mechanism.
  8586. // 3. Use the same single mechanism to support "private" and "user" data.
  8587. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  8588. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  8589. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  8590. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  8591. rmultiDash = /[A-Z]/g;
  8592. function getData( data ) {
  8593. if ( data === "true" ) {
  8594. return true;
  8595. }
  8596. if ( data === "false" ) {
  8597. return false;
  8598. }
  8599. if ( data === "null" ) {
  8600. return null;
  8601. }
  8602. // Only convert to a number if it doesn't change the string
  8603. if ( data === +data + "" ) {
  8604. return +data;
  8605. }
  8606. if ( rbrace.test( data ) ) {
  8607. return JSON.parse( data );
  8608. }
  8609. return data;
  8610. }
  8611. function dataAttr( elem, key, data ) {
  8612. var name;
  8613. // If nothing was found internally, try to fetch any
  8614. // data from the HTML5 data-* attribute
  8615. if ( data === undefined && elem.nodeType === 1 ) {
  8616. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  8617. data = elem.getAttribute( name );
  8618. if ( typeof data === "string" ) {
  8619. try {
  8620. data = getData( data );
  8621. } catch ( e ) {}
  8622. // Make sure we set the data so it isn't changed later
  8623. dataUser.set( elem, key, data );
  8624. } else {
  8625. data = undefined;
  8626. }
  8627. }
  8628. return data;
  8629. }
  8630. jQuery.extend( {
  8631. hasData: function( elem ) {
  8632. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  8633. },
  8634. data: function( elem, name, data ) {
  8635. return dataUser.access( elem, name, data );
  8636. },
  8637. removeData: function( elem, name ) {
  8638. dataUser.remove( elem, name );
  8639. },
  8640. // TODO: Now that all calls to _data and _removeData have been replaced
  8641. // with direct calls to dataPriv methods, these can be deprecated.
  8642. _data: function( elem, name, data ) {
  8643. return dataPriv.access( elem, name, data );
  8644. },
  8645. _removeData: function( elem, name ) {
  8646. dataPriv.remove( elem, name );
  8647. }
  8648. } );
  8649. jQuery.fn.extend( {
  8650. data: function( key, value ) {
  8651. var i, name, data,
  8652. elem = this[ 0 ],
  8653. attrs = elem && elem.attributes;
  8654. // Gets all values
  8655. if ( key === undefined ) {
  8656. if ( this.length ) {
  8657. data = dataUser.get( elem );
  8658. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  8659. i = attrs.length;
  8660. while ( i-- ) {
  8661. // Support: IE 11 only
  8662. // The attrs elements can be null (#14894)
  8663. if ( attrs[ i ] ) {
  8664. name = attrs[ i ].name;
  8665. if ( name.indexOf( "data-" ) === 0 ) {
  8666. name = camelCase( name.slice( 5 ) );
  8667. dataAttr( elem, name, data[ name ] );
  8668. }
  8669. }
  8670. }
  8671. dataPriv.set( elem, "hasDataAttrs", true );
  8672. }
  8673. }
  8674. return data;
  8675. }
  8676. // Sets multiple values
  8677. if ( typeof key === "object" ) {
  8678. return this.each( function() {
  8679. dataUser.set( this, key );
  8680. } );
  8681. }
  8682. return access( this, function( value ) {
  8683. var data;
  8684. // The calling jQuery object (element matches) is not empty
  8685. // (and therefore has an element appears at this[ 0 ]) and the
  8686. // `value` parameter was not undefined. An empty jQuery object
  8687. // will result in `undefined` for elem = this[ 0 ] which will
  8688. // throw an exception if an attempt to read a data cache is made.
  8689. if ( elem && value === undefined ) {
  8690. // Attempt to get data from the cache
  8691. // The key will always be camelCased in Data
  8692. data = dataUser.get( elem, key );
  8693. if ( data !== undefined ) {
  8694. return data;
  8695. }
  8696. // Attempt to "discover" the data in
  8697. // HTML5 custom data-* attrs
  8698. data = dataAttr( elem, key );
  8699. if ( data !== undefined ) {
  8700. return data;
  8701. }
  8702. // We tried really hard, but the data doesn't exist.
  8703. return;
  8704. }
  8705. // Set the data...
  8706. this.each( function() {
  8707. // We always store the camelCased key
  8708. dataUser.set( this, key, value );
  8709. } );
  8710. }, null, value, arguments.length > 1, null, true );
  8711. },
  8712. removeData: function( key ) {
  8713. return this.each( function() {
  8714. dataUser.remove( this, key );
  8715. } );
  8716. }
  8717. } );
  8718. jQuery.extend( {
  8719. queue: function( elem, type, data ) {
  8720. var queue;
  8721. if ( elem ) {
  8722. type = ( type || "fx" ) + "queue";
  8723. queue = dataPriv.get( elem, type );
  8724. // Speed up dequeue by getting out quickly if this is just a lookup
  8725. if ( data ) {
  8726. if ( !queue || Array.isArray( data ) ) {
  8727. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  8728. } else {
  8729. queue.push( data );
  8730. }
  8731. }
  8732. return queue || [];
  8733. }
  8734. },
  8735. dequeue: function( elem, type ) {
  8736. type = type || "fx";
  8737. var queue = jQuery.queue( elem, type ),
  8738. startLength = queue.length,
  8739. fn = queue.shift(),
  8740. hooks = jQuery._queueHooks( elem, type ),
  8741. next = function() {
  8742. jQuery.dequeue( elem, type );
  8743. };
  8744. // If the fx queue is dequeued, always remove the progress sentinel
  8745. if ( fn === "inprogress" ) {
  8746. fn = queue.shift();
  8747. startLength--;
  8748. }
  8749. if ( fn ) {
  8750. // Add a progress sentinel to prevent the fx queue from being
  8751. // automatically dequeued
  8752. if ( type === "fx" ) {
  8753. queue.unshift( "inprogress" );
  8754. }
  8755. // Clear up the last queue stop function
  8756. delete hooks.stop;
  8757. fn.call( elem, next, hooks );
  8758. }
  8759. if ( !startLength && hooks ) {
  8760. hooks.empty.fire();
  8761. }
  8762. },
  8763. // Not public - generate a queueHooks object, or return the current one
  8764. _queueHooks: function( elem, type ) {
  8765. var key = type + "queueHooks";
  8766. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  8767. empty: jQuery.Callbacks( "once memory" ).add( function() {
  8768. dataPriv.remove( elem, [ type + "queue", key ] );
  8769. } )
  8770. } );
  8771. }
  8772. } );
  8773. jQuery.fn.extend( {
  8774. queue: function( type, data ) {
  8775. var setter = 2;
  8776. if ( typeof type !== "string" ) {
  8777. data = type;
  8778. type = "fx";
  8779. setter--;
  8780. }
  8781. if ( arguments.length < setter ) {
  8782. return jQuery.queue( this[ 0 ], type );
  8783. }
  8784. return data === undefined ?
  8785. this :
  8786. this.each( function() {
  8787. var queue = jQuery.queue( this, type, data );
  8788. // Ensure a hooks for this queue
  8789. jQuery._queueHooks( this, type );
  8790. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  8791. jQuery.dequeue( this, type );
  8792. }
  8793. } );
  8794. },
  8795. dequeue: function( type ) {
  8796. return this.each( function() {
  8797. jQuery.dequeue( this, type );
  8798. } );
  8799. },
  8800. clearQueue: function( type ) {
  8801. return this.queue( type || "fx", [] );
  8802. },
  8803. // Get a promise resolved when queues of a certain type
  8804. // are emptied (fx is the type by default)
  8805. promise: function( type, obj ) {
  8806. var tmp,
  8807. count = 1,
  8808. defer = jQuery.Deferred(),
  8809. elements = this,
  8810. i = this.length,
  8811. resolve = function() {
  8812. if ( !( --count ) ) {
  8813. defer.resolveWith( elements, [ elements ] );
  8814. }
  8815. };
  8816. if ( typeof type !== "string" ) {
  8817. obj = type;
  8818. type = undefined;
  8819. }
  8820. type = type || "fx";
  8821. while ( i-- ) {
  8822. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  8823. if ( tmp && tmp.empty ) {
  8824. count++;
  8825. tmp.empty.add( resolve );
  8826. }
  8827. }
  8828. resolve();
  8829. return defer.promise( obj );
  8830. }
  8831. } );
  8832. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  8833. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  8834. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  8835. var documentElement = document.documentElement;
  8836. var isAttached = function( elem ) {
  8837. return jQuery.contains( elem.ownerDocument, elem );
  8838. },
  8839. composed = { composed: true };
  8840. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  8841. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  8842. // Support: iOS 10.0-10.2 only
  8843. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  8844. // leading to errors. We need to check for `getRootNode`.
  8845. if ( documentElement.getRootNode ) {
  8846. isAttached = function( elem ) {
  8847. return jQuery.contains( elem.ownerDocument, elem ) ||
  8848. elem.getRootNode( composed ) === elem.ownerDocument;
  8849. };
  8850. }
  8851. var isHiddenWithinTree = function( elem, el ) {
  8852. // isHiddenWithinTree might be called from jQuery#filter function;
  8853. // in that case, element will be second argument
  8854. elem = el || elem;
  8855. // Inline style trumps all
  8856. return elem.style.display === "none" ||
  8857. elem.style.display === "" &&
  8858. // Otherwise, check computed style
  8859. // Support: Firefox <=43 - 45
  8860. // Disconnected elements can have computed display: none, so first confirm that elem is
  8861. // in the document.
  8862. isAttached( elem ) &&
  8863. jQuery.css( elem, "display" ) === "none";
  8864. };
  8865. var swap = function( elem, options, callback, args ) {
  8866. var ret, name,
  8867. old = {};
  8868. // Remember the old values, and insert the new ones
  8869. for ( name in options ) {
  8870. old[ name ] = elem.style[ name ];
  8871. elem.style[ name ] = options[ name ];
  8872. }
  8873. ret = callback.apply( elem, args || [] );
  8874. // Revert the old values
  8875. for ( name in options ) {
  8876. elem.style[ name ] = old[ name ];
  8877. }
  8878. return ret;
  8879. };
  8880. function adjustCSS( elem, prop, valueParts, tween ) {
  8881. var adjusted, scale,
  8882. maxIterations = 20,
  8883. currentValue = tween ?
  8884. function() {
  8885. return tween.cur();
  8886. } :
  8887. function() {
  8888. return jQuery.css( elem, prop, "" );
  8889. },
  8890. initial = currentValue(),
  8891. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  8892. // Starting value computation is required for potential unit mismatches
  8893. initialInUnit = elem.nodeType &&
  8894. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  8895. rcssNum.exec( jQuery.css( elem, prop ) );
  8896. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  8897. // Support: Firefox <=54
  8898. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  8899. initial = initial / 2;
  8900. // Trust units reported by jQuery.css
  8901. unit = unit || initialInUnit[ 3 ];
  8902. // Iteratively approximate from a nonzero starting point
  8903. initialInUnit = +initial || 1;
  8904. while ( maxIterations-- ) {
  8905. // Evaluate and update our best guess (doubling guesses that zero out).
  8906. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  8907. jQuery.style( elem, prop, initialInUnit + unit );
  8908. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  8909. maxIterations = 0;
  8910. }
  8911. initialInUnit = initialInUnit / scale;
  8912. }
  8913. initialInUnit = initialInUnit * 2;
  8914. jQuery.style( elem, prop, initialInUnit + unit );
  8915. // Make sure we update the tween properties later on
  8916. valueParts = valueParts || [];
  8917. }
  8918. if ( valueParts ) {
  8919. initialInUnit = +initialInUnit || +initial || 0;
  8920. // Apply relative offset (+=/-=) if specified
  8921. adjusted = valueParts[ 1 ] ?
  8922. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  8923. +valueParts[ 2 ];
  8924. if ( tween ) {
  8925. tween.unit = unit;
  8926. tween.start = initialInUnit;
  8927. tween.end = adjusted;
  8928. }
  8929. }
  8930. return adjusted;
  8931. }
  8932. var defaultDisplayMap = {};
  8933. function getDefaultDisplay( elem ) {
  8934. var temp,
  8935. doc = elem.ownerDocument,
  8936. nodeName = elem.nodeName,
  8937. display = defaultDisplayMap[ nodeName ];
  8938. if ( display ) {
  8939. return display;
  8940. }
  8941. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  8942. display = jQuery.css( temp, "display" );
  8943. temp.parentNode.removeChild( temp );
  8944. if ( display === "none" ) {
  8945. display = "block";
  8946. }
  8947. defaultDisplayMap[ nodeName ] = display;
  8948. return display;
  8949. }
  8950. function showHide( elements, show ) {
  8951. var display, elem,
  8952. values = [],
  8953. index = 0,
  8954. length = elements.length;
  8955. // Determine new display value for elements that need to change
  8956. for ( ; index < length; index++ ) {
  8957. elem = elements[ index ];
  8958. if ( !elem.style ) {
  8959. continue;
  8960. }
  8961. display = elem.style.display;
  8962. if ( show ) {
  8963. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  8964. // check is required in this first loop unless we have a nonempty display value (either
  8965. // inline or about-to-be-restored)
  8966. if ( display === "none" ) {
  8967. values[ index ] = dataPriv.get( elem, "display" ) || null;
  8968. if ( !values[ index ] ) {
  8969. elem.style.display = "";
  8970. }
  8971. }
  8972. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  8973. values[ index ] = getDefaultDisplay( elem );
  8974. }
  8975. } else {
  8976. if ( display !== "none" ) {
  8977. values[ index ] = "none";
  8978. // Remember what we're overwriting
  8979. dataPriv.set( elem, "display", display );
  8980. }
  8981. }
  8982. }
  8983. // Set the display of the elements in a second loop to avoid constant reflow
  8984. for ( index = 0; index < length; index++ ) {
  8985. if ( values[ index ] != null ) {
  8986. elements[ index ].style.display = values[ index ];
  8987. }
  8988. }
  8989. return elements;
  8990. }
  8991. jQuery.fn.extend( {
  8992. show: function() {
  8993. return showHide( this, true );
  8994. },
  8995. hide: function() {
  8996. return showHide( this );
  8997. },
  8998. toggle: function( state ) {
  8999. if ( typeof state === "boolean" ) {
  9000. return state ? this.show() : this.hide();
  9001. }
  9002. return this.each( function() {
  9003. if ( isHiddenWithinTree( this ) ) {
  9004. jQuery( this ).show();
  9005. } else {
  9006. jQuery( this ).hide();
  9007. }
  9008. } );
  9009. }
  9010. } );
  9011. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  9012. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  9013. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  9014. // We have to close these tags to support XHTML (#13200)
  9015. var wrapMap = {
  9016. // Support: IE <=9 only
  9017. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  9018. // XHTML parsers do not magically insert elements in the
  9019. // same way that tag soup parsers do. So we cannot shorten
  9020. // this by omitting <tbody> or other required elements.
  9021. thead: [ 1, "<table>", "</table>" ],
  9022. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  9023. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  9024. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  9025. _default: [ 0, "", "" ]
  9026. };
  9027. // Support: IE <=9 only
  9028. wrapMap.optgroup = wrapMap.option;
  9029. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  9030. wrapMap.th = wrapMap.td;
  9031. function getAll( context, tag ) {
  9032. // Support: IE <=9 - 11 only
  9033. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  9034. var ret;
  9035. if ( typeof context.getElementsByTagName !== "undefined" ) {
  9036. ret = context.getElementsByTagName( tag || "*" );
  9037. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  9038. ret = context.querySelectorAll( tag || "*" );
  9039. } else {
  9040. ret = [];
  9041. }
  9042. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  9043. return jQuery.merge( [ context ], ret );
  9044. }
  9045. return ret;
  9046. }
  9047. // Mark scripts as having already been evaluated
  9048. function setGlobalEval( elems, refElements ) {
  9049. var i = 0,
  9050. l = elems.length;
  9051. for ( ; i < l; i++ ) {
  9052. dataPriv.set(
  9053. elems[ i ],
  9054. "globalEval",
  9055. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  9056. );
  9057. }
  9058. }
  9059. var rhtml = /<|&#?\w+;/;
  9060. function buildFragment( elems, context, scripts, selection, ignored ) {
  9061. var elem, tmp, tag, wrap, attached, j,
  9062. fragment = context.createDocumentFragment(),
  9063. nodes = [],
  9064. i = 0,
  9065. l = elems.length;
  9066. for ( ; i < l; i++ ) {
  9067. elem = elems[ i ];
  9068. if ( elem || elem === 0 ) {
  9069. // Add nodes directly
  9070. if ( toType( elem ) === "object" ) {
  9071. // Support: Android <=4.0 only, PhantomJS 1 only
  9072. // push.apply(_, arraylike) throws on ancient WebKit
  9073. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  9074. // Convert non-html into a text node
  9075. } else if ( !rhtml.test( elem ) ) {
  9076. nodes.push( context.createTextNode( elem ) );
  9077. // Convert html into DOM nodes
  9078. } else {
  9079. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  9080. // Deserialize a standard representation
  9081. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  9082. wrap = wrapMap[ tag ] || wrapMap._default;
  9083. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  9084. // Descend through wrappers to the right content
  9085. j = wrap[ 0 ];
  9086. while ( j-- ) {
  9087. tmp = tmp.lastChild;
  9088. }
  9089. // Support: Android <=4.0 only, PhantomJS 1 only
  9090. // push.apply(_, arraylike) throws on ancient WebKit
  9091. jQuery.merge( nodes, tmp.childNodes );
  9092. // Remember the top-level container
  9093. tmp = fragment.firstChild;
  9094. // Ensure the created nodes are orphaned (#12392)
  9095. tmp.textContent = "";
  9096. }
  9097. }
  9098. }
  9099. // Remove wrapper from fragment
  9100. fragment.textContent = "";
  9101. i = 0;
  9102. while ( ( elem = nodes[ i++ ] ) ) {
  9103. // Skip elements already in the context collection (trac-4087)
  9104. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  9105. if ( ignored ) {
  9106. ignored.push( elem );
  9107. }
  9108. continue;
  9109. }
  9110. attached = isAttached( elem );
  9111. // Append to fragment
  9112. tmp = getAll( fragment.appendChild( elem ), "script" );
  9113. // Preserve script evaluation history
  9114. if ( attached ) {
  9115. setGlobalEval( tmp );
  9116. }
  9117. // Capture executables
  9118. if ( scripts ) {
  9119. j = 0;
  9120. while ( ( elem = tmp[ j++ ] ) ) {
  9121. if ( rscriptType.test( elem.type || "" ) ) {
  9122. scripts.push( elem );
  9123. }
  9124. }
  9125. }
  9126. }
  9127. return fragment;
  9128. }
  9129. ( function() {
  9130. var fragment = document.createDocumentFragment(),
  9131. div = fragment.appendChild( document.createElement( "div" ) ),
  9132. input = document.createElement( "input" );
  9133. // Support: Android 4.0 - 4.3 only
  9134. // Check state lost if the name is set (#11217)
  9135. // Support: Windows Web Apps (WWA)
  9136. // `name` and `type` must use .setAttribute for WWA (#14901)
  9137. input.setAttribute( "type", "radio" );
  9138. input.setAttribute( "checked", "checked" );
  9139. input.setAttribute( "name", "t" );
  9140. div.appendChild( input );
  9141. // Support: Android <=4.1 only
  9142. // Older WebKit doesn't clone checked state correctly in fragments
  9143. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  9144. // Support: IE <=11 only
  9145. // Make sure textarea (and checkbox) defaultValue is properly cloned
  9146. div.innerHTML = "<textarea>x</textarea>";
  9147. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  9148. } )();
  9149. var
  9150. rkeyEvent = /^key/,
  9151. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  9152. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  9153. function returnTrue() {
  9154. return true;
  9155. }
  9156. function returnFalse() {
  9157. return false;
  9158. }
  9159. // Support: IE <=9 - 11+
  9160. // focus() and blur() are asynchronous, except when they are no-op.
  9161. // So expect focus to be synchronous when the element is already active,
  9162. // and blur to be synchronous when the element is not already active.
  9163. // (focus and blur are always synchronous in other supported browsers,
  9164. // this just defines when we can count on it).
  9165. function expectSync( elem, type ) {
  9166. return ( elem === safeActiveElement() ) === ( type === "focus" );
  9167. }
  9168. // Support: IE <=9 only
  9169. // Accessing document.activeElement can throw unexpectedly
  9170. // https://bugs.jquery.com/ticket/13393
  9171. function safeActiveElement() {
  9172. try {
  9173. return document.activeElement;
  9174. } catch ( err ) { }
  9175. }
  9176. function on( elem, types, selector, data, fn, one ) {
  9177. var origFn, type;
  9178. // Types can be a map of types/handlers
  9179. if ( typeof types === "object" ) {
  9180. // ( types-Object, selector, data )
  9181. if ( typeof selector !== "string" ) {
  9182. // ( types-Object, data )
  9183. data = data || selector;
  9184. selector = undefined;
  9185. }
  9186. for ( type in types ) {
  9187. on( elem, type, selector, data, types[ type ], one );
  9188. }
  9189. return elem;
  9190. }
  9191. if ( data == null && fn == null ) {
  9192. // ( types, fn )
  9193. fn = selector;
  9194. data = selector = undefined;
  9195. } else if ( fn == null ) {
  9196. if ( typeof selector === "string" ) {
  9197. // ( types, selector, fn )
  9198. fn = data;
  9199. data = undefined;
  9200. } else {
  9201. // ( types, data, fn )
  9202. fn = data;
  9203. data = selector;
  9204. selector = undefined;
  9205. }
  9206. }
  9207. if ( fn === false ) {
  9208. fn = returnFalse;
  9209. } else if ( !fn ) {
  9210. return elem;
  9211. }
  9212. if ( one === 1 ) {
  9213. origFn = fn;
  9214. fn = function( event ) {
  9215. // Can use an empty set, since event contains the info
  9216. jQuery().off( event );
  9217. return origFn.apply( this, arguments );
  9218. };
  9219. // Use same guid so caller can remove using origFn
  9220. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  9221. }
  9222. return elem.each( function() {
  9223. jQuery.event.add( this, types, fn, data, selector );
  9224. } );
  9225. }
  9226. /*
  9227. * Helper functions for managing events -- not part of the public interface.
  9228. * Props to Dean Edwards' addEvent library for many of the ideas.
  9229. */
  9230. jQuery.event = {
  9231. global: {},
  9232. add: function( elem, types, handler, data, selector ) {
  9233. var handleObjIn, eventHandle, tmp,
  9234. events, t, handleObj,
  9235. special, handlers, type, namespaces, origType,
  9236. elemData = dataPriv.get( elem );
  9237. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  9238. if ( !elemData ) {
  9239. return;
  9240. }
  9241. // Caller can pass in an object of custom data in lieu of the handler
  9242. if ( handler.handler ) {
  9243. handleObjIn = handler;
  9244. handler = handleObjIn.handler;
  9245. selector = handleObjIn.selector;
  9246. }
  9247. // Ensure that invalid selectors throw exceptions at attach time
  9248. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  9249. if ( selector ) {
  9250. jQuery.find.matchesSelector( documentElement, selector );
  9251. }
  9252. // Make sure that the handler has a unique ID, used to find/remove it later
  9253. if ( !handler.guid ) {
  9254. handler.guid = jQuery.guid++;
  9255. }
  9256. // Init the element's event structure and main handler, if this is the first
  9257. if ( !( events = elemData.events ) ) {
  9258. events = elemData.events = {};
  9259. }
  9260. if ( !( eventHandle = elemData.handle ) ) {
  9261. eventHandle = elemData.handle = function( e ) {
  9262. // Discard the second event of a jQuery.event.trigger() and
  9263. // when an event is called after a page has unloaded
  9264. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  9265. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  9266. };
  9267. }
  9268. // Handle multiple events separated by a space
  9269. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  9270. t = types.length;
  9271. while ( t-- ) {
  9272. tmp = rtypenamespace.exec( types[ t ] ) || [];
  9273. type = origType = tmp[ 1 ];
  9274. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  9275. // There *must* be a type, no attaching namespace-only handlers
  9276. if ( !type ) {
  9277. continue;
  9278. }
  9279. // If event changes its type, use the special event handlers for the changed type
  9280. special = jQuery.event.special[ type ] || {};
  9281. // If selector defined, determine special event api type, otherwise given type
  9282. type = ( selector ? special.delegateType : special.bindType ) || type;
  9283. // Update special based on newly reset type
  9284. special = jQuery.event.special[ type ] || {};
  9285. // handleObj is passed to all event handlers
  9286. handleObj = jQuery.extend( {
  9287. type: type,
  9288. origType: origType,
  9289. data: data,
  9290. handler: handler,
  9291. guid: handler.guid,
  9292. selector: selector,
  9293. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  9294. namespace: namespaces.join( "." )
  9295. }, handleObjIn );
  9296. // Init the event handler queue if we're the first
  9297. if ( !( handlers = events[ type ] ) ) {
  9298. handlers = events[ type ] = [];
  9299. handlers.delegateCount = 0;
  9300. // Only use addEventListener if the special events handler returns false
  9301. if ( !special.setup ||
  9302. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  9303. if ( elem.addEventListener ) {
  9304. elem.addEventListener( type, eventHandle );
  9305. }
  9306. }
  9307. }
  9308. if ( special.add ) {
  9309. special.add.call( elem, handleObj );
  9310. if ( !handleObj.handler.guid ) {
  9311. handleObj.handler.guid = handler.guid;
  9312. }
  9313. }
  9314. // Add to the element's handler list, delegates in front
  9315. if ( selector ) {
  9316. handlers.splice( handlers.delegateCount++, 0, handleObj );
  9317. } else {
  9318. handlers.push( handleObj );
  9319. }
  9320. // Keep track of which events have ever been used, for event optimization
  9321. jQuery.event.global[ type ] = true;
  9322. }
  9323. },
  9324. // Detach an event or set of events from an element
  9325. remove: function( elem, types, handler, selector, mappedTypes ) {
  9326. var j, origCount, tmp,
  9327. events, t, handleObj,
  9328. special, handlers, type, namespaces, origType,
  9329. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  9330. if ( !elemData || !( events = elemData.events ) ) {
  9331. return;
  9332. }
  9333. // Once for each type.namespace in types; type may be omitted
  9334. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  9335. t = types.length;
  9336. while ( t-- ) {
  9337. tmp = rtypenamespace.exec( types[ t ] ) || [];
  9338. type = origType = tmp[ 1 ];
  9339. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  9340. // Unbind all events (on this namespace, if provided) for the element
  9341. if ( !type ) {
  9342. for ( type in events ) {
  9343. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  9344. }
  9345. continue;
  9346. }
  9347. special = jQuery.event.special[ type ] || {};
  9348. type = ( selector ? special.delegateType : special.bindType ) || type;
  9349. handlers = events[ type ] || [];
  9350. tmp = tmp[ 2 ] &&
  9351. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  9352. // Remove matching events
  9353. origCount = j = handlers.length;
  9354. while ( j-- ) {
  9355. handleObj = handlers[ j ];
  9356. if ( ( mappedTypes || origType === handleObj.origType ) &&
  9357. ( !handler || handler.guid === handleObj.guid ) &&
  9358. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  9359. ( !selector || selector === handleObj.selector ||
  9360. selector === "**" && handleObj.selector ) ) {
  9361. handlers.splice( j, 1 );
  9362. if ( handleObj.selector ) {
  9363. handlers.delegateCount--;
  9364. }
  9365. if ( special.remove ) {
  9366. special.remove.call( elem, handleObj );
  9367. }
  9368. }
  9369. }
  9370. // Remove generic event handler if we removed something and no more handlers exist
  9371. // (avoids potential for endless recursion during removal of special event handlers)
  9372. if ( origCount && !handlers.length ) {
  9373. if ( !special.teardown ||
  9374. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  9375. jQuery.removeEvent( elem, type, elemData.handle );
  9376. }
  9377. delete events[ type ];
  9378. }
  9379. }
  9380. // Remove data and the expando if it's no longer used
  9381. if ( jQuery.isEmptyObject( events ) ) {
  9382. dataPriv.remove( elem, "handle events" );
  9383. }
  9384. },
  9385. dispatch: function( nativeEvent ) {
  9386. // Make a writable jQuery.Event from the native event object
  9387. var event = jQuery.event.fix( nativeEvent );
  9388. var i, j, ret, matched, handleObj, handlerQueue,
  9389. args = new Array( arguments.length ),
  9390. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  9391. special = jQuery.event.special[ event.type ] || {};
  9392. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  9393. args[ 0 ] = event;
  9394. for ( i = 1; i < arguments.length; i++ ) {
  9395. args[ i ] = arguments[ i ];
  9396. }
  9397. event.delegateTarget = this;
  9398. // Call the preDispatch hook for the mapped type, and let it bail if desired
  9399. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  9400. return;
  9401. }
  9402. // Determine handlers
  9403. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  9404. // Run delegates first; they may want to stop propagation beneath us
  9405. i = 0;
  9406. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  9407. event.currentTarget = matched.elem;
  9408. j = 0;
  9409. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  9410. !event.isImmediatePropagationStopped() ) {
  9411. // If the event is namespaced, then each handler is only invoked if it is
  9412. // specially universal or its namespaces are a superset of the event's.
  9413. if ( !event.rnamespace || handleObj.namespace === false ||
  9414. event.rnamespace.test( handleObj.namespace ) ) {
  9415. event.handleObj = handleObj;
  9416. event.data = handleObj.data;
  9417. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  9418. handleObj.handler ).apply( matched.elem, args );
  9419. if ( ret !== undefined ) {
  9420. if ( ( event.result = ret ) === false ) {
  9421. event.preventDefault();
  9422. event.stopPropagation();
  9423. }
  9424. }
  9425. }
  9426. }
  9427. }
  9428. // Call the postDispatch hook for the mapped type
  9429. if ( special.postDispatch ) {
  9430. special.postDispatch.call( this, event );
  9431. }
  9432. return event.result;
  9433. },
  9434. handlers: function( event, handlers ) {
  9435. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  9436. handlerQueue = [],
  9437. delegateCount = handlers.delegateCount,
  9438. cur = event.target;
  9439. // Find delegate handlers
  9440. if ( delegateCount &&
  9441. // Support: IE <=9
  9442. // Black-hole SVG <use> instance trees (trac-13180)
  9443. cur.nodeType &&
  9444. // Support: Firefox <=42
  9445. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  9446. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  9447. // Support: IE 11 only
  9448. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  9449. !( event.type === "click" && event.button >= 1 ) ) {
  9450. for ( ; cur !== this; cur = cur.parentNode || this ) {
  9451. // Don't check non-elements (#13208)
  9452. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  9453. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  9454. matchedHandlers = [];
  9455. matchedSelectors = {};
  9456. for ( i = 0; i < delegateCount; i++ ) {
  9457. handleObj = handlers[ i ];
  9458. // Don't conflict with Object.prototype properties (#13203)
  9459. sel = handleObj.selector + " ";
  9460. if ( matchedSelectors[ sel ] === undefined ) {
  9461. matchedSelectors[ sel ] = handleObj.needsContext ?
  9462. jQuery( sel, this ).index( cur ) > -1 :
  9463. jQuery.find( sel, this, null, [ cur ] ).length;
  9464. }
  9465. if ( matchedSelectors[ sel ] ) {
  9466. matchedHandlers.push( handleObj );
  9467. }
  9468. }
  9469. if ( matchedHandlers.length ) {
  9470. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  9471. }
  9472. }
  9473. }
  9474. }
  9475. // Add the remaining (directly-bound) handlers
  9476. cur = this;
  9477. if ( delegateCount < handlers.length ) {
  9478. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  9479. }
  9480. return handlerQueue;
  9481. },
  9482. addProp: function( name, hook ) {
  9483. Object.defineProperty( jQuery.Event.prototype, name, {
  9484. enumerable: true,
  9485. configurable: true,
  9486. get: isFunction( hook ) ?
  9487. function() {
  9488. if ( this.originalEvent ) {
  9489. return hook( this.originalEvent );
  9490. }
  9491. } :
  9492. function() {
  9493. if ( this.originalEvent ) {
  9494. return this.originalEvent[ name ];
  9495. }
  9496. },
  9497. set: function( value ) {
  9498. Object.defineProperty( this, name, {
  9499. enumerable: true,
  9500. configurable: true,
  9501. writable: true,
  9502. value: value
  9503. } );
  9504. }
  9505. } );
  9506. },
  9507. fix: function( originalEvent ) {
  9508. return originalEvent[ jQuery.expando ] ?
  9509. originalEvent :
  9510. new jQuery.Event( originalEvent );
  9511. },
  9512. special: {
  9513. load: {
  9514. // Prevent triggered image.load events from bubbling to window.load
  9515. noBubble: true
  9516. },
  9517. click: {
  9518. // Utilize native event to ensure correct state for checkable inputs
  9519. setup: function( data ) {
  9520. // For mutual compressibility with _default, replace `this` access with a local var.
  9521. // `|| data` is dead code meant only to preserve the variable through minification.
  9522. var el = this || data;
  9523. // Claim the first handler
  9524. if ( rcheckableType.test( el.type ) &&
  9525. el.click && nodeName( el, "input" ) ) {
  9526. // dataPriv.set( el, "click", ... )
  9527. leverageNative( el, "click", returnTrue );
  9528. }
  9529. // Return false to allow normal processing in the caller
  9530. return false;
  9531. },
  9532. trigger: function( data ) {
  9533. // For mutual compressibility with _default, replace `this` access with a local var.
  9534. // `|| data` is dead code meant only to preserve the variable through minification.
  9535. var el = this || data;
  9536. // Force setup before triggering a click
  9537. if ( rcheckableType.test( el.type ) &&
  9538. el.click && nodeName( el, "input" ) ) {
  9539. leverageNative( el, "click" );
  9540. }
  9541. // Return non-false to allow normal event-path propagation
  9542. return true;
  9543. },
  9544. // For cross-browser consistency, suppress native .click() on links
  9545. // Also prevent it if we're currently inside a leveraged native-event stack
  9546. _default: function( event ) {
  9547. var target = event.target;
  9548. return rcheckableType.test( target.type ) &&
  9549. target.click && nodeName( target, "input" ) &&
  9550. dataPriv.get( target, "click" ) ||
  9551. nodeName( target, "a" );
  9552. }
  9553. },
  9554. beforeunload: {
  9555. postDispatch: function( event ) {
  9556. // Support: Firefox 20+
  9557. // Firefox doesn't alert if the returnValue field is not set.
  9558. if ( event.result !== undefined && event.originalEvent ) {
  9559. event.originalEvent.returnValue = event.result;
  9560. }
  9561. }
  9562. }
  9563. }
  9564. };
  9565. // Ensure the presence of an event listener that handles manually-triggered
  9566. // synthetic events by interrupting progress until reinvoked in response to
  9567. // *native* events that it fires directly, ensuring that state changes have
  9568. // already occurred before other listeners are invoked.
  9569. function leverageNative( el, type, expectSync ) {
  9570. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  9571. if ( !expectSync ) {
  9572. if ( dataPriv.get( el, type ) === undefined ) {
  9573. jQuery.event.add( el, type, returnTrue );
  9574. }
  9575. return;
  9576. }
  9577. // Register the controller as a special universal handler for all event namespaces
  9578. dataPriv.set( el, type, false );
  9579. jQuery.event.add( el, type, {
  9580. namespace: false,
  9581. handler: function( event ) {
  9582. var notAsync, result,
  9583. saved = dataPriv.get( this, type );
  9584. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  9585. // Interrupt processing of the outer synthetic .trigger()ed event
  9586. // Saved data should be false in such cases, but might be a leftover capture object
  9587. // from an async native handler (gh-4350)
  9588. if ( !saved.length ) {
  9589. // Store arguments for use when handling the inner native event
  9590. // There will always be at least one argument (an event object), so this array
  9591. // will not be confused with a leftover capture object.
  9592. saved = slice.call( arguments );
  9593. dataPriv.set( this, type, saved );
  9594. // Trigger the native event and capture its result
  9595. // Support: IE <=9 - 11+
  9596. // focus() and blur() are asynchronous
  9597. notAsync = expectSync( this, type );
  9598. this[ type ]();
  9599. result = dataPriv.get( this, type );
  9600. if ( saved !== result || notAsync ) {
  9601. dataPriv.set( this, type, false );
  9602. } else {
  9603. result = {};
  9604. }
  9605. if ( saved !== result ) {
  9606. // Cancel the outer synthetic event
  9607. event.stopImmediatePropagation();
  9608. event.preventDefault();
  9609. return result.value;
  9610. }
  9611. // If this is an inner synthetic event for an event with a bubbling surrogate
  9612. // (focus or blur), assume that the surrogate already propagated from triggering the
  9613. // native event and prevent that from happening again here.
  9614. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  9615. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  9616. // less bad than duplication.
  9617. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  9618. event.stopPropagation();
  9619. }
  9620. // If this is a native event triggered above, everything is now in order
  9621. // Fire an inner synthetic event with the original arguments
  9622. } else if ( saved.length ) {
  9623. // ...and capture the result
  9624. dataPriv.set( this, type, {
  9625. value: jQuery.event.trigger(
  9626. // Support: IE <=9 - 11+
  9627. // Extend with the prototype to reset the above stopImmediatePropagation()
  9628. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  9629. saved.slice( 1 ),
  9630. this
  9631. )
  9632. } );
  9633. // Abort handling of the native event
  9634. event.stopImmediatePropagation();
  9635. }
  9636. }
  9637. } );
  9638. }
  9639. jQuery.removeEvent = function( elem, type, handle ) {
  9640. // This "if" is needed for plain objects
  9641. if ( elem.removeEventListener ) {
  9642. elem.removeEventListener( type, handle );
  9643. }
  9644. };
  9645. jQuery.Event = function( src, props ) {
  9646. // Allow instantiation without the 'new' keyword
  9647. if ( !( this instanceof jQuery.Event ) ) {
  9648. return new jQuery.Event( src, props );
  9649. }
  9650. // Event object
  9651. if ( src && src.type ) {
  9652. this.originalEvent = src;
  9653. this.type = src.type;
  9654. // Events bubbling up the document may have been marked as prevented
  9655. // by a handler lower down the tree; reflect the correct value.
  9656. this.isDefaultPrevented = src.defaultPrevented ||
  9657. src.defaultPrevented === undefined &&
  9658. // Support: Android <=2.3 only
  9659. src.returnValue === false ?
  9660. returnTrue :
  9661. returnFalse;
  9662. // Create target properties
  9663. // Support: Safari <=6 - 7 only
  9664. // Target should not be a text node (#504, #13143)
  9665. this.target = ( src.target && src.target.nodeType === 3 ) ?
  9666. src.target.parentNode :
  9667. src.target;
  9668. this.currentTarget = src.currentTarget;
  9669. this.relatedTarget = src.relatedTarget;
  9670. // Event type
  9671. } else {
  9672. this.type = src;
  9673. }
  9674. // Put explicitly provided properties onto the event object
  9675. if ( props ) {
  9676. jQuery.extend( this, props );
  9677. }
  9678. // Create a timestamp if incoming event doesn't have one
  9679. this.timeStamp = src && src.timeStamp || Date.now();
  9680. // Mark it as fixed
  9681. this[ jQuery.expando ] = true;
  9682. };
  9683. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  9684. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  9685. jQuery.Event.prototype = {
  9686. constructor: jQuery.Event,
  9687. isDefaultPrevented: returnFalse,
  9688. isPropagationStopped: returnFalse,
  9689. isImmediatePropagationStopped: returnFalse,
  9690. isSimulated: false,
  9691. preventDefault: function() {
  9692. var e = this.originalEvent;
  9693. this.isDefaultPrevented = returnTrue;
  9694. if ( e && !this.isSimulated ) {
  9695. e.preventDefault();
  9696. }
  9697. },
  9698. stopPropagation: function() {
  9699. var e = this.originalEvent;
  9700. this.isPropagationStopped = returnTrue;
  9701. if ( e && !this.isSimulated ) {
  9702. e.stopPropagation();
  9703. }
  9704. },
  9705. stopImmediatePropagation: function() {
  9706. var e = this.originalEvent;
  9707. this.isImmediatePropagationStopped = returnTrue;
  9708. if ( e && !this.isSimulated ) {
  9709. e.stopImmediatePropagation();
  9710. }
  9711. this.stopPropagation();
  9712. }
  9713. };
  9714. // Includes all common event props including KeyEvent and MouseEvent specific props
  9715. jQuery.each( {
  9716. altKey: true,
  9717. bubbles: true,
  9718. cancelable: true,
  9719. changedTouches: true,
  9720. ctrlKey: true,
  9721. detail: true,
  9722. eventPhase: true,
  9723. metaKey: true,
  9724. pageX: true,
  9725. pageY: true,
  9726. shiftKey: true,
  9727. view: true,
  9728. "char": true,
  9729. code: true,
  9730. charCode: true,
  9731. key: true,
  9732. keyCode: true,
  9733. button: true,
  9734. buttons: true,
  9735. clientX: true,
  9736. clientY: true,
  9737. offsetX: true,
  9738. offsetY: true,
  9739. pointerId: true,
  9740. pointerType: true,
  9741. screenX: true,
  9742. screenY: true,
  9743. targetTouches: true,
  9744. toElement: true,
  9745. touches: true,
  9746. which: function( event ) {
  9747. var button = event.button;
  9748. // Add which for key events
  9749. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  9750. return event.charCode != null ? event.charCode : event.keyCode;
  9751. }
  9752. // Add which for click: 1 === left; 2 === middle; 3 === right
  9753. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  9754. if ( button & 1 ) {
  9755. return 1;
  9756. }
  9757. if ( button & 2 ) {
  9758. return 3;
  9759. }
  9760. if ( button & 4 ) {
  9761. return 2;
  9762. }
  9763. return 0;
  9764. }
  9765. return event.which;
  9766. }
  9767. }, jQuery.event.addProp );
  9768. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  9769. jQuery.event.special[ type ] = {
  9770. // Utilize native event if possible so blur/focus sequence is correct
  9771. setup: function() {
  9772. // Claim the first handler
  9773. // dataPriv.set( this, "focus", ... )
  9774. // dataPriv.set( this, "blur", ... )
  9775. leverageNative( this, type, expectSync );
  9776. // Return false to allow normal processing in the caller
  9777. return false;
  9778. },
  9779. trigger: function() {
  9780. // Force setup before trigger
  9781. leverageNative( this, type );
  9782. // Return non-false to allow normal event-path propagation
  9783. return true;
  9784. },
  9785. delegateType: delegateType
  9786. };
  9787. } );
  9788. // Create mouseenter/leave events using mouseover/out and event-time checks
  9789. // so that event delegation works in jQuery.
  9790. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  9791. //
  9792. // Support: Safari 7 only
  9793. // Safari sends mouseenter too often; see:
  9794. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  9795. // for the description of the bug (it existed in older Chrome versions as well).
  9796. jQuery.each( {
  9797. mouseenter: "mouseover",
  9798. mouseleave: "mouseout",
  9799. pointerenter: "pointerover",
  9800. pointerleave: "pointerout"
  9801. }, function( orig, fix ) {
  9802. jQuery.event.special[ orig ] = {
  9803. delegateType: fix,
  9804. bindType: fix,
  9805. handle: function( event ) {
  9806. var ret,
  9807. target = this,
  9808. related = event.relatedTarget,
  9809. handleObj = event.handleObj;
  9810. // For mouseenter/leave call the handler if related is outside the target.
  9811. // NB: No relatedTarget if the mouse left/entered the browser window
  9812. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  9813. event.type = handleObj.origType;
  9814. ret = handleObj.handler.apply( this, arguments );
  9815. event.type = fix;
  9816. }
  9817. return ret;
  9818. }
  9819. };
  9820. } );
  9821. jQuery.fn.extend( {
  9822. on: function( types, selector, data, fn ) {
  9823. return on( this, types, selector, data, fn );
  9824. },
  9825. one: function( types, selector, data, fn ) {
  9826. return on( this, types, selector, data, fn, 1 );
  9827. },
  9828. off: function( types, selector, fn ) {
  9829. var handleObj, type;
  9830. if ( types && types.preventDefault && types.handleObj ) {
  9831. // ( event ) dispatched jQuery.Event
  9832. handleObj = types.handleObj;
  9833. jQuery( types.delegateTarget ).off(
  9834. handleObj.namespace ?
  9835. handleObj.origType + "." + handleObj.namespace :
  9836. handleObj.origType,
  9837. handleObj.selector,
  9838. handleObj.handler
  9839. );
  9840. return this;
  9841. }
  9842. if ( typeof types === "object" ) {
  9843. // ( types-object [, selector] )
  9844. for ( type in types ) {
  9845. this.off( type, selector, types[ type ] );
  9846. }
  9847. return this;
  9848. }
  9849. if ( selector === false || typeof selector === "function" ) {
  9850. // ( types [, fn] )
  9851. fn = selector;
  9852. selector = undefined;
  9853. }
  9854. if ( fn === false ) {
  9855. fn = returnFalse;
  9856. }
  9857. return this.each( function() {
  9858. jQuery.event.remove( this, types, fn, selector );
  9859. } );
  9860. }
  9861. } );
  9862. var
  9863. /* eslint-disable max-len */
  9864. // See https://github.com/eslint/eslint/issues/3229
  9865. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  9866. /* eslint-enable */
  9867. // Support: IE <=10 - 11, Edge 12 - 13 only
  9868. // In IE/Edge using regex groups here causes severe slowdowns.
  9869. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  9870. rnoInnerhtml = /<script|<style|<link/i,
  9871. // checked="checked" or checked
  9872. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  9873. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  9874. // Prefer a tbody over its parent table for containing new rows
  9875. function manipulationTarget( elem, content ) {
  9876. if ( nodeName( elem, "table" ) &&
  9877. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  9878. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  9879. }
  9880. return elem;
  9881. }
  9882. // Replace/restore the type attribute of script elements for safe DOM manipulation
  9883. function disableScript( elem ) {
  9884. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  9885. return elem;
  9886. }
  9887. function restoreScript( elem ) {
  9888. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  9889. elem.type = elem.type.slice( 5 );
  9890. } else {
  9891. elem.removeAttribute( "type" );
  9892. }
  9893. return elem;
  9894. }
  9895. function cloneCopyEvent( src, dest ) {
  9896. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  9897. if ( dest.nodeType !== 1 ) {
  9898. return;
  9899. }
  9900. // 1. Copy private data: events, handlers, etc.
  9901. if ( dataPriv.hasData( src ) ) {
  9902. pdataOld = dataPriv.access( src );
  9903. pdataCur = dataPriv.set( dest, pdataOld );
  9904. events = pdataOld.events;
  9905. if ( events ) {
  9906. delete pdataCur.handle;
  9907. pdataCur.events = {};
  9908. for ( type in events ) {
  9909. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  9910. jQuery.event.add( dest, type, events[ type ][ i ] );
  9911. }
  9912. }
  9913. }
  9914. }
  9915. // 2. Copy user data
  9916. if ( dataUser.hasData( src ) ) {
  9917. udataOld = dataUser.access( src );
  9918. udataCur = jQuery.extend( {}, udataOld );
  9919. dataUser.set( dest, udataCur );
  9920. }
  9921. }
  9922. // Fix IE bugs, see support tests
  9923. function fixInput( src, dest ) {
  9924. var nodeName = dest.nodeName.toLowerCase();
  9925. // Fails to persist the checked state of a cloned checkbox or radio button.
  9926. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  9927. dest.checked = src.checked;
  9928. // Fails to return the selected option to the default selected state when cloning options
  9929. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  9930. dest.defaultValue = src.defaultValue;
  9931. }
  9932. }
  9933. function domManip( collection, args, callback, ignored ) {
  9934. // Flatten any nested arrays
  9935. args = concat.apply( [], args );
  9936. var fragment, first, scripts, hasScripts, node, doc,
  9937. i = 0,
  9938. l = collection.length,
  9939. iNoClone = l - 1,
  9940. value = args[ 0 ],
  9941. valueIsFunction = isFunction( value );
  9942. // We can't cloneNode fragments that contain checked, in WebKit
  9943. if ( valueIsFunction ||
  9944. ( l > 1 && typeof value === "string" &&
  9945. !support.checkClone && rchecked.test( value ) ) ) {
  9946. return collection.each( function( index ) {
  9947. var self = collection.eq( index );
  9948. if ( valueIsFunction ) {
  9949. args[ 0 ] = value.call( this, index, self.html() );
  9950. }
  9951. domManip( self, args, callback, ignored );
  9952. } );
  9953. }
  9954. if ( l ) {
  9955. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  9956. first = fragment.firstChild;
  9957. if ( fragment.childNodes.length === 1 ) {
  9958. fragment = first;
  9959. }
  9960. // Require either new content or an interest in ignored elements to invoke the callback
  9961. if ( first || ignored ) {
  9962. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  9963. hasScripts = scripts.length;
  9964. // Use the original fragment for the last item
  9965. // instead of the first because it can end up
  9966. // being emptied incorrectly in certain situations (#8070).
  9967. for ( ; i < l; i++ ) {
  9968. node = fragment;
  9969. if ( i !== iNoClone ) {
  9970. node = jQuery.clone( node, true, true );
  9971. // Keep references to cloned scripts for later restoration
  9972. if ( hasScripts ) {
  9973. // Support: Android <=4.0 only, PhantomJS 1 only
  9974. // push.apply(_, arraylike) throws on ancient WebKit
  9975. jQuery.merge( scripts, getAll( node, "script" ) );
  9976. }
  9977. }
  9978. callback.call( collection[ i ], node, i );
  9979. }
  9980. if ( hasScripts ) {
  9981. doc = scripts[ scripts.length - 1 ].ownerDocument;
  9982. // Reenable scripts
  9983. jQuery.map( scripts, restoreScript );
  9984. // Evaluate executable scripts on first document insertion
  9985. for ( i = 0; i < hasScripts; i++ ) {
  9986. node = scripts[ i ];
  9987. if ( rscriptType.test( node.type || "" ) &&
  9988. !dataPriv.access( node, "globalEval" ) &&
  9989. jQuery.contains( doc, node ) ) {
  9990. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  9991. // Optional AJAX dependency, but won't run scripts if not present
  9992. if ( jQuery._evalUrl && !node.noModule ) {
  9993. jQuery._evalUrl( node.src, {
  9994. nonce: node.nonce || node.getAttribute( "nonce" )
  9995. } );
  9996. }
  9997. } else {
  9998. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  9999. }
  10000. }
  10001. }
  10002. }
  10003. }
  10004. }
  10005. return collection;
  10006. }
  10007. function remove( elem, selector, keepData ) {
  10008. var node,
  10009. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  10010. i = 0;
  10011. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  10012. if ( !keepData && node.nodeType === 1 ) {
  10013. jQuery.cleanData( getAll( node ) );
  10014. }
  10015. if ( node.parentNode ) {
  10016. if ( keepData && isAttached( node ) ) {
  10017. setGlobalEval( getAll( node, "script" ) );
  10018. }
  10019. node.parentNode.removeChild( node );
  10020. }
  10021. }
  10022. return elem;
  10023. }
  10024. jQuery.extend( {
  10025. htmlPrefilter: function( html ) {
  10026. return html.replace( rxhtmlTag, "<$1></$2>" );
  10027. },
  10028. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  10029. var i, l, srcElements, destElements,
  10030. clone = elem.cloneNode( true ),
  10031. inPage = isAttached( elem );
  10032. // Fix IE cloning issues
  10033. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  10034. !jQuery.isXMLDoc( elem ) ) {
  10035. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  10036. destElements = getAll( clone );
  10037. srcElements = getAll( elem );
  10038. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  10039. fixInput( srcElements[ i ], destElements[ i ] );
  10040. }
  10041. }
  10042. // Copy the events from the original to the clone
  10043. if ( dataAndEvents ) {
  10044. if ( deepDataAndEvents ) {
  10045. srcElements = srcElements || getAll( elem );
  10046. destElements = destElements || getAll( clone );
  10047. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  10048. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  10049. }
  10050. } else {
  10051. cloneCopyEvent( elem, clone );
  10052. }
  10053. }
  10054. // Preserve script evaluation history
  10055. destElements = getAll( clone, "script" );
  10056. if ( destElements.length > 0 ) {
  10057. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  10058. }
  10059. // Return the cloned set
  10060. return clone;
  10061. },
  10062. cleanData: function( elems ) {
  10063. var data, elem, type,
  10064. special = jQuery.event.special,
  10065. i = 0;
  10066. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  10067. if ( acceptData( elem ) ) {
  10068. if ( ( data = elem[ dataPriv.expando ] ) ) {
  10069. if ( data.events ) {
  10070. for ( type in data.events ) {
  10071. if ( special[ type ] ) {
  10072. jQuery.event.remove( elem, type );
  10073. // This is a shortcut to avoid jQuery.event.remove's overhead
  10074. } else {
  10075. jQuery.removeEvent( elem, type, data.handle );
  10076. }
  10077. }
  10078. }
  10079. // Support: Chrome <=35 - 45+
  10080. // Assign undefined instead of using delete, see Data#remove
  10081. elem[ dataPriv.expando ] = undefined;
  10082. }
  10083. if ( elem[ dataUser.expando ] ) {
  10084. // Support: Chrome <=35 - 45+
  10085. // Assign undefined instead of using delete, see Data#remove
  10086. elem[ dataUser.expando ] = undefined;
  10087. }
  10088. }
  10089. }
  10090. }
  10091. } );
  10092. jQuery.fn.extend( {
  10093. detach: function( selector ) {
  10094. return remove( this, selector, true );
  10095. },
  10096. remove: function( selector ) {
  10097. return remove( this, selector );
  10098. },
  10099. text: function( value ) {
  10100. return access( this, function( value ) {
  10101. return value === undefined ?
  10102. jQuery.text( this ) :
  10103. this.empty().each( function() {
  10104. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10105. this.textContent = value;
  10106. }
  10107. } );
  10108. }, null, value, arguments.length );
  10109. },
  10110. append: function() {
  10111. return domManip( this, arguments, function( elem ) {
  10112. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10113. var target = manipulationTarget( this, elem );
  10114. target.appendChild( elem );
  10115. }
  10116. } );
  10117. },
  10118. prepend: function() {
  10119. return domManip( this, arguments, function( elem ) {
  10120. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10121. var target = manipulationTarget( this, elem );
  10122. target.insertBefore( elem, target.firstChild );
  10123. }
  10124. } );
  10125. },
  10126. before: function() {
  10127. return domManip( this, arguments, function( elem ) {
  10128. if ( this.parentNode ) {
  10129. this.parentNode.insertBefore( elem, this );
  10130. }
  10131. } );
  10132. },
  10133. after: function() {
  10134. return domManip( this, arguments, function( elem ) {
  10135. if ( this.parentNode ) {
  10136. this.parentNode.insertBefore( elem, this.nextSibling );
  10137. }
  10138. } );
  10139. },
  10140. empty: function() {
  10141. var elem,
  10142. i = 0;
  10143. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  10144. if ( elem.nodeType === 1 ) {
  10145. // Prevent memory leaks
  10146. jQuery.cleanData( getAll( elem, false ) );
  10147. // Remove any remaining nodes
  10148. elem.textContent = "";
  10149. }
  10150. }
  10151. return this;
  10152. },
  10153. clone: function( dataAndEvents, deepDataAndEvents ) {
  10154. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  10155. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  10156. return this.map( function() {
  10157. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  10158. } );
  10159. },
  10160. html: function( value ) {
  10161. return access( this, function( value ) {
  10162. var elem = this[ 0 ] || {},
  10163. i = 0,
  10164. l = this.length;
  10165. if ( value === undefined && elem.nodeType === 1 ) {
  10166. return elem.innerHTML;
  10167. }
  10168. // See if we can take a shortcut and just use innerHTML
  10169. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  10170. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  10171. value = jQuery.htmlPrefilter( value );
  10172. try {
  10173. for ( ; i < l; i++ ) {
  10174. elem = this[ i ] || {};
  10175. // Remove element nodes and prevent memory leaks
  10176. if ( elem.nodeType === 1 ) {
  10177. jQuery.cleanData( getAll( elem, false ) );
  10178. elem.innerHTML = value;
  10179. }
  10180. }
  10181. elem = 0;
  10182. // If using innerHTML throws an exception, use the fallback method
  10183. } catch ( e ) {}
  10184. }
  10185. if ( elem ) {
  10186. this.empty().append( value );
  10187. }
  10188. }, null, value, arguments.length );
  10189. },
  10190. replaceWith: function() {
  10191. var ignored = [];
  10192. // Make the changes, replacing each non-ignored context element with the new content
  10193. return domManip( this, arguments, function( elem ) {
  10194. var parent = this.parentNode;
  10195. if ( jQuery.inArray( this, ignored ) < 0 ) {
  10196. jQuery.cleanData( getAll( this ) );
  10197. if ( parent ) {
  10198. parent.replaceChild( elem, this );
  10199. }
  10200. }
  10201. // Force callback invocation
  10202. }, ignored );
  10203. }
  10204. } );
  10205. jQuery.each( {
  10206. appendTo: "append",
  10207. prependTo: "prepend",
  10208. insertBefore: "before",
  10209. insertAfter: "after",
  10210. replaceAll: "replaceWith"
  10211. }, function( name, original ) {
  10212. jQuery.fn[ name ] = function( selector ) {
  10213. var elems,
  10214. ret = [],
  10215. insert = jQuery( selector ),
  10216. last = insert.length - 1,
  10217. i = 0;
  10218. for ( ; i <= last; i++ ) {
  10219. elems = i === last ? this : this.clone( true );
  10220. jQuery( insert[ i ] )[ original ]( elems );
  10221. // Support: Android <=4.0 only, PhantomJS 1 only
  10222. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  10223. push.apply( ret, elems.get() );
  10224. }
  10225. return this.pushStack( ret );
  10226. };
  10227. } );
  10228. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  10229. var getStyles = function( elem ) {
  10230. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  10231. // IE throws on elements created in popups
  10232. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  10233. var view = elem.ownerDocument.defaultView;
  10234. if ( !view || !view.opener ) {
  10235. view = window;
  10236. }
  10237. return view.getComputedStyle( elem );
  10238. };
  10239. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  10240. ( function() {
  10241. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  10242. // so they're executed at the same time to save the second computation.
  10243. function computeStyleTests() {
  10244. // This is a singleton, we need to execute it only once
  10245. if ( !div ) {
  10246. return;
  10247. }
  10248. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  10249. "margin-top:1px;padding:0;border:0";
  10250. div.style.cssText =
  10251. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  10252. "margin:auto;border:1px;padding:1px;" +
  10253. "width:60%;top:1%";
  10254. documentElement.appendChild( container ).appendChild( div );
  10255. var divStyle = window.getComputedStyle( div );
  10256. pixelPositionVal = divStyle.top !== "1%";
  10257. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  10258. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  10259. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  10260. // Some styles come back with percentage values, even though they shouldn't
  10261. div.style.right = "60%";
  10262. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  10263. // Support: IE 9 - 11 only
  10264. // Detect misreporting of content dimensions for box-sizing:border-box elements
  10265. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  10266. // Support: IE 9 only
  10267. // Detect overflow:scroll screwiness (gh-3699)
  10268. // Support: Chrome <=64
  10269. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  10270. div.style.position = "absolute";
  10271. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  10272. documentElement.removeChild( container );
  10273. // Nullify the div so it wouldn't be stored in the memory and
  10274. // it will also be a sign that checks already performed
  10275. div = null;
  10276. }
  10277. function roundPixelMeasures( measure ) {
  10278. return Math.round( parseFloat( measure ) );
  10279. }
  10280. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  10281. reliableMarginLeftVal,
  10282. container = document.createElement( "div" ),
  10283. div = document.createElement( "div" );
  10284. // Finish early in limited (non-browser) environments
  10285. if ( !div.style ) {
  10286. return;
  10287. }
  10288. // Support: IE <=9 - 11 only
  10289. // Style of cloned element affects source element cloned (#8908)
  10290. div.style.backgroundClip = "content-box";
  10291. div.cloneNode( true ).style.backgroundClip = "";
  10292. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  10293. jQuery.extend( support, {
  10294. boxSizingReliable: function() {
  10295. computeStyleTests();
  10296. return boxSizingReliableVal;
  10297. },
  10298. pixelBoxStyles: function() {
  10299. computeStyleTests();
  10300. return pixelBoxStylesVal;
  10301. },
  10302. pixelPosition: function() {
  10303. computeStyleTests();
  10304. return pixelPositionVal;
  10305. },
  10306. reliableMarginLeft: function() {
  10307. computeStyleTests();
  10308. return reliableMarginLeftVal;
  10309. },
  10310. scrollboxSize: function() {
  10311. computeStyleTests();
  10312. return scrollboxSizeVal;
  10313. }
  10314. } );
  10315. } )();
  10316. function curCSS( elem, name, computed ) {
  10317. var width, minWidth, maxWidth, ret,
  10318. // Support: Firefox 51+
  10319. // Retrieving style before computed somehow
  10320. // fixes an issue with getting wrong values
  10321. // on detached elements
  10322. style = elem.style;
  10323. computed = computed || getStyles( elem );
  10324. // getPropertyValue is needed for:
  10325. // .css('filter') (IE 9 only, #12537)
  10326. // .css('--customProperty) (#3144)
  10327. if ( computed ) {
  10328. ret = computed.getPropertyValue( name ) || computed[ name ];
  10329. if ( ret === "" && !isAttached( elem ) ) {
  10330. ret = jQuery.style( elem, name );
  10331. }
  10332. // A tribute to the "awesome hack by Dean Edwards"
  10333. // Android Browser returns percentage for some values,
  10334. // but width seems to be reliably pixels.
  10335. // This is against the CSSOM draft spec:
  10336. // https://drafts.csswg.org/cssom/#resolved-values
  10337. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  10338. // Remember the original values
  10339. width = style.width;
  10340. minWidth = style.minWidth;
  10341. maxWidth = style.maxWidth;
  10342. // Put in the new values to get a computed value out
  10343. style.minWidth = style.maxWidth = style.width = ret;
  10344. ret = computed.width;
  10345. // Revert the changed values
  10346. style.width = width;
  10347. style.minWidth = minWidth;
  10348. style.maxWidth = maxWidth;
  10349. }
  10350. }
  10351. return ret !== undefined ?
  10352. // Support: IE <=9 - 11 only
  10353. // IE returns zIndex value as an integer.
  10354. ret + "" :
  10355. ret;
  10356. }
  10357. function addGetHookIf( conditionFn, hookFn ) {
  10358. // Define the hook, we'll check on the first run if it's really needed.
  10359. return {
  10360. get: function() {
  10361. if ( conditionFn() ) {
  10362. // Hook not needed (or it's not possible to use it due
  10363. // to missing dependency), remove it.
  10364. delete this.get;
  10365. return;
  10366. }
  10367. // Hook needed; redefine it so that the support test is not executed again.
  10368. return ( this.get = hookFn ).apply( this, arguments );
  10369. }
  10370. };
  10371. }
  10372. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  10373. emptyStyle = document.createElement( "div" ).style,
  10374. vendorProps = {};
  10375. // Return a vendor-prefixed property or undefined
  10376. function vendorPropName( name ) {
  10377. // Check for vendor prefixed names
  10378. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  10379. i = cssPrefixes.length;
  10380. while ( i-- ) {
  10381. name = cssPrefixes[ i ] + capName;
  10382. if ( name in emptyStyle ) {
  10383. return name;
  10384. }
  10385. }
  10386. }
  10387. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  10388. function finalPropName( name ) {
  10389. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  10390. if ( final ) {
  10391. return final;
  10392. }
  10393. if ( name in emptyStyle ) {
  10394. return name;
  10395. }
  10396. return vendorProps[ name ] = vendorPropName( name ) || name;
  10397. }
  10398. var
  10399. // Swappable if display is none or starts with table
  10400. // except "table", "table-cell", or "table-caption"
  10401. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  10402. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  10403. rcustomProp = /^--/,
  10404. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  10405. cssNormalTransform = {
  10406. letterSpacing: "0",
  10407. fontWeight: "400"
  10408. };
  10409. function setPositiveNumber( elem, value, subtract ) {
  10410. // Any relative (+/-) values have already been
  10411. // normalized at this point
  10412. var matches = rcssNum.exec( value );
  10413. return matches ?
  10414. // Guard against undefined "subtract", e.g., when used as in cssHooks
  10415. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  10416. value;
  10417. }
  10418. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  10419. var i = dimension === "width" ? 1 : 0,
  10420. extra = 0,
  10421. delta = 0;
  10422. // Adjustment may not be necessary
  10423. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  10424. return 0;
  10425. }
  10426. for ( ; i < 4; i += 2 ) {
  10427. // Both box models exclude margin
  10428. if ( box === "margin" ) {
  10429. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  10430. }
  10431. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  10432. if ( !isBorderBox ) {
  10433. // Add padding
  10434. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  10435. // For "border" or "margin", add border
  10436. if ( box !== "padding" ) {
  10437. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10438. // But still keep track of it otherwise
  10439. } else {
  10440. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10441. }
  10442. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  10443. // "padding" or "margin"
  10444. } else {
  10445. // For "content", subtract padding
  10446. if ( box === "content" ) {
  10447. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  10448. }
  10449. // For "content" or "padding", subtract border
  10450. if ( box !== "margin" ) {
  10451. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10452. }
  10453. }
  10454. }
  10455. // Account for positive content-box scroll gutter when requested by providing computedVal
  10456. if ( !isBorderBox && computedVal >= 0 ) {
  10457. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  10458. // Assuming integer scroll gutter, subtract the rest and round down
  10459. delta += Math.max( 0, Math.ceil(
  10460. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  10461. computedVal -
  10462. delta -
  10463. extra -
  10464. 0.5
  10465. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  10466. // Use an explicit zero to avoid NaN (gh-3964)
  10467. ) ) || 0;
  10468. }
  10469. return delta;
  10470. }
  10471. function getWidthOrHeight( elem, dimension, extra ) {
  10472. // Start with computed style
  10473. var styles = getStyles( elem ),
  10474. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  10475. // Fake content-box until we know it's needed to know the true value.
  10476. boxSizingNeeded = !support.boxSizingReliable() || extra,
  10477. isBorderBox = boxSizingNeeded &&
  10478. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  10479. valueIsBorderBox = isBorderBox,
  10480. val = curCSS( elem, dimension, styles ),
  10481. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  10482. // Support: Firefox <=54
  10483. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  10484. if ( rnumnonpx.test( val ) ) {
  10485. if ( !extra ) {
  10486. return val;
  10487. }
  10488. val = "auto";
  10489. }
  10490. // Fall back to offsetWidth/offsetHeight when value is "auto"
  10491. // This happens for inline elements with no explicit setting (gh-3571)
  10492. // Support: Android <=4.1 - 4.3 only
  10493. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  10494. // Support: IE 9-11 only
  10495. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  10496. // We use getClientRects() to check for hidden/disconnected.
  10497. // In those cases, the computed value can be trusted to be border-box
  10498. if ( ( !support.boxSizingReliable() && isBorderBox ||
  10499. val === "auto" ||
  10500. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  10501. elem.getClientRects().length ) {
  10502. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  10503. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  10504. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  10505. // retrieved value as a content box dimension.
  10506. valueIsBorderBox = offsetProp in elem;
  10507. if ( valueIsBorderBox ) {
  10508. val = elem[ offsetProp ];
  10509. }
  10510. }
  10511. // Normalize "" and auto
  10512. val = parseFloat( val ) || 0;
  10513. // Adjust for the element's box model
  10514. return ( val +
  10515. boxModelAdjustment(
  10516. elem,
  10517. dimension,
  10518. extra || ( isBorderBox ? "border" : "content" ),
  10519. valueIsBorderBox,
  10520. styles,
  10521. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  10522. val
  10523. )
  10524. ) + "px";
  10525. }
  10526. jQuery.extend( {
  10527. // Add in style property hooks for overriding the default
  10528. // behavior of getting and setting a style property
  10529. cssHooks: {
  10530. opacity: {
  10531. get: function( elem, computed ) {
  10532. if ( computed ) {
  10533. // We should always get a number back from opacity
  10534. var ret = curCSS( elem, "opacity" );
  10535. return ret === "" ? "1" : ret;
  10536. }
  10537. }
  10538. }
  10539. },
  10540. // Don't automatically add "px" to these possibly-unitless properties
  10541. cssNumber: {
  10542. "animationIterationCount": true,
  10543. "columnCount": true,
  10544. "fillOpacity": true,
  10545. "flexGrow": true,
  10546. "flexShrink": true,
  10547. "fontWeight": true,
  10548. "gridArea": true,
  10549. "gridColumn": true,
  10550. "gridColumnEnd": true,
  10551. "gridColumnStart": true,
  10552. "gridRow": true,
  10553. "gridRowEnd": true,
  10554. "gridRowStart": true,
  10555. "lineHeight": true,
  10556. "opacity": true,
  10557. "order": true,
  10558. "orphans": true,
  10559. "widows": true,
  10560. "zIndex": true,
  10561. "zoom": true
  10562. },
  10563. // Add in properties whose names you wish to fix before
  10564. // setting or getting the value
  10565. cssProps: {},
  10566. // Get and set the style property on a DOM Node
  10567. style: function( elem, name, value, extra ) {
  10568. // Don't set styles on text and comment nodes
  10569. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  10570. return;
  10571. }
  10572. // Make sure that we're working with the right name
  10573. var ret, type, hooks,
  10574. origName = camelCase( name ),
  10575. isCustomProp = rcustomProp.test( name ),
  10576. style = elem.style;
  10577. // Make sure that we're working with the right name. We don't
  10578. // want to query the value if it is a CSS custom property
  10579. // since they are user-defined.
  10580. if ( !isCustomProp ) {
  10581. name = finalPropName( origName );
  10582. }
  10583. // Gets hook for the prefixed version, then unprefixed version
  10584. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  10585. // Check if we're setting a value
  10586. if ( value !== undefined ) {
  10587. type = typeof value;
  10588. // Convert "+=" or "-=" to relative numbers (#7345)
  10589. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  10590. value = adjustCSS( elem, name, ret );
  10591. // Fixes bug #9237
  10592. type = "number";
  10593. }
  10594. // Make sure that null and NaN values aren't set (#7116)
  10595. if ( value == null || value !== value ) {
  10596. return;
  10597. }
  10598. // If a number was passed in, add the unit (except for certain CSS properties)
  10599. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  10600. // "px" to a few hardcoded values.
  10601. if ( type === "number" && !isCustomProp ) {
  10602. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  10603. }
  10604. // background-* props affect original clone's values
  10605. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  10606. style[ name ] = "inherit";
  10607. }
  10608. // If a hook was provided, use that value, otherwise just set the specified value
  10609. if ( !hooks || !( "set" in hooks ) ||
  10610. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  10611. if ( isCustomProp ) {
  10612. style.setProperty( name, value );
  10613. } else {
  10614. style[ name ] = value;
  10615. }
  10616. }
  10617. } else {
  10618. // If a hook was provided get the non-computed value from there
  10619. if ( hooks && "get" in hooks &&
  10620. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  10621. return ret;
  10622. }
  10623. // Otherwise just get the value from the style object
  10624. return style[ name ];
  10625. }
  10626. },
  10627. css: function( elem, name, extra, styles ) {
  10628. var val, num, hooks,
  10629. origName = camelCase( name ),
  10630. isCustomProp = rcustomProp.test( name );
  10631. // Make sure that we're working with the right name. We don't
  10632. // want to modify the value if it is a CSS custom property
  10633. // since they are user-defined.
  10634. if ( !isCustomProp ) {
  10635. name = finalPropName( origName );
  10636. }
  10637. // Try prefixed name followed by the unprefixed name
  10638. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  10639. // If a hook was provided get the computed value from there
  10640. if ( hooks && "get" in hooks ) {
  10641. val = hooks.get( elem, true, extra );
  10642. }
  10643. // Otherwise, if a way to get the computed value exists, use that
  10644. if ( val === undefined ) {
  10645. val = curCSS( elem, name, styles );
  10646. }
  10647. // Convert "normal" to computed value
  10648. if ( val === "normal" && name in cssNormalTransform ) {
  10649. val = cssNormalTransform[ name ];
  10650. }
  10651. // Make numeric if forced or a qualifier was provided and val looks numeric
  10652. if ( extra === "" || extra ) {
  10653. num = parseFloat( val );
  10654. return extra === true || isFinite( num ) ? num || 0 : val;
  10655. }
  10656. return val;
  10657. }
  10658. } );
  10659. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  10660. jQuery.cssHooks[ dimension ] = {
  10661. get: function( elem, computed, extra ) {
  10662. if ( computed ) {
  10663. // Certain elements can have dimension info if we invisibly show them
  10664. // but it must have a current display style that would benefit
  10665. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  10666. // Support: Safari 8+
  10667. // Table columns in Safari have non-zero offsetWidth & zero
  10668. // getBoundingClientRect().width unless display is changed.
  10669. // Support: IE <=11 only
  10670. // Running getBoundingClientRect on a disconnected node
  10671. // in IE throws an error.
  10672. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  10673. swap( elem, cssShow, function() {
  10674. return getWidthOrHeight( elem, dimension, extra );
  10675. } ) :
  10676. getWidthOrHeight( elem, dimension, extra );
  10677. }
  10678. },
  10679. set: function( elem, value, extra ) {
  10680. var matches,
  10681. styles = getStyles( elem ),
  10682. // Only read styles.position if the test has a chance to fail
  10683. // to avoid forcing a reflow.
  10684. scrollboxSizeBuggy = !support.scrollboxSize() &&
  10685. styles.position === "absolute",
  10686. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  10687. boxSizingNeeded = scrollboxSizeBuggy || extra,
  10688. isBorderBox = boxSizingNeeded &&
  10689. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  10690. subtract = extra ?
  10691. boxModelAdjustment(
  10692. elem,
  10693. dimension,
  10694. extra,
  10695. isBorderBox,
  10696. styles
  10697. ) :
  10698. 0;
  10699. // Account for unreliable border-box dimensions by comparing offset* to computed and
  10700. // faking a content-box to get border and padding (gh-3699)
  10701. if ( isBorderBox && scrollboxSizeBuggy ) {
  10702. subtract -= Math.ceil(
  10703. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  10704. parseFloat( styles[ dimension ] ) -
  10705. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  10706. 0.5
  10707. );
  10708. }
  10709. // Convert to pixels if value adjustment is needed
  10710. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  10711. ( matches[ 3 ] || "px" ) !== "px" ) {
  10712. elem.style[ dimension ] = value;
  10713. value = jQuery.css( elem, dimension );
  10714. }
  10715. return setPositiveNumber( elem, value, subtract );
  10716. }
  10717. };
  10718. } );
  10719. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  10720. function( elem, computed ) {
  10721. if ( computed ) {
  10722. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  10723. elem.getBoundingClientRect().left -
  10724. swap( elem, { marginLeft: 0 }, function() {
  10725. return elem.getBoundingClientRect().left;
  10726. } )
  10727. ) + "px";
  10728. }
  10729. }
  10730. );
  10731. // These hooks are used by animate to expand properties
  10732. jQuery.each( {
  10733. margin: "",
  10734. padding: "",
  10735. border: "Width"
  10736. }, function( prefix, suffix ) {
  10737. jQuery.cssHooks[ prefix + suffix ] = {
  10738. expand: function( value ) {
  10739. var i = 0,
  10740. expanded = {},
  10741. // Assumes a single number if not a string
  10742. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  10743. for ( ; i < 4; i++ ) {
  10744. expanded[ prefix + cssExpand[ i ] + suffix ] =
  10745. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  10746. }
  10747. return expanded;
  10748. }
  10749. };
  10750. if ( prefix !== "margin" ) {
  10751. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  10752. }
  10753. } );
  10754. jQuery.fn.extend( {
  10755. css: function( name, value ) {
  10756. return access( this, function( elem, name, value ) {
  10757. var styles, len,
  10758. map = {},
  10759. i = 0;
  10760. if ( Array.isArray( name ) ) {
  10761. styles = getStyles( elem );
  10762. len = name.length;
  10763. for ( ; i < len; i++ ) {
  10764. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  10765. }
  10766. return map;
  10767. }
  10768. return value !== undefined ?
  10769. jQuery.style( elem, name, value ) :
  10770. jQuery.css( elem, name );
  10771. }, name, value, arguments.length > 1 );
  10772. }
  10773. } );
  10774. function Tween( elem, options, prop, end, easing ) {
  10775. return new Tween.prototype.init( elem, options, prop, end, easing );
  10776. }
  10777. jQuery.Tween = Tween;
  10778. Tween.prototype = {
  10779. constructor: Tween,
  10780. init: function( elem, options, prop, end, easing, unit ) {
  10781. this.elem = elem;
  10782. this.prop = prop;
  10783. this.easing = easing || jQuery.easing._default;
  10784. this.options = options;
  10785. this.start = this.now = this.cur();
  10786. this.end = end;
  10787. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  10788. },
  10789. cur: function() {
  10790. var hooks = Tween.propHooks[ this.prop ];
  10791. return hooks && hooks.get ?
  10792. hooks.get( this ) :
  10793. Tween.propHooks._default.get( this );
  10794. },
  10795. run: function( percent ) {
  10796. var eased,
  10797. hooks = Tween.propHooks[ this.prop ];
  10798. if ( this.options.duration ) {
  10799. this.pos = eased = jQuery.easing[ this.easing ](
  10800. percent, this.options.duration * percent, 0, 1, this.options.duration
  10801. );
  10802. } else {
  10803. this.pos = eased = percent;
  10804. }
  10805. this.now = ( this.end - this.start ) * eased + this.start;
  10806. if ( this.options.step ) {
  10807. this.options.step.call( this.elem, this.now, this );
  10808. }
  10809. if ( hooks && hooks.set ) {
  10810. hooks.set( this );
  10811. } else {
  10812. Tween.propHooks._default.set( this );
  10813. }
  10814. return this;
  10815. }
  10816. };
  10817. Tween.prototype.init.prototype = Tween.prototype;
  10818. Tween.propHooks = {
  10819. _default: {
  10820. get: function( tween ) {
  10821. var result;
  10822. // Use a property on the element directly when it is not a DOM element,
  10823. // or when there is no matching style property that exists.
  10824. if ( tween.elem.nodeType !== 1 ||
  10825. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  10826. return tween.elem[ tween.prop ];
  10827. }
  10828. // Passing an empty string as a 3rd parameter to .css will automatically
  10829. // attempt a parseFloat and fallback to a string if the parse fails.
  10830. // Simple values such as "10px" are parsed to Float;
  10831. // complex values such as "rotate(1rad)" are returned as-is.
  10832. result = jQuery.css( tween.elem, tween.prop, "" );
  10833. // Empty strings, null, undefined and "auto" are converted to 0.
  10834. return !result || result === "auto" ? 0 : result;
  10835. },
  10836. set: function( tween ) {
  10837. // Use step hook for back compat.
  10838. // Use cssHook if its there.
  10839. // Use .style if available and use plain properties where available.
  10840. if ( jQuery.fx.step[ tween.prop ] ) {
  10841. jQuery.fx.step[ tween.prop ]( tween );
  10842. } else if ( tween.elem.nodeType === 1 && (
  10843. jQuery.cssHooks[ tween.prop ] ||
  10844. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  10845. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  10846. } else {
  10847. tween.elem[ tween.prop ] = tween.now;
  10848. }
  10849. }
  10850. }
  10851. };
  10852. // Support: IE <=9 only
  10853. // Panic based approach to setting things on disconnected nodes
  10854. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  10855. set: function( tween ) {
  10856. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  10857. tween.elem[ tween.prop ] = tween.now;
  10858. }
  10859. }
  10860. };
  10861. jQuery.easing = {
  10862. linear: function( p ) {
  10863. return p;
  10864. },
  10865. swing: function( p ) {
  10866. return 0.5 - Math.cos( p * Math.PI ) / 2;
  10867. },
  10868. _default: "swing"
  10869. };
  10870. jQuery.fx = Tween.prototype.init;
  10871. // Back compat <1.8 extension point
  10872. jQuery.fx.step = {};
  10873. var
  10874. fxNow, inProgress,
  10875. rfxtypes = /^(?:toggle|show|hide)$/,
  10876. rrun = /queueHooks$/;
  10877. function schedule() {
  10878. if ( inProgress ) {
  10879. if ( document.hidden === false && window.requestAnimationFrame ) {
  10880. window.requestAnimationFrame( schedule );
  10881. } else {
  10882. window.setTimeout( schedule, jQuery.fx.interval );
  10883. }
  10884. jQuery.fx.tick();
  10885. }
  10886. }
  10887. // Animations created synchronously will run synchronously
  10888. function createFxNow() {
  10889. window.setTimeout( function() {
  10890. fxNow = undefined;
  10891. } );
  10892. return ( fxNow = Date.now() );
  10893. }
  10894. // Generate parameters to create a standard animation
  10895. function genFx( type, includeWidth ) {
  10896. var which,
  10897. i = 0,
  10898. attrs = { height: type };
  10899. // If we include width, step value is 1 to do all cssExpand values,
  10900. // otherwise step value is 2 to skip over Left and Right
  10901. includeWidth = includeWidth ? 1 : 0;
  10902. for ( ; i < 4; i += 2 - includeWidth ) {
  10903. which = cssExpand[ i ];
  10904. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  10905. }
  10906. if ( includeWidth ) {
  10907. attrs.opacity = attrs.width = type;
  10908. }
  10909. return attrs;
  10910. }
  10911. function createTween( value, prop, animation ) {
  10912. var tween,
  10913. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  10914. index = 0,
  10915. length = collection.length;
  10916. for ( ; index < length; index++ ) {
  10917. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  10918. // We're done with this property
  10919. return tween;
  10920. }
  10921. }
  10922. }
  10923. function defaultPrefilter( elem, props, opts ) {
  10924. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  10925. isBox = "width" in props || "height" in props,
  10926. anim = this,
  10927. orig = {},
  10928. style = elem.style,
  10929. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  10930. dataShow = dataPriv.get( elem, "fxshow" );
  10931. // Queue-skipping animations hijack the fx hooks
  10932. if ( !opts.queue ) {
  10933. hooks = jQuery._queueHooks( elem, "fx" );
  10934. if ( hooks.unqueued == null ) {
  10935. hooks.unqueued = 0;
  10936. oldfire = hooks.empty.fire;
  10937. hooks.empty.fire = function() {
  10938. if ( !hooks.unqueued ) {
  10939. oldfire();
  10940. }
  10941. };
  10942. }
  10943. hooks.unqueued++;
  10944. anim.always( function() {
  10945. // Ensure the complete handler is called before this completes
  10946. anim.always( function() {
  10947. hooks.unqueued--;
  10948. if ( !jQuery.queue( elem, "fx" ).length ) {
  10949. hooks.empty.fire();
  10950. }
  10951. } );
  10952. } );
  10953. }
  10954. // Detect show/hide animations
  10955. for ( prop in props ) {
  10956. value = props[ prop ];
  10957. if ( rfxtypes.test( value ) ) {
  10958. delete props[ prop ];
  10959. toggle = toggle || value === "toggle";
  10960. if ( value === ( hidden ? "hide" : "show" ) ) {
  10961. // Pretend to be hidden if this is a "show" and
  10962. // there is still data from a stopped show/hide
  10963. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  10964. hidden = true;
  10965. // Ignore all other no-op show/hide data
  10966. } else {
  10967. continue;
  10968. }
  10969. }
  10970. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  10971. }
  10972. }
  10973. // Bail out if this is a no-op like .hide().hide()
  10974. propTween = !jQuery.isEmptyObject( props );
  10975. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  10976. return;
  10977. }
  10978. // Restrict "overflow" and "display" styles during box animations
  10979. if ( isBox && elem.nodeType === 1 ) {
  10980. // Support: IE <=9 - 11, Edge 12 - 15
  10981. // Record all 3 overflow attributes because IE does not infer the shorthand
  10982. // from identically-valued overflowX and overflowY and Edge just mirrors
  10983. // the overflowX value there.
  10984. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  10985. // Identify a display type, preferring old show/hide data over the CSS cascade
  10986. restoreDisplay = dataShow && dataShow.display;
  10987. if ( restoreDisplay == null ) {
  10988. restoreDisplay = dataPriv.get( elem, "display" );
  10989. }
  10990. display = jQuery.css( elem, "display" );
  10991. if ( display === "none" ) {
  10992. if ( restoreDisplay ) {
  10993. display = restoreDisplay;
  10994. } else {
  10995. // Get nonempty value(s) by temporarily forcing visibility
  10996. showHide( [ elem ], true );
  10997. restoreDisplay = elem.style.display || restoreDisplay;
  10998. display = jQuery.css( elem, "display" );
  10999. showHide( [ elem ] );
  11000. }
  11001. }
  11002. // Animate inline elements as inline-block
  11003. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  11004. if ( jQuery.css( elem, "float" ) === "none" ) {
  11005. // Restore the original display value at the end of pure show/hide animations
  11006. if ( !propTween ) {
  11007. anim.done( function() {
  11008. style.display = restoreDisplay;
  11009. } );
  11010. if ( restoreDisplay == null ) {
  11011. display = style.display;
  11012. restoreDisplay = display === "none" ? "" : display;
  11013. }
  11014. }
  11015. style.display = "inline-block";
  11016. }
  11017. }
  11018. }
  11019. if ( opts.overflow ) {
  11020. style.overflow = "hidden";
  11021. anim.always( function() {
  11022. style.overflow = opts.overflow[ 0 ];
  11023. style.overflowX = opts.overflow[ 1 ];
  11024. style.overflowY = opts.overflow[ 2 ];
  11025. } );
  11026. }
  11027. // Implement show/hide animations
  11028. propTween = false;
  11029. for ( prop in orig ) {
  11030. // General show/hide setup for this element animation
  11031. if ( !propTween ) {
  11032. if ( dataShow ) {
  11033. if ( "hidden" in dataShow ) {
  11034. hidden = dataShow.hidden;
  11035. }
  11036. } else {
  11037. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  11038. }
  11039. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  11040. if ( toggle ) {
  11041. dataShow.hidden = !hidden;
  11042. }
  11043. // Show elements before animating them
  11044. if ( hidden ) {
  11045. showHide( [ elem ], true );
  11046. }
  11047. /* eslint-disable no-loop-func */
  11048. anim.done( function() {
  11049. /* eslint-enable no-loop-func */
  11050. // The final step of a "hide" animation is actually hiding the element
  11051. if ( !hidden ) {
  11052. showHide( [ elem ] );
  11053. }
  11054. dataPriv.remove( elem, "fxshow" );
  11055. for ( prop in orig ) {
  11056. jQuery.style( elem, prop, orig[ prop ] );
  11057. }
  11058. } );
  11059. }
  11060. // Per-property setup
  11061. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  11062. if ( !( prop in dataShow ) ) {
  11063. dataShow[ prop ] = propTween.start;
  11064. if ( hidden ) {
  11065. propTween.end = propTween.start;
  11066. propTween.start = 0;
  11067. }
  11068. }
  11069. }
  11070. }
  11071. function propFilter( props, specialEasing ) {
  11072. var index, name, easing, value, hooks;
  11073. // camelCase, specialEasing and expand cssHook pass
  11074. for ( index in props ) {
  11075. name = camelCase( index );
  11076. easing = specialEasing[ name ];
  11077. value = props[ index ];
  11078. if ( Array.isArray( value ) ) {
  11079. easing = value[ 1 ];
  11080. value = props[ index ] = value[ 0 ];
  11081. }
  11082. if ( index !== name ) {
  11083. props[ name ] = value;
  11084. delete props[ index ];
  11085. }
  11086. hooks = jQuery.cssHooks[ name ];
  11087. if ( hooks && "expand" in hooks ) {
  11088. value = hooks.expand( value );
  11089. delete props[ name ];
  11090. // Not quite $.extend, this won't overwrite existing keys.
  11091. // Reusing 'index' because we have the correct "name"
  11092. for ( index in value ) {
  11093. if ( !( index in props ) ) {
  11094. props[ index ] = value[ index ];
  11095. specialEasing[ index ] = easing;
  11096. }
  11097. }
  11098. } else {
  11099. specialEasing[ name ] = easing;
  11100. }
  11101. }
  11102. }
  11103. function Animation( elem, properties, options ) {
  11104. var result,
  11105. stopped,
  11106. index = 0,
  11107. length = Animation.prefilters.length,
  11108. deferred = jQuery.Deferred().always( function() {
  11109. // Don't match elem in the :animated selector
  11110. delete tick.elem;
  11111. } ),
  11112. tick = function() {
  11113. if ( stopped ) {
  11114. return false;
  11115. }
  11116. var currentTime = fxNow || createFxNow(),
  11117. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  11118. // Support: Android 2.3 only
  11119. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  11120. temp = remaining / animation.duration || 0,
  11121. percent = 1 - temp,
  11122. index = 0,
  11123. length = animation.tweens.length;
  11124. for ( ; index < length; index++ ) {
  11125. animation.tweens[ index ].run( percent );
  11126. }
  11127. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  11128. // If there's more to do, yield
  11129. if ( percent < 1 && length ) {
  11130. return remaining;
  11131. }
  11132. // If this was an empty animation, synthesize a final progress notification
  11133. if ( !length ) {
  11134. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  11135. }
  11136. // Resolve the animation and report its conclusion
  11137. deferred.resolveWith( elem, [ animation ] );
  11138. return false;
  11139. },
  11140. animation = deferred.promise( {
  11141. elem: elem,
  11142. props: jQuery.extend( {}, properties ),
  11143. opts: jQuery.extend( true, {
  11144. specialEasing: {},
  11145. easing: jQuery.easing._default
  11146. }, options ),
  11147. originalProperties: properties,
  11148. originalOptions: options,
  11149. startTime: fxNow || createFxNow(),
  11150. duration: options.duration,
  11151. tweens: [],
  11152. createTween: function( prop, end ) {
  11153. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  11154. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  11155. animation.tweens.push( tween );
  11156. return tween;
  11157. },
  11158. stop: function( gotoEnd ) {
  11159. var index = 0,
  11160. // If we are going to the end, we want to run all the tweens
  11161. // otherwise we skip this part
  11162. length = gotoEnd ? animation.tweens.length : 0;
  11163. if ( stopped ) {
  11164. return this;
  11165. }
  11166. stopped = true;
  11167. for ( ; index < length; index++ ) {
  11168. animation.tweens[ index ].run( 1 );
  11169. }
  11170. // Resolve when we played the last frame; otherwise, reject
  11171. if ( gotoEnd ) {
  11172. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  11173. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  11174. } else {
  11175. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  11176. }
  11177. return this;
  11178. }
  11179. } ),
  11180. props = animation.props;
  11181. propFilter( props, animation.opts.specialEasing );
  11182. for ( ; index < length; index++ ) {
  11183. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  11184. if ( result ) {
  11185. if ( isFunction( result.stop ) ) {
  11186. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  11187. result.stop.bind( result );
  11188. }
  11189. return result;
  11190. }
  11191. }
  11192. jQuery.map( props, createTween, animation );
  11193. if ( isFunction( animation.opts.start ) ) {
  11194. animation.opts.start.call( elem, animation );
  11195. }
  11196. // Attach callbacks from options
  11197. animation
  11198. .progress( animation.opts.progress )
  11199. .done( animation.opts.done, animation.opts.complete )
  11200. .fail( animation.opts.fail )
  11201. .always( animation.opts.always );
  11202. jQuery.fx.timer(
  11203. jQuery.extend( tick, {
  11204. elem: elem,
  11205. anim: animation,
  11206. queue: animation.opts.queue
  11207. } )
  11208. );
  11209. return animation;
  11210. }
  11211. jQuery.Animation = jQuery.extend( Animation, {
  11212. tweeners: {
  11213. "*": [ function( prop, value ) {
  11214. var tween = this.createTween( prop, value );
  11215. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  11216. return tween;
  11217. } ]
  11218. },
  11219. tweener: function( props, callback ) {
  11220. if ( isFunction( props ) ) {
  11221. callback = props;
  11222. props = [ "*" ];
  11223. } else {
  11224. props = props.match( rnothtmlwhite );
  11225. }
  11226. var prop,
  11227. index = 0,
  11228. length = props.length;
  11229. for ( ; index < length; index++ ) {
  11230. prop = props[ index ];
  11231. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  11232. Animation.tweeners[ prop ].unshift( callback );
  11233. }
  11234. },
  11235. prefilters: [ defaultPrefilter ],
  11236. prefilter: function( callback, prepend ) {
  11237. if ( prepend ) {
  11238. Animation.prefilters.unshift( callback );
  11239. } else {
  11240. Animation.prefilters.push( callback );
  11241. }
  11242. }
  11243. } );
  11244. jQuery.speed = function( speed, easing, fn ) {
  11245. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  11246. complete: fn || !fn && easing ||
  11247. isFunction( speed ) && speed,
  11248. duration: speed,
  11249. easing: fn && easing || easing && !isFunction( easing ) && easing
  11250. };
  11251. // Go to the end state if fx are off
  11252. if ( jQuery.fx.off ) {
  11253. opt.duration = 0;
  11254. } else {
  11255. if ( typeof opt.duration !== "number" ) {
  11256. if ( opt.duration in jQuery.fx.speeds ) {
  11257. opt.duration = jQuery.fx.speeds[ opt.duration ];
  11258. } else {
  11259. opt.duration = jQuery.fx.speeds._default;
  11260. }
  11261. }
  11262. }
  11263. // Normalize opt.queue - true/undefined/null -> "fx"
  11264. if ( opt.queue == null || opt.queue === true ) {
  11265. opt.queue = "fx";
  11266. }
  11267. // Queueing
  11268. opt.old = opt.complete;
  11269. opt.complete = function() {
  11270. if ( isFunction( opt.old ) ) {
  11271. opt.old.call( this );
  11272. }
  11273. if ( opt.queue ) {
  11274. jQuery.dequeue( this, opt.queue );
  11275. }
  11276. };
  11277. return opt;
  11278. };
  11279. jQuery.fn.extend( {
  11280. fadeTo: function( speed, to, easing, callback ) {
  11281. // Show any hidden elements after setting opacity to 0
  11282. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  11283. // Animate to the value specified
  11284. .end().animate( { opacity: to }, speed, easing, callback );
  11285. },
  11286. animate: function( prop, speed, easing, callback ) {
  11287. var empty = jQuery.isEmptyObject( prop ),
  11288. optall = jQuery.speed( speed, easing, callback ),
  11289. doAnimation = function() {
  11290. // Operate on a copy of prop so per-property easing won't be lost
  11291. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  11292. // Empty animations, or finishing resolves immediately
  11293. if ( empty || dataPriv.get( this, "finish" ) ) {
  11294. anim.stop( true );
  11295. }
  11296. };
  11297. doAnimation.finish = doAnimation;
  11298. return empty || optall.queue === false ?
  11299. this.each( doAnimation ) :
  11300. this.queue( optall.queue, doAnimation );
  11301. },
  11302. stop: function( type, clearQueue, gotoEnd ) {
  11303. var stopQueue = function( hooks ) {
  11304. var stop = hooks.stop;
  11305. delete hooks.stop;
  11306. stop( gotoEnd );
  11307. };
  11308. if ( typeof type !== "string" ) {
  11309. gotoEnd = clearQueue;
  11310. clearQueue = type;
  11311. type = undefined;
  11312. }
  11313. if ( clearQueue && type !== false ) {
  11314. this.queue( type || "fx", [] );
  11315. }
  11316. return this.each( function() {
  11317. var dequeue = true,
  11318. index = type != null && type + "queueHooks",
  11319. timers = jQuery.timers,
  11320. data = dataPriv.get( this );
  11321. if ( index ) {
  11322. if ( data[ index ] && data[ index ].stop ) {
  11323. stopQueue( data[ index ] );
  11324. }
  11325. } else {
  11326. for ( index in data ) {
  11327. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  11328. stopQueue( data[ index ] );
  11329. }
  11330. }
  11331. }
  11332. for ( index = timers.length; index--; ) {
  11333. if ( timers[ index ].elem === this &&
  11334. ( type == null || timers[ index ].queue === type ) ) {
  11335. timers[ index ].anim.stop( gotoEnd );
  11336. dequeue = false;
  11337. timers.splice( index, 1 );
  11338. }
  11339. }
  11340. // Start the next in the queue if the last step wasn't forced.
  11341. // Timers currently will call their complete callbacks, which
  11342. // will dequeue but only if they were gotoEnd.
  11343. if ( dequeue || !gotoEnd ) {
  11344. jQuery.dequeue( this, type );
  11345. }
  11346. } );
  11347. },
  11348. finish: function( type ) {
  11349. if ( type !== false ) {
  11350. type = type || "fx";
  11351. }
  11352. return this.each( function() {
  11353. var index,
  11354. data = dataPriv.get( this ),
  11355. queue = data[ type + "queue" ],
  11356. hooks = data[ type + "queueHooks" ],
  11357. timers = jQuery.timers,
  11358. length = queue ? queue.length : 0;
  11359. // Enable finishing flag on private data
  11360. data.finish = true;
  11361. // Empty the queue first
  11362. jQuery.queue( this, type, [] );
  11363. if ( hooks && hooks.stop ) {
  11364. hooks.stop.call( this, true );
  11365. }
  11366. // Look for any active animations, and finish them
  11367. for ( index = timers.length; index--; ) {
  11368. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  11369. timers[ index ].anim.stop( true );
  11370. timers.splice( index, 1 );
  11371. }
  11372. }
  11373. // Look for any animations in the old queue and finish them
  11374. for ( index = 0; index < length; index++ ) {
  11375. if ( queue[ index ] && queue[ index ].finish ) {
  11376. queue[ index ].finish.call( this );
  11377. }
  11378. }
  11379. // Turn off finishing flag
  11380. delete data.finish;
  11381. } );
  11382. }
  11383. } );
  11384. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  11385. var cssFn = jQuery.fn[ name ];
  11386. jQuery.fn[ name ] = function( speed, easing, callback ) {
  11387. return speed == null || typeof speed === "boolean" ?
  11388. cssFn.apply( this, arguments ) :
  11389. this.animate( genFx( name, true ), speed, easing, callback );
  11390. };
  11391. } );
  11392. // Generate shortcuts for custom animations
  11393. jQuery.each( {
  11394. slideDown: genFx( "show" ),
  11395. slideUp: genFx( "hide" ),
  11396. slideToggle: genFx( "toggle" ),
  11397. fadeIn: { opacity: "show" },
  11398. fadeOut: { opacity: "hide" },
  11399. fadeToggle: { opacity: "toggle" }
  11400. }, function( name, props ) {
  11401. jQuery.fn[ name ] = function( speed, easing, callback ) {
  11402. return this.animate( props, speed, easing, callback );
  11403. };
  11404. } );
  11405. jQuery.timers = [];
  11406. jQuery.fx.tick = function() {
  11407. var timer,
  11408. i = 0,
  11409. timers = jQuery.timers;
  11410. fxNow = Date.now();
  11411. for ( ; i < timers.length; i++ ) {
  11412. timer = timers[ i ];
  11413. // Run the timer and safely remove it when done (allowing for external removal)
  11414. if ( !timer() && timers[ i ] === timer ) {
  11415. timers.splice( i--, 1 );
  11416. }
  11417. }
  11418. if ( !timers.length ) {
  11419. jQuery.fx.stop();
  11420. }
  11421. fxNow = undefined;
  11422. };
  11423. jQuery.fx.timer = function( timer ) {
  11424. jQuery.timers.push( timer );
  11425. jQuery.fx.start();
  11426. };
  11427. jQuery.fx.interval = 13;
  11428. jQuery.fx.start = function() {
  11429. if ( inProgress ) {
  11430. return;
  11431. }
  11432. inProgress = true;
  11433. schedule();
  11434. };
  11435. jQuery.fx.stop = function() {
  11436. inProgress = null;
  11437. };
  11438. jQuery.fx.speeds = {
  11439. slow: 600,
  11440. fast: 200,
  11441. // Default speed
  11442. _default: 400
  11443. };
  11444. // Based off of the plugin by Clint Helfers, with permission.
  11445. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  11446. jQuery.fn.delay = function( time, type ) {
  11447. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  11448. type = type || "fx";
  11449. return this.queue( type, function( next, hooks ) {
  11450. var timeout = window.setTimeout( next, time );
  11451. hooks.stop = function() {
  11452. window.clearTimeout( timeout );
  11453. };
  11454. } );
  11455. };
  11456. ( function() {
  11457. var input = document.createElement( "input" ),
  11458. select = document.createElement( "select" ),
  11459. opt = select.appendChild( document.createElement( "option" ) );
  11460. input.type = "checkbox";
  11461. // Support: Android <=4.3 only
  11462. // Default value for a checkbox should be "on"
  11463. support.checkOn = input.value !== "";
  11464. // Support: IE <=11 only
  11465. // Must access selectedIndex to make default options select
  11466. support.optSelected = opt.selected;
  11467. // Support: IE <=11 only
  11468. // An input loses its value after becoming a radio
  11469. input = document.createElement( "input" );
  11470. input.value = "t";
  11471. input.type = "radio";
  11472. support.radioValue = input.value === "t";
  11473. } )();
  11474. var boolHook,
  11475. attrHandle = jQuery.expr.attrHandle;
  11476. jQuery.fn.extend( {
  11477. attr: function( name, value ) {
  11478. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  11479. },
  11480. removeAttr: function( name ) {
  11481. return this.each( function() {
  11482. jQuery.removeAttr( this, name );
  11483. } );
  11484. }
  11485. } );
  11486. jQuery.extend( {
  11487. attr: function( elem, name, value ) {
  11488. var ret, hooks,
  11489. nType = elem.nodeType;
  11490. // Don't get/set attributes on text, comment and attribute nodes
  11491. if ( nType === 3 || nType === 8 || nType === 2 ) {
  11492. return;
  11493. }
  11494. // Fallback to prop when attributes are not supported
  11495. if ( typeof elem.getAttribute === "undefined" ) {
  11496. return jQuery.prop( elem, name, value );
  11497. }
  11498. // Attribute hooks are determined by the lowercase version
  11499. // Grab necessary hook if one is defined
  11500. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  11501. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  11502. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  11503. }
  11504. if ( value !== undefined ) {
  11505. if ( value === null ) {
  11506. jQuery.removeAttr( elem, name );
  11507. return;
  11508. }
  11509. if ( hooks && "set" in hooks &&
  11510. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  11511. return ret;
  11512. }
  11513. elem.setAttribute( name, value + "" );
  11514. return value;
  11515. }
  11516. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  11517. return ret;
  11518. }
  11519. ret = jQuery.find.attr( elem, name );
  11520. // Non-existent attributes return null, we normalize to undefined
  11521. return ret == null ? undefined : ret;
  11522. },
  11523. attrHooks: {
  11524. type: {
  11525. set: function( elem, value ) {
  11526. if ( !support.radioValue && value === "radio" &&
  11527. nodeName( elem, "input" ) ) {
  11528. var val = elem.value;
  11529. elem.setAttribute( "type", value );
  11530. if ( val ) {
  11531. elem.value = val;
  11532. }
  11533. return value;
  11534. }
  11535. }
  11536. }
  11537. },
  11538. removeAttr: function( elem, value ) {
  11539. var name,
  11540. i = 0,
  11541. // Attribute names can contain non-HTML whitespace characters
  11542. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  11543. attrNames = value && value.match( rnothtmlwhite );
  11544. if ( attrNames && elem.nodeType === 1 ) {
  11545. while ( ( name = attrNames[ i++ ] ) ) {
  11546. elem.removeAttribute( name );
  11547. }
  11548. }
  11549. }
  11550. } );
  11551. // Hooks for boolean attributes
  11552. boolHook = {
  11553. set: function( elem, value, name ) {
  11554. if ( value === false ) {
  11555. // Remove boolean attributes when set to false
  11556. jQuery.removeAttr( elem, name );
  11557. } else {
  11558. elem.setAttribute( name, name );
  11559. }
  11560. return name;
  11561. }
  11562. };
  11563. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  11564. var getter = attrHandle[ name ] || jQuery.find.attr;
  11565. attrHandle[ name ] = function( elem, name, isXML ) {
  11566. var ret, handle,
  11567. lowercaseName = name.toLowerCase();
  11568. if ( !isXML ) {
  11569. // Avoid an infinite loop by temporarily removing this function from the getter
  11570. handle = attrHandle[ lowercaseName ];
  11571. attrHandle[ lowercaseName ] = ret;
  11572. ret = getter( elem, name, isXML ) != null ?
  11573. lowercaseName :
  11574. null;
  11575. attrHandle[ lowercaseName ] = handle;
  11576. }
  11577. return ret;
  11578. };
  11579. } );
  11580. var rfocusable = /^(?:input|select|textarea|button)$/i,
  11581. rclickable = /^(?:a|area)$/i;
  11582. jQuery.fn.extend( {
  11583. prop: function( name, value ) {
  11584. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  11585. },
  11586. removeProp: function( name ) {
  11587. return this.each( function() {
  11588. delete this[ jQuery.propFix[ name ] || name ];
  11589. } );
  11590. }
  11591. } );
  11592. jQuery.extend( {
  11593. prop: function( elem, name, value ) {
  11594. var ret, hooks,
  11595. nType = elem.nodeType;
  11596. // Don't get/set properties on text, comment and attribute nodes
  11597. if ( nType === 3 || nType === 8 || nType === 2 ) {
  11598. return;
  11599. }
  11600. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  11601. // Fix name and attach hooks
  11602. name = jQuery.propFix[ name ] || name;
  11603. hooks = jQuery.propHooks[ name ];
  11604. }
  11605. if ( value !== undefined ) {
  11606. if ( hooks && "set" in hooks &&
  11607. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  11608. return ret;
  11609. }
  11610. return ( elem[ name ] = value );
  11611. }
  11612. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  11613. return ret;
  11614. }
  11615. return elem[ name ];
  11616. },
  11617. propHooks: {
  11618. tabIndex: {
  11619. get: function( elem ) {
  11620. // Support: IE <=9 - 11 only
  11621. // elem.tabIndex doesn't always return the
  11622. // correct value when it hasn't been explicitly set
  11623. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  11624. // Use proper attribute retrieval(#12072)
  11625. var tabindex = jQuery.find.attr( elem, "tabindex" );
  11626. if ( tabindex ) {
  11627. return parseInt( tabindex, 10 );
  11628. }
  11629. if (
  11630. rfocusable.test( elem.nodeName ) ||
  11631. rclickable.test( elem.nodeName ) &&
  11632. elem.href
  11633. ) {
  11634. return 0;
  11635. }
  11636. return -1;
  11637. }
  11638. }
  11639. },
  11640. propFix: {
  11641. "for": "htmlFor",
  11642. "class": "className"
  11643. }
  11644. } );
  11645. // Support: IE <=11 only
  11646. // Accessing the selectedIndex property
  11647. // forces the browser to respect setting selected
  11648. // on the option
  11649. // The getter ensures a default option is selected
  11650. // when in an optgroup
  11651. // eslint rule "no-unused-expressions" is disabled for this code
  11652. // since it considers such accessions noop
  11653. if ( !support.optSelected ) {
  11654. jQuery.propHooks.selected = {
  11655. get: function( elem ) {
  11656. /* eslint no-unused-expressions: "off" */
  11657. var parent = elem.parentNode;
  11658. if ( parent && parent.parentNode ) {
  11659. parent.parentNode.selectedIndex;
  11660. }
  11661. return null;
  11662. },
  11663. set: function( elem ) {
  11664. /* eslint no-unused-expressions: "off" */
  11665. var parent = elem.parentNode;
  11666. if ( parent ) {
  11667. parent.selectedIndex;
  11668. if ( parent.parentNode ) {
  11669. parent.parentNode.selectedIndex;
  11670. }
  11671. }
  11672. }
  11673. };
  11674. }
  11675. jQuery.each( [
  11676. "tabIndex",
  11677. "readOnly",
  11678. "maxLength",
  11679. "cellSpacing",
  11680. "cellPadding",
  11681. "rowSpan",
  11682. "colSpan",
  11683. "useMap",
  11684. "frameBorder",
  11685. "contentEditable"
  11686. ], function() {
  11687. jQuery.propFix[ this.toLowerCase() ] = this;
  11688. } );
  11689. // Strip and collapse whitespace according to HTML spec
  11690. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  11691. function stripAndCollapse( value ) {
  11692. var tokens = value.match( rnothtmlwhite ) || [];
  11693. return tokens.join( " " );
  11694. }
  11695. function getClass( elem ) {
  11696. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  11697. }
  11698. function classesToArray( value ) {
  11699. if ( Array.isArray( value ) ) {
  11700. return value;
  11701. }
  11702. if ( typeof value === "string" ) {
  11703. return value.match( rnothtmlwhite ) || [];
  11704. }
  11705. return [];
  11706. }
  11707. jQuery.fn.extend( {
  11708. addClass: function( value ) {
  11709. var classes, elem, cur, curValue, clazz, j, finalValue,
  11710. i = 0;
  11711. if ( isFunction( value ) ) {
  11712. return this.each( function( j ) {
  11713. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  11714. } );
  11715. }
  11716. classes = classesToArray( value );
  11717. if ( classes.length ) {
  11718. while ( ( elem = this[ i++ ] ) ) {
  11719. curValue = getClass( elem );
  11720. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  11721. if ( cur ) {
  11722. j = 0;
  11723. while ( ( clazz = classes[ j++ ] ) ) {
  11724. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  11725. cur += clazz + " ";
  11726. }
  11727. }
  11728. // Only assign if different to avoid unneeded rendering.
  11729. finalValue = stripAndCollapse( cur );
  11730. if ( curValue !== finalValue ) {
  11731. elem.setAttribute( "class", finalValue );
  11732. }
  11733. }
  11734. }
  11735. }
  11736. return this;
  11737. },
  11738. removeClass: function( value ) {
  11739. var classes, elem, cur, curValue, clazz, j, finalValue,
  11740. i = 0;
  11741. if ( isFunction( value ) ) {
  11742. return this.each( function( j ) {
  11743. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  11744. } );
  11745. }
  11746. if ( !arguments.length ) {
  11747. return this.attr( "class", "" );
  11748. }
  11749. classes = classesToArray( value );
  11750. if ( classes.length ) {
  11751. while ( ( elem = this[ i++ ] ) ) {
  11752. curValue = getClass( elem );
  11753. // This expression is here for better compressibility (see addClass)
  11754. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  11755. if ( cur ) {
  11756. j = 0;
  11757. while ( ( clazz = classes[ j++ ] ) ) {
  11758. // Remove *all* instances
  11759. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  11760. cur = cur.replace( " " + clazz + " ", " " );
  11761. }
  11762. }
  11763. // Only assign if different to avoid unneeded rendering.
  11764. finalValue = stripAndCollapse( cur );
  11765. if ( curValue !== finalValue ) {
  11766. elem.setAttribute( "class", finalValue );
  11767. }
  11768. }
  11769. }
  11770. }
  11771. return this;
  11772. },
  11773. toggleClass: function( value, stateVal ) {
  11774. var type = typeof value,
  11775. isValidValue = type === "string" || Array.isArray( value );
  11776. if ( typeof stateVal === "boolean" && isValidValue ) {
  11777. return stateVal ? this.addClass( value ) : this.removeClass( value );
  11778. }
  11779. if ( isFunction( value ) ) {
  11780. return this.each( function( i ) {
  11781. jQuery( this ).toggleClass(
  11782. value.call( this, i, getClass( this ), stateVal ),
  11783. stateVal
  11784. );
  11785. } );
  11786. }
  11787. return this.each( function() {
  11788. var className, i, self, classNames;
  11789. if ( isValidValue ) {
  11790. // Toggle individual class names
  11791. i = 0;
  11792. self = jQuery( this );
  11793. classNames = classesToArray( value );
  11794. while ( ( className = classNames[ i++ ] ) ) {
  11795. // Check each className given, space separated list
  11796. if ( self.hasClass( className ) ) {
  11797. self.removeClass( className );
  11798. } else {
  11799. self.addClass( className );
  11800. }
  11801. }
  11802. // Toggle whole class name
  11803. } else if ( value === undefined || type === "boolean" ) {
  11804. className = getClass( this );
  11805. if ( className ) {
  11806. // Store className if set
  11807. dataPriv.set( this, "__className__", className );
  11808. }
  11809. // If the element has a class name or if we're passed `false`,
  11810. // then remove the whole classname (if there was one, the above saved it).
  11811. // Otherwise bring back whatever was previously saved (if anything),
  11812. // falling back to the empty string if nothing was stored.
  11813. if ( this.setAttribute ) {
  11814. this.setAttribute( "class",
  11815. className || value === false ?
  11816. "" :
  11817. dataPriv.get( this, "__className__" ) || ""
  11818. );
  11819. }
  11820. }
  11821. } );
  11822. },
  11823. hasClass: function( selector ) {
  11824. var className, elem,
  11825. i = 0;
  11826. className = " " + selector + " ";
  11827. while ( ( elem = this[ i++ ] ) ) {
  11828. if ( elem.nodeType === 1 &&
  11829. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  11830. return true;
  11831. }
  11832. }
  11833. return false;
  11834. }
  11835. } );
  11836. var rreturn = /\r/g;
  11837. jQuery.fn.extend( {
  11838. val: function( value ) {
  11839. var hooks, ret, valueIsFunction,
  11840. elem = this[ 0 ];
  11841. if ( !arguments.length ) {
  11842. if ( elem ) {
  11843. hooks = jQuery.valHooks[ elem.type ] ||
  11844. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  11845. if ( hooks &&
  11846. "get" in hooks &&
  11847. ( ret = hooks.get( elem, "value" ) ) !== undefined
  11848. ) {
  11849. return ret;
  11850. }
  11851. ret = elem.value;
  11852. // Handle most common string cases
  11853. if ( typeof ret === "string" ) {
  11854. return ret.replace( rreturn, "" );
  11855. }
  11856. // Handle cases where value is null/undef or number
  11857. return ret == null ? "" : ret;
  11858. }
  11859. return;
  11860. }
  11861. valueIsFunction = isFunction( value );
  11862. return this.each( function( i ) {
  11863. var val;
  11864. if ( this.nodeType !== 1 ) {
  11865. return;
  11866. }
  11867. if ( valueIsFunction ) {
  11868. val = value.call( this, i, jQuery( this ).val() );
  11869. } else {
  11870. val = value;
  11871. }
  11872. // Treat null/undefined as ""; convert numbers to string
  11873. if ( val == null ) {
  11874. val = "";
  11875. } else if ( typeof val === "number" ) {
  11876. val += "";
  11877. } else if ( Array.isArray( val ) ) {
  11878. val = jQuery.map( val, function( value ) {
  11879. return value == null ? "" : value + "";
  11880. } );
  11881. }
  11882. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  11883. // If set returns undefined, fall back to normal setting
  11884. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  11885. this.value = val;
  11886. }
  11887. } );
  11888. }
  11889. } );
  11890. jQuery.extend( {
  11891. valHooks: {
  11892. option: {
  11893. get: function( elem ) {
  11894. var val = jQuery.find.attr( elem, "value" );
  11895. return val != null ?
  11896. val :
  11897. // Support: IE <=10 - 11 only
  11898. // option.text throws exceptions (#14686, #14858)
  11899. // Strip and collapse whitespace
  11900. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  11901. stripAndCollapse( jQuery.text( elem ) );
  11902. }
  11903. },
  11904. select: {
  11905. get: function( elem ) {
  11906. var value, option, i,
  11907. options = elem.options,
  11908. index = elem.selectedIndex,
  11909. one = elem.type === "select-one",
  11910. values = one ? null : [],
  11911. max = one ? index + 1 : options.length;
  11912. if ( index < 0 ) {
  11913. i = max;
  11914. } else {
  11915. i = one ? index : 0;
  11916. }
  11917. // Loop through all the selected options
  11918. for ( ; i < max; i++ ) {
  11919. option = options[ i ];
  11920. // Support: IE <=9 only
  11921. // IE8-9 doesn't update selected after form reset (#2551)
  11922. if ( ( option.selected || i === index ) &&
  11923. // Don't return options that are disabled or in a disabled optgroup
  11924. !option.disabled &&
  11925. ( !option.parentNode.disabled ||
  11926. !nodeName( option.parentNode, "optgroup" ) ) ) {
  11927. // Get the specific value for the option
  11928. value = jQuery( option ).val();
  11929. // We don't need an array for one selects
  11930. if ( one ) {
  11931. return value;
  11932. }
  11933. // Multi-Selects return an array
  11934. values.push( value );
  11935. }
  11936. }
  11937. return values;
  11938. },
  11939. set: function( elem, value ) {
  11940. var optionSet, option,
  11941. options = elem.options,
  11942. values = jQuery.makeArray( value ),
  11943. i = options.length;
  11944. while ( i-- ) {
  11945. option = options[ i ];
  11946. /* eslint-disable no-cond-assign */
  11947. if ( option.selected =
  11948. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  11949. ) {
  11950. optionSet = true;
  11951. }
  11952. /* eslint-enable no-cond-assign */
  11953. }
  11954. // Force browsers to behave consistently when non-matching value is set
  11955. if ( !optionSet ) {
  11956. elem.selectedIndex = -1;
  11957. }
  11958. return values;
  11959. }
  11960. }
  11961. }
  11962. } );
  11963. // Radios and checkboxes getter/setter
  11964. jQuery.each( [ "radio", "checkbox" ], function() {
  11965. jQuery.valHooks[ this ] = {
  11966. set: function( elem, value ) {
  11967. if ( Array.isArray( value ) ) {
  11968. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  11969. }
  11970. }
  11971. };
  11972. if ( !support.checkOn ) {
  11973. jQuery.valHooks[ this ].get = function( elem ) {
  11974. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  11975. };
  11976. }
  11977. } );
  11978. // Return jQuery for attributes-only inclusion
  11979. support.focusin = "onfocusin" in window;
  11980. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  11981. stopPropagationCallback = function( e ) {
  11982. e.stopPropagation();
  11983. };
  11984. jQuery.extend( jQuery.event, {
  11985. trigger: function( event, data, elem, onlyHandlers ) {
  11986. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  11987. eventPath = [ elem || document ],
  11988. type = hasOwn.call( event, "type" ) ? event.type : event,
  11989. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  11990. cur = lastElement = tmp = elem = elem || document;
  11991. // Don't do events on text and comment nodes
  11992. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  11993. return;
  11994. }
  11995. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  11996. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  11997. return;
  11998. }
  11999. if ( type.indexOf( "." ) > -1 ) {
  12000. // Namespaced trigger; create a regexp to match event type in handle()
  12001. namespaces = type.split( "." );
  12002. type = namespaces.shift();
  12003. namespaces.sort();
  12004. }
  12005. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  12006. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  12007. event = event[ jQuery.expando ] ?
  12008. event :
  12009. new jQuery.Event( type, typeof event === "object" && event );
  12010. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  12011. event.isTrigger = onlyHandlers ? 2 : 3;
  12012. event.namespace = namespaces.join( "." );
  12013. event.rnamespace = event.namespace ?
  12014. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  12015. null;
  12016. // Clean up the event in case it is being reused
  12017. event.result = undefined;
  12018. if ( !event.target ) {
  12019. event.target = elem;
  12020. }
  12021. // Clone any incoming data and prepend the event, creating the handler arg list
  12022. data = data == null ?
  12023. [ event ] :
  12024. jQuery.makeArray( data, [ event ] );
  12025. // Allow special events to draw outside the lines
  12026. special = jQuery.event.special[ type ] || {};
  12027. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  12028. return;
  12029. }
  12030. // Determine event propagation path in advance, per W3C events spec (#9951)
  12031. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  12032. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  12033. bubbleType = special.delegateType || type;
  12034. if ( !rfocusMorph.test( bubbleType + type ) ) {
  12035. cur = cur.parentNode;
  12036. }
  12037. for ( ; cur; cur = cur.parentNode ) {
  12038. eventPath.push( cur );
  12039. tmp = cur;
  12040. }
  12041. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  12042. if ( tmp === ( elem.ownerDocument || document ) ) {
  12043. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  12044. }
  12045. }
  12046. // Fire handlers on the event path
  12047. i = 0;
  12048. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  12049. lastElement = cur;
  12050. event.type = i > 1 ?
  12051. bubbleType :
  12052. special.bindType || type;
  12053. // jQuery handler
  12054. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  12055. dataPriv.get( cur, "handle" );
  12056. if ( handle ) {
  12057. handle.apply( cur, data );
  12058. }
  12059. // Native handler
  12060. handle = ontype && cur[ ontype ];
  12061. if ( handle && handle.apply && acceptData( cur ) ) {
  12062. event.result = handle.apply( cur, data );
  12063. if ( event.result === false ) {
  12064. event.preventDefault();
  12065. }
  12066. }
  12067. }
  12068. event.type = type;
  12069. // If nobody prevented the default action, do it now
  12070. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  12071. if ( ( !special._default ||
  12072. special._default.apply( eventPath.pop(), data ) === false ) &&
  12073. acceptData( elem ) ) {
  12074. // Call a native DOM method on the target with the same name as the event.
  12075. // Don't do default actions on window, that's where global variables be (#6170)
  12076. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  12077. // Don't re-trigger an onFOO event when we call its FOO() method
  12078. tmp = elem[ ontype ];
  12079. if ( tmp ) {
  12080. elem[ ontype ] = null;
  12081. }
  12082. // Prevent re-triggering of the same event, since we already bubbled it above
  12083. jQuery.event.triggered = type;
  12084. if ( event.isPropagationStopped() ) {
  12085. lastElement.addEventListener( type, stopPropagationCallback );
  12086. }
  12087. elem[ type ]();
  12088. if ( event.isPropagationStopped() ) {
  12089. lastElement.removeEventListener( type, stopPropagationCallback );
  12090. }
  12091. jQuery.event.triggered = undefined;
  12092. if ( tmp ) {
  12093. elem[ ontype ] = tmp;
  12094. }
  12095. }
  12096. }
  12097. }
  12098. return event.result;
  12099. },
  12100. // Piggyback on a donor event to simulate a different one
  12101. // Used only for `focus(in | out)` events
  12102. simulate: function( type, elem, event ) {
  12103. var e = jQuery.extend(
  12104. new jQuery.Event(),
  12105. event,
  12106. {
  12107. type: type,
  12108. isSimulated: true
  12109. }
  12110. );
  12111. jQuery.event.trigger( e, null, elem );
  12112. }
  12113. } );
  12114. jQuery.fn.extend( {
  12115. trigger: function( type, data ) {
  12116. return this.each( function() {
  12117. jQuery.event.trigger( type, data, this );
  12118. } );
  12119. },
  12120. triggerHandler: function( type, data ) {
  12121. var elem = this[ 0 ];
  12122. if ( elem ) {
  12123. return jQuery.event.trigger( type, data, elem, true );
  12124. }
  12125. }
  12126. } );
  12127. // Support: Firefox <=44
  12128. // Firefox doesn't have focus(in | out) events
  12129. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  12130. //
  12131. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  12132. // focus(in | out) events fire after focus & blur events,
  12133. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  12134. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  12135. if ( !support.focusin ) {
  12136. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  12137. // Attach a single capturing handler on the document while someone wants focusin/focusout
  12138. var handler = function( event ) {
  12139. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  12140. };
  12141. jQuery.event.special[ fix ] = {
  12142. setup: function() {
  12143. var doc = this.ownerDocument || this,
  12144. attaches = dataPriv.access( doc, fix );
  12145. if ( !attaches ) {
  12146. doc.addEventListener( orig, handler, true );
  12147. }
  12148. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  12149. },
  12150. teardown: function() {
  12151. var doc = this.ownerDocument || this,
  12152. attaches = dataPriv.access( doc, fix ) - 1;
  12153. if ( !attaches ) {
  12154. doc.removeEventListener( orig, handler, true );
  12155. dataPriv.remove( doc, fix );
  12156. } else {
  12157. dataPriv.access( doc, fix, attaches );
  12158. }
  12159. }
  12160. };
  12161. } );
  12162. }
  12163. var location = window.location;
  12164. var nonce = Date.now();
  12165. var rquery = ( /\?/ );
  12166. // Cross-browser xml parsing
  12167. jQuery.parseXML = function( data ) {
  12168. var xml;
  12169. if ( !data || typeof data !== "string" ) {
  12170. return null;
  12171. }
  12172. // Support: IE 9 - 11 only
  12173. // IE throws on parseFromString with invalid input.
  12174. try {
  12175. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  12176. } catch ( e ) {
  12177. xml = undefined;
  12178. }
  12179. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  12180. jQuery.error( "Invalid XML: " + data );
  12181. }
  12182. return xml;
  12183. };
  12184. var
  12185. rbracket = /\[\]$/,
  12186. rCRLF = /\r?\n/g,
  12187. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  12188. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  12189. function buildParams( prefix, obj, traditional, add ) {
  12190. var name;
  12191. if ( Array.isArray( obj ) ) {
  12192. // Serialize array item.
  12193. jQuery.each( obj, function( i, v ) {
  12194. if ( traditional || rbracket.test( prefix ) ) {
  12195. // Treat each array item as a scalar.
  12196. add( prefix, v );
  12197. } else {
  12198. // Item is non-scalar (array or object), encode its numeric index.
  12199. buildParams(
  12200. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  12201. v,
  12202. traditional,
  12203. add
  12204. );
  12205. }
  12206. } );
  12207. } else if ( !traditional && toType( obj ) === "object" ) {
  12208. // Serialize object item.
  12209. for ( name in obj ) {
  12210. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  12211. }
  12212. } else {
  12213. // Serialize scalar item.
  12214. add( prefix, obj );
  12215. }
  12216. }
  12217. // Serialize an array of form elements or a set of
  12218. // key/values into a query string
  12219. jQuery.param = function( a, traditional ) {
  12220. var prefix,
  12221. s = [],
  12222. add = function( key, valueOrFunction ) {
  12223. // If value is a function, invoke it and use its return value
  12224. var value = isFunction( valueOrFunction ) ?
  12225. valueOrFunction() :
  12226. valueOrFunction;
  12227. s[ s.length ] = encodeURIComponent( key ) + "=" +
  12228. encodeURIComponent( value == null ? "" : value );
  12229. };
  12230. if ( a == null ) {
  12231. return "";
  12232. }
  12233. // If an array was passed in, assume that it is an array of form elements.
  12234. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  12235. // Serialize the form elements
  12236. jQuery.each( a, function() {
  12237. add( this.name, this.value );
  12238. } );
  12239. } else {
  12240. // If traditional, encode the "old" way (the way 1.3.2 or older
  12241. // did it), otherwise encode params recursively.
  12242. for ( prefix in a ) {
  12243. buildParams( prefix, a[ prefix ], traditional, add );
  12244. }
  12245. }
  12246. // Return the resulting serialization
  12247. return s.join( "&" );
  12248. };
  12249. jQuery.fn.extend( {
  12250. serialize: function() {
  12251. return jQuery.param( this.serializeArray() );
  12252. },
  12253. serializeArray: function() {
  12254. return this.map( function() {
  12255. // Can add propHook for "elements" to filter or add form elements
  12256. var elements = jQuery.prop( this, "elements" );
  12257. return elements ? jQuery.makeArray( elements ) : this;
  12258. } )
  12259. .filter( function() {
  12260. var type = this.type;
  12261. // Use .is( ":disabled" ) so that fieldset[disabled] works
  12262. return this.name && !jQuery( this ).is( ":disabled" ) &&
  12263. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  12264. ( this.checked || !rcheckableType.test( type ) );
  12265. } )
  12266. .map( function( i, elem ) {
  12267. var val = jQuery( this ).val();
  12268. if ( val == null ) {
  12269. return null;
  12270. }
  12271. if ( Array.isArray( val ) ) {
  12272. return jQuery.map( val, function( val ) {
  12273. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  12274. } );
  12275. }
  12276. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  12277. } ).get();
  12278. }
  12279. } );
  12280. var
  12281. r20 = /%20/g,
  12282. rhash = /#.*$/,
  12283. rantiCache = /([?&])_=[^&]*/,
  12284. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  12285. // #7653, #8125, #8152: local protocol detection
  12286. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  12287. rnoContent = /^(?:GET|HEAD)$/,
  12288. rprotocol = /^\/\//,
  12289. /* Prefilters
  12290. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  12291. * 2) These are called:
  12292. * - BEFORE asking for a transport
  12293. * - AFTER param serialization (s.data is a string if s.processData is true)
  12294. * 3) key is the dataType
  12295. * 4) the catchall symbol "*" can be used
  12296. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  12297. */
  12298. prefilters = {},
  12299. /* Transports bindings
  12300. * 1) key is the dataType
  12301. * 2) the catchall symbol "*" can be used
  12302. * 3) selection will start with transport dataType and THEN go to "*" if needed
  12303. */
  12304. transports = {},
  12305. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  12306. allTypes = "*/".concat( "*" ),
  12307. // Anchor tag for parsing the document origin
  12308. originAnchor = document.createElement( "a" );
  12309. originAnchor.href = location.href;
  12310. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  12311. function addToPrefiltersOrTransports( structure ) {
  12312. // dataTypeExpression is optional and defaults to "*"
  12313. return function( dataTypeExpression, func ) {
  12314. if ( typeof dataTypeExpression !== "string" ) {
  12315. func = dataTypeExpression;
  12316. dataTypeExpression = "*";
  12317. }
  12318. var dataType,
  12319. i = 0,
  12320. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  12321. if ( isFunction( func ) ) {
  12322. // For each dataType in the dataTypeExpression
  12323. while ( ( dataType = dataTypes[ i++ ] ) ) {
  12324. // Prepend if requested
  12325. if ( dataType[ 0 ] === "+" ) {
  12326. dataType = dataType.slice( 1 ) || "*";
  12327. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  12328. // Otherwise append
  12329. } else {
  12330. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  12331. }
  12332. }
  12333. }
  12334. };
  12335. }
  12336. // Base inspection function for prefilters and transports
  12337. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  12338. var inspected = {},
  12339. seekingTransport = ( structure === transports );
  12340. function inspect( dataType ) {
  12341. var selected;
  12342. inspected[ dataType ] = true;
  12343. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  12344. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  12345. if ( typeof dataTypeOrTransport === "string" &&
  12346. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  12347. options.dataTypes.unshift( dataTypeOrTransport );
  12348. inspect( dataTypeOrTransport );
  12349. return false;
  12350. } else if ( seekingTransport ) {
  12351. return !( selected = dataTypeOrTransport );
  12352. }
  12353. } );
  12354. return selected;
  12355. }
  12356. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  12357. }
  12358. // A special extend for ajax options
  12359. // that takes "flat" options (not to be deep extended)
  12360. // Fixes #9887
  12361. function ajaxExtend( target, src ) {
  12362. var key, deep,
  12363. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  12364. for ( key in src ) {
  12365. if ( src[ key ] !== undefined ) {
  12366. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  12367. }
  12368. }
  12369. if ( deep ) {
  12370. jQuery.extend( true, target, deep );
  12371. }
  12372. return target;
  12373. }
  12374. /* Handles responses to an ajax request:
  12375. * - finds the right dataType (mediates between content-type and expected dataType)
  12376. * - returns the corresponding response
  12377. */
  12378. function ajaxHandleResponses( s, jqXHR, responses ) {
  12379. var ct, type, finalDataType, firstDataType,
  12380. contents = s.contents,
  12381. dataTypes = s.dataTypes;
  12382. // Remove auto dataType and get content-type in the process
  12383. while ( dataTypes[ 0 ] === "*" ) {
  12384. dataTypes.shift();
  12385. if ( ct === undefined ) {
  12386. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  12387. }
  12388. }
  12389. // Check if we're dealing with a known content-type
  12390. if ( ct ) {
  12391. for ( type in contents ) {
  12392. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  12393. dataTypes.unshift( type );
  12394. break;
  12395. }
  12396. }
  12397. }
  12398. // Check to see if we have a response for the expected dataType
  12399. if ( dataTypes[ 0 ] in responses ) {
  12400. finalDataType = dataTypes[ 0 ];
  12401. } else {
  12402. // Try convertible dataTypes
  12403. for ( type in responses ) {
  12404. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  12405. finalDataType = type;
  12406. break;
  12407. }
  12408. if ( !firstDataType ) {
  12409. firstDataType = type;
  12410. }
  12411. }
  12412. // Or just use first one
  12413. finalDataType = finalDataType || firstDataType;
  12414. }
  12415. // If we found a dataType
  12416. // We add the dataType to the list if needed
  12417. // and return the corresponding response
  12418. if ( finalDataType ) {
  12419. if ( finalDataType !== dataTypes[ 0 ] ) {
  12420. dataTypes.unshift( finalDataType );
  12421. }
  12422. return responses[ finalDataType ];
  12423. }
  12424. }
  12425. /* Chain conversions given the request and the original response
  12426. * Also sets the responseXXX fields on the jqXHR instance
  12427. */
  12428. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  12429. var conv2, current, conv, tmp, prev,
  12430. converters = {},
  12431. // Work with a copy of dataTypes in case we need to modify it for conversion
  12432. dataTypes = s.dataTypes.slice();
  12433. // Create converters map with lowercased keys
  12434. if ( dataTypes[ 1 ] ) {
  12435. for ( conv in s.converters ) {
  12436. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  12437. }
  12438. }
  12439. current = dataTypes.shift();
  12440. // Convert to each sequential dataType
  12441. while ( current ) {
  12442. if ( s.responseFields[ current ] ) {
  12443. jqXHR[ s.responseFields[ current ] ] = response;
  12444. }
  12445. // Apply the dataFilter if provided
  12446. if ( !prev && isSuccess && s.dataFilter ) {
  12447. response = s.dataFilter( response, s.dataType );
  12448. }
  12449. prev = current;
  12450. current = dataTypes.shift();
  12451. if ( current ) {
  12452. // There's only work to do if current dataType is non-auto
  12453. if ( current === "*" ) {
  12454. current = prev;
  12455. // Convert response if prev dataType is non-auto and differs from current
  12456. } else if ( prev !== "*" && prev !== current ) {
  12457. // Seek a direct converter
  12458. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  12459. // If none found, seek a pair
  12460. if ( !conv ) {
  12461. for ( conv2 in converters ) {
  12462. // If conv2 outputs current
  12463. tmp = conv2.split( " " );
  12464. if ( tmp[ 1 ] === current ) {
  12465. // If prev can be converted to accepted input
  12466. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  12467. converters[ "* " + tmp[ 0 ] ];
  12468. if ( conv ) {
  12469. // Condense equivalence converters
  12470. if ( conv === true ) {
  12471. conv = converters[ conv2 ];
  12472. // Otherwise, insert the intermediate dataType
  12473. } else if ( converters[ conv2 ] !== true ) {
  12474. current = tmp[ 0 ];
  12475. dataTypes.unshift( tmp[ 1 ] );
  12476. }
  12477. break;
  12478. }
  12479. }
  12480. }
  12481. }
  12482. // Apply converter (if not an equivalence)
  12483. if ( conv !== true ) {
  12484. // Unless errors are allowed to bubble, catch and return them
  12485. if ( conv && s.throws ) {
  12486. response = conv( response );
  12487. } else {
  12488. try {
  12489. response = conv( response );
  12490. } catch ( e ) {
  12491. return {
  12492. state: "parsererror",
  12493. error: conv ? e : "No conversion from " + prev + " to " + current
  12494. };
  12495. }
  12496. }
  12497. }
  12498. }
  12499. }
  12500. }
  12501. return { state: "success", data: response };
  12502. }
  12503. jQuery.extend( {
  12504. // Counter for holding the number of active queries
  12505. active: 0,
  12506. // Last-Modified header cache for next request
  12507. lastModified: {},
  12508. etag: {},
  12509. ajaxSettings: {
  12510. url: location.href,
  12511. type: "GET",
  12512. isLocal: rlocalProtocol.test( location.protocol ),
  12513. global: true,
  12514. processData: true,
  12515. async: true,
  12516. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  12517. /*
  12518. timeout: 0,
  12519. data: null,
  12520. dataType: null,
  12521. username: null,
  12522. password: null,
  12523. cache: null,
  12524. throws: false,
  12525. traditional: false,
  12526. headers: {},
  12527. */
  12528. accepts: {
  12529. "*": allTypes,
  12530. text: "text/plain",
  12531. html: "text/html",
  12532. xml: "application/xml, text/xml",
  12533. json: "application/json, text/javascript"
  12534. },
  12535. contents: {
  12536. xml: /\bxml\b/,
  12537. html: /\bhtml/,
  12538. json: /\bjson\b/
  12539. },
  12540. responseFields: {
  12541. xml: "responseXML",
  12542. text: "responseText",
  12543. json: "responseJSON"
  12544. },
  12545. // Data converters
  12546. // Keys separate source (or catchall "*") and destination types with a single space
  12547. converters: {
  12548. // Convert anything to text
  12549. "* text": String,
  12550. // Text to html (true = no transformation)
  12551. "text html": true,
  12552. // Evaluate text as a json expression
  12553. "text json": JSON.parse,
  12554. // Parse text as xml
  12555. "text xml": jQuery.parseXML
  12556. },
  12557. // For options that shouldn't be deep extended:
  12558. // you can add your own custom options here if
  12559. // and when you create one that shouldn't be
  12560. // deep extended (see ajaxExtend)
  12561. flatOptions: {
  12562. url: true,
  12563. context: true
  12564. }
  12565. },
  12566. // Creates a full fledged settings object into target
  12567. // with both ajaxSettings and settings fields.
  12568. // If target is omitted, writes into ajaxSettings.
  12569. ajaxSetup: function( target, settings ) {
  12570. return settings ?
  12571. // Building a settings object
  12572. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  12573. // Extending ajaxSettings
  12574. ajaxExtend( jQuery.ajaxSettings, target );
  12575. },
  12576. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  12577. ajaxTransport: addToPrefiltersOrTransports( transports ),
  12578. // Main method
  12579. ajax: function( url, options ) {
  12580. // If url is an object, simulate pre-1.5 signature
  12581. if ( typeof url === "object" ) {
  12582. options = url;
  12583. url = undefined;
  12584. }
  12585. // Force options to be an object
  12586. options = options || {};
  12587. var transport,
  12588. // URL without anti-cache param
  12589. cacheURL,
  12590. // Response headers
  12591. responseHeadersString,
  12592. responseHeaders,
  12593. // timeout handle
  12594. timeoutTimer,
  12595. // Url cleanup var
  12596. urlAnchor,
  12597. // Request state (becomes false upon send and true upon completion)
  12598. completed,
  12599. // To know if global events are to be dispatched
  12600. fireGlobals,
  12601. // Loop variable
  12602. i,
  12603. // uncached part of the url
  12604. uncached,
  12605. // Create the final options object
  12606. s = jQuery.ajaxSetup( {}, options ),
  12607. // Callbacks context
  12608. callbackContext = s.context || s,
  12609. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  12610. globalEventContext = s.context &&
  12611. ( callbackContext.nodeType || callbackContext.jquery ) ?
  12612. jQuery( callbackContext ) :
  12613. jQuery.event,
  12614. // Deferreds
  12615. deferred = jQuery.Deferred(),
  12616. completeDeferred = jQuery.Callbacks( "once memory" ),
  12617. // Status-dependent callbacks
  12618. statusCode = s.statusCode || {},
  12619. // Headers (they are sent all at once)
  12620. requestHeaders = {},
  12621. requestHeadersNames = {},
  12622. // Default abort message
  12623. strAbort = "canceled",
  12624. // Fake xhr
  12625. jqXHR = {
  12626. readyState: 0,
  12627. // Builds headers hashtable if needed
  12628. getResponseHeader: function( key ) {
  12629. var match;
  12630. if ( completed ) {
  12631. if ( !responseHeaders ) {
  12632. responseHeaders = {};
  12633. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  12634. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  12635. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  12636. .concat( match[ 2 ] );
  12637. }
  12638. }
  12639. match = responseHeaders[ key.toLowerCase() + " " ];
  12640. }
  12641. return match == null ? null : match.join( ", " );
  12642. },
  12643. // Raw string
  12644. getAllResponseHeaders: function() {
  12645. return completed ? responseHeadersString : null;
  12646. },
  12647. // Caches the header
  12648. setRequestHeader: function( name, value ) {
  12649. if ( completed == null ) {
  12650. name = requestHeadersNames[ name.toLowerCase() ] =
  12651. requestHeadersNames[ name.toLowerCase() ] || name;
  12652. requestHeaders[ name ] = value;
  12653. }
  12654. return this;
  12655. },
  12656. // Overrides response content-type header
  12657. overrideMimeType: function( type ) {
  12658. if ( completed == null ) {
  12659. s.mimeType = type;
  12660. }
  12661. return this;
  12662. },
  12663. // Status-dependent callbacks
  12664. statusCode: function( map ) {
  12665. var code;
  12666. if ( map ) {
  12667. if ( completed ) {
  12668. // Execute the appropriate callbacks
  12669. jqXHR.always( map[ jqXHR.status ] );
  12670. } else {
  12671. // Lazy-add the new callbacks in a way that preserves old ones
  12672. for ( code in map ) {
  12673. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  12674. }
  12675. }
  12676. }
  12677. return this;
  12678. },
  12679. // Cancel the request
  12680. abort: function( statusText ) {
  12681. var finalText = statusText || strAbort;
  12682. if ( transport ) {
  12683. transport.abort( finalText );
  12684. }
  12685. done( 0, finalText );
  12686. return this;
  12687. }
  12688. };
  12689. // Attach deferreds
  12690. deferred.promise( jqXHR );
  12691. // Add protocol if not provided (prefilters might expect it)
  12692. // Handle falsy url in the settings object (#10093: consistency with old signature)
  12693. // We also use the url parameter if available
  12694. s.url = ( ( url || s.url || location.href ) + "" )
  12695. .replace( rprotocol, location.protocol + "//" );
  12696. // Alias method option to type as per ticket #12004
  12697. s.type = options.method || options.type || s.method || s.type;
  12698. // Extract dataTypes list
  12699. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  12700. // A cross-domain request is in order when the origin doesn't match the current origin.
  12701. if ( s.crossDomain == null ) {
  12702. urlAnchor = document.createElement( "a" );
  12703. // Support: IE <=8 - 11, Edge 12 - 15
  12704. // IE throws exception on accessing the href property if url is malformed,
  12705. // e.g. http://example.com:80x/
  12706. try {
  12707. urlAnchor.href = s.url;
  12708. // Support: IE <=8 - 11 only
  12709. // Anchor's host property isn't correctly set when s.url is relative
  12710. urlAnchor.href = urlAnchor.href;
  12711. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  12712. urlAnchor.protocol + "//" + urlAnchor.host;
  12713. } catch ( e ) {
  12714. // If there is an error parsing the URL, assume it is crossDomain,
  12715. // it can be rejected by the transport if it is invalid
  12716. s.crossDomain = true;
  12717. }
  12718. }
  12719. // Convert data if not already a string
  12720. if ( s.data && s.processData && typeof s.data !== "string" ) {
  12721. s.data = jQuery.param( s.data, s.traditional );
  12722. }
  12723. // Apply prefilters
  12724. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  12725. // If request was aborted inside a prefilter, stop there
  12726. if ( completed ) {
  12727. return jqXHR;
  12728. }
  12729. // We can fire global events as of now if asked to
  12730. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  12731. fireGlobals = jQuery.event && s.global;
  12732. // Watch for a new set of requests
  12733. if ( fireGlobals && jQuery.active++ === 0 ) {
  12734. jQuery.event.trigger( "ajaxStart" );
  12735. }
  12736. // Uppercase the type
  12737. s.type = s.type.toUpperCase();
  12738. // Determine if request has content
  12739. s.hasContent = !rnoContent.test( s.type );
  12740. // Save the URL in case we're toying with the If-Modified-Since
  12741. // and/or If-None-Match header later on
  12742. // Remove hash to simplify url manipulation
  12743. cacheURL = s.url.replace( rhash, "" );
  12744. // More options handling for requests with no content
  12745. if ( !s.hasContent ) {
  12746. // Remember the hash so we can put it back
  12747. uncached = s.url.slice( cacheURL.length );
  12748. // If data is available and should be processed, append data to url
  12749. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  12750. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  12751. // #9682: remove data so that it's not used in an eventual retry
  12752. delete s.data;
  12753. }
  12754. // Add or update anti-cache param if needed
  12755. if ( s.cache === false ) {
  12756. cacheURL = cacheURL.replace( rantiCache, "$1" );
  12757. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  12758. }
  12759. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  12760. s.url = cacheURL + uncached;
  12761. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  12762. } else if ( s.data && s.processData &&
  12763. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  12764. s.data = s.data.replace( r20, "+" );
  12765. }
  12766. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  12767. if ( s.ifModified ) {
  12768. if ( jQuery.lastModified[ cacheURL ] ) {
  12769. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  12770. }
  12771. if ( jQuery.etag[ cacheURL ] ) {
  12772. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  12773. }
  12774. }
  12775. // Set the correct header, if data is being sent
  12776. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  12777. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  12778. }
  12779. // Set the Accepts header for the server, depending on the dataType
  12780. jqXHR.setRequestHeader(
  12781. "Accept",
  12782. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  12783. s.accepts[ s.dataTypes[ 0 ] ] +
  12784. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  12785. s.accepts[ "*" ]
  12786. );
  12787. // Check for headers option
  12788. for ( i in s.headers ) {
  12789. jqXHR.setRequestHeader( i, s.headers[ i ] );
  12790. }
  12791. // Allow custom headers/mimetypes and early abort
  12792. if ( s.beforeSend &&
  12793. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  12794. // Abort if not done already and return
  12795. return jqXHR.abort();
  12796. }
  12797. // Aborting is no longer a cancellation
  12798. strAbort = "abort";
  12799. // Install callbacks on deferreds
  12800. completeDeferred.add( s.complete );
  12801. jqXHR.done( s.success );
  12802. jqXHR.fail( s.error );
  12803. // Get transport
  12804. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  12805. // If no transport, we auto-abort
  12806. if ( !transport ) {
  12807. done( -1, "No Transport" );
  12808. } else {
  12809. jqXHR.readyState = 1;
  12810. // Send global event
  12811. if ( fireGlobals ) {
  12812. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  12813. }
  12814. // If request was aborted inside ajaxSend, stop there
  12815. if ( completed ) {
  12816. return jqXHR;
  12817. }
  12818. // Timeout
  12819. if ( s.async && s.timeout > 0 ) {
  12820. timeoutTimer = window.setTimeout( function() {
  12821. jqXHR.abort( "timeout" );
  12822. }, s.timeout );
  12823. }
  12824. try {
  12825. completed = false;
  12826. transport.send( requestHeaders, done );
  12827. } catch ( e ) {
  12828. // Rethrow post-completion exceptions
  12829. if ( completed ) {
  12830. throw e;
  12831. }
  12832. // Propagate others as results
  12833. done( -1, e );
  12834. }
  12835. }
  12836. // Callback for when everything is done
  12837. function done( status, nativeStatusText, responses, headers ) {
  12838. var isSuccess, success, error, response, modified,
  12839. statusText = nativeStatusText;
  12840. // Ignore repeat invocations
  12841. if ( completed ) {
  12842. return;
  12843. }
  12844. completed = true;
  12845. // Clear timeout if it exists
  12846. if ( timeoutTimer ) {
  12847. window.clearTimeout( timeoutTimer );
  12848. }
  12849. // Dereference transport for early garbage collection
  12850. // (no matter how long the jqXHR object will be used)
  12851. transport = undefined;
  12852. // Cache response headers
  12853. responseHeadersString = headers || "";
  12854. // Set readyState
  12855. jqXHR.readyState = status > 0 ? 4 : 0;
  12856. // Determine if successful
  12857. isSuccess = status >= 200 && status < 300 || status === 304;
  12858. // Get response data
  12859. if ( responses ) {
  12860. response = ajaxHandleResponses( s, jqXHR, responses );
  12861. }
  12862. // Convert no matter what (that way responseXXX fields are always set)
  12863. response = ajaxConvert( s, response, jqXHR, isSuccess );
  12864. // If successful, handle type chaining
  12865. if ( isSuccess ) {
  12866. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  12867. if ( s.ifModified ) {
  12868. modified = jqXHR.getResponseHeader( "Last-Modified" );
  12869. if ( modified ) {
  12870. jQuery.lastModified[ cacheURL ] = modified;
  12871. }
  12872. modified = jqXHR.getResponseHeader( "etag" );
  12873. if ( modified ) {
  12874. jQuery.etag[ cacheURL ] = modified;
  12875. }
  12876. }
  12877. // if no content
  12878. if ( status === 204 || s.type === "HEAD" ) {
  12879. statusText = "nocontent";
  12880. // if not modified
  12881. } else if ( status === 304 ) {
  12882. statusText = "notmodified";
  12883. // If we have data, let's convert it
  12884. } else {
  12885. statusText = response.state;
  12886. success = response.data;
  12887. error = response.error;
  12888. isSuccess = !error;
  12889. }
  12890. } else {
  12891. // Extract error from statusText and normalize for non-aborts
  12892. error = statusText;
  12893. if ( status || !statusText ) {
  12894. statusText = "error";
  12895. if ( status < 0 ) {
  12896. status = 0;
  12897. }
  12898. }
  12899. }
  12900. // Set data for the fake xhr object
  12901. jqXHR.status = status;
  12902. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  12903. // Success/Error
  12904. if ( isSuccess ) {
  12905. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  12906. } else {
  12907. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  12908. }
  12909. // Status-dependent callbacks
  12910. jqXHR.statusCode( statusCode );
  12911. statusCode = undefined;
  12912. if ( fireGlobals ) {
  12913. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  12914. [ jqXHR, s, isSuccess ? success : error ] );
  12915. }
  12916. // Complete
  12917. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  12918. if ( fireGlobals ) {
  12919. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  12920. // Handle the global AJAX counter
  12921. if ( !( --jQuery.active ) ) {
  12922. jQuery.event.trigger( "ajaxStop" );
  12923. }
  12924. }
  12925. }
  12926. return jqXHR;
  12927. },
  12928. getJSON: function( url, data, callback ) {
  12929. return jQuery.get( url, data, callback, "json" );
  12930. },
  12931. getScript: function( url, callback ) {
  12932. return jQuery.get( url, undefined, callback, "script" );
  12933. }
  12934. } );
  12935. jQuery.each( [ "get", "post" ], function( i, method ) {
  12936. jQuery[ method ] = function( url, data, callback, type ) {
  12937. // Shift arguments if data argument was omitted
  12938. if ( isFunction( data ) ) {
  12939. type = type || callback;
  12940. callback = data;
  12941. data = undefined;
  12942. }
  12943. // The url can be an options object (which then must have .url)
  12944. return jQuery.ajax( jQuery.extend( {
  12945. url: url,
  12946. type: method,
  12947. dataType: type,
  12948. data: data,
  12949. success: callback
  12950. }, jQuery.isPlainObject( url ) && url ) );
  12951. };
  12952. } );
  12953. jQuery._evalUrl = function( url, options ) {
  12954. return jQuery.ajax( {
  12955. url: url,
  12956. // Make this explicit, since user can override this through ajaxSetup (#11264)
  12957. type: "GET",
  12958. dataType: "script",
  12959. cache: true,
  12960. async: false,
  12961. global: false,
  12962. // Only evaluate the response if it is successful (gh-4126)
  12963. // dataFilter is not invoked for failure responses, so using it instead
  12964. // of the default converter is kludgy but it works.
  12965. converters: {
  12966. "text script": function() {}
  12967. },
  12968. dataFilter: function( response ) {
  12969. jQuery.globalEval( response, options );
  12970. }
  12971. } );
  12972. };
  12973. jQuery.fn.extend( {
  12974. wrapAll: function( html ) {
  12975. var wrap;
  12976. if ( this[ 0 ] ) {
  12977. if ( isFunction( html ) ) {
  12978. html = html.call( this[ 0 ] );
  12979. }
  12980. // The elements to wrap the target around
  12981. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  12982. if ( this[ 0 ].parentNode ) {
  12983. wrap.insertBefore( this[ 0 ] );
  12984. }
  12985. wrap.map( function() {
  12986. var elem = this;
  12987. while ( elem.firstElementChild ) {
  12988. elem = elem.firstElementChild;
  12989. }
  12990. return elem;
  12991. } ).append( this );
  12992. }
  12993. return this;
  12994. },
  12995. wrapInner: function( html ) {
  12996. if ( isFunction( html ) ) {
  12997. return this.each( function( i ) {
  12998. jQuery( this ).wrapInner( html.call( this, i ) );
  12999. } );
  13000. }
  13001. return this.each( function() {
  13002. var self = jQuery( this ),
  13003. contents = self.contents();
  13004. if ( contents.length ) {
  13005. contents.wrapAll( html );
  13006. } else {
  13007. self.append( html );
  13008. }
  13009. } );
  13010. },
  13011. wrap: function( html ) {
  13012. var htmlIsFunction = isFunction( html );
  13013. return this.each( function( i ) {
  13014. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  13015. } );
  13016. },
  13017. unwrap: function( selector ) {
  13018. this.parent( selector ).not( "body" ).each( function() {
  13019. jQuery( this ).replaceWith( this.childNodes );
  13020. } );
  13021. return this;
  13022. }
  13023. } );
  13024. jQuery.expr.pseudos.hidden = function( elem ) {
  13025. return !jQuery.expr.pseudos.visible( elem );
  13026. };
  13027. jQuery.expr.pseudos.visible = function( elem ) {
  13028. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  13029. };
  13030. jQuery.ajaxSettings.xhr = function() {
  13031. try {
  13032. return new window.XMLHttpRequest();
  13033. } catch ( e ) {}
  13034. };
  13035. var xhrSuccessStatus = {
  13036. // File protocol always yields status code 0, assume 200
  13037. 0: 200,
  13038. // Support: IE <=9 only
  13039. // #1450: sometimes IE returns 1223 when it should be 204
  13040. 1223: 204
  13041. },
  13042. xhrSupported = jQuery.ajaxSettings.xhr();
  13043. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  13044. support.ajax = xhrSupported = !!xhrSupported;
  13045. jQuery.ajaxTransport( function( options ) {
  13046. var callback, errorCallback;
  13047. // Cross domain only allowed if supported through XMLHttpRequest
  13048. if ( support.cors || xhrSupported && !options.crossDomain ) {
  13049. return {
  13050. send: function( headers, complete ) {
  13051. var i,
  13052. xhr = options.xhr();
  13053. xhr.open(
  13054. options.type,
  13055. options.url,
  13056. options.async,
  13057. options.username,
  13058. options.password
  13059. );
  13060. // Apply custom fields if provided
  13061. if ( options.xhrFields ) {
  13062. for ( i in options.xhrFields ) {
  13063. xhr[ i ] = options.xhrFields[ i ];
  13064. }
  13065. }
  13066. // Override mime type if needed
  13067. if ( options.mimeType && xhr.overrideMimeType ) {
  13068. xhr.overrideMimeType( options.mimeType );
  13069. }
  13070. // X-Requested-With header
  13071. // For cross-domain requests, seeing as conditions for a preflight are
  13072. // akin to a jigsaw puzzle, we simply never set it to be sure.
  13073. // (it can always be set on a per-request basis or even using ajaxSetup)
  13074. // For same-domain requests, won't change header if already provided.
  13075. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  13076. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  13077. }
  13078. // Set headers
  13079. for ( i in headers ) {
  13080. xhr.setRequestHeader( i, headers[ i ] );
  13081. }
  13082. // Callback
  13083. callback = function( type ) {
  13084. return function() {
  13085. if ( callback ) {
  13086. callback = errorCallback = xhr.onload =
  13087. xhr.onerror = xhr.onabort = xhr.ontimeout =
  13088. xhr.onreadystatechange = null;
  13089. if ( type === "abort" ) {
  13090. xhr.abort();
  13091. } else if ( type === "error" ) {
  13092. // Support: IE <=9 only
  13093. // On a manual native abort, IE9 throws
  13094. // errors on any property access that is not readyState
  13095. if ( typeof xhr.status !== "number" ) {
  13096. complete( 0, "error" );
  13097. } else {
  13098. complete(
  13099. // File: protocol always yields status 0; see #8605, #14207
  13100. xhr.status,
  13101. xhr.statusText
  13102. );
  13103. }
  13104. } else {
  13105. complete(
  13106. xhrSuccessStatus[ xhr.status ] || xhr.status,
  13107. xhr.statusText,
  13108. // Support: IE <=9 only
  13109. // IE9 has no XHR2 but throws on binary (trac-11426)
  13110. // For XHR2 non-text, let the caller handle it (gh-2498)
  13111. ( xhr.responseType || "text" ) !== "text" ||
  13112. typeof xhr.responseText !== "string" ?
  13113. { binary: xhr.response } :
  13114. { text: xhr.responseText },
  13115. xhr.getAllResponseHeaders()
  13116. );
  13117. }
  13118. }
  13119. };
  13120. };
  13121. // Listen to events
  13122. xhr.onload = callback();
  13123. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  13124. // Support: IE 9 only
  13125. // Use onreadystatechange to replace onabort
  13126. // to handle uncaught aborts
  13127. if ( xhr.onabort !== undefined ) {
  13128. xhr.onabort = errorCallback;
  13129. } else {
  13130. xhr.onreadystatechange = function() {
  13131. // Check readyState before timeout as it changes
  13132. if ( xhr.readyState === 4 ) {
  13133. // Allow onerror to be called first,
  13134. // but that will not handle a native abort
  13135. // Also, save errorCallback to a variable
  13136. // as xhr.onerror cannot be accessed
  13137. window.setTimeout( function() {
  13138. if ( callback ) {
  13139. errorCallback();
  13140. }
  13141. } );
  13142. }
  13143. };
  13144. }
  13145. // Create the abort callback
  13146. callback = callback( "abort" );
  13147. try {
  13148. // Do send the request (this may raise an exception)
  13149. xhr.send( options.hasContent && options.data || null );
  13150. } catch ( e ) {
  13151. // #14683: Only rethrow if this hasn't been notified as an error yet
  13152. if ( callback ) {
  13153. throw e;
  13154. }
  13155. }
  13156. },
  13157. abort: function() {
  13158. if ( callback ) {
  13159. callback();
  13160. }
  13161. }
  13162. };
  13163. }
  13164. } );
  13165. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  13166. jQuery.ajaxPrefilter( function( s ) {
  13167. if ( s.crossDomain ) {
  13168. s.contents.script = false;
  13169. }
  13170. } );
  13171. // Install script dataType
  13172. jQuery.ajaxSetup( {
  13173. accepts: {
  13174. script: "text/javascript, application/javascript, " +
  13175. "application/ecmascript, application/x-ecmascript"
  13176. },
  13177. contents: {
  13178. script: /\b(?:java|ecma)script\b/
  13179. },
  13180. converters: {
  13181. "text script": function( text ) {
  13182. jQuery.globalEval( text );
  13183. return text;
  13184. }
  13185. }
  13186. } );
  13187. // Handle cache's special case and crossDomain
  13188. jQuery.ajaxPrefilter( "script", function( s ) {
  13189. if ( s.cache === undefined ) {
  13190. s.cache = false;
  13191. }
  13192. if ( s.crossDomain ) {
  13193. s.type = "GET";
  13194. }
  13195. } );
  13196. // Bind script tag hack transport
  13197. jQuery.ajaxTransport( "script", function( s ) {
  13198. // This transport only deals with cross domain or forced-by-attrs requests
  13199. if ( s.crossDomain || s.scriptAttrs ) {
  13200. var script, callback;
  13201. return {
  13202. send: function( _, complete ) {
  13203. script = jQuery( "<script>" )
  13204. .attr( s.scriptAttrs || {} )
  13205. .prop( { charset: s.scriptCharset, src: s.url } )
  13206. .on( "load error", callback = function( evt ) {
  13207. script.remove();
  13208. callback = null;
  13209. if ( evt ) {
  13210. complete( evt.type === "error" ? 404 : 200, evt.type );
  13211. }
  13212. } );
  13213. // Use native DOM manipulation to avoid our domManip AJAX trickery
  13214. document.head.appendChild( script[ 0 ] );
  13215. },
  13216. abort: function() {
  13217. if ( callback ) {
  13218. callback();
  13219. }
  13220. }
  13221. };
  13222. }
  13223. } );
  13224. var oldCallbacks = [],
  13225. rjsonp = /(=)\?(?=&|$)|\?\?/;
  13226. // Default jsonp settings
  13227. jQuery.ajaxSetup( {
  13228. jsonp: "callback",
  13229. jsonpCallback: function() {
  13230. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  13231. this[ callback ] = true;
  13232. return callback;
  13233. }
  13234. } );
  13235. // Detect, normalize options and install callbacks for jsonp requests
  13236. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  13237. var callbackName, overwritten, responseContainer,
  13238. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  13239. "url" :
  13240. typeof s.data === "string" &&
  13241. ( s.contentType || "" )
  13242. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  13243. rjsonp.test( s.data ) && "data"
  13244. );
  13245. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  13246. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  13247. // Get callback name, remembering preexisting value associated with it
  13248. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  13249. s.jsonpCallback() :
  13250. s.jsonpCallback;
  13251. // Insert callback into url or form data
  13252. if ( jsonProp ) {
  13253. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  13254. } else if ( s.jsonp !== false ) {
  13255. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  13256. }
  13257. // Use data converter to retrieve json after script execution
  13258. s.converters[ "script json" ] = function() {
  13259. if ( !responseContainer ) {
  13260. jQuery.error( callbackName + " was not called" );
  13261. }
  13262. return responseContainer[ 0 ];
  13263. };
  13264. // Force json dataType
  13265. s.dataTypes[ 0 ] = "json";
  13266. // Install callback
  13267. overwritten = window[ callbackName ];
  13268. window[ callbackName ] = function() {
  13269. responseContainer = arguments;
  13270. };
  13271. // Clean-up function (fires after converters)
  13272. jqXHR.always( function() {
  13273. // If previous value didn't exist - remove it
  13274. if ( overwritten === undefined ) {
  13275. jQuery( window ).removeProp( callbackName );
  13276. // Otherwise restore preexisting value
  13277. } else {
  13278. window[ callbackName ] = overwritten;
  13279. }
  13280. // Save back as free
  13281. if ( s[ callbackName ] ) {
  13282. // Make sure that re-using the options doesn't screw things around
  13283. s.jsonpCallback = originalSettings.jsonpCallback;
  13284. // Save the callback name for future use
  13285. oldCallbacks.push( callbackName );
  13286. }
  13287. // Call if it was a function and we have a response
  13288. if ( responseContainer && isFunction( overwritten ) ) {
  13289. overwritten( responseContainer[ 0 ] );
  13290. }
  13291. responseContainer = overwritten = undefined;
  13292. } );
  13293. // Delegate to script
  13294. return "script";
  13295. }
  13296. } );
  13297. // Support: Safari 8 only
  13298. // In Safari 8 documents created via document.implementation.createHTMLDocument
  13299. // collapse sibling forms: the second one becomes a child of the first one.
  13300. // Because of that, this security measure has to be disabled in Safari 8.
  13301. // https://bugs.webkit.org/show_bug.cgi?id=137337
  13302. support.createHTMLDocument = ( function() {
  13303. var body = document.implementation.createHTMLDocument( "" ).body;
  13304. body.innerHTML = "<form></form><form></form>";
  13305. return body.childNodes.length === 2;
  13306. } )();
  13307. // Argument "data" should be string of html
  13308. // context (optional): If specified, the fragment will be created in this context,
  13309. // defaults to document
  13310. // keepScripts (optional): If true, will include scripts passed in the html string
  13311. jQuery.parseHTML = function( data, context, keepScripts ) {
  13312. if ( typeof data !== "string" ) {
  13313. return [];
  13314. }
  13315. if ( typeof context === "boolean" ) {
  13316. keepScripts = context;
  13317. context = false;
  13318. }
  13319. var base, parsed, scripts;
  13320. if ( !context ) {
  13321. // Stop scripts or inline event handlers from being executed immediately
  13322. // by using document.implementation
  13323. if ( support.createHTMLDocument ) {
  13324. context = document.implementation.createHTMLDocument( "" );
  13325. // Set the base href for the created document
  13326. // so any parsed elements with URLs
  13327. // are based on the document's URL (gh-2965)
  13328. base = context.createElement( "base" );
  13329. base.href = document.location.href;
  13330. context.head.appendChild( base );
  13331. } else {
  13332. context = document;
  13333. }
  13334. }
  13335. parsed = rsingleTag.exec( data );
  13336. scripts = !keepScripts && [];
  13337. // Single tag
  13338. if ( parsed ) {
  13339. return [ context.createElement( parsed[ 1 ] ) ];
  13340. }
  13341. parsed = buildFragment( [ data ], context, scripts );
  13342. if ( scripts && scripts.length ) {
  13343. jQuery( scripts ).remove();
  13344. }
  13345. return jQuery.merge( [], parsed.childNodes );
  13346. };
  13347. /**
  13348. * Load a url into a page
  13349. */
  13350. jQuery.fn.load = function( url, params, callback ) {
  13351. var selector, type, response,
  13352. self = this,
  13353. off = url.indexOf( " " );
  13354. if ( off > -1 ) {
  13355. selector = stripAndCollapse( url.slice( off ) );
  13356. url = url.slice( 0, off );
  13357. }
  13358. // If it's a function
  13359. if ( isFunction( params ) ) {
  13360. // We assume that it's the callback
  13361. callback = params;
  13362. params = undefined;
  13363. // Otherwise, build a param string
  13364. } else if ( params && typeof params === "object" ) {
  13365. type = "POST";
  13366. }
  13367. // If we have elements to modify, make the request
  13368. if ( self.length > 0 ) {
  13369. jQuery.ajax( {
  13370. url: url,
  13371. // If "type" variable is undefined, then "GET" method will be used.
  13372. // Make value of this field explicit since
  13373. // user can override it through ajaxSetup method
  13374. type: type || "GET",
  13375. dataType: "html",
  13376. data: params
  13377. } ).done( function( responseText ) {
  13378. // Save response for use in complete callback
  13379. response = arguments;
  13380. self.html( selector ?
  13381. // If a selector was specified, locate the right elements in a dummy div
  13382. // Exclude scripts to avoid IE 'Permission Denied' errors
  13383. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  13384. // Otherwise use the full result
  13385. responseText );
  13386. // If the request succeeds, this function gets "data", "status", "jqXHR"
  13387. // but they are ignored because response was set above.
  13388. // If it fails, this function gets "jqXHR", "status", "error"
  13389. } ).always( callback && function( jqXHR, status ) {
  13390. self.each( function() {
  13391. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  13392. } );
  13393. } );
  13394. }
  13395. return this;
  13396. };
  13397. // Attach a bunch of functions for handling common AJAX events
  13398. jQuery.each( [
  13399. "ajaxStart",
  13400. "ajaxStop",
  13401. "ajaxComplete",
  13402. "ajaxError",
  13403. "ajaxSuccess",
  13404. "ajaxSend"
  13405. ], function( i, type ) {
  13406. jQuery.fn[ type ] = function( fn ) {
  13407. return this.on( type, fn );
  13408. };
  13409. } );
  13410. jQuery.expr.pseudos.animated = function( elem ) {
  13411. return jQuery.grep( jQuery.timers, function( fn ) {
  13412. return elem === fn.elem;
  13413. } ).length;
  13414. };
  13415. jQuery.offset = {
  13416. setOffset: function( elem, options, i ) {
  13417. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  13418. position = jQuery.css( elem, "position" ),
  13419. curElem = jQuery( elem ),
  13420. props = {};
  13421. // Set position first, in-case top/left are set even on static elem
  13422. if ( position === "static" ) {
  13423. elem.style.position = "relative";
  13424. }
  13425. curOffset = curElem.offset();
  13426. curCSSTop = jQuery.css( elem, "top" );
  13427. curCSSLeft = jQuery.css( elem, "left" );
  13428. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  13429. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  13430. // Need to be able to calculate position if either
  13431. // top or left is auto and position is either absolute or fixed
  13432. if ( calculatePosition ) {
  13433. curPosition = curElem.position();
  13434. curTop = curPosition.top;
  13435. curLeft = curPosition.left;
  13436. } else {
  13437. curTop = parseFloat( curCSSTop ) || 0;
  13438. curLeft = parseFloat( curCSSLeft ) || 0;
  13439. }
  13440. if ( isFunction( options ) ) {
  13441. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  13442. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  13443. }
  13444. if ( options.top != null ) {
  13445. props.top = ( options.top - curOffset.top ) + curTop;
  13446. }
  13447. if ( options.left != null ) {
  13448. props.left = ( options.left - curOffset.left ) + curLeft;
  13449. }
  13450. if ( "using" in options ) {
  13451. options.using.call( elem, props );
  13452. } else {
  13453. curElem.css( props );
  13454. }
  13455. }
  13456. };
  13457. jQuery.fn.extend( {
  13458. // offset() relates an element's border box to the document origin
  13459. offset: function( options ) {
  13460. // Preserve chaining for setter
  13461. if ( arguments.length ) {
  13462. return options === undefined ?
  13463. this :
  13464. this.each( function( i ) {
  13465. jQuery.offset.setOffset( this, options, i );
  13466. } );
  13467. }
  13468. var rect, win,
  13469. elem = this[ 0 ];
  13470. if ( !elem ) {
  13471. return;
  13472. }
  13473. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  13474. // Support: IE <=11 only
  13475. // Running getBoundingClientRect on a
  13476. // disconnected node in IE throws an error
  13477. if ( !elem.getClientRects().length ) {
  13478. return { top: 0, left: 0 };
  13479. }
  13480. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  13481. rect = elem.getBoundingClientRect();
  13482. win = elem.ownerDocument.defaultView;
  13483. return {
  13484. top: rect.top + win.pageYOffset,
  13485. left: rect.left + win.pageXOffset
  13486. };
  13487. },
  13488. // position() relates an element's margin box to its offset parent's padding box
  13489. // This corresponds to the behavior of CSS absolute positioning
  13490. position: function() {
  13491. if ( !this[ 0 ] ) {
  13492. return;
  13493. }
  13494. var offsetParent, offset, doc,
  13495. elem = this[ 0 ],
  13496. parentOffset = { top: 0, left: 0 };
  13497. // position:fixed elements are offset from the viewport, which itself always has zero offset
  13498. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  13499. // Assume position:fixed implies availability of getBoundingClientRect
  13500. offset = elem.getBoundingClientRect();
  13501. } else {
  13502. offset = this.offset();
  13503. // Account for the *real* offset parent, which can be the document or its root element
  13504. // when a statically positioned element is identified
  13505. doc = elem.ownerDocument;
  13506. offsetParent = elem.offsetParent || doc.documentElement;
  13507. while ( offsetParent &&
  13508. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  13509. jQuery.css( offsetParent, "position" ) === "static" ) {
  13510. offsetParent = offsetParent.parentNode;
  13511. }
  13512. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  13513. // Incorporate borders into its offset, since they are outside its content origin
  13514. parentOffset = jQuery( offsetParent ).offset();
  13515. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  13516. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  13517. }
  13518. }
  13519. // Subtract parent offsets and element margins
  13520. return {
  13521. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  13522. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  13523. };
  13524. },
  13525. // This method will return documentElement in the following cases:
  13526. // 1) For the element inside the iframe without offsetParent, this method will return
  13527. // documentElement of the parent window
  13528. // 2) For the hidden or detached element
  13529. // 3) For body or html element, i.e. in case of the html node - it will return itself
  13530. //
  13531. // but those exceptions were never presented as a real life use-cases
  13532. // and might be considered as more preferable results.
  13533. //
  13534. // This logic, however, is not guaranteed and can change at any point in the future
  13535. offsetParent: function() {
  13536. return this.map( function() {
  13537. var offsetParent = this.offsetParent;
  13538. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  13539. offsetParent = offsetParent.offsetParent;
  13540. }
  13541. return offsetParent || documentElement;
  13542. } );
  13543. }
  13544. } );
  13545. // Create scrollLeft and scrollTop methods
  13546. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  13547. var top = "pageYOffset" === prop;
  13548. jQuery.fn[ method ] = function( val ) {
  13549. return access( this, function( elem, method, val ) {
  13550. // Coalesce documents and windows
  13551. var win;
  13552. if ( isWindow( elem ) ) {
  13553. win = elem;
  13554. } else if ( elem.nodeType === 9 ) {
  13555. win = elem.defaultView;
  13556. }
  13557. if ( val === undefined ) {
  13558. return win ? win[ prop ] : elem[ method ];
  13559. }
  13560. if ( win ) {
  13561. win.scrollTo(
  13562. !top ? val : win.pageXOffset,
  13563. top ? val : win.pageYOffset
  13564. );
  13565. } else {
  13566. elem[ method ] = val;
  13567. }
  13568. }, method, val, arguments.length );
  13569. };
  13570. } );
  13571. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  13572. // Add the top/left cssHooks using jQuery.fn.position
  13573. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  13574. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  13575. // getComputedStyle returns percent when specified for top/left/bottom/right;
  13576. // rather than make the css module depend on the offset module, just check for it here
  13577. jQuery.each( [ "top", "left" ], function( i, prop ) {
  13578. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  13579. function( elem, computed ) {
  13580. if ( computed ) {
  13581. computed = curCSS( elem, prop );
  13582. // If curCSS returns percentage, fallback to offset
  13583. return rnumnonpx.test( computed ) ?
  13584. jQuery( elem ).position()[ prop ] + "px" :
  13585. computed;
  13586. }
  13587. }
  13588. );
  13589. } );
  13590. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  13591. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  13592. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  13593. function( defaultExtra, funcName ) {
  13594. // Margin is only for outerHeight, outerWidth
  13595. jQuery.fn[ funcName ] = function( margin, value ) {
  13596. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  13597. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  13598. return access( this, function( elem, type, value ) {
  13599. var doc;
  13600. if ( isWindow( elem ) ) {
  13601. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  13602. return funcName.indexOf( "outer" ) === 0 ?
  13603. elem[ "inner" + name ] :
  13604. elem.document.documentElement[ "client" + name ];
  13605. }
  13606. // Get document width or height
  13607. if ( elem.nodeType === 9 ) {
  13608. doc = elem.documentElement;
  13609. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  13610. // whichever is greatest
  13611. return Math.max(
  13612. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  13613. elem.body[ "offset" + name ], doc[ "offset" + name ],
  13614. doc[ "client" + name ]
  13615. );
  13616. }
  13617. return value === undefined ?
  13618. // Get width or height on the element, requesting but not forcing parseFloat
  13619. jQuery.css( elem, type, extra ) :
  13620. // Set width or height on the element
  13621. jQuery.style( elem, type, value, extra );
  13622. }, type, chainable ? margin : undefined, chainable );
  13623. };
  13624. } );
  13625. } );
  13626. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  13627. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  13628. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  13629. function( i, name ) {
  13630. // Handle event binding
  13631. jQuery.fn[ name ] = function( data, fn ) {
  13632. return arguments.length > 0 ?
  13633. this.on( name, null, data, fn ) :
  13634. this.trigger( name );
  13635. };
  13636. } );
  13637. jQuery.fn.extend( {
  13638. hover: function( fnOver, fnOut ) {
  13639. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  13640. }
  13641. } );
  13642. jQuery.fn.extend( {
  13643. bind: function( types, data, fn ) {
  13644. return this.on( types, null, data, fn );
  13645. },
  13646. unbind: function( types, fn ) {
  13647. return this.off( types, null, fn );
  13648. },
  13649. delegate: function( selector, types, data, fn ) {
  13650. return this.on( types, selector, data, fn );
  13651. },
  13652. undelegate: function( selector, types, fn ) {
  13653. // ( namespace ) or ( selector, types [, fn] )
  13654. return arguments.length === 1 ?
  13655. this.off( selector, "**" ) :
  13656. this.off( types, selector || "**", fn );
  13657. }
  13658. } );
  13659. // Bind a function to a context, optionally partially applying any
  13660. // arguments.
  13661. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  13662. // However, it is not slated for removal any time soon
  13663. jQuery.proxy = function( fn, context ) {
  13664. var tmp, args, proxy;
  13665. if ( typeof context === "string" ) {
  13666. tmp = fn[ context ];
  13667. context = fn;
  13668. fn = tmp;
  13669. }
  13670. // Quick check to determine if target is callable, in the spec
  13671. // this throws a TypeError, but we will just return undefined.
  13672. if ( !isFunction( fn ) ) {
  13673. return undefined;
  13674. }
  13675. // Simulated bind
  13676. args = slice.call( arguments, 2 );
  13677. proxy = function() {
  13678. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  13679. };
  13680. // Set the guid of unique handler to the same of original handler, so it can be removed
  13681. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  13682. return proxy;
  13683. };
  13684. jQuery.holdReady = function( hold ) {
  13685. if ( hold ) {
  13686. jQuery.readyWait++;
  13687. } else {
  13688. jQuery.ready( true );
  13689. }
  13690. };
  13691. jQuery.isArray = Array.isArray;
  13692. jQuery.parseJSON = JSON.parse;
  13693. jQuery.nodeName = nodeName;
  13694. jQuery.isFunction = isFunction;
  13695. jQuery.isWindow = isWindow;
  13696. jQuery.camelCase = camelCase;
  13697. jQuery.type = toType;
  13698. jQuery.now = Date.now;
  13699. jQuery.isNumeric = function( obj ) {
  13700. // As of jQuery 3.0, isNumeric is limited to
  13701. // strings and numbers (primitives or objects)
  13702. // that can be coerced to finite numbers (gh-2662)
  13703. var type = jQuery.type( obj );
  13704. return ( type === "number" || type === "string" ) &&
  13705. // parseFloat NaNs numeric-cast false positives ("")
  13706. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  13707. // subtraction forces infinities to NaN
  13708. !isNaN( obj - parseFloat( obj ) );
  13709. };
  13710. // Register as a named AMD module, since jQuery can be concatenated with other
  13711. // files that may use define, but not via a proper concatenation script that
  13712. // understands anonymous AMD modules. A named AMD is safest and most robust
  13713. // way to register. Lowercase jquery is used because AMD module names are
  13714. // derived from file names, and jQuery is normally delivered in a lowercase
  13715. // file name. Do this after creating the global so that if an AMD module wants
  13716. // to call noConflict to hide this version of jQuery, it will work.
  13717. // Note that for maximum portability, libraries that are not jQuery should
  13718. // declare themselves as anonymous modules, and avoid setting a global if an
  13719. // AMD loader is present. jQuery is a special case. For more information, see
  13720. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  13721. if ( true ) {
  13722. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  13723. return jQuery;
  13724. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  13725. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  13726. }
  13727. var
  13728. // Map over jQuery in case of overwrite
  13729. _jQuery = window.jQuery,
  13730. // Map over the $ in case of overwrite
  13731. _$ = window.$;
  13732. jQuery.noConflict = function( deep ) {
  13733. if ( window.$ === jQuery ) {
  13734. window.$ = _$;
  13735. }
  13736. if ( deep && window.jQuery === jQuery ) {
  13737. window.jQuery = _jQuery;
  13738. }
  13739. return jQuery;
  13740. };
  13741. // Expose jQuery and $ identifiers, even in AMD
  13742. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  13743. // and CommonJS for browser emulators (#13566)
  13744. if ( !noGlobal ) {
  13745. window.jQuery = window.$ = jQuery;
  13746. }
  13747. return jQuery;
  13748. } );
  13749. /***/ }),
  13750. /***/ "./node_modules/lodash/lodash.js":
  13751. /*!***************************************!*\
  13752. !*** ./node_modules/lodash/lodash.js ***!
  13753. \***************************************/
  13754. /*! no static exports found */
  13755. /***/ (function(module, exports, __webpack_require__) {
  13756. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  13757. * @license
  13758. * Lodash <https://lodash.com/>
  13759. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  13760. * Released under MIT license <https://lodash.com/license>
  13761. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  13762. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  13763. */
  13764. ;(function() {
  13765. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  13766. var undefined;
  13767. /** Used as the semantic version number. */
  13768. var VERSION = '4.17.15';
  13769. /** Used as the size to enable large array optimizations. */
  13770. var LARGE_ARRAY_SIZE = 200;
  13771. /** Error message constants. */
  13772. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  13773. FUNC_ERROR_TEXT = 'Expected a function';
  13774. /** Used to stand-in for `undefined` hash values. */
  13775. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  13776. /** Used as the maximum memoize cache size. */
  13777. var MAX_MEMOIZE_SIZE = 500;
  13778. /** Used as the internal argument placeholder. */
  13779. var PLACEHOLDER = '__lodash_placeholder__';
  13780. /** Used to compose bitmasks for cloning. */
  13781. var CLONE_DEEP_FLAG = 1,
  13782. CLONE_FLAT_FLAG = 2,
  13783. CLONE_SYMBOLS_FLAG = 4;
  13784. /** Used to compose bitmasks for value comparisons. */
  13785. var COMPARE_PARTIAL_FLAG = 1,
  13786. COMPARE_UNORDERED_FLAG = 2;
  13787. /** Used to compose bitmasks for function metadata. */
  13788. var WRAP_BIND_FLAG = 1,
  13789. WRAP_BIND_KEY_FLAG = 2,
  13790. WRAP_CURRY_BOUND_FLAG = 4,
  13791. WRAP_CURRY_FLAG = 8,
  13792. WRAP_CURRY_RIGHT_FLAG = 16,
  13793. WRAP_PARTIAL_FLAG = 32,
  13794. WRAP_PARTIAL_RIGHT_FLAG = 64,
  13795. WRAP_ARY_FLAG = 128,
  13796. WRAP_REARG_FLAG = 256,
  13797. WRAP_FLIP_FLAG = 512;
  13798. /** Used as default options for `_.truncate`. */
  13799. var DEFAULT_TRUNC_LENGTH = 30,
  13800. DEFAULT_TRUNC_OMISSION = '...';
  13801. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  13802. var HOT_COUNT = 800,
  13803. HOT_SPAN = 16;
  13804. /** Used to indicate the type of lazy iteratees. */
  13805. var LAZY_FILTER_FLAG = 1,
  13806. LAZY_MAP_FLAG = 2,
  13807. LAZY_WHILE_FLAG = 3;
  13808. /** Used as references for various `Number` constants. */
  13809. var INFINITY = 1 / 0,
  13810. MAX_SAFE_INTEGER = 9007199254740991,
  13811. MAX_INTEGER = 1.7976931348623157e+308,
  13812. NAN = 0 / 0;
  13813. /** Used as references for the maximum length and index of an array. */
  13814. var MAX_ARRAY_LENGTH = 4294967295,
  13815. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  13816. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  13817. /** Used to associate wrap methods with their bit flags. */
  13818. var wrapFlags = [
  13819. ['ary', WRAP_ARY_FLAG],
  13820. ['bind', WRAP_BIND_FLAG],
  13821. ['bindKey', WRAP_BIND_KEY_FLAG],
  13822. ['curry', WRAP_CURRY_FLAG],
  13823. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  13824. ['flip', WRAP_FLIP_FLAG],
  13825. ['partial', WRAP_PARTIAL_FLAG],
  13826. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  13827. ['rearg', WRAP_REARG_FLAG]
  13828. ];
  13829. /** `Object#toString` result references. */
  13830. var argsTag = '[object Arguments]',
  13831. arrayTag = '[object Array]',
  13832. asyncTag = '[object AsyncFunction]',
  13833. boolTag = '[object Boolean]',
  13834. dateTag = '[object Date]',
  13835. domExcTag = '[object DOMException]',
  13836. errorTag = '[object Error]',
  13837. funcTag = '[object Function]',
  13838. genTag = '[object GeneratorFunction]',
  13839. mapTag = '[object Map]',
  13840. numberTag = '[object Number]',
  13841. nullTag = '[object Null]',
  13842. objectTag = '[object Object]',
  13843. promiseTag = '[object Promise]',
  13844. proxyTag = '[object Proxy]',
  13845. regexpTag = '[object RegExp]',
  13846. setTag = '[object Set]',
  13847. stringTag = '[object String]',
  13848. symbolTag = '[object Symbol]',
  13849. undefinedTag = '[object Undefined]',
  13850. weakMapTag = '[object WeakMap]',
  13851. weakSetTag = '[object WeakSet]';
  13852. var arrayBufferTag = '[object ArrayBuffer]',
  13853. dataViewTag = '[object DataView]',
  13854. float32Tag = '[object Float32Array]',
  13855. float64Tag = '[object Float64Array]',
  13856. int8Tag = '[object Int8Array]',
  13857. int16Tag = '[object Int16Array]',
  13858. int32Tag = '[object Int32Array]',
  13859. uint8Tag = '[object Uint8Array]',
  13860. uint8ClampedTag = '[object Uint8ClampedArray]',
  13861. uint16Tag = '[object Uint16Array]',
  13862. uint32Tag = '[object Uint32Array]';
  13863. /** Used to match empty string literals in compiled template source. */
  13864. var reEmptyStringLeading = /\b__p \+= '';/g,
  13865. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  13866. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  13867. /** Used to match HTML entities and HTML characters. */
  13868. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  13869. reUnescapedHtml = /[&<>"']/g,
  13870. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  13871. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  13872. /** Used to match template delimiters. */
  13873. var reEscape = /<%-([\s\S]+?)%>/g,
  13874. reEvaluate = /<%([\s\S]+?)%>/g,
  13875. reInterpolate = /<%=([\s\S]+?)%>/g;
  13876. /** Used to match property names within property paths. */
  13877. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  13878. reIsPlainProp = /^\w*$/,
  13879. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  13880. /**
  13881. * Used to match `RegExp`
  13882. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  13883. */
  13884. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  13885. reHasRegExpChar = RegExp(reRegExpChar.source);
  13886. /** Used to match leading and trailing whitespace. */
  13887. var reTrim = /^\s+|\s+$/g,
  13888. reTrimStart = /^\s+/,
  13889. reTrimEnd = /\s+$/;
  13890. /** Used to match wrap detail comments. */
  13891. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  13892. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  13893. reSplitDetails = /,? & /;
  13894. /** Used to match words composed of alphanumeric characters. */
  13895. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  13896. /** Used to match backslashes in property paths. */
  13897. var reEscapeChar = /\\(\\)?/g;
  13898. /**
  13899. * Used to match
  13900. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  13901. */
  13902. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  13903. /** Used to match `RegExp` flags from their coerced string values. */
  13904. var reFlags = /\w*$/;
  13905. /** Used to detect bad signed hexadecimal string values. */
  13906. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  13907. /** Used to detect binary string values. */
  13908. var reIsBinary = /^0b[01]+$/i;
  13909. /** Used to detect host constructors (Safari). */
  13910. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  13911. /** Used to detect octal string values. */
  13912. var reIsOctal = /^0o[0-7]+$/i;
  13913. /** Used to detect unsigned integer values. */
  13914. var reIsUint = /^(?:0|[1-9]\d*)$/;
  13915. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  13916. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  13917. /** Used to ensure capturing order of template delimiters. */
  13918. var reNoMatch = /($^)/;
  13919. /** Used to match unescaped characters in compiled string literals. */
  13920. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  13921. /** Used to compose unicode character classes. */
  13922. var rsAstralRange = '\\ud800-\\udfff',
  13923. rsComboMarksRange = '\\u0300-\\u036f',
  13924. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  13925. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  13926. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  13927. rsDingbatRange = '\\u2700-\\u27bf',
  13928. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  13929. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  13930. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  13931. rsPunctuationRange = '\\u2000-\\u206f',
  13932. rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
  13933. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  13934. rsVarRange = '\\ufe0e\\ufe0f',
  13935. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  13936. /** Used to compose unicode capture groups. */
  13937. var rsApos = "['\u2019]",
  13938. rsAstral = '[' + rsAstralRange + ']',
  13939. rsBreak = '[' + rsBreakRange + ']',
  13940. rsCombo = '[' + rsComboRange + ']',
  13941. rsDigits = '\\d+',
  13942. rsDingbat = '[' + rsDingbatRange + ']',
  13943. rsLower = '[' + rsLowerRange + ']',
  13944. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  13945. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  13946. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  13947. rsNonAstral = '[^' + rsAstralRange + ']',
  13948. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  13949. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  13950. rsUpper = '[' + rsUpperRange + ']',
  13951. rsZWJ = '\\u200d';
  13952. /** Used to compose unicode regexes. */
  13953. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  13954. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  13955. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  13956. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  13957. reOptMod = rsModifier + '?',
  13958. rsOptVar = '[' + rsVarRange + ']?',
  13959. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  13960. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  13961. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  13962. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  13963. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  13964. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  13965. /** Used to match apostrophes. */
  13966. var reApos = RegExp(rsApos, 'g');
  13967. /**
  13968. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  13969. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  13970. */
  13971. var reComboMark = RegExp(rsCombo, 'g');
  13972. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  13973. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  13974. /** Used to match complex or compound words. */
  13975. var reUnicodeWord = RegExp([
  13976. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  13977. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  13978. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  13979. rsUpper + '+' + rsOptContrUpper,
  13980. rsOrdUpper,
  13981. rsOrdLower,
  13982. rsDigits,
  13983. rsEmoji
  13984. ].join('|'), 'g');
  13985. /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
  13986. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  13987. /** Used to detect strings that need a more robust regexp to match words. */
  13988. var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
  13989. /** Used to assign default `context` object properties. */
  13990. var contextProps = [
  13991. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  13992. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  13993. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  13994. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  13995. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  13996. ];
  13997. /** Used to make template sourceURLs easier to identify. */
  13998. var templateCounter = -1;
  13999. /** Used to identify `toStringTag` values of typed arrays. */
  14000. var typedArrayTags = {};
  14001. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  14002. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  14003. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  14004. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  14005. typedArrayTags[uint32Tag] = true;
  14006. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  14007. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  14008. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  14009. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  14010. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  14011. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  14012. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  14013. typedArrayTags[weakMapTag] = false;
  14014. /** Used to identify `toStringTag` values supported by `_.clone`. */
  14015. var cloneableTags = {};
  14016. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  14017. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  14018. cloneableTags[boolTag] = cloneableTags[dateTag] =
  14019. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  14020. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  14021. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  14022. cloneableTags[numberTag] = cloneableTags[objectTag] =
  14023. cloneableTags[regexpTag] = cloneableTags[setTag] =
  14024. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  14025. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  14026. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  14027. cloneableTags[errorTag] = cloneableTags[funcTag] =
  14028. cloneableTags[weakMapTag] = false;
  14029. /** Used to map Latin Unicode letters to basic Latin letters. */
  14030. var deburredLetters = {
  14031. // Latin-1 Supplement block.
  14032. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  14033. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  14034. '\xc7': 'C', '\xe7': 'c',
  14035. '\xd0': 'D', '\xf0': 'd',
  14036. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  14037. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  14038. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  14039. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  14040. '\xd1': 'N', '\xf1': 'n',
  14041. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  14042. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  14043. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  14044. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  14045. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  14046. '\xc6': 'Ae', '\xe6': 'ae',
  14047. '\xde': 'Th', '\xfe': 'th',
  14048. '\xdf': 'ss',
  14049. // Latin Extended-A block.
  14050. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  14051. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  14052. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  14053. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  14054. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  14055. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  14056. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  14057. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  14058. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  14059. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  14060. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  14061. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  14062. '\u0134': 'J', '\u0135': 'j',
  14063. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  14064. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  14065. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  14066. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  14067. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  14068. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  14069. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  14070. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  14071. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  14072. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  14073. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  14074. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  14075. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  14076. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  14077. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  14078. '\u0174': 'W', '\u0175': 'w',
  14079. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  14080. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  14081. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  14082. '\u0132': 'IJ', '\u0133': 'ij',
  14083. '\u0152': 'Oe', '\u0153': 'oe',
  14084. '\u0149': "'n", '\u017f': 's'
  14085. };
  14086. /** Used to map characters to HTML entities. */
  14087. var htmlEscapes = {
  14088. '&': '&amp;',
  14089. '<': '&lt;',
  14090. '>': '&gt;',
  14091. '"': '&quot;',
  14092. "'": '&#39;'
  14093. };
  14094. /** Used to map HTML entities to characters. */
  14095. var htmlUnescapes = {
  14096. '&amp;': '&',
  14097. '&lt;': '<',
  14098. '&gt;': '>',
  14099. '&quot;': '"',
  14100. '&#39;': "'"
  14101. };
  14102. /** Used to escape characters for inclusion in compiled string literals. */
  14103. var stringEscapes = {
  14104. '\\': '\\',
  14105. "'": "'",
  14106. '\n': 'n',
  14107. '\r': 'r',
  14108. '\u2028': 'u2028',
  14109. '\u2029': 'u2029'
  14110. };
  14111. /** Built-in method references without a dependency on `root`. */
  14112. var freeParseFloat = parseFloat,
  14113. freeParseInt = parseInt;
  14114. /** Detect free variable `global` from Node.js. */
  14115. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  14116. /** Detect free variable `self`. */
  14117. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  14118. /** Used as a reference to the global object. */
  14119. var root = freeGlobal || freeSelf || Function('return this')();
  14120. /** Detect free variable `exports`. */
  14121. var freeExports = true && exports && !exports.nodeType && exports;
  14122. /** Detect free variable `module`. */
  14123. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  14124. /** Detect the popular CommonJS extension `module.exports`. */
  14125. var moduleExports = freeModule && freeModule.exports === freeExports;
  14126. /** Detect free variable `process` from Node.js. */
  14127. var freeProcess = moduleExports && freeGlobal.process;
  14128. /** Used to access faster Node.js helpers. */
  14129. var nodeUtil = (function() {
  14130. try {
  14131. // Use `util.types` for Node.js 10+.
  14132. var types = freeModule && freeModule.require && freeModule.require('util').types;
  14133. if (types) {
  14134. return types;
  14135. }
  14136. // Legacy `process.binding('util')` for Node.js < 10.
  14137. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  14138. } catch (e) {}
  14139. }());
  14140. /* Node.js helper references. */
  14141. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  14142. nodeIsDate = nodeUtil && nodeUtil.isDate,
  14143. nodeIsMap = nodeUtil && nodeUtil.isMap,
  14144. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  14145. nodeIsSet = nodeUtil && nodeUtil.isSet,
  14146. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  14147. /*--------------------------------------------------------------------------*/
  14148. /**
  14149. * A faster alternative to `Function#apply`, this function invokes `func`
  14150. * with the `this` binding of `thisArg` and the arguments of `args`.
  14151. *
  14152. * @private
  14153. * @param {Function} func The function to invoke.
  14154. * @param {*} thisArg The `this` binding of `func`.
  14155. * @param {Array} args The arguments to invoke `func` with.
  14156. * @returns {*} Returns the result of `func`.
  14157. */
  14158. function apply(func, thisArg, args) {
  14159. switch (args.length) {
  14160. case 0: return func.call(thisArg);
  14161. case 1: return func.call(thisArg, args[0]);
  14162. case 2: return func.call(thisArg, args[0], args[1]);
  14163. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  14164. }
  14165. return func.apply(thisArg, args);
  14166. }
  14167. /**
  14168. * A specialized version of `baseAggregator` for arrays.
  14169. *
  14170. * @private
  14171. * @param {Array} [array] The array to iterate over.
  14172. * @param {Function} setter The function to set `accumulator` values.
  14173. * @param {Function} iteratee The iteratee to transform keys.
  14174. * @param {Object} accumulator The initial aggregated object.
  14175. * @returns {Function} Returns `accumulator`.
  14176. */
  14177. function arrayAggregator(array, setter, iteratee, accumulator) {
  14178. var index = -1,
  14179. length = array == null ? 0 : array.length;
  14180. while (++index < length) {
  14181. var value = array[index];
  14182. setter(accumulator, value, iteratee(value), array);
  14183. }
  14184. return accumulator;
  14185. }
  14186. /**
  14187. * A specialized version of `_.forEach` for arrays without support for
  14188. * iteratee shorthands.
  14189. *
  14190. * @private
  14191. * @param {Array} [array] The array to iterate over.
  14192. * @param {Function} iteratee The function invoked per iteration.
  14193. * @returns {Array} Returns `array`.
  14194. */
  14195. function arrayEach(array, iteratee) {
  14196. var index = -1,
  14197. length = array == null ? 0 : array.length;
  14198. while (++index < length) {
  14199. if (iteratee(array[index], index, array) === false) {
  14200. break;
  14201. }
  14202. }
  14203. return array;
  14204. }
  14205. /**
  14206. * A specialized version of `_.forEachRight` for arrays without support for
  14207. * iteratee shorthands.
  14208. *
  14209. * @private
  14210. * @param {Array} [array] The array to iterate over.
  14211. * @param {Function} iteratee The function invoked per iteration.
  14212. * @returns {Array} Returns `array`.
  14213. */
  14214. function arrayEachRight(array, iteratee) {
  14215. var length = array == null ? 0 : array.length;
  14216. while (length--) {
  14217. if (iteratee(array[length], length, array) === false) {
  14218. break;
  14219. }
  14220. }
  14221. return array;
  14222. }
  14223. /**
  14224. * A specialized version of `_.every` for arrays without support for
  14225. * iteratee shorthands.
  14226. *
  14227. * @private
  14228. * @param {Array} [array] The array to iterate over.
  14229. * @param {Function} predicate The function invoked per iteration.
  14230. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  14231. * else `false`.
  14232. */
  14233. function arrayEvery(array, predicate) {
  14234. var index = -1,
  14235. length = array == null ? 0 : array.length;
  14236. while (++index < length) {
  14237. if (!predicate(array[index], index, array)) {
  14238. return false;
  14239. }
  14240. }
  14241. return true;
  14242. }
  14243. /**
  14244. * A specialized version of `_.filter` for arrays without support for
  14245. * iteratee shorthands.
  14246. *
  14247. * @private
  14248. * @param {Array} [array] The array to iterate over.
  14249. * @param {Function} predicate The function invoked per iteration.
  14250. * @returns {Array} Returns the new filtered array.
  14251. */
  14252. function arrayFilter(array, predicate) {
  14253. var index = -1,
  14254. length = array == null ? 0 : array.length,
  14255. resIndex = 0,
  14256. result = [];
  14257. while (++index < length) {
  14258. var value = array[index];
  14259. if (predicate(value, index, array)) {
  14260. result[resIndex++] = value;
  14261. }
  14262. }
  14263. return result;
  14264. }
  14265. /**
  14266. * A specialized version of `_.includes` for arrays without support for
  14267. * specifying an index to search from.
  14268. *
  14269. * @private
  14270. * @param {Array} [array] The array to inspect.
  14271. * @param {*} target The value to search for.
  14272. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  14273. */
  14274. function arrayIncludes(array, value) {
  14275. var length = array == null ? 0 : array.length;
  14276. return !!length && baseIndexOf(array, value, 0) > -1;
  14277. }
  14278. /**
  14279. * This function is like `arrayIncludes` except that it accepts a comparator.
  14280. *
  14281. * @private
  14282. * @param {Array} [array] The array to inspect.
  14283. * @param {*} target The value to search for.
  14284. * @param {Function} comparator The comparator invoked per element.
  14285. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  14286. */
  14287. function arrayIncludesWith(array, value, comparator) {
  14288. var index = -1,
  14289. length = array == null ? 0 : array.length;
  14290. while (++index < length) {
  14291. if (comparator(value, array[index])) {
  14292. return true;
  14293. }
  14294. }
  14295. return false;
  14296. }
  14297. /**
  14298. * A specialized version of `_.map` for arrays without support for iteratee
  14299. * shorthands.
  14300. *
  14301. * @private
  14302. * @param {Array} [array] The array to iterate over.
  14303. * @param {Function} iteratee The function invoked per iteration.
  14304. * @returns {Array} Returns the new mapped array.
  14305. */
  14306. function arrayMap(array, iteratee) {
  14307. var index = -1,
  14308. length = array == null ? 0 : array.length,
  14309. result = Array(length);
  14310. while (++index < length) {
  14311. result[index] = iteratee(array[index], index, array);
  14312. }
  14313. return result;
  14314. }
  14315. /**
  14316. * Appends the elements of `values` to `array`.
  14317. *
  14318. * @private
  14319. * @param {Array} array The array to modify.
  14320. * @param {Array} values The values to append.
  14321. * @returns {Array} Returns `array`.
  14322. */
  14323. function arrayPush(array, values) {
  14324. var index = -1,
  14325. length = values.length,
  14326. offset = array.length;
  14327. while (++index < length) {
  14328. array[offset + index] = values[index];
  14329. }
  14330. return array;
  14331. }
  14332. /**
  14333. * A specialized version of `_.reduce` for arrays without support for
  14334. * iteratee shorthands.
  14335. *
  14336. * @private
  14337. * @param {Array} [array] The array to iterate over.
  14338. * @param {Function} iteratee The function invoked per iteration.
  14339. * @param {*} [accumulator] The initial value.
  14340. * @param {boolean} [initAccum] Specify using the first element of `array` as
  14341. * the initial value.
  14342. * @returns {*} Returns the accumulated value.
  14343. */
  14344. function arrayReduce(array, iteratee, accumulator, initAccum) {
  14345. var index = -1,
  14346. length = array == null ? 0 : array.length;
  14347. if (initAccum && length) {
  14348. accumulator = array[++index];
  14349. }
  14350. while (++index < length) {
  14351. accumulator = iteratee(accumulator, array[index], index, array);
  14352. }
  14353. return accumulator;
  14354. }
  14355. /**
  14356. * A specialized version of `_.reduceRight` for arrays without support for
  14357. * iteratee shorthands.
  14358. *
  14359. * @private
  14360. * @param {Array} [array] The array to iterate over.
  14361. * @param {Function} iteratee The function invoked per iteration.
  14362. * @param {*} [accumulator] The initial value.
  14363. * @param {boolean} [initAccum] Specify using the last element of `array` as
  14364. * the initial value.
  14365. * @returns {*} Returns the accumulated value.
  14366. */
  14367. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  14368. var length = array == null ? 0 : array.length;
  14369. if (initAccum && length) {
  14370. accumulator = array[--length];
  14371. }
  14372. while (length--) {
  14373. accumulator = iteratee(accumulator, array[length], length, array);
  14374. }
  14375. return accumulator;
  14376. }
  14377. /**
  14378. * A specialized version of `_.some` for arrays without support for iteratee
  14379. * shorthands.
  14380. *
  14381. * @private
  14382. * @param {Array} [array] The array to iterate over.
  14383. * @param {Function} predicate The function invoked per iteration.
  14384. * @returns {boolean} Returns `true` if any element passes the predicate check,
  14385. * else `false`.
  14386. */
  14387. function arraySome(array, predicate) {
  14388. var index = -1,
  14389. length = array == null ? 0 : array.length;
  14390. while (++index < length) {
  14391. if (predicate(array[index], index, array)) {
  14392. return true;
  14393. }
  14394. }
  14395. return false;
  14396. }
  14397. /**
  14398. * Gets the size of an ASCII `string`.
  14399. *
  14400. * @private
  14401. * @param {string} string The string inspect.
  14402. * @returns {number} Returns the string size.
  14403. */
  14404. var asciiSize = baseProperty('length');
  14405. /**
  14406. * Converts an ASCII `string` to an array.
  14407. *
  14408. * @private
  14409. * @param {string} string The string to convert.
  14410. * @returns {Array} Returns the converted array.
  14411. */
  14412. function asciiToArray(string) {
  14413. return string.split('');
  14414. }
  14415. /**
  14416. * Splits an ASCII `string` into an array of its words.
  14417. *
  14418. * @private
  14419. * @param {string} The string to inspect.
  14420. * @returns {Array} Returns the words of `string`.
  14421. */
  14422. function asciiWords(string) {
  14423. return string.match(reAsciiWord) || [];
  14424. }
  14425. /**
  14426. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  14427. * without support for iteratee shorthands, which iterates over `collection`
  14428. * using `eachFunc`.
  14429. *
  14430. * @private
  14431. * @param {Array|Object} collection The collection to inspect.
  14432. * @param {Function} predicate The function invoked per iteration.
  14433. * @param {Function} eachFunc The function to iterate over `collection`.
  14434. * @returns {*} Returns the found element or its key, else `undefined`.
  14435. */
  14436. function baseFindKey(collection, predicate, eachFunc) {
  14437. var result;
  14438. eachFunc(collection, function(value, key, collection) {
  14439. if (predicate(value, key, collection)) {
  14440. result = key;
  14441. return false;
  14442. }
  14443. });
  14444. return result;
  14445. }
  14446. /**
  14447. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  14448. * support for iteratee shorthands.
  14449. *
  14450. * @private
  14451. * @param {Array} array The array to inspect.
  14452. * @param {Function} predicate The function invoked per iteration.
  14453. * @param {number} fromIndex The index to search from.
  14454. * @param {boolean} [fromRight] Specify iterating from right to left.
  14455. * @returns {number} Returns the index of the matched value, else `-1`.
  14456. */
  14457. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  14458. var length = array.length,
  14459. index = fromIndex + (fromRight ? 1 : -1);
  14460. while ((fromRight ? index-- : ++index < length)) {
  14461. if (predicate(array[index], index, array)) {
  14462. return index;
  14463. }
  14464. }
  14465. return -1;
  14466. }
  14467. /**
  14468. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  14469. *
  14470. * @private
  14471. * @param {Array} array The array to inspect.
  14472. * @param {*} value The value to search for.
  14473. * @param {number} fromIndex The index to search from.
  14474. * @returns {number} Returns the index of the matched value, else `-1`.
  14475. */
  14476. function baseIndexOf(array, value, fromIndex) {
  14477. return value === value
  14478. ? strictIndexOf(array, value, fromIndex)
  14479. : baseFindIndex(array, baseIsNaN, fromIndex);
  14480. }
  14481. /**
  14482. * This function is like `baseIndexOf` except that it accepts a comparator.
  14483. *
  14484. * @private
  14485. * @param {Array} array The array to inspect.
  14486. * @param {*} value The value to search for.
  14487. * @param {number} fromIndex The index to search from.
  14488. * @param {Function} comparator The comparator invoked per element.
  14489. * @returns {number} Returns the index of the matched value, else `-1`.
  14490. */
  14491. function baseIndexOfWith(array, value, fromIndex, comparator) {
  14492. var index = fromIndex - 1,
  14493. length = array.length;
  14494. while (++index < length) {
  14495. if (comparator(array[index], value)) {
  14496. return index;
  14497. }
  14498. }
  14499. return -1;
  14500. }
  14501. /**
  14502. * The base implementation of `_.isNaN` without support for number objects.
  14503. *
  14504. * @private
  14505. * @param {*} value The value to check.
  14506. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  14507. */
  14508. function baseIsNaN(value) {
  14509. return value !== value;
  14510. }
  14511. /**
  14512. * The base implementation of `_.mean` and `_.meanBy` without support for
  14513. * iteratee shorthands.
  14514. *
  14515. * @private
  14516. * @param {Array} array The array to iterate over.
  14517. * @param {Function} iteratee The function invoked per iteration.
  14518. * @returns {number} Returns the mean.
  14519. */
  14520. function baseMean(array, iteratee) {
  14521. var length = array == null ? 0 : array.length;
  14522. return length ? (baseSum(array, iteratee) / length) : NAN;
  14523. }
  14524. /**
  14525. * The base implementation of `_.property` without support for deep paths.
  14526. *
  14527. * @private
  14528. * @param {string} key The key of the property to get.
  14529. * @returns {Function} Returns the new accessor function.
  14530. */
  14531. function baseProperty(key) {
  14532. return function(object) {
  14533. return object == null ? undefined : object[key];
  14534. };
  14535. }
  14536. /**
  14537. * The base implementation of `_.propertyOf` without support for deep paths.
  14538. *
  14539. * @private
  14540. * @param {Object} object The object to query.
  14541. * @returns {Function} Returns the new accessor function.
  14542. */
  14543. function basePropertyOf(object) {
  14544. return function(key) {
  14545. return object == null ? undefined : object[key];
  14546. };
  14547. }
  14548. /**
  14549. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  14550. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  14551. *
  14552. * @private
  14553. * @param {Array|Object} collection The collection to iterate over.
  14554. * @param {Function} iteratee The function invoked per iteration.
  14555. * @param {*} accumulator The initial value.
  14556. * @param {boolean} initAccum Specify using the first or last element of
  14557. * `collection` as the initial value.
  14558. * @param {Function} eachFunc The function to iterate over `collection`.
  14559. * @returns {*} Returns the accumulated value.
  14560. */
  14561. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  14562. eachFunc(collection, function(value, index, collection) {
  14563. accumulator = initAccum
  14564. ? (initAccum = false, value)
  14565. : iteratee(accumulator, value, index, collection);
  14566. });
  14567. return accumulator;
  14568. }
  14569. /**
  14570. * The base implementation of `_.sortBy` which uses `comparer` to define the
  14571. * sort order of `array` and replaces criteria objects with their corresponding
  14572. * values.
  14573. *
  14574. * @private
  14575. * @param {Array} array The array to sort.
  14576. * @param {Function} comparer The function to define sort order.
  14577. * @returns {Array} Returns `array`.
  14578. */
  14579. function baseSortBy(array, comparer) {
  14580. var length = array.length;
  14581. array.sort(comparer);
  14582. while (length--) {
  14583. array[length] = array[length].value;
  14584. }
  14585. return array;
  14586. }
  14587. /**
  14588. * The base implementation of `_.sum` and `_.sumBy` without support for
  14589. * iteratee shorthands.
  14590. *
  14591. * @private
  14592. * @param {Array} array The array to iterate over.
  14593. * @param {Function} iteratee The function invoked per iteration.
  14594. * @returns {number} Returns the sum.
  14595. */
  14596. function baseSum(array, iteratee) {
  14597. var result,
  14598. index = -1,
  14599. length = array.length;
  14600. while (++index < length) {
  14601. var current = iteratee(array[index]);
  14602. if (current !== undefined) {
  14603. result = result === undefined ? current : (result + current);
  14604. }
  14605. }
  14606. return result;
  14607. }
  14608. /**
  14609. * The base implementation of `_.times` without support for iteratee shorthands
  14610. * or max array length checks.
  14611. *
  14612. * @private
  14613. * @param {number} n The number of times to invoke `iteratee`.
  14614. * @param {Function} iteratee The function invoked per iteration.
  14615. * @returns {Array} Returns the array of results.
  14616. */
  14617. function baseTimes(n, iteratee) {
  14618. var index = -1,
  14619. result = Array(n);
  14620. while (++index < n) {
  14621. result[index] = iteratee(index);
  14622. }
  14623. return result;
  14624. }
  14625. /**
  14626. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  14627. * of key-value pairs for `object` corresponding to the property names of `props`.
  14628. *
  14629. * @private
  14630. * @param {Object} object The object to query.
  14631. * @param {Array} props The property names to get values for.
  14632. * @returns {Object} Returns the key-value pairs.
  14633. */
  14634. function baseToPairs(object, props) {
  14635. return arrayMap(props, function(key) {
  14636. return [key, object[key]];
  14637. });
  14638. }
  14639. /**
  14640. * The base implementation of `_.unary` without support for storing metadata.
  14641. *
  14642. * @private
  14643. * @param {Function} func The function to cap arguments for.
  14644. * @returns {Function} Returns the new capped function.
  14645. */
  14646. function baseUnary(func) {
  14647. return function(value) {
  14648. return func(value);
  14649. };
  14650. }
  14651. /**
  14652. * The base implementation of `_.values` and `_.valuesIn` which creates an
  14653. * array of `object` property values corresponding to the property names
  14654. * of `props`.
  14655. *
  14656. * @private
  14657. * @param {Object} object The object to query.
  14658. * @param {Array} props The property names to get values for.
  14659. * @returns {Object} Returns the array of property values.
  14660. */
  14661. function baseValues(object, props) {
  14662. return arrayMap(props, function(key) {
  14663. return object[key];
  14664. });
  14665. }
  14666. /**
  14667. * Checks if a `cache` value for `key` exists.
  14668. *
  14669. * @private
  14670. * @param {Object} cache The cache to query.
  14671. * @param {string} key The key of the entry to check.
  14672. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  14673. */
  14674. function cacheHas(cache, key) {
  14675. return cache.has(key);
  14676. }
  14677. /**
  14678. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  14679. * that is not found in the character symbols.
  14680. *
  14681. * @private
  14682. * @param {Array} strSymbols The string symbols to inspect.
  14683. * @param {Array} chrSymbols The character symbols to find.
  14684. * @returns {number} Returns the index of the first unmatched string symbol.
  14685. */
  14686. function charsStartIndex(strSymbols, chrSymbols) {
  14687. var index = -1,
  14688. length = strSymbols.length;
  14689. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  14690. return index;
  14691. }
  14692. /**
  14693. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  14694. * that is not found in the character symbols.
  14695. *
  14696. * @private
  14697. * @param {Array} strSymbols The string symbols to inspect.
  14698. * @param {Array} chrSymbols The character symbols to find.
  14699. * @returns {number} Returns the index of the last unmatched string symbol.
  14700. */
  14701. function charsEndIndex(strSymbols, chrSymbols) {
  14702. var index = strSymbols.length;
  14703. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  14704. return index;
  14705. }
  14706. /**
  14707. * Gets the number of `placeholder` occurrences in `array`.
  14708. *
  14709. * @private
  14710. * @param {Array} array The array to inspect.
  14711. * @param {*} placeholder The placeholder to search for.
  14712. * @returns {number} Returns the placeholder count.
  14713. */
  14714. function countHolders(array, placeholder) {
  14715. var length = array.length,
  14716. result = 0;
  14717. while (length--) {
  14718. if (array[length] === placeholder) {
  14719. ++result;
  14720. }
  14721. }
  14722. return result;
  14723. }
  14724. /**
  14725. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  14726. * letters to basic Latin letters.
  14727. *
  14728. * @private
  14729. * @param {string} letter The matched letter to deburr.
  14730. * @returns {string} Returns the deburred letter.
  14731. */
  14732. var deburrLetter = basePropertyOf(deburredLetters);
  14733. /**
  14734. * Used by `_.escape` to convert characters to HTML entities.
  14735. *
  14736. * @private
  14737. * @param {string} chr The matched character to escape.
  14738. * @returns {string} Returns the escaped character.
  14739. */
  14740. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  14741. /**
  14742. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  14743. *
  14744. * @private
  14745. * @param {string} chr The matched character to escape.
  14746. * @returns {string} Returns the escaped character.
  14747. */
  14748. function escapeStringChar(chr) {
  14749. return '\\' + stringEscapes[chr];
  14750. }
  14751. /**
  14752. * Gets the value at `key` of `object`.
  14753. *
  14754. * @private
  14755. * @param {Object} [object] The object to query.
  14756. * @param {string} key The key of the property to get.
  14757. * @returns {*} Returns the property value.
  14758. */
  14759. function getValue(object, key) {
  14760. return object == null ? undefined : object[key];
  14761. }
  14762. /**
  14763. * Checks if `string` contains Unicode symbols.
  14764. *
  14765. * @private
  14766. * @param {string} string The string to inspect.
  14767. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  14768. */
  14769. function hasUnicode(string) {
  14770. return reHasUnicode.test(string);
  14771. }
  14772. /**
  14773. * Checks if `string` contains a word composed of Unicode symbols.
  14774. *
  14775. * @private
  14776. * @param {string} string The string to inspect.
  14777. * @returns {boolean} Returns `true` if a word is found, else `false`.
  14778. */
  14779. function hasUnicodeWord(string) {
  14780. return reHasUnicodeWord.test(string);
  14781. }
  14782. /**
  14783. * Converts `iterator` to an array.
  14784. *
  14785. * @private
  14786. * @param {Object} iterator The iterator to convert.
  14787. * @returns {Array} Returns the converted array.
  14788. */
  14789. function iteratorToArray(iterator) {
  14790. var data,
  14791. result = [];
  14792. while (!(data = iterator.next()).done) {
  14793. result.push(data.value);
  14794. }
  14795. return result;
  14796. }
  14797. /**
  14798. * Converts `map` to its key-value pairs.
  14799. *
  14800. * @private
  14801. * @param {Object} map The map to convert.
  14802. * @returns {Array} Returns the key-value pairs.
  14803. */
  14804. function mapToArray(map) {
  14805. var index = -1,
  14806. result = Array(map.size);
  14807. map.forEach(function(value, key) {
  14808. result[++index] = [key, value];
  14809. });
  14810. return result;
  14811. }
  14812. /**
  14813. * Creates a unary function that invokes `func` with its argument transformed.
  14814. *
  14815. * @private
  14816. * @param {Function} func The function to wrap.
  14817. * @param {Function} transform The argument transform.
  14818. * @returns {Function} Returns the new function.
  14819. */
  14820. function overArg(func, transform) {
  14821. return function(arg) {
  14822. return func(transform(arg));
  14823. };
  14824. }
  14825. /**
  14826. * Replaces all `placeholder` elements in `array` with an internal placeholder
  14827. * and returns an array of their indexes.
  14828. *
  14829. * @private
  14830. * @param {Array} array The array to modify.
  14831. * @param {*} placeholder The placeholder to replace.
  14832. * @returns {Array} Returns the new array of placeholder indexes.
  14833. */
  14834. function replaceHolders(array, placeholder) {
  14835. var index = -1,
  14836. length = array.length,
  14837. resIndex = 0,
  14838. result = [];
  14839. while (++index < length) {
  14840. var value = array[index];
  14841. if (value === placeholder || value === PLACEHOLDER) {
  14842. array[index] = PLACEHOLDER;
  14843. result[resIndex++] = index;
  14844. }
  14845. }
  14846. return result;
  14847. }
  14848. /**
  14849. * Converts `set` to an array of its values.
  14850. *
  14851. * @private
  14852. * @param {Object} set The set to convert.
  14853. * @returns {Array} Returns the values.
  14854. */
  14855. function setToArray(set) {
  14856. var index = -1,
  14857. result = Array(set.size);
  14858. set.forEach(function(value) {
  14859. result[++index] = value;
  14860. });
  14861. return result;
  14862. }
  14863. /**
  14864. * Converts `set` to its value-value pairs.
  14865. *
  14866. * @private
  14867. * @param {Object} set The set to convert.
  14868. * @returns {Array} Returns the value-value pairs.
  14869. */
  14870. function setToPairs(set) {
  14871. var index = -1,
  14872. result = Array(set.size);
  14873. set.forEach(function(value) {
  14874. result[++index] = [value, value];
  14875. });
  14876. return result;
  14877. }
  14878. /**
  14879. * A specialized version of `_.indexOf` which performs strict equality
  14880. * comparisons of values, i.e. `===`.
  14881. *
  14882. * @private
  14883. * @param {Array} array The array to inspect.
  14884. * @param {*} value The value to search for.
  14885. * @param {number} fromIndex The index to search from.
  14886. * @returns {number} Returns the index of the matched value, else `-1`.
  14887. */
  14888. function strictIndexOf(array, value, fromIndex) {
  14889. var index = fromIndex - 1,
  14890. length = array.length;
  14891. while (++index < length) {
  14892. if (array[index] === value) {
  14893. return index;
  14894. }
  14895. }
  14896. return -1;
  14897. }
  14898. /**
  14899. * A specialized version of `_.lastIndexOf` which performs strict equality
  14900. * comparisons of values, i.e. `===`.
  14901. *
  14902. * @private
  14903. * @param {Array} array The array to inspect.
  14904. * @param {*} value The value to search for.
  14905. * @param {number} fromIndex The index to search from.
  14906. * @returns {number} Returns the index of the matched value, else `-1`.
  14907. */
  14908. function strictLastIndexOf(array, value, fromIndex) {
  14909. var index = fromIndex + 1;
  14910. while (index--) {
  14911. if (array[index] === value) {
  14912. return index;
  14913. }
  14914. }
  14915. return index;
  14916. }
  14917. /**
  14918. * Gets the number of symbols in `string`.
  14919. *
  14920. * @private
  14921. * @param {string} string The string to inspect.
  14922. * @returns {number} Returns the string size.
  14923. */
  14924. function stringSize(string) {
  14925. return hasUnicode(string)
  14926. ? unicodeSize(string)
  14927. : asciiSize(string);
  14928. }
  14929. /**
  14930. * Converts `string` to an array.
  14931. *
  14932. * @private
  14933. * @param {string} string The string to convert.
  14934. * @returns {Array} Returns the converted array.
  14935. */
  14936. function stringToArray(string) {
  14937. return hasUnicode(string)
  14938. ? unicodeToArray(string)
  14939. : asciiToArray(string);
  14940. }
  14941. /**
  14942. * Used by `_.unescape` to convert HTML entities to characters.
  14943. *
  14944. * @private
  14945. * @param {string} chr The matched character to unescape.
  14946. * @returns {string} Returns the unescaped character.
  14947. */
  14948. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  14949. /**
  14950. * Gets the size of a Unicode `string`.
  14951. *
  14952. * @private
  14953. * @param {string} string The string inspect.
  14954. * @returns {number} Returns the string size.
  14955. */
  14956. function unicodeSize(string) {
  14957. var result = reUnicode.lastIndex = 0;
  14958. while (reUnicode.test(string)) {
  14959. ++result;
  14960. }
  14961. return result;
  14962. }
  14963. /**
  14964. * Converts a Unicode `string` to an array.
  14965. *
  14966. * @private
  14967. * @param {string} string The string to convert.
  14968. * @returns {Array} Returns the converted array.
  14969. */
  14970. function unicodeToArray(string) {
  14971. return string.match(reUnicode) || [];
  14972. }
  14973. /**
  14974. * Splits a Unicode `string` into an array of its words.
  14975. *
  14976. * @private
  14977. * @param {string} The string to inspect.
  14978. * @returns {Array} Returns the words of `string`.
  14979. */
  14980. function unicodeWords(string) {
  14981. return string.match(reUnicodeWord) || [];
  14982. }
  14983. /*--------------------------------------------------------------------------*/
  14984. /**
  14985. * Create a new pristine `lodash` function using the `context` object.
  14986. *
  14987. * @static
  14988. * @memberOf _
  14989. * @since 1.1.0
  14990. * @category Util
  14991. * @param {Object} [context=root] The context object.
  14992. * @returns {Function} Returns a new `lodash` function.
  14993. * @example
  14994. *
  14995. * _.mixin({ 'foo': _.constant('foo') });
  14996. *
  14997. * var lodash = _.runInContext();
  14998. * lodash.mixin({ 'bar': lodash.constant('bar') });
  14999. *
  15000. * _.isFunction(_.foo);
  15001. * // => true
  15002. * _.isFunction(_.bar);
  15003. * // => false
  15004. *
  15005. * lodash.isFunction(lodash.foo);
  15006. * // => false
  15007. * lodash.isFunction(lodash.bar);
  15008. * // => true
  15009. *
  15010. * // Create a suped-up `defer` in Node.js.
  15011. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  15012. */
  15013. var runInContext = (function runInContext(context) {
  15014. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  15015. /** Built-in constructor references. */
  15016. var Array = context.Array,
  15017. Date = context.Date,
  15018. Error = context.Error,
  15019. Function = context.Function,
  15020. Math = context.Math,
  15021. Object = context.Object,
  15022. RegExp = context.RegExp,
  15023. String = context.String,
  15024. TypeError = context.TypeError;
  15025. /** Used for built-in method references. */
  15026. var arrayProto = Array.prototype,
  15027. funcProto = Function.prototype,
  15028. objectProto = Object.prototype;
  15029. /** Used to detect overreaching core-js shims. */
  15030. var coreJsData = context['__core-js_shared__'];
  15031. /** Used to resolve the decompiled source of functions. */
  15032. var funcToString = funcProto.toString;
  15033. /** Used to check objects for own properties. */
  15034. var hasOwnProperty = objectProto.hasOwnProperty;
  15035. /** Used to generate unique IDs. */
  15036. var idCounter = 0;
  15037. /** Used to detect methods masquerading as native. */
  15038. var maskSrcKey = (function() {
  15039. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  15040. return uid ? ('Symbol(src)_1.' + uid) : '';
  15041. }());
  15042. /**
  15043. * Used to resolve the
  15044. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  15045. * of values.
  15046. */
  15047. var nativeObjectToString = objectProto.toString;
  15048. /** Used to infer the `Object` constructor. */
  15049. var objectCtorString = funcToString.call(Object);
  15050. /** Used to restore the original `_` reference in `_.noConflict`. */
  15051. var oldDash = root._;
  15052. /** Used to detect if a method is native. */
  15053. var reIsNative = RegExp('^' +
  15054. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  15055. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  15056. );
  15057. /** Built-in value references. */
  15058. var Buffer = moduleExports ? context.Buffer : undefined,
  15059. Symbol = context.Symbol,
  15060. Uint8Array = context.Uint8Array,
  15061. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  15062. getPrototype = overArg(Object.getPrototypeOf, Object),
  15063. objectCreate = Object.create,
  15064. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  15065. splice = arrayProto.splice,
  15066. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  15067. symIterator = Symbol ? Symbol.iterator : undefined,
  15068. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  15069. var defineProperty = (function() {
  15070. try {
  15071. var func = getNative(Object, 'defineProperty');
  15072. func({}, '', {});
  15073. return func;
  15074. } catch (e) {}
  15075. }());
  15076. /** Mocked built-ins. */
  15077. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  15078. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  15079. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  15080. /* Built-in method references for those with the same name as other `lodash` methods. */
  15081. var nativeCeil = Math.ceil,
  15082. nativeFloor = Math.floor,
  15083. nativeGetSymbols = Object.getOwnPropertySymbols,
  15084. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  15085. nativeIsFinite = context.isFinite,
  15086. nativeJoin = arrayProto.join,
  15087. nativeKeys = overArg(Object.keys, Object),
  15088. nativeMax = Math.max,
  15089. nativeMin = Math.min,
  15090. nativeNow = Date.now,
  15091. nativeParseInt = context.parseInt,
  15092. nativeRandom = Math.random,
  15093. nativeReverse = arrayProto.reverse;
  15094. /* Built-in method references that are verified to be native. */
  15095. var DataView = getNative(context, 'DataView'),
  15096. Map = getNative(context, 'Map'),
  15097. Promise = getNative(context, 'Promise'),
  15098. Set = getNative(context, 'Set'),
  15099. WeakMap = getNative(context, 'WeakMap'),
  15100. nativeCreate = getNative(Object, 'create');
  15101. /** Used to store function metadata. */
  15102. var metaMap = WeakMap && new WeakMap;
  15103. /** Used to lookup unminified function names. */
  15104. var realNames = {};
  15105. /** Used to detect maps, sets, and weakmaps. */
  15106. var dataViewCtorString = toSource(DataView),
  15107. mapCtorString = toSource(Map),
  15108. promiseCtorString = toSource(Promise),
  15109. setCtorString = toSource(Set),
  15110. weakMapCtorString = toSource(WeakMap);
  15111. /** Used to convert symbols to primitives and strings. */
  15112. var symbolProto = Symbol ? Symbol.prototype : undefined,
  15113. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  15114. symbolToString = symbolProto ? symbolProto.toString : undefined;
  15115. /*------------------------------------------------------------------------*/
  15116. /**
  15117. * Creates a `lodash` object which wraps `value` to enable implicit method
  15118. * chain sequences. Methods that operate on and return arrays, collections,
  15119. * and functions can be chained together. Methods that retrieve a single value
  15120. * or may return a primitive value will automatically end the chain sequence
  15121. * and return the unwrapped value. Otherwise, the value must be unwrapped
  15122. * with `_#value`.
  15123. *
  15124. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  15125. * enabled using `_.chain`.
  15126. *
  15127. * The execution of chained methods is lazy, that is, it's deferred until
  15128. * `_#value` is implicitly or explicitly called.
  15129. *
  15130. * Lazy evaluation allows several methods to support shortcut fusion.
  15131. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  15132. * the creation of intermediate arrays and can greatly reduce the number of
  15133. * iteratee executions. Sections of a chain sequence qualify for shortcut
  15134. * fusion if the section is applied to an array and iteratees accept only
  15135. * one argument. The heuristic for whether a section qualifies for shortcut
  15136. * fusion is subject to change.
  15137. *
  15138. * Chaining is supported in custom builds as long as the `_#value` method is
  15139. * directly or indirectly included in the build.
  15140. *
  15141. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  15142. *
  15143. * The wrapper `Array` methods are:
  15144. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  15145. *
  15146. * The wrapper `String` methods are:
  15147. * `replace` and `split`
  15148. *
  15149. * The wrapper methods that support shortcut fusion are:
  15150. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  15151. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  15152. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  15153. *
  15154. * The chainable wrapper methods are:
  15155. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  15156. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  15157. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  15158. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  15159. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  15160. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  15161. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  15162. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  15163. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  15164. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  15165. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  15166. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  15167. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  15168. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  15169. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  15170. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  15171. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  15172. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  15173. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  15174. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  15175. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  15176. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  15177. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  15178. * `zipObject`, `zipObjectDeep`, and `zipWith`
  15179. *
  15180. * The wrapper methods that are **not** chainable by default are:
  15181. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  15182. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  15183. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  15184. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  15185. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  15186. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  15187. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  15188. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  15189. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  15190. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  15191. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  15192. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  15193. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  15194. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  15195. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  15196. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  15197. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  15198. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  15199. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  15200. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  15201. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  15202. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  15203. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  15204. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  15205. * `upperFirst`, `value`, and `words`
  15206. *
  15207. * @name _
  15208. * @constructor
  15209. * @category Seq
  15210. * @param {*} value The value to wrap in a `lodash` instance.
  15211. * @returns {Object} Returns the new `lodash` wrapper instance.
  15212. * @example
  15213. *
  15214. * function square(n) {
  15215. * return n * n;
  15216. * }
  15217. *
  15218. * var wrapped = _([1, 2, 3]);
  15219. *
  15220. * // Returns an unwrapped value.
  15221. * wrapped.reduce(_.add);
  15222. * // => 6
  15223. *
  15224. * // Returns a wrapped value.
  15225. * var squares = wrapped.map(square);
  15226. *
  15227. * _.isArray(squares);
  15228. * // => false
  15229. *
  15230. * _.isArray(squares.value());
  15231. * // => true
  15232. */
  15233. function lodash(value) {
  15234. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  15235. if (value instanceof LodashWrapper) {
  15236. return value;
  15237. }
  15238. if (hasOwnProperty.call(value, '__wrapped__')) {
  15239. return wrapperClone(value);
  15240. }
  15241. }
  15242. return new LodashWrapper(value);
  15243. }
  15244. /**
  15245. * The base implementation of `_.create` without support for assigning
  15246. * properties to the created object.
  15247. *
  15248. * @private
  15249. * @param {Object} proto The object to inherit from.
  15250. * @returns {Object} Returns the new object.
  15251. */
  15252. var baseCreate = (function() {
  15253. function object() {}
  15254. return function(proto) {
  15255. if (!isObject(proto)) {
  15256. return {};
  15257. }
  15258. if (objectCreate) {
  15259. return objectCreate(proto);
  15260. }
  15261. object.prototype = proto;
  15262. var result = new object;
  15263. object.prototype = undefined;
  15264. return result;
  15265. };
  15266. }());
  15267. /**
  15268. * The function whose prototype chain sequence wrappers inherit from.
  15269. *
  15270. * @private
  15271. */
  15272. function baseLodash() {
  15273. // No operation performed.
  15274. }
  15275. /**
  15276. * The base constructor for creating `lodash` wrapper objects.
  15277. *
  15278. * @private
  15279. * @param {*} value The value to wrap.
  15280. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  15281. */
  15282. function LodashWrapper(value, chainAll) {
  15283. this.__wrapped__ = value;
  15284. this.__actions__ = [];
  15285. this.__chain__ = !!chainAll;
  15286. this.__index__ = 0;
  15287. this.__values__ = undefined;
  15288. }
  15289. /**
  15290. * By default, the template delimiters used by lodash are like those in
  15291. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  15292. * following template settings to use alternative delimiters.
  15293. *
  15294. * @static
  15295. * @memberOf _
  15296. * @type {Object}
  15297. */
  15298. lodash.templateSettings = {
  15299. /**
  15300. * Used to detect `data` property values to be HTML-escaped.
  15301. *
  15302. * @memberOf _.templateSettings
  15303. * @type {RegExp}
  15304. */
  15305. 'escape': reEscape,
  15306. /**
  15307. * Used to detect code to be evaluated.
  15308. *
  15309. * @memberOf _.templateSettings
  15310. * @type {RegExp}
  15311. */
  15312. 'evaluate': reEvaluate,
  15313. /**
  15314. * Used to detect `data` property values to inject.
  15315. *
  15316. * @memberOf _.templateSettings
  15317. * @type {RegExp}
  15318. */
  15319. 'interpolate': reInterpolate,
  15320. /**
  15321. * Used to reference the data object in the template text.
  15322. *
  15323. * @memberOf _.templateSettings
  15324. * @type {string}
  15325. */
  15326. 'variable': '',
  15327. /**
  15328. * Used to import variables into the compiled template.
  15329. *
  15330. * @memberOf _.templateSettings
  15331. * @type {Object}
  15332. */
  15333. 'imports': {
  15334. /**
  15335. * A reference to the `lodash` function.
  15336. *
  15337. * @memberOf _.templateSettings.imports
  15338. * @type {Function}
  15339. */
  15340. '_': lodash
  15341. }
  15342. };
  15343. // Ensure wrappers are instances of `baseLodash`.
  15344. lodash.prototype = baseLodash.prototype;
  15345. lodash.prototype.constructor = lodash;
  15346. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  15347. LodashWrapper.prototype.constructor = LodashWrapper;
  15348. /*------------------------------------------------------------------------*/
  15349. /**
  15350. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  15351. *
  15352. * @private
  15353. * @constructor
  15354. * @param {*} value The value to wrap.
  15355. */
  15356. function LazyWrapper(value) {
  15357. this.__wrapped__ = value;
  15358. this.__actions__ = [];
  15359. this.__dir__ = 1;
  15360. this.__filtered__ = false;
  15361. this.__iteratees__ = [];
  15362. this.__takeCount__ = MAX_ARRAY_LENGTH;
  15363. this.__views__ = [];
  15364. }
  15365. /**
  15366. * Creates a clone of the lazy wrapper object.
  15367. *
  15368. * @private
  15369. * @name clone
  15370. * @memberOf LazyWrapper
  15371. * @returns {Object} Returns the cloned `LazyWrapper` object.
  15372. */
  15373. function lazyClone() {
  15374. var result = new LazyWrapper(this.__wrapped__);
  15375. result.__actions__ = copyArray(this.__actions__);
  15376. result.__dir__ = this.__dir__;
  15377. result.__filtered__ = this.__filtered__;
  15378. result.__iteratees__ = copyArray(this.__iteratees__);
  15379. result.__takeCount__ = this.__takeCount__;
  15380. result.__views__ = copyArray(this.__views__);
  15381. return result;
  15382. }
  15383. /**
  15384. * Reverses the direction of lazy iteration.
  15385. *
  15386. * @private
  15387. * @name reverse
  15388. * @memberOf LazyWrapper
  15389. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  15390. */
  15391. function lazyReverse() {
  15392. if (this.__filtered__) {
  15393. var result = new LazyWrapper(this);
  15394. result.__dir__ = -1;
  15395. result.__filtered__ = true;
  15396. } else {
  15397. result = this.clone();
  15398. result.__dir__ *= -1;
  15399. }
  15400. return result;
  15401. }
  15402. /**
  15403. * Extracts the unwrapped value from its lazy wrapper.
  15404. *
  15405. * @private
  15406. * @name value
  15407. * @memberOf LazyWrapper
  15408. * @returns {*} Returns the unwrapped value.
  15409. */
  15410. function lazyValue() {
  15411. var array = this.__wrapped__.value(),
  15412. dir = this.__dir__,
  15413. isArr = isArray(array),
  15414. isRight = dir < 0,
  15415. arrLength = isArr ? array.length : 0,
  15416. view = getView(0, arrLength, this.__views__),
  15417. start = view.start,
  15418. end = view.end,
  15419. length = end - start,
  15420. index = isRight ? end : (start - 1),
  15421. iteratees = this.__iteratees__,
  15422. iterLength = iteratees.length,
  15423. resIndex = 0,
  15424. takeCount = nativeMin(length, this.__takeCount__);
  15425. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  15426. return baseWrapperValue(array, this.__actions__);
  15427. }
  15428. var result = [];
  15429. outer:
  15430. while (length-- && resIndex < takeCount) {
  15431. index += dir;
  15432. var iterIndex = -1,
  15433. value = array[index];
  15434. while (++iterIndex < iterLength) {
  15435. var data = iteratees[iterIndex],
  15436. iteratee = data.iteratee,
  15437. type = data.type,
  15438. computed = iteratee(value);
  15439. if (type == LAZY_MAP_FLAG) {
  15440. value = computed;
  15441. } else if (!computed) {
  15442. if (type == LAZY_FILTER_FLAG) {
  15443. continue outer;
  15444. } else {
  15445. break outer;
  15446. }
  15447. }
  15448. }
  15449. result[resIndex++] = value;
  15450. }
  15451. return result;
  15452. }
  15453. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  15454. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  15455. LazyWrapper.prototype.constructor = LazyWrapper;
  15456. /*------------------------------------------------------------------------*/
  15457. /**
  15458. * Creates a hash object.
  15459. *
  15460. * @private
  15461. * @constructor
  15462. * @param {Array} [entries] The key-value pairs to cache.
  15463. */
  15464. function Hash(entries) {
  15465. var index = -1,
  15466. length = entries == null ? 0 : entries.length;
  15467. this.clear();
  15468. while (++index < length) {
  15469. var entry = entries[index];
  15470. this.set(entry[0], entry[1]);
  15471. }
  15472. }
  15473. /**
  15474. * Removes all key-value entries from the hash.
  15475. *
  15476. * @private
  15477. * @name clear
  15478. * @memberOf Hash
  15479. */
  15480. function hashClear() {
  15481. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  15482. this.size = 0;
  15483. }
  15484. /**
  15485. * Removes `key` and its value from the hash.
  15486. *
  15487. * @private
  15488. * @name delete
  15489. * @memberOf Hash
  15490. * @param {Object} hash The hash to modify.
  15491. * @param {string} key The key of the value to remove.
  15492. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15493. */
  15494. function hashDelete(key) {
  15495. var result = this.has(key) && delete this.__data__[key];
  15496. this.size -= result ? 1 : 0;
  15497. return result;
  15498. }
  15499. /**
  15500. * Gets the hash value for `key`.
  15501. *
  15502. * @private
  15503. * @name get
  15504. * @memberOf Hash
  15505. * @param {string} key The key of the value to get.
  15506. * @returns {*} Returns the entry value.
  15507. */
  15508. function hashGet(key) {
  15509. var data = this.__data__;
  15510. if (nativeCreate) {
  15511. var result = data[key];
  15512. return result === HASH_UNDEFINED ? undefined : result;
  15513. }
  15514. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  15515. }
  15516. /**
  15517. * Checks if a hash value for `key` exists.
  15518. *
  15519. * @private
  15520. * @name has
  15521. * @memberOf Hash
  15522. * @param {string} key The key of the entry to check.
  15523. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15524. */
  15525. function hashHas(key) {
  15526. var data = this.__data__;
  15527. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  15528. }
  15529. /**
  15530. * Sets the hash `key` to `value`.
  15531. *
  15532. * @private
  15533. * @name set
  15534. * @memberOf Hash
  15535. * @param {string} key The key of the value to set.
  15536. * @param {*} value The value to set.
  15537. * @returns {Object} Returns the hash instance.
  15538. */
  15539. function hashSet(key, value) {
  15540. var data = this.__data__;
  15541. this.size += this.has(key) ? 0 : 1;
  15542. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  15543. return this;
  15544. }
  15545. // Add methods to `Hash`.
  15546. Hash.prototype.clear = hashClear;
  15547. Hash.prototype['delete'] = hashDelete;
  15548. Hash.prototype.get = hashGet;
  15549. Hash.prototype.has = hashHas;
  15550. Hash.prototype.set = hashSet;
  15551. /*------------------------------------------------------------------------*/
  15552. /**
  15553. * Creates an list cache object.
  15554. *
  15555. * @private
  15556. * @constructor
  15557. * @param {Array} [entries] The key-value pairs to cache.
  15558. */
  15559. function ListCache(entries) {
  15560. var index = -1,
  15561. length = entries == null ? 0 : entries.length;
  15562. this.clear();
  15563. while (++index < length) {
  15564. var entry = entries[index];
  15565. this.set(entry[0], entry[1]);
  15566. }
  15567. }
  15568. /**
  15569. * Removes all key-value entries from the list cache.
  15570. *
  15571. * @private
  15572. * @name clear
  15573. * @memberOf ListCache
  15574. */
  15575. function listCacheClear() {
  15576. this.__data__ = [];
  15577. this.size = 0;
  15578. }
  15579. /**
  15580. * Removes `key` and its value from the list cache.
  15581. *
  15582. * @private
  15583. * @name delete
  15584. * @memberOf ListCache
  15585. * @param {string} key The key of the value to remove.
  15586. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15587. */
  15588. function listCacheDelete(key) {
  15589. var data = this.__data__,
  15590. index = assocIndexOf(data, key);
  15591. if (index < 0) {
  15592. return false;
  15593. }
  15594. var lastIndex = data.length - 1;
  15595. if (index == lastIndex) {
  15596. data.pop();
  15597. } else {
  15598. splice.call(data, index, 1);
  15599. }
  15600. --this.size;
  15601. return true;
  15602. }
  15603. /**
  15604. * Gets the list cache value for `key`.
  15605. *
  15606. * @private
  15607. * @name get
  15608. * @memberOf ListCache
  15609. * @param {string} key The key of the value to get.
  15610. * @returns {*} Returns the entry value.
  15611. */
  15612. function listCacheGet(key) {
  15613. var data = this.__data__,
  15614. index = assocIndexOf(data, key);
  15615. return index < 0 ? undefined : data[index][1];
  15616. }
  15617. /**
  15618. * Checks if a list cache value for `key` exists.
  15619. *
  15620. * @private
  15621. * @name has
  15622. * @memberOf ListCache
  15623. * @param {string} key The key of the entry to check.
  15624. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15625. */
  15626. function listCacheHas(key) {
  15627. return assocIndexOf(this.__data__, key) > -1;
  15628. }
  15629. /**
  15630. * Sets the list cache `key` to `value`.
  15631. *
  15632. * @private
  15633. * @name set
  15634. * @memberOf ListCache
  15635. * @param {string} key The key of the value to set.
  15636. * @param {*} value The value to set.
  15637. * @returns {Object} Returns the list cache instance.
  15638. */
  15639. function listCacheSet(key, value) {
  15640. var data = this.__data__,
  15641. index = assocIndexOf(data, key);
  15642. if (index < 0) {
  15643. ++this.size;
  15644. data.push([key, value]);
  15645. } else {
  15646. data[index][1] = value;
  15647. }
  15648. return this;
  15649. }
  15650. // Add methods to `ListCache`.
  15651. ListCache.prototype.clear = listCacheClear;
  15652. ListCache.prototype['delete'] = listCacheDelete;
  15653. ListCache.prototype.get = listCacheGet;
  15654. ListCache.prototype.has = listCacheHas;
  15655. ListCache.prototype.set = listCacheSet;
  15656. /*------------------------------------------------------------------------*/
  15657. /**
  15658. * Creates a map cache object to store key-value pairs.
  15659. *
  15660. * @private
  15661. * @constructor
  15662. * @param {Array} [entries] The key-value pairs to cache.
  15663. */
  15664. function MapCache(entries) {
  15665. var index = -1,
  15666. length = entries == null ? 0 : entries.length;
  15667. this.clear();
  15668. while (++index < length) {
  15669. var entry = entries[index];
  15670. this.set(entry[0], entry[1]);
  15671. }
  15672. }
  15673. /**
  15674. * Removes all key-value entries from the map.
  15675. *
  15676. * @private
  15677. * @name clear
  15678. * @memberOf MapCache
  15679. */
  15680. function mapCacheClear() {
  15681. this.size = 0;
  15682. this.__data__ = {
  15683. 'hash': new Hash,
  15684. 'map': new (Map || ListCache),
  15685. 'string': new Hash
  15686. };
  15687. }
  15688. /**
  15689. * Removes `key` and its value from the map.
  15690. *
  15691. * @private
  15692. * @name delete
  15693. * @memberOf MapCache
  15694. * @param {string} key The key of the value to remove.
  15695. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15696. */
  15697. function mapCacheDelete(key) {
  15698. var result = getMapData(this, key)['delete'](key);
  15699. this.size -= result ? 1 : 0;
  15700. return result;
  15701. }
  15702. /**
  15703. * Gets the map value for `key`.
  15704. *
  15705. * @private
  15706. * @name get
  15707. * @memberOf MapCache
  15708. * @param {string} key The key of the value to get.
  15709. * @returns {*} Returns the entry value.
  15710. */
  15711. function mapCacheGet(key) {
  15712. return getMapData(this, key).get(key);
  15713. }
  15714. /**
  15715. * Checks if a map value for `key` exists.
  15716. *
  15717. * @private
  15718. * @name has
  15719. * @memberOf MapCache
  15720. * @param {string} key The key of the entry to check.
  15721. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15722. */
  15723. function mapCacheHas(key) {
  15724. return getMapData(this, key).has(key);
  15725. }
  15726. /**
  15727. * Sets the map `key` to `value`.
  15728. *
  15729. * @private
  15730. * @name set
  15731. * @memberOf MapCache
  15732. * @param {string} key The key of the value to set.
  15733. * @param {*} value The value to set.
  15734. * @returns {Object} Returns the map cache instance.
  15735. */
  15736. function mapCacheSet(key, value) {
  15737. var data = getMapData(this, key),
  15738. size = data.size;
  15739. data.set(key, value);
  15740. this.size += data.size == size ? 0 : 1;
  15741. return this;
  15742. }
  15743. // Add methods to `MapCache`.
  15744. MapCache.prototype.clear = mapCacheClear;
  15745. MapCache.prototype['delete'] = mapCacheDelete;
  15746. MapCache.prototype.get = mapCacheGet;
  15747. MapCache.prototype.has = mapCacheHas;
  15748. MapCache.prototype.set = mapCacheSet;
  15749. /*------------------------------------------------------------------------*/
  15750. /**
  15751. *
  15752. * Creates an array cache object to store unique values.
  15753. *
  15754. * @private
  15755. * @constructor
  15756. * @param {Array} [values] The values to cache.
  15757. */
  15758. function SetCache(values) {
  15759. var index = -1,
  15760. length = values == null ? 0 : values.length;
  15761. this.__data__ = new MapCache;
  15762. while (++index < length) {
  15763. this.add(values[index]);
  15764. }
  15765. }
  15766. /**
  15767. * Adds `value` to the array cache.
  15768. *
  15769. * @private
  15770. * @name add
  15771. * @memberOf SetCache
  15772. * @alias push
  15773. * @param {*} value The value to cache.
  15774. * @returns {Object} Returns the cache instance.
  15775. */
  15776. function setCacheAdd(value) {
  15777. this.__data__.set(value, HASH_UNDEFINED);
  15778. return this;
  15779. }
  15780. /**
  15781. * Checks if `value` is in the array cache.
  15782. *
  15783. * @private
  15784. * @name has
  15785. * @memberOf SetCache
  15786. * @param {*} value The value to search for.
  15787. * @returns {number} Returns `true` if `value` is found, else `false`.
  15788. */
  15789. function setCacheHas(value) {
  15790. return this.__data__.has(value);
  15791. }
  15792. // Add methods to `SetCache`.
  15793. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  15794. SetCache.prototype.has = setCacheHas;
  15795. /*------------------------------------------------------------------------*/
  15796. /**
  15797. * Creates a stack cache object to store key-value pairs.
  15798. *
  15799. * @private
  15800. * @constructor
  15801. * @param {Array} [entries] The key-value pairs to cache.
  15802. */
  15803. function Stack(entries) {
  15804. var data = this.__data__ = new ListCache(entries);
  15805. this.size = data.size;
  15806. }
  15807. /**
  15808. * Removes all key-value entries from the stack.
  15809. *
  15810. * @private
  15811. * @name clear
  15812. * @memberOf Stack
  15813. */
  15814. function stackClear() {
  15815. this.__data__ = new ListCache;
  15816. this.size = 0;
  15817. }
  15818. /**
  15819. * Removes `key` and its value from the stack.
  15820. *
  15821. * @private
  15822. * @name delete
  15823. * @memberOf Stack
  15824. * @param {string} key The key of the value to remove.
  15825. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15826. */
  15827. function stackDelete(key) {
  15828. var data = this.__data__,
  15829. result = data['delete'](key);
  15830. this.size = data.size;
  15831. return result;
  15832. }
  15833. /**
  15834. * Gets the stack value for `key`.
  15835. *
  15836. * @private
  15837. * @name get
  15838. * @memberOf Stack
  15839. * @param {string} key The key of the value to get.
  15840. * @returns {*} Returns the entry value.
  15841. */
  15842. function stackGet(key) {
  15843. return this.__data__.get(key);
  15844. }
  15845. /**
  15846. * Checks if a stack value for `key` exists.
  15847. *
  15848. * @private
  15849. * @name has
  15850. * @memberOf Stack
  15851. * @param {string} key The key of the entry to check.
  15852. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15853. */
  15854. function stackHas(key) {
  15855. return this.__data__.has(key);
  15856. }
  15857. /**
  15858. * Sets the stack `key` to `value`.
  15859. *
  15860. * @private
  15861. * @name set
  15862. * @memberOf Stack
  15863. * @param {string} key The key of the value to set.
  15864. * @param {*} value The value to set.
  15865. * @returns {Object} Returns the stack cache instance.
  15866. */
  15867. function stackSet(key, value) {
  15868. var data = this.__data__;
  15869. if (data instanceof ListCache) {
  15870. var pairs = data.__data__;
  15871. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  15872. pairs.push([key, value]);
  15873. this.size = ++data.size;
  15874. return this;
  15875. }
  15876. data = this.__data__ = new MapCache(pairs);
  15877. }
  15878. data.set(key, value);
  15879. this.size = data.size;
  15880. return this;
  15881. }
  15882. // Add methods to `Stack`.
  15883. Stack.prototype.clear = stackClear;
  15884. Stack.prototype['delete'] = stackDelete;
  15885. Stack.prototype.get = stackGet;
  15886. Stack.prototype.has = stackHas;
  15887. Stack.prototype.set = stackSet;
  15888. /*------------------------------------------------------------------------*/
  15889. /**
  15890. * Creates an array of the enumerable property names of the array-like `value`.
  15891. *
  15892. * @private
  15893. * @param {*} value The value to query.
  15894. * @param {boolean} inherited Specify returning inherited property names.
  15895. * @returns {Array} Returns the array of property names.
  15896. */
  15897. function arrayLikeKeys(value, inherited) {
  15898. var isArr = isArray(value),
  15899. isArg = !isArr && isArguments(value),
  15900. isBuff = !isArr && !isArg && isBuffer(value),
  15901. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  15902. skipIndexes = isArr || isArg || isBuff || isType,
  15903. result = skipIndexes ? baseTimes(value.length, String) : [],
  15904. length = result.length;
  15905. for (var key in value) {
  15906. if ((inherited || hasOwnProperty.call(value, key)) &&
  15907. !(skipIndexes && (
  15908. // Safari 9 has enumerable `arguments.length` in strict mode.
  15909. key == 'length' ||
  15910. // Node.js 0.10 has enumerable non-index properties on buffers.
  15911. (isBuff && (key == 'offset' || key == 'parent')) ||
  15912. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  15913. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  15914. // Skip index properties.
  15915. isIndex(key, length)
  15916. ))) {
  15917. result.push(key);
  15918. }
  15919. }
  15920. return result;
  15921. }
  15922. /**
  15923. * A specialized version of `_.sample` for arrays.
  15924. *
  15925. * @private
  15926. * @param {Array} array The array to sample.
  15927. * @returns {*} Returns the random element.
  15928. */
  15929. function arraySample(array) {
  15930. var length = array.length;
  15931. return length ? array[baseRandom(0, length - 1)] : undefined;
  15932. }
  15933. /**
  15934. * A specialized version of `_.sampleSize` for arrays.
  15935. *
  15936. * @private
  15937. * @param {Array} array The array to sample.
  15938. * @param {number} n The number of elements to sample.
  15939. * @returns {Array} Returns the random elements.
  15940. */
  15941. function arraySampleSize(array, n) {
  15942. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  15943. }
  15944. /**
  15945. * A specialized version of `_.shuffle` for arrays.
  15946. *
  15947. * @private
  15948. * @param {Array} array The array to shuffle.
  15949. * @returns {Array} Returns the new shuffled array.
  15950. */
  15951. function arrayShuffle(array) {
  15952. return shuffleSelf(copyArray(array));
  15953. }
  15954. /**
  15955. * This function is like `assignValue` except that it doesn't assign
  15956. * `undefined` values.
  15957. *
  15958. * @private
  15959. * @param {Object} object The object to modify.
  15960. * @param {string} key The key of the property to assign.
  15961. * @param {*} value The value to assign.
  15962. */
  15963. function assignMergeValue(object, key, value) {
  15964. if ((value !== undefined && !eq(object[key], value)) ||
  15965. (value === undefined && !(key in object))) {
  15966. baseAssignValue(object, key, value);
  15967. }
  15968. }
  15969. /**
  15970. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  15971. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  15972. * for equality comparisons.
  15973. *
  15974. * @private
  15975. * @param {Object} object The object to modify.
  15976. * @param {string} key The key of the property to assign.
  15977. * @param {*} value The value to assign.
  15978. */
  15979. function assignValue(object, key, value) {
  15980. var objValue = object[key];
  15981. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  15982. (value === undefined && !(key in object))) {
  15983. baseAssignValue(object, key, value);
  15984. }
  15985. }
  15986. /**
  15987. * Gets the index at which the `key` is found in `array` of key-value pairs.
  15988. *
  15989. * @private
  15990. * @param {Array} array The array to inspect.
  15991. * @param {*} key The key to search for.
  15992. * @returns {number} Returns the index of the matched value, else `-1`.
  15993. */
  15994. function assocIndexOf(array, key) {
  15995. var length = array.length;
  15996. while (length--) {
  15997. if (eq(array[length][0], key)) {
  15998. return length;
  15999. }
  16000. }
  16001. return -1;
  16002. }
  16003. /**
  16004. * Aggregates elements of `collection` on `accumulator` with keys transformed
  16005. * by `iteratee` and values set by `setter`.
  16006. *
  16007. * @private
  16008. * @param {Array|Object} collection The collection to iterate over.
  16009. * @param {Function} setter The function to set `accumulator` values.
  16010. * @param {Function} iteratee The iteratee to transform keys.
  16011. * @param {Object} accumulator The initial aggregated object.
  16012. * @returns {Function} Returns `accumulator`.
  16013. */
  16014. function baseAggregator(collection, setter, iteratee, accumulator) {
  16015. baseEach(collection, function(value, key, collection) {
  16016. setter(accumulator, value, iteratee(value), collection);
  16017. });
  16018. return accumulator;
  16019. }
  16020. /**
  16021. * The base implementation of `_.assign` without support for multiple sources
  16022. * or `customizer` functions.
  16023. *
  16024. * @private
  16025. * @param {Object} object The destination object.
  16026. * @param {Object} source The source object.
  16027. * @returns {Object} Returns `object`.
  16028. */
  16029. function baseAssign(object, source) {
  16030. return object && copyObject(source, keys(source), object);
  16031. }
  16032. /**
  16033. * The base implementation of `_.assignIn` without support for multiple sources
  16034. * or `customizer` functions.
  16035. *
  16036. * @private
  16037. * @param {Object} object The destination object.
  16038. * @param {Object} source The source object.
  16039. * @returns {Object} Returns `object`.
  16040. */
  16041. function baseAssignIn(object, source) {
  16042. return object && copyObject(source, keysIn(source), object);
  16043. }
  16044. /**
  16045. * The base implementation of `assignValue` and `assignMergeValue` without
  16046. * value checks.
  16047. *
  16048. * @private
  16049. * @param {Object} object The object to modify.
  16050. * @param {string} key The key of the property to assign.
  16051. * @param {*} value The value to assign.
  16052. */
  16053. function baseAssignValue(object, key, value) {
  16054. if (key == '__proto__' && defineProperty) {
  16055. defineProperty(object, key, {
  16056. 'configurable': true,
  16057. 'enumerable': true,
  16058. 'value': value,
  16059. 'writable': true
  16060. });
  16061. } else {
  16062. object[key] = value;
  16063. }
  16064. }
  16065. /**
  16066. * The base implementation of `_.at` without support for individual paths.
  16067. *
  16068. * @private
  16069. * @param {Object} object The object to iterate over.
  16070. * @param {string[]} paths The property paths to pick.
  16071. * @returns {Array} Returns the picked elements.
  16072. */
  16073. function baseAt(object, paths) {
  16074. var index = -1,
  16075. length = paths.length,
  16076. result = Array(length),
  16077. skip = object == null;
  16078. while (++index < length) {
  16079. result[index] = skip ? undefined : get(object, paths[index]);
  16080. }
  16081. return result;
  16082. }
  16083. /**
  16084. * The base implementation of `_.clamp` which doesn't coerce arguments.
  16085. *
  16086. * @private
  16087. * @param {number} number The number to clamp.
  16088. * @param {number} [lower] The lower bound.
  16089. * @param {number} upper The upper bound.
  16090. * @returns {number} Returns the clamped number.
  16091. */
  16092. function baseClamp(number, lower, upper) {
  16093. if (number === number) {
  16094. if (upper !== undefined) {
  16095. number = number <= upper ? number : upper;
  16096. }
  16097. if (lower !== undefined) {
  16098. number = number >= lower ? number : lower;
  16099. }
  16100. }
  16101. return number;
  16102. }
  16103. /**
  16104. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  16105. * traversed objects.
  16106. *
  16107. * @private
  16108. * @param {*} value The value to clone.
  16109. * @param {boolean} bitmask The bitmask flags.
  16110. * 1 - Deep clone
  16111. * 2 - Flatten inherited properties
  16112. * 4 - Clone symbols
  16113. * @param {Function} [customizer] The function to customize cloning.
  16114. * @param {string} [key] The key of `value`.
  16115. * @param {Object} [object] The parent object of `value`.
  16116. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  16117. * @returns {*} Returns the cloned value.
  16118. */
  16119. function baseClone(value, bitmask, customizer, key, object, stack) {
  16120. var result,
  16121. isDeep = bitmask & CLONE_DEEP_FLAG,
  16122. isFlat = bitmask & CLONE_FLAT_FLAG,
  16123. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  16124. if (customizer) {
  16125. result = object ? customizer(value, key, object, stack) : customizer(value);
  16126. }
  16127. if (result !== undefined) {
  16128. return result;
  16129. }
  16130. if (!isObject(value)) {
  16131. return value;
  16132. }
  16133. var isArr = isArray(value);
  16134. if (isArr) {
  16135. result = initCloneArray(value);
  16136. if (!isDeep) {
  16137. return copyArray(value, result);
  16138. }
  16139. } else {
  16140. var tag = getTag(value),
  16141. isFunc = tag == funcTag || tag == genTag;
  16142. if (isBuffer(value)) {
  16143. return cloneBuffer(value, isDeep);
  16144. }
  16145. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  16146. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  16147. if (!isDeep) {
  16148. return isFlat
  16149. ? copySymbolsIn(value, baseAssignIn(result, value))
  16150. : copySymbols(value, baseAssign(result, value));
  16151. }
  16152. } else {
  16153. if (!cloneableTags[tag]) {
  16154. return object ? value : {};
  16155. }
  16156. result = initCloneByTag(value, tag, isDeep);
  16157. }
  16158. }
  16159. // Check for circular references and return its corresponding clone.
  16160. stack || (stack = new Stack);
  16161. var stacked = stack.get(value);
  16162. if (stacked) {
  16163. return stacked;
  16164. }
  16165. stack.set(value, result);
  16166. if (isSet(value)) {
  16167. value.forEach(function(subValue) {
  16168. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  16169. });
  16170. } else if (isMap(value)) {
  16171. value.forEach(function(subValue, key) {
  16172. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  16173. });
  16174. }
  16175. var keysFunc = isFull
  16176. ? (isFlat ? getAllKeysIn : getAllKeys)
  16177. : (isFlat ? keysIn : keys);
  16178. var props = isArr ? undefined : keysFunc(value);
  16179. arrayEach(props || value, function(subValue, key) {
  16180. if (props) {
  16181. key = subValue;
  16182. subValue = value[key];
  16183. }
  16184. // Recursively populate clone (susceptible to call stack limits).
  16185. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  16186. });
  16187. return result;
  16188. }
  16189. /**
  16190. * The base implementation of `_.conforms` which doesn't clone `source`.
  16191. *
  16192. * @private
  16193. * @param {Object} source The object of property predicates to conform to.
  16194. * @returns {Function} Returns the new spec function.
  16195. */
  16196. function baseConforms(source) {
  16197. var props = keys(source);
  16198. return function(object) {
  16199. return baseConformsTo(object, source, props);
  16200. };
  16201. }
  16202. /**
  16203. * The base implementation of `_.conformsTo` which accepts `props` to check.
  16204. *
  16205. * @private
  16206. * @param {Object} object The object to inspect.
  16207. * @param {Object} source The object of property predicates to conform to.
  16208. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  16209. */
  16210. function baseConformsTo(object, source, props) {
  16211. var length = props.length;
  16212. if (object == null) {
  16213. return !length;
  16214. }
  16215. object = Object(object);
  16216. while (length--) {
  16217. var key = props[length],
  16218. predicate = source[key],
  16219. value = object[key];
  16220. if ((value === undefined && !(key in object)) || !predicate(value)) {
  16221. return false;
  16222. }
  16223. }
  16224. return true;
  16225. }
  16226. /**
  16227. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  16228. * to provide to `func`.
  16229. *
  16230. * @private
  16231. * @param {Function} func The function to delay.
  16232. * @param {number} wait The number of milliseconds to delay invocation.
  16233. * @param {Array} args The arguments to provide to `func`.
  16234. * @returns {number|Object} Returns the timer id or timeout object.
  16235. */
  16236. function baseDelay(func, wait, args) {
  16237. if (typeof func != 'function') {
  16238. throw new TypeError(FUNC_ERROR_TEXT);
  16239. }
  16240. return setTimeout(function() { func.apply(undefined, args); }, wait);
  16241. }
  16242. /**
  16243. * The base implementation of methods like `_.difference` without support
  16244. * for excluding multiple arrays or iteratee shorthands.
  16245. *
  16246. * @private
  16247. * @param {Array} array The array to inspect.
  16248. * @param {Array} values The values to exclude.
  16249. * @param {Function} [iteratee] The iteratee invoked per element.
  16250. * @param {Function} [comparator] The comparator invoked per element.
  16251. * @returns {Array} Returns the new array of filtered values.
  16252. */
  16253. function baseDifference(array, values, iteratee, comparator) {
  16254. var index = -1,
  16255. includes = arrayIncludes,
  16256. isCommon = true,
  16257. length = array.length,
  16258. result = [],
  16259. valuesLength = values.length;
  16260. if (!length) {
  16261. return result;
  16262. }
  16263. if (iteratee) {
  16264. values = arrayMap(values, baseUnary(iteratee));
  16265. }
  16266. if (comparator) {
  16267. includes = arrayIncludesWith;
  16268. isCommon = false;
  16269. }
  16270. else if (values.length >= LARGE_ARRAY_SIZE) {
  16271. includes = cacheHas;
  16272. isCommon = false;
  16273. values = new SetCache(values);
  16274. }
  16275. outer:
  16276. while (++index < length) {
  16277. var value = array[index],
  16278. computed = iteratee == null ? value : iteratee(value);
  16279. value = (comparator || value !== 0) ? value : 0;
  16280. if (isCommon && computed === computed) {
  16281. var valuesIndex = valuesLength;
  16282. while (valuesIndex--) {
  16283. if (values[valuesIndex] === computed) {
  16284. continue outer;
  16285. }
  16286. }
  16287. result.push(value);
  16288. }
  16289. else if (!includes(values, computed, comparator)) {
  16290. result.push(value);
  16291. }
  16292. }
  16293. return result;
  16294. }
  16295. /**
  16296. * The base implementation of `_.forEach` without support for iteratee shorthands.
  16297. *
  16298. * @private
  16299. * @param {Array|Object} collection The collection to iterate over.
  16300. * @param {Function} iteratee The function invoked per iteration.
  16301. * @returns {Array|Object} Returns `collection`.
  16302. */
  16303. var baseEach = createBaseEach(baseForOwn);
  16304. /**
  16305. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  16306. *
  16307. * @private
  16308. * @param {Array|Object} collection The collection to iterate over.
  16309. * @param {Function} iteratee The function invoked per iteration.
  16310. * @returns {Array|Object} Returns `collection`.
  16311. */
  16312. var baseEachRight = createBaseEach(baseForOwnRight, true);
  16313. /**
  16314. * The base implementation of `_.every` without support for iteratee shorthands.
  16315. *
  16316. * @private
  16317. * @param {Array|Object} collection The collection to iterate over.
  16318. * @param {Function} predicate The function invoked per iteration.
  16319. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  16320. * else `false`
  16321. */
  16322. function baseEvery(collection, predicate) {
  16323. var result = true;
  16324. baseEach(collection, function(value, index, collection) {
  16325. result = !!predicate(value, index, collection);
  16326. return result;
  16327. });
  16328. return result;
  16329. }
  16330. /**
  16331. * The base implementation of methods like `_.max` and `_.min` which accepts a
  16332. * `comparator` to determine the extremum value.
  16333. *
  16334. * @private
  16335. * @param {Array} array The array to iterate over.
  16336. * @param {Function} iteratee The iteratee invoked per iteration.
  16337. * @param {Function} comparator The comparator used to compare values.
  16338. * @returns {*} Returns the extremum value.
  16339. */
  16340. function baseExtremum(array, iteratee, comparator) {
  16341. var index = -1,
  16342. length = array.length;
  16343. while (++index < length) {
  16344. var value = array[index],
  16345. current = iteratee(value);
  16346. if (current != null && (computed === undefined
  16347. ? (current === current && !isSymbol(current))
  16348. : comparator(current, computed)
  16349. )) {
  16350. var computed = current,
  16351. result = value;
  16352. }
  16353. }
  16354. return result;
  16355. }
  16356. /**
  16357. * The base implementation of `_.fill` without an iteratee call guard.
  16358. *
  16359. * @private
  16360. * @param {Array} array The array to fill.
  16361. * @param {*} value The value to fill `array` with.
  16362. * @param {number} [start=0] The start position.
  16363. * @param {number} [end=array.length] The end position.
  16364. * @returns {Array} Returns `array`.
  16365. */
  16366. function baseFill(array, value, start, end) {
  16367. var length = array.length;
  16368. start = toInteger(start);
  16369. if (start < 0) {
  16370. start = -start > length ? 0 : (length + start);
  16371. }
  16372. end = (end === undefined || end > length) ? length : toInteger(end);
  16373. if (end < 0) {
  16374. end += length;
  16375. }
  16376. end = start > end ? 0 : toLength(end);
  16377. while (start < end) {
  16378. array[start++] = value;
  16379. }
  16380. return array;
  16381. }
  16382. /**
  16383. * The base implementation of `_.filter` without support for iteratee shorthands.
  16384. *
  16385. * @private
  16386. * @param {Array|Object} collection The collection to iterate over.
  16387. * @param {Function} predicate The function invoked per iteration.
  16388. * @returns {Array} Returns the new filtered array.
  16389. */
  16390. function baseFilter(collection, predicate) {
  16391. var result = [];
  16392. baseEach(collection, function(value, index, collection) {
  16393. if (predicate(value, index, collection)) {
  16394. result.push(value);
  16395. }
  16396. });
  16397. return result;
  16398. }
  16399. /**
  16400. * The base implementation of `_.flatten` with support for restricting flattening.
  16401. *
  16402. * @private
  16403. * @param {Array} array The array to flatten.
  16404. * @param {number} depth The maximum recursion depth.
  16405. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  16406. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  16407. * @param {Array} [result=[]] The initial result value.
  16408. * @returns {Array} Returns the new flattened array.
  16409. */
  16410. function baseFlatten(array, depth, predicate, isStrict, result) {
  16411. var index = -1,
  16412. length = array.length;
  16413. predicate || (predicate = isFlattenable);
  16414. result || (result = []);
  16415. while (++index < length) {
  16416. var value = array[index];
  16417. if (depth > 0 && predicate(value)) {
  16418. if (depth > 1) {
  16419. // Recursively flatten arrays (susceptible to call stack limits).
  16420. baseFlatten(value, depth - 1, predicate, isStrict, result);
  16421. } else {
  16422. arrayPush(result, value);
  16423. }
  16424. } else if (!isStrict) {
  16425. result[result.length] = value;
  16426. }
  16427. }
  16428. return result;
  16429. }
  16430. /**
  16431. * The base implementation of `baseForOwn` which iterates over `object`
  16432. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  16433. * Iteratee functions may exit iteration early by explicitly returning `false`.
  16434. *
  16435. * @private
  16436. * @param {Object} object The object to iterate over.
  16437. * @param {Function} iteratee The function invoked per iteration.
  16438. * @param {Function} keysFunc The function to get the keys of `object`.
  16439. * @returns {Object} Returns `object`.
  16440. */
  16441. var baseFor = createBaseFor();
  16442. /**
  16443. * This function is like `baseFor` except that it iterates over properties
  16444. * in the opposite order.
  16445. *
  16446. * @private
  16447. * @param {Object} object The object to iterate over.
  16448. * @param {Function} iteratee The function invoked per iteration.
  16449. * @param {Function} keysFunc The function to get the keys of `object`.
  16450. * @returns {Object} Returns `object`.
  16451. */
  16452. var baseForRight = createBaseFor(true);
  16453. /**
  16454. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  16455. *
  16456. * @private
  16457. * @param {Object} object The object to iterate over.
  16458. * @param {Function} iteratee The function invoked per iteration.
  16459. * @returns {Object} Returns `object`.
  16460. */
  16461. function baseForOwn(object, iteratee) {
  16462. return object && baseFor(object, iteratee, keys);
  16463. }
  16464. /**
  16465. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  16466. *
  16467. * @private
  16468. * @param {Object} object The object to iterate over.
  16469. * @param {Function} iteratee The function invoked per iteration.
  16470. * @returns {Object} Returns `object`.
  16471. */
  16472. function baseForOwnRight(object, iteratee) {
  16473. return object && baseForRight(object, iteratee, keys);
  16474. }
  16475. /**
  16476. * The base implementation of `_.functions` which creates an array of
  16477. * `object` function property names filtered from `props`.
  16478. *
  16479. * @private
  16480. * @param {Object} object The object to inspect.
  16481. * @param {Array} props The property names to filter.
  16482. * @returns {Array} Returns the function names.
  16483. */
  16484. function baseFunctions(object, props) {
  16485. return arrayFilter(props, function(key) {
  16486. return isFunction(object[key]);
  16487. });
  16488. }
  16489. /**
  16490. * The base implementation of `_.get` without support for default values.
  16491. *
  16492. * @private
  16493. * @param {Object} object The object to query.
  16494. * @param {Array|string} path The path of the property to get.
  16495. * @returns {*} Returns the resolved value.
  16496. */
  16497. function baseGet(object, path) {
  16498. path = castPath(path, object);
  16499. var index = 0,
  16500. length = path.length;
  16501. while (object != null && index < length) {
  16502. object = object[toKey(path[index++])];
  16503. }
  16504. return (index && index == length) ? object : undefined;
  16505. }
  16506. /**
  16507. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  16508. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  16509. * symbols of `object`.
  16510. *
  16511. * @private
  16512. * @param {Object} object The object to query.
  16513. * @param {Function} keysFunc The function to get the keys of `object`.
  16514. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  16515. * @returns {Array} Returns the array of property names and symbols.
  16516. */
  16517. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  16518. var result = keysFunc(object);
  16519. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  16520. }
  16521. /**
  16522. * The base implementation of `getTag` without fallbacks for buggy environments.
  16523. *
  16524. * @private
  16525. * @param {*} value The value to query.
  16526. * @returns {string} Returns the `toStringTag`.
  16527. */
  16528. function baseGetTag(value) {
  16529. if (value == null) {
  16530. return value === undefined ? undefinedTag : nullTag;
  16531. }
  16532. return (symToStringTag && symToStringTag in Object(value))
  16533. ? getRawTag(value)
  16534. : objectToString(value);
  16535. }
  16536. /**
  16537. * The base implementation of `_.gt` which doesn't coerce arguments.
  16538. *
  16539. * @private
  16540. * @param {*} value The value to compare.
  16541. * @param {*} other The other value to compare.
  16542. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  16543. * else `false`.
  16544. */
  16545. function baseGt(value, other) {
  16546. return value > other;
  16547. }
  16548. /**
  16549. * The base implementation of `_.has` without support for deep paths.
  16550. *
  16551. * @private
  16552. * @param {Object} [object] The object to query.
  16553. * @param {Array|string} key The key to check.
  16554. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  16555. */
  16556. function baseHas(object, key) {
  16557. return object != null && hasOwnProperty.call(object, key);
  16558. }
  16559. /**
  16560. * The base implementation of `_.hasIn` without support for deep paths.
  16561. *
  16562. * @private
  16563. * @param {Object} [object] The object to query.
  16564. * @param {Array|string} key The key to check.
  16565. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  16566. */
  16567. function baseHasIn(object, key) {
  16568. return object != null && key in Object(object);
  16569. }
  16570. /**
  16571. * The base implementation of `_.inRange` which doesn't coerce arguments.
  16572. *
  16573. * @private
  16574. * @param {number} number The number to check.
  16575. * @param {number} start The start of the range.
  16576. * @param {number} end The end of the range.
  16577. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  16578. */
  16579. function baseInRange(number, start, end) {
  16580. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  16581. }
  16582. /**
  16583. * The base implementation of methods like `_.intersection`, without support
  16584. * for iteratee shorthands, that accepts an array of arrays to inspect.
  16585. *
  16586. * @private
  16587. * @param {Array} arrays The arrays to inspect.
  16588. * @param {Function} [iteratee] The iteratee invoked per element.
  16589. * @param {Function} [comparator] The comparator invoked per element.
  16590. * @returns {Array} Returns the new array of shared values.
  16591. */
  16592. function baseIntersection(arrays, iteratee, comparator) {
  16593. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  16594. length = arrays[0].length,
  16595. othLength = arrays.length,
  16596. othIndex = othLength,
  16597. caches = Array(othLength),
  16598. maxLength = Infinity,
  16599. result = [];
  16600. while (othIndex--) {
  16601. var array = arrays[othIndex];
  16602. if (othIndex && iteratee) {
  16603. array = arrayMap(array, baseUnary(iteratee));
  16604. }
  16605. maxLength = nativeMin(array.length, maxLength);
  16606. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  16607. ? new SetCache(othIndex && array)
  16608. : undefined;
  16609. }
  16610. array = arrays[0];
  16611. var index = -1,
  16612. seen = caches[0];
  16613. outer:
  16614. while (++index < length && result.length < maxLength) {
  16615. var value = array[index],
  16616. computed = iteratee ? iteratee(value) : value;
  16617. value = (comparator || value !== 0) ? value : 0;
  16618. if (!(seen
  16619. ? cacheHas(seen, computed)
  16620. : includes(result, computed, comparator)
  16621. )) {
  16622. othIndex = othLength;
  16623. while (--othIndex) {
  16624. var cache = caches[othIndex];
  16625. if (!(cache
  16626. ? cacheHas(cache, computed)
  16627. : includes(arrays[othIndex], computed, comparator))
  16628. ) {
  16629. continue outer;
  16630. }
  16631. }
  16632. if (seen) {
  16633. seen.push(computed);
  16634. }
  16635. result.push(value);
  16636. }
  16637. }
  16638. return result;
  16639. }
  16640. /**
  16641. * The base implementation of `_.invert` and `_.invertBy` which inverts
  16642. * `object` with values transformed by `iteratee` and set by `setter`.
  16643. *
  16644. * @private
  16645. * @param {Object} object The object to iterate over.
  16646. * @param {Function} setter The function to set `accumulator` values.
  16647. * @param {Function} iteratee The iteratee to transform values.
  16648. * @param {Object} accumulator The initial inverted object.
  16649. * @returns {Function} Returns `accumulator`.
  16650. */
  16651. function baseInverter(object, setter, iteratee, accumulator) {
  16652. baseForOwn(object, function(value, key, object) {
  16653. setter(accumulator, iteratee(value), key, object);
  16654. });
  16655. return accumulator;
  16656. }
  16657. /**
  16658. * The base implementation of `_.invoke` without support for individual
  16659. * method arguments.
  16660. *
  16661. * @private
  16662. * @param {Object} object The object to query.
  16663. * @param {Array|string} path The path of the method to invoke.
  16664. * @param {Array} args The arguments to invoke the method with.
  16665. * @returns {*} Returns the result of the invoked method.
  16666. */
  16667. function baseInvoke(object, path, args) {
  16668. path = castPath(path, object);
  16669. object = parent(object, path);
  16670. var func = object == null ? object : object[toKey(last(path))];
  16671. return func == null ? undefined : apply(func, object, args);
  16672. }
  16673. /**
  16674. * The base implementation of `_.isArguments`.
  16675. *
  16676. * @private
  16677. * @param {*} value The value to check.
  16678. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  16679. */
  16680. function baseIsArguments(value) {
  16681. return isObjectLike(value) && baseGetTag(value) == argsTag;
  16682. }
  16683. /**
  16684. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  16685. *
  16686. * @private
  16687. * @param {*} value The value to check.
  16688. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  16689. */
  16690. function baseIsArrayBuffer(value) {
  16691. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  16692. }
  16693. /**
  16694. * The base implementation of `_.isDate` without Node.js optimizations.
  16695. *
  16696. * @private
  16697. * @param {*} value The value to check.
  16698. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  16699. */
  16700. function baseIsDate(value) {
  16701. return isObjectLike(value) && baseGetTag(value) == dateTag;
  16702. }
  16703. /**
  16704. * The base implementation of `_.isEqual` which supports partial comparisons
  16705. * and tracks traversed objects.
  16706. *
  16707. * @private
  16708. * @param {*} value The value to compare.
  16709. * @param {*} other The other value to compare.
  16710. * @param {boolean} bitmask The bitmask flags.
  16711. * 1 - Unordered comparison
  16712. * 2 - Partial comparison
  16713. * @param {Function} [customizer] The function to customize comparisons.
  16714. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  16715. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  16716. */
  16717. function baseIsEqual(value, other, bitmask, customizer, stack) {
  16718. if (value === other) {
  16719. return true;
  16720. }
  16721. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  16722. return value !== value && other !== other;
  16723. }
  16724. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  16725. }
  16726. /**
  16727. * A specialized version of `baseIsEqual` for arrays and objects which performs
  16728. * deep comparisons and tracks traversed objects enabling objects with circular
  16729. * references to be compared.
  16730. *
  16731. * @private
  16732. * @param {Object} object The object to compare.
  16733. * @param {Object} other The other object to compare.
  16734. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  16735. * @param {Function} customizer The function to customize comparisons.
  16736. * @param {Function} equalFunc The function to determine equivalents of values.
  16737. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  16738. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  16739. */
  16740. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  16741. var objIsArr = isArray(object),
  16742. othIsArr = isArray(other),
  16743. objTag = objIsArr ? arrayTag : getTag(object),
  16744. othTag = othIsArr ? arrayTag : getTag(other);
  16745. objTag = objTag == argsTag ? objectTag : objTag;
  16746. othTag = othTag == argsTag ? objectTag : othTag;
  16747. var objIsObj = objTag == objectTag,
  16748. othIsObj = othTag == objectTag,
  16749. isSameTag = objTag == othTag;
  16750. if (isSameTag && isBuffer(object)) {
  16751. if (!isBuffer(other)) {
  16752. return false;
  16753. }
  16754. objIsArr = true;
  16755. objIsObj = false;
  16756. }
  16757. if (isSameTag && !objIsObj) {
  16758. stack || (stack = new Stack);
  16759. return (objIsArr || isTypedArray(object))
  16760. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  16761. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  16762. }
  16763. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  16764. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  16765. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  16766. if (objIsWrapped || othIsWrapped) {
  16767. var objUnwrapped = objIsWrapped ? object.value() : object,
  16768. othUnwrapped = othIsWrapped ? other.value() : other;
  16769. stack || (stack = new Stack);
  16770. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  16771. }
  16772. }
  16773. if (!isSameTag) {
  16774. return false;
  16775. }
  16776. stack || (stack = new Stack);
  16777. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  16778. }
  16779. /**
  16780. * The base implementation of `_.isMap` without Node.js optimizations.
  16781. *
  16782. * @private
  16783. * @param {*} value The value to check.
  16784. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  16785. */
  16786. function baseIsMap(value) {
  16787. return isObjectLike(value) && getTag(value) == mapTag;
  16788. }
  16789. /**
  16790. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  16791. *
  16792. * @private
  16793. * @param {Object} object The object to inspect.
  16794. * @param {Object} source The object of property values to match.
  16795. * @param {Array} matchData The property names, values, and compare flags to match.
  16796. * @param {Function} [customizer] The function to customize comparisons.
  16797. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  16798. */
  16799. function baseIsMatch(object, source, matchData, customizer) {
  16800. var index = matchData.length,
  16801. length = index,
  16802. noCustomizer = !customizer;
  16803. if (object == null) {
  16804. return !length;
  16805. }
  16806. object = Object(object);
  16807. while (index--) {
  16808. var data = matchData[index];
  16809. if ((noCustomizer && data[2])
  16810. ? data[1] !== object[data[0]]
  16811. : !(data[0] in object)
  16812. ) {
  16813. return false;
  16814. }
  16815. }
  16816. while (++index < length) {
  16817. data = matchData[index];
  16818. var key = data[0],
  16819. objValue = object[key],
  16820. srcValue = data[1];
  16821. if (noCustomizer && data[2]) {
  16822. if (objValue === undefined && !(key in object)) {
  16823. return false;
  16824. }
  16825. } else {
  16826. var stack = new Stack;
  16827. if (customizer) {
  16828. var result = customizer(objValue, srcValue, key, object, source, stack);
  16829. }
  16830. if (!(result === undefined
  16831. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  16832. : result
  16833. )) {
  16834. return false;
  16835. }
  16836. }
  16837. }
  16838. return true;
  16839. }
  16840. /**
  16841. * The base implementation of `_.isNative` without bad shim checks.
  16842. *
  16843. * @private
  16844. * @param {*} value The value to check.
  16845. * @returns {boolean} Returns `true` if `value` is a native function,
  16846. * else `false`.
  16847. */
  16848. function baseIsNative(value) {
  16849. if (!isObject(value) || isMasked(value)) {
  16850. return false;
  16851. }
  16852. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  16853. return pattern.test(toSource(value));
  16854. }
  16855. /**
  16856. * The base implementation of `_.isRegExp` without Node.js optimizations.
  16857. *
  16858. * @private
  16859. * @param {*} value The value to check.
  16860. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  16861. */
  16862. function baseIsRegExp(value) {
  16863. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  16864. }
  16865. /**
  16866. * The base implementation of `_.isSet` without Node.js optimizations.
  16867. *
  16868. * @private
  16869. * @param {*} value The value to check.
  16870. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  16871. */
  16872. function baseIsSet(value) {
  16873. return isObjectLike(value) && getTag(value) == setTag;
  16874. }
  16875. /**
  16876. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  16877. *
  16878. * @private
  16879. * @param {*} value The value to check.
  16880. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  16881. */
  16882. function baseIsTypedArray(value) {
  16883. return isObjectLike(value) &&
  16884. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  16885. }
  16886. /**
  16887. * The base implementation of `_.iteratee`.
  16888. *
  16889. * @private
  16890. * @param {*} [value=_.identity] The value to convert to an iteratee.
  16891. * @returns {Function} Returns the iteratee.
  16892. */
  16893. function baseIteratee(value) {
  16894. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  16895. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  16896. if (typeof value == 'function') {
  16897. return value;
  16898. }
  16899. if (value == null) {
  16900. return identity;
  16901. }
  16902. if (typeof value == 'object') {
  16903. return isArray(value)
  16904. ? baseMatchesProperty(value[0], value[1])
  16905. : baseMatches(value);
  16906. }
  16907. return property(value);
  16908. }
  16909. /**
  16910. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  16911. *
  16912. * @private
  16913. * @param {Object} object The object to query.
  16914. * @returns {Array} Returns the array of property names.
  16915. */
  16916. function baseKeys(object) {
  16917. if (!isPrototype(object)) {
  16918. return nativeKeys(object);
  16919. }
  16920. var result = [];
  16921. for (var key in Object(object)) {
  16922. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  16923. result.push(key);
  16924. }
  16925. }
  16926. return result;
  16927. }
  16928. /**
  16929. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  16930. *
  16931. * @private
  16932. * @param {Object} object The object to query.
  16933. * @returns {Array} Returns the array of property names.
  16934. */
  16935. function baseKeysIn(object) {
  16936. if (!isObject(object)) {
  16937. return nativeKeysIn(object);
  16938. }
  16939. var isProto = isPrototype(object),
  16940. result = [];
  16941. for (var key in object) {
  16942. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  16943. result.push(key);
  16944. }
  16945. }
  16946. return result;
  16947. }
  16948. /**
  16949. * The base implementation of `_.lt` which doesn't coerce arguments.
  16950. *
  16951. * @private
  16952. * @param {*} value The value to compare.
  16953. * @param {*} other The other value to compare.
  16954. * @returns {boolean} Returns `true` if `value` is less than `other`,
  16955. * else `false`.
  16956. */
  16957. function baseLt(value, other) {
  16958. return value < other;
  16959. }
  16960. /**
  16961. * The base implementation of `_.map` without support for iteratee shorthands.
  16962. *
  16963. * @private
  16964. * @param {Array|Object} collection The collection to iterate over.
  16965. * @param {Function} iteratee The function invoked per iteration.
  16966. * @returns {Array} Returns the new mapped array.
  16967. */
  16968. function baseMap(collection, iteratee) {
  16969. var index = -1,
  16970. result = isArrayLike(collection) ? Array(collection.length) : [];
  16971. baseEach(collection, function(value, key, collection) {
  16972. result[++index] = iteratee(value, key, collection);
  16973. });
  16974. return result;
  16975. }
  16976. /**
  16977. * The base implementation of `_.matches` which doesn't clone `source`.
  16978. *
  16979. * @private
  16980. * @param {Object} source The object of property values to match.
  16981. * @returns {Function} Returns the new spec function.
  16982. */
  16983. function baseMatches(source) {
  16984. var matchData = getMatchData(source);
  16985. if (matchData.length == 1 && matchData[0][2]) {
  16986. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  16987. }
  16988. return function(object) {
  16989. return object === source || baseIsMatch(object, source, matchData);
  16990. };
  16991. }
  16992. /**
  16993. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  16994. *
  16995. * @private
  16996. * @param {string} path The path of the property to get.
  16997. * @param {*} srcValue The value to match.
  16998. * @returns {Function} Returns the new spec function.
  16999. */
  17000. function baseMatchesProperty(path, srcValue) {
  17001. if (isKey(path) && isStrictComparable(srcValue)) {
  17002. return matchesStrictComparable(toKey(path), srcValue);
  17003. }
  17004. return function(object) {
  17005. var objValue = get(object, path);
  17006. return (objValue === undefined && objValue === srcValue)
  17007. ? hasIn(object, path)
  17008. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  17009. };
  17010. }
  17011. /**
  17012. * The base implementation of `_.merge` without support for multiple sources.
  17013. *
  17014. * @private
  17015. * @param {Object} object The destination object.
  17016. * @param {Object} source The source object.
  17017. * @param {number} srcIndex The index of `source`.
  17018. * @param {Function} [customizer] The function to customize merged values.
  17019. * @param {Object} [stack] Tracks traversed source values and their merged
  17020. * counterparts.
  17021. */
  17022. function baseMerge(object, source, srcIndex, customizer, stack) {
  17023. if (object === source) {
  17024. return;
  17025. }
  17026. baseFor(source, function(srcValue, key) {
  17027. stack || (stack = new Stack);
  17028. if (isObject(srcValue)) {
  17029. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  17030. }
  17031. else {
  17032. var newValue = customizer
  17033. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  17034. : undefined;
  17035. if (newValue === undefined) {
  17036. newValue = srcValue;
  17037. }
  17038. assignMergeValue(object, key, newValue);
  17039. }
  17040. }, keysIn);
  17041. }
  17042. /**
  17043. * A specialized version of `baseMerge` for arrays and objects which performs
  17044. * deep merges and tracks traversed objects enabling objects with circular
  17045. * references to be merged.
  17046. *
  17047. * @private
  17048. * @param {Object} object The destination object.
  17049. * @param {Object} source The source object.
  17050. * @param {string} key The key of the value to merge.
  17051. * @param {number} srcIndex The index of `source`.
  17052. * @param {Function} mergeFunc The function to merge values.
  17053. * @param {Function} [customizer] The function to customize assigned values.
  17054. * @param {Object} [stack] Tracks traversed source values and their merged
  17055. * counterparts.
  17056. */
  17057. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  17058. var objValue = safeGet(object, key),
  17059. srcValue = safeGet(source, key),
  17060. stacked = stack.get(srcValue);
  17061. if (stacked) {
  17062. assignMergeValue(object, key, stacked);
  17063. return;
  17064. }
  17065. var newValue = customizer
  17066. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  17067. : undefined;
  17068. var isCommon = newValue === undefined;
  17069. if (isCommon) {
  17070. var isArr = isArray(srcValue),
  17071. isBuff = !isArr && isBuffer(srcValue),
  17072. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  17073. newValue = srcValue;
  17074. if (isArr || isBuff || isTyped) {
  17075. if (isArray(objValue)) {
  17076. newValue = objValue;
  17077. }
  17078. else if (isArrayLikeObject(objValue)) {
  17079. newValue = copyArray(objValue);
  17080. }
  17081. else if (isBuff) {
  17082. isCommon = false;
  17083. newValue = cloneBuffer(srcValue, true);
  17084. }
  17085. else if (isTyped) {
  17086. isCommon = false;
  17087. newValue = cloneTypedArray(srcValue, true);
  17088. }
  17089. else {
  17090. newValue = [];
  17091. }
  17092. }
  17093. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  17094. newValue = objValue;
  17095. if (isArguments(objValue)) {
  17096. newValue = toPlainObject(objValue);
  17097. }
  17098. else if (!isObject(objValue) || isFunction(objValue)) {
  17099. newValue = initCloneObject(srcValue);
  17100. }
  17101. }
  17102. else {
  17103. isCommon = false;
  17104. }
  17105. }
  17106. if (isCommon) {
  17107. // Recursively merge objects and arrays (susceptible to call stack limits).
  17108. stack.set(srcValue, newValue);
  17109. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  17110. stack['delete'](srcValue);
  17111. }
  17112. assignMergeValue(object, key, newValue);
  17113. }
  17114. /**
  17115. * The base implementation of `_.nth` which doesn't coerce arguments.
  17116. *
  17117. * @private
  17118. * @param {Array} array The array to query.
  17119. * @param {number} n The index of the element to return.
  17120. * @returns {*} Returns the nth element of `array`.
  17121. */
  17122. function baseNth(array, n) {
  17123. var length = array.length;
  17124. if (!length) {
  17125. return;
  17126. }
  17127. n += n < 0 ? length : 0;
  17128. return isIndex(n, length) ? array[n] : undefined;
  17129. }
  17130. /**
  17131. * The base implementation of `_.orderBy` without param guards.
  17132. *
  17133. * @private
  17134. * @param {Array|Object} collection The collection to iterate over.
  17135. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  17136. * @param {string[]} orders The sort orders of `iteratees`.
  17137. * @returns {Array} Returns the new sorted array.
  17138. */
  17139. function baseOrderBy(collection, iteratees, orders) {
  17140. var index = -1;
  17141. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  17142. var result = baseMap(collection, function(value, key, collection) {
  17143. var criteria = arrayMap(iteratees, function(iteratee) {
  17144. return iteratee(value);
  17145. });
  17146. return { 'criteria': criteria, 'index': ++index, 'value': value };
  17147. });
  17148. return baseSortBy(result, function(object, other) {
  17149. return compareMultiple(object, other, orders);
  17150. });
  17151. }
  17152. /**
  17153. * The base implementation of `_.pick` without support for individual
  17154. * property identifiers.
  17155. *
  17156. * @private
  17157. * @param {Object} object The source object.
  17158. * @param {string[]} paths The property paths to pick.
  17159. * @returns {Object} Returns the new object.
  17160. */
  17161. function basePick(object, paths) {
  17162. return basePickBy(object, paths, function(value, path) {
  17163. return hasIn(object, path);
  17164. });
  17165. }
  17166. /**
  17167. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  17168. *
  17169. * @private
  17170. * @param {Object} object The source object.
  17171. * @param {string[]} paths The property paths to pick.
  17172. * @param {Function} predicate The function invoked per property.
  17173. * @returns {Object} Returns the new object.
  17174. */
  17175. function basePickBy(object, paths, predicate) {
  17176. var index = -1,
  17177. length = paths.length,
  17178. result = {};
  17179. while (++index < length) {
  17180. var path = paths[index],
  17181. value = baseGet(object, path);
  17182. if (predicate(value, path)) {
  17183. baseSet(result, castPath(path, object), value);
  17184. }
  17185. }
  17186. return result;
  17187. }
  17188. /**
  17189. * A specialized version of `baseProperty` which supports deep paths.
  17190. *
  17191. * @private
  17192. * @param {Array|string} path The path of the property to get.
  17193. * @returns {Function} Returns the new accessor function.
  17194. */
  17195. function basePropertyDeep(path) {
  17196. return function(object) {
  17197. return baseGet(object, path);
  17198. };
  17199. }
  17200. /**
  17201. * The base implementation of `_.pullAllBy` without support for iteratee
  17202. * shorthands.
  17203. *
  17204. * @private
  17205. * @param {Array} array The array to modify.
  17206. * @param {Array} values The values to remove.
  17207. * @param {Function} [iteratee] The iteratee invoked per element.
  17208. * @param {Function} [comparator] The comparator invoked per element.
  17209. * @returns {Array} Returns `array`.
  17210. */
  17211. function basePullAll(array, values, iteratee, comparator) {
  17212. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  17213. index = -1,
  17214. length = values.length,
  17215. seen = array;
  17216. if (array === values) {
  17217. values = copyArray(values);
  17218. }
  17219. if (iteratee) {
  17220. seen = arrayMap(array, baseUnary(iteratee));
  17221. }
  17222. while (++index < length) {
  17223. var fromIndex = 0,
  17224. value = values[index],
  17225. computed = iteratee ? iteratee(value) : value;
  17226. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  17227. if (seen !== array) {
  17228. splice.call(seen, fromIndex, 1);
  17229. }
  17230. splice.call(array, fromIndex, 1);
  17231. }
  17232. }
  17233. return array;
  17234. }
  17235. /**
  17236. * The base implementation of `_.pullAt` without support for individual
  17237. * indexes or capturing the removed elements.
  17238. *
  17239. * @private
  17240. * @param {Array} array The array to modify.
  17241. * @param {number[]} indexes The indexes of elements to remove.
  17242. * @returns {Array} Returns `array`.
  17243. */
  17244. function basePullAt(array, indexes) {
  17245. var length = array ? indexes.length : 0,
  17246. lastIndex = length - 1;
  17247. while (length--) {
  17248. var index = indexes[length];
  17249. if (length == lastIndex || index !== previous) {
  17250. var previous = index;
  17251. if (isIndex(index)) {
  17252. splice.call(array, index, 1);
  17253. } else {
  17254. baseUnset(array, index);
  17255. }
  17256. }
  17257. }
  17258. return array;
  17259. }
  17260. /**
  17261. * The base implementation of `_.random` without support for returning
  17262. * floating-point numbers.
  17263. *
  17264. * @private
  17265. * @param {number} lower The lower bound.
  17266. * @param {number} upper The upper bound.
  17267. * @returns {number} Returns the random number.
  17268. */
  17269. function baseRandom(lower, upper) {
  17270. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  17271. }
  17272. /**
  17273. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  17274. * coerce arguments.
  17275. *
  17276. * @private
  17277. * @param {number} start The start of the range.
  17278. * @param {number} end The end of the range.
  17279. * @param {number} step The value to increment or decrement by.
  17280. * @param {boolean} [fromRight] Specify iterating from right to left.
  17281. * @returns {Array} Returns the range of numbers.
  17282. */
  17283. function baseRange(start, end, step, fromRight) {
  17284. var index = -1,
  17285. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  17286. result = Array(length);
  17287. while (length--) {
  17288. result[fromRight ? length : ++index] = start;
  17289. start += step;
  17290. }
  17291. return result;
  17292. }
  17293. /**
  17294. * The base implementation of `_.repeat` which doesn't coerce arguments.
  17295. *
  17296. * @private
  17297. * @param {string} string The string to repeat.
  17298. * @param {number} n The number of times to repeat the string.
  17299. * @returns {string} Returns the repeated string.
  17300. */
  17301. function baseRepeat(string, n) {
  17302. var result = '';
  17303. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  17304. return result;
  17305. }
  17306. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  17307. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  17308. do {
  17309. if (n % 2) {
  17310. result += string;
  17311. }
  17312. n = nativeFloor(n / 2);
  17313. if (n) {
  17314. string += string;
  17315. }
  17316. } while (n);
  17317. return result;
  17318. }
  17319. /**
  17320. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  17321. *
  17322. * @private
  17323. * @param {Function} func The function to apply a rest parameter to.
  17324. * @param {number} [start=func.length-1] The start position of the rest parameter.
  17325. * @returns {Function} Returns the new function.
  17326. */
  17327. function baseRest(func, start) {
  17328. return setToString(overRest(func, start, identity), func + '');
  17329. }
  17330. /**
  17331. * The base implementation of `_.sample`.
  17332. *
  17333. * @private
  17334. * @param {Array|Object} collection The collection to sample.
  17335. * @returns {*} Returns the random element.
  17336. */
  17337. function baseSample(collection) {
  17338. return arraySample(values(collection));
  17339. }
  17340. /**
  17341. * The base implementation of `_.sampleSize` without param guards.
  17342. *
  17343. * @private
  17344. * @param {Array|Object} collection The collection to sample.
  17345. * @param {number} n The number of elements to sample.
  17346. * @returns {Array} Returns the random elements.
  17347. */
  17348. function baseSampleSize(collection, n) {
  17349. var array = values(collection);
  17350. return shuffleSelf(array, baseClamp(n, 0, array.length));
  17351. }
  17352. /**
  17353. * The base implementation of `_.set`.
  17354. *
  17355. * @private
  17356. * @param {Object} object The object to modify.
  17357. * @param {Array|string} path The path of the property to set.
  17358. * @param {*} value The value to set.
  17359. * @param {Function} [customizer] The function to customize path creation.
  17360. * @returns {Object} Returns `object`.
  17361. */
  17362. function baseSet(object, path, value, customizer) {
  17363. if (!isObject(object)) {
  17364. return object;
  17365. }
  17366. path = castPath(path, object);
  17367. var index = -1,
  17368. length = path.length,
  17369. lastIndex = length - 1,
  17370. nested = object;
  17371. while (nested != null && ++index < length) {
  17372. var key = toKey(path[index]),
  17373. newValue = value;
  17374. if (index != lastIndex) {
  17375. var objValue = nested[key];
  17376. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  17377. if (newValue === undefined) {
  17378. newValue = isObject(objValue)
  17379. ? objValue
  17380. : (isIndex(path[index + 1]) ? [] : {});
  17381. }
  17382. }
  17383. assignValue(nested, key, newValue);
  17384. nested = nested[key];
  17385. }
  17386. return object;
  17387. }
  17388. /**
  17389. * The base implementation of `setData` without support for hot loop shorting.
  17390. *
  17391. * @private
  17392. * @param {Function} func The function to associate metadata with.
  17393. * @param {*} data The metadata.
  17394. * @returns {Function} Returns `func`.
  17395. */
  17396. var baseSetData = !metaMap ? identity : function(func, data) {
  17397. metaMap.set(func, data);
  17398. return func;
  17399. };
  17400. /**
  17401. * The base implementation of `setToString` without support for hot loop shorting.
  17402. *
  17403. * @private
  17404. * @param {Function} func The function to modify.
  17405. * @param {Function} string The `toString` result.
  17406. * @returns {Function} Returns `func`.
  17407. */
  17408. var baseSetToString = !defineProperty ? identity : function(func, string) {
  17409. return defineProperty(func, 'toString', {
  17410. 'configurable': true,
  17411. 'enumerable': false,
  17412. 'value': constant(string),
  17413. 'writable': true
  17414. });
  17415. };
  17416. /**
  17417. * The base implementation of `_.shuffle`.
  17418. *
  17419. * @private
  17420. * @param {Array|Object} collection The collection to shuffle.
  17421. * @returns {Array} Returns the new shuffled array.
  17422. */
  17423. function baseShuffle(collection) {
  17424. return shuffleSelf(values(collection));
  17425. }
  17426. /**
  17427. * The base implementation of `_.slice` without an iteratee call guard.
  17428. *
  17429. * @private
  17430. * @param {Array} array The array to slice.
  17431. * @param {number} [start=0] The start position.
  17432. * @param {number} [end=array.length] The end position.
  17433. * @returns {Array} Returns the slice of `array`.
  17434. */
  17435. function baseSlice(array, start, end) {
  17436. var index = -1,
  17437. length = array.length;
  17438. if (start < 0) {
  17439. start = -start > length ? 0 : (length + start);
  17440. }
  17441. end = end > length ? length : end;
  17442. if (end < 0) {
  17443. end += length;
  17444. }
  17445. length = start > end ? 0 : ((end - start) >>> 0);
  17446. start >>>= 0;
  17447. var result = Array(length);
  17448. while (++index < length) {
  17449. result[index] = array[index + start];
  17450. }
  17451. return result;
  17452. }
  17453. /**
  17454. * The base implementation of `_.some` without support for iteratee shorthands.
  17455. *
  17456. * @private
  17457. * @param {Array|Object} collection The collection to iterate over.
  17458. * @param {Function} predicate The function invoked per iteration.
  17459. * @returns {boolean} Returns `true` if any element passes the predicate check,
  17460. * else `false`.
  17461. */
  17462. function baseSome(collection, predicate) {
  17463. var result;
  17464. baseEach(collection, function(value, index, collection) {
  17465. result = predicate(value, index, collection);
  17466. return !result;
  17467. });
  17468. return !!result;
  17469. }
  17470. /**
  17471. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  17472. * performs a binary search of `array` to determine the index at which `value`
  17473. * should be inserted into `array` in order to maintain its sort order.
  17474. *
  17475. * @private
  17476. * @param {Array} array The sorted array to inspect.
  17477. * @param {*} value The value to evaluate.
  17478. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  17479. * @returns {number} Returns the index at which `value` should be inserted
  17480. * into `array`.
  17481. */
  17482. function baseSortedIndex(array, value, retHighest) {
  17483. var low = 0,
  17484. high = array == null ? low : array.length;
  17485. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  17486. while (low < high) {
  17487. var mid = (low + high) >>> 1,
  17488. computed = array[mid];
  17489. if (computed !== null && !isSymbol(computed) &&
  17490. (retHighest ? (computed <= value) : (computed < value))) {
  17491. low = mid + 1;
  17492. } else {
  17493. high = mid;
  17494. }
  17495. }
  17496. return high;
  17497. }
  17498. return baseSortedIndexBy(array, value, identity, retHighest);
  17499. }
  17500. /**
  17501. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  17502. * which invokes `iteratee` for `value` and each element of `array` to compute
  17503. * their sort ranking. The iteratee is invoked with one argument; (value).
  17504. *
  17505. * @private
  17506. * @param {Array} array The sorted array to inspect.
  17507. * @param {*} value The value to evaluate.
  17508. * @param {Function} iteratee The iteratee invoked per element.
  17509. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  17510. * @returns {number} Returns the index at which `value` should be inserted
  17511. * into `array`.
  17512. */
  17513. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  17514. value = iteratee(value);
  17515. var low = 0,
  17516. high = array == null ? 0 : array.length,
  17517. valIsNaN = value !== value,
  17518. valIsNull = value === null,
  17519. valIsSymbol = isSymbol(value),
  17520. valIsUndefined = value === undefined;
  17521. while (low < high) {
  17522. var mid = nativeFloor((low + high) / 2),
  17523. computed = iteratee(array[mid]),
  17524. othIsDefined = computed !== undefined,
  17525. othIsNull = computed === null,
  17526. othIsReflexive = computed === computed,
  17527. othIsSymbol = isSymbol(computed);
  17528. if (valIsNaN) {
  17529. var setLow = retHighest || othIsReflexive;
  17530. } else if (valIsUndefined) {
  17531. setLow = othIsReflexive && (retHighest || othIsDefined);
  17532. } else if (valIsNull) {
  17533. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  17534. } else if (valIsSymbol) {
  17535. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  17536. } else if (othIsNull || othIsSymbol) {
  17537. setLow = false;
  17538. } else {
  17539. setLow = retHighest ? (computed <= value) : (computed < value);
  17540. }
  17541. if (setLow) {
  17542. low = mid + 1;
  17543. } else {
  17544. high = mid;
  17545. }
  17546. }
  17547. return nativeMin(high, MAX_ARRAY_INDEX);
  17548. }
  17549. /**
  17550. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  17551. * support for iteratee shorthands.
  17552. *
  17553. * @private
  17554. * @param {Array} array The array to inspect.
  17555. * @param {Function} [iteratee] The iteratee invoked per element.
  17556. * @returns {Array} Returns the new duplicate free array.
  17557. */
  17558. function baseSortedUniq(array, iteratee) {
  17559. var index = -1,
  17560. length = array.length,
  17561. resIndex = 0,
  17562. result = [];
  17563. while (++index < length) {
  17564. var value = array[index],
  17565. computed = iteratee ? iteratee(value) : value;
  17566. if (!index || !eq(computed, seen)) {
  17567. var seen = computed;
  17568. result[resIndex++] = value === 0 ? 0 : value;
  17569. }
  17570. }
  17571. return result;
  17572. }
  17573. /**
  17574. * The base implementation of `_.toNumber` which doesn't ensure correct
  17575. * conversions of binary, hexadecimal, or octal string values.
  17576. *
  17577. * @private
  17578. * @param {*} value The value to process.
  17579. * @returns {number} Returns the number.
  17580. */
  17581. function baseToNumber(value) {
  17582. if (typeof value == 'number') {
  17583. return value;
  17584. }
  17585. if (isSymbol(value)) {
  17586. return NAN;
  17587. }
  17588. return +value;
  17589. }
  17590. /**
  17591. * The base implementation of `_.toString` which doesn't convert nullish
  17592. * values to empty strings.
  17593. *
  17594. * @private
  17595. * @param {*} value The value to process.
  17596. * @returns {string} Returns the string.
  17597. */
  17598. function baseToString(value) {
  17599. // Exit early for strings to avoid a performance hit in some environments.
  17600. if (typeof value == 'string') {
  17601. return value;
  17602. }
  17603. if (isArray(value)) {
  17604. // Recursively convert values (susceptible to call stack limits).
  17605. return arrayMap(value, baseToString) + '';
  17606. }
  17607. if (isSymbol(value)) {
  17608. return symbolToString ? symbolToString.call(value) : '';
  17609. }
  17610. var result = (value + '');
  17611. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  17612. }
  17613. /**
  17614. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  17615. *
  17616. * @private
  17617. * @param {Array} array The array to inspect.
  17618. * @param {Function} [iteratee] The iteratee invoked per element.
  17619. * @param {Function} [comparator] The comparator invoked per element.
  17620. * @returns {Array} Returns the new duplicate free array.
  17621. */
  17622. function baseUniq(array, iteratee, comparator) {
  17623. var index = -1,
  17624. includes = arrayIncludes,
  17625. length = array.length,
  17626. isCommon = true,
  17627. result = [],
  17628. seen = result;
  17629. if (comparator) {
  17630. isCommon = false;
  17631. includes = arrayIncludesWith;
  17632. }
  17633. else if (length >= LARGE_ARRAY_SIZE) {
  17634. var set = iteratee ? null : createSet(array);
  17635. if (set) {
  17636. return setToArray(set);
  17637. }
  17638. isCommon = false;
  17639. includes = cacheHas;
  17640. seen = new SetCache;
  17641. }
  17642. else {
  17643. seen = iteratee ? [] : result;
  17644. }
  17645. outer:
  17646. while (++index < length) {
  17647. var value = array[index],
  17648. computed = iteratee ? iteratee(value) : value;
  17649. value = (comparator || value !== 0) ? value : 0;
  17650. if (isCommon && computed === computed) {
  17651. var seenIndex = seen.length;
  17652. while (seenIndex--) {
  17653. if (seen[seenIndex] === computed) {
  17654. continue outer;
  17655. }
  17656. }
  17657. if (iteratee) {
  17658. seen.push(computed);
  17659. }
  17660. result.push(value);
  17661. }
  17662. else if (!includes(seen, computed, comparator)) {
  17663. if (seen !== result) {
  17664. seen.push(computed);
  17665. }
  17666. result.push(value);
  17667. }
  17668. }
  17669. return result;
  17670. }
  17671. /**
  17672. * The base implementation of `_.unset`.
  17673. *
  17674. * @private
  17675. * @param {Object} object The object to modify.
  17676. * @param {Array|string} path The property path to unset.
  17677. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  17678. */
  17679. function baseUnset(object, path) {
  17680. path = castPath(path, object);
  17681. object = parent(object, path);
  17682. return object == null || delete object[toKey(last(path))];
  17683. }
  17684. /**
  17685. * The base implementation of `_.update`.
  17686. *
  17687. * @private
  17688. * @param {Object} object The object to modify.
  17689. * @param {Array|string} path The path of the property to update.
  17690. * @param {Function} updater The function to produce the updated value.
  17691. * @param {Function} [customizer] The function to customize path creation.
  17692. * @returns {Object} Returns `object`.
  17693. */
  17694. function baseUpdate(object, path, updater, customizer) {
  17695. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  17696. }
  17697. /**
  17698. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  17699. * without support for iteratee shorthands.
  17700. *
  17701. * @private
  17702. * @param {Array} array The array to query.
  17703. * @param {Function} predicate The function invoked per iteration.
  17704. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  17705. * @param {boolean} [fromRight] Specify iterating from right to left.
  17706. * @returns {Array} Returns the slice of `array`.
  17707. */
  17708. function baseWhile(array, predicate, isDrop, fromRight) {
  17709. var length = array.length,
  17710. index = fromRight ? length : -1;
  17711. while ((fromRight ? index-- : ++index < length) &&
  17712. predicate(array[index], index, array)) {}
  17713. return isDrop
  17714. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  17715. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  17716. }
  17717. /**
  17718. * The base implementation of `wrapperValue` which returns the result of
  17719. * performing a sequence of actions on the unwrapped `value`, where each
  17720. * successive action is supplied the return value of the previous.
  17721. *
  17722. * @private
  17723. * @param {*} value The unwrapped value.
  17724. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  17725. * @returns {*} Returns the resolved value.
  17726. */
  17727. function baseWrapperValue(value, actions) {
  17728. var result = value;
  17729. if (result instanceof LazyWrapper) {
  17730. result = result.value();
  17731. }
  17732. return arrayReduce(actions, function(result, action) {
  17733. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  17734. }, result);
  17735. }
  17736. /**
  17737. * The base implementation of methods like `_.xor`, without support for
  17738. * iteratee shorthands, that accepts an array of arrays to inspect.
  17739. *
  17740. * @private
  17741. * @param {Array} arrays The arrays to inspect.
  17742. * @param {Function} [iteratee] The iteratee invoked per element.
  17743. * @param {Function} [comparator] The comparator invoked per element.
  17744. * @returns {Array} Returns the new array of values.
  17745. */
  17746. function baseXor(arrays, iteratee, comparator) {
  17747. var length = arrays.length;
  17748. if (length < 2) {
  17749. return length ? baseUniq(arrays[0]) : [];
  17750. }
  17751. var index = -1,
  17752. result = Array(length);
  17753. while (++index < length) {
  17754. var array = arrays[index],
  17755. othIndex = -1;
  17756. while (++othIndex < length) {
  17757. if (othIndex != index) {
  17758. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  17759. }
  17760. }
  17761. }
  17762. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  17763. }
  17764. /**
  17765. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  17766. *
  17767. * @private
  17768. * @param {Array} props The property identifiers.
  17769. * @param {Array} values The property values.
  17770. * @param {Function} assignFunc The function to assign values.
  17771. * @returns {Object} Returns the new object.
  17772. */
  17773. function baseZipObject(props, values, assignFunc) {
  17774. var index = -1,
  17775. length = props.length,
  17776. valsLength = values.length,
  17777. result = {};
  17778. while (++index < length) {
  17779. var value = index < valsLength ? values[index] : undefined;
  17780. assignFunc(result, props[index], value);
  17781. }
  17782. return result;
  17783. }
  17784. /**
  17785. * Casts `value` to an empty array if it's not an array like object.
  17786. *
  17787. * @private
  17788. * @param {*} value The value to inspect.
  17789. * @returns {Array|Object} Returns the cast array-like object.
  17790. */
  17791. function castArrayLikeObject(value) {
  17792. return isArrayLikeObject(value) ? value : [];
  17793. }
  17794. /**
  17795. * Casts `value` to `identity` if it's not a function.
  17796. *
  17797. * @private
  17798. * @param {*} value The value to inspect.
  17799. * @returns {Function} Returns cast function.
  17800. */
  17801. function castFunction(value) {
  17802. return typeof value == 'function' ? value : identity;
  17803. }
  17804. /**
  17805. * Casts `value` to a path array if it's not one.
  17806. *
  17807. * @private
  17808. * @param {*} value The value to inspect.
  17809. * @param {Object} [object] The object to query keys on.
  17810. * @returns {Array} Returns the cast property path array.
  17811. */
  17812. function castPath(value, object) {
  17813. if (isArray(value)) {
  17814. return value;
  17815. }
  17816. return isKey(value, object) ? [value] : stringToPath(toString(value));
  17817. }
  17818. /**
  17819. * A `baseRest` alias which can be replaced with `identity` by module
  17820. * replacement plugins.
  17821. *
  17822. * @private
  17823. * @type {Function}
  17824. * @param {Function} func The function to apply a rest parameter to.
  17825. * @returns {Function} Returns the new function.
  17826. */
  17827. var castRest = baseRest;
  17828. /**
  17829. * Casts `array` to a slice if it's needed.
  17830. *
  17831. * @private
  17832. * @param {Array} array The array to inspect.
  17833. * @param {number} start The start position.
  17834. * @param {number} [end=array.length] The end position.
  17835. * @returns {Array} Returns the cast slice.
  17836. */
  17837. function castSlice(array, start, end) {
  17838. var length = array.length;
  17839. end = end === undefined ? length : end;
  17840. return (!start && end >= length) ? array : baseSlice(array, start, end);
  17841. }
  17842. /**
  17843. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  17844. *
  17845. * @private
  17846. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  17847. */
  17848. var clearTimeout = ctxClearTimeout || function(id) {
  17849. return root.clearTimeout(id);
  17850. };
  17851. /**
  17852. * Creates a clone of `buffer`.
  17853. *
  17854. * @private
  17855. * @param {Buffer} buffer The buffer to clone.
  17856. * @param {boolean} [isDeep] Specify a deep clone.
  17857. * @returns {Buffer} Returns the cloned buffer.
  17858. */
  17859. function cloneBuffer(buffer, isDeep) {
  17860. if (isDeep) {
  17861. return buffer.slice();
  17862. }
  17863. var length = buffer.length,
  17864. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  17865. buffer.copy(result);
  17866. return result;
  17867. }
  17868. /**
  17869. * Creates a clone of `arrayBuffer`.
  17870. *
  17871. * @private
  17872. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  17873. * @returns {ArrayBuffer} Returns the cloned array buffer.
  17874. */
  17875. function cloneArrayBuffer(arrayBuffer) {
  17876. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  17877. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  17878. return result;
  17879. }
  17880. /**
  17881. * Creates a clone of `dataView`.
  17882. *
  17883. * @private
  17884. * @param {Object} dataView The data view to clone.
  17885. * @param {boolean} [isDeep] Specify a deep clone.
  17886. * @returns {Object} Returns the cloned data view.
  17887. */
  17888. function cloneDataView(dataView, isDeep) {
  17889. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  17890. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  17891. }
  17892. /**
  17893. * Creates a clone of `regexp`.
  17894. *
  17895. * @private
  17896. * @param {Object} regexp The regexp to clone.
  17897. * @returns {Object} Returns the cloned regexp.
  17898. */
  17899. function cloneRegExp(regexp) {
  17900. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  17901. result.lastIndex = regexp.lastIndex;
  17902. return result;
  17903. }
  17904. /**
  17905. * Creates a clone of the `symbol` object.
  17906. *
  17907. * @private
  17908. * @param {Object} symbol The symbol object to clone.
  17909. * @returns {Object} Returns the cloned symbol object.
  17910. */
  17911. function cloneSymbol(symbol) {
  17912. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  17913. }
  17914. /**
  17915. * Creates a clone of `typedArray`.
  17916. *
  17917. * @private
  17918. * @param {Object} typedArray The typed array to clone.
  17919. * @param {boolean} [isDeep] Specify a deep clone.
  17920. * @returns {Object} Returns the cloned typed array.
  17921. */
  17922. function cloneTypedArray(typedArray, isDeep) {
  17923. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  17924. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  17925. }
  17926. /**
  17927. * Compares values to sort them in ascending order.
  17928. *
  17929. * @private
  17930. * @param {*} value The value to compare.
  17931. * @param {*} other The other value to compare.
  17932. * @returns {number} Returns the sort order indicator for `value`.
  17933. */
  17934. function compareAscending(value, other) {
  17935. if (value !== other) {
  17936. var valIsDefined = value !== undefined,
  17937. valIsNull = value === null,
  17938. valIsReflexive = value === value,
  17939. valIsSymbol = isSymbol(value);
  17940. var othIsDefined = other !== undefined,
  17941. othIsNull = other === null,
  17942. othIsReflexive = other === other,
  17943. othIsSymbol = isSymbol(other);
  17944. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  17945. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  17946. (valIsNull && othIsDefined && othIsReflexive) ||
  17947. (!valIsDefined && othIsReflexive) ||
  17948. !valIsReflexive) {
  17949. return 1;
  17950. }
  17951. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  17952. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  17953. (othIsNull && valIsDefined && valIsReflexive) ||
  17954. (!othIsDefined && valIsReflexive) ||
  17955. !othIsReflexive) {
  17956. return -1;
  17957. }
  17958. }
  17959. return 0;
  17960. }
  17961. /**
  17962. * Used by `_.orderBy` to compare multiple properties of a value to another
  17963. * and stable sort them.
  17964. *
  17965. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  17966. * specify an order of "desc" for descending or "asc" for ascending sort order
  17967. * of corresponding values.
  17968. *
  17969. * @private
  17970. * @param {Object} object The object to compare.
  17971. * @param {Object} other The other object to compare.
  17972. * @param {boolean[]|string[]} orders The order to sort by for each property.
  17973. * @returns {number} Returns the sort order indicator for `object`.
  17974. */
  17975. function compareMultiple(object, other, orders) {
  17976. var index = -1,
  17977. objCriteria = object.criteria,
  17978. othCriteria = other.criteria,
  17979. length = objCriteria.length,
  17980. ordersLength = orders.length;
  17981. while (++index < length) {
  17982. var result = compareAscending(objCriteria[index], othCriteria[index]);
  17983. if (result) {
  17984. if (index >= ordersLength) {
  17985. return result;
  17986. }
  17987. var order = orders[index];
  17988. return result * (order == 'desc' ? -1 : 1);
  17989. }
  17990. }
  17991. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  17992. // that causes it, under certain circumstances, to provide the same value for
  17993. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  17994. // for more details.
  17995. //
  17996. // This also ensures a stable sort in V8 and other engines.
  17997. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  17998. return object.index - other.index;
  17999. }
  18000. /**
  18001. * Creates an array that is the composition of partially applied arguments,
  18002. * placeholders, and provided arguments into a single array of arguments.
  18003. *
  18004. * @private
  18005. * @param {Array} args The provided arguments.
  18006. * @param {Array} partials The arguments to prepend to those provided.
  18007. * @param {Array} holders The `partials` placeholder indexes.
  18008. * @params {boolean} [isCurried] Specify composing for a curried function.
  18009. * @returns {Array} Returns the new array of composed arguments.
  18010. */
  18011. function composeArgs(args, partials, holders, isCurried) {
  18012. var argsIndex = -1,
  18013. argsLength = args.length,
  18014. holdersLength = holders.length,
  18015. leftIndex = -1,
  18016. leftLength = partials.length,
  18017. rangeLength = nativeMax(argsLength - holdersLength, 0),
  18018. result = Array(leftLength + rangeLength),
  18019. isUncurried = !isCurried;
  18020. while (++leftIndex < leftLength) {
  18021. result[leftIndex] = partials[leftIndex];
  18022. }
  18023. while (++argsIndex < holdersLength) {
  18024. if (isUncurried || argsIndex < argsLength) {
  18025. result[holders[argsIndex]] = args[argsIndex];
  18026. }
  18027. }
  18028. while (rangeLength--) {
  18029. result[leftIndex++] = args[argsIndex++];
  18030. }
  18031. return result;
  18032. }
  18033. /**
  18034. * This function is like `composeArgs` except that the arguments composition
  18035. * is tailored for `_.partialRight`.
  18036. *
  18037. * @private
  18038. * @param {Array} args The provided arguments.
  18039. * @param {Array} partials The arguments to append to those provided.
  18040. * @param {Array} holders The `partials` placeholder indexes.
  18041. * @params {boolean} [isCurried] Specify composing for a curried function.
  18042. * @returns {Array} Returns the new array of composed arguments.
  18043. */
  18044. function composeArgsRight(args, partials, holders, isCurried) {
  18045. var argsIndex = -1,
  18046. argsLength = args.length,
  18047. holdersIndex = -1,
  18048. holdersLength = holders.length,
  18049. rightIndex = -1,
  18050. rightLength = partials.length,
  18051. rangeLength = nativeMax(argsLength - holdersLength, 0),
  18052. result = Array(rangeLength + rightLength),
  18053. isUncurried = !isCurried;
  18054. while (++argsIndex < rangeLength) {
  18055. result[argsIndex] = args[argsIndex];
  18056. }
  18057. var offset = argsIndex;
  18058. while (++rightIndex < rightLength) {
  18059. result[offset + rightIndex] = partials[rightIndex];
  18060. }
  18061. while (++holdersIndex < holdersLength) {
  18062. if (isUncurried || argsIndex < argsLength) {
  18063. result[offset + holders[holdersIndex]] = args[argsIndex++];
  18064. }
  18065. }
  18066. return result;
  18067. }
  18068. /**
  18069. * Copies the values of `source` to `array`.
  18070. *
  18071. * @private
  18072. * @param {Array} source The array to copy values from.
  18073. * @param {Array} [array=[]] The array to copy values to.
  18074. * @returns {Array} Returns `array`.
  18075. */
  18076. function copyArray(source, array) {
  18077. var index = -1,
  18078. length = source.length;
  18079. array || (array = Array(length));
  18080. while (++index < length) {
  18081. array[index] = source[index];
  18082. }
  18083. return array;
  18084. }
  18085. /**
  18086. * Copies properties of `source` to `object`.
  18087. *
  18088. * @private
  18089. * @param {Object} source The object to copy properties from.
  18090. * @param {Array} props The property identifiers to copy.
  18091. * @param {Object} [object={}] The object to copy properties to.
  18092. * @param {Function} [customizer] The function to customize copied values.
  18093. * @returns {Object} Returns `object`.
  18094. */
  18095. function copyObject(source, props, object, customizer) {
  18096. var isNew = !object;
  18097. object || (object = {});
  18098. var index = -1,
  18099. length = props.length;
  18100. while (++index < length) {
  18101. var key = props[index];
  18102. var newValue = customizer
  18103. ? customizer(object[key], source[key], key, object, source)
  18104. : undefined;
  18105. if (newValue === undefined) {
  18106. newValue = source[key];
  18107. }
  18108. if (isNew) {
  18109. baseAssignValue(object, key, newValue);
  18110. } else {
  18111. assignValue(object, key, newValue);
  18112. }
  18113. }
  18114. return object;
  18115. }
  18116. /**
  18117. * Copies own symbols of `source` to `object`.
  18118. *
  18119. * @private
  18120. * @param {Object} source The object to copy symbols from.
  18121. * @param {Object} [object={}] The object to copy symbols to.
  18122. * @returns {Object} Returns `object`.
  18123. */
  18124. function copySymbols(source, object) {
  18125. return copyObject(source, getSymbols(source), object);
  18126. }
  18127. /**
  18128. * Copies own and inherited symbols of `source` to `object`.
  18129. *
  18130. * @private
  18131. * @param {Object} source The object to copy symbols from.
  18132. * @param {Object} [object={}] The object to copy symbols to.
  18133. * @returns {Object} Returns `object`.
  18134. */
  18135. function copySymbolsIn(source, object) {
  18136. return copyObject(source, getSymbolsIn(source), object);
  18137. }
  18138. /**
  18139. * Creates a function like `_.groupBy`.
  18140. *
  18141. * @private
  18142. * @param {Function} setter The function to set accumulator values.
  18143. * @param {Function} [initializer] The accumulator object initializer.
  18144. * @returns {Function} Returns the new aggregator function.
  18145. */
  18146. function createAggregator(setter, initializer) {
  18147. return function(collection, iteratee) {
  18148. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  18149. accumulator = initializer ? initializer() : {};
  18150. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  18151. };
  18152. }
  18153. /**
  18154. * Creates a function like `_.assign`.
  18155. *
  18156. * @private
  18157. * @param {Function} assigner The function to assign values.
  18158. * @returns {Function} Returns the new assigner function.
  18159. */
  18160. function createAssigner(assigner) {
  18161. return baseRest(function(object, sources) {
  18162. var index = -1,
  18163. length = sources.length,
  18164. customizer = length > 1 ? sources[length - 1] : undefined,
  18165. guard = length > 2 ? sources[2] : undefined;
  18166. customizer = (assigner.length > 3 && typeof customizer == 'function')
  18167. ? (length--, customizer)
  18168. : undefined;
  18169. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  18170. customizer = length < 3 ? undefined : customizer;
  18171. length = 1;
  18172. }
  18173. object = Object(object);
  18174. while (++index < length) {
  18175. var source = sources[index];
  18176. if (source) {
  18177. assigner(object, source, index, customizer);
  18178. }
  18179. }
  18180. return object;
  18181. });
  18182. }
  18183. /**
  18184. * Creates a `baseEach` or `baseEachRight` function.
  18185. *
  18186. * @private
  18187. * @param {Function} eachFunc The function to iterate over a collection.
  18188. * @param {boolean} [fromRight] Specify iterating from right to left.
  18189. * @returns {Function} Returns the new base function.
  18190. */
  18191. function createBaseEach(eachFunc, fromRight) {
  18192. return function(collection, iteratee) {
  18193. if (collection == null) {
  18194. return collection;
  18195. }
  18196. if (!isArrayLike(collection)) {
  18197. return eachFunc(collection, iteratee);
  18198. }
  18199. var length = collection.length,
  18200. index = fromRight ? length : -1,
  18201. iterable = Object(collection);
  18202. while ((fromRight ? index-- : ++index < length)) {
  18203. if (iteratee(iterable[index], index, iterable) === false) {
  18204. break;
  18205. }
  18206. }
  18207. return collection;
  18208. };
  18209. }
  18210. /**
  18211. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  18212. *
  18213. * @private
  18214. * @param {boolean} [fromRight] Specify iterating from right to left.
  18215. * @returns {Function} Returns the new base function.
  18216. */
  18217. function createBaseFor(fromRight) {
  18218. return function(object, iteratee, keysFunc) {
  18219. var index = -1,
  18220. iterable = Object(object),
  18221. props = keysFunc(object),
  18222. length = props.length;
  18223. while (length--) {
  18224. var key = props[fromRight ? length : ++index];
  18225. if (iteratee(iterable[key], key, iterable) === false) {
  18226. break;
  18227. }
  18228. }
  18229. return object;
  18230. };
  18231. }
  18232. /**
  18233. * Creates a function that wraps `func` to invoke it with the optional `this`
  18234. * binding of `thisArg`.
  18235. *
  18236. * @private
  18237. * @param {Function} func The function to wrap.
  18238. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18239. * @param {*} [thisArg] The `this` binding of `func`.
  18240. * @returns {Function} Returns the new wrapped function.
  18241. */
  18242. function createBind(func, bitmask, thisArg) {
  18243. var isBind = bitmask & WRAP_BIND_FLAG,
  18244. Ctor = createCtor(func);
  18245. function wrapper() {
  18246. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18247. return fn.apply(isBind ? thisArg : this, arguments);
  18248. }
  18249. return wrapper;
  18250. }
  18251. /**
  18252. * Creates a function like `_.lowerFirst`.
  18253. *
  18254. * @private
  18255. * @param {string} methodName The name of the `String` case method to use.
  18256. * @returns {Function} Returns the new case function.
  18257. */
  18258. function createCaseFirst(methodName) {
  18259. return function(string) {
  18260. string = toString(string);
  18261. var strSymbols = hasUnicode(string)
  18262. ? stringToArray(string)
  18263. : undefined;
  18264. var chr = strSymbols
  18265. ? strSymbols[0]
  18266. : string.charAt(0);
  18267. var trailing = strSymbols
  18268. ? castSlice(strSymbols, 1).join('')
  18269. : string.slice(1);
  18270. return chr[methodName]() + trailing;
  18271. };
  18272. }
  18273. /**
  18274. * Creates a function like `_.camelCase`.
  18275. *
  18276. * @private
  18277. * @param {Function} callback The function to combine each word.
  18278. * @returns {Function} Returns the new compounder function.
  18279. */
  18280. function createCompounder(callback) {
  18281. return function(string) {
  18282. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  18283. };
  18284. }
  18285. /**
  18286. * Creates a function that produces an instance of `Ctor` regardless of
  18287. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  18288. *
  18289. * @private
  18290. * @param {Function} Ctor The constructor to wrap.
  18291. * @returns {Function} Returns the new wrapped function.
  18292. */
  18293. function createCtor(Ctor) {
  18294. return function() {
  18295. // Use a `switch` statement to work with class constructors. See
  18296. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  18297. // for more details.
  18298. var args = arguments;
  18299. switch (args.length) {
  18300. case 0: return new Ctor;
  18301. case 1: return new Ctor(args[0]);
  18302. case 2: return new Ctor(args[0], args[1]);
  18303. case 3: return new Ctor(args[0], args[1], args[2]);
  18304. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  18305. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  18306. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  18307. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  18308. }
  18309. var thisBinding = baseCreate(Ctor.prototype),
  18310. result = Ctor.apply(thisBinding, args);
  18311. // Mimic the constructor's `return` behavior.
  18312. // See https://es5.github.io/#x13.2.2 for more details.
  18313. return isObject(result) ? result : thisBinding;
  18314. };
  18315. }
  18316. /**
  18317. * Creates a function that wraps `func` to enable currying.
  18318. *
  18319. * @private
  18320. * @param {Function} func The function to wrap.
  18321. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18322. * @param {number} arity The arity of `func`.
  18323. * @returns {Function} Returns the new wrapped function.
  18324. */
  18325. function createCurry(func, bitmask, arity) {
  18326. var Ctor = createCtor(func);
  18327. function wrapper() {
  18328. var length = arguments.length,
  18329. args = Array(length),
  18330. index = length,
  18331. placeholder = getHolder(wrapper);
  18332. while (index--) {
  18333. args[index] = arguments[index];
  18334. }
  18335. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  18336. ? []
  18337. : replaceHolders(args, placeholder);
  18338. length -= holders.length;
  18339. if (length < arity) {
  18340. return createRecurry(
  18341. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  18342. args, holders, undefined, undefined, arity - length);
  18343. }
  18344. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18345. return apply(fn, this, args);
  18346. }
  18347. return wrapper;
  18348. }
  18349. /**
  18350. * Creates a `_.find` or `_.findLast` function.
  18351. *
  18352. * @private
  18353. * @param {Function} findIndexFunc The function to find the collection index.
  18354. * @returns {Function} Returns the new find function.
  18355. */
  18356. function createFind(findIndexFunc) {
  18357. return function(collection, predicate, fromIndex) {
  18358. var iterable = Object(collection);
  18359. if (!isArrayLike(collection)) {
  18360. var iteratee = getIteratee(predicate, 3);
  18361. collection = keys(collection);
  18362. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  18363. }
  18364. var index = findIndexFunc(collection, predicate, fromIndex);
  18365. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  18366. };
  18367. }
  18368. /**
  18369. * Creates a `_.flow` or `_.flowRight` function.
  18370. *
  18371. * @private
  18372. * @param {boolean} [fromRight] Specify iterating from right to left.
  18373. * @returns {Function} Returns the new flow function.
  18374. */
  18375. function createFlow(fromRight) {
  18376. return flatRest(function(funcs) {
  18377. var length = funcs.length,
  18378. index = length,
  18379. prereq = LodashWrapper.prototype.thru;
  18380. if (fromRight) {
  18381. funcs.reverse();
  18382. }
  18383. while (index--) {
  18384. var func = funcs[index];
  18385. if (typeof func != 'function') {
  18386. throw new TypeError(FUNC_ERROR_TEXT);
  18387. }
  18388. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  18389. var wrapper = new LodashWrapper([], true);
  18390. }
  18391. }
  18392. index = wrapper ? index : length;
  18393. while (++index < length) {
  18394. func = funcs[index];
  18395. var funcName = getFuncName(func),
  18396. data = funcName == 'wrapper' ? getData(func) : undefined;
  18397. if (data && isLaziable(data[0]) &&
  18398. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  18399. !data[4].length && data[9] == 1
  18400. ) {
  18401. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  18402. } else {
  18403. wrapper = (func.length == 1 && isLaziable(func))
  18404. ? wrapper[funcName]()
  18405. : wrapper.thru(func);
  18406. }
  18407. }
  18408. return function() {
  18409. var args = arguments,
  18410. value = args[0];
  18411. if (wrapper && args.length == 1 && isArray(value)) {
  18412. return wrapper.plant(value).value();
  18413. }
  18414. var index = 0,
  18415. result = length ? funcs[index].apply(this, args) : value;
  18416. while (++index < length) {
  18417. result = funcs[index].call(this, result);
  18418. }
  18419. return result;
  18420. };
  18421. });
  18422. }
  18423. /**
  18424. * Creates a function that wraps `func` to invoke it with optional `this`
  18425. * binding of `thisArg`, partial application, and currying.
  18426. *
  18427. * @private
  18428. * @param {Function|string} func The function or method name to wrap.
  18429. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18430. * @param {*} [thisArg] The `this` binding of `func`.
  18431. * @param {Array} [partials] The arguments to prepend to those provided to
  18432. * the new function.
  18433. * @param {Array} [holders] The `partials` placeholder indexes.
  18434. * @param {Array} [partialsRight] The arguments to append to those provided
  18435. * to the new function.
  18436. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  18437. * @param {Array} [argPos] The argument positions of the new function.
  18438. * @param {number} [ary] The arity cap of `func`.
  18439. * @param {number} [arity] The arity of `func`.
  18440. * @returns {Function} Returns the new wrapped function.
  18441. */
  18442. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  18443. var isAry = bitmask & WRAP_ARY_FLAG,
  18444. isBind = bitmask & WRAP_BIND_FLAG,
  18445. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  18446. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  18447. isFlip = bitmask & WRAP_FLIP_FLAG,
  18448. Ctor = isBindKey ? undefined : createCtor(func);
  18449. function wrapper() {
  18450. var length = arguments.length,
  18451. args = Array(length),
  18452. index = length;
  18453. while (index--) {
  18454. args[index] = arguments[index];
  18455. }
  18456. if (isCurried) {
  18457. var placeholder = getHolder(wrapper),
  18458. holdersCount = countHolders(args, placeholder);
  18459. }
  18460. if (partials) {
  18461. args = composeArgs(args, partials, holders, isCurried);
  18462. }
  18463. if (partialsRight) {
  18464. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  18465. }
  18466. length -= holdersCount;
  18467. if (isCurried && length < arity) {
  18468. var newHolders = replaceHolders(args, placeholder);
  18469. return createRecurry(
  18470. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  18471. args, newHolders, argPos, ary, arity - length
  18472. );
  18473. }
  18474. var thisBinding = isBind ? thisArg : this,
  18475. fn = isBindKey ? thisBinding[func] : func;
  18476. length = args.length;
  18477. if (argPos) {
  18478. args = reorder(args, argPos);
  18479. } else if (isFlip && length > 1) {
  18480. args.reverse();
  18481. }
  18482. if (isAry && ary < length) {
  18483. args.length = ary;
  18484. }
  18485. if (this && this !== root && this instanceof wrapper) {
  18486. fn = Ctor || createCtor(fn);
  18487. }
  18488. return fn.apply(thisBinding, args);
  18489. }
  18490. return wrapper;
  18491. }
  18492. /**
  18493. * Creates a function like `_.invertBy`.
  18494. *
  18495. * @private
  18496. * @param {Function} setter The function to set accumulator values.
  18497. * @param {Function} toIteratee The function to resolve iteratees.
  18498. * @returns {Function} Returns the new inverter function.
  18499. */
  18500. function createInverter(setter, toIteratee) {
  18501. return function(object, iteratee) {
  18502. return baseInverter(object, setter, toIteratee(iteratee), {});
  18503. };
  18504. }
  18505. /**
  18506. * Creates a function that performs a mathematical operation on two values.
  18507. *
  18508. * @private
  18509. * @param {Function} operator The function to perform the operation.
  18510. * @param {number} [defaultValue] The value used for `undefined` arguments.
  18511. * @returns {Function} Returns the new mathematical operation function.
  18512. */
  18513. function createMathOperation(operator, defaultValue) {
  18514. return function(value, other) {
  18515. var result;
  18516. if (value === undefined && other === undefined) {
  18517. return defaultValue;
  18518. }
  18519. if (value !== undefined) {
  18520. result = value;
  18521. }
  18522. if (other !== undefined) {
  18523. if (result === undefined) {
  18524. return other;
  18525. }
  18526. if (typeof value == 'string' || typeof other == 'string') {
  18527. value = baseToString(value);
  18528. other = baseToString(other);
  18529. } else {
  18530. value = baseToNumber(value);
  18531. other = baseToNumber(other);
  18532. }
  18533. result = operator(value, other);
  18534. }
  18535. return result;
  18536. };
  18537. }
  18538. /**
  18539. * Creates a function like `_.over`.
  18540. *
  18541. * @private
  18542. * @param {Function} arrayFunc The function to iterate over iteratees.
  18543. * @returns {Function} Returns the new over function.
  18544. */
  18545. function createOver(arrayFunc) {
  18546. return flatRest(function(iteratees) {
  18547. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  18548. return baseRest(function(args) {
  18549. var thisArg = this;
  18550. return arrayFunc(iteratees, function(iteratee) {
  18551. return apply(iteratee, thisArg, args);
  18552. });
  18553. });
  18554. });
  18555. }
  18556. /**
  18557. * Creates the padding for `string` based on `length`. The `chars` string
  18558. * is truncated if the number of characters exceeds `length`.
  18559. *
  18560. * @private
  18561. * @param {number} length The padding length.
  18562. * @param {string} [chars=' '] The string used as padding.
  18563. * @returns {string} Returns the padding for `string`.
  18564. */
  18565. function createPadding(length, chars) {
  18566. chars = chars === undefined ? ' ' : baseToString(chars);
  18567. var charsLength = chars.length;
  18568. if (charsLength < 2) {
  18569. return charsLength ? baseRepeat(chars, length) : chars;
  18570. }
  18571. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  18572. return hasUnicode(chars)
  18573. ? castSlice(stringToArray(result), 0, length).join('')
  18574. : result.slice(0, length);
  18575. }
  18576. /**
  18577. * Creates a function that wraps `func` to invoke it with the `this` binding
  18578. * of `thisArg` and `partials` prepended to the arguments it receives.
  18579. *
  18580. * @private
  18581. * @param {Function} func The function to wrap.
  18582. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18583. * @param {*} thisArg The `this` binding of `func`.
  18584. * @param {Array} partials The arguments to prepend to those provided to
  18585. * the new function.
  18586. * @returns {Function} Returns the new wrapped function.
  18587. */
  18588. function createPartial(func, bitmask, thisArg, partials) {
  18589. var isBind = bitmask & WRAP_BIND_FLAG,
  18590. Ctor = createCtor(func);
  18591. function wrapper() {
  18592. var argsIndex = -1,
  18593. argsLength = arguments.length,
  18594. leftIndex = -1,
  18595. leftLength = partials.length,
  18596. args = Array(leftLength + argsLength),
  18597. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18598. while (++leftIndex < leftLength) {
  18599. args[leftIndex] = partials[leftIndex];
  18600. }
  18601. while (argsLength--) {
  18602. args[leftIndex++] = arguments[++argsIndex];
  18603. }
  18604. return apply(fn, isBind ? thisArg : this, args);
  18605. }
  18606. return wrapper;
  18607. }
  18608. /**
  18609. * Creates a `_.range` or `_.rangeRight` function.
  18610. *
  18611. * @private
  18612. * @param {boolean} [fromRight] Specify iterating from right to left.
  18613. * @returns {Function} Returns the new range function.
  18614. */
  18615. function createRange(fromRight) {
  18616. return function(start, end, step) {
  18617. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  18618. end = step = undefined;
  18619. }
  18620. // Ensure the sign of `-0` is preserved.
  18621. start = toFinite(start);
  18622. if (end === undefined) {
  18623. end = start;
  18624. start = 0;
  18625. } else {
  18626. end = toFinite(end);
  18627. }
  18628. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  18629. return baseRange(start, end, step, fromRight);
  18630. };
  18631. }
  18632. /**
  18633. * Creates a function that performs a relational operation on two values.
  18634. *
  18635. * @private
  18636. * @param {Function} operator The function to perform the operation.
  18637. * @returns {Function} Returns the new relational operation function.
  18638. */
  18639. function createRelationalOperation(operator) {
  18640. return function(value, other) {
  18641. if (!(typeof value == 'string' && typeof other == 'string')) {
  18642. value = toNumber(value);
  18643. other = toNumber(other);
  18644. }
  18645. return operator(value, other);
  18646. };
  18647. }
  18648. /**
  18649. * Creates a function that wraps `func` to continue currying.
  18650. *
  18651. * @private
  18652. * @param {Function} func The function to wrap.
  18653. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18654. * @param {Function} wrapFunc The function to create the `func` wrapper.
  18655. * @param {*} placeholder The placeholder value.
  18656. * @param {*} [thisArg] The `this` binding of `func`.
  18657. * @param {Array} [partials] The arguments to prepend to those provided to
  18658. * the new function.
  18659. * @param {Array} [holders] The `partials` placeholder indexes.
  18660. * @param {Array} [argPos] The argument positions of the new function.
  18661. * @param {number} [ary] The arity cap of `func`.
  18662. * @param {number} [arity] The arity of `func`.
  18663. * @returns {Function} Returns the new wrapped function.
  18664. */
  18665. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  18666. var isCurry = bitmask & WRAP_CURRY_FLAG,
  18667. newHolders = isCurry ? holders : undefined,
  18668. newHoldersRight = isCurry ? undefined : holders,
  18669. newPartials = isCurry ? partials : undefined,
  18670. newPartialsRight = isCurry ? undefined : partials;
  18671. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  18672. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  18673. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  18674. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  18675. }
  18676. var newData = [
  18677. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  18678. newHoldersRight, argPos, ary, arity
  18679. ];
  18680. var result = wrapFunc.apply(undefined, newData);
  18681. if (isLaziable(func)) {
  18682. setData(result, newData);
  18683. }
  18684. result.placeholder = placeholder;
  18685. return setWrapToString(result, func, bitmask);
  18686. }
  18687. /**
  18688. * Creates a function like `_.round`.
  18689. *
  18690. * @private
  18691. * @param {string} methodName The name of the `Math` method to use when rounding.
  18692. * @returns {Function} Returns the new round function.
  18693. */
  18694. function createRound(methodName) {
  18695. var func = Math[methodName];
  18696. return function(number, precision) {
  18697. number = toNumber(number);
  18698. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  18699. if (precision && nativeIsFinite(number)) {
  18700. // Shift with exponential notation to avoid floating-point issues.
  18701. // See [MDN](https://mdn.io/round#Examples) for more details.
  18702. var pair = (toString(number) + 'e').split('e'),
  18703. value = func(pair[0] + 'e' + (+pair[1] + precision));
  18704. pair = (toString(value) + 'e').split('e');
  18705. return +(pair[0] + 'e' + (+pair[1] - precision));
  18706. }
  18707. return func(number);
  18708. };
  18709. }
  18710. /**
  18711. * Creates a set object of `values`.
  18712. *
  18713. * @private
  18714. * @param {Array} values The values to add to the set.
  18715. * @returns {Object} Returns the new set.
  18716. */
  18717. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  18718. return new Set(values);
  18719. };
  18720. /**
  18721. * Creates a `_.toPairs` or `_.toPairsIn` function.
  18722. *
  18723. * @private
  18724. * @param {Function} keysFunc The function to get the keys of a given object.
  18725. * @returns {Function} Returns the new pairs function.
  18726. */
  18727. function createToPairs(keysFunc) {
  18728. return function(object) {
  18729. var tag = getTag(object);
  18730. if (tag == mapTag) {
  18731. return mapToArray(object);
  18732. }
  18733. if (tag == setTag) {
  18734. return setToPairs(object);
  18735. }
  18736. return baseToPairs(object, keysFunc(object));
  18737. };
  18738. }
  18739. /**
  18740. * Creates a function that either curries or invokes `func` with optional
  18741. * `this` binding and partially applied arguments.
  18742. *
  18743. * @private
  18744. * @param {Function|string} func The function or method name to wrap.
  18745. * @param {number} bitmask The bitmask flags.
  18746. * 1 - `_.bind`
  18747. * 2 - `_.bindKey`
  18748. * 4 - `_.curry` or `_.curryRight` of a bound function
  18749. * 8 - `_.curry`
  18750. * 16 - `_.curryRight`
  18751. * 32 - `_.partial`
  18752. * 64 - `_.partialRight`
  18753. * 128 - `_.rearg`
  18754. * 256 - `_.ary`
  18755. * 512 - `_.flip`
  18756. * @param {*} [thisArg] The `this` binding of `func`.
  18757. * @param {Array} [partials] The arguments to be partially applied.
  18758. * @param {Array} [holders] The `partials` placeholder indexes.
  18759. * @param {Array} [argPos] The argument positions of the new function.
  18760. * @param {number} [ary] The arity cap of `func`.
  18761. * @param {number} [arity] The arity of `func`.
  18762. * @returns {Function} Returns the new wrapped function.
  18763. */
  18764. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  18765. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  18766. if (!isBindKey && typeof func != 'function') {
  18767. throw new TypeError(FUNC_ERROR_TEXT);
  18768. }
  18769. var length = partials ? partials.length : 0;
  18770. if (!length) {
  18771. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  18772. partials = holders = undefined;
  18773. }
  18774. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  18775. arity = arity === undefined ? arity : toInteger(arity);
  18776. length -= holders ? holders.length : 0;
  18777. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  18778. var partialsRight = partials,
  18779. holdersRight = holders;
  18780. partials = holders = undefined;
  18781. }
  18782. var data = isBindKey ? undefined : getData(func);
  18783. var newData = [
  18784. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  18785. argPos, ary, arity
  18786. ];
  18787. if (data) {
  18788. mergeData(newData, data);
  18789. }
  18790. func = newData[0];
  18791. bitmask = newData[1];
  18792. thisArg = newData[2];
  18793. partials = newData[3];
  18794. holders = newData[4];
  18795. arity = newData[9] = newData[9] === undefined
  18796. ? (isBindKey ? 0 : func.length)
  18797. : nativeMax(newData[9] - length, 0);
  18798. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  18799. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  18800. }
  18801. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  18802. var result = createBind(func, bitmask, thisArg);
  18803. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  18804. result = createCurry(func, bitmask, arity);
  18805. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  18806. result = createPartial(func, bitmask, thisArg, partials);
  18807. } else {
  18808. result = createHybrid.apply(undefined, newData);
  18809. }
  18810. var setter = data ? baseSetData : setData;
  18811. return setWrapToString(setter(result, newData), func, bitmask);
  18812. }
  18813. /**
  18814. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  18815. * of source objects to the destination object for all destination properties
  18816. * that resolve to `undefined`.
  18817. *
  18818. * @private
  18819. * @param {*} objValue The destination value.
  18820. * @param {*} srcValue The source value.
  18821. * @param {string} key The key of the property to assign.
  18822. * @param {Object} object The parent object of `objValue`.
  18823. * @returns {*} Returns the value to assign.
  18824. */
  18825. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  18826. if (objValue === undefined ||
  18827. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  18828. return srcValue;
  18829. }
  18830. return objValue;
  18831. }
  18832. /**
  18833. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  18834. * objects into destination objects that are passed thru.
  18835. *
  18836. * @private
  18837. * @param {*} objValue The destination value.
  18838. * @param {*} srcValue The source value.
  18839. * @param {string} key The key of the property to merge.
  18840. * @param {Object} object The parent object of `objValue`.
  18841. * @param {Object} source The parent object of `srcValue`.
  18842. * @param {Object} [stack] Tracks traversed source values and their merged
  18843. * counterparts.
  18844. * @returns {*} Returns the value to assign.
  18845. */
  18846. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  18847. if (isObject(objValue) && isObject(srcValue)) {
  18848. // Recursively merge objects and arrays (susceptible to call stack limits).
  18849. stack.set(srcValue, objValue);
  18850. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  18851. stack['delete'](srcValue);
  18852. }
  18853. return objValue;
  18854. }
  18855. /**
  18856. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  18857. * objects.
  18858. *
  18859. * @private
  18860. * @param {*} value The value to inspect.
  18861. * @param {string} key The key of the property to inspect.
  18862. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  18863. */
  18864. function customOmitClone(value) {
  18865. return isPlainObject(value) ? undefined : value;
  18866. }
  18867. /**
  18868. * A specialized version of `baseIsEqualDeep` for arrays with support for
  18869. * partial deep comparisons.
  18870. *
  18871. * @private
  18872. * @param {Array} array The array to compare.
  18873. * @param {Array} other The other array to compare.
  18874. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  18875. * @param {Function} customizer The function to customize comparisons.
  18876. * @param {Function} equalFunc The function to determine equivalents of values.
  18877. * @param {Object} stack Tracks traversed `array` and `other` objects.
  18878. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  18879. */
  18880. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  18881. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  18882. arrLength = array.length,
  18883. othLength = other.length;
  18884. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  18885. return false;
  18886. }
  18887. // Assume cyclic values are equal.
  18888. var stacked = stack.get(array);
  18889. if (stacked && stack.get(other)) {
  18890. return stacked == other;
  18891. }
  18892. var index = -1,
  18893. result = true,
  18894. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  18895. stack.set(array, other);
  18896. stack.set(other, array);
  18897. // Ignore non-index properties.
  18898. while (++index < arrLength) {
  18899. var arrValue = array[index],
  18900. othValue = other[index];
  18901. if (customizer) {
  18902. var compared = isPartial
  18903. ? customizer(othValue, arrValue, index, other, array, stack)
  18904. : customizer(arrValue, othValue, index, array, other, stack);
  18905. }
  18906. if (compared !== undefined) {
  18907. if (compared) {
  18908. continue;
  18909. }
  18910. result = false;
  18911. break;
  18912. }
  18913. // Recursively compare arrays (susceptible to call stack limits).
  18914. if (seen) {
  18915. if (!arraySome(other, function(othValue, othIndex) {
  18916. if (!cacheHas(seen, othIndex) &&
  18917. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  18918. return seen.push(othIndex);
  18919. }
  18920. })) {
  18921. result = false;
  18922. break;
  18923. }
  18924. } else if (!(
  18925. arrValue === othValue ||
  18926. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  18927. )) {
  18928. result = false;
  18929. break;
  18930. }
  18931. }
  18932. stack['delete'](array);
  18933. stack['delete'](other);
  18934. return result;
  18935. }
  18936. /**
  18937. * A specialized version of `baseIsEqualDeep` for comparing objects of
  18938. * the same `toStringTag`.
  18939. *
  18940. * **Note:** This function only supports comparing values with tags of
  18941. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  18942. *
  18943. * @private
  18944. * @param {Object} object The object to compare.
  18945. * @param {Object} other The other object to compare.
  18946. * @param {string} tag The `toStringTag` of the objects to compare.
  18947. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  18948. * @param {Function} customizer The function to customize comparisons.
  18949. * @param {Function} equalFunc The function to determine equivalents of values.
  18950. * @param {Object} stack Tracks traversed `object` and `other` objects.
  18951. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  18952. */
  18953. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  18954. switch (tag) {
  18955. case dataViewTag:
  18956. if ((object.byteLength != other.byteLength) ||
  18957. (object.byteOffset != other.byteOffset)) {
  18958. return false;
  18959. }
  18960. object = object.buffer;
  18961. other = other.buffer;
  18962. case arrayBufferTag:
  18963. if ((object.byteLength != other.byteLength) ||
  18964. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  18965. return false;
  18966. }
  18967. return true;
  18968. case boolTag:
  18969. case dateTag:
  18970. case numberTag:
  18971. // Coerce booleans to `1` or `0` and dates to milliseconds.
  18972. // Invalid dates are coerced to `NaN`.
  18973. return eq(+object, +other);
  18974. case errorTag:
  18975. return object.name == other.name && object.message == other.message;
  18976. case regexpTag:
  18977. case stringTag:
  18978. // Coerce regexes to strings and treat strings, primitives and objects,
  18979. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  18980. // for more details.
  18981. return object == (other + '');
  18982. case mapTag:
  18983. var convert = mapToArray;
  18984. case setTag:
  18985. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  18986. convert || (convert = setToArray);
  18987. if (object.size != other.size && !isPartial) {
  18988. return false;
  18989. }
  18990. // Assume cyclic values are equal.
  18991. var stacked = stack.get(object);
  18992. if (stacked) {
  18993. return stacked == other;
  18994. }
  18995. bitmask |= COMPARE_UNORDERED_FLAG;
  18996. // Recursively compare objects (susceptible to call stack limits).
  18997. stack.set(object, other);
  18998. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  18999. stack['delete'](object);
  19000. return result;
  19001. case symbolTag:
  19002. if (symbolValueOf) {
  19003. return symbolValueOf.call(object) == symbolValueOf.call(other);
  19004. }
  19005. }
  19006. return false;
  19007. }
  19008. /**
  19009. * A specialized version of `baseIsEqualDeep` for objects with support for
  19010. * partial deep comparisons.
  19011. *
  19012. * @private
  19013. * @param {Object} object The object to compare.
  19014. * @param {Object} other The other object to compare.
  19015. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19016. * @param {Function} customizer The function to customize comparisons.
  19017. * @param {Function} equalFunc The function to determine equivalents of values.
  19018. * @param {Object} stack Tracks traversed `object` and `other` objects.
  19019. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19020. */
  19021. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  19022. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  19023. objProps = getAllKeys(object),
  19024. objLength = objProps.length,
  19025. othProps = getAllKeys(other),
  19026. othLength = othProps.length;
  19027. if (objLength != othLength && !isPartial) {
  19028. return false;
  19029. }
  19030. var index = objLength;
  19031. while (index--) {
  19032. var key = objProps[index];
  19033. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  19034. return false;
  19035. }
  19036. }
  19037. // Assume cyclic values are equal.
  19038. var stacked = stack.get(object);
  19039. if (stacked && stack.get(other)) {
  19040. return stacked == other;
  19041. }
  19042. var result = true;
  19043. stack.set(object, other);
  19044. stack.set(other, object);
  19045. var skipCtor = isPartial;
  19046. while (++index < objLength) {
  19047. key = objProps[index];
  19048. var objValue = object[key],
  19049. othValue = other[key];
  19050. if (customizer) {
  19051. var compared = isPartial
  19052. ? customizer(othValue, objValue, key, other, object, stack)
  19053. : customizer(objValue, othValue, key, object, other, stack);
  19054. }
  19055. // Recursively compare objects (susceptible to call stack limits).
  19056. if (!(compared === undefined
  19057. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  19058. : compared
  19059. )) {
  19060. result = false;
  19061. break;
  19062. }
  19063. skipCtor || (skipCtor = key == 'constructor');
  19064. }
  19065. if (result && !skipCtor) {
  19066. var objCtor = object.constructor,
  19067. othCtor = other.constructor;
  19068. // Non `Object` object instances with different constructors are not equal.
  19069. if (objCtor != othCtor &&
  19070. ('constructor' in object && 'constructor' in other) &&
  19071. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  19072. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  19073. result = false;
  19074. }
  19075. }
  19076. stack['delete'](object);
  19077. stack['delete'](other);
  19078. return result;
  19079. }
  19080. /**
  19081. * A specialized version of `baseRest` which flattens the rest array.
  19082. *
  19083. * @private
  19084. * @param {Function} func The function to apply a rest parameter to.
  19085. * @returns {Function} Returns the new function.
  19086. */
  19087. function flatRest(func) {
  19088. return setToString(overRest(func, undefined, flatten), func + '');
  19089. }
  19090. /**
  19091. * Creates an array of own enumerable property names and symbols of `object`.
  19092. *
  19093. * @private
  19094. * @param {Object} object The object to query.
  19095. * @returns {Array} Returns the array of property names and symbols.
  19096. */
  19097. function getAllKeys(object) {
  19098. return baseGetAllKeys(object, keys, getSymbols);
  19099. }
  19100. /**
  19101. * Creates an array of own and inherited enumerable property names and
  19102. * symbols of `object`.
  19103. *
  19104. * @private
  19105. * @param {Object} object The object to query.
  19106. * @returns {Array} Returns the array of property names and symbols.
  19107. */
  19108. function getAllKeysIn(object) {
  19109. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  19110. }
  19111. /**
  19112. * Gets metadata for `func`.
  19113. *
  19114. * @private
  19115. * @param {Function} func The function to query.
  19116. * @returns {*} Returns the metadata for `func`.
  19117. */
  19118. var getData = !metaMap ? noop : function(func) {
  19119. return metaMap.get(func);
  19120. };
  19121. /**
  19122. * Gets the name of `func`.
  19123. *
  19124. * @private
  19125. * @param {Function} func The function to query.
  19126. * @returns {string} Returns the function name.
  19127. */
  19128. function getFuncName(func) {
  19129. var result = (func.name + ''),
  19130. array = realNames[result],
  19131. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  19132. while (length--) {
  19133. var data = array[length],
  19134. otherFunc = data.func;
  19135. if (otherFunc == null || otherFunc == func) {
  19136. return data.name;
  19137. }
  19138. }
  19139. return result;
  19140. }
  19141. /**
  19142. * Gets the argument placeholder value for `func`.
  19143. *
  19144. * @private
  19145. * @param {Function} func The function to inspect.
  19146. * @returns {*} Returns the placeholder value.
  19147. */
  19148. function getHolder(func) {
  19149. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  19150. return object.placeholder;
  19151. }
  19152. /**
  19153. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  19154. * this function returns the custom method, otherwise it returns `baseIteratee`.
  19155. * If arguments are provided, the chosen function is invoked with them and
  19156. * its result is returned.
  19157. *
  19158. * @private
  19159. * @param {*} [value] The value to convert to an iteratee.
  19160. * @param {number} [arity] The arity of the created iteratee.
  19161. * @returns {Function} Returns the chosen function or its result.
  19162. */
  19163. function getIteratee() {
  19164. var result = lodash.iteratee || iteratee;
  19165. result = result === iteratee ? baseIteratee : result;
  19166. return arguments.length ? result(arguments[0], arguments[1]) : result;
  19167. }
  19168. /**
  19169. * Gets the data for `map`.
  19170. *
  19171. * @private
  19172. * @param {Object} map The map to query.
  19173. * @param {string} key The reference key.
  19174. * @returns {*} Returns the map data.
  19175. */
  19176. function getMapData(map, key) {
  19177. var data = map.__data__;
  19178. return isKeyable(key)
  19179. ? data[typeof key == 'string' ? 'string' : 'hash']
  19180. : data.map;
  19181. }
  19182. /**
  19183. * Gets the property names, values, and compare flags of `object`.
  19184. *
  19185. * @private
  19186. * @param {Object} object The object to query.
  19187. * @returns {Array} Returns the match data of `object`.
  19188. */
  19189. function getMatchData(object) {
  19190. var result = keys(object),
  19191. length = result.length;
  19192. while (length--) {
  19193. var key = result[length],
  19194. value = object[key];
  19195. result[length] = [key, value, isStrictComparable(value)];
  19196. }
  19197. return result;
  19198. }
  19199. /**
  19200. * Gets the native function at `key` of `object`.
  19201. *
  19202. * @private
  19203. * @param {Object} object The object to query.
  19204. * @param {string} key The key of the method to get.
  19205. * @returns {*} Returns the function if it's native, else `undefined`.
  19206. */
  19207. function getNative(object, key) {
  19208. var value = getValue(object, key);
  19209. return baseIsNative(value) ? value : undefined;
  19210. }
  19211. /**
  19212. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  19213. *
  19214. * @private
  19215. * @param {*} value The value to query.
  19216. * @returns {string} Returns the raw `toStringTag`.
  19217. */
  19218. function getRawTag(value) {
  19219. var isOwn = hasOwnProperty.call(value, symToStringTag),
  19220. tag = value[symToStringTag];
  19221. try {
  19222. value[symToStringTag] = undefined;
  19223. var unmasked = true;
  19224. } catch (e) {}
  19225. var result = nativeObjectToString.call(value);
  19226. if (unmasked) {
  19227. if (isOwn) {
  19228. value[symToStringTag] = tag;
  19229. } else {
  19230. delete value[symToStringTag];
  19231. }
  19232. }
  19233. return result;
  19234. }
  19235. /**
  19236. * Creates an array of the own enumerable symbols of `object`.
  19237. *
  19238. * @private
  19239. * @param {Object} object The object to query.
  19240. * @returns {Array} Returns the array of symbols.
  19241. */
  19242. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  19243. if (object == null) {
  19244. return [];
  19245. }
  19246. object = Object(object);
  19247. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  19248. return propertyIsEnumerable.call(object, symbol);
  19249. });
  19250. };
  19251. /**
  19252. * Creates an array of the own and inherited enumerable symbols of `object`.
  19253. *
  19254. * @private
  19255. * @param {Object} object The object to query.
  19256. * @returns {Array} Returns the array of symbols.
  19257. */
  19258. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  19259. var result = [];
  19260. while (object) {
  19261. arrayPush(result, getSymbols(object));
  19262. object = getPrototype(object);
  19263. }
  19264. return result;
  19265. };
  19266. /**
  19267. * Gets the `toStringTag` of `value`.
  19268. *
  19269. * @private
  19270. * @param {*} value The value to query.
  19271. * @returns {string} Returns the `toStringTag`.
  19272. */
  19273. var getTag = baseGetTag;
  19274. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  19275. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  19276. (Map && getTag(new Map) != mapTag) ||
  19277. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  19278. (Set && getTag(new Set) != setTag) ||
  19279. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  19280. getTag = function(value) {
  19281. var result = baseGetTag(value),
  19282. Ctor = result == objectTag ? value.constructor : undefined,
  19283. ctorString = Ctor ? toSource(Ctor) : '';
  19284. if (ctorString) {
  19285. switch (ctorString) {
  19286. case dataViewCtorString: return dataViewTag;
  19287. case mapCtorString: return mapTag;
  19288. case promiseCtorString: return promiseTag;
  19289. case setCtorString: return setTag;
  19290. case weakMapCtorString: return weakMapTag;
  19291. }
  19292. }
  19293. return result;
  19294. };
  19295. }
  19296. /**
  19297. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  19298. *
  19299. * @private
  19300. * @param {number} start The start of the view.
  19301. * @param {number} end The end of the view.
  19302. * @param {Array} transforms The transformations to apply to the view.
  19303. * @returns {Object} Returns an object containing the `start` and `end`
  19304. * positions of the view.
  19305. */
  19306. function getView(start, end, transforms) {
  19307. var index = -1,
  19308. length = transforms.length;
  19309. while (++index < length) {
  19310. var data = transforms[index],
  19311. size = data.size;
  19312. switch (data.type) {
  19313. case 'drop': start += size; break;
  19314. case 'dropRight': end -= size; break;
  19315. case 'take': end = nativeMin(end, start + size); break;
  19316. case 'takeRight': start = nativeMax(start, end - size); break;
  19317. }
  19318. }
  19319. return { 'start': start, 'end': end };
  19320. }
  19321. /**
  19322. * Extracts wrapper details from the `source` body comment.
  19323. *
  19324. * @private
  19325. * @param {string} source The source to inspect.
  19326. * @returns {Array} Returns the wrapper details.
  19327. */
  19328. function getWrapDetails(source) {
  19329. var match = source.match(reWrapDetails);
  19330. return match ? match[1].split(reSplitDetails) : [];
  19331. }
  19332. /**
  19333. * Checks if `path` exists on `object`.
  19334. *
  19335. * @private
  19336. * @param {Object} object The object to query.
  19337. * @param {Array|string} path The path to check.
  19338. * @param {Function} hasFunc The function to check properties.
  19339. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  19340. */
  19341. function hasPath(object, path, hasFunc) {
  19342. path = castPath(path, object);
  19343. var index = -1,
  19344. length = path.length,
  19345. result = false;
  19346. while (++index < length) {
  19347. var key = toKey(path[index]);
  19348. if (!(result = object != null && hasFunc(object, key))) {
  19349. break;
  19350. }
  19351. object = object[key];
  19352. }
  19353. if (result || ++index != length) {
  19354. return result;
  19355. }
  19356. length = object == null ? 0 : object.length;
  19357. return !!length && isLength(length) && isIndex(key, length) &&
  19358. (isArray(object) || isArguments(object));
  19359. }
  19360. /**
  19361. * Initializes an array clone.
  19362. *
  19363. * @private
  19364. * @param {Array} array The array to clone.
  19365. * @returns {Array} Returns the initialized clone.
  19366. */
  19367. function initCloneArray(array) {
  19368. var length = array.length,
  19369. result = new array.constructor(length);
  19370. // Add properties assigned by `RegExp#exec`.
  19371. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  19372. result.index = array.index;
  19373. result.input = array.input;
  19374. }
  19375. return result;
  19376. }
  19377. /**
  19378. * Initializes an object clone.
  19379. *
  19380. * @private
  19381. * @param {Object} object The object to clone.
  19382. * @returns {Object} Returns the initialized clone.
  19383. */
  19384. function initCloneObject(object) {
  19385. return (typeof object.constructor == 'function' && !isPrototype(object))
  19386. ? baseCreate(getPrototype(object))
  19387. : {};
  19388. }
  19389. /**
  19390. * Initializes an object clone based on its `toStringTag`.
  19391. *
  19392. * **Note:** This function only supports cloning values with tags of
  19393. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  19394. *
  19395. * @private
  19396. * @param {Object} object The object to clone.
  19397. * @param {string} tag The `toStringTag` of the object to clone.
  19398. * @param {boolean} [isDeep] Specify a deep clone.
  19399. * @returns {Object} Returns the initialized clone.
  19400. */
  19401. function initCloneByTag(object, tag, isDeep) {
  19402. var Ctor = object.constructor;
  19403. switch (tag) {
  19404. case arrayBufferTag:
  19405. return cloneArrayBuffer(object);
  19406. case boolTag:
  19407. case dateTag:
  19408. return new Ctor(+object);
  19409. case dataViewTag:
  19410. return cloneDataView(object, isDeep);
  19411. case float32Tag: case float64Tag:
  19412. case int8Tag: case int16Tag: case int32Tag:
  19413. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  19414. return cloneTypedArray(object, isDeep);
  19415. case mapTag:
  19416. return new Ctor;
  19417. case numberTag:
  19418. case stringTag:
  19419. return new Ctor(object);
  19420. case regexpTag:
  19421. return cloneRegExp(object);
  19422. case setTag:
  19423. return new Ctor;
  19424. case symbolTag:
  19425. return cloneSymbol(object);
  19426. }
  19427. }
  19428. /**
  19429. * Inserts wrapper `details` in a comment at the top of the `source` body.
  19430. *
  19431. * @private
  19432. * @param {string} source The source to modify.
  19433. * @returns {Array} details The details to insert.
  19434. * @returns {string} Returns the modified source.
  19435. */
  19436. function insertWrapDetails(source, details) {
  19437. var length = details.length;
  19438. if (!length) {
  19439. return source;
  19440. }
  19441. var lastIndex = length - 1;
  19442. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  19443. details = details.join(length > 2 ? ', ' : ' ');
  19444. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  19445. }
  19446. /**
  19447. * Checks if `value` is a flattenable `arguments` object or array.
  19448. *
  19449. * @private
  19450. * @param {*} value The value to check.
  19451. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  19452. */
  19453. function isFlattenable(value) {
  19454. return isArray(value) || isArguments(value) ||
  19455. !!(spreadableSymbol && value && value[spreadableSymbol]);
  19456. }
  19457. /**
  19458. * Checks if `value` is a valid array-like index.
  19459. *
  19460. * @private
  19461. * @param {*} value The value to check.
  19462. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  19463. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  19464. */
  19465. function isIndex(value, length) {
  19466. var type = typeof value;
  19467. length = length == null ? MAX_SAFE_INTEGER : length;
  19468. return !!length &&
  19469. (type == 'number' ||
  19470. (type != 'symbol' && reIsUint.test(value))) &&
  19471. (value > -1 && value % 1 == 0 && value < length);
  19472. }
  19473. /**
  19474. * Checks if the given arguments are from an iteratee call.
  19475. *
  19476. * @private
  19477. * @param {*} value The potential iteratee value argument.
  19478. * @param {*} index The potential iteratee index or key argument.
  19479. * @param {*} object The potential iteratee object argument.
  19480. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  19481. * else `false`.
  19482. */
  19483. function isIterateeCall(value, index, object) {
  19484. if (!isObject(object)) {
  19485. return false;
  19486. }
  19487. var type = typeof index;
  19488. if (type == 'number'
  19489. ? (isArrayLike(object) && isIndex(index, object.length))
  19490. : (type == 'string' && index in object)
  19491. ) {
  19492. return eq(object[index], value);
  19493. }
  19494. return false;
  19495. }
  19496. /**
  19497. * Checks if `value` is a property name and not a property path.
  19498. *
  19499. * @private
  19500. * @param {*} value The value to check.
  19501. * @param {Object} [object] The object to query keys on.
  19502. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  19503. */
  19504. function isKey(value, object) {
  19505. if (isArray(value)) {
  19506. return false;
  19507. }
  19508. var type = typeof value;
  19509. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  19510. value == null || isSymbol(value)) {
  19511. return true;
  19512. }
  19513. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  19514. (object != null && value in Object(object));
  19515. }
  19516. /**
  19517. * Checks if `value` is suitable for use as unique object key.
  19518. *
  19519. * @private
  19520. * @param {*} value The value to check.
  19521. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  19522. */
  19523. function isKeyable(value) {
  19524. var type = typeof value;
  19525. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  19526. ? (value !== '__proto__')
  19527. : (value === null);
  19528. }
  19529. /**
  19530. * Checks if `func` has a lazy counterpart.
  19531. *
  19532. * @private
  19533. * @param {Function} func The function to check.
  19534. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  19535. * else `false`.
  19536. */
  19537. function isLaziable(func) {
  19538. var funcName = getFuncName(func),
  19539. other = lodash[funcName];
  19540. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  19541. return false;
  19542. }
  19543. if (func === other) {
  19544. return true;
  19545. }
  19546. var data = getData(other);
  19547. return !!data && func === data[0];
  19548. }
  19549. /**
  19550. * Checks if `func` has its source masked.
  19551. *
  19552. * @private
  19553. * @param {Function} func The function to check.
  19554. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  19555. */
  19556. function isMasked(func) {
  19557. return !!maskSrcKey && (maskSrcKey in func);
  19558. }
  19559. /**
  19560. * Checks if `func` is capable of being masked.
  19561. *
  19562. * @private
  19563. * @param {*} value The value to check.
  19564. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  19565. */
  19566. var isMaskable = coreJsData ? isFunction : stubFalse;
  19567. /**
  19568. * Checks if `value` is likely a prototype object.
  19569. *
  19570. * @private
  19571. * @param {*} value The value to check.
  19572. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  19573. */
  19574. function isPrototype(value) {
  19575. var Ctor = value && value.constructor,
  19576. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  19577. return value === proto;
  19578. }
  19579. /**
  19580. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  19581. *
  19582. * @private
  19583. * @param {*} value The value to check.
  19584. * @returns {boolean} Returns `true` if `value` if suitable for strict
  19585. * equality comparisons, else `false`.
  19586. */
  19587. function isStrictComparable(value) {
  19588. return value === value && !isObject(value);
  19589. }
  19590. /**
  19591. * A specialized version of `matchesProperty` for source values suitable
  19592. * for strict equality comparisons, i.e. `===`.
  19593. *
  19594. * @private
  19595. * @param {string} key The key of the property to get.
  19596. * @param {*} srcValue The value to match.
  19597. * @returns {Function} Returns the new spec function.
  19598. */
  19599. function matchesStrictComparable(key, srcValue) {
  19600. return function(object) {
  19601. if (object == null) {
  19602. return false;
  19603. }
  19604. return object[key] === srcValue &&
  19605. (srcValue !== undefined || (key in Object(object)));
  19606. };
  19607. }
  19608. /**
  19609. * A specialized version of `_.memoize` which clears the memoized function's
  19610. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  19611. *
  19612. * @private
  19613. * @param {Function} func The function to have its output memoized.
  19614. * @returns {Function} Returns the new memoized function.
  19615. */
  19616. function memoizeCapped(func) {
  19617. var result = memoize(func, function(key) {
  19618. if (cache.size === MAX_MEMOIZE_SIZE) {
  19619. cache.clear();
  19620. }
  19621. return key;
  19622. });
  19623. var cache = result.cache;
  19624. return result;
  19625. }
  19626. /**
  19627. * Merges the function metadata of `source` into `data`.
  19628. *
  19629. * Merging metadata reduces the number of wrappers used to invoke a function.
  19630. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  19631. * may be applied regardless of execution order. Methods like `_.ary` and
  19632. * `_.rearg` modify function arguments, making the order in which they are
  19633. * executed important, preventing the merging of metadata. However, we make
  19634. * an exception for a safe combined case where curried functions have `_.ary`
  19635. * and or `_.rearg` applied.
  19636. *
  19637. * @private
  19638. * @param {Array} data The destination metadata.
  19639. * @param {Array} source The source metadata.
  19640. * @returns {Array} Returns `data`.
  19641. */
  19642. function mergeData(data, source) {
  19643. var bitmask = data[1],
  19644. srcBitmask = source[1],
  19645. newBitmask = bitmask | srcBitmask,
  19646. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  19647. var isCombo =
  19648. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  19649. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  19650. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  19651. // Exit early if metadata can't be merged.
  19652. if (!(isCommon || isCombo)) {
  19653. return data;
  19654. }
  19655. // Use source `thisArg` if available.
  19656. if (srcBitmask & WRAP_BIND_FLAG) {
  19657. data[2] = source[2];
  19658. // Set when currying a bound function.
  19659. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  19660. }
  19661. // Compose partial arguments.
  19662. var value = source[3];
  19663. if (value) {
  19664. var partials = data[3];
  19665. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  19666. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  19667. }
  19668. // Compose partial right arguments.
  19669. value = source[5];
  19670. if (value) {
  19671. partials = data[5];
  19672. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  19673. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  19674. }
  19675. // Use source `argPos` if available.
  19676. value = source[7];
  19677. if (value) {
  19678. data[7] = value;
  19679. }
  19680. // Use source `ary` if it's smaller.
  19681. if (srcBitmask & WRAP_ARY_FLAG) {
  19682. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  19683. }
  19684. // Use source `arity` if one is not provided.
  19685. if (data[9] == null) {
  19686. data[9] = source[9];
  19687. }
  19688. // Use source `func` and merge bitmasks.
  19689. data[0] = source[0];
  19690. data[1] = newBitmask;
  19691. return data;
  19692. }
  19693. /**
  19694. * This function is like
  19695. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  19696. * except that it includes inherited enumerable properties.
  19697. *
  19698. * @private
  19699. * @param {Object} object The object to query.
  19700. * @returns {Array} Returns the array of property names.
  19701. */
  19702. function nativeKeysIn(object) {
  19703. var result = [];
  19704. if (object != null) {
  19705. for (var key in Object(object)) {
  19706. result.push(key);
  19707. }
  19708. }
  19709. return result;
  19710. }
  19711. /**
  19712. * Converts `value` to a string using `Object.prototype.toString`.
  19713. *
  19714. * @private
  19715. * @param {*} value The value to convert.
  19716. * @returns {string} Returns the converted string.
  19717. */
  19718. function objectToString(value) {
  19719. return nativeObjectToString.call(value);
  19720. }
  19721. /**
  19722. * A specialized version of `baseRest` which transforms the rest array.
  19723. *
  19724. * @private
  19725. * @param {Function} func The function to apply a rest parameter to.
  19726. * @param {number} [start=func.length-1] The start position of the rest parameter.
  19727. * @param {Function} transform The rest array transform.
  19728. * @returns {Function} Returns the new function.
  19729. */
  19730. function overRest(func, start, transform) {
  19731. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  19732. return function() {
  19733. var args = arguments,
  19734. index = -1,
  19735. length = nativeMax(args.length - start, 0),
  19736. array = Array(length);
  19737. while (++index < length) {
  19738. array[index] = args[start + index];
  19739. }
  19740. index = -1;
  19741. var otherArgs = Array(start + 1);
  19742. while (++index < start) {
  19743. otherArgs[index] = args[index];
  19744. }
  19745. otherArgs[start] = transform(array);
  19746. return apply(func, this, otherArgs);
  19747. };
  19748. }
  19749. /**
  19750. * Gets the parent value at `path` of `object`.
  19751. *
  19752. * @private
  19753. * @param {Object} object The object to query.
  19754. * @param {Array} path The path to get the parent value of.
  19755. * @returns {*} Returns the parent value.
  19756. */
  19757. function parent(object, path) {
  19758. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  19759. }
  19760. /**
  19761. * Reorder `array` according to the specified indexes where the element at
  19762. * the first index is assigned as the first element, the element at
  19763. * the second index is assigned as the second element, and so on.
  19764. *
  19765. * @private
  19766. * @param {Array} array The array to reorder.
  19767. * @param {Array} indexes The arranged array indexes.
  19768. * @returns {Array} Returns `array`.
  19769. */
  19770. function reorder(array, indexes) {
  19771. var arrLength = array.length,
  19772. length = nativeMin(indexes.length, arrLength),
  19773. oldArray = copyArray(array);
  19774. while (length--) {
  19775. var index = indexes[length];
  19776. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  19777. }
  19778. return array;
  19779. }
  19780. /**
  19781. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  19782. *
  19783. * @private
  19784. * @param {Object} object The object to query.
  19785. * @param {string} key The key of the property to get.
  19786. * @returns {*} Returns the property value.
  19787. */
  19788. function safeGet(object, key) {
  19789. if (key === 'constructor' && typeof object[key] === 'function') {
  19790. return;
  19791. }
  19792. if (key == '__proto__') {
  19793. return;
  19794. }
  19795. return object[key];
  19796. }
  19797. /**
  19798. * Sets metadata for `func`.
  19799. *
  19800. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  19801. * period of time, it will trip its breaker and transition to an identity
  19802. * function to avoid garbage collection pauses in V8. See
  19803. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  19804. * for more details.
  19805. *
  19806. * @private
  19807. * @param {Function} func The function to associate metadata with.
  19808. * @param {*} data The metadata.
  19809. * @returns {Function} Returns `func`.
  19810. */
  19811. var setData = shortOut(baseSetData);
  19812. /**
  19813. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  19814. *
  19815. * @private
  19816. * @param {Function} func The function to delay.
  19817. * @param {number} wait The number of milliseconds to delay invocation.
  19818. * @returns {number|Object} Returns the timer id or timeout object.
  19819. */
  19820. var setTimeout = ctxSetTimeout || function(func, wait) {
  19821. return root.setTimeout(func, wait);
  19822. };
  19823. /**
  19824. * Sets the `toString` method of `func` to return `string`.
  19825. *
  19826. * @private
  19827. * @param {Function} func The function to modify.
  19828. * @param {Function} string The `toString` result.
  19829. * @returns {Function} Returns `func`.
  19830. */
  19831. var setToString = shortOut(baseSetToString);
  19832. /**
  19833. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  19834. * with wrapper details in a comment at the top of the source body.
  19835. *
  19836. * @private
  19837. * @param {Function} wrapper The function to modify.
  19838. * @param {Function} reference The reference function.
  19839. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  19840. * @returns {Function} Returns `wrapper`.
  19841. */
  19842. function setWrapToString(wrapper, reference, bitmask) {
  19843. var source = (reference + '');
  19844. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  19845. }
  19846. /**
  19847. * Creates a function that'll short out and invoke `identity` instead
  19848. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  19849. * milliseconds.
  19850. *
  19851. * @private
  19852. * @param {Function} func The function to restrict.
  19853. * @returns {Function} Returns the new shortable function.
  19854. */
  19855. function shortOut(func) {
  19856. var count = 0,
  19857. lastCalled = 0;
  19858. return function() {
  19859. var stamp = nativeNow(),
  19860. remaining = HOT_SPAN - (stamp - lastCalled);
  19861. lastCalled = stamp;
  19862. if (remaining > 0) {
  19863. if (++count >= HOT_COUNT) {
  19864. return arguments[0];
  19865. }
  19866. } else {
  19867. count = 0;
  19868. }
  19869. return func.apply(undefined, arguments);
  19870. };
  19871. }
  19872. /**
  19873. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  19874. *
  19875. * @private
  19876. * @param {Array} array The array to shuffle.
  19877. * @param {number} [size=array.length] The size of `array`.
  19878. * @returns {Array} Returns `array`.
  19879. */
  19880. function shuffleSelf(array, size) {
  19881. var index = -1,
  19882. length = array.length,
  19883. lastIndex = length - 1;
  19884. size = size === undefined ? length : size;
  19885. while (++index < size) {
  19886. var rand = baseRandom(index, lastIndex),
  19887. value = array[rand];
  19888. array[rand] = array[index];
  19889. array[index] = value;
  19890. }
  19891. array.length = size;
  19892. return array;
  19893. }
  19894. /**
  19895. * Converts `string` to a property path array.
  19896. *
  19897. * @private
  19898. * @param {string} string The string to convert.
  19899. * @returns {Array} Returns the property path array.
  19900. */
  19901. var stringToPath = memoizeCapped(function(string) {
  19902. var result = [];
  19903. if (string.charCodeAt(0) === 46 /* . */) {
  19904. result.push('');
  19905. }
  19906. string.replace(rePropName, function(match, number, quote, subString) {
  19907. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  19908. });
  19909. return result;
  19910. });
  19911. /**
  19912. * Converts `value` to a string key if it's not a string or symbol.
  19913. *
  19914. * @private
  19915. * @param {*} value The value to inspect.
  19916. * @returns {string|symbol} Returns the key.
  19917. */
  19918. function toKey(value) {
  19919. if (typeof value == 'string' || isSymbol(value)) {
  19920. return value;
  19921. }
  19922. var result = (value + '');
  19923. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  19924. }
  19925. /**
  19926. * Converts `func` to its source code.
  19927. *
  19928. * @private
  19929. * @param {Function} func The function to convert.
  19930. * @returns {string} Returns the source code.
  19931. */
  19932. function toSource(func) {
  19933. if (func != null) {
  19934. try {
  19935. return funcToString.call(func);
  19936. } catch (e) {}
  19937. try {
  19938. return (func + '');
  19939. } catch (e) {}
  19940. }
  19941. return '';
  19942. }
  19943. /**
  19944. * Updates wrapper `details` based on `bitmask` flags.
  19945. *
  19946. * @private
  19947. * @returns {Array} details The details to modify.
  19948. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  19949. * @returns {Array} Returns `details`.
  19950. */
  19951. function updateWrapDetails(details, bitmask) {
  19952. arrayEach(wrapFlags, function(pair) {
  19953. var value = '_.' + pair[0];
  19954. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  19955. details.push(value);
  19956. }
  19957. });
  19958. return details.sort();
  19959. }
  19960. /**
  19961. * Creates a clone of `wrapper`.
  19962. *
  19963. * @private
  19964. * @param {Object} wrapper The wrapper to clone.
  19965. * @returns {Object} Returns the cloned wrapper.
  19966. */
  19967. function wrapperClone(wrapper) {
  19968. if (wrapper instanceof LazyWrapper) {
  19969. return wrapper.clone();
  19970. }
  19971. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  19972. result.__actions__ = copyArray(wrapper.__actions__);
  19973. result.__index__ = wrapper.__index__;
  19974. result.__values__ = wrapper.__values__;
  19975. return result;
  19976. }
  19977. /*------------------------------------------------------------------------*/
  19978. /**
  19979. * Creates an array of elements split into groups the length of `size`.
  19980. * If `array` can't be split evenly, the final chunk will be the remaining
  19981. * elements.
  19982. *
  19983. * @static
  19984. * @memberOf _
  19985. * @since 3.0.0
  19986. * @category Array
  19987. * @param {Array} array The array to process.
  19988. * @param {number} [size=1] The length of each chunk
  19989. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19990. * @returns {Array} Returns the new array of chunks.
  19991. * @example
  19992. *
  19993. * _.chunk(['a', 'b', 'c', 'd'], 2);
  19994. * // => [['a', 'b'], ['c', 'd']]
  19995. *
  19996. * _.chunk(['a', 'b', 'c', 'd'], 3);
  19997. * // => [['a', 'b', 'c'], ['d']]
  19998. */
  19999. function chunk(array, size, guard) {
  20000. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  20001. size = 1;
  20002. } else {
  20003. size = nativeMax(toInteger(size), 0);
  20004. }
  20005. var length = array == null ? 0 : array.length;
  20006. if (!length || size < 1) {
  20007. return [];
  20008. }
  20009. var index = 0,
  20010. resIndex = 0,
  20011. result = Array(nativeCeil(length / size));
  20012. while (index < length) {
  20013. result[resIndex++] = baseSlice(array, index, (index += size));
  20014. }
  20015. return result;
  20016. }
  20017. /**
  20018. * Creates an array with all falsey values removed. The values `false`, `null`,
  20019. * `0`, `""`, `undefined`, and `NaN` are falsey.
  20020. *
  20021. * @static
  20022. * @memberOf _
  20023. * @since 0.1.0
  20024. * @category Array
  20025. * @param {Array} array The array to compact.
  20026. * @returns {Array} Returns the new array of filtered values.
  20027. * @example
  20028. *
  20029. * _.compact([0, 1, false, 2, '', 3]);
  20030. * // => [1, 2, 3]
  20031. */
  20032. function compact(array) {
  20033. var index = -1,
  20034. length = array == null ? 0 : array.length,
  20035. resIndex = 0,
  20036. result = [];
  20037. while (++index < length) {
  20038. var value = array[index];
  20039. if (value) {
  20040. result[resIndex++] = value;
  20041. }
  20042. }
  20043. return result;
  20044. }
  20045. /**
  20046. * Creates a new array concatenating `array` with any additional arrays
  20047. * and/or values.
  20048. *
  20049. * @static
  20050. * @memberOf _
  20051. * @since 4.0.0
  20052. * @category Array
  20053. * @param {Array} array The array to concatenate.
  20054. * @param {...*} [values] The values to concatenate.
  20055. * @returns {Array} Returns the new concatenated array.
  20056. * @example
  20057. *
  20058. * var array = [1];
  20059. * var other = _.concat(array, 2, [3], [[4]]);
  20060. *
  20061. * console.log(other);
  20062. * // => [1, 2, 3, [4]]
  20063. *
  20064. * console.log(array);
  20065. * // => [1]
  20066. */
  20067. function concat() {
  20068. var length = arguments.length;
  20069. if (!length) {
  20070. return [];
  20071. }
  20072. var args = Array(length - 1),
  20073. array = arguments[0],
  20074. index = length;
  20075. while (index--) {
  20076. args[index - 1] = arguments[index];
  20077. }
  20078. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  20079. }
  20080. /**
  20081. * Creates an array of `array` values not included in the other given arrays
  20082. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20083. * for equality comparisons. The order and references of result values are
  20084. * determined by the first array.
  20085. *
  20086. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  20087. *
  20088. * @static
  20089. * @memberOf _
  20090. * @since 0.1.0
  20091. * @category Array
  20092. * @param {Array} array The array to inspect.
  20093. * @param {...Array} [values] The values to exclude.
  20094. * @returns {Array} Returns the new array of filtered values.
  20095. * @see _.without, _.xor
  20096. * @example
  20097. *
  20098. * _.difference([2, 1], [2, 3]);
  20099. * // => [1]
  20100. */
  20101. var difference = baseRest(function(array, values) {
  20102. return isArrayLikeObject(array)
  20103. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  20104. : [];
  20105. });
  20106. /**
  20107. * This method is like `_.difference` except that it accepts `iteratee` which
  20108. * is invoked for each element of `array` and `values` to generate the criterion
  20109. * by which they're compared. The order and references of result values are
  20110. * determined by the first array. The iteratee is invoked with one argument:
  20111. * (value).
  20112. *
  20113. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  20114. *
  20115. * @static
  20116. * @memberOf _
  20117. * @since 4.0.0
  20118. * @category Array
  20119. * @param {Array} array The array to inspect.
  20120. * @param {...Array} [values] The values to exclude.
  20121. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20122. * @returns {Array} Returns the new array of filtered values.
  20123. * @example
  20124. *
  20125. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  20126. * // => [1.2]
  20127. *
  20128. * // The `_.property` iteratee shorthand.
  20129. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  20130. * // => [{ 'x': 2 }]
  20131. */
  20132. var differenceBy = baseRest(function(array, values) {
  20133. var iteratee = last(values);
  20134. if (isArrayLikeObject(iteratee)) {
  20135. iteratee = undefined;
  20136. }
  20137. return isArrayLikeObject(array)
  20138. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  20139. : [];
  20140. });
  20141. /**
  20142. * This method is like `_.difference` except that it accepts `comparator`
  20143. * which is invoked to compare elements of `array` to `values`. The order and
  20144. * references of result values are determined by the first array. The comparator
  20145. * is invoked with two arguments: (arrVal, othVal).
  20146. *
  20147. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  20148. *
  20149. * @static
  20150. * @memberOf _
  20151. * @since 4.0.0
  20152. * @category Array
  20153. * @param {Array} array The array to inspect.
  20154. * @param {...Array} [values] The values to exclude.
  20155. * @param {Function} [comparator] The comparator invoked per element.
  20156. * @returns {Array} Returns the new array of filtered values.
  20157. * @example
  20158. *
  20159. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  20160. *
  20161. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  20162. * // => [{ 'x': 2, 'y': 1 }]
  20163. */
  20164. var differenceWith = baseRest(function(array, values) {
  20165. var comparator = last(values);
  20166. if (isArrayLikeObject(comparator)) {
  20167. comparator = undefined;
  20168. }
  20169. return isArrayLikeObject(array)
  20170. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  20171. : [];
  20172. });
  20173. /**
  20174. * Creates a slice of `array` with `n` elements dropped from the beginning.
  20175. *
  20176. * @static
  20177. * @memberOf _
  20178. * @since 0.5.0
  20179. * @category Array
  20180. * @param {Array} array The array to query.
  20181. * @param {number} [n=1] The number of elements to drop.
  20182. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20183. * @returns {Array} Returns the slice of `array`.
  20184. * @example
  20185. *
  20186. * _.drop([1, 2, 3]);
  20187. * // => [2, 3]
  20188. *
  20189. * _.drop([1, 2, 3], 2);
  20190. * // => [3]
  20191. *
  20192. * _.drop([1, 2, 3], 5);
  20193. * // => []
  20194. *
  20195. * _.drop([1, 2, 3], 0);
  20196. * // => [1, 2, 3]
  20197. */
  20198. function drop(array, n, guard) {
  20199. var length = array == null ? 0 : array.length;
  20200. if (!length) {
  20201. return [];
  20202. }
  20203. n = (guard || n === undefined) ? 1 : toInteger(n);
  20204. return baseSlice(array, n < 0 ? 0 : n, length);
  20205. }
  20206. /**
  20207. * Creates a slice of `array` with `n` elements dropped from the end.
  20208. *
  20209. * @static
  20210. * @memberOf _
  20211. * @since 3.0.0
  20212. * @category Array
  20213. * @param {Array} array The array to query.
  20214. * @param {number} [n=1] The number of elements to drop.
  20215. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20216. * @returns {Array} Returns the slice of `array`.
  20217. * @example
  20218. *
  20219. * _.dropRight([1, 2, 3]);
  20220. * // => [1, 2]
  20221. *
  20222. * _.dropRight([1, 2, 3], 2);
  20223. * // => [1]
  20224. *
  20225. * _.dropRight([1, 2, 3], 5);
  20226. * // => []
  20227. *
  20228. * _.dropRight([1, 2, 3], 0);
  20229. * // => [1, 2, 3]
  20230. */
  20231. function dropRight(array, n, guard) {
  20232. var length = array == null ? 0 : array.length;
  20233. if (!length) {
  20234. return [];
  20235. }
  20236. n = (guard || n === undefined) ? 1 : toInteger(n);
  20237. n = length - n;
  20238. return baseSlice(array, 0, n < 0 ? 0 : n);
  20239. }
  20240. /**
  20241. * Creates a slice of `array` excluding elements dropped from the end.
  20242. * Elements are dropped until `predicate` returns falsey. The predicate is
  20243. * invoked with three arguments: (value, index, array).
  20244. *
  20245. * @static
  20246. * @memberOf _
  20247. * @since 3.0.0
  20248. * @category Array
  20249. * @param {Array} array The array to query.
  20250. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20251. * @returns {Array} Returns the slice of `array`.
  20252. * @example
  20253. *
  20254. * var users = [
  20255. * { 'user': 'barney', 'active': true },
  20256. * { 'user': 'fred', 'active': false },
  20257. * { 'user': 'pebbles', 'active': false }
  20258. * ];
  20259. *
  20260. * _.dropRightWhile(users, function(o) { return !o.active; });
  20261. * // => objects for ['barney']
  20262. *
  20263. * // The `_.matches` iteratee shorthand.
  20264. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  20265. * // => objects for ['barney', 'fred']
  20266. *
  20267. * // The `_.matchesProperty` iteratee shorthand.
  20268. * _.dropRightWhile(users, ['active', false]);
  20269. * // => objects for ['barney']
  20270. *
  20271. * // The `_.property` iteratee shorthand.
  20272. * _.dropRightWhile(users, 'active');
  20273. * // => objects for ['barney', 'fred', 'pebbles']
  20274. */
  20275. function dropRightWhile(array, predicate) {
  20276. return (array && array.length)
  20277. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  20278. : [];
  20279. }
  20280. /**
  20281. * Creates a slice of `array` excluding elements dropped from the beginning.
  20282. * Elements are dropped until `predicate` returns falsey. The predicate is
  20283. * invoked with three arguments: (value, index, array).
  20284. *
  20285. * @static
  20286. * @memberOf _
  20287. * @since 3.0.0
  20288. * @category Array
  20289. * @param {Array} array The array to query.
  20290. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20291. * @returns {Array} Returns the slice of `array`.
  20292. * @example
  20293. *
  20294. * var users = [
  20295. * { 'user': 'barney', 'active': false },
  20296. * { 'user': 'fred', 'active': false },
  20297. * { 'user': 'pebbles', 'active': true }
  20298. * ];
  20299. *
  20300. * _.dropWhile(users, function(o) { return !o.active; });
  20301. * // => objects for ['pebbles']
  20302. *
  20303. * // The `_.matches` iteratee shorthand.
  20304. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  20305. * // => objects for ['fred', 'pebbles']
  20306. *
  20307. * // The `_.matchesProperty` iteratee shorthand.
  20308. * _.dropWhile(users, ['active', false]);
  20309. * // => objects for ['pebbles']
  20310. *
  20311. * // The `_.property` iteratee shorthand.
  20312. * _.dropWhile(users, 'active');
  20313. * // => objects for ['barney', 'fred', 'pebbles']
  20314. */
  20315. function dropWhile(array, predicate) {
  20316. return (array && array.length)
  20317. ? baseWhile(array, getIteratee(predicate, 3), true)
  20318. : [];
  20319. }
  20320. /**
  20321. * Fills elements of `array` with `value` from `start` up to, but not
  20322. * including, `end`.
  20323. *
  20324. * **Note:** This method mutates `array`.
  20325. *
  20326. * @static
  20327. * @memberOf _
  20328. * @since 3.2.0
  20329. * @category Array
  20330. * @param {Array} array The array to fill.
  20331. * @param {*} value The value to fill `array` with.
  20332. * @param {number} [start=0] The start position.
  20333. * @param {number} [end=array.length] The end position.
  20334. * @returns {Array} Returns `array`.
  20335. * @example
  20336. *
  20337. * var array = [1, 2, 3];
  20338. *
  20339. * _.fill(array, 'a');
  20340. * console.log(array);
  20341. * // => ['a', 'a', 'a']
  20342. *
  20343. * _.fill(Array(3), 2);
  20344. * // => [2, 2, 2]
  20345. *
  20346. * _.fill([4, 6, 8, 10], '*', 1, 3);
  20347. * // => [4, '*', '*', 10]
  20348. */
  20349. function fill(array, value, start, end) {
  20350. var length = array == null ? 0 : array.length;
  20351. if (!length) {
  20352. return [];
  20353. }
  20354. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  20355. start = 0;
  20356. end = length;
  20357. }
  20358. return baseFill(array, value, start, end);
  20359. }
  20360. /**
  20361. * This method is like `_.find` except that it returns the index of the first
  20362. * element `predicate` returns truthy for instead of the element itself.
  20363. *
  20364. * @static
  20365. * @memberOf _
  20366. * @since 1.1.0
  20367. * @category Array
  20368. * @param {Array} array The array to inspect.
  20369. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20370. * @param {number} [fromIndex=0] The index to search from.
  20371. * @returns {number} Returns the index of the found element, else `-1`.
  20372. * @example
  20373. *
  20374. * var users = [
  20375. * { 'user': 'barney', 'active': false },
  20376. * { 'user': 'fred', 'active': false },
  20377. * { 'user': 'pebbles', 'active': true }
  20378. * ];
  20379. *
  20380. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  20381. * // => 0
  20382. *
  20383. * // The `_.matches` iteratee shorthand.
  20384. * _.findIndex(users, { 'user': 'fred', 'active': false });
  20385. * // => 1
  20386. *
  20387. * // The `_.matchesProperty` iteratee shorthand.
  20388. * _.findIndex(users, ['active', false]);
  20389. * // => 0
  20390. *
  20391. * // The `_.property` iteratee shorthand.
  20392. * _.findIndex(users, 'active');
  20393. * // => 2
  20394. */
  20395. function findIndex(array, predicate, fromIndex) {
  20396. var length = array == null ? 0 : array.length;
  20397. if (!length) {
  20398. return -1;
  20399. }
  20400. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  20401. if (index < 0) {
  20402. index = nativeMax(length + index, 0);
  20403. }
  20404. return baseFindIndex(array, getIteratee(predicate, 3), index);
  20405. }
  20406. /**
  20407. * This method is like `_.findIndex` except that it iterates over elements
  20408. * of `collection` from right to left.
  20409. *
  20410. * @static
  20411. * @memberOf _
  20412. * @since 2.0.0
  20413. * @category Array
  20414. * @param {Array} array The array to inspect.
  20415. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20416. * @param {number} [fromIndex=array.length-1] The index to search from.
  20417. * @returns {number} Returns the index of the found element, else `-1`.
  20418. * @example
  20419. *
  20420. * var users = [
  20421. * { 'user': 'barney', 'active': true },
  20422. * { 'user': 'fred', 'active': false },
  20423. * { 'user': 'pebbles', 'active': false }
  20424. * ];
  20425. *
  20426. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  20427. * // => 2
  20428. *
  20429. * // The `_.matches` iteratee shorthand.
  20430. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  20431. * // => 0
  20432. *
  20433. * // The `_.matchesProperty` iteratee shorthand.
  20434. * _.findLastIndex(users, ['active', false]);
  20435. * // => 2
  20436. *
  20437. * // The `_.property` iteratee shorthand.
  20438. * _.findLastIndex(users, 'active');
  20439. * // => 0
  20440. */
  20441. function findLastIndex(array, predicate, fromIndex) {
  20442. var length = array == null ? 0 : array.length;
  20443. if (!length) {
  20444. return -1;
  20445. }
  20446. var index = length - 1;
  20447. if (fromIndex !== undefined) {
  20448. index = toInteger(fromIndex);
  20449. index = fromIndex < 0
  20450. ? nativeMax(length + index, 0)
  20451. : nativeMin(index, length - 1);
  20452. }
  20453. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  20454. }
  20455. /**
  20456. * Flattens `array` a single level deep.
  20457. *
  20458. * @static
  20459. * @memberOf _
  20460. * @since 0.1.0
  20461. * @category Array
  20462. * @param {Array} array The array to flatten.
  20463. * @returns {Array} Returns the new flattened array.
  20464. * @example
  20465. *
  20466. * _.flatten([1, [2, [3, [4]], 5]]);
  20467. * // => [1, 2, [3, [4]], 5]
  20468. */
  20469. function flatten(array) {
  20470. var length = array == null ? 0 : array.length;
  20471. return length ? baseFlatten(array, 1) : [];
  20472. }
  20473. /**
  20474. * Recursively flattens `array`.
  20475. *
  20476. * @static
  20477. * @memberOf _
  20478. * @since 3.0.0
  20479. * @category Array
  20480. * @param {Array} array The array to flatten.
  20481. * @returns {Array} Returns the new flattened array.
  20482. * @example
  20483. *
  20484. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  20485. * // => [1, 2, 3, 4, 5]
  20486. */
  20487. function flattenDeep(array) {
  20488. var length = array == null ? 0 : array.length;
  20489. return length ? baseFlatten(array, INFINITY) : [];
  20490. }
  20491. /**
  20492. * Recursively flatten `array` up to `depth` times.
  20493. *
  20494. * @static
  20495. * @memberOf _
  20496. * @since 4.4.0
  20497. * @category Array
  20498. * @param {Array} array The array to flatten.
  20499. * @param {number} [depth=1] The maximum recursion depth.
  20500. * @returns {Array} Returns the new flattened array.
  20501. * @example
  20502. *
  20503. * var array = [1, [2, [3, [4]], 5]];
  20504. *
  20505. * _.flattenDepth(array, 1);
  20506. * // => [1, 2, [3, [4]], 5]
  20507. *
  20508. * _.flattenDepth(array, 2);
  20509. * // => [1, 2, 3, [4], 5]
  20510. */
  20511. function flattenDepth(array, depth) {
  20512. var length = array == null ? 0 : array.length;
  20513. if (!length) {
  20514. return [];
  20515. }
  20516. depth = depth === undefined ? 1 : toInteger(depth);
  20517. return baseFlatten(array, depth);
  20518. }
  20519. /**
  20520. * The inverse of `_.toPairs`; this method returns an object composed
  20521. * from key-value `pairs`.
  20522. *
  20523. * @static
  20524. * @memberOf _
  20525. * @since 4.0.0
  20526. * @category Array
  20527. * @param {Array} pairs The key-value pairs.
  20528. * @returns {Object} Returns the new object.
  20529. * @example
  20530. *
  20531. * _.fromPairs([['a', 1], ['b', 2]]);
  20532. * // => { 'a': 1, 'b': 2 }
  20533. */
  20534. function fromPairs(pairs) {
  20535. var index = -1,
  20536. length = pairs == null ? 0 : pairs.length,
  20537. result = {};
  20538. while (++index < length) {
  20539. var pair = pairs[index];
  20540. result[pair[0]] = pair[1];
  20541. }
  20542. return result;
  20543. }
  20544. /**
  20545. * Gets the first element of `array`.
  20546. *
  20547. * @static
  20548. * @memberOf _
  20549. * @since 0.1.0
  20550. * @alias first
  20551. * @category Array
  20552. * @param {Array} array The array to query.
  20553. * @returns {*} Returns the first element of `array`.
  20554. * @example
  20555. *
  20556. * _.head([1, 2, 3]);
  20557. * // => 1
  20558. *
  20559. * _.head([]);
  20560. * // => undefined
  20561. */
  20562. function head(array) {
  20563. return (array && array.length) ? array[0] : undefined;
  20564. }
  20565. /**
  20566. * Gets the index at which the first occurrence of `value` is found in `array`
  20567. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20568. * for equality comparisons. If `fromIndex` is negative, it's used as the
  20569. * offset from the end of `array`.
  20570. *
  20571. * @static
  20572. * @memberOf _
  20573. * @since 0.1.0
  20574. * @category Array
  20575. * @param {Array} array The array to inspect.
  20576. * @param {*} value The value to search for.
  20577. * @param {number} [fromIndex=0] The index to search from.
  20578. * @returns {number} Returns the index of the matched value, else `-1`.
  20579. * @example
  20580. *
  20581. * _.indexOf([1, 2, 1, 2], 2);
  20582. * // => 1
  20583. *
  20584. * // Search from the `fromIndex`.
  20585. * _.indexOf([1, 2, 1, 2], 2, 2);
  20586. * // => 3
  20587. */
  20588. function indexOf(array, value, fromIndex) {
  20589. var length = array == null ? 0 : array.length;
  20590. if (!length) {
  20591. return -1;
  20592. }
  20593. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  20594. if (index < 0) {
  20595. index = nativeMax(length + index, 0);
  20596. }
  20597. return baseIndexOf(array, value, index);
  20598. }
  20599. /**
  20600. * Gets all but the last element of `array`.
  20601. *
  20602. * @static
  20603. * @memberOf _
  20604. * @since 0.1.0
  20605. * @category Array
  20606. * @param {Array} array The array to query.
  20607. * @returns {Array} Returns the slice of `array`.
  20608. * @example
  20609. *
  20610. * _.initial([1, 2, 3]);
  20611. * // => [1, 2]
  20612. */
  20613. function initial(array) {
  20614. var length = array == null ? 0 : array.length;
  20615. return length ? baseSlice(array, 0, -1) : [];
  20616. }
  20617. /**
  20618. * Creates an array of unique values that are included in all given arrays
  20619. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20620. * for equality comparisons. The order and references of result values are
  20621. * determined by the first array.
  20622. *
  20623. * @static
  20624. * @memberOf _
  20625. * @since 0.1.0
  20626. * @category Array
  20627. * @param {...Array} [arrays] The arrays to inspect.
  20628. * @returns {Array} Returns the new array of intersecting values.
  20629. * @example
  20630. *
  20631. * _.intersection([2, 1], [2, 3]);
  20632. * // => [2]
  20633. */
  20634. var intersection = baseRest(function(arrays) {
  20635. var mapped = arrayMap(arrays, castArrayLikeObject);
  20636. return (mapped.length && mapped[0] === arrays[0])
  20637. ? baseIntersection(mapped)
  20638. : [];
  20639. });
  20640. /**
  20641. * This method is like `_.intersection` except that it accepts `iteratee`
  20642. * which is invoked for each element of each `arrays` to generate the criterion
  20643. * by which they're compared. The order and references of result values are
  20644. * determined by the first array. The iteratee is invoked with one argument:
  20645. * (value).
  20646. *
  20647. * @static
  20648. * @memberOf _
  20649. * @since 4.0.0
  20650. * @category Array
  20651. * @param {...Array} [arrays] The arrays to inspect.
  20652. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20653. * @returns {Array} Returns the new array of intersecting values.
  20654. * @example
  20655. *
  20656. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  20657. * // => [2.1]
  20658. *
  20659. * // The `_.property` iteratee shorthand.
  20660. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  20661. * // => [{ 'x': 1 }]
  20662. */
  20663. var intersectionBy = baseRest(function(arrays) {
  20664. var iteratee = last(arrays),
  20665. mapped = arrayMap(arrays, castArrayLikeObject);
  20666. if (iteratee === last(mapped)) {
  20667. iteratee = undefined;
  20668. } else {
  20669. mapped.pop();
  20670. }
  20671. return (mapped.length && mapped[0] === arrays[0])
  20672. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  20673. : [];
  20674. });
  20675. /**
  20676. * This method is like `_.intersection` except that it accepts `comparator`
  20677. * which is invoked to compare elements of `arrays`. The order and references
  20678. * of result values are determined by the first array. The comparator is
  20679. * invoked with two arguments: (arrVal, othVal).
  20680. *
  20681. * @static
  20682. * @memberOf _
  20683. * @since 4.0.0
  20684. * @category Array
  20685. * @param {...Array} [arrays] The arrays to inspect.
  20686. * @param {Function} [comparator] The comparator invoked per element.
  20687. * @returns {Array} Returns the new array of intersecting values.
  20688. * @example
  20689. *
  20690. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  20691. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  20692. *
  20693. * _.intersectionWith(objects, others, _.isEqual);
  20694. * // => [{ 'x': 1, 'y': 2 }]
  20695. */
  20696. var intersectionWith = baseRest(function(arrays) {
  20697. var comparator = last(arrays),
  20698. mapped = arrayMap(arrays, castArrayLikeObject);
  20699. comparator = typeof comparator == 'function' ? comparator : undefined;
  20700. if (comparator) {
  20701. mapped.pop();
  20702. }
  20703. return (mapped.length && mapped[0] === arrays[0])
  20704. ? baseIntersection(mapped, undefined, comparator)
  20705. : [];
  20706. });
  20707. /**
  20708. * Converts all elements in `array` into a string separated by `separator`.
  20709. *
  20710. * @static
  20711. * @memberOf _
  20712. * @since 4.0.0
  20713. * @category Array
  20714. * @param {Array} array The array to convert.
  20715. * @param {string} [separator=','] The element separator.
  20716. * @returns {string} Returns the joined string.
  20717. * @example
  20718. *
  20719. * _.join(['a', 'b', 'c'], '~');
  20720. * // => 'a~b~c'
  20721. */
  20722. function join(array, separator) {
  20723. return array == null ? '' : nativeJoin.call(array, separator);
  20724. }
  20725. /**
  20726. * Gets the last element of `array`.
  20727. *
  20728. * @static
  20729. * @memberOf _
  20730. * @since 0.1.0
  20731. * @category Array
  20732. * @param {Array} array The array to query.
  20733. * @returns {*} Returns the last element of `array`.
  20734. * @example
  20735. *
  20736. * _.last([1, 2, 3]);
  20737. * // => 3
  20738. */
  20739. function last(array) {
  20740. var length = array == null ? 0 : array.length;
  20741. return length ? array[length - 1] : undefined;
  20742. }
  20743. /**
  20744. * This method is like `_.indexOf` except that it iterates over elements of
  20745. * `array` from right to left.
  20746. *
  20747. * @static
  20748. * @memberOf _
  20749. * @since 0.1.0
  20750. * @category Array
  20751. * @param {Array} array The array to inspect.
  20752. * @param {*} value The value to search for.
  20753. * @param {number} [fromIndex=array.length-1] The index to search from.
  20754. * @returns {number} Returns the index of the matched value, else `-1`.
  20755. * @example
  20756. *
  20757. * _.lastIndexOf([1, 2, 1, 2], 2);
  20758. * // => 3
  20759. *
  20760. * // Search from the `fromIndex`.
  20761. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  20762. * // => 1
  20763. */
  20764. function lastIndexOf(array, value, fromIndex) {
  20765. var length = array == null ? 0 : array.length;
  20766. if (!length) {
  20767. return -1;
  20768. }
  20769. var index = length;
  20770. if (fromIndex !== undefined) {
  20771. index = toInteger(fromIndex);
  20772. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  20773. }
  20774. return value === value
  20775. ? strictLastIndexOf(array, value, index)
  20776. : baseFindIndex(array, baseIsNaN, index, true);
  20777. }
  20778. /**
  20779. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  20780. * element from the end is returned.
  20781. *
  20782. * @static
  20783. * @memberOf _
  20784. * @since 4.11.0
  20785. * @category Array
  20786. * @param {Array} array The array to query.
  20787. * @param {number} [n=0] The index of the element to return.
  20788. * @returns {*} Returns the nth element of `array`.
  20789. * @example
  20790. *
  20791. * var array = ['a', 'b', 'c', 'd'];
  20792. *
  20793. * _.nth(array, 1);
  20794. * // => 'b'
  20795. *
  20796. * _.nth(array, -2);
  20797. * // => 'c';
  20798. */
  20799. function nth(array, n) {
  20800. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  20801. }
  20802. /**
  20803. * Removes all given values from `array` using
  20804. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20805. * for equality comparisons.
  20806. *
  20807. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  20808. * to remove elements from an array by predicate.
  20809. *
  20810. * @static
  20811. * @memberOf _
  20812. * @since 2.0.0
  20813. * @category Array
  20814. * @param {Array} array The array to modify.
  20815. * @param {...*} [values] The values to remove.
  20816. * @returns {Array} Returns `array`.
  20817. * @example
  20818. *
  20819. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  20820. *
  20821. * _.pull(array, 'a', 'c');
  20822. * console.log(array);
  20823. * // => ['b', 'b']
  20824. */
  20825. var pull = baseRest(pullAll);
  20826. /**
  20827. * This method is like `_.pull` except that it accepts an array of values to remove.
  20828. *
  20829. * **Note:** Unlike `_.difference`, this method mutates `array`.
  20830. *
  20831. * @static
  20832. * @memberOf _
  20833. * @since 4.0.0
  20834. * @category Array
  20835. * @param {Array} array The array to modify.
  20836. * @param {Array} values The values to remove.
  20837. * @returns {Array} Returns `array`.
  20838. * @example
  20839. *
  20840. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  20841. *
  20842. * _.pullAll(array, ['a', 'c']);
  20843. * console.log(array);
  20844. * // => ['b', 'b']
  20845. */
  20846. function pullAll(array, values) {
  20847. return (array && array.length && values && values.length)
  20848. ? basePullAll(array, values)
  20849. : array;
  20850. }
  20851. /**
  20852. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  20853. * invoked for each element of `array` and `values` to generate the criterion
  20854. * by which they're compared. The iteratee is invoked with one argument: (value).
  20855. *
  20856. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  20857. *
  20858. * @static
  20859. * @memberOf _
  20860. * @since 4.0.0
  20861. * @category Array
  20862. * @param {Array} array The array to modify.
  20863. * @param {Array} values The values to remove.
  20864. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20865. * @returns {Array} Returns `array`.
  20866. * @example
  20867. *
  20868. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  20869. *
  20870. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  20871. * console.log(array);
  20872. * // => [{ 'x': 2 }]
  20873. */
  20874. function pullAllBy(array, values, iteratee) {
  20875. return (array && array.length && values && values.length)
  20876. ? basePullAll(array, values, getIteratee(iteratee, 2))
  20877. : array;
  20878. }
  20879. /**
  20880. * This method is like `_.pullAll` except that it accepts `comparator` which
  20881. * is invoked to compare elements of `array` to `values`. The comparator is
  20882. * invoked with two arguments: (arrVal, othVal).
  20883. *
  20884. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  20885. *
  20886. * @static
  20887. * @memberOf _
  20888. * @since 4.6.0
  20889. * @category Array
  20890. * @param {Array} array The array to modify.
  20891. * @param {Array} values The values to remove.
  20892. * @param {Function} [comparator] The comparator invoked per element.
  20893. * @returns {Array} Returns `array`.
  20894. * @example
  20895. *
  20896. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  20897. *
  20898. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  20899. * console.log(array);
  20900. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  20901. */
  20902. function pullAllWith(array, values, comparator) {
  20903. return (array && array.length && values && values.length)
  20904. ? basePullAll(array, values, undefined, comparator)
  20905. : array;
  20906. }
  20907. /**
  20908. * Removes elements from `array` corresponding to `indexes` and returns an
  20909. * array of removed elements.
  20910. *
  20911. * **Note:** Unlike `_.at`, this method mutates `array`.
  20912. *
  20913. * @static
  20914. * @memberOf _
  20915. * @since 3.0.0
  20916. * @category Array
  20917. * @param {Array} array The array to modify.
  20918. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  20919. * @returns {Array} Returns the new array of removed elements.
  20920. * @example
  20921. *
  20922. * var array = ['a', 'b', 'c', 'd'];
  20923. * var pulled = _.pullAt(array, [1, 3]);
  20924. *
  20925. * console.log(array);
  20926. * // => ['a', 'c']
  20927. *
  20928. * console.log(pulled);
  20929. * // => ['b', 'd']
  20930. */
  20931. var pullAt = flatRest(function(array, indexes) {
  20932. var length = array == null ? 0 : array.length,
  20933. result = baseAt(array, indexes);
  20934. basePullAt(array, arrayMap(indexes, function(index) {
  20935. return isIndex(index, length) ? +index : index;
  20936. }).sort(compareAscending));
  20937. return result;
  20938. });
  20939. /**
  20940. * Removes all elements from `array` that `predicate` returns truthy for
  20941. * and returns an array of the removed elements. The predicate is invoked
  20942. * with three arguments: (value, index, array).
  20943. *
  20944. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  20945. * to pull elements from an array by value.
  20946. *
  20947. * @static
  20948. * @memberOf _
  20949. * @since 2.0.0
  20950. * @category Array
  20951. * @param {Array} array The array to modify.
  20952. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20953. * @returns {Array} Returns the new array of removed elements.
  20954. * @example
  20955. *
  20956. * var array = [1, 2, 3, 4];
  20957. * var evens = _.remove(array, function(n) {
  20958. * return n % 2 == 0;
  20959. * });
  20960. *
  20961. * console.log(array);
  20962. * // => [1, 3]
  20963. *
  20964. * console.log(evens);
  20965. * // => [2, 4]
  20966. */
  20967. function remove(array, predicate) {
  20968. var result = [];
  20969. if (!(array && array.length)) {
  20970. return result;
  20971. }
  20972. var index = -1,
  20973. indexes = [],
  20974. length = array.length;
  20975. predicate = getIteratee(predicate, 3);
  20976. while (++index < length) {
  20977. var value = array[index];
  20978. if (predicate(value, index, array)) {
  20979. result.push(value);
  20980. indexes.push(index);
  20981. }
  20982. }
  20983. basePullAt(array, indexes);
  20984. return result;
  20985. }
  20986. /**
  20987. * Reverses `array` so that the first element becomes the last, the second
  20988. * element becomes the second to last, and so on.
  20989. *
  20990. * **Note:** This method mutates `array` and is based on
  20991. * [`Array#reverse`](https://mdn.io/Array/reverse).
  20992. *
  20993. * @static
  20994. * @memberOf _
  20995. * @since 4.0.0
  20996. * @category Array
  20997. * @param {Array} array The array to modify.
  20998. * @returns {Array} Returns `array`.
  20999. * @example
  21000. *
  21001. * var array = [1, 2, 3];
  21002. *
  21003. * _.reverse(array);
  21004. * // => [3, 2, 1]
  21005. *
  21006. * console.log(array);
  21007. * // => [3, 2, 1]
  21008. */
  21009. function reverse(array) {
  21010. return array == null ? array : nativeReverse.call(array);
  21011. }
  21012. /**
  21013. * Creates a slice of `array` from `start` up to, but not including, `end`.
  21014. *
  21015. * **Note:** This method is used instead of
  21016. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  21017. * returned.
  21018. *
  21019. * @static
  21020. * @memberOf _
  21021. * @since 3.0.0
  21022. * @category Array
  21023. * @param {Array} array The array to slice.
  21024. * @param {number} [start=0] The start position.
  21025. * @param {number} [end=array.length] The end position.
  21026. * @returns {Array} Returns the slice of `array`.
  21027. */
  21028. function slice(array, start, end) {
  21029. var length = array == null ? 0 : array.length;
  21030. if (!length) {
  21031. return [];
  21032. }
  21033. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  21034. start = 0;
  21035. end = length;
  21036. }
  21037. else {
  21038. start = start == null ? 0 : toInteger(start);
  21039. end = end === undefined ? length : toInteger(end);
  21040. }
  21041. return baseSlice(array, start, end);
  21042. }
  21043. /**
  21044. * Uses a binary search to determine the lowest index at which `value`
  21045. * should be inserted into `array` in order to maintain its sort order.
  21046. *
  21047. * @static
  21048. * @memberOf _
  21049. * @since 0.1.0
  21050. * @category Array
  21051. * @param {Array} array The sorted array to inspect.
  21052. * @param {*} value The value to evaluate.
  21053. * @returns {number} Returns the index at which `value` should be inserted
  21054. * into `array`.
  21055. * @example
  21056. *
  21057. * _.sortedIndex([30, 50], 40);
  21058. * // => 1
  21059. */
  21060. function sortedIndex(array, value) {
  21061. return baseSortedIndex(array, value);
  21062. }
  21063. /**
  21064. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  21065. * which is invoked for `value` and each element of `array` to compute their
  21066. * sort ranking. The iteratee is invoked with one argument: (value).
  21067. *
  21068. * @static
  21069. * @memberOf _
  21070. * @since 4.0.0
  21071. * @category Array
  21072. * @param {Array} array The sorted array to inspect.
  21073. * @param {*} value The value to evaluate.
  21074. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21075. * @returns {number} Returns the index at which `value` should be inserted
  21076. * into `array`.
  21077. * @example
  21078. *
  21079. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  21080. *
  21081. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  21082. * // => 0
  21083. *
  21084. * // The `_.property` iteratee shorthand.
  21085. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  21086. * // => 0
  21087. */
  21088. function sortedIndexBy(array, value, iteratee) {
  21089. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  21090. }
  21091. /**
  21092. * This method is like `_.indexOf` except that it performs a binary
  21093. * search on a sorted `array`.
  21094. *
  21095. * @static
  21096. * @memberOf _
  21097. * @since 4.0.0
  21098. * @category Array
  21099. * @param {Array} array The array to inspect.
  21100. * @param {*} value The value to search for.
  21101. * @returns {number} Returns the index of the matched value, else `-1`.
  21102. * @example
  21103. *
  21104. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  21105. * // => 1
  21106. */
  21107. function sortedIndexOf(array, value) {
  21108. var length = array == null ? 0 : array.length;
  21109. if (length) {
  21110. var index = baseSortedIndex(array, value);
  21111. if (index < length && eq(array[index], value)) {
  21112. return index;
  21113. }
  21114. }
  21115. return -1;
  21116. }
  21117. /**
  21118. * This method is like `_.sortedIndex` except that it returns the highest
  21119. * index at which `value` should be inserted into `array` in order to
  21120. * maintain its sort order.
  21121. *
  21122. * @static
  21123. * @memberOf _
  21124. * @since 3.0.0
  21125. * @category Array
  21126. * @param {Array} array The sorted array to inspect.
  21127. * @param {*} value The value to evaluate.
  21128. * @returns {number} Returns the index at which `value` should be inserted
  21129. * into `array`.
  21130. * @example
  21131. *
  21132. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  21133. * // => 4
  21134. */
  21135. function sortedLastIndex(array, value) {
  21136. return baseSortedIndex(array, value, true);
  21137. }
  21138. /**
  21139. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  21140. * which is invoked for `value` and each element of `array` to compute their
  21141. * sort ranking. The iteratee is invoked with one argument: (value).
  21142. *
  21143. * @static
  21144. * @memberOf _
  21145. * @since 4.0.0
  21146. * @category Array
  21147. * @param {Array} array The sorted array to inspect.
  21148. * @param {*} value The value to evaluate.
  21149. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21150. * @returns {number} Returns the index at which `value` should be inserted
  21151. * into `array`.
  21152. * @example
  21153. *
  21154. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  21155. *
  21156. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  21157. * // => 1
  21158. *
  21159. * // The `_.property` iteratee shorthand.
  21160. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  21161. * // => 1
  21162. */
  21163. function sortedLastIndexBy(array, value, iteratee) {
  21164. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  21165. }
  21166. /**
  21167. * This method is like `_.lastIndexOf` except that it performs a binary
  21168. * search on a sorted `array`.
  21169. *
  21170. * @static
  21171. * @memberOf _
  21172. * @since 4.0.0
  21173. * @category Array
  21174. * @param {Array} array The array to inspect.
  21175. * @param {*} value The value to search for.
  21176. * @returns {number} Returns the index of the matched value, else `-1`.
  21177. * @example
  21178. *
  21179. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  21180. * // => 3
  21181. */
  21182. function sortedLastIndexOf(array, value) {
  21183. var length = array == null ? 0 : array.length;
  21184. if (length) {
  21185. var index = baseSortedIndex(array, value, true) - 1;
  21186. if (eq(array[index], value)) {
  21187. return index;
  21188. }
  21189. }
  21190. return -1;
  21191. }
  21192. /**
  21193. * This method is like `_.uniq` except that it's designed and optimized
  21194. * for sorted arrays.
  21195. *
  21196. * @static
  21197. * @memberOf _
  21198. * @since 4.0.0
  21199. * @category Array
  21200. * @param {Array} array The array to inspect.
  21201. * @returns {Array} Returns the new duplicate free array.
  21202. * @example
  21203. *
  21204. * _.sortedUniq([1, 1, 2]);
  21205. * // => [1, 2]
  21206. */
  21207. function sortedUniq(array) {
  21208. return (array && array.length)
  21209. ? baseSortedUniq(array)
  21210. : [];
  21211. }
  21212. /**
  21213. * This method is like `_.uniqBy` except that it's designed and optimized
  21214. * for sorted arrays.
  21215. *
  21216. * @static
  21217. * @memberOf _
  21218. * @since 4.0.0
  21219. * @category Array
  21220. * @param {Array} array The array to inspect.
  21221. * @param {Function} [iteratee] The iteratee invoked per element.
  21222. * @returns {Array} Returns the new duplicate free array.
  21223. * @example
  21224. *
  21225. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  21226. * // => [1.1, 2.3]
  21227. */
  21228. function sortedUniqBy(array, iteratee) {
  21229. return (array && array.length)
  21230. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  21231. : [];
  21232. }
  21233. /**
  21234. * Gets all but the first element of `array`.
  21235. *
  21236. * @static
  21237. * @memberOf _
  21238. * @since 4.0.0
  21239. * @category Array
  21240. * @param {Array} array The array to query.
  21241. * @returns {Array} Returns the slice of `array`.
  21242. * @example
  21243. *
  21244. * _.tail([1, 2, 3]);
  21245. * // => [2, 3]
  21246. */
  21247. function tail(array) {
  21248. var length = array == null ? 0 : array.length;
  21249. return length ? baseSlice(array, 1, length) : [];
  21250. }
  21251. /**
  21252. * Creates a slice of `array` with `n` elements taken from the beginning.
  21253. *
  21254. * @static
  21255. * @memberOf _
  21256. * @since 0.1.0
  21257. * @category Array
  21258. * @param {Array} array The array to query.
  21259. * @param {number} [n=1] The number of elements to take.
  21260. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  21261. * @returns {Array} Returns the slice of `array`.
  21262. * @example
  21263. *
  21264. * _.take([1, 2, 3]);
  21265. * // => [1]
  21266. *
  21267. * _.take([1, 2, 3], 2);
  21268. * // => [1, 2]
  21269. *
  21270. * _.take([1, 2, 3], 5);
  21271. * // => [1, 2, 3]
  21272. *
  21273. * _.take([1, 2, 3], 0);
  21274. * // => []
  21275. */
  21276. function take(array, n, guard) {
  21277. if (!(array && array.length)) {
  21278. return [];
  21279. }
  21280. n = (guard || n === undefined) ? 1 : toInteger(n);
  21281. return baseSlice(array, 0, n < 0 ? 0 : n);
  21282. }
  21283. /**
  21284. * Creates a slice of `array` with `n` elements taken from the end.
  21285. *
  21286. * @static
  21287. * @memberOf _
  21288. * @since 3.0.0
  21289. * @category Array
  21290. * @param {Array} array The array to query.
  21291. * @param {number} [n=1] The number of elements to take.
  21292. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  21293. * @returns {Array} Returns the slice of `array`.
  21294. * @example
  21295. *
  21296. * _.takeRight([1, 2, 3]);
  21297. * // => [3]
  21298. *
  21299. * _.takeRight([1, 2, 3], 2);
  21300. * // => [2, 3]
  21301. *
  21302. * _.takeRight([1, 2, 3], 5);
  21303. * // => [1, 2, 3]
  21304. *
  21305. * _.takeRight([1, 2, 3], 0);
  21306. * // => []
  21307. */
  21308. function takeRight(array, n, guard) {
  21309. var length = array == null ? 0 : array.length;
  21310. if (!length) {
  21311. return [];
  21312. }
  21313. n = (guard || n === undefined) ? 1 : toInteger(n);
  21314. n = length - n;
  21315. return baseSlice(array, n < 0 ? 0 : n, length);
  21316. }
  21317. /**
  21318. * Creates a slice of `array` with elements taken from the end. Elements are
  21319. * taken until `predicate` returns falsey. The predicate is invoked with
  21320. * three arguments: (value, index, array).
  21321. *
  21322. * @static
  21323. * @memberOf _
  21324. * @since 3.0.0
  21325. * @category Array
  21326. * @param {Array} array The array to query.
  21327. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  21328. * @returns {Array} Returns the slice of `array`.
  21329. * @example
  21330. *
  21331. * var users = [
  21332. * { 'user': 'barney', 'active': true },
  21333. * { 'user': 'fred', 'active': false },
  21334. * { 'user': 'pebbles', 'active': false }
  21335. * ];
  21336. *
  21337. * _.takeRightWhile(users, function(o) { return !o.active; });
  21338. * // => objects for ['fred', 'pebbles']
  21339. *
  21340. * // The `_.matches` iteratee shorthand.
  21341. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  21342. * // => objects for ['pebbles']
  21343. *
  21344. * // The `_.matchesProperty` iteratee shorthand.
  21345. * _.takeRightWhile(users, ['active', false]);
  21346. * // => objects for ['fred', 'pebbles']
  21347. *
  21348. * // The `_.property` iteratee shorthand.
  21349. * _.takeRightWhile(users, 'active');
  21350. * // => []
  21351. */
  21352. function takeRightWhile(array, predicate) {
  21353. return (array && array.length)
  21354. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  21355. : [];
  21356. }
  21357. /**
  21358. * Creates a slice of `array` with elements taken from the beginning. Elements
  21359. * are taken until `predicate` returns falsey. The predicate is invoked with
  21360. * three arguments: (value, index, array).
  21361. *
  21362. * @static
  21363. * @memberOf _
  21364. * @since 3.0.0
  21365. * @category Array
  21366. * @param {Array} array The array to query.
  21367. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  21368. * @returns {Array} Returns the slice of `array`.
  21369. * @example
  21370. *
  21371. * var users = [
  21372. * { 'user': 'barney', 'active': false },
  21373. * { 'user': 'fred', 'active': false },
  21374. * { 'user': 'pebbles', 'active': true }
  21375. * ];
  21376. *
  21377. * _.takeWhile(users, function(o) { return !o.active; });
  21378. * // => objects for ['barney', 'fred']
  21379. *
  21380. * // The `_.matches` iteratee shorthand.
  21381. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  21382. * // => objects for ['barney']
  21383. *
  21384. * // The `_.matchesProperty` iteratee shorthand.
  21385. * _.takeWhile(users, ['active', false]);
  21386. * // => objects for ['barney', 'fred']
  21387. *
  21388. * // The `_.property` iteratee shorthand.
  21389. * _.takeWhile(users, 'active');
  21390. * // => []
  21391. */
  21392. function takeWhile(array, predicate) {
  21393. return (array && array.length)
  21394. ? baseWhile(array, getIteratee(predicate, 3))
  21395. : [];
  21396. }
  21397. /**
  21398. * Creates an array of unique values, in order, from all given arrays using
  21399. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21400. * for equality comparisons.
  21401. *
  21402. * @static
  21403. * @memberOf _
  21404. * @since 0.1.0
  21405. * @category Array
  21406. * @param {...Array} [arrays] The arrays to inspect.
  21407. * @returns {Array} Returns the new array of combined values.
  21408. * @example
  21409. *
  21410. * _.union([2], [1, 2]);
  21411. * // => [2, 1]
  21412. */
  21413. var union = baseRest(function(arrays) {
  21414. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  21415. });
  21416. /**
  21417. * This method is like `_.union` except that it accepts `iteratee` which is
  21418. * invoked for each element of each `arrays` to generate the criterion by
  21419. * which uniqueness is computed. Result values are chosen from the first
  21420. * array in which the value occurs. The iteratee is invoked with one argument:
  21421. * (value).
  21422. *
  21423. * @static
  21424. * @memberOf _
  21425. * @since 4.0.0
  21426. * @category Array
  21427. * @param {...Array} [arrays] The arrays to inspect.
  21428. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21429. * @returns {Array} Returns the new array of combined values.
  21430. * @example
  21431. *
  21432. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  21433. * // => [2.1, 1.2]
  21434. *
  21435. * // The `_.property` iteratee shorthand.
  21436. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  21437. * // => [{ 'x': 1 }, { 'x': 2 }]
  21438. */
  21439. var unionBy = baseRest(function(arrays) {
  21440. var iteratee = last(arrays);
  21441. if (isArrayLikeObject(iteratee)) {
  21442. iteratee = undefined;
  21443. }
  21444. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  21445. });
  21446. /**
  21447. * This method is like `_.union` except that it accepts `comparator` which
  21448. * is invoked to compare elements of `arrays`. Result values are chosen from
  21449. * the first array in which the value occurs. The comparator is invoked
  21450. * with two arguments: (arrVal, othVal).
  21451. *
  21452. * @static
  21453. * @memberOf _
  21454. * @since 4.0.0
  21455. * @category Array
  21456. * @param {...Array} [arrays] The arrays to inspect.
  21457. * @param {Function} [comparator] The comparator invoked per element.
  21458. * @returns {Array} Returns the new array of combined values.
  21459. * @example
  21460. *
  21461. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  21462. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  21463. *
  21464. * _.unionWith(objects, others, _.isEqual);
  21465. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  21466. */
  21467. var unionWith = baseRest(function(arrays) {
  21468. var comparator = last(arrays);
  21469. comparator = typeof comparator == 'function' ? comparator : undefined;
  21470. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  21471. });
  21472. /**
  21473. * Creates a duplicate-free version of an array, using
  21474. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21475. * for equality comparisons, in which only the first occurrence of each element
  21476. * is kept. The order of result values is determined by the order they occur
  21477. * in the array.
  21478. *
  21479. * @static
  21480. * @memberOf _
  21481. * @since 0.1.0
  21482. * @category Array
  21483. * @param {Array} array The array to inspect.
  21484. * @returns {Array} Returns the new duplicate free array.
  21485. * @example
  21486. *
  21487. * _.uniq([2, 1, 2]);
  21488. * // => [2, 1]
  21489. */
  21490. function uniq(array) {
  21491. return (array && array.length) ? baseUniq(array) : [];
  21492. }
  21493. /**
  21494. * This method is like `_.uniq` except that it accepts `iteratee` which is
  21495. * invoked for each element in `array` to generate the criterion by which
  21496. * uniqueness is computed. The order of result values is determined by the
  21497. * order they occur in the array. The iteratee is invoked with one argument:
  21498. * (value).
  21499. *
  21500. * @static
  21501. * @memberOf _
  21502. * @since 4.0.0
  21503. * @category Array
  21504. * @param {Array} array The array to inspect.
  21505. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21506. * @returns {Array} Returns the new duplicate free array.
  21507. * @example
  21508. *
  21509. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  21510. * // => [2.1, 1.2]
  21511. *
  21512. * // The `_.property` iteratee shorthand.
  21513. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  21514. * // => [{ 'x': 1 }, { 'x': 2 }]
  21515. */
  21516. function uniqBy(array, iteratee) {
  21517. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  21518. }
  21519. /**
  21520. * This method is like `_.uniq` except that it accepts `comparator` which
  21521. * is invoked to compare elements of `array`. The order of result values is
  21522. * determined by the order they occur in the array.The comparator is invoked
  21523. * with two arguments: (arrVal, othVal).
  21524. *
  21525. * @static
  21526. * @memberOf _
  21527. * @since 4.0.0
  21528. * @category Array
  21529. * @param {Array} array The array to inspect.
  21530. * @param {Function} [comparator] The comparator invoked per element.
  21531. * @returns {Array} Returns the new duplicate free array.
  21532. * @example
  21533. *
  21534. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  21535. *
  21536. * _.uniqWith(objects, _.isEqual);
  21537. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  21538. */
  21539. function uniqWith(array, comparator) {
  21540. comparator = typeof comparator == 'function' ? comparator : undefined;
  21541. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  21542. }
  21543. /**
  21544. * This method is like `_.zip` except that it accepts an array of grouped
  21545. * elements and creates an array regrouping the elements to their pre-zip
  21546. * configuration.
  21547. *
  21548. * @static
  21549. * @memberOf _
  21550. * @since 1.2.0
  21551. * @category Array
  21552. * @param {Array} array The array of grouped elements to process.
  21553. * @returns {Array} Returns the new array of regrouped elements.
  21554. * @example
  21555. *
  21556. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  21557. * // => [['a', 1, true], ['b', 2, false]]
  21558. *
  21559. * _.unzip(zipped);
  21560. * // => [['a', 'b'], [1, 2], [true, false]]
  21561. */
  21562. function unzip(array) {
  21563. if (!(array && array.length)) {
  21564. return [];
  21565. }
  21566. var length = 0;
  21567. array = arrayFilter(array, function(group) {
  21568. if (isArrayLikeObject(group)) {
  21569. length = nativeMax(group.length, length);
  21570. return true;
  21571. }
  21572. });
  21573. return baseTimes(length, function(index) {
  21574. return arrayMap(array, baseProperty(index));
  21575. });
  21576. }
  21577. /**
  21578. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  21579. * how regrouped values should be combined. The iteratee is invoked with the
  21580. * elements of each group: (...group).
  21581. *
  21582. * @static
  21583. * @memberOf _
  21584. * @since 3.8.0
  21585. * @category Array
  21586. * @param {Array} array The array of grouped elements to process.
  21587. * @param {Function} [iteratee=_.identity] The function to combine
  21588. * regrouped values.
  21589. * @returns {Array} Returns the new array of regrouped elements.
  21590. * @example
  21591. *
  21592. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  21593. * // => [[1, 10, 100], [2, 20, 200]]
  21594. *
  21595. * _.unzipWith(zipped, _.add);
  21596. * // => [3, 30, 300]
  21597. */
  21598. function unzipWith(array, iteratee) {
  21599. if (!(array && array.length)) {
  21600. return [];
  21601. }
  21602. var result = unzip(array);
  21603. if (iteratee == null) {
  21604. return result;
  21605. }
  21606. return arrayMap(result, function(group) {
  21607. return apply(iteratee, undefined, group);
  21608. });
  21609. }
  21610. /**
  21611. * Creates an array excluding all given values using
  21612. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21613. * for equality comparisons.
  21614. *
  21615. * **Note:** Unlike `_.pull`, this method returns a new array.
  21616. *
  21617. * @static
  21618. * @memberOf _
  21619. * @since 0.1.0
  21620. * @category Array
  21621. * @param {Array} array The array to inspect.
  21622. * @param {...*} [values] The values to exclude.
  21623. * @returns {Array} Returns the new array of filtered values.
  21624. * @see _.difference, _.xor
  21625. * @example
  21626. *
  21627. * _.without([2, 1, 2, 3], 1, 2);
  21628. * // => [3]
  21629. */
  21630. var without = baseRest(function(array, values) {
  21631. return isArrayLikeObject(array)
  21632. ? baseDifference(array, values)
  21633. : [];
  21634. });
  21635. /**
  21636. * Creates an array of unique values that is the
  21637. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  21638. * of the given arrays. The order of result values is determined by the order
  21639. * they occur in the arrays.
  21640. *
  21641. * @static
  21642. * @memberOf _
  21643. * @since 2.4.0
  21644. * @category Array
  21645. * @param {...Array} [arrays] The arrays to inspect.
  21646. * @returns {Array} Returns the new array of filtered values.
  21647. * @see _.difference, _.without
  21648. * @example
  21649. *
  21650. * _.xor([2, 1], [2, 3]);
  21651. * // => [1, 3]
  21652. */
  21653. var xor = baseRest(function(arrays) {
  21654. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  21655. });
  21656. /**
  21657. * This method is like `_.xor` except that it accepts `iteratee` which is
  21658. * invoked for each element of each `arrays` to generate the criterion by
  21659. * which by which they're compared. The order of result values is determined
  21660. * by the order they occur in the arrays. The iteratee is invoked with one
  21661. * argument: (value).
  21662. *
  21663. * @static
  21664. * @memberOf _
  21665. * @since 4.0.0
  21666. * @category Array
  21667. * @param {...Array} [arrays] The arrays to inspect.
  21668. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21669. * @returns {Array} Returns the new array of filtered values.
  21670. * @example
  21671. *
  21672. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  21673. * // => [1.2, 3.4]
  21674. *
  21675. * // The `_.property` iteratee shorthand.
  21676. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  21677. * // => [{ 'x': 2 }]
  21678. */
  21679. var xorBy = baseRest(function(arrays) {
  21680. var iteratee = last(arrays);
  21681. if (isArrayLikeObject(iteratee)) {
  21682. iteratee = undefined;
  21683. }
  21684. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  21685. });
  21686. /**
  21687. * This method is like `_.xor` except that it accepts `comparator` which is
  21688. * invoked to compare elements of `arrays`. The order of result values is
  21689. * determined by the order they occur in the arrays. The comparator is invoked
  21690. * with two arguments: (arrVal, othVal).
  21691. *
  21692. * @static
  21693. * @memberOf _
  21694. * @since 4.0.0
  21695. * @category Array
  21696. * @param {...Array} [arrays] The arrays to inspect.
  21697. * @param {Function} [comparator] The comparator invoked per element.
  21698. * @returns {Array} Returns the new array of filtered values.
  21699. * @example
  21700. *
  21701. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  21702. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  21703. *
  21704. * _.xorWith(objects, others, _.isEqual);
  21705. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  21706. */
  21707. var xorWith = baseRest(function(arrays) {
  21708. var comparator = last(arrays);
  21709. comparator = typeof comparator == 'function' ? comparator : undefined;
  21710. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  21711. });
  21712. /**
  21713. * Creates an array of grouped elements, the first of which contains the
  21714. * first elements of the given arrays, the second of which contains the
  21715. * second elements of the given arrays, and so on.
  21716. *
  21717. * @static
  21718. * @memberOf _
  21719. * @since 0.1.0
  21720. * @category Array
  21721. * @param {...Array} [arrays] The arrays to process.
  21722. * @returns {Array} Returns the new array of grouped elements.
  21723. * @example
  21724. *
  21725. * _.zip(['a', 'b'], [1, 2], [true, false]);
  21726. * // => [['a', 1, true], ['b', 2, false]]
  21727. */
  21728. var zip = baseRest(unzip);
  21729. /**
  21730. * This method is like `_.fromPairs` except that it accepts two arrays,
  21731. * one of property identifiers and one of corresponding values.
  21732. *
  21733. * @static
  21734. * @memberOf _
  21735. * @since 0.4.0
  21736. * @category Array
  21737. * @param {Array} [props=[]] The property identifiers.
  21738. * @param {Array} [values=[]] The property values.
  21739. * @returns {Object} Returns the new object.
  21740. * @example
  21741. *
  21742. * _.zipObject(['a', 'b'], [1, 2]);
  21743. * // => { 'a': 1, 'b': 2 }
  21744. */
  21745. function zipObject(props, values) {
  21746. return baseZipObject(props || [], values || [], assignValue);
  21747. }
  21748. /**
  21749. * This method is like `_.zipObject` except that it supports property paths.
  21750. *
  21751. * @static
  21752. * @memberOf _
  21753. * @since 4.1.0
  21754. * @category Array
  21755. * @param {Array} [props=[]] The property identifiers.
  21756. * @param {Array} [values=[]] The property values.
  21757. * @returns {Object} Returns the new object.
  21758. * @example
  21759. *
  21760. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  21761. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  21762. */
  21763. function zipObjectDeep(props, values) {
  21764. return baseZipObject(props || [], values || [], baseSet);
  21765. }
  21766. /**
  21767. * This method is like `_.zip` except that it accepts `iteratee` to specify
  21768. * how grouped values should be combined. The iteratee is invoked with the
  21769. * elements of each group: (...group).
  21770. *
  21771. * @static
  21772. * @memberOf _
  21773. * @since 3.8.0
  21774. * @category Array
  21775. * @param {...Array} [arrays] The arrays to process.
  21776. * @param {Function} [iteratee=_.identity] The function to combine
  21777. * grouped values.
  21778. * @returns {Array} Returns the new array of grouped elements.
  21779. * @example
  21780. *
  21781. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  21782. * return a + b + c;
  21783. * });
  21784. * // => [111, 222]
  21785. */
  21786. var zipWith = baseRest(function(arrays) {
  21787. var length = arrays.length,
  21788. iteratee = length > 1 ? arrays[length - 1] : undefined;
  21789. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  21790. return unzipWith(arrays, iteratee);
  21791. });
  21792. /*------------------------------------------------------------------------*/
  21793. /**
  21794. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  21795. * chain sequences enabled. The result of such sequences must be unwrapped
  21796. * with `_#value`.
  21797. *
  21798. * @static
  21799. * @memberOf _
  21800. * @since 1.3.0
  21801. * @category Seq
  21802. * @param {*} value The value to wrap.
  21803. * @returns {Object} Returns the new `lodash` wrapper instance.
  21804. * @example
  21805. *
  21806. * var users = [
  21807. * { 'user': 'barney', 'age': 36 },
  21808. * { 'user': 'fred', 'age': 40 },
  21809. * { 'user': 'pebbles', 'age': 1 }
  21810. * ];
  21811. *
  21812. * var youngest = _
  21813. * .chain(users)
  21814. * .sortBy('age')
  21815. * .map(function(o) {
  21816. * return o.user + ' is ' + o.age;
  21817. * })
  21818. * .head()
  21819. * .value();
  21820. * // => 'pebbles is 1'
  21821. */
  21822. function chain(value) {
  21823. var result = lodash(value);
  21824. result.__chain__ = true;
  21825. return result;
  21826. }
  21827. /**
  21828. * This method invokes `interceptor` and returns `value`. The interceptor
  21829. * is invoked with one argument; (value). The purpose of this method is to
  21830. * "tap into" a method chain sequence in order to modify intermediate results.
  21831. *
  21832. * @static
  21833. * @memberOf _
  21834. * @since 0.1.0
  21835. * @category Seq
  21836. * @param {*} value The value to provide to `interceptor`.
  21837. * @param {Function} interceptor The function to invoke.
  21838. * @returns {*} Returns `value`.
  21839. * @example
  21840. *
  21841. * _([1, 2, 3])
  21842. * .tap(function(array) {
  21843. * // Mutate input array.
  21844. * array.pop();
  21845. * })
  21846. * .reverse()
  21847. * .value();
  21848. * // => [2, 1]
  21849. */
  21850. function tap(value, interceptor) {
  21851. interceptor(value);
  21852. return value;
  21853. }
  21854. /**
  21855. * This method is like `_.tap` except that it returns the result of `interceptor`.
  21856. * The purpose of this method is to "pass thru" values replacing intermediate
  21857. * results in a method chain sequence.
  21858. *
  21859. * @static
  21860. * @memberOf _
  21861. * @since 3.0.0
  21862. * @category Seq
  21863. * @param {*} value The value to provide to `interceptor`.
  21864. * @param {Function} interceptor The function to invoke.
  21865. * @returns {*} Returns the result of `interceptor`.
  21866. * @example
  21867. *
  21868. * _(' abc ')
  21869. * .chain()
  21870. * .trim()
  21871. * .thru(function(value) {
  21872. * return [value];
  21873. * })
  21874. * .value();
  21875. * // => ['abc']
  21876. */
  21877. function thru(value, interceptor) {
  21878. return interceptor(value);
  21879. }
  21880. /**
  21881. * This method is the wrapper version of `_.at`.
  21882. *
  21883. * @name at
  21884. * @memberOf _
  21885. * @since 1.0.0
  21886. * @category Seq
  21887. * @param {...(string|string[])} [paths] The property paths to pick.
  21888. * @returns {Object} Returns the new `lodash` wrapper instance.
  21889. * @example
  21890. *
  21891. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  21892. *
  21893. * _(object).at(['a[0].b.c', 'a[1]']).value();
  21894. * // => [3, 4]
  21895. */
  21896. var wrapperAt = flatRest(function(paths) {
  21897. var length = paths.length,
  21898. start = length ? paths[0] : 0,
  21899. value = this.__wrapped__,
  21900. interceptor = function(object) { return baseAt(object, paths); };
  21901. if (length > 1 || this.__actions__.length ||
  21902. !(value instanceof LazyWrapper) || !isIndex(start)) {
  21903. return this.thru(interceptor);
  21904. }
  21905. value = value.slice(start, +start + (length ? 1 : 0));
  21906. value.__actions__.push({
  21907. 'func': thru,
  21908. 'args': [interceptor],
  21909. 'thisArg': undefined
  21910. });
  21911. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  21912. if (length && !array.length) {
  21913. array.push(undefined);
  21914. }
  21915. return array;
  21916. });
  21917. });
  21918. /**
  21919. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  21920. *
  21921. * @name chain
  21922. * @memberOf _
  21923. * @since 0.1.0
  21924. * @category Seq
  21925. * @returns {Object} Returns the new `lodash` wrapper instance.
  21926. * @example
  21927. *
  21928. * var users = [
  21929. * { 'user': 'barney', 'age': 36 },
  21930. * { 'user': 'fred', 'age': 40 }
  21931. * ];
  21932. *
  21933. * // A sequence without explicit chaining.
  21934. * _(users).head();
  21935. * // => { 'user': 'barney', 'age': 36 }
  21936. *
  21937. * // A sequence with explicit chaining.
  21938. * _(users)
  21939. * .chain()
  21940. * .head()
  21941. * .pick('user')
  21942. * .value();
  21943. * // => { 'user': 'barney' }
  21944. */
  21945. function wrapperChain() {
  21946. return chain(this);
  21947. }
  21948. /**
  21949. * Executes the chain sequence and returns the wrapped result.
  21950. *
  21951. * @name commit
  21952. * @memberOf _
  21953. * @since 3.2.0
  21954. * @category Seq
  21955. * @returns {Object} Returns the new `lodash` wrapper instance.
  21956. * @example
  21957. *
  21958. * var array = [1, 2];
  21959. * var wrapped = _(array).push(3);
  21960. *
  21961. * console.log(array);
  21962. * // => [1, 2]
  21963. *
  21964. * wrapped = wrapped.commit();
  21965. * console.log(array);
  21966. * // => [1, 2, 3]
  21967. *
  21968. * wrapped.last();
  21969. * // => 3
  21970. *
  21971. * console.log(array);
  21972. * // => [1, 2, 3]
  21973. */
  21974. function wrapperCommit() {
  21975. return new LodashWrapper(this.value(), this.__chain__);
  21976. }
  21977. /**
  21978. * Gets the next value on a wrapped object following the
  21979. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  21980. *
  21981. * @name next
  21982. * @memberOf _
  21983. * @since 4.0.0
  21984. * @category Seq
  21985. * @returns {Object} Returns the next iterator value.
  21986. * @example
  21987. *
  21988. * var wrapped = _([1, 2]);
  21989. *
  21990. * wrapped.next();
  21991. * // => { 'done': false, 'value': 1 }
  21992. *
  21993. * wrapped.next();
  21994. * // => { 'done': false, 'value': 2 }
  21995. *
  21996. * wrapped.next();
  21997. * // => { 'done': true, 'value': undefined }
  21998. */
  21999. function wrapperNext() {
  22000. if (this.__values__ === undefined) {
  22001. this.__values__ = toArray(this.value());
  22002. }
  22003. var done = this.__index__ >= this.__values__.length,
  22004. value = done ? undefined : this.__values__[this.__index__++];
  22005. return { 'done': done, 'value': value };
  22006. }
  22007. /**
  22008. * Enables the wrapper to be iterable.
  22009. *
  22010. * @name Symbol.iterator
  22011. * @memberOf _
  22012. * @since 4.0.0
  22013. * @category Seq
  22014. * @returns {Object} Returns the wrapper object.
  22015. * @example
  22016. *
  22017. * var wrapped = _([1, 2]);
  22018. *
  22019. * wrapped[Symbol.iterator]() === wrapped;
  22020. * // => true
  22021. *
  22022. * Array.from(wrapped);
  22023. * // => [1, 2]
  22024. */
  22025. function wrapperToIterator() {
  22026. return this;
  22027. }
  22028. /**
  22029. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  22030. *
  22031. * @name plant
  22032. * @memberOf _
  22033. * @since 3.2.0
  22034. * @category Seq
  22035. * @param {*} value The value to plant.
  22036. * @returns {Object} Returns the new `lodash` wrapper instance.
  22037. * @example
  22038. *
  22039. * function square(n) {
  22040. * return n * n;
  22041. * }
  22042. *
  22043. * var wrapped = _([1, 2]).map(square);
  22044. * var other = wrapped.plant([3, 4]);
  22045. *
  22046. * other.value();
  22047. * // => [9, 16]
  22048. *
  22049. * wrapped.value();
  22050. * // => [1, 4]
  22051. */
  22052. function wrapperPlant(value) {
  22053. var result,
  22054. parent = this;
  22055. while (parent instanceof baseLodash) {
  22056. var clone = wrapperClone(parent);
  22057. clone.__index__ = 0;
  22058. clone.__values__ = undefined;
  22059. if (result) {
  22060. previous.__wrapped__ = clone;
  22061. } else {
  22062. result = clone;
  22063. }
  22064. var previous = clone;
  22065. parent = parent.__wrapped__;
  22066. }
  22067. previous.__wrapped__ = value;
  22068. return result;
  22069. }
  22070. /**
  22071. * This method is the wrapper version of `_.reverse`.
  22072. *
  22073. * **Note:** This method mutates the wrapped array.
  22074. *
  22075. * @name reverse
  22076. * @memberOf _
  22077. * @since 0.1.0
  22078. * @category Seq
  22079. * @returns {Object} Returns the new `lodash` wrapper instance.
  22080. * @example
  22081. *
  22082. * var array = [1, 2, 3];
  22083. *
  22084. * _(array).reverse().value()
  22085. * // => [3, 2, 1]
  22086. *
  22087. * console.log(array);
  22088. * // => [3, 2, 1]
  22089. */
  22090. function wrapperReverse() {
  22091. var value = this.__wrapped__;
  22092. if (value instanceof LazyWrapper) {
  22093. var wrapped = value;
  22094. if (this.__actions__.length) {
  22095. wrapped = new LazyWrapper(this);
  22096. }
  22097. wrapped = wrapped.reverse();
  22098. wrapped.__actions__.push({
  22099. 'func': thru,
  22100. 'args': [reverse],
  22101. 'thisArg': undefined
  22102. });
  22103. return new LodashWrapper(wrapped, this.__chain__);
  22104. }
  22105. return this.thru(reverse);
  22106. }
  22107. /**
  22108. * Executes the chain sequence to resolve the unwrapped value.
  22109. *
  22110. * @name value
  22111. * @memberOf _
  22112. * @since 0.1.0
  22113. * @alias toJSON, valueOf
  22114. * @category Seq
  22115. * @returns {*} Returns the resolved unwrapped value.
  22116. * @example
  22117. *
  22118. * _([1, 2, 3]).value();
  22119. * // => [1, 2, 3]
  22120. */
  22121. function wrapperValue() {
  22122. return baseWrapperValue(this.__wrapped__, this.__actions__);
  22123. }
  22124. /*------------------------------------------------------------------------*/
  22125. /**
  22126. * Creates an object composed of keys generated from the results of running
  22127. * each element of `collection` thru `iteratee`. The corresponding value of
  22128. * each key is the number of times the key was returned by `iteratee`. The
  22129. * iteratee is invoked with one argument: (value).
  22130. *
  22131. * @static
  22132. * @memberOf _
  22133. * @since 0.5.0
  22134. * @category Collection
  22135. * @param {Array|Object} collection The collection to iterate over.
  22136. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22137. * @returns {Object} Returns the composed aggregate object.
  22138. * @example
  22139. *
  22140. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  22141. * // => { '4': 1, '6': 2 }
  22142. *
  22143. * // The `_.property` iteratee shorthand.
  22144. * _.countBy(['one', 'two', 'three'], 'length');
  22145. * // => { '3': 2, '5': 1 }
  22146. */
  22147. var countBy = createAggregator(function(result, value, key) {
  22148. if (hasOwnProperty.call(result, key)) {
  22149. ++result[key];
  22150. } else {
  22151. baseAssignValue(result, key, 1);
  22152. }
  22153. });
  22154. /**
  22155. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  22156. * Iteration is stopped once `predicate` returns falsey. The predicate is
  22157. * invoked with three arguments: (value, index|key, collection).
  22158. *
  22159. * **Note:** This method returns `true` for
  22160. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  22161. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  22162. * elements of empty collections.
  22163. *
  22164. * @static
  22165. * @memberOf _
  22166. * @since 0.1.0
  22167. * @category Collection
  22168. * @param {Array|Object} collection The collection to iterate over.
  22169. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22170. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  22171. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  22172. * else `false`.
  22173. * @example
  22174. *
  22175. * _.every([true, 1, null, 'yes'], Boolean);
  22176. * // => false
  22177. *
  22178. * var users = [
  22179. * { 'user': 'barney', 'age': 36, 'active': false },
  22180. * { 'user': 'fred', 'age': 40, 'active': false }
  22181. * ];
  22182. *
  22183. * // The `_.matches` iteratee shorthand.
  22184. * _.every(users, { 'user': 'barney', 'active': false });
  22185. * // => false
  22186. *
  22187. * // The `_.matchesProperty` iteratee shorthand.
  22188. * _.every(users, ['active', false]);
  22189. * // => true
  22190. *
  22191. * // The `_.property` iteratee shorthand.
  22192. * _.every(users, 'active');
  22193. * // => false
  22194. */
  22195. function every(collection, predicate, guard) {
  22196. var func = isArray(collection) ? arrayEvery : baseEvery;
  22197. if (guard && isIterateeCall(collection, predicate, guard)) {
  22198. predicate = undefined;
  22199. }
  22200. return func(collection, getIteratee(predicate, 3));
  22201. }
  22202. /**
  22203. * Iterates over elements of `collection`, returning an array of all elements
  22204. * `predicate` returns truthy for. The predicate is invoked with three
  22205. * arguments: (value, index|key, collection).
  22206. *
  22207. * **Note:** Unlike `_.remove`, this method returns a new array.
  22208. *
  22209. * @static
  22210. * @memberOf _
  22211. * @since 0.1.0
  22212. * @category Collection
  22213. * @param {Array|Object} collection The collection to iterate over.
  22214. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22215. * @returns {Array} Returns the new filtered array.
  22216. * @see _.reject
  22217. * @example
  22218. *
  22219. * var users = [
  22220. * { 'user': 'barney', 'age': 36, 'active': true },
  22221. * { 'user': 'fred', 'age': 40, 'active': false }
  22222. * ];
  22223. *
  22224. * _.filter(users, function(o) { return !o.active; });
  22225. * // => objects for ['fred']
  22226. *
  22227. * // The `_.matches` iteratee shorthand.
  22228. * _.filter(users, { 'age': 36, 'active': true });
  22229. * // => objects for ['barney']
  22230. *
  22231. * // The `_.matchesProperty` iteratee shorthand.
  22232. * _.filter(users, ['active', false]);
  22233. * // => objects for ['fred']
  22234. *
  22235. * // The `_.property` iteratee shorthand.
  22236. * _.filter(users, 'active');
  22237. * // => objects for ['barney']
  22238. */
  22239. function filter(collection, predicate) {
  22240. var func = isArray(collection) ? arrayFilter : baseFilter;
  22241. return func(collection, getIteratee(predicate, 3));
  22242. }
  22243. /**
  22244. * Iterates over elements of `collection`, returning the first element
  22245. * `predicate` returns truthy for. The predicate is invoked with three
  22246. * arguments: (value, index|key, collection).
  22247. *
  22248. * @static
  22249. * @memberOf _
  22250. * @since 0.1.0
  22251. * @category Collection
  22252. * @param {Array|Object} collection The collection to inspect.
  22253. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22254. * @param {number} [fromIndex=0] The index to search from.
  22255. * @returns {*} Returns the matched element, else `undefined`.
  22256. * @example
  22257. *
  22258. * var users = [
  22259. * { 'user': 'barney', 'age': 36, 'active': true },
  22260. * { 'user': 'fred', 'age': 40, 'active': false },
  22261. * { 'user': 'pebbles', 'age': 1, 'active': true }
  22262. * ];
  22263. *
  22264. * _.find(users, function(o) { return o.age < 40; });
  22265. * // => object for 'barney'
  22266. *
  22267. * // The `_.matches` iteratee shorthand.
  22268. * _.find(users, { 'age': 1, 'active': true });
  22269. * // => object for 'pebbles'
  22270. *
  22271. * // The `_.matchesProperty` iteratee shorthand.
  22272. * _.find(users, ['active', false]);
  22273. * // => object for 'fred'
  22274. *
  22275. * // The `_.property` iteratee shorthand.
  22276. * _.find(users, 'active');
  22277. * // => object for 'barney'
  22278. */
  22279. var find = createFind(findIndex);
  22280. /**
  22281. * This method is like `_.find` except that it iterates over elements of
  22282. * `collection` from right to left.
  22283. *
  22284. * @static
  22285. * @memberOf _
  22286. * @since 2.0.0
  22287. * @category Collection
  22288. * @param {Array|Object} collection The collection to inspect.
  22289. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22290. * @param {number} [fromIndex=collection.length-1] The index to search from.
  22291. * @returns {*} Returns the matched element, else `undefined`.
  22292. * @example
  22293. *
  22294. * _.findLast([1, 2, 3, 4], function(n) {
  22295. * return n % 2 == 1;
  22296. * });
  22297. * // => 3
  22298. */
  22299. var findLast = createFind(findLastIndex);
  22300. /**
  22301. * Creates a flattened array of values by running each element in `collection`
  22302. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  22303. * with three arguments: (value, index|key, collection).
  22304. *
  22305. * @static
  22306. * @memberOf _
  22307. * @since 4.0.0
  22308. * @category Collection
  22309. * @param {Array|Object} collection The collection to iterate over.
  22310. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22311. * @returns {Array} Returns the new flattened array.
  22312. * @example
  22313. *
  22314. * function duplicate(n) {
  22315. * return [n, n];
  22316. * }
  22317. *
  22318. * _.flatMap([1, 2], duplicate);
  22319. * // => [1, 1, 2, 2]
  22320. */
  22321. function flatMap(collection, iteratee) {
  22322. return baseFlatten(map(collection, iteratee), 1);
  22323. }
  22324. /**
  22325. * This method is like `_.flatMap` except that it recursively flattens the
  22326. * mapped results.
  22327. *
  22328. * @static
  22329. * @memberOf _
  22330. * @since 4.7.0
  22331. * @category Collection
  22332. * @param {Array|Object} collection The collection to iterate over.
  22333. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22334. * @returns {Array} Returns the new flattened array.
  22335. * @example
  22336. *
  22337. * function duplicate(n) {
  22338. * return [[[n, n]]];
  22339. * }
  22340. *
  22341. * _.flatMapDeep([1, 2], duplicate);
  22342. * // => [1, 1, 2, 2]
  22343. */
  22344. function flatMapDeep(collection, iteratee) {
  22345. return baseFlatten(map(collection, iteratee), INFINITY);
  22346. }
  22347. /**
  22348. * This method is like `_.flatMap` except that it recursively flattens the
  22349. * mapped results up to `depth` times.
  22350. *
  22351. * @static
  22352. * @memberOf _
  22353. * @since 4.7.0
  22354. * @category Collection
  22355. * @param {Array|Object} collection The collection to iterate over.
  22356. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22357. * @param {number} [depth=1] The maximum recursion depth.
  22358. * @returns {Array} Returns the new flattened array.
  22359. * @example
  22360. *
  22361. * function duplicate(n) {
  22362. * return [[[n, n]]];
  22363. * }
  22364. *
  22365. * _.flatMapDepth([1, 2], duplicate, 2);
  22366. * // => [[1, 1], [2, 2]]
  22367. */
  22368. function flatMapDepth(collection, iteratee, depth) {
  22369. depth = depth === undefined ? 1 : toInteger(depth);
  22370. return baseFlatten(map(collection, iteratee), depth);
  22371. }
  22372. /**
  22373. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  22374. * The iteratee is invoked with three arguments: (value, index|key, collection).
  22375. * Iteratee functions may exit iteration early by explicitly returning `false`.
  22376. *
  22377. * **Note:** As with other "Collections" methods, objects with a "length"
  22378. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  22379. * or `_.forOwn` for object iteration.
  22380. *
  22381. * @static
  22382. * @memberOf _
  22383. * @since 0.1.0
  22384. * @alias each
  22385. * @category Collection
  22386. * @param {Array|Object} collection The collection to iterate over.
  22387. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22388. * @returns {Array|Object} Returns `collection`.
  22389. * @see _.forEachRight
  22390. * @example
  22391. *
  22392. * _.forEach([1, 2], function(value) {
  22393. * console.log(value);
  22394. * });
  22395. * // => Logs `1` then `2`.
  22396. *
  22397. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  22398. * console.log(key);
  22399. * });
  22400. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  22401. */
  22402. function forEach(collection, iteratee) {
  22403. var func = isArray(collection) ? arrayEach : baseEach;
  22404. return func(collection, getIteratee(iteratee, 3));
  22405. }
  22406. /**
  22407. * This method is like `_.forEach` except that it iterates over elements of
  22408. * `collection` from right to left.
  22409. *
  22410. * @static
  22411. * @memberOf _
  22412. * @since 2.0.0
  22413. * @alias eachRight
  22414. * @category Collection
  22415. * @param {Array|Object} collection The collection to iterate over.
  22416. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22417. * @returns {Array|Object} Returns `collection`.
  22418. * @see _.forEach
  22419. * @example
  22420. *
  22421. * _.forEachRight([1, 2], function(value) {
  22422. * console.log(value);
  22423. * });
  22424. * // => Logs `2` then `1`.
  22425. */
  22426. function forEachRight(collection, iteratee) {
  22427. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  22428. return func(collection, getIteratee(iteratee, 3));
  22429. }
  22430. /**
  22431. * Creates an object composed of keys generated from the results of running
  22432. * each element of `collection` thru `iteratee`. The order of grouped values
  22433. * is determined by the order they occur in `collection`. The corresponding
  22434. * value of each key is an array of elements responsible for generating the
  22435. * key. The iteratee is invoked with one argument: (value).
  22436. *
  22437. * @static
  22438. * @memberOf _
  22439. * @since 0.1.0
  22440. * @category Collection
  22441. * @param {Array|Object} collection The collection to iterate over.
  22442. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22443. * @returns {Object} Returns the composed aggregate object.
  22444. * @example
  22445. *
  22446. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  22447. * // => { '4': [4.2], '6': [6.1, 6.3] }
  22448. *
  22449. * // The `_.property` iteratee shorthand.
  22450. * _.groupBy(['one', 'two', 'three'], 'length');
  22451. * // => { '3': ['one', 'two'], '5': ['three'] }
  22452. */
  22453. var groupBy = createAggregator(function(result, value, key) {
  22454. if (hasOwnProperty.call(result, key)) {
  22455. result[key].push(value);
  22456. } else {
  22457. baseAssignValue(result, key, [value]);
  22458. }
  22459. });
  22460. /**
  22461. * Checks if `value` is in `collection`. If `collection` is a string, it's
  22462. * checked for a substring of `value`, otherwise
  22463. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  22464. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  22465. * the offset from the end of `collection`.
  22466. *
  22467. * @static
  22468. * @memberOf _
  22469. * @since 0.1.0
  22470. * @category Collection
  22471. * @param {Array|Object|string} collection The collection to inspect.
  22472. * @param {*} value The value to search for.
  22473. * @param {number} [fromIndex=0] The index to search from.
  22474. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  22475. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  22476. * @example
  22477. *
  22478. * _.includes([1, 2, 3], 1);
  22479. * // => true
  22480. *
  22481. * _.includes([1, 2, 3], 1, 2);
  22482. * // => false
  22483. *
  22484. * _.includes({ 'a': 1, 'b': 2 }, 1);
  22485. * // => true
  22486. *
  22487. * _.includes('abcd', 'bc');
  22488. * // => true
  22489. */
  22490. function includes(collection, value, fromIndex, guard) {
  22491. collection = isArrayLike(collection) ? collection : values(collection);
  22492. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  22493. var length = collection.length;
  22494. if (fromIndex < 0) {
  22495. fromIndex = nativeMax(length + fromIndex, 0);
  22496. }
  22497. return isString(collection)
  22498. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  22499. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  22500. }
  22501. /**
  22502. * Invokes the method at `path` of each element in `collection`, returning
  22503. * an array of the results of each invoked method. Any additional arguments
  22504. * are provided to each invoked method. If `path` is a function, it's invoked
  22505. * for, and `this` bound to, each element in `collection`.
  22506. *
  22507. * @static
  22508. * @memberOf _
  22509. * @since 4.0.0
  22510. * @category Collection
  22511. * @param {Array|Object} collection The collection to iterate over.
  22512. * @param {Array|Function|string} path The path of the method to invoke or
  22513. * the function invoked per iteration.
  22514. * @param {...*} [args] The arguments to invoke each method with.
  22515. * @returns {Array} Returns the array of results.
  22516. * @example
  22517. *
  22518. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  22519. * // => [[1, 5, 7], [1, 2, 3]]
  22520. *
  22521. * _.invokeMap([123, 456], String.prototype.split, '');
  22522. * // => [['1', '2', '3'], ['4', '5', '6']]
  22523. */
  22524. var invokeMap = baseRest(function(collection, path, args) {
  22525. var index = -1,
  22526. isFunc = typeof path == 'function',
  22527. result = isArrayLike(collection) ? Array(collection.length) : [];
  22528. baseEach(collection, function(value) {
  22529. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  22530. });
  22531. return result;
  22532. });
  22533. /**
  22534. * Creates an object composed of keys generated from the results of running
  22535. * each element of `collection` thru `iteratee`. The corresponding value of
  22536. * each key is the last element responsible for generating the key. The
  22537. * iteratee is invoked with one argument: (value).
  22538. *
  22539. * @static
  22540. * @memberOf _
  22541. * @since 4.0.0
  22542. * @category Collection
  22543. * @param {Array|Object} collection The collection to iterate over.
  22544. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22545. * @returns {Object} Returns the composed aggregate object.
  22546. * @example
  22547. *
  22548. * var array = [
  22549. * { 'dir': 'left', 'code': 97 },
  22550. * { 'dir': 'right', 'code': 100 }
  22551. * ];
  22552. *
  22553. * _.keyBy(array, function(o) {
  22554. * return String.fromCharCode(o.code);
  22555. * });
  22556. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  22557. *
  22558. * _.keyBy(array, 'dir');
  22559. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  22560. */
  22561. var keyBy = createAggregator(function(result, value, key) {
  22562. baseAssignValue(result, key, value);
  22563. });
  22564. /**
  22565. * Creates an array of values by running each element in `collection` thru
  22566. * `iteratee`. The iteratee is invoked with three arguments:
  22567. * (value, index|key, collection).
  22568. *
  22569. * Many lodash methods are guarded to work as iteratees for methods like
  22570. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  22571. *
  22572. * The guarded methods are:
  22573. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  22574. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  22575. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  22576. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  22577. *
  22578. * @static
  22579. * @memberOf _
  22580. * @since 0.1.0
  22581. * @category Collection
  22582. * @param {Array|Object} collection The collection to iterate over.
  22583. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22584. * @returns {Array} Returns the new mapped array.
  22585. * @example
  22586. *
  22587. * function square(n) {
  22588. * return n * n;
  22589. * }
  22590. *
  22591. * _.map([4, 8], square);
  22592. * // => [16, 64]
  22593. *
  22594. * _.map({ 'a': 4, 'b': 8 }, square);
  22595. * // => [16, 64] (iteration order is not guaranteed)
  22596. *
  22597. * var users = [
  22598. * { 'user': 'barney' },
  22599. * { 'user': 'fred' }
  22600. * ];
  22601. *
  22602. * // The `_.property` iteratee shorthand.
  22603. * _.map(users, 'user');
  22604. * // => ['barney', 'fred']
  22605. */
  22606. function map(collection, iteratee) {
  22607. var func = isArray(collection) ? arrayMap : baseMap;
  22608. return func(collection, getIteratee(iteratee, 3));
  22609. }
  22610. /**
  22611. * This method is like `_.sortBy` except that it allows specifying the sort
  22612. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  22613. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  22614. * descending or "asc" for ascending sort order of corresponding values.
  22615. *
  22616. * @static
  22617. * @memberOf _
  22618. * @since 4.0.0
  22619. * @category Collection
  22620. * @param {Array|Object} collection The collection to iterate over.
  22621. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  22622. * The iteratees to sort by.
  22623. * @param {string[]} [orders] The sort orders of `iteratees`.
  22624. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  22625. * @returns {Array} Returns the new sorted array.
  22626. * @example
  22627. *
  22628. * var users = [
  22629. * { 'user': 'fred', 'age': 48 },
  22630. * { 'user': 'barney', 'age': 34 },
  22631. * { 'user': 'fred', 'age': 40 },
  22632. * { 'user': 'barney', 'age': 36 }
  22633. * ];
  22634. *
  22635. * // Sort by `user` in ascending order and by `age` in descending order.
  22636. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  22637. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  22638. */
  22639. function orderBy(collection, iteratees, orders, guard) {
  22640. if (collection == null) {
  22641. return [];
  22642. }
  22643. if (!isArray(iteratees)) {
  22644. iteratees = iteratees == null ? [] : [iteratees];
  22645. }
  22646. orders = guard ? undefined : orders;
  22647. if (!isArray(orders)) {
  22648. orders = orders == null ? [] : [orders];
  22649. }
  22650. return baseOrderBy(collection, iteratees, orders);
  22651. }
  22652. /**
  22653. * Creates an array of elements split into two groups, the first of which
  22654. * contains elements `predicate` returns truthy for, the second of which
  22655. * contains elements `predicate` returns falsey for. The predicate is
  22656. * invoked with one argument: (value).
  22657. *
  22658. * @static
  22659. * @memberOf _
  22660. * @since 3.0.0
  22661. * @category Collection
  22662. * @param {Array|Object} collection The collection to iterate over.
  22663. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22664. * @returns {Array} Returns the array of grouped elements.
  22665. * @example
  22666. *
  22667. * var users = [
  22668. * { 'user': 'barney', 'age': 36, 'active': false },
  22669. * { 'user': 'fred', 'age': 40, 'active': true },
  22670. * { 'user': 'pebbles', 'age': 1, 'active': false }
  22671. * ];
  22672. *
  22673. * _.partition(users, function(o) { return o.active; });
  22674. * // => objects for [['fred'], ['barney', 'pebbles']]
  22675. *
  22676. * // The `_.matches` iteratee shorthand.
  22677. * _.partition(users, { 'age': 1, 'active': false });
  22678. * // => objects for [['pebbles'], ['barney', 'fred']]
  22679. *
  22680. * // The `_.matchesProperty` iteratee shorthand.
  22681. * _.partition(users, ['active', false]);
  22682. * // => objects for [['barney', 'pebbles'], ['fred']]
  22683. *
  22684. * // The `_.property` iteratee shorthand.
  22685. * _.partition(users, 'active');
  22686. * // => objects for [['fred'], ['barney', 'pebbles']]
  22687. */
  22688. var partition = createAggregator(function(result, value, key) {
  22689. result[key ? 0 : 1].push(value);
  22690. }, function() { return [[], []]; });
  22691. /**
  22692. * Reduces `collection` to a value which is the accumulated result of running
  22693. * each element in `collection` thru `iteratee`, where each successive
  22694. * invocation is supplied the return value of the previous. If `accumulator`
  22695. * is not given, the first element of `collection` is used as the initial
  22696. * value. The iteratee is invoked with four arguments:
  22697. * (accumulator, value, index|key, collection).
  22698. *
  22699. * Many lodash methods are guarded to work as iteratees for methods like
  22700. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  22701. *
  22702. * The guarded methods are:
  22703. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  22704. * and `sortBy`
  22705. *
  22706. * @static
  22707. * @memberOf _
  22708. * @since 0.1.0
  22709. * @category Collection
  22710. * @param {Array|Object} collection The collection to iterate over.
  22711. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22712. * @param {*} [accumulator] The initial value.
  22713. * @returns {*} Returns the accumulated value.
  22714. * @see _.reduceRight
  22715. * @example
  22716. *
  22717. * _.reduce([1, 2], function(sum, n) {
  22718. * return sum + n;
  22719. * }, 0);
  22720. * // => 3
  22721. *
  22722. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  22723. * (result[value] || (result[value] = [])).push(key);
  22724. * return result;
  22725. * }, {});
  22726. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  22727. */
  22728. function reduce(collection, iteratee, accumulator) {
  22729. var func = isArray(collection) ? arrayReduce : baseReduce,
  22730. initAccum = arguments.length < 3;
  22731. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  22732. }
  22733. /**
  22734. * This method is like `_.reduce` except that it iterates over elements of
  22735. * `collection` from right to left.
  22736. *
  22737. * @static
  22738. * @memberOf _
  22739. * @since 0.1.0
  22740. * @category Collection
  22741. * @param {Array|Object} collection The collection to iterate over.
  22742. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22743. * @param {*} [accumulator] The initial value.
  22744. * @returns {*} Returns the accumulated value.
  22745. * @see _.reduce
  22746. * @example
  22747. *
  22748. * var array = [[0, 1], [2, 3], [4, 5]];
  22749. *
  22750. * _.reduceRight(array, function(flattened, other) {
  22751. * return flattened.concat(other);
  22752. * }, []);
  22753. * // => [4, 5, 2, 3, 0, 1]
  22754. */
  22755. function reduceRight(collection, iteratee, accumulator) {
  22756. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  22757. initAccum = arguments.length < 3;
  22758. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  22759. }
  22760. /**
  22761. * The opposite of `_.filter`; this method returns the elements of `collection`
  22762. * that `predicate` does **not** return truthy for.
  22763. *
  22764. * @static
  22765. * @memberOf _
  22766. * @since 0.1.0
  22767. * @category Collection
  22768. * @param {Array|Object} collection The collection to iterate over.
  22769. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22770. * @returns {Array} Returns the new filtered array.
  22771. * @see _.filter
  22772. * @example
  22773. *
  22774. * var users = [
  22775. * { 'user': 'barney', 'age': 36, 'active': false },
  22776. * { 'user': 'fred', 'age': 40, 'active': true }
  22777. * ];
  22778. *
  22779. * _.reject(users, function(o) { return !o.active; });
  22780. * // => objects for ['fred']
  22781. *
  22782. * // The `_.matches` iteratee shorthand.
  22783. * _.reject(users, { 'age': 40, 'active': true });
  22784. * // => objects for ['barney']
  22785. *
  22786. * // The `_.matchesProperty` iteratee shorthand.
  22787. * _.reject(users, ['active', false]);
  22788. * // => objects for ['fred']
  22789. *
  22790. * // The `_.property` iteratee shorthand.
  22791. * _.reject(users, 'active');
  22792. * // => objects for ['barney']
  22793. */
  22794. function reject(collection, predicate) {
  22795. var func = isArray(collection) ? arrayFilter : baseFilter;
  22796. return func(collection, negate(getIteratee(predicate, 3)));
  22797. }
  22798. /**
  22799. * Gets a random element from `collection`.
  22800. *
  22801. * @static
  22802. * @memberOf _
  22803. * @since 2.0.0
  22804. * @category Collection
  22805. * @param {Array|Object} collection The collection to sample.
  22806. * @returns {*} Returns the random element.
  22807. * @example
  22808. *
  22809. * _.sample([1, 2, 3, 4]);
  22810. * // => 2
  22811. */
  22812. function sample(collection) {
  22813. var func = isArray(collection) ? arraySample : baseSample;
  22814. return func(collection);
  22815. }
  22816. /**
  22817. * Gets `n` random elements at unique keys from `collection` up to the
  22818. * size of `collection`.
  22819. *
  22820. * @static
  22821. * @memberOf _
  22822. * @since 4.0.0
  22823. * @category Collection
  22824. * @param {Array|Object} collection The collection to sample.
  22825. * @param {number} [n=1] The number of elements to sample.
  22826. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  22827. * @returns {Array} Returns the random elements.
  22828. * @example
  22829. *
  22830. * _.sampleSize([1, 2, 3], 2);
  22831. * // => [3, 1]
  22832. *
  22833. * _.sampleSize([1, 2, 3], 4);
  22834. * // => [2, 3, 1]
  22835. */
  22836. function sampleSize(collection, n, guard) {
  22837. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  22838. n = 1;
  22839. } else {
  22840. n = toInteger(n);
  22841. }
  22842. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  22843. return func(collection, n);
  22844. }
  22845. /**
  22846. * Creates an array of shuffled values, using a version of the
  22847. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  22848. *
  22849. * @static
  22850. * @memberOf _
  22851. * @since 0.1.0
  22852. * @category Collection
  22853. * @param {Array|Object} collection The collection to shuffle.
  22854. * @returns {Array} Returns the new shuffled array.
  22855. * @example
  22856. *
  22857. * _.shuffle([1, 2, 3, 4]);
  22858. * // => [4, 1, 3, 2]
  22859. */
  22860. function shuffle(collection) {
  22861. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  22862. return func(collection);
  22863. }
  22864. /**
  22865. * Gets the size of `collection` by returning its length for array-like
  22866. * values or the number of own enumerable string keyed properties for objects.
  22867. *
  22868. * @static
  22869. * @memberOf _
  22870. * @since 0.1.0
  22871. * @category Collection
  22872. * @param {Array|Object|string} collection The collection to inspect.
  22873. * @returns {number} Returns the collection size.
  22874. * @example
  22875. *
  22876. * _.size([1, 2, 3]);
  22877. * // => 3
  22878. *
  22879. * _.size({ 'a': 1, 'b': 2 });
  22880. * // => 2
  22881. *
  22882. * _.size('pebbles');
  22883. * // => 7
  22884. */
  22885. function size(collection) {
  22886. if (collection == null) {
  22887. return 0;
  22888. }
  22889. if (isArrayLike(collection)) {
  22890. return isString(collection) ? stringSize(collection) : collection.length;
  22891. }
  22892. var tag = getTag(collection);
  22893. if (tag == mapTag || tag == setTag) {
  22894. return collection.size;
  22895. }
  22896. return baseKeys(collection).length;
  22897. }
  22898. /**
  22899. * Checks if `predicate` returns truthy for **any** element of `collection`.
  22900. * Iteration is stopped once `predicate` returns truthy. The predicate is
  22901. * invoked with three arguments: (value, index|key, collection).
  22902. *
  22903. * @static
  22904. * @memberOf _
  22905. * @since 0.1.0
  22906. * @category Collection
  22907. * @param {Array|Object} collection The collection to iterate over.
  22908. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22909. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  22910. * @returns {boolean} Returns `true` if any element passes the predicate check,
  22911. * else `false`.
  22912. * @example
  22913. *
  22914. * _.some([null, 0, 'yes', false], Boolean);
  22915. * // => true
  22916. *
  22917. * var users = [
  22918. * { 'user': 'barney', 'active': true },
  22919. * { 'user': 'fred', 'active': false }
  22920. * ];
  22921. *
  22922. * // The `_.matches` iteratee shorthand.
  22923. * _.some(users, { 'user': 'barney', 'active': false });
  22924. * // => false
  22925. *
  22926. * // The `_.matchesProperty` iteratee shorthand.
  22927. * _.some(users, ['active', false]);
  22928. * // => true
  22929. *
  22930. * // The `_.property` iteratee shorthand.
  22931. * _.some(users, 'active');
  22932. * // => true
  22933. */
  22934. function some(collection, predicate, guard) {
  22935. var func = isArray(collection) ? arraySome : baseSome;
  22936. if (guard && isIterateeCall(collection, predicate, guard)) {
  22937. predicate = undefined;
  22938. }
  22939. return func(collection, getIteratee(predicate, 3));
  22940. }
  22941. /**
  22942. * Creates an array of elements, sorted in ascending order by the results of
  22943. * running each element in a collection thru each iteratee. This method
  22944. * performs a stable sort, that is, it preserves the original sort order of
  22945. * equal elements. The iteratees are invoked with one argument: (value).
  22946. *
  22947. * @static
  22948. * @memberOf _
  22949. * @since 0.1.0
  22950. * @category Collection
  22951. * @param {Array|Object} collection The collection to iterate over.
  22952. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  22953. * The iteratees to sort by.
  22954. * @returns {Array} Returns the new sorted array.
  22955. * @example
  22956. *
  22957. * var users = [
  22958. * { 'user': 'fred', 'age': 48 },
  22959. * { 'user': 'barney', 'age': 36 },
  22960. * { 'user': 'fred', 'age': 40 },
  22961. * { 'user': 'barney', 'age': 34 }
  22962. * ];
  22963. *
  22964. * _.sortBy(users, [function(o) { return o.user; }]);
  22965. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  22966. *
  22967. * _.sortBy(users, ['user', 'age']);
  22968. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  22969. */
  22970. var sortBy = baseRest(function(collection, iteratees) {
  22971. if (collection == null) {
  22972. return [];
  22973. }
  22974. var length = iteratees.length;
  22975. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  22976. iteratees = [];
  22977. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  22978. iteratees = [iteratees[0]];
  22979. }
  22980. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  22981. });
  22982. /*------------------------------------------------------------------------*/
  22983. /**
  22984. * Gets the timestamp of the number of milliseconds that have elapsed since
  22985. * the Unix epoch (1 January 1970 00:00:00 UTC).
  22986. *
  22987. * @static
  22988. * @memberOf _
  22989. * @since 2.4.0
  22990. * @category Date
  22991. * @returns {number} Returns the timestamp.
  22992. * @example
  22993. *
  22994. * _.defer(function(stamp) {
  22995. * console.log(_.now() - stamp);
  22996. * }, _.now());
  22997. * // => Logs the number of milliseconds it took for the deferred invocation.
  22998. */
  22999. var now = ctxNow || function() {
  23000. return root.Date.now();
  23001. };
  23002. /*------------------------------------------------------------------------*/
  23003. /**
  23004. * The opposite of `_.before`; this method creates a function that invokes
  23005. * `func` once it's called `n` or more times.
  23006. *
  23007. * @static
  23008. * @memberOf _
  23009. * @since 0.1.0
  23010. * @category Function
  23011. * @param {number} n The number of calls before `func` is invoked.
  23012. * @param {Function} func The function to restrict.
  23013. * @returns {Function} Returns the new restricted function.
  23014. * @example
  23015. *
  23016. * var saves = ['profile', 'settings'];
  23017. *
  23018. * var done = _.after(saves.length, function() {
  23019. * console.log('done saving!');
  23020. * });
  23021. *
  23022. * _.forEach(saves, function(type) {
  23023. * asyncSave({ 'type': type, 'complete': done });
  23024. * });
  23025. * // => Logs 'done saving!' after the two async saves have completed.
  23026. */
  23027. function after(n, func) {
  23028. if (typeof func != 'function') {
  23029. throw new TypeError(FUNC_ERROR_TEXT);
  23030. }
  23031. n = toInteger(n);
  23032. return function() {
  23033. if (--n < 1) {
  23034. return func.apply(this, arguments);
  23035. }
  23036. };
  23037. }
  23038. /**
  23039. * Creates a function that invokes `func`, with up to `n` arguments,
  23040. * ignoring any additional arguments.
  23041. *
  23042. * @static
  23043. * @memberOf _
  23044. * @since 3.0.0
  23045. * @category Function
  23046. * @param {Function} func The function to cap arguments for.
  23047. * @param {number} [n=func.length] The arity cap.
  23048. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23049. * @returns {Function} Returns the new capped function.
  23050. * @example
  23051. *
  23052. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  23053. * // => [6, 8, 10]
  23054. */
  23055. function ary(func, n, guard) {
  23056. n = guard ? undefined : n;
  23057. n = (func && n == null) ? func.length : n;
  23058. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  23059. }
  23060. /**
  23061. * Creates a function that invokes `func`, with the `this` binding and arguments
  23062. * of the created function, while it's called less than `n` times. Subsequent
  23063. * calls to the created function return the result of the last `func` invocation.
  23064. *
  23065. * @static
  23066. * @memberOf _
  23067. * @since 3.0.0
  23068. * @category Function
  23069. * @param {number} n The number of calls at which `func` is no longer invoked.
  23070. * @param {Function} func The function to restrict.
  23071. * @returns {Function} Returns the new restricted function.
  23072. * @example
  23073. *
  23074. * jQuery(element).on('click', _.before(5, addContactToList));
  23075. * // => Allows adding up to 4 contacts to the list.
  23076. */
  23077. function before(n, func) {
  23078. var result;
  23079. if (typeof func != 'function') {
  23080. throw new TypeError(FUNC_ERROR_TEXT);
  23081. }
  23082. n = toInteger(n);
  23083. return function() {
  23084. if (--n > 0) {
  23085. result = func.apply(this, arguments);
  23086. }
  23087. if (n <= 1) {
  23088. func = undefined;
  23089. }
  23090. return result;
  23091. };
  23092. }
  23093. /**
  23094. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  23095. * and `partials` prepended to the arguments it receives.
  23096. *
  23097. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  23098. * may be used as a placeholder for partially applied arguments.
  23099. *
  23100. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  23101. * property of bound functions.
  23102. *
  23103. * @static
  23104. * @memberOf _
  23105. * @since 0.1.0
  23106. * @category Function
  23107. * @param {Function} func The function to bind.
  23108. * @param {*} thisArg The `this` binding of `func`.
  23109. * @param {...*} [partials] The arguments to be partially applied.
  23110. * @returns {Function} Returns the new bound function.
  23111. * @example
  23112. *
  23113. * function greet(greeting, punctuation) {
  23114. * return greeting + ' ' + this.user + punctuation;
  23115. * }
  23116. *
  23117. * var object = { 'user': 'fred' };
  23118. *
  23119. * var bound = _.bind(greet, object, 'hi');
  23120. * bound('!');
  23121. * // => 'hi fred!'
  23122. *
  23123. * // Bound with placeholders.
  23124. * var bound = _.bind(greet, object, _, '!');
  23125. * bound('hi');
  23126. * // => 'hi fred!'
  23127. */
  23128. var bind = baseRest(function(func, thisArg, partials) {
  23129. var bitmask = WRAP_BIND_FLAG;
  23130. if (partials.length) {
  23131. var holders = replaceHolders(partials, getHolder(bind));
  23132. bitmask |= WRAP_PARTIAL_FLAG;
  23133. }
  23134. return createWrap(func, bitmask, thisArg, partials, holders);
  23135. });
  23136. /**
  23137. * Creates a function that invokes the method at `object[key]` with `partials`
  23138. * prepended to the arguments it receives.
  23139. *
  23140. * This method differs from `_.bind` by allowing bound functions to reference
  23141. * methods that may be redefined or don't yet exist. See
  23142. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  23143. * for more details.
  23144. *
  23145. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  23146. * builds, may be used as a placeholder for partially applied arguments.
  23147. *
  23148. * @static
  23149. * @memberOf _
  23150. * @since 0.10.0
  23151. * @category Function
  23152. * @param {Object} object The object to invoke the method on.
  23153. * @param {string} key The key of the method.
  23154. * @param {...*} [partials] The arguments to be partially applied.
  23155. * @returns {Function} Returns the new bound function.
  23156. * @example
  23157. *
  23158. * var object = {
  23159. * 'user': 'fred',
  23160. * 'greet': function(greeting, punctuation) {
  23161. * return greeting + ' ' + this.user + punctuation;
  23162. * }
  23163. * };
  23164. *
  23165. * var bound = _.bindKey(object, 'greet', 'hi');
  23166. * bound('!');
  23167. * // => 'hi fred!'
  23168. *
  23169. * object.greet = function(greeting, punctuation) {
  23170. * return greeting + 'ya ' + this.user + punctuation;
  23171. * };
  23172. *
  23173. * bound('!');
  23174. * // => 'hiya fred!'
  23175. *
  23176. * // Bound with placeholders.
  23177. * var bound = _.bindKey(object, 'greet', _, '!');
  23178. * bound('hi');
  23179. * // => 'hiya fred!'
  23180. */
  23181. var bindKey = baseRest(function(object, key, partials) {
  23182. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  23183. if (partials.length) {
  23184. var holders = replaceHolders(partials, getHolder(bindKey));
  23185. bitmask |= WRAP_PARTIAL_FLAG;
  23186. }
  23187. return createWrap(key, bitmask, object, partials, holders);
  23188. });
  23189. /**
  23190. * Creates a function that accepts arguments of `func` and either invokes
  23191. * `func` returning its result, if at least `arity` number of arguments have
  23192. * been provided, or returns a function that accepts the remaining `func`
  23193. * arguments, and so on. The arity of `func` may be specified if `func.length`
  23194. * is not sufficient.
  23195. *
  23196. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  23197. * may be used as a placeholder for provided arguments.
  23198. *
  23199. * **Note:** This method doesn't set the "length" property of curried functions.
  23200. *
  23201. * @static
  23202. * @memberOf _
  23203. * @since 2.0.0
  23204. * @category Function
  23205. * @param {Function} func The function to curry.
  23206. * @param {number} [arity=func.length] The arity of `func`.
  23207. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23208. * @returns {Function} Returns the new curried function.
  23209. * @example
  23210. *
  23211. * var abc = function(a, b, c) {
  23212. * return [a, b, c];
  23213. * };
  23214. *
  23215. * var curried = _.curry(abc);
  23216. *
  23217. * curried(1)(2)(3);
  23218. * // => [1, 2, 3]
  23219. *
  23220. * curried(1, 2)(3);
  23221. * // => [1, 2, 3]
  23222. *
  23223. * curried(1, 2, 3);
  23224. * // => [1, 2, 3]
  23225. *
  23226. * // Curried with placeholders.
  23227. * curried(1)(_, 3)(2);
  23228. * // => [1, 2, 3]
  23229. */
  23230. function curry(func, arity, guard) {
  23231. arity = guard ? undefined : arity;
  23232. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  23233. result.placeholder = curry.placeholder;
  23234. return result;
  23235. }
  23236. /**
  23237. * This method is like `_.curry` except that arguments are applied to `func`
  23238. * in the manner of `_.partialRight` instead of `_.partial`.
  23239. *
  23240. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  23241. * builds, may be used as a placeholder for provided arguments.
  23242. *
  23243. * **Note:** This method doesn't set the "length" property of curried functions.
  23244. *
  23245. * @static
  23246. * @memberOf _
  23247. * @since 3.0.0
  23248. * @category Function
  23249. * @param {Function} func The function to curry.
  23250. * @param {number} [arity=func.length] The arity of `func`.
  23251. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23252. * @returns {Function} Returns the new curried function.
  23253. * @example
  23254. *
  23255. * var abc = function(a, b, c) {
  23256. * return [a, b, c];
  23257. * };
  23258. *
  23259. * var curried = _.curryRight(abc);
  23260. *
  23261. * curried(3)(2)(1);
  23262. * // => [1, 2, 3]
  23263. *
  23264. * curried(2, 3)(1);
  23265. * // => [1, 2, 3]
  23266. *
  23267. * curried(1, 2, 3);
  23268. * // => [1, 2, 3]
  23269. *
  23270. * // Curried with placeholders.
  23271. * curried(3)(1, _)(2);
  23272. * // => [1, 2, 3]
  23273. */
  23274. function curryRight(func, arity, guard) {
  23275. arity = guard ? undefined : arity;
  23276. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  23277. result.placeholder = curryRight.placeholder;
  23278. return result;
  23279. }
  23280. /**
  23281. * Creates a debounced function that delays invoking `func` until after `wait`
  23282. * milliseconds have elapsed since the last time the debounced function was
  23283. * invoked. The debounced function comes with a `cancel` method to cancel
  23284. * delayed `func` invocations and a `flush` method to immediately invoke them.
  23285. * Provide `options` to indicate whether `func` should be invoked on the
  23286. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  23287. * with the last arguments provided to the debounced function. Subsequent
  23288. * calls to the debounced function return the result of the last `func`
  23289. * invocation.
  23290. *
  23291. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  23292. * invoked on the trailing edge of the timeout only if the debounced function
  23293. * is invoked more than once during the `wait` timeout.
  23294. *
  23295. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  23296. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  23297. *
  23298. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  23299. * for details over the differences between `_.debounce` and `_.throttle`.
  23300. *
  23301. * @static
  23302. * @memberOf _
  23303. * @since 0.1.0
  23304. * @category Function
  23305. * @param {Function} func The function to debounce.
  23306. * @param {number} [wait=0] The number of milliseconds to delay.
  23307. * @param {Object} [options={}] The options object.
  23308. * @param {boolean} [options.leading=false]
  23309. * Specify invoking on the leading edge of the timeout.
  23310. * @param {number} [options.maxWait]
  23311. * The maximum time `func` is allowed to be delayed before it's invoked.
  23312. * @param {boolean} [options.trailing=true]
  23313. * Specify invoking on the trailing edge of the timeout.
  23314. * @returns {Function} Returns the new debounced function.
  23315. * @example
  23316. *
  23317. * // Avoid costly calculations while the window size is in flux.
  23318. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  23319. *
  23320. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  23321. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  23322. * 'leading': true,
  23323. * 'trailing': false
  23324. * }));
  23325. *
  23326. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  23327. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  23328. * var source = new EventSource('/stream');
  23329. * jQuery(source).on('message', debounced);
  23330. *
  23331. * // Cancel the trailing debounced invocation.
  23332. * jQuery(window).on('popstate', debounced.cancel);
  23333. */
  23334. function debounce(func, wait, options) {
  23335. var lastArgs,
  23336. lastThis,
  23337. maxWait,
  23338. result,
  23339. timerId,
  23340. lastCallTime,
  23341. lastInvokeTime = 0,
  23342. leading = false,
  23343. maxing = false,
  23344. trailing = true;
  23345. if (typeof func != 'function') {
  23346. throw new TypeError(FUNC_ERROR_TEXT);
  23347. }
  23348. wait = toNumber(wait) || 0;
  23349. if (isObject(options)) {
  23350. leading = !!options.leading;
  23351. maxing = 'maxWait' in options;
  23352. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  23353. trailing = 'trailing' in options ? !!options.trailing : trailing;
  23354. }
  23355. function invokeFunc(time) {
  23356. var args = lastArgs,
  23357. thisArg = lastThis;
  23358. lastArgs = lastThis = undefined;
  23359. lastInvokeTime = time;
  23360. result = func.apply(thisArg, args);
  23361. return result;
  23362. }
  23363. function leadingEdge(time) {
  23364. // Reset any `maxWait` timer.
  23365. lastInvokeTime = time;
  23366. // Start the timer for the trailing edge.
  23367. timerId = setTimeout(timerExpired, wait);
  23368. // Invoke the leading edge.
  23369. return leading ? invokeFunc(time) : result;
  23370. }
  23371. function remainingWait(time) {
  23372. var timeSinceLastCall = time - lastCallTime,
  23373. timeSinceLastInvoke = time - lastInvokeTime,
  23374. timeWaiting = wait - timeSinceLastCall;
  23375. return maxing
  23376. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  23377. : timeWaiting;
  23378. }
  23379. function shouldInvoke(time) {
  23380. var timeSinceLastCall = time - lastCallTime,
  23381. timeSinceLastInvoke = time - lastInvokeTime;
  23382. // Either this is the first call, activity has stopped and we're at the
  23383. // trailing edge, the system time has gone backwards and we're treating
  23384. // it as the trailing edge, or we've hit the `maxWait` limit.
  23385. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  23386. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  23387. }
  23388. function timerExpired() {
  23389. var time = now();
  23390. if (shouldInvoke(time)) {
  23391. return trailingEdge(time);
  23392. }
  23393. // Restart the timer.
  23394. timerId = setTimeout(timerExpired, remainingWait(time));
  23395. }
  23396. function trailingEdge(time) {
  23397. timerId = undefined;
  23398. // Only invoke if we have `lastArgs` which means `func` has been
  23399. // debounced at least once.
  23400. if (trailing && lastArgs) {
  23401. return invokeFunc(time);
  23402. }
  23403. lastArgs = lastThis = undefined;
  23404. return result;
  23405. }
  23406. function cancel() {
  23407. if (timerId !== undefined) {
  23408. clearTimeout(timerId);
  23409. }
  23410. lastInvokeTime = 0;
  23411. lastArgs = lastCallTime = lastThis = timerId = undefined;
  23412. }
  23413. function flush() {
  23414. return timerId === undefined ? result : trailingEdge(now());
  23415. }
  23416. function debounced() {
  23417. var time = now(),
  23418. isInvoking = shouldInvoke(time);
  23419. lastArgs = arguments;
  23420. lastThis = this;
  23421. lastCallTime = time;
  23422. if (isInvoking) {
  23423. if (timerId === undefined) {
  23424. return leadingEdge(lastCallTime);
  23425. }
  23426. if (maxing) {
  23427. // Handle invocations in a tight loop.
  23428. clearTimeout(timerId);
  23429. timerId = setTimeout(timerExpired, wait);
  23430. return invokeFunc(lastCallTime);
  23431. }
  23432. }
  23433. if (timerId === undefined) {
  23434. timerId = setTimeout(timerExpired, wait);
  23435. }
  23436. return result;
  23437. }
  23438. debounced.cancel = cancel;
  23439. debounced.flush = flush;
  23440. return debounced;
  23441. }
  23442. /**
  23443. * Defers invoking the `func` until the current call stack has cleared. Any
  23444. * additional arguments are provided to `func` when it's invoked.
  23445. *
  23446. * @static
  23447. * @memberOf _
  23448. * @since 0.1.0
  23449. * @category Function
  23450. * @param {Function} func The function to defer.
  23451. * @param {...*} [args] The arguments to invoke `func` with.
  23452. * @returns {number} Returns the timer id.
  23453. * @example
  23454. *
  23455. * _.defer(function(text) {
  23456. * console.log(text);
  23457. * }, 'deferred');
  23458. * // => Logs 'deferred' after one millisecond.
  23459. */
  23460. var defer = baseRest(function(func, args) {
  23461. return baseDelay(func, 1, args);
  23462. });
  23463. /**
  23464. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  23465. * provided to `func` when it's invoked.
  23466. *
  23467. * @static
  23468. * @memberOf _
  23469. * @since 0.1.0
  23470. * @category Function
  23471. * @param {Function} func The function to delay.
  23472. * @param {number} wait The number of milliseconds to delay invocation.
  23473. * @param {...*} [args] The arguments to invoke `func` with.
  23474. * @returns {number} Returns the timer id.
  23475. * @example
  23476. *
  23477. * _.delay(function(text) {
  23478. * console.log(text);
  23479. * }, 1000, 'later');
  23480. * // => Logs 'later' after one second.
  23481. */
  23482. var delay = baseRest(function(func, wait, args) {
  23483. return baseDelay(func, toNumber(wait) || 0, args);
  23484. });
  23485. /**
  23486. * Creates a function that invokes `func` with arguments reversed.
  23487. *
  23488. * @static
  23489. * @memberOf _
  23490. * @since 4.0.0
  23491. * @category Function
  23492. * @param {Function} func The function to flip arguments for.
  23493. * @returns {Function} Returns the new flipped function.
  23494. * @example
  23495. *
  23496. * var flipped = _.flip(function() {
  23497. * return _.toArray(arguments);
  23498. * });
  23499. *
  23500. * flipped('a', 'b', 'c', 'd');
  23501. * // => ['d', 'c', 'b', 'a']
  23502. */
  23503. function flip(func) {
  23504. return createWrap(func, WRAP_FLIP_FLAG);
  23505. }
  23506. /**
  23507. * Creates a function that memoizes the result of `func`. If `resolver` is
  23508. * provided, it determines the cache key for storing the result based on the
  23509. * arguments provided to the memoized function. By default, the first argument
  23510. * provided to the memoized function is used as the map cache key. The `func`
  23511. * is invoked with the `this` binding of the memoized function.
  23512. *
  23513. * **Note:** The cache is exposed as the `cache` property on the memoized
  23514. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  23515. * constructor with one whose instances implement the
  23516. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  23517. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  23518. *
  23519. * @static
  23520. * @memberOf _
  23521. * @since 0.1.0
  23522. * @category Function
  23523. * @param {Function} func The function to have its output memoized.
  23524. * @param {Function} [resolver] The function to resolve the cache key.
  23525. * @returns {Function} Returns the new memoized function.
  23526. * @example
  23527. *
  23528. * var object = { 'a': 1, 'b': 2 };
  23529. * var other = { 'c': 3, 'd': 4 };
  23530. *
  23531. * var values = _.memoize(_.values);
  23532. * values(object);
  23533. * // => [1, 2]
  23534. *
  23535. * values(other);
  23536. * // => [3, 4]
  23537. *
  23538. * object.a = 2;
  23539. * values(object);
  23540. * // => [1, 2]
  23541. *
  23542. * // Modify the result cache.
  23543. * values.cache.set(object, ['a', 'b']);
  23544. * values(object);
  23545. * // => ['a', 'b']
  23546. *
  23547. * // Replace `_.memoize.Cache`.
  23548. * _.memoize.Cache = WeakMap;
  23549. */
  23550. function memoize(func, resolver) {
  23551. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  23552. throw new TypeError(FUNC_ERROR_TEXT);
  23553. }
  23554. var memoized = function() {
  23555. var args = arguments,
  23556. key = resolver ? resolver.apply(this, args) : args[0],
  23557. cache = memoized.cache;
  23558. if (cache.has(key)) {
  23559. return cache.get(key);
  23560. }
  23561. var result = func.apply(this, args);
  23562. memoized.cache = cache.set(key, result) || cache;
  23563. return result;
  23564. };
  23565. memoized.cache = new (memoize.Cache || MapCache);
  23566. return memoized;
  23567. }
  23568. // Expose `MapCache`.
  23569. memoize.Cache = MapCache;
  23570. /**
  23571. * Creates a function that negates the result of the predicate `func`. The
  23572. * `func` predicate is invoked with the `this` binding and arguments of the
  23573. * created function.
  23574. *
  23575. * @static
  23576. * @memberOf _
  23577. * @since 3.0.0
  23578. * @category Function
  23579. * @param {Function} predicate The predicate to negate.
  23580. * @returns {Function} Returns the new negated function.
  23581. * @example
  23582. *
  23583. * function isEven(n) {
  23584. * return n % 2 == 0;
  23585. * }
  23586. *
  23587. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  23588. * // => [1, 3, 5]
  23589. */
  23590. function negate(predicate) {
  23591. if (typeof predicate != 'function') {
  23592. throw new TypeError(FUNC_ERROR_TEXT);
  23593. }
  23594. return function() {
  23595. var args = arguments;
  23596. switch (args.length) {
  23597. case 0: return !predicate.call(this);
  23598. case 1: return !predicate.call(this, args[0]);
  23599. case 2: return !predicate.call(this, args[0], args[1]);
  23600. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  23601. }
  23602. return !predicate.apply(this, args);
  23603. };
  23604. }
  23605. /**
  23606. * Creates a function that is restricted to invoking `func` once. Repeat calls
  23607. * to the function return the value of the first invocation. The `func` is
  23608. * invoked with the `this` binding and arguments of the created function.
  23609. *
  23610. * @static
  23611. * @memberOf _
  23612. * @since 0.1.0
  23613. * @category Function
  23614. * @param {Function} func The function to restrict.
  23615. * @returns {Function} Returns the new restricted function.
  23616. * @example
  23617. *
  23618. * var initialize = _.once(createApplication);
  23619. * initialize();
  23620. * initialize();
  23621. * // => `createApplication` is invoked once
  23622. */
  23623. function once(func) {
  23624. return before(2, func);
  23625. }
  23626. /**
  23627. * Creates a function that invokes `func` with its arguments transformed.
  23628. *
  23629. * @static
  23630. * @since 4.0.0
  23631. * @memberOf _
  23632. * @category Function
  23633. * @param {Function} func The function to wrap.
  23634. * @param {...(Function|Function[])} [transforms=[_.identity]]
  23635. * The argument transforms.
  23636. * @returns {Function} Returns the new function.
  23637. * @example
  23638. *
  23639. * function doubled(n) {
  23640. * return n * 2;
  23641. * }
  23642. *
  23643. * function square(n) {
  23644. * return n * n;
  23645. * }
  23646. *
  23647. * var func = _.overArgs(function(x, y) {
  23648. * return [x, y];
  23649. * }, [square, doubled]);
  23650. *
  23651. * func(9, 3);
  23652. * // => [81, 6]
  23653. *
  23654. * func(10, 5);
  23655. * // => [100, 10]
  23656. */
  23657. var overArgs = castRest(function(func, transforms) {
  23658. transforms = (transforms.length == 1 && isArray(transforms[0]))
  23659. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  23660. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  23661. var funcsLength = transforms.length;
  23662. return baseRest(function(args) {
  23663. var index = -1,
  23664. length = nativeMin(args.length, funcsLength);
  23665. while (++index < length) {
  23666. args[index] = transforms[index].call(this, args[index]);
  23667. }
  23668. return apply(func, this, args);
  23669. });
  23670. });
  23671. /**
  23672. * Creates a function that invokes `func` with `partials` prepended to the
  23673. * arguments it receives. This method is like `_.bind` except it does **not**
  23674. * alter the `this` binding.
  23675. *
  23676. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  23677. * builds, may be used as a placeholder for partially applied arguments.
  23678. *
  23679. * **Note:** This method doesn't set the "length" property of partially
  23680. * applied functions.
  23681. *
  23682. * @static
  23683. * @memberOf _
  23684. * @since 0.2.0
  23685. * @category Function
  23686. * @param {Function} func The function to partially apply arguments to.
  23687. * @param {...*} [partials] The arguments to be partially applied.
  23688. * @returns {Function} Returns the new partially applied function.
  23689. * @example
  23690. *
  23691. * function greet(greeting, name) {
  23692. * return greeting + ' ' + name;
  23693. * }
  23694. *
  23695. * var sayHelloTo = _.partial(greet, 'hello');
  23696. * sayHelloTo('fred');
  23697. * // => 'hello fred'
  23698. *
  23699. * // Partially applied with placeholders.
  23700. * var greetFred = _.partial(greet, _, 'fred');
  23701. * greetFred('hi');
  23702. * // => 'hi fred'
  23703. */
  23704. var partial = baseRest(function(func, partials) {
  23705. var holders = replaceHolders(partials, getHolder(partial));
  23706. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  23707. });
  23708. /**
  23709. * This method is like `_.partial` except that partially applied arguments
  23710. * are appended to the arguments it receives.
  23711. *
  23712. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  23713. * builds, may be used as a placeholder for partially applied arguments.
  23714. *
  23715. * **Note:** This method doesn't set the "length" property of partially
  23716. * applied functions.
  23717. *
  23718. * @static
  23719. * @memberOf _
  23720. * @since 1.0.0
  23721. * @category Function
  23722. * @param {Function} func The function to partially apply arguments to.
  23723. * @param {...*} [partials] The arguments to be partially applied.
  23724. * @returns {Function} Returns the new partially applied function.
  23725. * @example
  23726. *
  23727. * function greet(greeting, name) {
  23728. * return greeting + ' ' + name;
  23729. * }
  23730. *
  23731. * var greetFred = _.partialRight(greet, 'fred');
  23732. * greetFred('hi');
  23733. * // => 'hi fred'
  23734. *
  23735. * // Partially applied with placeholders.
  23736. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  23737. * sayHelloTo('fred');
  23738. * // => 'hello fred'
  23739. */
  23740. var partialRight = baseRest(function(func, partials) {
  23741. var holders = replaceHolders(partials, getHolder(partialRight));
  23742. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  23743. });
  23744. /**
  23745. * Creates a function that invokes `func` with arguments arranged according
  23746. * to the specified `indexes` where the argument value at the first index is
  23747. * provided as the first argument, the argument value at the second index is
  23748. * provided as the second argument, and so on.
  23749. *
  23750. * @static
  23751. * @memberOf _
  23752. * @since 3.0.0
  23753. * @category Function
  23754. * @param {Function} func The function to rearrange arguments for.
  23755. * @param {...(number|number[])} indexes The arranged argument indexes.
  23756. * @returns {Function} Returns the new function.
  23757. * @example
  23758. *
  23759. * var rearged = _.rearg(function(a, b, c) {
  23760. * return [a, b, c];
  23761. * }, [2, 0, 1]);
  23762. *
  23763. * rearged('b', 'c', 'a')
  23764. * // => ['a', 'b', 'c']
  23765. */
  23766. var rearg = flatRest(function(func, indexes) {
  23767. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  23768. });
  23769. /**
  23770. * Creates a function that invokes `func` with the `this` binding of the
  23771. * created function and arguments from `start` and beyond provided as
  23772. * an array.
  23773. *
  23774. * **Note:** This method is based on the
  23775. * [rest parameter](https://mdn.io/rest_parameters).
  23776. *
  23777. * @static
  23778. * @memberOf _
  23779. * @since 4.0.0
  23780. * @category Function
  23781. * @param {Function} func The function to apply a rest parameter to.
  23782. * @param {number} [start=func.length-1] The start position of the rest parameter.
  23783. * @returns {Function} Returns the new function.
  23784. * @example
  23785. *
  23786. * var say = _.rest(function(what, names) {
  23787. * return what + ' ' + _.initial(names).join(', ') +
  23788. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  23789. * });
  23790. *
  23791. * say('hello', 'fred', 'barney', 'pebbles');
  23792. * // => 'hello fred, barney, & pebbles'
  23793. */
  23794. function rest(func, start) {
  23795. if (typeof func != 'function') {
  23796. throw new TypeError(FUNC_ERROR_TEXT);
  23797. }
  23798. start = start === undefined ? start : toInteger(start);
  23799. return baseRest(func, start);
  23800. }
  23801. /**
  23802. * Creates a function that invokes `func` with the `this` binding of the
  23803. * create function and an array of arguments much like
  23804. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  23805. *
  23806. * **Note:** This method is based on the
  23807. * [spread operator](https://mdn.io/spread_operator).
  23808. *
  23809. * @static
  23810. * @memberOf _
  23811. * @since 3.2.0
  23812. * @category Function
  23813. * @param {Function} func The function to spread arguments over.
  23814. * @param {number} [start=0] The start position of the spread.
  23815. * @returns {Function} Returns the new function.
  23816. * @example
  23817. *
  23818. * var say = _.spread(function(who, what) {
  23819. * return who + ' says ' + what;
  23820. * });
  23821. *
  23822. * say(['fred', 'hello']);
  23823. * // => 'fred says hello'
  23824. *
  23825. * var numbers = Promise.all([
  23826. * Promise.resolve(40),
  23827. * Promise.resolve(36)
  23828. * ]);
  23829. *
  23830. * numbers.then(_.spread(function(x, y) {
  23831. * return x + y;
  23832. * }));
  23833. * // => a Promise of 76
  23834. */
  23835. function spread(func, start) {
  23836. if (typeof func != 'function') {
  23837. throw new TypeError(FUNC_ERROR_TEXT);
  23838. }
  23839. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  23840. return baseRest(function(args) {
  23841. var array = args[start],
  23842. otherArgs = castSlice(args, 0, start);
  23843. if (array) {
  23844. arrayPush(otherArgs, array);
  23845. }
  23846. return apply(func, this, otherArgs);
  23847. });
  23848. }
  23849. /**
  23850. * Creates a throttled function that only invokes `func` at most once per
  23851. * every `wait` milliseconds. The throttled function comes with a `cancel`
  23852. * method to cancel delayed `func` invocations and a `flush` method to
  23853. * immediately invoke them. Provide `options` to indicate whether `func`
  23854. * should be invoked on the leading and/or trailing edge of the `wait`
  23855. * timeout. The `func` is invoked with the last arguments provided to the
  23856. * throttled function. Subsequent calls to the throttled function return the
  23857. * result of the last `func` invocation.
  23858. *
  23859. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  23860. * invoked on the trailing edge of the timeout only if the throttled function
  23861. * is invoked more than once during the `wait` timeout.
  23862. *
  23863. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  23864. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  23865. *
  23866. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  23867. * for details over the differences between `_.throttle` and `_.debounce`.
  23868. *
  23869. * @static
  23870. * @memberOf _
  23871. * @since 0.1.0
  23872. * @category Function
  23873. * @param {Function} func The function to throttle.
  23874. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  23875. * @param {Object} [options={}] The options object.
  23876. * @param {boolean} [options.leading=true]
  23877. * Specify invoking on the leading edge of the timeout.
  23878. * @param {boolean} [options.trailing=true]
  23879. * Specify invoking on the trailing edge of the timeout.
  23880. * @returns {Function} Returns the new throttled function.
  23881. * @example
  23882. *
  23883. * // Avoid excessively updating the position while scrolling.
  23884. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  23885. *
  23886. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  23887. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  23888. * jQuery(element).on('click', throttled);
  23889. *
  23890. * // Cancel the trailing throttled invocation.
  23891. * jQuery(window).on('popstate', throttled.cancel);
  23892. */
  23893. function throttle(func, wait, options) {
  23894. var leading = true,
  23895. trailing = true;
  23896. if (typeof func != 'function') {
  23897. throw new TypeError(FUNC_ERROR_TEXT);
  23898. }
  23899. if (isObject(options)) {
  23900. leading = 'leading' in options ? !!options.leading : leading;
  23901. trailing = 'trailing' in options ? !!options.trailing : trailing;
  23902. }
  23903. return debounce(func, wait, {
  23904. 'leading': leading,
  23905. 'maxWait': wait,
  23906. 'trailing': trailing
  23907. });
  23908. }
  23909. /**
  23910. * Creates a function that accepts up to one argument, ignoring any
  23911. * additional arguments.
  23912. *
  23913. * @static
  23914. * @memberOf _
  23915. * @since 4.0.0
  23916. * @category Function
  23917. * @param {Function} func The function to cap arguments for.
  23918. * @returns {Function} Returns the new capped function.
  23919. * @example
  23920. *
  23921. * _.map(['6', '8', '10'], _.unary(parseInt));
  23922. * // => [6, 8, 10]
  23923. */
  23924. function unary(func) {
  23925. return ary(func, 1);
  23926. }
  23927. /**
  23928. * Creates a function that provides `value` to `wrapper` as its first
  23929. * argument. Any additional arguments provided to the function are appended
  23930. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  23931. * binding of the created function.
  23932. *
  23933. * @static
  23934. * @memberOf _
  23935. * @since 0.1.0
  23936. * @category Function
  23937. * @param {*} value The value to wrap.
  23938. * @param {Function} [wrapper=identity] The wrapper function.
  23939. * @returns {Function} Returns the new function.
  23940. * @example
  23941. *
  23942. * var p = _.wrap(_.escape, function(func, text) {
  23943. * return '<p>' + func(text) + '</p>';
  23944. * });
  23945. *
  23946. * p('fred, barney, & pebbles');
  23947. * // => '<p>fred, barney, &amp; pebbles</p>'
  23948. */
  23949. function wrap(value, wrapper) {
  23950. return partial(castFunction(wrapper), value);
  23951. }
  23952. /*------------------------------------------------------------------------*/
  23953. /**
  23954. * Casts `value` as an array if it's not one.
  23955. *
  23956. * @static
  23957. * @memberOf _
  23958. * @since 4.4.0
  23959. * @category Lang
  23960. * @param {*} value The value to inspect.
  23961. * @returns {Array} Returns the cast array.
  23962. * @example
  23963. *
  23964. * _.castArray(1);
  23965. * // => [1]
  23966. *
  23967. * _.castArray({ 'a': 1 });
  23968. * // => [{ 'a': 1 }]
  23969. *
  23970. * _.castArray('abc');
  23971. * // => ['abc']
  23972. *
  23973. * _.castArray(null);
  23974. * // => [null]
  23975. *
  23976. * _.castArray(undefined);
  23977. * // => [undefined]
  23978. *
  23979. * _.castArray();
  23980. * // => []
  23981. *
  23982. * var array = [1, 2, 3];
  23983. * console.log(_.castArray(array) === array);
  23984. * // => true
  23985. */
  23986. function castArray() {
  23987. if (!arguments.length) {
  23988. return [];
  23989. }
  23990. var value = arguments[0];
  23991. return isArray(value) ? value : [value];
  23992. }
  23993. /**
  23994. * Creates a shallow clone of `value`.
  23995. *
  23996. * **Note:** This method is loosely based on the
  23997. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  23998. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  23999. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  24000. * arrays. The own enumerable properties of `arguments` objects are cloned
  24001. * as plain objects. An empty object is returned for uncloneable values such
  24002. * as error objects, functions, DOM nodes, and WeakMaps.
  24003. *
  24004. * @static
  24005. * @memberOf _
  24006. * @since 0.1.0
  24007. * @category Lang
  24008. * @param {*} value The value to clone.
  24009. * @returns {*} Returns the cloned value.
  24010. * @see _.cloneDeep
  24011. * @example
  24012. *
  24013. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  24014. *
  24015. * var shallow = _.clone(objects);
  24016. * console.log(shallow[0] === objects[0]);
  24017. * // => true
  24018. */
  24019. function clone(value) {
  24020. return baseClone(value, CLONE_SYMBOLS_FLAG);
  24021. }
  24022. /**
  24023. * This method is like `_.clone` except that it accepts `customizer` which
  24024. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  24025. * cloning is handled by the method instead. The `customizer` is invoked with
  24026. * up to four arguments; (value [, index|key, object, stack]).
  24027. *
  24028. * @static
  24029. * @memberOf _
  24030. * @since 4.0.0
  24031. * @category Lang
  24032. * @param {*} value The value to clone.
  24033. * @param {Function} [customizer] The function to customize cloning.
  24034. * @returns {*} Returns the cloned value.
  24035. * @see _.cloneDeepWith
  24036. * @example
  24037. *
  24038. * function customizer(value) {
  24039. * if (_.isElement(value)) {
  24040. * return value.cloneNode(false);
  24041. * }
  24042. * }
  24043. *
  24044. * var el = _.cloneWith(document.body, customizer);
  24045. *
  24046. * console.log(el === document.body);
  24047. * // => false
  24048. * console.log(el.nodeName);
  24049. * // => 'BODY'
  24050. * console.log(el.childNodes.length);
  24051. * // => 0
  24052. */
  24053. function cloneWith(value, customizer) {
  24054. customizer = typeof customizer == 'function' ? customizer : undefined;
  24055. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  24056. }
  24057. /**
  24058. * This method is like `_.clone` except that it recursively clones `value`.
  24059. *
  24060. * @static
  24061. * @memberOf _
  24062. * @since 1.0.0
  24063. * @category Lang
  24064. * @param {*} value The value to recursively clone.
  24065. * @returns {*} Returns the deep cloned value.
  24066. * @see _.clone
  24067. * @example
  24068. *
  24069. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  24070. *
  24071. * var deep = _.cloneDeep(objects);
  24072. * console.log(deep[0] === objects[0]);
  24073. * // => false
  24074. */
  24075. function cloneDeep(value) {
  24076. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  24077. }
  24078. /**
  24079. * This method is like `_.cloneWith` except that it recursively clones `value`.
  24080. *
  24081. * @static
  24082. * @memberOf _
  24083. * @since 4.0.0
  24084. * @category Lang
  24085. * @param {*} value The value to recursively clone.
  24086. * @param {Function} [customizer] The function to customize cloning.
  24087. * @returns {*} Returns the deep cloned value.
  24088. * @see _.cloneWith
  24089. * @example
  24090. *
  24091. * function customizer(value) {
  24092. * if (_.isElement(value)) {
  24093. * return value.cloneNode(true);
  24094. * }
  24095. * }
  24096. *
  24097. * var el = _.cloneDeepWith(document.body, customizer);
  24098. *
  24099. * console.log(el === document.body);
  24100. * // => false
  24101. * console.log(el.nodeName);
  24102. * // => 'BODY'
  24103. * console.log(el.childNodes.length);
  24104. * // => 20
  24105. */
  24106. function cloneDeepWith(value, customizer) {
  24107. customizer = typeof customizer == 'function' ? customizer : undefined;
  24108. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  24109. }
  24110. /**
  24111. * Checks if `object` conforms to `source` by invoking the predicate
  24112. * properties of `source` with the corresponding property values of `object`.
  24113. *
  24114. * **Note:** This method is equivalent to `_.conforms` when `source` is
  24115. * partially applied.
  24116. *
  24117. * @static
  24118. * @memberOf _
  24119. * @since 4.14.0
  24120. * @category Lang
  24121. * @param {Object} object The object to inspect.
  24122. * @param {Object} source The object of property predicates to conform to.
  24123. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  24124. * @example
  24125. *
  24126. * var object = { 'a': 1, 'b': 2 };
  24127. *
  24128. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  24129. * // => true
  24130. *
  24131. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  24132. * // => false
  24133. */
  24134. function conformsTo(object, source) {
  24135. return source == null || baseConformsTo(object, source, keys(source));
  24136. }
  24137. /**
  24138. * Performs a
  24139. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24140. * comparison between two values to determine if they are equivalent.
  24141. *
  24142. * @static
  24143. * @memberOf _
  24144. * @since 4.0.0
  24145. * @category Lang
  24146. * @param {*} value The value to compare.
  24147. * @param {*} other The other value to compare.
  24148. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24149. * @example
  24150. *
  24151. * var object = { 'a': 1 };
  24152. * var other = { 'a': 1 };
  24153. *
  24154. * _.eq(object, object);
  24155. * // => true
  24156. *
  24157. * _.eq(object, other);
  24158. * // => false
  24159. *
  24160. * _.eq('a', 'a');
  24161. * // => true
  24162. *
  24163. * _.eq('a', Object('a'));
  24164. * // => false
  24165. *
  24166. * _.eq(NaN, NaN);
  24167. * // => true
  24168. */
  24169. function eq(value, other) {
  24170. return value === other || (value !== value && other !== other);
  24171. }
  24172. /**
  24173. * Checks if `value` is greater than `other`.
  24174. *
  24175. * @static
  24176. * @memberOf _
  24177. * @since 3.9.0
  24178. * @category Lang
  24179. * @param {*} value The value to compare.
  24180. * @param {*} other The other value to compare.
  24181. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  24182. * else `false`.
  24183. * @see _.lt
  24184. * @example
  24185. *
  24186. * _.gt(3, 1);
  24187. * // => true
  24188. *
  24189. * _.gt(3, 3);
  24190. * // => false
  24191. *
  24192. * _.gt(1, 3);
  24193. * // => false
  24194. */
  24195. var gt = createRelationalOperation(baseGt);
  24196. /**
  24197. * Checks if `value` is greater than or equal to `other`.
  24198. *
  24199. * @static
  24200. * @memberOf _
  24201. * @since 3.9.0
  24202. * @category Lang
  24203. * @param {*} value The value to compare.
  24204. * @param {*} other The other value to compare.
  24205. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  24206. * `other`, else `false`.
  24207. * @see _.lte
  24208. * @example
  24209. *
  24210. * _.gte(3, 1);
  24211. * // => true
  24212. *
  24213. * _.gte(3, 3);
  24214. * // => true
  24215. *
  24216. * _.gte(1, 3);
  24217. * // => false
  24218. */
  24219. var gte = createRelationalOperation(function(value, other) {
  24220. return value >= other;
  24221. });
  24222. /**
  24223. * Checks if `value` is likely an `arguments` object.
  24224. *
  24225. * @static
  24226. * @memberOf _
  24227. * @since 0.1.0
  24228. * @category Lang
  24229. * @param {*} value The value to check.
  24230. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  24231. * else `false`.
  24232. * @example
  24233. *
  24234. * _.isArguments(function() { return arguments; }());
  24235. * // => true
  24236. *
  24237. * _.isArguments([1, 2, 3]);
  24238. * // => false
  24239. */
  24240. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  24241. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  24242. !propertyIsEnumerable.call(value, 'callee');
  24243. };
  24244. /**
  24245. * Checks if `value` is classified as an `Array` object.
  24246. *
  24247. * @static
  24248. * @memberOf _
  24249. * @since 0.1.0
  24250. * @category Lang
  24251. * @param {*} value The value to check.
  24252. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  24253. * @example
  24254. *
  24255. * _.isArray([1, 2, 3]);
  24256. * // => true
  24257. *
  24258. * _.isArray(document.body.children);
  24259. * // => false
  24260. *
  24261. * _.isArray('abc');
  24262. * // => false
  24263. *
  24264. * _.isArray(_.noop);
  24265. * // => false
  24266. */
  24267. var isArray = Array.isArray;
  24268. /**
  24269. * Checks if `value` is classified as an `ArrayBuffer` object.
  24270. *
  24271. * @static
  24272. * @memberOf _
  24273. * @since 4.3.0
  24274. * @category Lang
  24275. * @param {*} value The value to check.
  24276. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  24277. * @example
  24278. *
  24279. * _.isArrayBuffer(new ArrayBuffer(2));
  24280. * // => true
  24281. *
  24282. * _.isArrayBuffer(new Array(2));
  24283. * // => false
  24284. */
  24285. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  24286. /**
  24287. * Checks if `value` is array-like. A value is considered array-like if it's
  24288. * not a function and has a `value.length` that's an integer greater than or
  24289. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  24290. *
  24291. * @static
  24292. * @memberOf _
  24293. * @since 4.0.0
  24294. * @category Lang
  24295. * @param {*} value The value to check.
  24296. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  24297. * @example
  24298. *
  24299. * _.isArrayLike([1, 2, 3]);
  24300. * // => true
  24301. *
  24302. * _.isArrayLike(document.body.children);
  24303. * // => true
  24304. *
  24305. * _.isArrayLike('abc');
  24306. * // => true
  24307. *
  24308. * _.isArrayLike(_.noop);
  24309. * // => false
  24310. */
  24311. function isArrayLike(value) {
  24312. return value != null && isLength(value.length) && !isFunction(value);
  24313. }
  24314. /**
  24315. * This method is like `_.isArrayLike` except that it also checks if `value`
  24316. * is an object.
  24317. *
  24318. * @static
  24319. * @memberOf _
  24320. * @since 4.0.0
  24321. * @category Lang
  24322. * @param {*} value The value to check.
  24323. * @returns {boolean} Returns `true` if `value` is an array-like object,
  24324. * else `false`.
  24325. * @example
  24326. *
  24327. * _.isArrayLikeObject([1, 2, 3]);
  24328. * // => true
  24329. *
  24330. * _.isArrayLikeObject(document.body.children);
  24331. * // => true
  24332. *
  24333. * _.isArrayLikeObject('abc');
  24334. * // => false
  24335. *
  24336. * _.isArrayLikeObject(_.noop);
  24337. * // => false
  24338. */
  24339. function isArrayLikeObject(value) {
  24340. return isObjectLike(value) && isArrayLike(value);
  24341. }
  24342. /**
  24343. * Checks if `value` is classified as a boolean primitive or object.
  24344. *
  24345. * @static
  24346. * @memberOf _
  24347. * @since 0.1.0
  24348. * @category Lang
  24349. * @param {*} value The value to check.
  24350. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  24351. * @example
  24352. *
  24353. * _.isBoolean(false);
  24354. * // => true
  24355. *
  24356. * _.isBoolean(null);
  24357. * // => false
  24358. */
  24359. function isBoolean(value) {
  24360. return value === true || value === false ||
  24361. (isObjectLike(value) && baseGetTag(value) == boolTag);
  24362. }
  24363. /**
  24364. * Checks if `value` is a buffer.
  24365. *
  24366. * @static
  24367. * @memberOf _
  24368. * @since 4.3.0
  24369. * @category Lang
  24370. * @param {*} value The value to check.
  24371. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  24372. * @example
  24373. *
  24374. * _.isBuffer(new Buffer(2));
  24375. * // => true
  24376. *
  24377. * _.isBuffer(new Uint8Array(2));
  24378. * // => false
  24379. */
  24380. var isBuffer = nativeIsBuffer || stubFalse;
  24381. /**
  24382. * Checks if `value` is classified as a `Date` object.
  24383. *
  24384. * @static
  24385. * @memberOf _
  24386. * @since 0.1.0
  24387. * @category Lang
  24388. * @param {*} value The value to check.
  24389. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  24390. * @example
  24391. *
  24392. * _.isDate(new Date);
  24393. * // => true
  24394. *
  24395. * _.isDate('Mon April 23 2012');
  24396. * // => false
  24397. */
  24398. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  24399. /**
  24400. * Checks if `value` is likely a DOM element.
  24401. *
  24402. * @static
  24403. * @memberOf _
  24404. * @since 0.1.0
  24405. * @category Lang
  24406. * @param {*} value The value to check.
  24407. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  24408. * @example
  24409. *
  24410. * _.isElement(document.body);
  24411. * // => true
  24412. *
  24413. * _.isElement('<body>');
  24414. * // => false
  24415. */
  24416. function isElement(value) {
  24417. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  24418. }
  24419. /**
  24420. * Checks if `value` is an empty object, collection, map, or set.
  24421. *
  24422. * Objects are considered empty if they have no own enumerable string keyed
  24423. * properties.
  24424. *
  24425. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  24426. * jQuery-like collections are considered empty if they have a `length` of `0`.
  24427. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  24428. *
  24429. * @static
  24430. * @memberOf _
  24431. * @since 0.1.0
  24432. * @category Lang
  24433. * @param {*} value The value to check.
  24434. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  24435. * @example
  24436. *
  24437. * _.isEmpty(null);
  24438. * // => true
  24439. *
  24440. * _.isEmpty(true);
  24441. * // => true
  24442. *
  24443. * _.isEmpty(1);
  24444. * // => true
  24445. *
  24446. * _.isEmpty([1, 2, 3]);
  24447. * // => false
  24448. *
  24449. * _.isEmpty({ 'a': 1 });
  24450. * // => false
  24451. */
  24452. function isEmpty(value) {
  24453. if (value == null) {
  24454. return true;
  24455. }
  24456. if (isArrayLike(value) &&
  24457. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  24458. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  24459. return !value.length;
  24460. }
  24461. var tag = getTag(value);
  24462. if (tag == mapTag || tag == setTag) {
  24463. return !value.size;
  24464. }
  24465. if (isPrototype(value)) {
  24466. return !baseKeys(value).length;
  24467. }
  24468. for (var key in value) {
  24469. if (hasOwnProperty.call(value, key)) {
  24470. return false;
  24471. }
  24472. }
  24473. return true;
  24474. }
  24475. /**
  24476. * Performs a deep comparison between two values to determine if they are
  24477. * equivalent.
  24478. *
  24479. * **Note:** This method supports comparing arrays, array buffers, booleans,
  24480. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  24481. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  24482. * by their own, not inherited, enumerable properties. Functions and DOM
  24483. * nodes are compared by strict equality, i.e. `===`.
  24484. *
  24485. * @static
  24486. * @memberOf _
  24487. * @since 0.1.0
  24488. * @category Lang
  24489. * @param {*} value The value to compare.
  24490. * @param {*} other The other value to compare.
  24491. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24492. * @example
  24493. *
  24494. * var object = { 'a': 1 };
  24495. * var other = { 'a': 1 };
  24496. *
  24497. * _.isEqual(object, other);
  24498. * // => true
  24499. *
  24500. * object === other;
  24501. * // => false
  24502. */
  24503. function isEqual(value, other) {
  24504. return baseIsEqual(value, other);
  24505. }
  24506. /**
  24507. * This method is like `_.isEqual` except that it accepts `customizer` which
  24508. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  24509. * are handled by the method instead. The `customizer` is invoked with up to
  24510. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  24511. *
  24512. * @static
  24513. * @memberOf _
  24514. * @since 4.0.0
  24515. * @category Lang
  24516. * @param {*} value The value to compare.
  24517. * @param {*} other The other value to compare.
  24518. * @param {Function} [customizer] The function to customize comparisons.
  24519. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24520. * @example
  24521. *
  24522. * function isGreeting(value) {
  24523. * return /^h(?:i|ello)$/.test(value);
  24524. * }
  24525. *
  24526. * function customizer(objValue, othValue) {
  24527. * if (isGreeting(objValue) && isGreeting(othValue)) {
  24528. * return true;
  24529. * }
  24530. * }
  24531. *
  24532. * var array = ['hello', 'goodbye'];
  24533. * var other = ['hi', 'goodbye'];
  24534. *
  24535. * _.isEqualWith(array, other, customizer);
  24536. * // => true
  24537. */
  24538. function isEqualWith(value, other, customizer) {
  24539. customizer = typeof customizer == 'function' ? customizer : undefined;
  24540. var result = customizer ? customizer(value, other) : undefined;
  24541. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  24542. }
  24543. /**
  24544. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  24545. * `SyntaxError`, `TypeError`, or `URIError` object.
  24546. *
  24547. * @static
  24548. * @memberOf _
  24549. * @since 3.0.0
  24550. * @category Lang
  24551. * @param {*} value The value to check.
  24552. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  24553. * @example
  24554. *
  24555. * _.isError(new Error);
  24556. * // => true
  24557. *
  24558. * _.isError(Error);
  24559. * // => false
  24560. */
  24561. function isError(value) {
  24562. if (!isObjectLike(value)) {
  24563. return false;
  24564. }
  24565. var tag = baseGetTag(value);
  24566. return tag == errorTag || tag == domExcTag ||
  24567. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  24568. }
  24569. /**
  24570. * Checks if `value` is a finite primitive number.
  24571. *
  24572. * **Note:** This method is based on
  24573. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  24574. *
  24575. * @static
  24576. * @memberOf _
  24577. * @since 0.1.0
  24578. * @category Lang
  24579. * @param {*} value The value to check.
  24580. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  24581. * @example
  24582. *
  24583. * _.isFinite(3);
  24584. * // => true
  24585. *
  24586. * _.isFinite(Number.MIN_VALUE);
  24587. * // => true
  24588. *
  24589. * _.isFinite(Infinity);
  24590. * // => false
  24591. *
  24592. * _.isFinite('3');
  24593. * // => false
  24594. */
  24595. function isFinite(value) {
  24596. return typeof value == 'number' && nativeIsFinite(value);
  24597. }
  24598. /**
  24599. * Checks if `value` is classified as a `Function` object.
  24600. *
  24601. * @static
  24602. * @memberOf _
  24603. * @since 0.1.0
  24604. * @category Lang
  24605. * @param {*} value The value to check.
  24606. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  24607. * @example
  24608. *
  24609. * _.isFunction(_);
  24610. * // => true
  24611. *
  24612. * _.isFunction(/abc/);
  24613. * // => false
  24614. */
  24615. function isFunction(value) {
  24616. if (!isObject(value)) {
  24617. return false;
  24618. }
  24619. // The use of `Object#toString` avoids issues with the `typeof` operator
  24620. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  24621. var tag = baseGetTag(value);
  24622. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  24623. }
  24624. /**
  24625. * Checks if `value` is an integer.
  24626. *
  24627. * **Note:** This method is based on
  24628. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  24629. *
  24630. * @static
  24631. * @memberOf _
  24632. * @since 4.0.0
  24633. * @category Lang
  24634. * @param {*} value The value to check.
  24635. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  24636. * @example
  24637. *
  24638. * _.isInteger(3);
  24639. * // => true
  24640. *
  24641. * _.isInteger(Number.MIN_VALUE);
  24642. * // => false
  24643. *
  24644. * _.isInteger(Infinity);
  24645. * // => false
  24646. *
  24647. * _.isInteger('3');
  24648. * // => false
  24649. */
  24650. function isInteger(value) {
  24651. return typeof value == 'number' && value == toInteger(value);
  24652. }
  24653. /**
  24654. * Checks if `value` is a valid array-like length.
  24655. *
  24656. * **Note:** This method is loosely based on
  24657. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  24658. *
  24659. * @static
  24660. * @memberOf _
  24661. * @since 4.0.0
  24662. * @category Lang
  24663. * @param {*} value The value to check.
  24664. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  24665. * @example
  24666. *
  24667. * _.isLength(3);
  24668. * // => true
  24669. *
  24670. * _.isLength(Number.MIN_VALUE);
  24671. * // => false
  24672. *
  24673. * _.isLength(Infinity);
  24674. * // => false
  24675. *
  24676. * _.isLength('3');
  24677. * // => false
  24678. */
  24679. function isLength(value) {
  24680. return typeof value == 'number' &&
  24681. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  24682. }
  24683. /**
  24684. * Checks if `value` is the
  24685. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  24686. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  24687. *
  24688. * @static
  24689. * @memberOf _
  24690. * @since 0.1.0
  24691. * @category Lang
  24692. * @param {*} value The value to check.
  24693. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  24694. * @example
  24695. *
  24696. * _.isObject({});
  24697. * // => true
  24698. *
  24699. * _.isObject([1, 2, 3]);
  24700. * // => true
  24701. *
  24702. * _.isObject(_.noop);
  24703. * // => true
  24704. *
  24705. * _.isObject(null);
  24706. * // => false
  24707. */
  24708. function isObject(value) {
  24709. var type = typeof value;
  24710. return value != null && (type == 'object' || type == 'function');
  24711. }
  24712. /**
  24713. * Checks if `value` is object-like. A value is object-like if it's not `null`
  24714. * and has a `typeof` result of "object".
  24715. *
  24716. * @static
  24717. * @memberOf _
  24718. * @since 4.0.0
  24719. * @category Lang
  24720. * @param {*} value The value to check.
  24721. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  24722. * @example
  24723. *
  24724. * _.isObjectLike({});
  24725. * // => true
  24726. *
  24727. * _.isObjectLike([1, 2, 3]);
  24728. * // => true
  24729. *
  24730. * _.isObjectLike(_.noop);
  24731. * // => false
  24732. *
  24733. * _.isObjectLike(null);
  24734. * // => false
  24735. */
  24736. function isObjectLike(value) {
  24737. return value != null && typeof value == 'object';
  24738. }
  24739. /**
  24740. * Checks if `value` is classified as a `Map` object.
  24741. *
  24742. * @static
  24743. * @memberOf _
  24744. * @since 4.3.0
  24745. * @category Lang
  24746. * @param {*} value The value to check.
  24747. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  24748. * @example
  24749. *
  24750. * _.isMap(new Map);
  24751. * // => true
  24752. *
  24753. * _.isMap(new WeakMap);
  24754. * // => false
  24755. */
  24756. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  24757. /**
  24758. * Performs a partial deep comparison between `object` and `source` to
  24759. * determine if `object` contains equivalent property values.
  24760. *
  24761. * **Note:** This method is equivalent to `_.matches` when `source` is
  24762. * partially applied.
  24763. *
  24764. * Partial comparisons will match empty array and empty object `source`
  24765. * values against any array or object value, respectively. See `_.isEqual`
  24766. * for a list of supported value comparisons.
  24767. *
  24768. * @static
  24769. * @memberOf _
  24770. * @since 3.0.0
  24771. * @category Lang
  24772. * @param {Object} object The object to inspect.
  24773. * @param {Object} source The object of property values to match.
  24774. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  24775. * @example
  24776. *
  24777. * var object = { 'a': 1, 'b': 2 };
  24778. *
  24779. * _.isMatch(object, { 'b': 2 });
  24780. * // => true
  24781. *
  24782. * _.isMatch(object, { 'b': 1 });
  24783. * // => false
  24784. */
  24785. function isMatch(object, source) {
  24786. return object === source || baseIsMatch(object, source, getMatchData(source));
  24787. }
  24788. /**
  24789. * This method is like `_.isMatch` except that it accepts `customizer` which
  24790. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  24791. * are handled by the method instead. The `customizer` is invoked with five
  24792. * arguments: (objValue, srcValue, index|key, object, source).
  24793. *
  24794. * @static
  24795. * @memberOf _
  24796. * @since 4.0.0
  24797. * @category Lang
  24798. * @param {Object} object The object to inspect.
  24799. * @param {Object} source The object of property values to match.
  24800. * @param {Function} [customizer] The function to customize comparisons.
  24801. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  24802. * @example
  24803. *
  24804. * function isGreeting(value) {
  24805. * return /^h(?:i|ello)$/.test(value);
  24806. * }
  24807. *
  24808. * function customizer(objValue, srcValue) {
  24809. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  24810. * return true;
  24811. * }
  24812. * }
  24813. *
  24814. * var object = { 'greeting': 'hello' };
  24815. * var source = { 'greeting': 'hi' };
  24816. *
  24817. * _.isMatchWith(object, source, customizer);
  24818. * // => true
  24819. */
  24820. function isMatchWith(object, source, customizer) {
  24821. customizer = typeof customizer == 'function' ? customizer : undefined;
  24822. return baseIsMatch(object, source, getMatchData(source), customizer);
  24823. }
  24824. /**
  24825. * Checks if `value` is `NaN`.
  24826. *
  24827. * **Note:** This method is based on
  24828. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  24829. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  24830. * `undefined` and other non-number values.
  24831. *
  24832. * @static
  24833. * @memberOf _
  24834. * @since 0.1.0
  24835. * @category Lang
  24836. * @param {*} value The value to check.
  24837. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  24838. * @example
  24839. *
  24840. * _.isNaN(NaN);
  24841. * // => true
  24842. *
  24843. * _.isNaN(new Number(NaN));
  24844. * // => true
  24845. *
  24846. * isNaN(undefined);
  24847. * // => true
  24848. *
  24849. * _.isNaN(undefined);
  24850. * // => false
  24851. */
  24852. function isNaN(value) {
  24853. // An `NaN` primitive is the only value that is not equal to itself.
  24854. // Perform the `toStringTag` check first to avoid errors with some
  24855. // ActiveX objects in IE.
  24856. return isNumber(value) && value != +value;
  24857. }
  24858. /**
  24859. * Checks if `value` is a pristine native function.
  24860. *
  24861. * **Note:** This method can't reliably detect native functions in the presence
  24862. * of the core-js package because core-js circumvents this kind of detection.
  24863. * Despite multiple requests, the core-js maintainer has made it clear: any
  24864. * attempt to fix the detection will be obstructed. As a result, we're left
  24865. * with little choice but to throw an error. Unfortunately, this also affects
  24866. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  24867. * which rely on core-js.
  24868. *
  24869. * @static
  24870. * @memberOf _
  24871. * @since 3.0.0
  24872. * @category Lang
  24873. * @param {*} value The value to check.
  24874. * @returns {boolean} Returns `true` if `value` is a native function,
  24875. * else `false`.
  24876. * @example
  24877. *
  24878. * _.isNative(Array.prototype.push);
  24879. * // => true
  24880. *
  24881. * _.isNative(_);
  24882. * // => false
  24883. */
  24884. function isNative(value) {
  24885. if (isMaskable(value)) {
  24886. throw new Error(CORE_ERROR_TEXT);
  24887. }
  24888. return baseIsNative(value);
  24889. }
  24890. /**
  24891. * Checks if `value` is `null`.
  24892. *
  24893. * @static
  24894. * @memberOf _
  24895. * @since 0.1.0
  24896. * @category Lang
  24897. * @param {*} value The value to check.
  24898. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  24899. * @example
  24900. *
  24901. * _.isNull(null);
  24902. * // => true
  24903. *
  24904. * _.isNull(void 0);
  24905. * // => false
  24906. */
  24907. function isNull(value) {
  24908. return value === null;
  24909. }
  24910. /**
  24911. * Checks if `value` is `null` or `undefined`.
  24912. *
  24913. * @static
  24914. * @memberOf _
  24915. * @since 4.0.0
  24916. * @category Lang
  24917. * @param {*} value The value to check.
  24918. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  24919. * @example
  24920. *
  24921. * _.isNil(null);
  24922. * // => true
  24923. *
  24924. * _.isNil(void 0);
  24925. * // => true
  24926. *
  24927. * _.isNil(NaN);
  24928. * // => false
  24929. */
  24930. function isNil(value) {
  24931. return value == null;
  24932. }
  24933. /**
  24934. * Checks if `value` is classified as a `Number` primitive or object.
  24935. *
  24936. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  24937. * classified as numbers, use the `_.isFinite` method.
  24938. *
  24939. * @static
  24940. * @memberOf _
  24941. * @since 0.1.0
  24942. * @category Lang
  24943. * @param {*} value The value to check.
  24944. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  24945. * @example
  24946. *
  24947. * _.isNumber(3);
  24948. * // => true
  24949. *
  24950. * _.isNumber(Number.MIN_VALUE);
  24951. * // => true
  24952. *
  24953. * _.isNumber(Infinity);
  24954. * // => true
  24955. *
  24956. * _.isNumber('3');
  24957. * // => false
  24958. */
  24959. function isNumber(value) {
  24960. return typeof value == 'number' ||
  24961. (isObjectLike(value) && baseGetTag(value) == numberTag);
  24962. }
  24963. /**
  24964. * Checks if `value` is a plain object, that is, an object created by the
  24965. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  24966. *
  24967. * @static
  24968. * @memberOf _
  24969. * @since 0.8.0
  24970. * @category Lang
  24971. * @param {*} value The value to check.
  24972. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  24973. * @example
  24974. *
  24975. * function Foo() {
  24976. * this.a = 1;
  24977. * }
  24978. *
  24979. * _.isPlainObject(new Foo);
  24980. * // => false
  24981. *
  24982. * _.isPlainObject([1, 2, 3]);
  24983. * // => false
  24984. *
  24985. * _.isPlainObject({ 'x': 0, 'y': 0 });
  24986. * // => true
  24987. *
  24988. * _.isPlainObject(Object.create(null));
  24989. * // => true
  24990. */
  24991. function isPlainObject(value) {
  24992. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  24993. return false;
  24994. }
  24995. var proto = getPrototype(value);
  24996. if (proto === null) {
  24997. return true;
  24998. }
  24999. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  25000. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  25001. funcToString.call(Ctor) == objectCtorString;
  25002. }
  25003. /**
  25004. * Checks if `value` is classified as a `RegExp` object.
  25005. *
  25006. * @static
  25007. * @memberOf _
  25008. * @since 0.1.0
  25009. * @category Lang
  25010. * @param {*} value The value to check.
  25011. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  25012. * @example
  25013. *
  25014. * _.isRegExp(/abc/);
  25015. * // => true
  25016. *
  25017. * _.isRegExp('/abc/');
  25018. * // => false
  25019. */
  25020. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  25021. /**
  25022. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  25023. * double precision number which isn't the result of a rounded unsafe integer.
  25024. *
  25025. * **Note:** This method is based on
  25026. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  25027. *
  25028. * @static
  25029. * @memberOf _
  25030. * @since 4.0.0
  25031. * @category Lang
  25032. * @param {*} value The value to check.
  25033. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  25034. * @example
  25035. *
  25036. * _.isSafeInteger(3);
  25037. * // => true
  25038. *
  25039. * _.isSafeInteger(Number.MIN_VALUE);
  25040. * // => false
  25041. *
  25042. * _.isSafeInteger(Infinity);
  25043. * // => false
  25044. *
  25045. * _.isSafeInteger('3');
  25046. * // => false
  25047. */
  25048. function isSafeInteger(value) {
  25049. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  25050. }
  25051. /**
  25052. * Checks if `value` is classified as a `Set` object.
  25053. *
  25054. * @static
  25055. * @memberOf _
  25056. * @since 4.3.0
  25057. * @category Lang
  25058. * @param {*} value The value to check.
  25059. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  25060. * @example
  25061. *
  25062. * _.isSet(new Set);
  25063. * // => true
  25064. *
  25065. * _.isSet(new WeakSet);
  25066. * // => false
  25067. */
  25068. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  25069. /**
  25070. * Checks if `value` is classified as a `String` primitive or object.
  25071. *
  25072. * @static
  25073. * @since 0.1.0
  25074. * @memberOf _
  25075. * @category Lang
  25076. * @param {*} value The value to check.
  25077. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  25078. * @example
  25079. *
  25080. * _.isString('abc');
  25081. * // => true
  25082. *
  25083. * _.isString(1);
  25084. * // => false
  25085. */
  25086. function isString(value) {
  25087. return typeof value == 'string' ||
  25088. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  25089. }
  25090. /**
  25091. * Checks if `value` is classified as a `Symbol` primitive or object.
  25092. *
  25093. * @static
  25094. * @memberOf _
  25095. * @since 4.0.0
  25096. * @category Lang
  25097. * @param {*} value The value to check.
  25098. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  25099. * @example
  25100. *
  25101. * _.isSymbol(Symbol.iterator);
  25102. * // => true
  25103. *
  25104. * _.isSymbol('abc');
  25105. * // => false
  25106. */
  25107. function isSymbol(value) {
  25108. return typeof value == 'symbol' ||
  25109. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  25110. }
  25111. /**
  25112. * Checks if `value` is classified as a typed array.
  25113. *
  25114. * @static
  25115. * @memberOf _
  25116. * @since 3.0.0
  25117. * @category Lang
  25118. * @param {*} value The value to check.
  25119. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  25120. * @example
  25121. *
  25122. * _.isTypedArray(new Uint8Array);
  25123. * // => true
  25124. *
  25125. * _.isTypedArray([]);
  25126. * // => false
  25127. */
  25128. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  25129. /**
  25130. * Checks if `value` is `undefined`.
  25131. *
  25132. * @static
  25133. * @since 0.1.0
  25134. * @memberOf _
  25135. * @category Lang
  25136. * @param {*} value The value to check.
  25137. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  25138. * @example
  25139. *
  25140. * _.isUndefined(void 0);
  25141. * // => true
  25142. *
  25143. * _.isUndefined(null);
  25144. * // => false
  25145. */
  25146. function isUndefined(value) {
  25147. return value === undefined;
  25148. }
  25149. /**
  25150. * Checks if `value` is classified as a `WeakMap` object.
  25151. *
  25152. * @static
  25153. * @memberOf _
  25154. * @since 4.3.0
  25155. * @category Lang
  25156. * @param {*} value The value to check.
  25157. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  25158. * @example
  25159. *
  25160. * _.isWeakMap(new WeakMap);
  25161. * // => true
  25162. *
  25163. * _.isWeakMap(new Map);
  25164. * // => false
  25165. */
  25166. function isWeakMap(value) {
  25167. return isObjectLike(value) && getTag(value) == weakMapTag;
  25168. }
  25169. /**
  25170. * Checks if `value` is classified as a `WeakSet` object.
  25171. *
  25172. * @static
  25173. * @memberOf _
  25174. * @since 4.3.0
  25175. * @category Lang
  25176. * @param {*} value The value to check.
  25177. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  25178. * @example
  25179. *
  25180. * _.isWeakSet(new WeakSet);
  25181. * // => true
  25182. *
  25183. * _.isWeakSet(new Set);
  25184. * // => false
  25185. */
  25186. function isWeakSet(value) {
  25187. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  25188. }
  25189. /**
  25190. * Checks if `value` is less than `other`.
  25191. *
  25192. * @static
  25193. * @memberOf _
  25194. * @since 3.9.0
  25195. * @category Lang
  25196. * @param {*} value The value to compare.
  25197. * @param {*} other The other value to compare.
  25198. * @returns {boolean} Returns `true` if `value` is less than `other`,
  25199. * else `false`.
  25200. * @see _.gt
  25201. * @example
  25202. *
  25203. * _.lt(1, 3);
  25204. * // => true
  25205. *
  25206. * _.lt(3, 3);
  25207. * // => false
  25208. *
  25209. * _.lt(3, 1);
  25210. * // => false
  25211. */
  25212. var lt = createRelationalOperation(baseLt);
  25213. /**
  25214. * Checks if `value` is less than or equal to `other`.
  25215. *
  25216. * @static
  25217. * @memberOf _
  25218. * @since 3.9.0
  25219. * @category Lang
  25220. * @param {*} value The value to compare.
  25221. * @param {*} other The other value to compare.
  25222. * @returns {boolean} Returns `true` if `value` is less than or equal to
  25223. * `other`, else `false`.
  25224. * @see _.gte
  25225. * @example
  25226. *
  25227. * _.lte(1, 3);
  25228. * // => true
  25229. *
  25230. * _.lte(3, 3);
  25231. * // => true
  25232. *
  25233. * _.lte(3, 1);
  25234. * // => false
  25235. */
  25236. var lte = createRelationalOperation(function(value, other) {
  25237. return value <= other;
  25238. });
  25239. /**
  25240. * Converts `value` to an array.
  25241. *
  25242. * @static
  25243. * @since 0.1.0
  25244. * @memberOf _
  25245. * @category Lang
  25246. * @param {*} value The value to convert.
  25247. * @returns {Array} Returns the converted array.
  25248. * @example
  25249. *
  25250. * _.toArray({ 'a': 1, 'b': 2 });
  25251. * // => [1, 2]
  25252. *
  25253. * _.toArray('abc');
  25254. * // => ['a', 'b', 'c']
  25255. *
  25256. * _.toArray(1);
  25257. * // => []
  25258. *
  25259. * _.toArray(null);
  25260. * // => []
  25261. */
  25262. function toArray(value) {
  25263. if (!value) {
  25264. return [];
  25265. }
  25266. if (isArrayLike(value)) {
  25267. return isString(value) ? stringToArray(value) : copyArray(value);
  25268. }
  25269. if (symIterator && value[symIterator]) {
  25270. return iteratorToArray(value[symIterator]());
  25271. }
  25272. var tag = getTag(value),
  25273. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  25274. return func(value);
  25275. }
  25276. /**
  25277. * Converts `value` to a finite number.
  25278. *
  25279. * @static
  25280. * @memberOf _
  25281. * @since 4.12.0
  25282. * @category Lang
  25283. * @param {*} value The value to convert.
  25284. * @returns {number} Returns the converted number.
  25285. * @example
  25286. *
  25287. * _.toFinite(3.2);
  25288. * // => 3.2
  25289. *
  25290. * _.toFinite(Number.MIN_VALUE);
  25291. * // => 5e-324
  25292. *
  25293. * _.toFinite(Infinity);
  25294. * // => 1.7976931348623157e+308
  25295. *
  25296. * _.toFinite('3.2');
  25297. * // => 3.2
  25298. */
  25299. function toFinite(value) {
  25300. if (!value) {
  25301. return value === 0 ? value : 0;
  25302. }
  25303. value = toNumber(value);
  25304. if (value === INFINITY || value === -INFINITY) {
  25305. var sign = (value < 0 ? -1 : 1);
  25306. return sign * MAX_INTEGER;
  25307. }
  25308. return value === value ? value : 0;
  25309. }
  25310. /**
  25311. * Converts `value` to an integer.
  25312. *
  25313. * **Note:** This method is loosely based on
  25314. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  25315. *
  25316. * @static
  25317. * @memberOf _
  25318. * @since 4.0.0
  25319. * @category Lang
  25320. * @param {*} value The value to convert.
  25321. * @returns {number} Returns the converted integer.
  25322. * @example
  25323. *
  25324. * _.toInteger(3.2);
  25325. * // => 3
  25326. *
  25327. * _.toInteger(Number.MIN_VALUE);
  25328. * // => 0
  25329. *
  25330. * _.toInteger(Infinity);
  25331. * // => 1.7976931348623157e+308
  25332. *
  25333. * _.toInteger('3.2');
  25334. * // => 3
  25335. */
  25336. function toInteger(value) {
  25337. var result = toFinite(value),
  25338. remainder = result % 1;
  25339. return result === result ? (remainder ? result - remainder : result) : 0;
  25340. }
  25341. /**
  25342. * Converts `value` to an integer suitable for use as the length of an
  25343. * array-like object.
  25344. *
  25345. * **Note:** This method is based on
  25346. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  25347. *
  25348. * @static
  25349. * @memberOf _
  25350. * @since 4.0.0
  25351. * @category Lang
  25352. * @param {*} value The value to convert.
  25353. * @returns {number} Returns the converted integer.
  25354. * @example
  25355. *
  25356. * _.toLength(3.2);
  25357. * // => 3
  25358. *
  25359. * _.toLength(Number.MIN_VALUE);
  25360. * // => 0
  25361. *
  25362. * _.toLength(Infinity);
  25363. * // => 4294967295
  25364. *
  25365. * _.toLength('3.2');
  25366. * // => 3
  25367. */
  25368. function toLength(value) {
  25369. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  25370. }
  25371. /**
  25372. * Converts `value` to a number.
  25373. *
  25374. * @static
  25375. * @memberOf _
  25376. * @since 4.0.0
  25377. * @category Lang
  25378. * @param {*} value The value to process.
  25379. * @returns {number} Returns the number.
  25380. * @example
  25381. *
  25382. * _.toNumber(3.2);
  25383. * // => 3.2
  25384. *
  25385. * _.toNumber(Number.MIN_VALUE);
  25386. * // => 5e-324
  25387. *
  25388. * _.toNumber(Infinity);
  25389. * // => Infinity
  25390. *
  25391. * _.toNumber('3.2');
  25392. * // => 3.2
  25393. */
  25394. function toNumber(value) {
  25395. if (typeof value == 'number') {
  25396. return value;
  25397. }
  25398. if (isSymbol(value)) {
  25399. return NAN;
  25400. }
  25401. if (isObject(value)) {
  25402. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  25403. value = isObject(other) ? (other + '') : other;
  25404. }
  25405. if (typeof value != 'string') {
  25406. return value === 0 ? value : +value;
  25407. }
  25408. value = value.replace(reTrim, '');
  25409. var isBinary = reIsBinary.test(value);
  25410. return (isBinary || reIsOctal.test(value))
  25411. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  25412. : (reIsBadHex.test(value) ? NAN : +value);
  25413. }
  25414. /**
  25415. * Converts `value` to a plain object flattening inherited enumerable string
  25416. * keyed properties of `value` to own properties of the plain object.
  25417. *
  25418. * @static
  25419. * @memberOf _
  25420. * @since 3.0.0
  25421. * @category Lang
  25422. * @param {*} value The value to convert.
  25423. * @returns {Object} Returns the converted plain object.
  25424. * @example
  25425. *
  25426. * function Foo() {
  25427. * this.b = 2;
  25428. * }
  25429. *
  25430. * Foo.prototype.c = 3;
  25431. *
  25432. * _.assign({ 'a': 1 }, new Foo);
  25433. * // => { 'a': 1, 'b': 2 }
  25434. *
  25435. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  25436. * // => { 'a': 1, 'b': 2, 'c': 3 }
  25437. */
  25438. function toPlainObject(value) {
  25439. return copyObject(value, keysIn(value));
  25440. }
  25441. /**
  25442. * Converts `value` to a safe integer. A safe integer can be compared and
  25443. * represented correctly.
  25444. *
  25445. * @static
  25446. * @memberOf _
  25447. * @since 4.0.0
  25448. * @category Lang
  25449. * @param {*} value The value to convert.
  25450. * @returns {number} Returns the converted integer.
  25451. * @example
  25452. *
  25453. * _.toSafeInteger(3.2);
  25454. * // => 3
  25455. *
  25456. * _.toSafeInteger(Number.MIN_VALUE);
  25457. * // => 0
  25458. *
  25459. * _.toSafeInteger(Infinity);
  25460. * // => 9007199254740991
  25461. *
  25462. * _.toSafeInteger('3.2');
  25463. * // => 3
  25464. */
  25465. function toSafeInteger(value) {
  25466. return value
  25467. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  25468. : (value === 0 ? value : 0);
  25469. }
  25470. /**
  25471. * Converts `value` to a string. An empty string is returned for `null`
  25472. * and `undefined` values. The sign of `-0` is preserved.
  25473. *
  25474. * @static
  25475. * @memberOf _
  25476. * @since 4.0.0
  25477. * @category Lang
  25478. * @param {*} value The value to convert.
  25479. * @returns {string} Returns the converted string.
  25480. * @example
  25481. *
  25482. * _.toString(null);
  25483. * // => ''
  25484. *
  25485. * _.toString(-0);
  25486. * // => '-0'
  25487. *
  25488. * _.toString([1, 2, 3]);
  25489. * // => '1,2,3'
  25490. */
  25491. function toString(value) {
  25492. return value == null ? '' : baseToString(value);
  25493. }
  25494. /*------------------------------------------------------------------------*/
  25495. /**
  25496. * Assigns own enumerable string keyed properties of source objects to the
  25497. * destination object. Source objects are applied from left to right.
  25498. * Subsequent sources overwrite property assignments of previous sources.
  25499. *
  25500. * **Note:** This method mutates `object` and is loosely based on
  25501. * [`Object.assign`](https://mdn.io/Object/assign).
  25502. *
  25503. * @static
  25504. * @memberOf _
  25505. * @since 0.10.0
  25506. * @category Object
  25507. * @param {Object} object The destination object.
  25508. * @param {...Object} [sources] The source objects.
  25509. * @returns {Object} Returns `object`.
  25510. * @see _.assignIn
  25511. * @example
  25512. *
  25513. * function Foo() {
  25514. * this.a = 1;
  25515. * }
  25516. *
  25517. * function Bar() {
  25518. * this.c = 3;
  25519. * }
  25520. *
  25521. * Foo.prototype.b = 2;
  25522. * Bar.prototype.d = 4;
  25523. *
  25524. * _.assign({ 'a': 0 }, new Foo, new Bar);
  25525. * // => { 'a': 1, 'c': 3 }
  25526. */
  25527. var assign = createAssigner(function(object, source) {
  25528. if (isPrototype(source) || isArrayLike(source)) {
  25529. copyObject(source, keys(source), object);
  25530. return;
  25531. }
  25532. for (var key in source) {
  25533. if (hasOwnProperty.call(source, key)) {
  25534. assignValue(object, key, source[key]);
  25535. }
  25536. }
  25537. });
  25538. /**
  25539. * This method is like `_.assign` except that it iterates over own and
  25540. * inherited source properties.
  25541. *
  25542. * **Note:** This method mutates `object`.
  25543. *
  25544. * @static
  25545. * @memberOf _
  25546. * @since 4.0.0
  25547. * @alias extend
  25548. * @category Object
  25549. * @param {Object} object The destination object.
  25550. * @param {...Object} [sources] The source objects.
  25551. * @returns {Object} Returns `object`.
  25552. * @see _.assign
  25553. * @example
  25554. *
  25555. * function Foo() {
  25556. * this.a = 1;
  25557. * }
  25558. *
  25559. * function Bar() {
  25560. * this.c = 3;
  25561. * }
  25562. *
  25563. * Foo.prototype.b = 2;
  25564. * Bar.prototype.d = 4;
  25565. *
  25566. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  25567. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  25568. */
  25569. var assignIn = createAssigner(function(object, source) {
  25570. copyObject(source, keysIn(source), object);
  25571. });
  25572. /**
  25573. * This method is like `_.assignIn` except that it accepts `customizer`
  25574. * which is invoked to produce the assigned values. If `customizer` returns
  25575. * `undefined`, assignment is handled by the method instead. The `customizer`
  25576. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  25577. *
  25578. * **Note:** This method mutates `object`.
  25579. *
  25580. * @static
  25581. * @memberOf _
  25582. * @since 4.0.0
  25583. * @alias extendWith
  25584. * @category Object
  25585. * @param {Object} object The destination object.
  25586. * @param {...Object} sources The source objects.
  25587. * @param {Function} [customizer] The function to customize assigned values.
  25588. * @returns {Object} Returns `object`.
  25589. * @see _.assignWith
  25590. * @example
  25591. *
  25592. * function customizer(objValue, srcValue) {
  25593. * return _.isUndefined(objValue) ? srcValue : objValue;
  25594. * }
  25595. *
  25596. * var defaults = _.partialRight(_.assignInWith, customizer);
  25597. *
  25598. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  25599. * // => { 'a': 1, 'b': 2 }
  25600. */
  25601. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  25602. copyObject(source, keysIn(source), object, customizer);
  25603. });
  25604. /**
  25605. * This method is like `_.assign` except that it accepts `customizer`
  25606. * which is invoked to produce the assigned values. If `customizer` returns
  25607. * `undefined`, assignment is handled by the method instead. The `customizer`
  25608. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  25609. *
  25610. * **Note:** This method mutates `object`.
  25611. *
  25612. * @static
  25613. * @memberOf _
  25614. * @since 4.0.0
  25615. * @category Object
  25616. * @param {Object} object The destination object.
  25617. * @param {...Object} sources The source objects.
  25618. * @param {Function} [customizer] The function to customize assigned values.
  25619. * @returns {Object} Returns `object`.
  25620. * @see _.assignInWith
  25621. * @example
  25622. *
  25623. * function customizer(objValue, srcValue) {
  25624. * return _.isUndefined(objValue) ? srcValue : objValue;
  25625. * }
  25626. *
  25627. * var defaults = _.partialRight(_.assignWith, customizer);
  25628. *
  25629. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  25630. * // => { 'a': 1, 'b': 2 }
  25631. */
  25632. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  25633. copyObject(source, keys(source), object, customizer);
  25634. });
  25635. /**
  25636. * Creates an array of values corresponding to `paths` of `object`.
  25637. *
  25638. * @static
  25639. * @memberOf _
  25640. * @since 1.0.0
  25641. * @category Object
  25642. * @param {Object} object The object to iterate over.
  25643. * @param {...(string|string[])} [paths] The property paths to pick.
  25644. * @returns {Array} Returns the picked values.
  25645. * @example
  25646. *
  25647. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  25648. *
  25649. * _.at(object, ['a[0].b.c', 'a[1]']);
  25650. * // => [3, 4]
  25651. */
  25652. var at = flatRest(baseAt);
  25653. /**
  25654. * Creates an object that inherits from the `prototype` object. If a
  25655. * `properties` object is given, its own enumerable string keyed properties
  25656. * are assigned to the created object.
  25657. *
  25658. * @static
  25659. * @memberOf _
  25660. * @since 2.3.0
  25661. * @category Object
  25662. * @param {Object} prototype The object to inherit from.
  25663. * @param {Object} [properties] The properties to assign to the object.
  25664. * @returns {Object} Returns the new object.
  25665. * @example
  25666. *
  25667. * function Shape() {
  25668. * this.x = 0;
  25669. * this.y = 0;
  25670. * }
  25671. *
  25672. * function Circle() {
  25673. * Shape.call(this);
  25674. * }
  25675. *
  25676. * Circle.prototype = _.create(Shape.prototype, {
  25677. * 'constructor': Circle
  25678. * });
  25679. *
  25680. * var circle = new Circle;
  25681. * circle instanceof Circle;
  25682. * // => true
  25683. *
  25684. * circle instanceof Shape;
  25685. * // => true
  25686. */
  25687. function create(prototype, properties) {
  25688. var result = baseCreate(prototype);
  25689. return properties == null ? result : baseAssign(result, properties);
  25690. }
  25691. /**
  25692. * Assigns own and inherited enumerable string keyed properties of source
  25693. * objects to the destination object for all destination properties that
  25694. * resolve to `undefined`. Source objects are applied from left to right.
  25695. * Once a property is set, additional values of the same property are ignored.
  25696. *
  25697. * **Note:** This method mutates `object`.
  25698. *
  25699. * @static
  25700. * @since 0.1.0
  25701. * @memberOf _
  25702. * @category Object
  25703. * @param {Object} object The destination object.
  25704. * @param {...Object} [sources] The source objects.
  25705. * @returns {Object} Returns `object`.
  25706. * @see _.defaultsDeep
  25707. * @example
  25708. *
  25709. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  25710. * // => { 'a': 1, 'b': 2 }
  25711. */
  25712. var defaults = baseRest(function(object, sources) {
  25713. object = Object(object);
  25714. var index = -1;
  25715. var length = sources.length;
  25716. var guard = length > 2 ? sources[2] : undefined;
  25717. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  25718. length = 1;
  25719. }
  25720. while (++index < length) {
  25721. var source = sources[index];
  25722. var props = keysIn(source);
  25723. var propsIndex = -1;
  25724. var propsLength = props.length;
  25725. while (++propsIndex < propsLength) {
  25726. var key = props[propsIndex];
  25727. var value = object[key];
  25728. if (value === undefined ||
  25729. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  25730. object[key] = source[key];
  25731. }
  25732. }
  25733. }
  25734. return object;
  25735. });
  25736. /**
  25737. * This method is like `_.defaults` except that it recursively assigns
  25738. * default properties.
  25739. *
  25740. * **Note:** This method mutates `object`.
  25741. *
  25742. * @static
  25743. * @memberOf _
  25744. * @since 3.10.0
  25745. * @category Object
  25746. * @param {Object} object The destination object.
  25747. * @param {...Object} [sources] The source objects.
  25748. * @returns {Object} Returns `object`.
  25749. * @see _.defaults
  25750. * @example
  25751. *
  25752. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  25753. * // => { 'a': { 'b': 2, 'c': 3 } }
  25754. */
  25755. var defaultsDeep = baseRest(function(args) {
  25756. args.push(undefined, customDefaultsMerge);
  25757. return apply(mergeWith, undefined, args);
  25758. });
  25759. /**
  25760. * This method is like `_.find` except that it returns the key of the first
  25761. * element `predicate` returns truthy for instead of the element itself.
  25762. *
  25763. * @static
  25764. * @memberOf _
  25765. * @since 1.1.0
  25766. * @category Object
  25767. * @param {Object} object The object to inspect.
  25768. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25769. * @returns {string|undefined} Returns the key of the matched element,
  25770. * else `undefined`.
  25771. * @example
  25772. *
  25773. * var users = {
  25774. * 'barney': { 'age': 36, 'active': true },
  25775. * 'fred': { 'age': 40, 'active': false },
  25776. * 'pebbles': { 'age': 1, 'active': true }
  25777. * };
  25778. *
  25779. * _.findKey(users, function(o) { return o.age < 40; });
  25780. * // => 'barney' (iteration order is not guaranteed)
  25781. *
  25782. * // The `_.matches` iteratee shorthand.
  25783. * _.findKey(users, { 'age': 1, 'active': true });
  25784. * // => 'pebbles'
  25785. *
  25786. * // The `_.matchesProperty` iteratee shorthand.
  25787. * _.findKey(users, ['active', false]);
  25788. * // => 'fred'
  25789. *
  25790. * // The `_.property` iteratee shorthand.
  25791. * _.findKey(users, 'active');
  25792. * // => 'barney'
  25793. */
  25794. function findKey(object, predicate) {
  25795. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  25796. }
  25797. /**
  25798. * This method is like `_.findKey` except that it iterates over elements of
  25799. * a collection in the opposite order.
  25800. *
  25801. * @static
  25802. * @memberOf _
  25803. * @since 2.0.0
  25804. * @category Object
  25805. * @param {Object} object The object to inspect.
  25806. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25807. * @returns {string|undefined} Returns the key of the matched element,
  25808. * else `undefined`.
  25809. * @example
  25810. *
  25811. * var users = {
  25812. * 'barney': { 'age': 36, 'active': true },
  25813. * 'fred': { 'age': 40, 'active': false },
  25814. * 'pebbles': { 'age': 1, 'active': true }
  25815. * };
  25816. *
  25817. * _.findLastKey(users, function(o) { return o.age < 40; });
  25818. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  25819. *
  25820. * // The `_.matches` iteratee shorthand.
  25821. * _.findLastKey(users, { 'age': 36, 'active': true });
  25822. * // => 'barney'
  25823. *
  25824. * // The `_.matchesProperty` iteratee shorthand.
  25825. * _.findLastKey(users, ['active', false]);
  25826. * // => 'fred'
  25827. *
  25828. * // The `_.property` iteratee shorthand.
  25829. * _.findLastKey(users, 'active');
  25830. * // => 'pebbles'
  25831. */
  25832. function findLastKey(object, predicate) {
  25833. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  25834. }
  25835. /**
  25836. * Iterates over own and inherited enumerable string keyed properties of an
  25837. * object and invokes `iteratee` for each property. The iteratee is invoked
  25838. * with three arguments: (value, key, object). Iteratee functions may exit
  25839. * iteration early by explicitly returning `false`.
  25840. *
  25841. * @static
  25842. * @memberOf _
  25843. * @since 0.3.0
  25844. * @category Object
  25845. * @param {Object} object The object to iterate over.
  25846. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25847. * @returns {Object} Returns `object`.
  25848. * @see _.forInRight
  25849. * @example
  25850. *
  25851. * function Foo() {
  25852. * this.a = 1;
  25853. * this.b = 2;
  25854. * }
  25855. *
  25856. * Foo.prototype.c = 3;
  25857. *
  25858. * _.forIn(new Foo, function(value, key) {
  25859. * console.log(key);
  25860. * });
  25861. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  25862. */
  25863. function forIn(object, iteratee) {
  25864. return object == null
  25865. ? object
  25866. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  25867. }
  25868. /**
  25869. * This method is like `_.forIn` except that it iterates over properties of
  25870. * `object` in the opposite order.
  25871. *
  25872. * @static
  25873. * @memberOf _
  25874. * @since 2.0.0
  25875. * @category Object
  25876. * @param {Object} object The object to iterate over.
  25877. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25878. * @returns {Object} Returns `object`.
  25879. * @see _.forIn
  25880. * @example
  25881. *
  25882. * function Foo() {
  25883. * this.a = 1;
  25884. * this.b = 2;
  25885. * }
  25886. *
  25887. * Foo.prototype.c = 3;
  25888. *
  25889. * _.forInRight(new Foo, function(value, key) {
  25890. * console.log(key);
  25891. * });
  25892. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  25893. */
  25894. function forInRight(object, iteratee) {
  25895. return object == null
  25896. ? object
  25897. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  25898. }
  25899. /**
  25900. * Iterates over own enumerable string keyed properties of an object and
  25901. * invokes `iteratee` for each property. The iteratee is invoked with three
  25902. * arguments: (value, key, object). Iteratee functions may exit iteration
  25903. * early by explicitly returning `false`.
  25904. *
  25905. * @static
  25906. * @memberOf _
  25907. * @since 0.3.0
  25908. * @category Object
  25909. * @param {Object} object The object to iterate over.
  25910. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25911. * @returns {Object} Returns `object`.
  25912. * @see _.forOwnRight
  25913. * @example
  25914. *
  25915. * function Foo() {
  25916. * this.a = 1;
  25917. * this.b = 2;
  25918. * }
  25919. *
  25920. * Foo.prototype.c = 3;
  25921. *
  25922. * _.forOwn(new Foo, function(value, key) {
  25923. * console.log(key);
  25924. * });
  25925. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  25926. */
  25927. function forOwn(object, iteratee) {
  25928. return object && baseForOwn(object, getIteratee(iteratee, 3));
  25929. }
  25930. /**
  25931. * This method is like `_.forOwn` except that it iterates over properties of
  25932. * `object` in the opposite order.
  25933. *
  25934. * @static
  25935. * @memberOf _
  25936. * @since 2.0.0
  25937. * @category Object
  25938. * @param {Object} object The object to iterate over.
  25939. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25940. * @returns {Object} Returns `object`.
  25941. * @see _.forOwn
  25942. * @example
  25943. *
  25944. * function Foo() {
  25945. * this.a = 1;
  25946. * this.b = 2;
  25947. * }
  25948. *
  25949. * Foo.prototype.c = 3;
  25950. *
  25951. * _.forOwnRight(new Foo, function(value, key) {
  25952. * console.log(key);
  25953. * });
  25954. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  25955. */
  25956. function forOwnRight(object, iteratee) {
  25957. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  25958. }
  25959. /**
  25960. * Creates an array of function property names from own enumerable properties
  25961. * of `object`.
  25962. *
  25963. * @static
  25964. * @since 0.1.0
  25965. * @memberOf _
  25966. * @category Object
  25967. * @param {Object} object The object to inspect.
  25968. * @returns {Array} Returns the function names.
  25969. * @see _.functionsIn
  25970. * @example
  25971. *
  25972. * function Foo() {
  25973. * this.a = _.constant('a');
  25974. * this.b = _.constant('b');
  25975. * }
  25976. *
  25977. * Foo.prototype.c = _.constant('c');
  25978. *
  25979. * _.functions(new Foo);
  25980. * // => ['a', 'b']
  25981. */
  25982. function functions(object) {
  25983. return object == null ? [] : baseFunctions(object, keys(object));
  25984. }
  25985. /**
  25986. * Creates an array of function property names from own and inherited
  25987. * enumerable properties of `object`.
  25988. *
  25989. * @static
  25990. * @memberOf _
  25991. * @since 4.0.0
  25992. * @category Object
  25993. * @param {Object} object The object to inspect.
  25994. * @returns {Array} Returns the function names.
  25995. * @see _.functions
  25996. * @example
  25997. *
  25998. * function Foo() {
  25999. * this.a = _.constant('a');
  26000. * this.b = _.constant('b');
  26001. * }
  26002. *
  26003. * Foo.prototype.c = _.constant('c');
  26004. *
  26005. * _.functionsIn(new Foo);
  26006. * // => ['a', 'b', 'c']
  26007. */
  26008. function functionsIn(object) {
  26009. return object == null ? [] : baseFunctions(object, keysIn(object));
  26010. }
  26011. /**
  26012. * Gets the value at `path` of `object`. If the resolved value is
  26013. * `undefined`, the `defaultValue` is returned in its place.
  26014. *
  26015. * @static
  26016. * @memberOf _
  26017. * @since 3.7.0
  26018. * @category Object
  26019. * @param {Object} object The object to query.
  26020. * @param {Array|string} path The path of the property to get.
  26021. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  26022. * @returns {*} Returns the resolved value.
  26023. * @example
  26024. *
  26025. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  26026. *
  26027. * _.get(object, 'a[0].b.c');
  26028. * // => 3
  26029. *
  26030. * _.get(object, ['a', '0', 'b', 'c']);
  26031. * // => 3
  26032. *
  26033. * _.get(object, 'a.b.c', 'default');
  26034. * // => 'default'
  26035. */
  26036. function get(object, path, defaultValue) {
  26037. var result = object == null ? undefined : baseGet(object, path);
  26038. return result === undefined ? defaultValue : result;
  26039. }
  26040. /**
  26041. * Checks if `path` is a direct property of `object`.
  26042. *
  26043. * @static
  26044. * @since 0.1.0
  26045. * @memberOf _
  26046. * @category Object
  26047. * @param {Object} object The object to query.
  26048. * @param {Array|string} path The path to check.
  26049. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  26050. * @example
  26051. *
  26052. * var object = { 'a': { 'b': 2 } };
  26053. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  26054. *
  26055. * _.has(object, 'a');
  26056. * // => true
  26057. *
  26058. * _.has(object, 'a.b');
  26059. * // => true
  26060. *
  26061. * _.has(object, ['a', 'b']);
  26062. * // => true
  26063. *
  26064. * _.has(other, 'a');
  26065. * // => false
  26066. */
  26067. function has(object, path) {
  26068. return object != null && hasPath(object, path, baseHas);
  26069. }
  26070. /**
  26071. * Checks if `path` is a direct or inherited property of `object`.
  26072. *
  26073. * @static
  26074. * @memberOf _
  26075. * @since 4.0.0
  26076. * @category Object
  26077. * @param {Object} object The object to query.
  26078. * @param {Array|string} path The path to check.
  26079. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  26080. * @example
  26081. *
  26082. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  26083. *
  26084. * _.hasIn(object, 'a');
  26085. * // => true
  26086. *
  26087. * _.hasIn(object, 'a.b');
  26088. * // => true
  26089. *
  26090. * _.hasIn(object, ['a', 'b']);
  26091. * // => true
  26092. *
  26093. * _.hasIn(object, 'b');
  26094. * // => false
  26095. */
  26096. function hasIn(object, path) {
  26097. return object != null && hasPath(object, path, baseHasIn);
  26098. }
  26099. /**
  26100. * Creates an object composed of the inverted keys and values of `object`.
  26101. * If `object` contains duplicate values, subsequent values overwrite
  26102. * property assignments of previous values.
  26103. *
  26104. * @static
  26105. * @memberOf _
  26106. * @since 0.7.0
  26107. * @category Object
  26108. * @param {Object} object The object to invert.
  26109. * @returns {Object} Returns the new inverted object.
  26110. * @example
  26111. *
  26112. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  26113. *
  26114. * _.invert(object);
  26115. * // => { '1': 'c', '2': 'b' }
  26116. */
  26117. var invert = createInverter(function(result, value, key) {
  26118. if (value != null &&
  26119. typeof value.toString != 'function') {
  26120. value = nativeObjectToString.call(value);
  26121. }
  26122. result[value] = key;
  26123. }, constant(identity));
  26124. /**
  26125. * This method is like `_.invert` except that the inverted object is generated
  26126. * from the results of running each element of `object` thru `iteratee`. The
  26127. * corresponding inverted value of each inverted key is an array of keys
  26128. * responsible for generating the inverted value. The iteratee is invoked
  26129. * with one argument: (value).
  26130. *
  26131. * @static
  26132. * @memberOf _
  26133. * @since 4.1.0
  26134. * @category Object
  26135. * @param {Object} object The object to invert.
  26136. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  26137. * @returns {Object} Returns the new inverted object.
  26138. * @example
  26139. *
  26140. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  26141. *
  26142. * _.invertBy(object);
  26143. * // => { '1': ['a', 'c'], '2': ['b'] }
  26144. *
  26145. * _.invertBy(object, function(value) {
  26146. * return 'group' + value;
  26147. * });
  26148. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  26149. */
  26150. var invertBy = createInverter(function(result, value, key) {
  26151. if (value != null &&
  26152. typeof value.toString != 'function') {
  26153. value = nativeObjectToString.call(value);
  26154. }
  26155. if (hasOwnProperty.call(result, value)) {
  26156. result[value].push(key);
  26157. } else {
  26158. result[value] = [key];
  26159. }
  26160. }, getIteratee);
  26161. /**
  26162. * Invokes the method at `path` of `object`.
  26163. *
  26164. * @static
  26165. * @memberOf _
  26166. * @since 4.0.0
  26167. * @category Object
  26168. * @param {Object} object The object to query.
  26169. * @param {Array|string} path The path of the method to invoke.
  26170. * @param {...*} [args] The arguments to invoke the method with.
  26171. * @returns {*} Returns the result of the invoked method.
  26172. * @example
  26173. *
  26174. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  26175. *
  26176. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  26177. * // => [2, 3]
  26178. */
  26179. var invoke = baseRest(baseInvoke);
  26180. /**
  26181. * Creates an array of the own enumerable property names of `object`.
  26182. *
  26183. * **Note:** Non-object values are coerced to objects. See the
  26184. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  26185. * for more details.
  26186. *
  26187. * @static
  26188. * @since 0.1.0
  26189. * @memberOf _
  26190. * @category Object
  26191. * @param {Object} object The object to query.
  26192. * @returns {Array} Returns the array of property names.
  26193. * @example
  26194. *
  26195. * function Foo() {
  26196. * this.a = 1;
  26197. * this.b = 2;
  26198. * }
  26199. *
  26200. * Foo.prototype.c = 3;
  26201. *
  26202. * _.keys(new Foo);
  26203. * // => ['a', 'b'] (iteration order is not guaranteed)
  26204. *
  26205. * _.keys('hi');
  26206. * // => ['0', '1']
  26207. */
  26208. function keys(object) {
  26209. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  26210. }
  26211. /**
  26212. * Creates an array of the own and inherited enumerable property names of `object`.
  26213. *
  26214. * **Note:** Non-object values are coerced to objects.
  26215. *
  26216. * @static
  26217. * @memberOf _
  26218. * @since 3.0.0
  26219. * @category Object
  26220. * @param {Object} object The object to query.
  26221. * @returns {Array} Returns the array of property names.
  26222. * @example
  26223. *
  26224. * function Foo() {
  26225. * this.a = 1;
  26226. * this.b = 2;
  26227. * }
  26228. *
  26229. * Foo.prototype.c = 3;
  26230. *
  26231. * _.keysIn(new Foo);
  26232. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  26233. */
  26234. function keysIn(object) {
  26235. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  26236. }
  26237. /**
  26238. * The opposite of `_.mapValues`; this method creates an object with the
  26239. * same values as `object` and keys generated by running each own enumerable
  26240. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  26241. * with three arguments: (value, key, object).
  26242. *
  26243. * @static
  26244. * @memberOf _
  26245. * @since 3.8.0
  26246. * @category Object
  26247. * @param {Object} object The object to iterate over.
  26248. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26249. * @returns {Object} Returns the new mapped object.
  26250. * @see _.mapValues
  26251. * @example
  26252. *
  26253. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  26254. * return key + value;
  26255. * });
  26256. * // => { 'a1': 1, 'b2': 2 }
  26257. */
  26258. function mapKeys(object, iteratee) {
  26259. var result = {};
  26260. iteratee = getIteratee(iteratee, 3);
  26261. baseForOwn(object, function(value, key, object) {
  26262. baseAssignValue(result, iteratee(value, key, object), value);
  26263. });
  26264. return result;
  26265. }
  26266. /**
  26267. * Creates an object with the same keys as `object` and values generated
  26268. * by running each own enumerable string keyed property of `object` thru
  26269. * `iteratee`. The iteratee is invoked with three arguments:
  26270. * (value, key, object).
  26271. *
  26272. * @static
  26273. * @memberOf _
  26274. * @since 2.4.0
  26275. * @category Object
  26276. * @param {Object} object The object to iterate over.
  26277. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26278. * @returns {Object} Returns the new mapped object.
  26279. * @see _.mapKeys
  26280. * @example
  26281. *
  26282. * var users = {
  26283. * 'fred': { 'user': 'fred', 'age': 40 },
  26284. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  26285. * };
  26286. *
  26287. * _.mapValues(users, function(o) { return o.age; });
  26288. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  26289. *
  26290. * // The `_.property` iteratee shorthand.
  26291. * _.mapValues(users, 'age');
  26292. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  26293. */
  26294. function mapValues(object, iteratee) {
  26295. var result = {};
  26296. iteratee = getIteratee(iteratee, 3);
  26297. baseForOwn(object, function(value, key, object) {
  26298. baseAssignValue(result, key, iteratee(value, key, object));
  26299. });
  26300. return result;
  26301. }
  26302. /**
  26303. * This method is like `_.assign` except that it recursively merges own and
  26304. * inherited enumerable string keyed properties of source objects into the
  26305. * destination object. Source properties that resolve to `undefined` are
  26306. * skipped if a destination value exists. Array and plain object properties
  26307. * are merged recursively. Other objects and value types are overridden by
  26308. * assignment. Source objects are applied from left to right. Subsequent
  26309. * sources overwrite property assignments of previous sources.
  26310. *
  26311. * **Note:** This method mutates `object`.
  26312. *
  26313. * @static
  26314. * @memberOf _
  26315. * @since 0.5.0
  26316. * @category Object
  26317. * @param {Object} object The destination object.
  26318. * @param {...Object} [sources] The source objects.
  26319. * @returns {Object} Returns `object`.
  26320. * @example
  26321. *
  26322. * var object = {
  26323. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  26324. * };
  26325. *
  26326. * var other = {
  26327. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  26328. * };
  26329. *
  26330. * _.merge(object, other);
  26331. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  26332. */
  26333. var merge = createAssigner(function(object, source, srcIndex) {
  26334. baseMerge(object, source, srcIndex);
  26335. });
  26336. /**
  26337. * This method is like `_.merge` except that it accepts `customizer` which
  26338. * is invoked to produce the merged values of the destination and source
  26339. * properties. If `customizer` returns `undefined`, merging is handled by the
  26340. * method instead. The `customizer` is invoked with six arguments:
  26341. * (objValue, srcValue, key, object, source, stack).
  26342. *
  26343. * **Note:** This method mutates `object`.
  26344. *
  26345. * @static
  26346. * @memberOf _
  26347. * @since 4.0.0
  26348. * @category Object
  26349. * @param {Object} object The destination object.
  26350. * @param {...Object} sources The source objects.
  26351. * @param {Function} customizer The function to customize assigned values.
  26352. * @returns {Object} Returns `object`.
  26353. * @example
  26354. *
  26355. * function customizer(objValue, srcValue) {
  26356. * if (_.isArray(objValue)) {
  26357. * return objValue.concat(srcValue);
  26358. * }
  26359. * }
  26360. *
  26361. * var object = { 'a': [1], 'b': [2] };
  26362. * var other = { 'a': [3], 'b': [4] };
  26363. *
  26364. * _.mergeWith(object, other, customizer);
  26365. * // => { 'a': [1, 3], 'b': [2, 4] }
  26366. */
  26367. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  26368. baseMerge(object, source, srcIndex, customizer);
  26369. });
  26370. /**
  26371. * The opposite of `_.pick`; this method creates an object composed of the
  26372. * own and inherited enumerable property paths of `object` that are not omitted.
  26373. *
  26374. * **Note:** This method is considerably slower than `_.pick`.
  26375. *
  26376. * @static
  26377. * @since 0.1.0
  26378. * @memberOf _
  26379. * @category Object
  26380. * @param {Object} object The source object.
  26381. * @param {...(string|string[])} [paths] The property paths to omit.
  26382. * @returns {Object} Returns the new object.
  26383. * @example
  26384. *
  26385. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26386. *
  26387. * _.omit(object, ['a', 'c']);
  26388. * // => { 'b': '2' }
  26389. */
  26390. var omit = flatRest(function(object, paths) {
  26391. var result = {};
  26392. if (object == null) {
  26393. return result;
  26394. }
  26395. var isDeep = false;
  26396. paths = arrayMap(paths, function(path) {
  26397. path = castPath(path, object);
  26398. isDeep || (isDeep = path.length > 1);
  26399. return path;
  26400. });
  26401. copyObject(object, getAllKeysIn(object), result);
  26402. if (isDeep) {
  26403. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  26404. }
  26405. var length = paths.length;
  26406. while (length--) {
  26407. baseUnset(result, paths[length]);
  26408. }
  26409. return result;
  26410. });
  26411. /**
  26412. * The opposite of `_.pickBy`; this method creates an object composed of
  26413. * the own and inherited enumerable string keyed properties of `object` that
  26414. * `predicate` doesn't return truthy for. The predicate is invoked with two
  26415. * arguments: (value, key).
  26416. *
  26417. * @static
  26418. * @memberOf _
  26419. * @since 4.0.0
  26420. * @category Object
  26421. * @param {Object} object The source object.
  26422. * @param {Function} [predicate=_.identity] The function invoked per property.
  26423. * @returns {Object} Returns the new object.
  26424. * @example
  26425. *
  26426. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26427. *
  26428. * _.omitBy(object, _.isNumber);
  26429. * // => { 'b': '2' }
  26430. */
  26431. function omitBy(object, predicate) {
  26432. return pickBy(object, negate(getIteratee(predicate)));
  26433. }
  26434. /**
  26435. * Creates an object composed of the picked `object` properties.
  26436. *
  26437. * @static
  26438. * @since 0.1.0
  26439. * @memberOf _
  26440. * @category Object
  26441. * @param {Object} object The source object.
  26442. * @param {...(string|string[])} [paths] The property paths to pick.
  26443. * @returns {Object} Returns the new object.
  26444. * @example
  26445. *
  26446. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26447. *
  26448. * _.pick(object, ['a', 'c']);
  26449. * // => { 'a': 1, 'c': 3 }
  26450. */
  26451. var pick = flatRest(function(object, paths) {
  26452. return object == null ? {} : basePick(object, paths);
  26453. });
  26454. /**
  26455. * Creates an object composed of the `object` properties `predicate` returns
  26456. * truthy for. The predicate is invoked with two arguments: (value, key).
  26457. *
  26458. * @static
  26459. * @memberOf _
  26460. * @since 4.0.0
  26461. * @category Object
  26462. * @param {Object} object The source object.
  26463. * @param {Function} [predicate=_.identity] The function invoked per property.
  26464. * @returns {Object} Returns the new object.
  26465. * @example
  26466. *
  26467. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26468. *
  26469. * _.pickBy(object, _.isNumber);
  26470. * // => { 'a': 1, 'c': 3 }
  26471. */
  26472. function pickBy(object, predicate) {
  26473. if (object == null) {
  26474. return {};
  26475. }
  26476. var props = arrayMap(getAllKeysIn(object), function(prop) {
  26477. return [prop];
  26478. });
  26479. predicate = getIteratee(predicate);
  26480. return basePickBy(object, props, function(value, path) {
  26481. return predicate(value, path[0]);
  26482. });
  26483. }
  26484. /**
  26485. * This method is like `_.get` except that if the resolved value is a
  26486. * function it's invoked with the `this` binding of its parent object and
  26487. * its result is returned.
  26488. *
  26489. * @static
  26490. * @since 0.1.0
  26491. * @memberOf _
  26492. * @category Object
  26493. * @param {Object} object The object to query.
  26494. * @param {Array|string} path The path of the property to resolve.
  26495. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  26496. * @returns {*} Returns the resolved value.
  26497. * @example
  26498. *
  26499. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  26500. *
  26501. * _.result(object, 'a[0].b.c1');
  26502. * // => 3
  26503. *
  26504. * _.result(object, 'a[0].b.c2');
  26505. * // => 4
  26506. *
  26507. * _.result(object, 'a[0].b.c3', 'default');
  26508. * // => 'default'
  26509. *
  26510. * _.result(object, 'a[0].b.c3', _.constant('default'));
  26511. * // => 'default'
  26512. */
  26513. function result(object, path, defaultValue) {
  26514. path = castPath(path, object);
  26515. var index = -1,
  26516. length = path.length;
  26517. // Ensure the loop is entered when path is empty.
  26518. if (!length) {
  26519. length = 1;
  26520. object = undefined;
  26521. }
  26522. while (++index < length) {
  26523. var value = object == null ? undefined : object[toKey(path[index])];
  26524. if (value === undefined) {
  26525. index = length;
  26526. value = defaultValue;
  26527. }
  26528. object = isFunction(value) ? value.call(object) : value;
  26529. }
  26530. return object;
  26531. }
  26532. /**
  26533. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  26534. * it's created. Arrays are created for missing index properties while objects
  26535. * are created for all other missing properties. Use `_.setWith` to customize
  26536. * `path` creation.
  26537. *
  26538. * **Note:** This method mutates `object`.
  26539. *
  26540. * @static
  26541. * @memberOf _
  26542. * @since 3.7.0
  26543. * @category Object
  26544. * @param {Object} object The object to modify.
  26545. * @param {Array|string} path The path of the property to set.
  26546. * @param {*} value The value to set.
  26547. * @returns {Object} Returns `object`.
  26548. * @example
  26549. *
  26550. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  26551. *
  26552. * _.set(object, 'a[0].b.c', 4);
  26553. * console.log(object.a[0].b.c);
  26554. * // => 4
  26555. *
  26556. * _.set(object, ['x', '0', 'y', 'z'], 5);
  26557. * console.log(object.x[0].y.z);
  26558. * // => 5
  26559. */
  26560. function set(object, path, value) {
  26561. return object == null ? object : baseSet(object, path, value);
  26562. }
  26563. /**
  26564. * This method is like `_.set` except that it accepts `customizer` which is
  26565. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  26566. * path creation is handled by the method instead. The `customizer` is invoked
  26567. * with three arguments: (nsValue, key, nsObject).
  26568. *
  26569. * **Note:** This method mutates `object`.
  26570. *
  26571. * @static
  26572. * @memberOf _
  26573. * @since 4.0.0
  26574. * @category Object
  26575. * @param {Object} object The object to modify.
  26576. * @param {Array|string} path The path of the property to set.
  26577. * @param {*} value The value to set.
  26578. * @param {Function} [customizer] The function to customize assigned values.
  26579. * @returns {Object} Returns `object`.
  26580. * @example
  26581. *
  26582. * var object = {};
  26583. *
  26584. * _.setWith(object, '[0][1]', 'a', Object);
  26585. * // => { '0': { '1': 'a' } }
  26586. */
  26587. function setWith(object, path, value, customizer) {
  26588. customizer = typeof customizer == 'function' ? customizer : undefined;
  26589. return object == null ? object : baseSet(object, path, value, customizer);
  26590. }
  26591. /**
  26592. * Creates an array of own enumerable string keyed-value pairs for `object`
  26593. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  26594. * entries are returned.
  26595. *
  26596. * @static
  26597. * @memberOf _
  26598. * @since 4.0.0
  26599. * @alias entries
  26600. * @category Object
  26601. * @param {Object} object The object to query.
  26602. * @returns {Array} Returns the key-value pairs.
  26603. * @example
  26604. *
  26605. * function Foo() {
  26606. * this.a = 1;
  26607. * this.b = 2;
  26608. * }
  26609. *
  26610. * Foo.prototype.c = 3;
  26611. *
  26612. * _.toPairs(new Foo);
  26613. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  26614. */
  26615. var toPairs = createToPairs(keys);
  26616. /**
  26617. * Creates an array of own and inherited enumerable string keyed-value pairs
  26618. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  26619. * or set, its entries are returned.
  26620. *
  26621. * @static
  26622. * @memberOf _
  26623. * @since 4.0.0
  26624. * @alias entriesIn
  26625. * @category Object
  26626. * @param {Object} object The object to query.
  26627. * @returns {Array} Returns the key-value pairs.
  26628. * @example
  26629. *
  26630. * function Foo() {
  26631. * this.a = 1;
  26632. * this.b = 2;
  26633. * }
  26634. *
  26635. * Foo.prototype.c = 3;
  26636. *
  26637. * _.toPairsIn(new Foo);
  26638. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  26639. */
  26640. var toPairsIn = createToPairs(keysIn);
  26641. /**
  26642. * An alternative to `_.reduce`; this method transforms `object` to a new
  26643. * `accumulator` object which is the result of running each of its own
  26644. * enumerable string keyed properties thru `iteratee`, with each invocation
  26645. * potentially mutating the `accumulator` object. If `accumulator` is not
  26646. * provided, a new object with the same `[[Prototype]]` will be used. The
  26647. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  26648. * Iteratee functions may exit iteration early by explicitly returning `false`.
  26649. *
  26650. * @static
  26651. * @memberOf _
  26652. * @since 1.3.0
  26653. * @category Object
  26654. * @param {Object} object The object to iterate over.
  26655. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26656. * @param {*} [accumulator] The custom accumulator value.
  26657. * @returns {*} Returns the accumulated value.
  26658. * @example
  26659. *
  26660. * _.transform([2, 3, 4], function(result, n) {
  26661. * result.push(n *= n);
  26662. * return n % 2 == 0;
  26663. * }, []);
  26664. * // => [4, 9]
  26665. *
  26666. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  26667. * (result[value] || (result[value] = [])).push(key);
  26668. * }, {});
  26669. * // => { '1': ['a', 'c'], '2': ['b'] }
  26670. */
  26671. function transform(object, iteratee, accumulator) {
  26672. var isArr = isArray(object),
  26673. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  26674. iteratee = getIteratee(iteratee, 4);
  26675. if (accumulator == null) {
  26676. var Ctor = object && object.constructor;
  26677. if (isArrLike) {
  26678. accumulator = isArr ? new Ctor : [];
  26679. }
  26680. else if (isObject(object)) {
  26681. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  26682. }
  26683. else {
  26684. accumulator = {};
  26685. }
  26686. }
  26687. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  26688. return iteratee(accumulator, value, index, object);
  26689. });
  26690. return accumulator;
  26691. }
  26692. /**
  26693. * Removes the property at `path` of `object`.
  26694. *
  26695. * **Note:** This method mutates `object`.
  26696. *
  26697. * @static
  26698. * @memberOf _
  26699. * @since 4.0.0
  26700. * @category Object
  26701. * @param {Object} object The object to modify.
  26702. * @param {Array|string} path The path of the property to unset.
  26703. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  26704. * @example
  26705. *
  26706. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  26707. * _.unset(object, 'a[0].b.c');
  26708. * // => true
  26709. *
  26710. * console.log(object);
  26711. * // => { 'a': [{ 'b': {} }] };
  26712. *
  26713. * _.unset(object, ['a', '0', 'b', 'c']);
  26714. * // => true
  26715. *
  26716. * console.log(object);
  26717. * // => { 'a': [{ 'b': {} }] };
  26718. */
  26719. function unset(object, path) {
  26720. return object == null ? true : baseUnset(object, path);
  26721. }
  26722. /**
  26723. * This method is like `_.set` except that accepts `updater` to produce the
  26724. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  26725. * is invoked with one argument: (value).
  26726. *
  26727. * **Note:** This method mutates `object`.
  26728. *
  26729. * @static
  26730. * @memberOf _
  26731. * @since 4.6.0
  26732. * @category Object
  26733. * @param {Object} object The object to modify.
  26734. * @param {Array|string} path The path of the property to set.
  26735. * @param {Function} updater The function to produce the updated value.
  26736. * @returns {Object} Returns `object`.
  26737. * @example
  26738. *
  26739. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  26740. *
  26741. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  26742. * console.log(object.a[0].b.c);
  26743. * // => 9
  26744. *
  26745. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  26746. * console.log(object.x[0].y.z);
  26747. * // => 0
  26748. */
  26749. function update(object, path, updater) {
  26750. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  26751. }
  26752. /**
  26753. * This method is like `_.update` except that it accepts `customizer` which is
  26754. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  26755. * path creation is handled by the method instead. The `customizer` is invoked
  26756. * with three arguments: (nsValue, key, nsObject).
  26757. *
  26758. * **Note:** This method mutates `object`.
  26759. *
  26760. * @static
  26761. * @memberOf _
  26762. * @since 4.6.0
  26763. * @category Object
  26764. * @param {Object} object The object to modify.
  26765. * @param {Array|string} path The path of the property to set.
  26766. * @param {Function} updater The function to produce the updated value.
  26767. * @param {Function} [customizer] The function to customize assigned values.
  26768. * @returns {Object} Returns `object`.
  26769. * @example
  26770. *
  26771. * var object = {};
  26772. *
  26773. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  26774. * // => { '0': { '1': 'a' } }
  26775. */
  26776. function updateWith(object, path, updater, customizer) {
  26777. customizer = typeof customizer == 'function' ? customizer : undefined;
  26778. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  26779. }
  26780. /**
  26781. * Creates an array of the own enumerable string keyed property values of `object`.
  26782. *
  26783. * **Note:** Non-object values are coerced to objects.
  26784. *
  26785. * @static
  26786. * @since 0.1.0
  26787. * @memberOf _
  26788. * @category Object
  26789. * @param {Object} object The object to query.
  26790. * @returns {Array} Returns the array of property values.
  26791. * @example
  26792. *
  26793. * function Foo() {
  26794. * this.a = 1;
  26795. * this.b = 2;
  26796. * }
  26797. *
  26798. * Foo.prototype.c = 3;
  26799. *
  26800. * _.values(new Foo);
  26801. * // => [1, 2] (iteration order is not guaranteed)
  26802. *
  26803. * _.values('hi');
  26804. * // => ['h', 'i']
  26805. */
  26806. function values(object) {
  26807. return object == null ? [] : baseValues(object, keys(object));
  26808. }
  26809. /**
  26810. * Creates an array of the own and inherited enumerable string keyed property
  26811. * values of `object`.
  26812. *
  26813. * **Note:** Non-object values are coerced to objects.
  26814. *
  26815. * @static
  26816. * @memberOf _
  26817. * @since 3.0.0
  26818. * @category Object
  26819. * @param {Object} object The object to query.
  26820. * @returns {Array} Returns the array of property values.
  26821. * @example
  26822. *
  26823. * function Foo() {
  26824. * this.a = 1;
  26825. * this.b = 2;
  26826. * }
  26827. *
  26828. * Foo.prototype.c = 3;
  26829. *
  26830. * _.valuesIn(new Foo);
  26831. * // => [1, 2, 3] (iteration order is not guaranteed)
  26832. */
  26833. function valuesIn(object) {
  26834. return object == null ? [] : baseValues(object, keysIn(object));
  26835. }
  26836. /*------------------------------------------------------------------------*/
  26837. /**
  26838. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  26839. *
  26840. * @static
  26841. * @memberOf _
  26842. * @since 4.0.0
  26843. * @category Number
  26844. * @param {number} number The number to clamp.
  26845. * @param {number} [lower] The lower bound.
  26846. * @param {number} upper The upper bound.
  26847. * @returns {number} Returns the clamped number.
  26848. * @example
  26849. *
  26850. * _.clamp(-10, -5, 5);
  26851. * // => -5
  26852. *
  26853. * _.clamp(10, -5, 5);
  26854. * // => 5
  26855. */
  26856. function clamp(number, lower, upper) {
  26857. if (upper === undefined) {
  26858. upper = lower;
  26859. lower = undefined;
  26860. }
  26861. if (upper !== undefined) {
  26862. upper = toNumber(upper);
  26863. upper = upper === upper ? upper : 0;
  26864. }
  26865. if (lower !== undefined) {
  26866. lower = toNumber(lower);
  26867. lower = lower === lower ? lower : 0;
  26868. }
  26869. return baseClamp(toNumber(number), lower, upper);
  26870. }
  26871. /**
  26872. * Checks if `n` is between `start` and up to, but not including, `end`. If
  26873. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  26874. * If `start` is greater than `end` the params are swapped to support
  26875. * negative ranges.
  26876. *
  26877. * @static
  26878. * @memberOf _
  26879. * @since 3.3.0
  26880. * @category Number
  26881. * @param {number} number The number to check.
  26882. * @param {number} [start=0] The start of the range.
  26883. * @param {number} end The end of the range.
  26884. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  26885. * @see _.range, _.rangeRight
  26886. * @example
  26887. *
  26888. * _.inRange(3, 2, 4);
  26889. * // => true
  26890. *
  26891. * _.inRange(4, 8);
  26892. * // => true
  26893. *
  26894. * _.inRange(4, 2);
  26895. * // => false
  26896. *
  26897. * _.inRange(2, 2);
  26898. * // => false
  26899. *
  26900. * _.inRange(1.2, 2);
  26901. * // => true
  26902. *
  26903. * _.inRange(5.2, 4);
  26904. * // => false
  26905. *
  26906. * _.inRange(-3, -2, -6);
  26907. * // => true
  26908. */
  26909. function inRange(number, start, end) {
  26910. start = toFinite(start);
  26911. if (end === undefined) {
  26912. end = start;
  26913. start = 0;
  26914. } else {
  26915. end = toFinite(end);
  26916. }
  26917. number = toNumber(number);
  26918. return baseInRange(number, start, end);
  26919. }
  26920. /**
  26921. * Produces a random number between the inclusive `lower` and `upper` bounds.
  26922. * If only one argument is provided a number between `0` and the given number
  26923. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  26924. * floats, a floating-point number is returned instead of an integer.
  26925. *
  26926. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  26927. * floating-point values which can produce unexpected results.
  26928. *
  26929. * @static
  26930. * @memberOf _
  26931. * @since 0.7.0
  26932. * @category Number
  26933. * @param {number} [lower=0] The lower bound.
  26934. * @param {number} [upper=1] The upper bound.
  26935. * @param {boolean} [floating] Specify returning a floating-point number.
  26936. * @returns {number} Returns the random number.
  26937. * @example
  26938. *
  26939. * _.random(0, 5);
  26940. * // => an integer between 0 and 5
  26941. *
  26942. * _.random(5);
  26943. * // => also an integer between 0 and 5
  26944. *
  26945. * _.random(5, true);
  26946. * // => a floating-point number between 0 and 5
  26947. *
  26948. * _.random(1.2, 5.2);
  26949. * // => a floating-point number between 1.2 and 5.2
  26950. */
  26951. function random(lower, upper, floating) {
  26952. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  26953. upper = floating = undefined;
  26954. }
  26955. if (floating === undefined) {
  26956. if (typeof upper == 'boolean') {
  26957. floating = upper;
  26958. upper = undefined;
  26959. }
  26960. else if (typeof lower == 'boolean') {
  26961. floating = lower;
  26962. lower = undefined;
  26963. }
  26964. }
  26965. if (lower === undefined && upper === undefined) {
  26966. lower = 0;
  26967. upper = 1;
  26968. }
  26969. else {
  26970. lower = toFinite(lower);
  26971. if (upper === undefined) {
  26972. upper = lower;
  26973. lower = 0;
  26974. } else {
  26975. upper = toFinite(upper);
  26976. }
  26977. }
  26978. if (lower > upper) {
  26979. var temp = lower;
  26980. lower = upper;
  26981. upper = temp;
  26982. }
  26983. if (floating || lower % 1 || upper % 1) {
  26984. var rand = nativeRandom();
  26985. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  26986. }
  26987. return baseRandom(lower, upper);
  26988. }
  26989. /*------------------------------------------------------------------------*/
  26990. /**
  26991. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  26992. *
  26993. * @static
  26994. * @memberOf _
  26995. * @since 3.0.0
  26996. * @category String
  26997. * @param {string} [string=''] The string to convert.
  26998. * @returns {string} Returns the camel cased string.
  26999. * @example
  27000. *
  27001. * _.camelCase('Foo Bar');
  27002. * // => 'fooBar'
  27003. *
  27004. * _.camelCase('--foo-bar--');
  27005. * // => 'fooBar'
  27006. *
  27007. * _.camelCase('__FOO_BAR__');
  27008. * // => 'fooBar'
  27009. */
  27010. var camelCase = createCompounder(function(result, word, index) {
  27011. word = word.toLowerCase();
  27012. return result + (index ? capitalize(word) : word);
  27013. });
  27014. /**
  27015. * Converts the first character of `string` to upper case and the remaining
  27016. * to lower case.
  27017. *
  27018. * @static
  27019. * @memberOf _
  27020. * @since 3.0.0
  27021. * @category String
  27022. * @param {string} [string=''] The string to capitalize.
  27023. * @returns {string} Returns the capitalized string.
  27024. * @example
  27025. *
  27026. * _.capitalize('FRED');
  27027. * // => 'Fred'
  27028. */
  27029. function capitalize(string) {
  27030. return upperFirst(toString(string).toLowerCase());
  27031. }
  27032. /**
  27033. * Deburrs `string` by converting
  27034. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  27035. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  27036. * letters to basic Latin letters and removing
  27037. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  27038. *
  27039. * @static
  27040. * @memberOf _
  27041. * @since 3.0.0
  27042. * @category String
  27043. * @param {string} [string=''] The string to deburr.
  27044. * @returns {string} Returns the deburred string.
  27045. * @example
  27046. *
  27047. * _.deburr('déjà vu');
  27048. * // => 'deja vu'
  27049. */
  27050. function deburr(string) {
  27051. string = toString(string);
  27052. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  27053. }
  27054. /**
  27055. * Checks if `string` ends with the given target string.
  27056. *
  27057. * @static
  27058. * @memberOf _
  27059. * @since 3.0.0
  27060. * @category String
  27061. * @param {string} [string=''] The string to inspect.
  27062. * @param {string} [target] The string to search for.
  27063. * @param {number} [position=string.length] The position to search up to.
  27064. * @returns {boolean} Returns `true` if `string` ends with `target`,
  27065. * else `false`.
  27066. * @example
  27067. *
  27068. * _.endsWith('abc', 'c');
  27069. * // => true
  27070. *
  27071. * _.endsWith('abc', 'b');
  27072. * // => false
  27073. *
  27074. * _.endsWith('abc', 'b', 2);
  27075. * // => true
  27076. */
  27077. function endsWith(string, target, position) {
  27078. string = toString(string);
  27079. target = baseToString(target);
  27080. var length = string.length;
  27081. position = position === undefined
  27082. ? length
  27083. : baseClamp(toInteger(position), 0, length);
  27084. var end = position;
  27085. position -= target.length;
  27086. return position >= 0 && string.slice(position, end) == target;
  27087. }
  27088. /**
  27089. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  27090. * corresponding HTML entities.
  27091. *
  27092. * **Note:** No other characters are escaped. To escape additional
  27093. * characters use a third-party library like [_he_](https://mths.be/he).
  27094. *
  27095. * Though the ">" character is escaped for symmetry, characters like
  27096. * ">" and "/" don't need escaping in HTML and have no special meaning
  27097. * unless they're part of a tag or unquoted attribute value. See
  27098. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  27099. * (under "semi-related fun fact") for more details.
  27100. *
  27101. * When working with HTML you should always
  27102. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  27103. * XSS vectors.
  27104. *
  27105. * @static
  27106. * @since 0.1.0
  27107. * @memberOf _
  27108. * @category String
  27109. * @param {string} [string=''] The string to escape.
  27110. * @returns {string} Returns the escaped string.
  27111. * @example
  27112. *
  27113. * _.escape('fred, barney, & pebbles');
  27114. * // => 'fred, barney, &amp; pebbles'
  27115. */
  27116. function escape(string) {
  27117. string = toString(string);
  27118. return (string && reHasUnescapedHtml.test(string))
  27119. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  27120. : string;
  27121. }
  27122. /**
  27123. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  27124. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  27125. *
  27126. * @static
  27127. * @memberOf _
  27128. * @since 3.0.0
  27129. * @category String
  27130. * @param {string} [string=''] The string to escape.
  27131. * @returns {string} Returns the escaped string.
  27132. * @example
  27133. *
  27134. * _.escapeRegExp('[lodash](https://lodash.com/)');
  27135. * // => '\[lodash\]\(https://lodash\.com/\)'
  27136. */
  27137. function escapeRegExp(string) {
  27138. string = toString(string);
  27139. return (string && reHasRegExpChar.test(string))
  27140. ? string.replace(reRegExpChar, '\\$&')
  27141. : string;
  27142. }
  27143. /**
  27144. * Converts `string` to
  27145. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  27146. *
  27147. * @static
  27148. * @memberOf _
  27149. * @since 3.0.0
  27150. * @category String
  27151. * @param {string} [string=''] The string to convert.
  27152. * @returns {string} Returns the kebab cased string.
  27153. * @example
  27154. *
  27155. * _.kebabCase('Foo Bar');
  27156. * // => 'foo-bar'
  27157. *
  27158. * _.kebabCase('fooBar');
  27159. * // => 'foo-bar'
  27160. *
  27161. * _.kebabCase('__FOO_BAR__');
  27162. * // => 'foo-bar'
  27163. */
  27164. var kebabCase = createCompounder(function(result, word, index) {
  27165. return result + (index ? '-' : '') + word.toLowerCase();
  27166. });
  27167. /**
  27168. * Converts `string`, as space separated words, to lower case.
  27169. *
  27170. * @static
  27171. * @memberOf _
  27172. * @since 4.0.0
  27173. * @category String
  27174. * @param {string} [string=''] The string to convert.
  27175. * @returns {string} Returns the lower cased string.
  27176. * @example
  27177. *
  27178. * _.lowerCase('--Foo-Bar--');
  27179. * // => 'foo bar'
  27180. *
  27181. * _.lowerCase('fooBar');
  27182. * // => 'foo bar'
  27183. *
  27184. * _.lowerCase('__FOO_BAR__');
  27185. * // => 'foo bar'
  27186. */
  27187. var lowerCase = createCompounder(function(result, word, index) {
  27188. return result + (index ? ' ' : '') + word.toLowerCase();
  27189. });
  27190. /**
  27191. * Converts the first character of `string` to lower case.
  27192. *
  27193. * @static
  27194. * @memberOf _
  27195. * @since 4.0.0
  27196. * @category String
  27197. * @param {string} [string=''] The string to convert.
  27198. * @returns {string} Returns the converted string.
  27199. * @example
  27200. *
  27201. * _.lowerFirst('Fred');
  27202. * // => 'fred'
  27203. *
  27204. * _.lowerFirst('FRED');
  27205. * // => 'fRED'
  27206. */
  27207. var lowerFirst = createCaseFirst('toLowerCase');
  27208. /**
  27209. * Pads `string` on the left and right sides if it's shorter than `length`.
  27210. * Padding characters are truncated if they can't be evenly divided by `length`.
  27211. *
  27212. * @static
  27213. * @memberOf _
  27214. * @since 3.0.0
  27215. * @category String
  27216. * @param {string} [string=''] The string to pad.
  27217. * @param {number} [length=0] The padding length.
  27218. * @param {string} [chars=' '] The string used as padding.
  27219. * @returns {string} Returns the padded string.
  27220. * @example
  27221. *
  27222. * _.pad('abc', 8);
  27223. * // => ' abc '
  27224. *
  27225. * _.pad('abc', 8, '_-');
  27226. * // => '_-abc_-_'
  27227. *
  27228. * _.pad('abc', 3);
  27229. * // => 'abc'
  27230. */
  27231. function pad(string, length, chars) {
  27232. string = toString(string);
  27233. length = toInteger(length);
  27234. var strLength = length ? stringSize(string) : 0;
  27235. if (!length || strLength >= length) {
  27236. return string;
  27237. }
  27238. var mid = (length - strLength) / 2;
  27239. return (
  27240. createPadding(nativeFloor(mid), chars) +
  27241. string +
  27242. createPadding(nativeCeil(mid), chars)
  27243. );
  27244. }
  27245. /**
  27246. * Pads `string` on the right side if it's shorter than `length`. Padding
  27247. * characters are truncated if they exceed `length`.
  27248. *
  27249. * @static
  27250. * @memberOf _
  27251. * @since 4.0.0
  27252. * @category String
  27253. * @param {string} [string=''] The string to pad.
  27254. * @param {number} [length=0] The padding length.
  27255. * @param {string} [chars=' '] The string used as padding.
  27256. * @returns {string} Returns the padded string.
  27257. * @example
  27258. *
  27259. * _.padEnd('abc', 6);
  27260. * // => 'abc '
  27261. *
  27262. * _.padEnd('abc', 6, '_-');
  27263. * // => 'abc_-_'
  27264. *
  27265. * _.padEnd('abc', 3);
  27266. * // => 'abc'
  27267. */
  27268. function padEnd(string, length, chars) {
  27269. string = toString(string);
  27270. length = toInteger(length);
  27271. var strLength = length ? stringSize(string) : 0;
  27272. return (length && strLength < length)
  27273. ? (string + createPadding(length - strLength, chars))
  27274. : string;
  27275. }
  27276. /**
  27277. * Pads `string` on the left side if it's shorter than `length`. Padding
  27278. * characters are truncated if they exceed `length`.
  27279. *
  27280. * @static
  27281. * @memberOf _
  27282. * @since 4.0.0
  27283. * @category String
  27284. * @param {string} [string=''] The string to pad.
  27285. * @param {number} [length=0] The padding length.
  27286. * @param {string} [chars=' '] The string used as padding.
  27287. * @returns {string} Returns the padded string.
  27288. * @example
  27289. *
  27290. * _.padStart('abc', 6);
  27291. * // => ' abc'
  27292. *
  27293. * _.padStart('abc', 6, '_-');
  27294. * // => '_-_abc'
  27295. *
  27296. * _.padStart('abc', 3);
  27297. * // => 'abc'
  27298. */
  27299. function padStart(string, length, chars) {
  27300. string = toString(string);
  27301. length = toInteger(length);
  27302. var strLength = length ? stringSize(string) : 0;
  27303. return (length && strLength < length)
  27304. ? (createPadding(length - strLength, chars) + string)
  27305. : string;
  27306. }
  27307. /**
  27308. * Converts `string` to an integer of the specified radix. If `radix` is
  27309. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  27310. * hexadecimal, in which case a `radix` of `16` is used.
  27311. *
  27312. * **Note:** This method aligns with the
  27313. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  27314. *
  27315. * @static
  27316. * @memberOf _
  27317. * @since 1.1.0
  27318. * @category String
  27319. * @param {string} string The string to convert.
  27320. * @param {number} [radix=10] The radix to interpret `value` by.
  27321. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27322. * @returns {number} Returns the converted integer.
  27323. * @example
  27324. *
  27325. * _.parseInt('08');
  27326. * // => 8
  27327. *
  27328. * _.map(['6', '08', '10'], _.parseInt);
  27329. * // => [6, 8, 10]
  27330. */
  27331. function parseInt(string, radix, guard) {
  27332. if (guard || radix == null) {
  27333. radix = 0;
  27334. } else if (radix) {
  27335. radix = +radix;
  27336. }
  27337. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  27338. }
  27339. /**
  27340. * Repeats the given string `n` times.
  27341. *
  27342. * @static
  27343. * @memberOf _
  27344. * @since 3.0.0
  27345. * @category String
  27346. * @param {string} [string=''] The string to repeat.
  27347. * @param {number} [n=1] The number of times to repeat the string.
  27348. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27349. * @returns {string} Returns the repeated string.
  27350. * @example
  27351. *
  27352. * _.repeat('*', 3);
  27353. * // => '***'
  27354. *
  27355. * _.repeat('abc', 2);
  27356. * // => 'abcabc'
  27357. *
  27358. * _.repeat('abc', 0);
  27359. * // => ''
  27360. */
  27361. function repeat(string, n, guard) {
  27362. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  27363. n = 1;
  27364. } else {
  27365. n = toInteger(n);
  27366. }
  27367. return baseRepeat(toString(string), n);
  27368. }
  27369. /**
  27370. * Replaces matches for `pattern` in `string` with `replacement`.
  27371. *
  27372. * **Note:** This method is based on
  27373. * [`String#replace`](https://mdn.io/String/replace).
  27374. *
  27375. * @static
  27376. * @memberOf _
  27377. * @since 4.0.0
  27378. * @category String
  27379. * @param {string} [string=''] The string to modify.
  27380. * @param {RegExp|string} pattern The pattern to replace.
  27381. * @param {Function|string} replacement The match replacement.
  27382. * @returns {string} Returns the modified string.
  27383. * @example
  27384. *
  27385. * _.replace('Hi Fred', 'Fred', 'Barney');
  27386. * // => 'Hi Barney'
  27387. */
  27388. function replace() {
  27389. var args = arguments,
  27390. string = toString(args[0]);
  27391. return args.length < 3 ? string : string.replace(args[1], args[2]);
  27392. }
  27393. /**
  27394. * Converts `string` to
  27395. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  27396. *
  27397. * @static
  27398. * @memberOf _
  27399. * @since 3.0.0
  27400. * @category String
  27401. * @param {string} [string=''] The string to convert.
  27402. * @returns {string} Returns the snake cased string.
  27403. * @example
  27404. *
  27405. * _.snakeCase('Foo Bar');
  27406. * // => 'foo_bar'
  27407. *
  27408. * _.snakeCase('fooBar');
  27409. * // => 'foo_bar'
  27410. *
  27411. * _.snakeCase('--FOO-BAR--');
  27412. * // => 'foo_bar'
  27413. */
  27414. var snakeCase = createCompounder(function(result, word, index) {
  27415. return result + (index ? '_' : '') + word.toLowerCase();
  27416. });
  27417. /**
  27418. * Splits `string` by `separator`.
  27419. *
  27420. * **Note:** This method is based on
  27421. * [`String#split`](https://mdn.io/String/split).
  27422. *
  27423. * @static
  27424. * @memberOf _
  27425. * @since 4.0.0
  27426. * @category String
  27427. * @param {string} [string=''] The string to split.
  27428. * @param {RegExp|string} separator The separator pattern to split by.
  27429. * @param {number} [limit] The length to truncate results to.
  27430. * @returns {Array} Returns the string segments.
  27431. * @example
  27432. *
  27433. * _.split('a-b-c', '-', 2);
  27434. * // => ['a', 'b']
  27435. */
  27436. function split(string, separator, limit) {
  27437. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  27438. separator = limit = undefined;
  27439. }
  27440. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  27441. if (!limit) {
  27442. return [];
  27443. }
  27444. string = toString(string);
  27445. if (string && (
  27446. typeof separator == 'string' ||
  27447. (separator != null && !isRegExp(separator))
  27448. )) {
  27449. separator = baseToString(separator);
  27450. if (!separator && hasUnicode(string)) {
  27451. return castSlice(stringToArray(string), 0, limit);
  27452. }
  27453. }
  27454. return string.split(separator, limit);
  27455. }
  27456. /**
  27457. * Converts `string` to
  27458. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  27459. *
  27460. * @static
  27461. * @memberOf _
  27462. * @since 3.1.0
  27463. * @category String
  27464. * @param {string} [string=''] The string to convert.
  27465. * @returns {string} Returns the start cased string.
  27466. * @example
  27467. *
  27468. * _.startCase('--foo-bar--');
  27469. * // => 'Foo Bar'
  27470. *
  27471. * _.startCase('fooBar');
  27472. * // => 'Foo Bar'
  27473. *
  27474. * _.startCase('__FOO_BAR__');
  27475. * // => 'FOO BAR'
  27476. */
  27477. var startCase = createCompounder(function(result, word, index) {
  27478. return result + (index ? ' ' : '') + upperFirst(word);
  27479. });
  27480. /**
  27481. * Checks if `string` starts with the given target string.
  27482. *
  27483. * @static
  27484. * @memberOf _
  27485. * @since 3.0.0
  27486. * @category String
  27487. * @param {string} [string=''] The string to inspect.
  27488. * @param {string} [target] The string to search for.
  27489. * @param {number} [position=0] The position to search from.
  27490. * @returns {boolean} Returns `true` if `string` starts with `target`,
  27491. * else `false`.
  27492. * @example
  27493. *
  27494. * _.startsWith('abc', 'a');
  27495. * // => true
  27496. *
  27497. * _.startsWith('abc', 'b');
  27498. * // => false
  27499. *
  27500. * _.startsWith('abc', 'b', 1);
  27501. * // => true
  27502. */
  27503. function startsWith(string, target, position) {
  27504. string = toString(string);
  27505. position = position == null
  27506. ? 0
  27507. : baseClamp(toInteger(position), 0, string.length);
  27508. target = baseToString(target);
  27509. return string.slice(position, position + target.length) == target;
  27510. }
  27511. /**
  27512. * Creates a compiled template function that can interpolate data properties
  27513. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  27514. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  27515. * properties may be accessed as free variables in the template. If a setting
  27516. * object is given, it takes precedence over `_.templateSettings` values.
  27517. *
  27518. * **Note:** In the development build `_.template` utilizes
  27519. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  27520. * for easier debugging.
  27521. *
  27522. * For more information on precompiling templates see
  27523. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  27524. *
  27525. * For more information on Chrome extension sandboxes see
  27526. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  27527. *
  27528. * @static
  27529. * @since 0.1.0
  27530. * @memberOf _
  27531. * @category String
  27532. * @param {string} [string=''] The template string.
  27533. * @param {Object} [options={}] The options object.
  27534. * @param {RegExp} [options.escape=_.templateSettings.escape]
  27535. * The HTML "escape" delimiter.
  27536. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  27537. * The "evaluate" delimiter.
  27538. * @param {Object} [options.imports=_.templateSettings.imports]
  27539. * An object to import into the template as free variables.
  27540. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  27541. * The "interpolate" delimiter.
  27542. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  27543. * The sourceURL of the compiled template.
  27544. * @param {string} [options.variable='obj']
  27545. * The data object variable name.
  27546. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27547. * @returns {Function} Returns the compiled template function.
  27548. * @example
  27549. *
  27550. * // Use the "interpolate" delimiter to create a compiled template.
  27551. * var compiled = _.template('hello <%= user %>!');
  27552. * compiled({ 'user': 'fred' });
  27553. * // => 'hello fred!'
  27554. *
  27555. * // Use the HTML "escape" delimiter to escape data property values.
  27556. * var compiled = _.template('<b><%- value %></b>');
  27557. * compiled({ 'value': '<script>' });
  27558. * // => '<b>&lt;script&gt;</b>'
  27559. *
  27560. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  27561. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  27562. * compiled({ 'users': ['fred', 'barney'] });
  27563. * // => '<li>fred</li><li>barney</li>'
  27564. *
  27565. * // Use the internal `print` function in "evaluate" delimiters.
  27566. * var compiled = _.template('<% print("hello " + user); %>!');
  27567. * compiled({ 'user': 'barney' });
  27568. * // => 'hello barney!'
  27569. *
  27570. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  27571. * // Disable support by replacing the "interpolate" delimiter.
  27572. * var compiled = _.template('hello ${ user }!');
  27573. * compiled({ 'user': 'pebbles' });
  27574. * // => 'hello pebbles!'
  27575. *
  27576. * // Use backslashes to treat delimiters as plain text.
  27577. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  27578. * compiled({ 'value': 'ignored' });
  27579. * // => '<%- value %>'
  27580. *
  27581. * // Use the `imports` option to import `jQuery` as `jq`.
  27582. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  27583. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  27584. * compiled({ 'users': ['fred', 'barney'] });
  27585. * // => '<li>fred</li><li>barney</li>'
  27586. *
  27587. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  27588. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  27589. * compiled(data);
  27590. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  27591. *
  27592. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  27593. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  27594. * compiled.source;
  27595. * // => function(data) {
  27596. * // var __t, __p = '';
  27597. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  27598. * // return __p;
  27599. * // }
  27600. *
  27601. * // Use custom template delimiters.
  27602. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  27603. * var compiled = _.template('hello {{ user }}!');
  27604. * compiled({ 'user': 'mustache' });
  27605. * // => 'hello mustache!'
  27606. *
  27607. * // Use the `source` property to inline compiled templates for meaningful
  27608. * // line numbers in error messages and stack traces.
  27609. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  27610. * var JST = {\
  27611. * "main": ' + _.template(mainText).source + '\
  27612. * };\
  27613. * ');
  27614. */
  27615. function template(string, options, guard) {
  27616. // Based on John Resig's `tmpl` implementation
  27617. // (http://ejohn.org/blog/javascript-micro-templating/)
  27618. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  27619. var settings = lodash.templateSettings;
  27620. if (guard && isIterateeCall(string, options, guard)) {
  27621. options = undefined;
  27622. }
  27623. string = toString(string);
  27624. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  27625. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  27626. importsKeys = keys(imports),
  27627. importsValues = baseValues(imports, importsKeys);
  27628. var isEscaping,
  27629. isEvaluating,
  27630. index = 0,
  27631. interpolate = options.interpolate || reNoMatch,
  27632. source = "__p += '";
  27633. // Compile the regexp to match each delimiter.
  27634. var reDelimiters = RegExp(
  27635. (options.escape || reNoMatch).source + '|' +
  27636. interpolate.source + '|' +
  27637. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  27638. (options.evaluate || reNoMatch).source + '|$'
  27639. , 'g');
  27640. // Use a sourceURL for easier debugging.
  27641. // The sourceURL gets injected into the source that's eval-ed, so be careful
  27642. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  27643. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  27644. var sourceURL = '//# sourceURL=' +
  27645. (hasOwnProperty.call(options, 'sourceURL')
  27646. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  27647. : ('lodash.templateSources[' + (++templateCounter) + ']')
  27648. ) + '\n';
  27649. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  27650. interpolateValue || (interpolateValue = esTemplateValue);
  27651. // Escape characters that can't be included in string literals.
  27652. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  27653. // Replace delimiters with snippets.
  27654. if (escapeValue) {
  27655. isEscaping = true;
  27656. source += "' +\n__e(" + escapeValue + ") +\n'";
  27657. }
  27658. if (evaluateValue) {
  27659. isEvaluating = true;
  27660. source += "';\n" + evaluateValue + ";\n__p += '";
  27661. }
  27662. if (interpolateValue) {
  27663. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  27664. }
  27665. index = offset + match.length;
  27666. // The JS engine embedded in Adobe products needs `match` returned in
  27667. // order to produce the correct `offset` value.
  27668. return match;
  27669. });
  27670. source += "';\n";
  27671. // If `variable` is not specified wrap a with-statement around the generated
  27672. // code to add the data object to the top of the scope chain.
  27673. // Like with sourceURL, we take care to not check the option's prototype,
  27674. // as this configuration is a code injection vector.
  27675. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  27676. if (!variable) {
  27677. source = 'with (obj) {\n' + source + '\n}\n';
  27678. }
  27679. // Cleanup code by stripping empty strings.
  27680. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  27681. .replace(reEmptyStringMiddle, '$1')
  27682. .replace(reEmptyStringTrailing, '$1;');
  27683. // Frame code as the function body.
  27684. source = 'function(' + (variable || 'obj') + ') {\n' +
  27685. (variable
  27686. ? ''
  27687. : 'obj || (obj = {});\n'
  27688. ) +
  27689. "var __t, __p = ''" +
  27690. (isEscaping
  27691. ? ', __e = _.escape'
  27692. : ''
  27693. ) +
  27694. (isEvaluating
  27695. ? ', __j = Array.prototype.join;\n' +
  27696. "function print() { __p += __j.call(arguments, '') }\n"
  27697. : ';\n'
  27698. ) +
  27699. source +
  27700. 'return __p\n}';
  27701. var result = attempt(function() {
  27702. return Function(importsKeys, sourceURL + 'return ' + source)
  27703. .apply(undefined, importsValues);
  27704. });
  27705. // Provide the compiled function's source by its `toString` method or
  27706. // the `source` property as a convenience for inlining compiled templates.
  27707. result.source = source;
  27708. if (isError(result)) {
  27709. throw result;
  27710. }
  27711. return result;
  27712. }
  27713. /**
  27714. * Converts `string`, as a whole, to lower case just like
  27715. * [String#toLowerCase](https://mdn.io/toLowerCase).
  27716. *
  27717. * @static
  27718. * @memberOf _
  27719. * @since 4.0.0
  27720. * @category String
  27721. * @param {string} [string=''] The string to convert.
  27722. * @returns {string} Returns the lower cased string.
  27723. * @example
  27724. *
  27725. * _.toLower('--Foo-Bar--');
  27726. * // => '--foo-bar--'
  27727. *
  27728. * _.toLower('fooBar');
  27729. * // => 'foobar'
  27730. *
  27731. * _.toLower('__FOO_BAR__');
  27732. * // => '__foo_bar__'
  27733. */
  27734. function toLower(value) {
  27735. return toString(value).toLowerCase();
  27736. }
  27737. /**
  27738. * Converts `string`, as a whole, to upper case just like
  27739. * [String#toUpperCase](https://mdn.io/toUpperCase).
  27740. *
  27741. * @static
  27742. * @memberOf _
  27743. * @since 4.0.0
  27744. * @category String
  27745. * @param {string} [string=''] The string to convert.
  27746. * @returns {string} Returns the upper cased string.
  27747. * @example
  27748. *
  27749. * _.toUpper('--foo-bar--');
  27750. * // => '--FOO-BAR--'
  27751. *
  27752. * _.toUpper('fooBar');
  27753. * // => 'FOOBAR'
  27754. *
  27755. * _.toUpper('__foo_bar__');
  27756. * // => '__FOO_BAR__'
  27757. */
  27758. function toUpper(value) {
  27759. return toString(value).toUpperCase();
  27760. }
  27761. /**
  27762. * Removes leading and trailing whitespace or specified characters from `string`.
  27763. *
  27764. * @static
  27765. * @memberOf _
  27766. * @since 3.0.0
  27767. * @category String
  27768. * @param {string} [string=''] The string to trim.
  27769. * @param {string} [chars=whitespace] The characters to trim.
  27770. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27771. * @returns {string} Returns the trimmed string.
  27772. * @example
  27773. *
  27774. * _.trim(' abc ');
  27775. * // => 'abc'
  27776. *
  27777. * _.trim('-_-abc-_-', '_-');
  27778. * // => 'abc'
  27779. *
  27780. * _.map([' foo ', ' bar '], _.trim);
  27781. * // => ['foo', 'bar']
  27782. */
  27783. function trim(string, chars, guard) {
  27784. string = toString(string);
  27785. if (string && (guard || chars === undefined)) {
  27786. return string.replace(reTrim, '');
  27787. }
  27788. if (!string || !(chars = baseToString(chars))) {
  27789. return string;
  27790. }
  27791. var strSymbols = stringToArray(string),
  27792. chrSymbols = stringToArray(chars),
  27793. start = charsStartIndex(strSymbols, chrSymbols),
  27794. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  27795. return castSlice(strSymbols, start, end).join('');
  27796. }
  27797. /**
  27798. * Removes trailing whitespace or specified characters from `string`.
  27799. *
  27800. * @static
  27801. * @memberOf _
  27802. * @since 4.0.0
  27803. * @category String
  27804. * @param {string} [string=''] The string to trim.
  27805. * @param {string} [chars=whitespace] The characters to trim.
  27806. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27807. * @returns {string} Returns the trimmed string.
  27808. * @example
  27809. *
  27810. * _.trimEnd(' abc ');
  27811. * // => ' abc'
  27812. *
  27813. * _.trimEnd('-_-abc-_-', '_-');
  27814. * // => '-_-abc'
  27815. */
  27816. function trimEnd(string, chars, guard) {
  27817. string = toString(string);
  27818. if (string && (guard || chars === undefined)) {
  27819. return string.replace(reTrimEnd, '');
  27820. }
  27821. if (!string || !(chars = baseToString(chars))) {
  27822. return string;
  27823. }
  27824. var strSymbols = stringToArray(string),
  27825. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  27826. return castSlice(strSymbols, 0, end).join('');
  27827. }
  27828. /**
  27829. * Removes leading whitespace or specified characters from `string`.
  27830. *
  27831. * @static
  27832. * @memberOf _
  27833. * @since 4.0.0
  27834. * @category String
  27835. * @param {string} [string=''] The string to trim.
  27836. * @param {string} [chars=whitespace] The characters to trim.
  27837. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27838. * @returns {string} Returns the trimmed string.
  27839. * @example
  27840. *
  27841. * _.trimStart(' abc ');
  27842. * // => 'abc '
  27843. *
  27844. * _.trimStart('-_-abc-_-', '_-');
  27845. * // => 'abc-_-'
  27846. */
  27847. function trimStart(string, chars, guard) {
  27848. string = toString(string);
  27849. if (string && (guard || chars === undefined)) {
  27850. return string.replace(reTrimStart, '');
  27851. }
  27852. if (!string || !(chars = baseToString(chars))) {
  27853. return string;
  27854. }
  27855. var strSymbols = stringToArray(string),
  27856. start = charsStartIndex(strSymbols, stringToArray(chars));
  27857. return castSlice(strSymbols, start).join('');
  27858. }
  27859. /**
  27860. * Truncates `string` if it's longer than the given maximum string length.
  27861. * The last characters of the truncated string are replaced with the omission
  27862. * string which defaults to "...".
  27863. *
  27864. * @static
  27865. * @memberOf _
  27866. * @since 4.0.0
  27867. * @category String
  27868. * @param {string} [string=''] The string to truncate.
  27869. * @param {Object} [options={}] The options object.
  27870. * @param {number} [options.length=30] The maximum string length.
  27871. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  27872. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  27873. * @returns {string} Returns the truncated string.
  27874. * @example
  27875. *
  27876. * _.truncate('hi-diddly-ho there, neighborino');
  27877. * // => 'hi-diddly-ho there, neighbo...'
  27878. *
  27879. * _.truncate('hi-diddly-ho there, neighborino', {
  27880. * 'length': 24,
  27881. * 'separator': ' '
  27882. * });
  27883. * // => 'hi-diddly-ho there,...'
  27884. *
  27885. * _.truncate('hi-diddly-ho there, neighborino', {
  27886. * 'length': 24,
  27887. * 'separator': /,? +/
  27888. * });
  27889. * // => 'hi-diddly-ho there...'
  27890. *
  27891. * _.truncate('hi-diddly-ho there, neighborino', {
  27892. * 'omission': ' [...]'
  27893. * });
  27894. * // => 'hi-diddly-ho there, neig [...]'
  27895. */
  27896. function truncate(string, options) {
  27897. var length = DEFAULT_TRUNC_LENGTH,
  27898. omission = DEFAULT_TRUNC_OMISSION;
  27899. if (isObject(options)) {
  27900. var separator = 'separator' in options ? options.separator : separator;
  27901. length = 'length' in options ? toInteger(options.length) : length;
  27902. omission = 'omission' in options ? baseToString(options.omission) : omission;
  27903. }
  27904. string = toString(string);
  27905. var strLength = string.length;
  27906. if (hasUnicode(string)) {
  27907. var strSymbols = stringToArray(string);
  27908. strLength = strSymbols.length;
  27909. }
  27910. if (length >= strLength) {
  27911. return string;
  27912. }
  27913. var end = length - stringSize(omission);
  27914. if (end < 1) {
  27915. return omission;
  27916. }
  27917. var result = strSymbols
  27918. ? castSlice(strSymbols, 0, end).join('')
  27919. : string.slice(0, end);
  27920. if (separator === undefined) {
  27921. return result + omission;
  27922. }
  27923. if (strSymbols) {
  27924. end += (result.length - end);
  27925. }
  27926. if (isRegExp(separator)) {
  27927. if (string.slice(end).search(separator)) {
  27928. var match,
  27929. substring = result;
  27930. if (!separator.global) {
  27931. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  27932. }
  27933. separator.lastIndex = 0;
  27934. while ((match = separator.exec(substring))) {
  27935. var newEnd = match.index;
  27936. }
  27937. result = result.slice(0, newEnd === undefined ? end : newEnd);
  27938. }
  27939. } else if (string.indexOf(baseToString(separator), end) != end) {
  27940. var index = result.lastIndexOf(separator);
  27941. if (index > -1) {
  27942. result = result.slice(0, index);
  27943. }
  27944. }
  27945. return result + omission;
  27946. }
  27947. /**
  27948. * The inverse of `_.escape`; this method converts the HTML entities
  27949. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  27950. * their corresponding characters.
  27951. *
  27952. * **Note:** No other HTML entities are unescaped. To unescape additional
  27953. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  27954. *
  27955. * @static
  27956. * @memberOf _
  27957. * @since 0.6.0
  27958. * @category String
  27959. * @param {string} [string=''] The string to unescape.
  27960. * @returns {string} Returns the unescaped string.
  27961. * @example
  27962. *
  27963. * _.unescape('fred, barney, &amp; pebbles');
  27964. * // => 'fred, barney, & pebbles'
  27965. */
  27966. function unescape(string) {
  27967. string = toString(string);
  27968. return (string && reHasEscapedHtml.test(string))
  27969. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  27970. : string;
  27971. }
  27972. /**
  27973. * Converts `string`, as space separated words, to upper case.
  27974. *
  27975. * @static
  27976. * @memberOf _
  27977. * @since 4.0.0
  27978. * @category String
  27979. * @param {string} [string=''] The string to convert.
  27980. * @returns {string} Returns the upper cased string.
  27981. * @example
  27982. *
  27983. * _.upperCase('--foo-bar');
  27984. * // => 'FOO BAR'
  27985. *
  27986. * _.upperCase('fooBar');
  27987. * // => 'FOO BAR'
  27988. *
  27989. * _.upperCase('__foo_bar__');
  27990. * // => 'FOO BAR'
  27991. */
  27992. var upperCase = createCompounder(function(result, word, index) {
  27993. return result + (index ? ' ' : '') + word.toUpperCase();
  27994. });
  27995. /**
  27996. * Converts the first character of `string` to upper case.
  27997. *
  27998. * @static
  27999. * @memberOf _
  28000. * @since 4.0.0
  28001. * @category String
  28002. * @param {string} [string=''] The string to convert.
  28003. * @returns {string} Returns the converted string.
  28004. * @example
  28005. *
  28006. * _.upperFirst('fred');
  28007. * // => 'Fred'
  28008. *
  28009. * _.upperFirst('FRED');
  28010. * // => 'FRED'
  28011. */
  28012. var upperFirst = createCaseFirst('toUpperCase');
  28013. /**
  28014. * Splits `string` into an array of its words.
  28015. *
  28016. * @static
  28017. * @memberOf _
  28018. * @since 3.0.0
  28019. * @category String
  28020. * @param {string} [string=''] The string to inspect.
  28021. * @param {RegExp|string} [pattern] The pattern to match words.
  28022. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  28023. * @returns {Array} Returns the words of `string`.
  28024. * @example
  28025. *
  28026. * _.words('fred, barney, & pebbles');
  28027. * // => ['fred', 'barney', 'pebbles']
  28028. *
  28029. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  28030. * // => ['fred', 'barney', '&', 'pebbles']
  28031. */
  28032. function words(string, pattern, guard) {
  28033. string = toString(string);
  28034. pattern = guard ? undefined : pattern;
  28035. if (pattern === undefined) {
  28036. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  28037. }
  28038. return string.match(pattern) || [];
  28039. }
  28040. /*------------------------------------------------------------------------*/
  28041. /**
  28042. * Attempts to invoke `func`, returning either the result or the caught error
  28043. * object. Any additional arguments are provided to `func` when it's invoked.
  28044. *
  28045. * @static
  28046. * @memberOf _
  28047. * @since 3.0.0
  28048. * @category Util
  28049. * @param {Function} func The function to attempt.
  28050. * @param {...*} [args] The arguments to invoke `func` with.
  28051. * @returns {*} Returns the `func` result or error object.
  28052. * @example
  28053. *
  28054. * // Avoid throwing errors for invalid selectors.
  28055. * var elements = _.attempt(function(selector) {
  28056. * return document.querySelectorAll(selector);
  28057. * }, '>_>');
  28058. *
  28059. * if (_.isError(elements)) {
  28060. * elements = [];
  28061. * }
  28062. */
  28063. var attempt = baseRest(function(func, args) {
  28064. try {
  28065. return apply(func, undefined, args);
  28066. } catch (e) {
  28067. return isError(e) ? e : new Error(e);
  28068. }
  28069. });
  28070. /**
  28071. * Binds methods of an object to the object itself, overwriting the existing
  28072. * method.
  28073. *
  28074. * **Note:** This method doesn't set the "length" property of bound functions.
  28075. *
  28076. * @static
  28077. * @since 0.1.0
  28078. * @memberOf _
  28079. * @category Util
  28080. * @param {Object} object The object to bind and assign the bound methods to.
  28081. * @param {...(string|string[])} methodNames The object method names to bind.
  28082. * @returns {Object} Returns `object`.
  28083. * @example
  28084. *
  28085. * var view = {
  28086. * 'label': 'docs',
  28087. * 'click': function() {
  28088. * console.log('clicked ' + this.label);
  28089. * }
  28090. * };
  28091. *
  28092. * _.bindAll(view, ['click']);
  28093. * jQuery(element).on('click', view.click);
  28094. * // => Logs 'clicked docs' when clicked.
  28095. */
  28096. var bindAll = flatRest(function(object, methodNames) {
  28097. arrayEach(methodNames, function(key) {
  28098. key = toKey(key);
  28099. baseAssignValue(object, key, bind(object[key], object));
  28100. });
  28101. return object;
  28102. });
  28103. /**
  28104. * Creates a function that iterates over `pairs` and invokes the corresponding
  28105. * function of the first predicate to return truthy. The predicate-function
  28106. * pairs are invoked with the `this` binding and arguments of the created
  28107. * function.
  28108. *
  28109. * @static
  28110. * @memberOf _
  28111. * @since 4.0.0
  28112. * @category Util
  28113. * @param {Array} pairs The predicate-function pairs.
  28114. * @returns {Function} Returns the new composite function.
  28115. * @example
  28116. *
  28117. * var func = _.cond([
  28118. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  28119. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  28120. * [_.stubTrue, _.constant('no match')]
  28121. * ]);
  28122. *
  28123. * func({ 'a': 1, 'b': 2 });
  28124. * // => 'matches A'
  28125. *
  28126. * func({ 'a': 0, 'b': 1 });
  28127. * // => 'matches B'
  28128. *
  28129. * func({ 'a': '1', 'b': '2' });
  28130. * // => 'no match'
  28131. */
  28132. function cond(pairs) {
  28133. var length = pairs == null ? 0 : pairs.length,
  28134. toIteratee = getIteratee();
  28135. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  28136. if (typeof pair[1] != 'function') {
  28137. throw new TypeError(FUNC_ERROR_TEXT);
  28138. }
  28139. return [toIteratee(pair[0]), pair[1]];
  28140. });
  28141. return baseRest(function(args) {
  28142. var index = -1;
  28143. while (++index < length) {
  28144. var pair = pairs[index];
  28145. if (apply(pair[0], this, args)) {
  28146. return apply(pair[1], this, args);
  28147. }
  28148. }
  28149. });
  28150. }
  28151. /**
  28152. * Creates a function that invokes the predicate properties of `source` with
  28153. * the corresponding property values of a given object, returning `true` if
  28154. * all predicates return truthy, else `false`.
  28155. *
  28156. * **Note:** The created function is equivalent to `_.conformsTo` with
  28157. * `source` partially applied.
  28158. *
  28159. * @static
  28160. * @memberOf _
  28161. * @since 4.0.0
  28162. * @category Util
  28163. * @param {Object} source The object of property predicates to conform to.
  28164. * @returns {Function} Returns the new spec function.
  28165. * @example
  28166. *
  28167. * var objects = [
  28168. * { 'a': 2, 'b': 1 },
  28169. * { 'a': 1, 'b': 2 }
  28170. * ];
  28171. *
  28172. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  28173. * // => [{ 'a': 1, 'b': 2 }]
  28174. */
  28175. function conforms(source) {
  28176. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  28177. }
  28178. /**
  28179. * Creates a function that returns `value`.
  28180. *
  28181. * @static
  28182. * @memberOf _
  28183. * @since 2.4.0
  28184. * @category Util
  28185. * @param {*} value The value to return from the new function.
  28186. * @returns {Function} Returns the new constant function.
  28187. * @example
  28188. *
  28189. * var objects = _.times(2, _.constant({ 'a': 1 }));
  28190. *
  28191. * console.log(objects);
  28192. * // => [{ 'a': 1 }, { 'a': 1 }]
  28193. *
  28194. * console.log(objects[0] === objects[1]);
  28195. * // => true
  28196. */
  28197. function constant(value) {
  28198. return function() {
  28199. return value;
  28200. };
  28201. }
  28202. /**
  28203. * Checks `value` to determine whether a default value should be returned in
  28204. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  28205. * or `undefined`.
  28206. *
  28207. * @static
  28208. * @memberOf _
  28209. * @since 4.14.0
  28210. * @category Util
  28211. * @param {*} value The value to check.
  28212. * @param {*} defaultValue The default value.
  28213. * @returns {*} Returns the resolved value.
  28214. * @example
  28215. *
  28216. * _.defaultTo(1, 10);
  28217. * // => 1
  28218. *
  28219. * _.defaultTo(undefined, 10);
  28220. * // => 10
  28221. */
  28222. function defaultTo(value, defaultValue) {
  28223. return (value == null || value !== value) ? defaultValue : value;
  28224. }
  28225. /**
  28226. * Creates a function that returns the result of invoking the given functions
  28227. * with the `this` binding of the created function, where each successive
  28228. * invocation is supplied the return value of the previous.
  28229. *
  28230. * @static
  28231. * @memberOf _
  28232. * @since 3.0.0
  28233. * @category Util
  28234. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  28235. * @returns {Function} Returns the new composite function.
  28236. * @see _.flowRight
  28237. * @example
  28238. *
  28239. * function square(n) {
  28240. * return n * n;
  28241. * }
  28242. *
  28243. * var addSquare = _.flow([_.add, square]);
  28244. * addSquare(1, 2);
  28245. * // => 9
  28246. */
  28247. var flow = createFlow();
  28248. /**
  28249. * This method is like `_.flow` except that it creates a function that
  28250. * invokes the given functions from right to left.
  28251. *
  28252. * @static
  28253. * @since 3.0.0
  28254. * @memberOf _
  28255. * @category Util
  28256. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  28257. * @returns {Function} Returns the new composite function.
  28258. * @see _.flow
  28259. * @example
  28260. *
  28261. * function square(n) {
  28262. * return n * n;
  28263. * }
  28264. *
  28265. * var addSquare = _.flowRight([square, _.add]);
  28266. * addSquare(1, 2);
  28267. * // => 9
  28268. */
  28269. var flowRight = createFlow(true);
  28270. /**
  28271. * This method returns the first argument it receives.
  28272. *
  28273. * @static
  28274. * @since 0.1.0
  28275. * @memberOf _
  28276. * @category Util
  28277. * @param {*} value Any value.
  28278. * @returns {*} Returns `value`.
  28279. * @example
  28280. *
  28281. * var object = { 'a': 1 };
  28282. *
  28283. * console.log(_.identity(object) === object);
  28284. * // => true
  28285. */
  28286. function identity(value) {
  28287. return value;
  28288. }
  28289. /**
  28290. * Creates a function that invokes `func` with the arguments of the created
  28291. * function. If `func` is a property name, the created function returns the
  28292. * property value for a given element. If `func` is an array or object, the
  28293. * created function returns `true` for elements that contain the equivalent
  28294. * source properties, otherwise it returns `false`.
  28295. *
  28296. * @static
  28297. * @since 4.0.0
  28298. * @memberOf _
  28299. * @category Util
  28300. * @param {*} [func=_.identity] The value to convert to a callback.
  28301. * @returns {Function} Returns the callback.
  28302. * @example
  28303. *
  28304. * var users = [
  28305. * { 'user': 'barney', 'age': 36, 'active': true },
  28306. * { 'user': 'fred', 'age': 40, 'active': false }
  28307. * ];
  28308. *
  28309. * // The `_.matches` iteratee shorthand.
  28310. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  28311. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  28312. *
  28313. * // The `_.matchesProperty` iteratee shorthand.
  28314. * _.filter(users, _.iteratee(['user', 'fred']));
  28315. * // => [{ 'user': 'fred', 'age': 40 }]
  28316. *
  28317. * // The `_.property` iteratee shorthand.
  28318. * _.map(users, _.iteratee('user'));
  28319. * // => ['barney', 'fred']
  28320. *
  28321. * // Create custom iteratee shorthands.
  28322. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  28323. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  28324. * return func.test(string);
  28325. * };
  28326. * });
  28327. *
  28328. * _.filter(['abc', 'def'], /ef/);
  28329. * // => ['def']
  28330. */
  28331. function iteratee(func) {
  28332. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  28333. }
  28334. /**
  28335. * Creates a function that performs a partial deep comparison between a given
  28336. * object and `source`, returning `true` if the given object has equivalent
  28337. * property values, else `false`.
  28338. *
  28339. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  28340. * partially applied.
  28341. *
  28342. * Partial comparisons will match empty array and empty object `source`
  28343. * values against any array or object value, respectively. See `_.isEqual`
  28344. * for a list of supported value comparisons.
  28345. *
  28346. * @static
  28347. * @memberOf _
  28348. * @since 3.0.0
  28349. * @category Util
  28350. * @param {Object} source The object of property values to match.
  28351. * @returns {Function} Returns the new spec function.
  28352. * @example
  28353. *
  28354. * var objects = [
  28355. * { 'a': 1, 'b': 2, 'c': 3 },
  28356. * { 'a': 4, 'b': 5, 'c': 6 }
  28357. * ];
  28358. *
  28359. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  28360. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  28361. */
  28362. function matches(source) {
  28363. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  28364. }
  28365. /**
  28366. * Creates a function that performs a partial deep comparison between the
  28367. * value at `path` of a given object to `srcValue`, returning `true` if the
  28368. * object value is equivalent, else `false`.
  28369. *
  28370. * **Note:** Partial comparisons will match empty array and empty object
  28371. * `srcValue` values against any array or object value, respectively. See
  28372. * `_.isEqual` for a list of supported value comparisons.
  28373. *
  28374. * @static
  28375. * @memberOf _
  28376. * @since 3.2.0
  28377. * @category Util
  28378. * @param {Array|string} path The path of the property to get.
  28379. * @param {*} srcValue The value to match.
  28380. * @returns {Function} Returns the new spec function.
  28381. * @example
  28382. *
  28383. * var objects = [
  28384. * { 'a': 1, 'b': 2, 'c': 3 },
  28385. * { 'a': 4, 'b': 5, 'c': 6 }
  28386. * ];
  28387. *
  28388. * _.find(objects, _.matchesProperty('a', 4));
  28389. * // => { 'a': 4, 'b': 5, 'c': 6 }
  28390. */
  28391. function matchesProperty(path, srcValue) {
  28392. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  28393. }
  28394. /**
  28395. * Creates a function that invokes the method at `path` of a given object.
  28396. * Any additional arguments are provided to the invoked method.
  28397. *
  28398. * @static
  28399. * @memberOf _
  28400. * @since 3.7.0
  28401. * @category Util
  28402. * @param {Array|string} path The path of the method to invoke.
  28403. * @param {...*} [args] The arguments to invoke the method with.
  28404. * @returns {Function} Returns the new invoker function.
  28405. * @example
  28406. *
  28407. * var objects = [
  28408. * { 'a': { 'b': _.constant(2) } },
  28409. * { 'a': { 'b': _.constant(1) } }
  28410. * ];
  28411. *
  28412. * _.map(objects, _.method('a.b'));
  28413. * // => [2, 1]
  28414. *
  28415. * _.map(objects, _.method(['a', 'b']));
  28416. * // => [2, 1]
  28417. */
  28418. var method = baseRest(function(path, args) {
  28419. return function(object) {
  28420. return baseInvoke(object, path, args);
  28421. };
  28422. });
  28423. /**
  28424. * The opposite of `_.method`; this method creates a function that invokes
  28425. * the method at a given path of `object`. Any additional arguments are
  28426. * provided to the invoked method.
  28427. *
  28428. * @static
  28429. * @memberOf _
  28430. * @since 3.7.0
  28431. * @category Util
  28432. * @param {Object} object The object to query.
  28433. * @param {...*} [args] The arguments to invoke the method with.
  28434. * @returns {Function} Returns the new invoker function.
  28435. * @example
  28436. *
  28437. * var array = _.times(3, _.constant),
  28438. * object = { 'a': array, 'b': array, 'c': array };
  28439. *
  28440. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  28441. * // => [2, 0]
  28442. *
  28443. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  28444. * // => [2, 0]
  28445. */
  28446. var methodOf = baseRest(function(object, args) {
  28447. return function(path) {
  28448. return baseInvoke(object, path, args);
  28449. };
  28450. });
  28451. /**
  28452. * Adds all own enumerable string keyed function properties of a source
  28453. * object to the destination object. If `object` is a function, then methods
  28454. * are added to its prototype as well.
  28455. *
  28456. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  28457. * avoid conflicts caused by modifying the original.
  28458. *
  28459. * @static
  28460. * @since 0.1.0
  28461. * @memberOf _
  28462. * @category Util
  28463. * @param {Function|Object} [object=lodash] The destination object.
  28464. * @param {Object} source The object of functions to add.
  28465. * @param {Object} [options={}] The options object.
  28466. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  28467. * @returns {Function|Object} Returns `object`.
  28468. * @example
  28469. *
  28470. * function vowels(string) {
  28471. * return _.filter(string, function(v) {
  28472. * return /[aeiou]/i.test(v);
  28473. * });
  28474. * }
  28475. *
  28476. * _.mixin({ 'vowels': vowels });
  28477. * _.vowels('fred');
  28478. * // => ['e']
  28479. *
  28480. * _('fred').vowels().value();
  28481. * // => ['e']
  28482. *
  28483. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  28484. * _('fred').vowels();
  28485. * // => ['e']
  28486. */
  28487. function mixin(object, source, options) {
  28488. var props = keys(source),
  28489. methodNames = baseFunctions(source, props);
  28490. if (options == null &&
  28491. !(isObject(source) && (methodNames.length || !props.length))) {
  28492. options = source;
  28493. source = object;
  28494. object = this;
  28495. methodNames = baseFunctions(source, keys(source));
  28496. }
  28497. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  28498. isFunc = isFunction(object);
  28499. arrayEach(methodNames, function(methodName) {
  28500. var func = source[methodName];
  28501. object[methodName] = func;
  28502. if (isFunc) {
  28503. object.prototype[methodName] = function() {
  28504. var chainAll = this.__chain__;
  28505. if (chain || chainAll) {
  28506. var result = object(this.__wrapped__),
  28507. actions = result.__actions__ = copyArray(this.__actions__);
  28508. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  28509. result.__chain__ = chainAll;
  28510. return result;
  28511. }
  28512. return func.apply(object, arrayPush([this.value()], arguments));
  28513. };
  28514. }
  28515. });
  28516. return object;
  28517. }
  28518. /**
  28519. * Reverts the `_` variable to its previous value and returns a reference to
  28520. * the `lodash` function.
  28521. *
  28522. * @static
  28523. * @since 0.1.0
  28524. * @memberOf _
  28525. * @category Util
  28526. * @returns {Function} Returns the `lodash` function.
  28527. * @example
  28528. *
  28529. * var lodash = _.noConflict();
  28530. */
  28531. function noConflict() {
  28532. if (root._ === this) {
  28533. root._ = oldDash;
  28534. }
  28535. return this;
  28536. }
  28537. /**
  28538. * This method returns `undefined`.
  28539. *
  28540. * @static
  28541. * @memberOf _
  28542. * @since 2.3.0
  28543. * @category Util
  28544. * @example
  28545. *
  28546. * _.times(2, _.noop);
  28547. * // => [undefined, undefined]
  28548. */
  28549. function noop() {
  28550. // No operation performed.
  28551. }
  28552. /**
  28553. * Creates a function that gets the argument at index `n`. If `n` is negative,
  28554. * the nth argument from the end is returned.
  28555. *
  28556. * @static
  28557. * @memberOf _
  28558. * @since 4.0.0
  28559. * @category Util
  28560. * @param {number} [n=0] The index of the argument to return.
  28561. * @returns {Function} Returns the new pass-thru function.
  28562. * @example
  28563. *
  28564. * var func = _.nthArg(1);
  28565. * func('a', 'b', 'c', 'd');
  28566. * // => 'b'
  28567. *
  28568. * var func = _.nthArg(-2);
  28569. * func('a', 'b', 'c', 'd');
  28570. * // => 'c'
  28571. */
  28572. function nthArg(n) {
  28573. n = toInteger(n);
  28574. return baseRest(function(args) {
  28575. return baseNth(args, n);
  28576. });
  28577. }
  28578. /**
  28579. * Creates a function that invokes `iteratees` with the arguments it receives
  28580. * and returns their results.
  28581. *
  28582. * @static
  28583. * @memberOf _
  28584. * @since 4.0.0
  28585. * @category Util
  28586. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  28587. * The iteratees to invoke.
  28588. * @returns {Function} Returns the new function.
  28589. * @example
  28590. *
  28591. * var func = _.over([Math.max, Math.min]);
  28592. *
  28593. * func(1, 2, 3, 4);
  28594. * // => [4, 1]
  28595. */
  28596. var over = createOver(arrayMap);
  28597. /**
  28598. * Creates a function that checks if **all** of the `predicates` return
  28599. * truthy when invoked with the arguments it receives.
  28600. *
  28601. * @static
  28602. * @memberOf _
  28603. * @since 4.0.0
  28604. * @category Util
  28605. * @param {...(Function|Function[])} [predicates=[_.identity]]
  28606. * The predicates to check.
  28607. * @returns {Function} Returns the new function.
  28608. * @example
  28609. *
  28610. * var func = _.overEvery([Boolean, isFinite]);
  28611. *
  28612. * func('1');
  28613. * // => true
  28614. *
  28615. * func(null);
  28616. * // => false
  28617. *
  28618. * func(NaN);
  28619. * // => false
  28620. */
  28621. var overEvery = createOver(arrayEvery);
  28622. /**
  28623. * Creates a function that checks if **any** of the `predicates` return
  28624. * truthy when invoked with the arguments it receives.
  28625. *
  28626. * @static
  28627. * @memberOf _
  28628. * @since 4.0.0
  28629. * @category Util
  28630. * @param {...(Function|Function[])} [predicates=[_.identity]]
  28631. * The predicates to check.
  28632. * @returns {Function} Returns the new function.
  28633. * @example
  28634. *
  28635. * var func = _.overSome([Boolean, isFinite]);
  28636. *
  28637. * func('1');
  28638. * // => true
  28639. *
  28640. * func(null);
  28641. * // => true
  28642. *
  28643. * func(NaN);
  28644. * // => false
  28645. */
  28646. var overSome = createOver(arraySome);
  28647. /**
  28648. * Creates a function that returns the value at `path` of a given object.
  28649. *
  28650. * @static
  28651. * @memberOf _
  28652. * @since 2.4.0
  28653. * @category Util
  28654. * @param {Array|string} path The path of the property to get.
  28655. * @returns {Function} Returns the new accessor function.
  28656. * @example
  28657. *
  28658. * var objects = [
  28659. * { 'a': { 'b': 2 } },
  28660. * { 'a': { 'b': 1 } }
  28661. * ];
  28662. *
  28663. * _.map(objects, _.property('a.b'));
  28664. * // => [2, 1]
  28665. *
  28666. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  28667. * // => [1, 2]
  28668. */
  28669. function property(path) {
  28670. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  28671. }
  28672. /**
  28673. * The opposite of `_.property`; this method creates a function that returns
  28674. * the value at a given path of `object`.
  28675. *
  28676. * @static
  28677. * @memberOf _
  28678. * @since 3.0.0
  28679. * @category Util
  28680. * @param {Object} object The object to query.
  28681. * @returns {Function} Returns the new accessor function.
  28682. * @example
  28683. *
  28684. * var array = [0, 1, 2],
  28685. * object = { 'a': array, 'b': array, 'c': array };
  28686. *
  28687. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  28688. * // => [2, 0]
  28689. *
  28690. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  28691. * // => [2, 0]
  28692. */
  28693. function propertyOf(object) {
  28694. return function(path) {
  28695. return object == null ? undefined : baseGet(object, path);
  28696. };
  28697. }
  28698. /**
  28699. * Creates an array of numbers (positive and/or negative) progressing from
  28700. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  28701. * `start` is specified without an `end` or `step`. If `end` is not specified,
  28702. * it's set to `start` with `start` then set to `0`.
  28703. *
  28704. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  28705. * floating-point values which can produce unexpected results.
  28706. *
  28707. * @static
  28708. * @since 0.1.0
  28709. * @memberOf _
  28710. * @category Util
  28711. * @param {number} [start=0] The start of the range.
  28712. * @param {number} end The end of the range.
  28713. * @param {number} [step=1] The value to increment or decrement by.
  28714. * @returns {Array} Returns the range of numbers.
  28715. * @see _.inRange, _.rangeRight
  28716. * @example
  28717. *
  28718. * _.range(4);
  28719. * // => [0, 1, 2, 3]
  28720. *
  28721. * _.range(-4);
  28722. * // => [0, -1, -2, -3]
  28723. *
  28724. * _.range(1, 5);
  28725. * // => [1, 2, 3, 4]
  28726. *
  28727. * _.range(0, 20, 5);
  28728. * // => [0, 5, 10, 15]
  28729. *
  28730. * _.range(0, -4, -1);
  28731. * // => [0, -1, -2, -3]
  28732. *
  28733. * _.range(1, 4, 0);
  28734. * // => [1, 1, 1]
  28735. *
  28736. * _.range(0);
  28737. * // => []
  28738. */
  28739. var range = createRange();
  28740. /**
  28741. * This method is like `_.range` except that it populates values in
  28742. * descending order.
  28743. *
  28744. * @static
  28745. * @memberOf _
  28746. * @since 4.0.0
  28747. * @category Util
  28748. * @param {number} [start=0] The start of the range.
  28749. * @param {number} end The end of the range.
  28750. * @param {number} [step=1] The value to increment or decrement by.
  28751. * @returns {Array} Returns the range of numbers.
  28752. * @see _.inRange, _.range
  28753. * @example
  28754. *
  28755. * _.rangeRight(4);
  28756. * // => [3, 2, 1, 0]
  28757. *
  28758. * _.rangeRight(-4);
  28759. * // => [-3, -2, -1, 0]
  28760. *
  28761. * _.rangeRight(1, 5);
  28762. * // => [4, 3, 2, 1]
  28763. *
  28764. * _.rangeRight(0, 20, 5);
  28765. * // => [15, 10, 5, 0]
  28766. *
  28767. * _.rangeRight(0, -4, -1);
  28768. * // => [-3, -2, -1, 0]
  28769. *
  28770. * _.rangeRight(1, 4, 0);
  28771. * // => [1, 1, 1]
  28772. *
  28773. * _.rangeRight(0);
  28774. * // => []
  28775. */
  28776. var rangeRight = createRange(true);
  28777. /**
  28778. * This method returns a new empty array.
  28779. *
  28780. * @static
  28781. * @memberOf _
  28782. * @since 4.13.0
  28783. * @category Util
  28784. * @returns {Array} Returns the new empty array.
  28785. * @example
  28786. *
  28787. * var arrays = _.times(2, _.stubArray);
  28788. *
  28789. * console.log(arrays);
  28790. * // => [[], []]
  28791. *
  28792. * console.log(arrays[0] === arrays[1]);
  28793. * // => false
  28794. */
  28795. function stubArray() {
  28796. return [];
  28797. }
  28798. /**
  28799. * This method returns `false`.
  28800. *
  28801. * @static
  28802. * @memberOf _
  28803. * @since 4.13.0
  28804. * @category Util
  28805. * @returns {boolean} Returns `false`.
  28806. * @example
  28807. *
  28808. * _.times(2, _.stubFalse);
  28809. * // => [false, false]
  28810. */
  28811. function stubFalse() {
  28812. return false;
  28813. }
  28814. /**
  28815. * This method returns a new empty object.
  28816. *
  28817. * @static
  28818. * @memberOf _
  28819. * @since 4.13.0
  28820. * @category Util
  28821. * @returns {Object} Returns the new empty object.
  28822. * @example
  28823. *
  28824. * var objects = _.times(2, _.stubObject);
  28825. *
  28826. * console.log(objects);
  28827. * // => [{}, {}]
  28828. *
  28829. * console.log(objects[0] === objects[1]);
  28830. * // => false
  28831. */
  28832. function stubObject() {
  28833. return {};
  28834. }
  28835. /**
  28836. * This method returns an empty string.
  28837. *
  28838. * @static
  28839. * @memberOf _
  28840. * @since 4.13.0
  28841. * @category Util
  28842. * @returns {string} Returns the empty string.
  28843. * @example
  28844. *
  28845. * _.times(2, _.stubString);
  28846. * // => ['', '']
  28847. */
  28848. function stubString() {
  28849. return '';
  28850. }
  28851. /**
  28852. * This method returns `true`.
  28853. *
  28854. * @static
  28855. * @memberOf _
  28856. * @since 4.13.0
  28857. * @category Util
  28858. * @returns {boolean} Returns `true`.
  28859. * @example
  28860. *
  28861. * _.times(2, _.stubTrue);
  28862. * // => [true, true]
  28863. */
  28864. function stubTrue() {
  28865. return true;
  28866. }
  28867. /**
  28868. * Invokes the iteratee `n` times, returning an array of the results of
  28869. * each invocation. The iteratee is invoked with one argument; (index).
  28870. *
  28871. * @static
  28872. * @since 0.1.0
  28873. * @memberOf _
  28874. * @category Util
  28875. * @param {number} n The number of times to invoke `iteratee`.
  28876. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28877. * @returns {Array} Returns the array of results.
  28878. * @example
  28879. *
  28880. * _.times(3, String);
  28881. * // => ['0', '1', '2']
  28882. *
  28883. * _.times(4, _.constant(0));
  28884. * // => [0, 0, 0, 0]
  28885. */
  28886. function times(n, iteratee) {
  28887. n = toInteger(n);
  28888. if (n < 1 || n > MAX_SAFE_INTEGER) {
  28889. return [];
  28890. }
  28891. var index = MAX_ARRAY_LENGTH,
  28892. length = nativeMin(n, MAX_ARRAY_LENGTH);
  28893. iteratee = getIteratee(iteratee);
  28894. n -= MAX_ARRAY_LENGTH;
  28895. var result = baseTimes(length, iteratee);
  28896. while (++index < n) {
  28897. iteratee(index);
  28898. }
  28899. return result;
  28900. }
  28901. /**
  28902. * Converts `value` to a property path array.
  28903. *
  28904. * @static
  28905. * @memberOf _
  28906. * @since 4.0.0
  28907. * @category Util
  28908. * @param {*} value The value to convert.
  28909. * @returns {Array} Returns the new property path array.
  28910. * @example
  28911. *
  28912. * _.toPath('a.b.c');
  28913. * // => ['a', 'b', 'c']
  28914. *
  28915. * _.toPath('a[0].b.c');
  28916. * // => ['a', '0', 'b', 'c']
  28917. */
  28918. function toPath(value) {
  28919. if (isArray(value)) {
  28920. return arrayMap(value, toKey);
  28921. }
  28922. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  28923. }
  28924. /**
  28925. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  28926. *
  28927. * @static
  28928. * @since 0.1.0
  28929. * @memberOf _
  28930. * @category Util
  28931. * @param {string} [prefix=''] The value to prefix the ID with.
  28932. * @returns {string} Returns the unique ID.
  28933. * @example
  28934. *
  28935. * _.uniqueId('contact_');
  28936. * // => 'contact_104'
  28937. *
  28938. * _.uniqueId();
  28939. * // => '105'
  28940. */
  28941. function uniqueId(prefix) {
  28942. var id = ++idCounter;
  28943. return toString(prefix) + id;
  28944. }
  28945. /*------------------------------------------------------------------------*/
  28946. /**
  28947. * Adds two numbers.
  28948. *
  28949. * @static
  28950. * @memberOf _
  28951. * @since 3.4.0
  28952. * @category Math
  28953. * @param {number} augend The first number in an addition.
  28954. * @param {number} addend The second number in an addition.
  28955. * @returns {number} Returns the total.
  28956. * @example
  28957. *
  28958. * _.add(6, 4);
  28959. * // => 10
  28960. */
  28961. var add = createMathOperation(function(augend, addend) {
  28962. return augend + addend;
  28963. }, 0);
  28964. /**
  28965. * Computes `number` rounded up to `precision`.
  28966. *
  28967. * @static
  28968. * @memberOf _
  28969. * @since 3.10.0
  28970. * @category Math
  28971. * @param {number} number The number to round up.
  28972. * @param {number} [precision=0] The precision to round up to.
  28973. * @returns {number} Returns the rounded up number.
  28974. * @example
  28975. *
  28976. * _.ceil(4.006);
  28977. * // => 5
  28978. *
  28979. * _.ceil(6.004, 2);
  28980. * // => 6.01
  28981. *
  28982. * _.ceil(6040, -2);
  28983. * // => 6100
  28984. */
  28985. var ceil = createRound('ceil');
  28986. /**
  28987. * Divide two numbers.
  28988. *
  28989. * @static
  28990. * @memberOf _
  28991. * @since 4.7.0
  28992. * @category Math
  28993. * @param {number} dividend The first number in a division.
  28994. * @param {number} divisor The second number in a division.
  28995. * @returns {number} Returns the quotient.
  28996. * @example
  28997. *
  28998. * _.divide(6, 4);
  28999. * // => 1.5
  29000. */
  29001. var divide = createMathOperation(function(dividend, divisor) {
  29002. return dividend / divisor;
  29003. }, 1);
  29004. /**
  29005. * Computes `number` rounded down to `precision`.
  29006. *
  29007. * @static
  29008. * @memberOf _
  29009. * @since 3.10.0
  29010. * @category Math
  29011. * @param {number} number The number to round down.
  29012. * @param {number} [precision=0] The precision to round down to.
  29013. * @returns {number} Returns the rounded down number.
  29014. * @example
  29015. *
  29016. * _.floor(4.006);
  29017. * // => 4
  29018. *
  29019. * _.floor(0.046, 2);
  29020. * // => 0.04
  29021. *
  29022. * _.floor(4060, -2);
  29023. * // => 4000
  29024. */
  29025. var floor = createRound('floor');
  29026. /**
  29027. * Computes the maximum value of `array`. If `array` is empty or falsey,
  29028. * `undefined` is returned.
  29029. *
  29030. * @static
  29031. * @since 0.1.0
  29032. * @memberOf _
  29033. * @category Math
  29034. * @param {Array} array The array to iterate over.
  29035. * @returns {*} Returns the maximum value.
  29036. * @example
  29037. *
  29038. * _.max([4, 2, 8, 6]);
  29039. * // => 8
  29040. *
  29041. * _.max([]);
  29042. * // => undefined
  29043. */
  29044. function max(array) {
  29045. return (array && array.length)
  29046. ? baseExtremum(array, identity, baseGt)
  29047. : undefined;
  29048. }
  29049. /**
  29050. * This method is like `_.max` except that it accepts `iteratee` which is
  29051. * invoked for each element in `array` to generate the criterion by which
  29052. * the value is ranked. The iteratee is invoked with one argument: (value).
  29053. *
  29054. * @static
  29055. * @memberOf _
  29056. * @since 4.0.0
  29057. * @category Math
  29058. * @param {Array} array The array to iterate over.
  29059. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29060. * @returns {*} Returns the maximum value.
  29061. * @example
  29062. *
  29063. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  29064. *
  29065. * _.maxBy(objects, function(o) { return o.n; });
  29066. * // => { 'n': 2 }
  29067. *
  29068. * // The `_.property` iteratee shorthand.
  29069. * _.maxBy(objects, 'n');
  29070. * // => { 'n': 2 }
  29071. */
  29072. function maxBy(array, iteratee) {
  29073. return (array && array.length)
  29074. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  29075. : undefined;
  29076. }
  29077. /**
  29078. * Computes the mean of the values in `array`.
  29079. *
  29080. * @static
  29081. * @memberOf _
  29082. * @since 4.0.0
  29083. * @category Math
  29084. * @param {Array} array The array to iterate over.
  29085. * @returns {number} Returns the mean.
  29086. * @example
  29087. *
  29088. * _.mean([4, 2, 8, 6]);
  29089. * // => 5
  29090. */
  29091. function mean(array) {
  29092. return baseMean(array, identity);
  29093. }
  29094. /**
  29095. * This method is like `_.mean` except that it accepts `iteratee` which is
  29096. * invoked for each element in `array` to generate the value to be averaged.
  29097. * The iteratee is invoked with one argument: (value).
  29098. *
  29099. * @static
  29100. * @memberOf _
  29101. * @since 4.7.0
  29102. * @category Math
  29103. * @param {Array} array The array to iterate over.
  29104. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29105. * @returns {number} Returns the mean.
  29106. * @example
  29107. *
  29108. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  29109. *
  29110. * _.meanBy(objects, function(o) { return o.n; });
  29111. * // => 5
  29112. *
  29113. * // The `_.property` iteratee shorthand.
  29114. * _.meanBy(objects, 'n');
  29115. * // => 5
  29116. */
  29117. function meanBy(array, iteratee) {
  29118. return baseMean(array, getIteratee(iteratee, 2));
  29119. }
  29120. /**
  29121. * Computes the minimum value of `array`. If `array` is empty or falsey,
  29122. * `undefined` is returned.
  29123. *
  29124. * @static
  29125. * @since 0.1.0
  29126. * @memberOf _
  29127. * @category Math
  29128. * @param {Array} array The array to iterate over.
  29129. * @returns {*} Returns the minimum value.
  29130. * @example
  29131. *
  29132. * _.min([4, 2, 8, 6]);
  29133. * // => 2
  29134. *
  29135. * _.min([]);
  29136. * // => undefined
  29137. */
  29138. function min(array) {
  29139. return (array && array.length)
  29140. ? baseExtremum(array, identity, baseLt)
  29141. : undefined;
  29142. }
  29143. /**
  29144. * This method is like `_.min` except that it accepts `iteratee` which is
  29145. * invoked for each element in `array` to generate the criterion by which
  29146. * the value is ranked. The iteratee is invoked with one argument: (value).
  29147. *
  29148. * @static
  29149. * @memberOf _
  29150. * @since 4.0.0
  29151. * @category Math
  29152. * @param {Array} array The array to iterate over.
  29153. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29154. * @returns {*} Returns the minimum value.
  29155. * @example
  29156. *
  29157. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  29158. *
  29159. * _.minBy(objects, function(o) { return o.n; });
  29160. * // => { 'n': 1 }
  29161. *
  29162. * // The `_.property` iteratee shorthand.
  29163. * _.minBy(objects, 'n');
  29164. * // => { 'n': 1 }
  29165. */
  29166. function minBy(array, iteratee) {
  29167. return (array && array.length)
  29168. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  29169. : undefined;
  29170. }
  29171. /**
  29172. * Multiply two numbers.
  29173. *
  29174. * @static
  29175. * @memberOf _
  29176. * @since 4.7.0
  29177. * @category Math
  29178. * @param {number} multiplier The first number in a multiplication.
  29179. * @param {number} multiplicand The second number in a multiplication.
  29180. * @returns {number} Returns the product.
  29181. * @example
  29182. *
  29183. * _.multiply(6, 4);
  29184. * // => 24
  29185. */
  29186. var multiply = createMathOperation(function(multiplier, multiplicand) {
  29187. return multiplier * multiplicand;
  29188. }, 1);
  29189. /**
  29190. * Computes `number` rounded to `precision`.
  29191. *
  29192. * @static
  29193. * @memberOf _
  29194. * @since 3.10.0
  29195. * @category Math
  29196. * @param {number} number The number to round.
  29197. * @param {number} [precision=0] The precision to round to.
  29198. * @returns {number} Returns the rounded number.
  29199. * @example
  29200. *
  29201. * _.round(4.006);
  29202. * // => 4
  29203. *
  29204. * _.round(4.006, 2);
  29205. * // => 4.01
  29206. *
  29207. * _.round(4060, -2);
  29208. * // => 4100
  29209. */
  29210. var round = createRound('round');
  29211. /**
  29212. * Subtract two numbers.
  29213. *
  29214. * @static
  29215. * @memberOf _
  29216. * @since 4.0.0
  29217. * @category Math
  29218. * @param {number} minuend The first number in a subtraction.
  29219. * @param {number} subtrahend The second number in a subtraction.
  29220. * @returns {number} Returns the difference.
  29221. * @example
  29222. *
  29223. * _.subtract(6, 4);
  29224. * // => 2
  29225. */
  29226. var subtract = createMathOperation(function(minuend, subtrahend) {
  29227. return minuend - subtrahend;
  29228. }, 0);
  29229. /**
  29230. * Computes the sum of the values in `array`.
  29231. *
  29232. * @static
  29233. * @memberOf _
  29234. * @since 3.4.0
  29235. * @category Math
  29236. * @param {Array} array The array to iterate over.
  29237. * @returns {number} Returns the sum.
  29238. * @example
  29239. *
  29240. * _.sum([4, 2, 8, 6]);
  29241. * // => 20
  29242. */
  29243. function sum(array) {
  29244. return (array && array.length)
  29245. ? baseSum(array, identity)
  29246. : 0;
  29247. }
  29248. /**
  29249. * This method is like `_.sum` except that it accepts `iteratee` which is
  29250. * invoked for each element in `array` to generate the value to be summed.
  29251. * The iteratee is invoked with one argument: (value).
  29252. *
  29253. * @static
  29254. * @memberOf _
  29255. * @since 4.0.0
  29256. * @category Math
  29257. * @param {Array} array The array to iterate over.
  29258. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29259. * @returns {number} Returns the sum.
  29260. * @example
  29261. *
  29262. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  29263. *
  29264. * _.sumBy(objects, function(o) { return o.n; });
  29265. * // => 20
  29266. *
  29267. * // The `_.property` iteratee shorthand.
  29268. * _.sumBy(objects, 'n');
  29269. * // => 20
  29270. */
  29271. function sumBy(array, iteratee) {
  29272. return (array && array.length)
  29273. ? baseSum(array, getIteratee(iteratee, 2))
  29274. : 0;
  29275. }
  29276. /*------------------------------------------------------------------------*/
  29277. // Add methods that return wrapped values in chain sequences.
  29278. lodash.after = after;
  29279. lodash.ary = ary;
  29280. lodash.assign = assign;
  29281. lodash.assignIn = assignIn;
  29282. lodash.assignInWith = assignInWith;
  29283. lodash.assignWith = assignWith;
  29284. lodash.at = at;
  29285. lodash.before = before;
  29286. lodash.bind = bind;
  29287. lodash.bindAll = bindAll;
  29288. lodash.bindKey = bindKey;
  29289. lodash.castArray = castArray;
  29290. lodash.chain = chain;
  29291. lodash.chunk = chunk;
  29292. lodash.compact = compact;
  29293. lodash.concat = concat;
  29294. lodash.cond = cond;
  29295. lodash.conforms = conforms;
  29296. lodash.constant = constant;
  29297. lodash.countBy = countBy;
  29298. lodash.create = create;
  29299. lodash.curry = curry;
  29300. lodash.curryRight = curryRight;
  29301. lodash.debounce = debounce;
  29302. lodash.defaults = defaults;
  29303. lodash.defaultsDeep = defaultsDeep;
  29304. lodash.defer = defer;
  29305. lodash.delay = delay;
  29306. lodash.difference = difference;
  29307. lodash.differenceBy = differenceBy;
  29308. lodash.differenceWith = differenceWith;
  29309. lodash.drop = drop;
  29310. lodash.dropRight = dropRight;
  29311. lodash.dropRightWhile = dropRightWhile;
  29312. lodash.dropWhile = dropWhile;
  29313. lodash.fill = fill;
  29314. lodash.filter = filter;
  29315. lodash.flatMap = flatMap;
  29316. lodash.flatMapDeep = flatMapDeep;
  29317. lodash.flatMapDepth = flatMapDepth;
  29318. lodash.flatten = flatten;
  29319. lodash.flattenDeep = flattenDeep;
  29320. lodash.flattenDepth = flattenDepth;
  29321. lodash.flip = flip;
  29322. lodash.flow = flow;
  29323. lodash.flowRight = flowRight;
  29324. lodash.fromPairs = fromPairs;
  29325. lodash.functions = functions;
  29326. lodash.functionsIn = functionsIn;
  29327. lodash.groupBy = groupBy;
  29328. lodash.initial = initial;
  29329. lodash.intersection = intersection;
  29330. lodash.intersectionBy = intersectionBy;
  29331. lodash.intersectionWith = intersectionWith;
  29332. lodash.invert = invert;
  29333. lodash.invertBy = invertBy;
  29334. lodash.invokeMap = invokeMap;
  29335. lodash.iteratee = iteratee;
  29336. lodash.keyBy = keyBy;
  29337. lodash.keys = keys;
  29338. lodash.keysIn = keysIn;
  29339. lodash.map = map;
  29340. lodash.mapKeys = mapKeys;
  29341. lodash.mapValues = mapValues;
  29342. lodash.matches = matches;
  29343. lodash.matchesProperty = matchesProperty;
  29344. lodash.memoize = memoize;
  29345. lodash.merge = merge;
  29346. lodash.mergeWith = mergeWith;
  29347. lodash.method = method;
  29348. lodash.methodOf = methodOf;
  29349. lodash.mixin = mixin;
  29350. lodash.negate = negate;
  29351. lodash.nthArg = nthArg;
  29352. lodash.omit = omit;
  29353. lodash.omitBy = omitBy;
  29354. lodash.once = once;
  29355. lodash.orderBy = orderBy;
  29356. lodash.over = over;
  29357. lodash.overArgs = overArgs;
  29358. lodash.overEvery = overEvery;
  29359. lodash.overSome = overSome;
  29360. lodash.partial = partial;
  29361. lodash.partialRight = partialRight;
  29362. lodash.partition = partition;
  29363. lodash.pick = pick;
  29364. lodash.pickBy = pickBy;
  29365. lodash.property = property;
  29366. lodash.propertyOf = propertyOf;
  29367. lodash.pull = pull;
  29368. lodash.pullAll = pullAll;
  29369. lodash.pullAllBy = pullAllBy;
  29370. lodash.pullAllWith = pullAllWith;
  29371. lodash.pullAt = pullAt;
  29372. lodash.range = range;
  29373. lodash.rangeRight = rangeRight;
  29374. lodash.rearg = rearg;
  29375. lodash.reject = reject;
  29376. lodash.remove = remove;
  29377. lodash.rest = rest;
  29378. lodash.reverse = reverse;
  29379. lodash.sampleSize = sampleSize;
  29380. lodash.set = set;
  29381. lodash.setWith = setWith;
  29382. lodash.shuffle = shuffle;
  29383. lodash.slice = slice;
  29384. lodash.sortBy = sortBy;
  29385. lodash.sortedUniq = sortedUniq;
  29386. lodash.sortedUniqBy = sortedUniqBy;
  29387. lodash.split = split;
  29388. lodash.spread = spread;
  29389. lodash.tail = tail;
  29390. lodash.take = take;
  29391. lodash.takeRight = takeRight;
  29392. lodash.takeRightWhile = takeRightWhile;
  29393. lodash.takeWhile = takeWhile;
  29394. lodash.tap = tap;
  29395. lodash.throttle = throttle;
  29396. lodash.thru = thru;
  29397. lodash.toArray = toArray;
  29398. lodash.toPairs = toPairs;
  29399. lodash.toPairsIn = toPairsIn;
  29400. lodash.toPath = toPath;
  29401. lodash.toPlainObject = toPlainObject;
  29402. lodash.transform = transform;
  29403. lodash.unary = unary;
  29404. lodash.union = union;
  29405. lodash.unionBy = unionBy;
  29406. lodash.unionWith = unionWith;
  29407. lodash.uniq = uniq;
  29408. lodash.uniqBy = uniqBy;
  29409. lodash.uniqWith = uniqWith;
  29410. lodash.unset = unset;
  29411. lodash.unzip = unzip;
  29412. lodash.unzipWith = unzipWith;
  29413. lodash.update = update;
  29414. lodash.updateWith = updateWith;
  29415. lodash.values = values;
  29416. lodash.valuesIn = valuesIn;
  29417. lodash.without = without;
  29418. lodash.words = words;
  29419. lodash.wrap = wrap;
  29420. lodash.xor = xor;
  29421. lodash.xorBy = xorBy;
  29422. lodash.xorWith = xorWith;
  29423. lodash.zip = zip;
  29424. lodash.zipObject = zipObject;
  29425. lodash.zipObjectDeep = zipObjectDeep;
  29426. lodash.zipWith = zipWith;
  29427. // Add aliases.
  29428. lodash.entries = toPairs;
  29429. lodash.entriesIn = toPairsIn;
  29430. lodash.extend = assignIn;
  29431. lodash.extendWith = assignInWith;
  29432. // Add methods to `lodash.prototype`.
  29433. mixin(lodash, lodash);
  29434. /*------------------------------------------------------------------------*/
  29435. // Add methods that return unwrapped values in chain sequences.
  29436. lodash.add = add;
  29437. lodash.attempt = attempt;
  29438. lodash.camelCase = camelCase;
  29439. lodash.capitalize = capitalize;
  29440. lodash.ceil = ceil;
  29441. lodash.clamp = clamp;
  29442. lodash.clone = clone;
  29443. lodash.cloneDeep = cloneDeep;
  29444. lodash.cloneDeepWith = cloneDeepWith;
  29445. lodash.cloneWith = cloneWith;
  29446. lodash.conformsTo = conformsTo;
  29447. lodash.deburr = deburr;
  29448. lodash.defaultTo = defaultTo;
  29449. lodash.divide = divide;
  29450. lodash.endsWith = endsWith;
  29451. lodash.eq = eq;
  29452. lodash.escape = escape;
  29453. lodash.escapeRegExp = escapeRegExp;
  29454. lodash.every = every;
  29455. lodash.find = find;
  29456. lodash.findIndex = findIndex;
  29457. lodash.findKey = findKey;
  29458. lodash.findLast = findLast;
  29459. lodash.findLastIndex = findLastIndex;
  29460. lodash.findLastKey = findLastKey;
  29461. lodash.floor = floor;
  29462. lodash.forEach = forEach;
  29463. lodash.forEachRight = forEachRight;
  29464. lodash.forIn = forIn;
  29465. lodash.forInRight = forInRight;
  29466. lodash.forOwn = forOwn;
  29467. lodash.forOwnRight = forOwnRight;
  29468. lodash.get = get;
  29469. lodash.gt = gt;
  29470. lodash.gte = gte;
  29471. lodash.has = has;
  29472. lodash.hasIn = hasIn;
  29473. lodash.head = head;
  29474. lodash.identity = identity;
  29475. lodash.includes = includes;
  29476. lodash.indexOf = indexOf;
  29477. lodash.inRange = inRange;
  29478. lodash.invoke = invoke;
  29479. lodash.isArguments = isArguments;
  29480. lodash.isArray = isArray;
  29481. lodash.isArrayBuffer = isArrayBuffer;
  29482. lodash.isArrayLike = isArrayLike;
  29483. lodash.isArrayLikeObject = isArrayLikeObject;
  29484. lodash.isBoolean = isBoolean;
  29485. lodash.isBuffer = isBuffer;
  29486. lodash.isDate = isDate;
  29487. lodash.isElement = isElement;
  29488. lodash.isEmpty = isEmpty;
  29489. lodash.isEqual = isEqual;
  29490. lodash.isEqualWith = isEqualWith;
  29491. lodash.isError = isError;
  29492. lodash.isFinite = isFinite;
  29493. lodash.isFunction = isFunction;
  29494. lodash.isInteger = isInteger;
  29495. lodash.isLength = isLength;
  29496. lodash.isMap = isMap;
  29497. lodash.isMatch = isMatch;
  29498. lodash.isMatchWith = isMatchWith;
  29499. lodash.isNaN = isNaN;
  29500. lodash.isNative = isNative;
  29501. lodash.isNil = isNil;
  29502. lodash.isNull = isNull;
  29503. lodash.isNumber = isNumber;
  29504. lodash.isObject = isObject;
  29505. lodash.isObjectLike = isObjectLike;
  29506. lodash.isPlainObject = isPlainObject;
  29507. lodash.isRegExp = isRegExp;
  29508. lodash.isSafeInteger = isSafeInteger;
  29509. lodash.isSet = isSet;
  29510. lodash.isString = isString;
  29511. lodash.isSymbol = isSymbol;
  29512. lodash.isTypedArray = isTypedArray;
  29513. lodash.isUndefined = isUndefined;
  29514. lodash.isWeakMap = isWeakMap;
  29515. lodash.isWeakSet = isWeakSet;
  29516. lodash.join = join;
  29517. lodash.kebabCase = kebabCase;
  29518. lodash.last = last;
  29519. lodash.lastIndexOf = lastIndexOf;
  29520. lodash.lowerCase = lowerCase;
  29521. lodash.lowerFirst = lowerFirst;
  29522. lodash.lt = lt;
  29523. lodash.lte = lte;
  29524. lodash.max = max;
  29525. lodash.maxBy = maxBy;
  29526. lodash.mean = mean;
  29527. lodash.meanBy = meanBy;
  29528. lodash.min = min;
  29529. lodash.minBy = minBy;
  29530. lodash.stubArray = stubArray;
  29531. lodash.stubFalse = stubFalse;
  29532. lodash.stubObject = stubObject;
  29533. lodash.stubString = stubString;
  29534. lodash.stubTrue = stubTrue;
  29535. lodash.multiply = multiply;
  29536. lodash.nth = nth;
  29537. lodash.noConflict = noConflict;
  29538. lodash.noop = noop;
  29539. lodash.now = now;
  29540. lodash.pad = pad;
  29541. lodash.padEnd = padEnd;
  29542. lodash.padStart = padStart;
  29543. lodash.parseInt = parseInt;
  29544. lodash.random = random;
  29545. lodash.reduce = reduce;
  29546. lodash.reduceRight = reduceRight;
  29547. lodash.repeat = repeat;
  29548. lodash.replace = replace;
  29549. lodash.result = result;
  29550. lodash.round = round;
  29551. lodash.runInContext = runInContext;
  29552. lodash.sample = sample;
  29553. lodash.size = size;
  29554. lodash.snakeCase = snakeCase;
  29555. lodash.some = some;
  29556. lodash.sortedIndex = sortedIndex;
  29557. lodash.sortedIndexBy = sortedIndexBy;
  29558. lodash.sortedIndexOf = sortedIndexOf;
  29559. lodash.sortedLastIndex = sortedLastIndex;
  29560. lodash.sortedLastIndexBy = sortedLastIndexBy;
  29561. lodash.sortedLastIndexOf = sortedLastIndexOf;
  29562. lodash.startCase = startCase;
  29563. lodash.startsWith = startsWith;
  29564. lodash.subtract = subtract;
  29565. lodash.sum = sum;
  29566. lodash.sumBy = sumBy;
  29567. lodash.template = template;
  29568. lodash.times = times;
  29569. lodash.toFinite = toFinite;
  29570. lodash.toInteger = toInteger;
  29571. lodash.toLength = toLength;
  29572. lodash.toLower = toLower;
  29573. lodash.toNumber = toNumber;
  29574. lodash.toSafeInteger = toSafeInteger;
  29575. lodash.toString = toString;
  29576. lodash.toUpper = toUpper;
  29577. lodash.trim = trim;
  29578. lodash.trimEnd = trimEnd;
  29579. lodash.trimStart = trimStart;
  29580. lodash.truncate = truncate;
  29581. lodash.unescape = unescape;
  29582. lodash.uniqueId = uniqueId;
  29583. lodash.upperCase = upperCase;
  29584. lodash.upperFirst = upperFirst;
  29585. // Add aliases.
  29586. lodash.each = forEach;
  29587. lodash.eachRight = forEachRight;
  29588. lodash.first = head;
  29589. mixin(lodash, (function() {
  29590. var source = {};
  29591. baseForOwn(lodash, function(func, methodName) {
  29592. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  29593. source[methodName] = func;
  29594. }
  29595. });
  29596. return source;
  29597. }()), { 'chain': false });
  29598. /*------------------------------------------------------------------------*/
  29599. /**
  29600. * The semantic version number.
  29601. *
  29602. * @static
  29603. * @memberOf _
  29604. * @type {string}
  29605. */
  29606. lodash.VERSION = VERSION;
  29607. // Assign default placeholders.
  29608. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  29609. lodash[methodName].placeholder = lodash;
  29610. });
  29611. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  29612. arrayEach(['drop', 'take'], function(methodName, index) {
  29613. LazyWrapper.prototype[methodName] = function(n) {
  29614. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  29615. var result = (this.__filtered__ && !index)
  29616. ? new LazyWrapper(this)
  29617. : this.clone();
  29618. if (result.__filtered__) {
  29619. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  29620. } else {
  29621. result.__views__.push({
  29622. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  29623. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  29624. });
  29625. }
  29626. return result;
  29627. };
  29628. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  29629. return this.reverse()[methodName](n).reverse();
  29630. };
  29631. });
  29632. // Add `LazyWrapper` methods that accept an `iteratee` value.
  29633. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  29634. var type = index + 1,
  29635. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  29636. LazyWrapper.prototype[methodName] = function(iteratee) {
  29637. var result = this.clone();
  29638. result.__iteratees__.push({
  29639. 'iteratee': getIteratee(iteratee, 3),
  29640. 'type': type
  29641. });
  29642. result.__filtered__ = result.__filtered__ || isFilter;
  29643. return result;
  29644. };
  29645. });
  29646. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  29647. arrayEach(['head', 'last'], function(methodName, index) {
  29648. var takeName = 'take' + (index ? 'Right' : '');
  29649. LazyWrapper.prototype[methodName] = function() {
  29650. return this[takeName](1).value()[0];
  29651. };
  29652. });
  29653. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  29654. arrayEach(['initial', 'tail'], function(methodName, index) {
  29655. var dropName = 'drop' + (index ? '' : 'Right');
  29656. LazyWrapper.prototype[methodName] = function() {
  29657. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  29658. };
  29659. });
  29660. LazyWrapper.prototype.compact = function() {
  29661. return this.filter(identity);
  29662. };
  29663. LazyWrapper.prototype.find = function(predicate) {
  29664. return this.filter(predicate).head();
  29665. };
  29666. LazyWrapper.prototype.findLast = function(predicate) {
  29667. return this.reverse().find(predicate);
  29668. };
  29669. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  29670. if (typeof path == 'function') {
  29671. return new LazyWrapper(this);
  29672. }
  29673. return this.map(function(value) {
  29674. return baseInvoke(value, path, args);
  29675. });
  29676. });
  29677. LazyWrapper.prototype.reject = function(predicate) {
  29678. return this.filter(negate(getIteratee(predicate)));
  29679. };
  29680. LazyWrapper.prototype.slice = function(start, end) {
  29681. start = toInteger(start);
  29682. var result = this;
  29683. if (result.__filtered__ && (start > 0 || end < 0)) {
  29684. return new LazyWrapper(result);
  29685. }
  29686. if (start < 0) {
  29687. result = result.takeRight(-start);
  29688. } else if (start) {
  29689. result = result.drop(start);
  29690. }
  29691. if (end !== undefined) {
  29692. end = toInteger(end);
  29693. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  29694. }
  29695. return result;
  29696. };
  29697. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  29698. return this.reverse().takeWhile(predicate).reverse();
  29699. };
  29700. LazyWrapper.prototype.toArray = function() {
  29701. return this.take(MAX_ARRAY_LENGTH);
  29702. };
  29703. // Add `LazyWrapper` methods to `lodash.prototype`.
  29704. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  29705. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  29706. isTaker = /^(?:head|last)$/.test(methodName),
  29707. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  29708. retUnwrapped = isTaker || /^find/.test(methodName);
  29709. if (!lodashFunc) {
  29710. return;
  29711. }
  29712. lodash.prototype[methodName] = function() {
  29713. var value = this.__wrapped__,
  29714. args = isTaker ? [1] : arguments,
  29715. isLazy = value instanceof LazyWrapper,
  29716. iteratee = args[0],
  29717. useLazy = isLazy || isArray(value);
  29718. var interceptor = function(value) {
  29719. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  29720. return (isTaker && chainAll) ? result[0] : result;
  29721. };
  29722. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  29723. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  29724. isLazy = useLazy = false;
  29725. }
  29726. var chainAll = this.__chain__,
  29727. isHybrid = !!this.__actions__.length,
  29728. isUnwrapped = retUnwrapped && !chainAll,
  29729. onlyLazy = isLazy && !isHybrid;
  29730. if (!retUnwrapped && useLazy) {
  29731. value = onlyLazy ? value : new LazyWrapper(this);
  29732. var result = func.apply(value, args);
  29733. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  29734. return new LodashWrapper(result, chainAll);
  29735. }
  29736. if (isUnwrapped && onlyLazy) {
  29737. return func.apply(this, args);
  29738. }
  29739. result = this.thru(interceptor);
  29740. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  29741. };
  29742. });
  29743. // Add `Array` methods to `lodash.prototype`.
  29744. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  29745. var func = arrayProto[methodName],
  29746. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  29747. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  29748. lodash.prototype[methodName] = function() {
  29749. var args = arguments;
  29750. if (retUnwrapped && !this.__chain__) {
  29751. var value = this.value();
  29752. return func.apply(isArray(value) ? value : [], args);
  29753. }
  29754. return this[chainName](function(value) {
  29755. return func.apply(isArray(value) ? value : [], args);
  29756. });
  29757. };
  29758. });
  29759. // Map minified method names to their real names.
  29760. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  29761. var lodashFunc = lodash[methodName];
  29762. if (lodashFunc) {
  29763. var key = lodashFunc.name + '';
  29764. if (!hasOwnProperty.call(realNames, key)) {
  29765. realNames[key] = [];
  29766. }
  29767. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  29768. }
  29769. });
  29770. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  29771. 'name': 'wrapper',
  29772. 'func': undefined
  29773. }];
  29774. // Add methods to `LazyWrapper`.
  29775. LazyWrapper.prototype.clone = lazyClone;
  29776. LazyWrapper.prototype.reverse = lazyReverse;
  29777. LazyWrapper.prototype.value = lazyValue;
  29778. // Add chain sequence methods to the `lodash` wrapper.
  29779. lodash.prototype.at = wrapperAt;
  29780. lodash.prototype.chain = wrapperChain;
  29781. lodash.prototype.commit = wrapperCommit;
  29782. lodash.prototype.next = wrapperNext;
  29783. lodash.prototype.plant = wrapperPlant;
  29784. lodash.prototype.reverse = wrapperReverse;
  29785. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  29786. // Add lazy aliases.
  29787. lodash.prototype.first = lodash.prototype.head;
  29788. if (symIterator) {
  29789. lodash.prototype[symIterator] = wrapperToIterator;
  29790. }
  29791. return lodash;
  29792. });
  29793. /*--------------------------------------------------------------------------*/
  29794. // Export lodash.
  29795. var _ = runInContext();
  29796. // Some AMD build optimizers, like r.js, check for condition patterns like:
  29797. if (true) {
  29798. // Expose Lodash on the global object to prevent errors when Lodash is
  29799. // loaded by a script tag in the presence of an AMD loader.
  29800. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  29801. // Use `_.noConflict` to remove Lodash from the global object.
  29802. root._ = _;
  29803. // Define as an anonymous module so, through path mapping, it can be
  29804. // referenced as the "underscore" module.
  29805. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  29806. return _;
  29807. }).call(exports, __webpack_require__, exports, module),
  29808. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  29809. }
  29810. // Check for `exports` after `define` in case a build optimizer adds it.
  29811. else {}
  29812. }.call(this));
  29813. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module)))
  29814. /***/ }),
  29815. /***/ "./node_modules/object-assign/index.js":
  29816. /*!*********************************************!*\
  29817. !*** ./node_modules/object-assign/index.js ***!
  29818. \*********************************************/
  29819. /*! no static exports found */
  29820. /***/ (function(module, exports, __webpack_require__) {
  29821. "use strict";
  29822. /*
  29823. object-assign
  29824. (c) Sindre Sorhus
  29825. @license MIT
  29826. */
  29827. /* eslint-disable no-unused-vars */
  29828. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  29829. var hasOwnProperty = Object.prototype.hasOwnProperty;
  29830. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  29831. function toObject(val) {
  29832. if (val === null || val === undefined) {
  29833. throw new TypeError('Object.assign cannot be called with null or undefined');
  29834. }
  29835. return Object(val);
  29836. }
  29837. function shouldUseNative() {
  29838. try {
  29839. if (!Object.assign) {
  29840. return false;
  29841. }
  29842. // Detect buggy property enumeration order in older V8 versions.
  29843. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  29844. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  29845. test1[5] = 'de';
  29846. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  29847. return false;
  29848. }
  29849. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  29850. var test2 = {};
  29851. for (var i = 0; i < 10; i++) {
  29852. test2['_' + String.fromCharCode(i)] = i;
  29853. }
  29854. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  29855. return test2[n];
  29856. });
  29857. if (order2.join('') !== '0123456789') {
  29858. return false;
  29859. }
  29860. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  29861. var test3 = {};
  29862. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  29863. test3[letter] = letter;
  29864. });
  29865. if (Object.keys(Object.assign({}, test3)).join('') !==
  29866. 'abcdefghijklmnopqrst') {
  29867. return false;
  29868. }
  29869. return true;
  29870. } catch (err) {
  29871. // We don't expect any of the above to throw, but better to be safe.
  29872. return false;
  29873. }
  29874. }
  29875. module.exports = shouldUseNative() ? Object.assign : function (target, source) {
  29876. var from;
  29877. var to = toObject(target);
  29878. var symbols;
  29879. for (var s = 1; s < arguments.length; s++) {
  29880. from = Object(arguments[s]);
  29881. for (var key in from) {
  29882. if (hasOwnProperty.call(from, key)) {
  29883. to[key] = from[key];
  29884. }
  29885. }
  29886. if (getOwnPropertySymbols) {
  29887. symbols = getOwnPropertySymbols(from);
  29888. for (var i = 0; i < symbols.length; i++) {
  29889. if (propIsEnumerable.call(from, symbols[i])) {
  29890. to[symbols[i]] = from[symbols[i]];
  29891. }
  29892. }
  29893. }
  29894. }
  29895. return to;
  29896. };
  29897. /***/ }),
  29898. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  29899. /*!***************************************************!*\
  29900. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  29901. \***************************************************/
  29902. /*! exports provided: default */
  29903. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29904. "use strict";
  29905. __webpack_require__.r(__webpack_exports__);
  29906. /* WEBPACK VAR INJECTION */(function(global) {/**!
  29907. * @fileOverview Kickass library to create and place poppers near their reference elements.
  29908. * @version 1.15.0
  29909. * @license
  29910. * Copyright (c) 2016 Federico Zivolo and contributors
  29911. *
  29912. * Permission is hereby granted, free of charge, to any person obtaining a copy
  29913. * of this software and associated documentation files (the "Software"), to deal
  29914. * in the Software without restriction, including without limitation the rights
  29915. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  29916. * copies of the Software, and to permit persons to whom the Software is
  29917. * furnished to do so, subject to the following conditions:
  29918. *
  29919. * The above copyright notice and this permission notice shall be included in all
  29920. * copies or substantial portions of the Software.
  29921. *
  29922. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  29923. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  29924. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  29925. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  29926. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  29927. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  29928. * SOFTWARE.
  29929. */
  29930. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
  29931. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  29932. var timeoutDuration = 0;
  29933. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  29934. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  29935. timeoutDuration = 1;
  29936. break;
  29937. }
  29938. }
  29939. function microtaskDebounce(fn) {
  29940. var called = false;
  29941. return function () {
  29942. if (called) {
  29943. return;
  29944. }
  29945. called = true;
  29946. window.Promise.resolve().then(function () {
  29947. called = false;
  29948. fn();
  29949. });
  29950. };
  29951. }
  29952. function taskDebounce(fn) {
  29953. var scheduled = false;
  29954. return function () {
  29955. if (!scheduled) {
  29956. scheduled = true;
  29957. setTimeout(function () {
  29958. scheduled = false;
  29959. fn();
  29960. }, timeoutDuration);
  29961. }
  29962. };
  29963. }
  29964. var supportsMicroTasks = isBrowser && window.Promise;
  29965. /**
  29966. * Create a debounced version of a method, that's asynchronously deferred
  29967. * but called in the minimum time possible.
  29968. *
  29969. * @method
  29970. * @memberof Popper.Utils
  29971. * @argument {Function} fn
  29972. * @returns {Function}
  29973. */
  29974. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  29975. /**
  29976. * Check if the given variable is a function
  29977. * @method
  29978. * @memberof Popper.Utils
  29979. * @argument {Any} functionToCheck - variable to check
  29980. * @returns {Boolean} answer to: is a function?
  29981. */
  29982. function isFunction(functionToCheck) {
  29983. var getType = {};
  29984. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  29985. }
  29986. /**
  29987. * Get CSS computed property of the given element
  29988. * @method
  29989. * @memberof Popper.Utils
  29990. * @argument {Eement} element
  29991. * @argument {String} property
  29992. */
  29993. function getStyleComputedProperty(element, property) {
  29994. if (element.nodeType !== 1) {
  29995. return [];
  29996. }
  29997. // NOTE: 1 DOM access here
  29998. var window = element.ownerDocument.defaultView;
  29999. var css = window.getComputedStyle(element, null);
  30000. return property ? css[property] : css;
  30001. }
  30002. /**
  30003. * Returns the parentNode or the host of the element
  30004. * @method
  30005. * @memberof Popper.Utils
  30006. * @argument {Element} element
  30007. * @returns {Element} parent
  30008. */
  30009. function getParentNode(element) {
  30010. if (element.nodeName === 'HTML') {
  30011. return element;
  30012. }
  30013. return element.parentNode || element.host;
  30014. }
  30015. /**
  30016. * Returns the scrolling parent of the given element
  30017. * @method
  30018. * @memberof Popper.Utils
  30019. * @argument {Element} element
  30020. * @returns {Element} scroll parent
  30021. */
  30022. function getScrollParent(element) {
  30023. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  30024. if (!element) {
  30025. return document.body;
  30026. }
  30027. switch (element.nodeName) {
  30028. case 'HTML':
  30029. case 'BODY':
  30030. return element.ownerDocument.body;
  30031. case '#document':
  30032. return element.body;
  30033. }
  30034. // Firefox want us to check `-x` and `-y` variations as well
  30035. var _getStyleComputedProp = getStyleComputedProperty(element),
  30036. overflow = _getStyleComputedProp.overflow,
  30037. overflowX = _getStyleComputedProp.overflowX,
  30038. overflowY = _getStyleComputedProp.overflowY;
  30039. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  30040. return element;
  30041. }
  30042. return getScrollParent(getParentNode(element));
  30043. }
  30044. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  30045. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  30046. /**
  30047. * Determines if the browser is Internet Explorer
  30048. * @method
  30049. * @memberof Popper.Utils
  30050. * @param {Number} version to check
  30051. * @returns {Boolean} isIE
  30052. */
  30053. function isIE(version) {
  30054. if (version === 11) {
  30055. return isIE11;
  30056. }
  30057. if (version === 10) {
  30058. return isIE10;
  30059. }
  30060. return isIE11 || isIE10;
  30061. }
  30062. /**
  30063. * Returns the offset parent of the given element
  30064. * @method
  30065. * @memberof Popper.Utils
  30066. * @argument {Element} element
  30067. * @returns {Element} offset parent
  30068. */
  30069. function getOffsetParent(element) {
  30070. if (!element) {
  30071. return document.documentElement;
  30072. }
  30073. var noOffsetParent = isIE(10) ? document.body : null;
  30074. // NOTE: 1 DOM access here
  30075. var offsetParent = element.offsetParent || null;
  30076. // Skip hidden elements which don't have an offsetParent
  30077. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  30078. offsetParent = (element = element.nextElementSibling).offsetParent;
  30079. }
  30080. var nodeName = offsetParent && offsetParent.nodeName;
  30081. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  30082. return element ? element.ownerDocument.documentElement : document.documentElement;
  30083. }
  30084. // .offsetParent will return the closest TH, TD or TABLE in case
  30085. // no offsetParent is present, I hate this job...
  30086. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  30087. return getOffsetParent(offsetParent);
  30088. }
  30089. return offsetParent;
  30090. }
  30091. function isOffsetContainer(element) {
  30092. var nodeName = element.nodeName;
  30093. if (nodeName === 'BODY') {
  30094. return false;
  30095. }
  30096. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  30097. }
  30098. /**
  30099. * Finds the root node (document, shadowDOM root) of the given element
  30100. * @method
  30101. * @memberof Popper.Utils
  30102. * @argument {Element} node
  30103. * @returns {Element} root node
  30104. */
  30105. function getRoot(node) {
  30106. if (node.parentNode !== null) {
  30107. return getRoot(node.parentNode);
  30108. }
  30109. return node;
  30110. }
  30111. /**
  30112. * Finds the offset parent common to the two provided nodes
  30113. * @method
  30114. * @memberof Popper.Utils
  30115. * @argument {Element} element1
  30116. * @argument {Element} element2
  30117. * @returns {Element} common offset parent
  30118. */
  30119. function findCommonOffsetParent(element1, element2) {
  30120. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  30121. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  30122. return document.documentElement;
  30123. }
  30124. // Here we make sure to give as "start" the element that comes first in the DOM
  30125. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  30126. var start = order ? element1 : element2;
  30127. var end = order ? element2 : element1;
  30128. // Get common ancestor container
  30129. var range = document.createRange();
  30130. range.setStart(start, 0);
  30131. range.setEnd(end, 0);
  30132. var commonAncestorContainer = range.commonAncestorContainer;
  30133. // Both nodes are inside #document
  30134. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  30135. if (isOffsetContainer(commonAncestorContainer)) {
  30136. return commonAncestorContainer;
  30137. }
  30138. return getOffsetParent(commonAncestorContainer);
  30139. }
  30140. // one of the nodes is inside shadowDOM, find which one
  30141. var element1root = getRoot(element1);
  30142. if (element1root.host) {
  30143. return findCommonOffsetParent(element1root.host, element2);
  30144. } else {
  30145. return findCommonOffsetParent(element1, getRoot(element2).host);
  30146. }
  30147. }
  30148. /**
  30149. * Gets the scroll value of the given element in the given side (top and left)
  30150. * @method
  30151. * @memberof Popper.Utils
  30152. * @argument {Element} element
  30153. * @argument {String} side `top` or `left`
  30154. * @returns {number} amount of scrolled pixels
  30155. */
  30156. function getScroll(element) {
  30157. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  30158. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  30159. var nodeName = element.nodeName;
  30160. if (nodeName === 'BODY' || nodeName === 'HTML') {
  30161. var html = element.ownerDocument.documentElement;
  30162. var scrollingElement = element.ownerDocument.scrollingElement || html;
  30163. return scrollingElement[upperSide];
  30164. }
  30165. return element[upperSide];
  30166. }
  30167. /*
  30168. * Sum or subtract the element scroll values (left and top) from a given rect object
  30169. * @method
  30170. * @memberof Popper.Utils
  30171. * @param {Object} rect - Rect object you want to change
  30172. * @param {HTMLElement} element - The element from the function reads the scroll values
  30173. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  30174. * @return {Object} rect - The modifier rect object
  30175. */
  30176. function includeScroll(rect, element) {
  30177. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30178. var scrollTop = getScroll(element, 'top');
  30179. var scrollLeft = getScroll(element, 'left');
  30180. var modifier = subtract ? -1 : 1;
  30181. rect.top += scrollTop * modifier;
  30182. rect.bottom += scrollTop * modifier;
  30183. rect.left += scrollLeft * modifier;
  30184. rect.right += scrollLeft * modifier;
  30185. return rect;
  30186. }
  30187. /*
  30188. * Helper to detect borders of a given element
  30189. * @method
  30190. * @memberof Popper.Utils
  30191. * @param {CSSStyleDeclaration} styles
  30192. * Result of `getStyleComputedProperty` on the given element
  30193. * @param {String} axis - `x` or `y`
  30194. * @return {number} borders - The borders size of the given axis
  30195. */
  30196. function getBordersSize(styles, axis) {
  30197. var sideA = axis === 'x' ? 'Left' : 'Top';
  30198. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  30199. return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);
  30200. }
  30201. function getSize(axis, body, html, computedStyle) {
  30202. return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
  30203. }
  30204. function getWindowSizes(document) {
  30205. var body = document.body;
  30206. var html = document.documentElement;
  30207. var computedStyle = isIE(10) && getComputedStyle(html);
  30208. return {
  30209. height: getSize('Height', body, html, computedStyle),
  30210. width: getSize('Width', body, html, computedStyle)
  30211. };
  30212. }
  30213. var classCallCheck = function (instance, Constructor) {
  30214. if (!(instance instanceof Constructor)) {
  30215. throw new TypeError("Cannot call a class as a function");
  30216. }
  30217. };
  30218. var createClass = function () {
  30219. function defineProperties(target, props) {
  30220. for (var i = 0; i < props.length; i++) {
  30221. var descriptor = props[i];
  30222. descriptor.enumerable = descriptor.enumerable || false;
  30223. descriptor.configurable = true;
  30224. if ("value" in descriptor) descriptor.writable = true;
  30225. Object.defineProperty(target, descriptor.key, descriptor);
  30226. }
  30227. }
  30228. return function (Constructor, protoProps, staticProps) {
  30229. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  30230. if (staticProps) defineProperties(Constructor, staticProps);
  30231. return Constructor;
  30232. };
  30233. }();
  30234. var defineProperty = function (obj, key, value) {
  30235. if (key in obj) {
  30236. Object.defineProperty(obj, key, {
  30237. value: value,
  30238. enumerable: true,
  30239. configurable: true,
  30240. writable: true
  30241. });
  30242. } else {
  30243. obj[key] = value;
  30244. }
  30245. return obj;
  30246. };
  30247. var _extends = Object.assign || function (target) {
  30248. for (var i = 1; i < arguments.length; i++) {
  30249. var source = arguments[i];
  30250. for (var key in source) {
  30251. if (Object.prototype.hasOwnProperty.call(source, key)) {
  30252. target[key] = source[key];
  30253. }
  30254. }
  30255. }
  30256. return target;
  30257. };
  30258. /**
  30259. * Given element offsets, generate an output similar to getBoundingClientRect
  30260. * @method
  30261. * @memberof Popper.Utils
  30262. * @argument {Object} offsets
  30263. * @returns {Object} ClientRect like output
  30264. */
  30265. function getClientRect(offsets) {
  30266. return _extends({}, offsets, {
  30267. right: offsets.left + offsets.width,
  30268. bottom: offsets.top + offsets.height
  30269. });
  30270. }
  30271. /**
  30272. * Get bounding client rect of given element
  30273. * @method
  30274. * @memberof Popper.Utils
  30275. * @param {HTMLElement} element
  30276. * @return {Object} client rect
  30277. */
  30278. function getBoundingClientRect(element) {
  30279. var rect = {};
  30280. // IE10 10 FIX: Please, don't ask, the element isn't
  30281. // considered in DOM in some circumstances...
  30282. // This isn't reproducible in IE10 compatibility mode of IE11
  30283. try {
  30284. if (isIE(10)) {
  30285. rect = element.getBoundingClientRect();
  30286. var scrollTop = getScroll(element, 'top');
  30287. var scrollLeft = getScroll(element, 'left');
  30288. rect.top += scrollTop;
  30289. rect.left += scrollLeft;
  30290. rect.bottom += scrollTop;
  30291. rect.right += scrollLeft;
  30292. } else {
  30293. rect = element.getBoundingClientRect();
  30294. }
  30295. } catch (e) {}
  30296. var result = {
  30297. left: rect.left,
  30298. top: rect.top,
  30299. width: rect.right - rect.left,
  30300. height: rect.bottom - rect.top
  30301. };
  30302. // subtract scrollbar size from sizes
  30303. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  30304. var width = sizes.width || element.clientWidth || result.right - result.left;
  30305. var height = sizes.height || element.clientHeight || result.bottom - result.top;
  30306. var horizScrollbar = element.offsetWidth - width;
  30307. var vertScrollbar = element.offsetHeight - height;
  30308. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  30309. // we make this check conditional for performance reasons
  30310. if (horizScrollbar || vertScrollbar) {
  30311. var styles = getStyleComputedProperty(element);
  30312. horizScrollbar -= getBordersSize(styles, 'x');
  30313. vertScrollbar -= getBordersSize(styles, 'y');
  30314. result.width -= horizScrollbar;
  30315. result.height -= vertScrollbar;
  30316. }
  30317. return getClientRect(result);
  30318. }
  30319. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  30320. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30321. var isIE10 = isIE(10);
  30322. var isHTML = parent.nodeName === 'HTML';
  30323. var childrenRect = getBoundingClientRect(children);
  30324. var parentRect = getBoundingClientRect(parent);
  30325. var scrollParent = getScrollParent(children);
  30326. var styles = getStyleComputedProperty(parent);
  30327. var borderTopWidth = parseFloat(styles.borderTopWidth, 10);
  30328. var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);
  30329. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  30330. if (fixedPosition && isHTML) {
  30331. parentRect.top = Math.max(parentRect.top, 0);
  30332. parentRect.left = Math.max(parentRect.left, 0);
  30333. }
  30334. var offsets = getClientRect({
  30335. top: childrenRect.top - parentRect.top - borderTopWidth,
  30336. left: childrenRect.left - parentRect.left - borderLeftWidth,
  30337. width: childrenRect.width,
  30338. height: childrenRect.height
  30339. });
  30340. offsets.marginTop = 0;
  30341. offsets.marginLeft = 0;
  30342. // Subtract margins of documentElement in case it's being used as parent
  30343. // we do this only on HTML because it's the only element that behaves
  30344. // differently when margins are applied to it. The margins are included in
  30345. // the box of the documentElement, in the other cases not.
  30346. if (!isIE10 && isHTML) {
  30347. var marginTop = parseFloat(styles.marginTop, 10);
  30348. var marginLeft = parseFloat(styles.marginLeft, 10);
  30349. offsets.top -= borderTopWidth - marginTop;
  30350. offsets.bottom -= borderTopWidth - marginTop;
  30351. offsets.left -= borderLeftWidth - marginLeft;
  30352. offsets.right -= borderLeftWidth - marginLeft;
  30353. // Attach marginTop and marginLeft because in some circumstances we may need them
  30354. offsets.marginTop = marginTop;
  30355. offsets.marginLeft = marginLeft;
  30356. }
  30357. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  30358. offsets = includeScroll(offsets, parent);
  30359. }
  30360. return offsets;
  30361. }
  30362. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  30363. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  30364. var html = element.ownerDocument.documentElement;
  30365. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  30366. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  30367. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  30368. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  30369. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  30370. var offset = {
  30371. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  30372. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  30373. width: width,
  30374. height: height
  30375. };
  30376. return getClientRect(offset);
  30377. }
  30378. /**
  30379. * Check if the given element is fixed or is inside a fixed parent
  30380. * @method
  30381. * @memberof Popper.Utils
  30382. * @argument {Element} element
  30383. * @argument {Element} customContainer
  30384. * @returns {Boolean} answer to "isFixed?"
  30385. */
  30386. function isFixed(element) {
  30387. var nodeName = element.nodeName;
  30388. if (nodeName === 'BODY' || nodeName === 'HTML') {
  30389. return false;
  30390. }
  30391. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  30392. return true;
  30393. }
  30394. var parentNode = getParentNode(element);
  30395. if (!parentNode) {
  30396. return false;
  30397. }
  30398. return isFixed(parentNode);
  30399. }
  30400. /**
  30401. * Finds the first parent of an element that has a transformed property defined
  30402. * @method
  30403. * @memberof Popper.Utils
  30404. * @argument {Element} element
  30405. * @returns {Element} first transformed parent or documentElement
  30406. */
  30407. function getFixedPositionOffsetParent(element) {
  30408. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  30409. if (!element || !element.parentElement || isIE()) {
  30410. return document.documentElement;
  30411. }
  30412. var el = element.parentElement;
  30413. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  30414. el = el.parentElement;
  30415. }
  30416. return el || document.documentElement;
  30417. }
  30418. /**
  30419. * Computed the boundaries limits and return them
  30420. * @method
  30421. * @memberof Popper.Utils
  30422. * @param {HTMLElement} popper
  30423. * @param {HTMLElement} reference
  30424. * @param {number} padding
  30425. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  30426. * @param {Boolean} fixedPosition - Is in fixed position mode
  30427. * @returns {Object} Coordinates of the boundaries
  30428. */
  30429. function getBoundaries(popper, reference, padding, boundariesElement) {
  30430. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  30431. // NOTE: 1 DOM access here
  30432. var boundaries = { top: 0, left: 0 };
  30433. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
  30434. // Handle viewport case
  30435. if (boundariesElement === 'viewport') {
  30436. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  30437. } else {
  30438. // Handle other cases based on DOM element used as boundaries
  30439. var boundariesNode = void 0;
  30440. if (boundariesElement === 'scrollParent') {
  30441. boundariesNode = getScrollParent(getParentNode(reference));
  30442. if (boundariesNode.nodeName === 'BODY') {
  30443. boundariesNode = popper.ownerDocument.documentElement;
  30444. }
  30445. } else if (boundariesElement === 'window') {
  30446. boundariesNode = popper.ownerDocument.documentElement;
  30447. } else {
  30448. boundariesNode = boundariesElement;
  30449. }
  30450. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  30451. // In case of HTML, we need a different computation
  30452. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  30453. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  30454. height = _getWindowSizes.height,
  30455. width = _getWindowSizes.width;
  30456. boundaries.top += offsets.top - offsets.marginTop;
  30457. boundaries.bottom = height + offsets.top;
  30458. boundaries.left += offsets.left - offsets.marginLeft;
  30459. boundaries.right = width + offsets.left;
  30460. } else {
  30461. // for all the other DOM elements, this one is good
  30462. boundaries = offsets;
  30463. }
  30464. }
  30465. // Add paddings
  30466. padding = padding || 0;
  30467. var isPaddingNumber = typeof padding === 'number';
  30468. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  30469. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  30470. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  30471. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  30472. return boundaries;
  30473. }
  30474. function getArea(_ref) {
  30475. var width = _ref.width,
  30476. height = _ref.height;
  30477. return width * height;
  30478. }
  30479. /**
  30480. * Utility used to transform the `auto` placement to the placement with more
  30481. * available space.
  30482. * @method
  30483. * @memberof Popper.Utils
  30484. * @argument {Object} data - The data object generated by update method
  30485. * @argument {Object} options - Modifiers configuration and options
  30486. * @returns {Object} The data object, properly modified
  30487. */
  30488. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  30489. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  30490. if (placement.indexOf('auto') === -1) {
  30491. return placement;
  30492. }
  30493. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  30494. var rects = {
  30495. top: {
  30496. width: boundaries.width,
  30497. height: refRect.top - boundaries.top
  30498. },
  30499. right: {
  30500. width: boundaries.right - refRect.right,
  30501. height: boundaries.height
  30502. },
  30503. bottom: {
  30504. width: boundaries.width,
  30505. height: boundaries.bottom - refRect.bottom
  30506. },
  30507. left: {
  30508. width: refRect.left - boundaries.left,
  30509. height: boundaries.height
  30510. }
  30511. };
  30512. var sortedAreas = Object.keys(rects).map(function (key) {
  30513. return _extends({
  30514. key: key
  30515. }, rects[key], {
  30516. area: getArea(rects[key])
  30517. });
  30518. }).sort(function (a, b) {
  30519. return b.area - a.area;
  30520. });
  30521. var filteredAreas = sortedAreas.filter(function (_ref2) {
  30522. var width = _ref2.width,
  30523. height = _ref2.height;
  30524. return width >= popper.clientWidth && height >= popper.clientHeight;
  30525. });
  30526. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  30527. var variation = placement.split('-')[1];
  30528. return computedPlacement + (variation ? '-' + variation : '');
  30529. }
  30530. /**
  30531. * Get offsets to the reference element
  30532. * @method
  30533. * @memberof Popper.Utils
  30534. * @param {Object} state
  30535. * @param {Element} popper - the popper element
  30536. * @param {Element} reference - the reference element (the popper will be relative to this)
  30537. * @param {Element} fixedPosition - is in fixed position mode
  30538. * @returns {Object} An object containing the offsets which will be applied to the popper
  30539. */
  30540. function getReferenceOffsets(state, popper, reference) {
  30541. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  30542. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
  30543. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  30544. }
  30545. /**
  30546. * Get the outer sizes of the given element (offset size + margins)
  30547. * @method
  30548. * @memberof Popper.Utils
  30549. * @argument {Element} element
  30550. * @returns {Object} object containing width and height properties
  30551. */
  30552. function getOuterSizes(element) {
  30553. var window = element.ownerDocument.defaultView;
  30554. var styles = window.getComputedStyle(element);
  30555. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  30556. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  30557. var result = {
  30558. width: element.offsetWidth + y,
  30559. height: element.offsetHeight + x
  30560. };
  30561. return result;
  30562. }
  30563. /**
  30564. * Get the opposite placement of the given one
  30565. * @method
  30566. * @memberof Popper.Utils
  30567. * @argument {String} placement
  30568. * @returns {String} flipped placement
  30569. */
  30570. function getOppositePlacement(placement) {
  30571. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  30572. return placement.replace(/left|right|bottom|top/g, function (matched) {
  30573. return hash[matched];
  30574. });
  30575. }
  30576. /**
  30577. * Get offsets to the popper
  30578. * @method
  30579. * @memberof Popper.Utils
  30580. * @param {Object} position - CSS position the Popper will get applied
  30581. * @param {HTMLElement} popper - the popper element
  30582. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  30583. * @param {String} placement - one of the valid placement options
  30584. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  30585. */
  30586. function getPopperOffsets(popper, referenceOffsets, placement) {
  30587. placement = placement.split('-')[0];
  30588. // Get popper node sizes
  30589. var popperRect = getOuterSizes(popper);
  30590. // Add position, width and height to our offsets object
  30591. var popperOffsets = {
  30592. width: popperRect.width,
  30593. height: popperRect.height
  30594. };
  30595. // depending by the popper placement we have to compute its offsets slightly differently
  30596. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  30597. var mainSide = isHoriz ? 'top' : 'left';
  30598. var secondarySide = isHoriz ? 'left' : 'top';
  30599. var measurement = isHoriz ? 'height' : 'width';
  30600. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  30601. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  30602. if (placement === secondarySide) {
  30603. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  30604. } else {
  30605. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  30606. }
  30607. return popperOffsets;
  30608. }
  30609. /**
  30610. * Mimics the `find` method of Array
  30611. * @method
  30612. * @memberof Popper.Utils
  30613. * @argument {Array} arr
  30614. * @argument prop
  30615. * @argument value
  30616. * @returns index or -1
  30617. */
  30618. function find(arr, check) {
  30619. // use native find if supported
  30620. if (Array.prototype.find) {
  30621. return arr.find(check);
  30622. }
  30623. // use `filter` to obtain the same behavior of `find`
  30624. return arr.filter(check)[0];
  30625. }
  30626. /**
  30627. * Return the index of the matching object
  30628. * @method
  30629. * @memberof Popper.Utils
  30630. * @argument {Array} arr
  30631. * @argument prop
  30632. * @argument value
  30633. * @returns index or -1
  30634. */
  30635. function findIndex(arr, prop, value) {
  30636. // use native findIndex if supported
  30637. if (Array.prototype.findIndex) {
  30638. return arr.findIndex(function (cur) {
  30639. return cur[prop] === value;
  30640. });
  30641. }
  30642. // use `find` + `indexOf` if `findIndex` isn't supported
  30643. var match = find(arr, function (obj) {
  30644. return obj[prop] === value;
  30645. });
  30646. return arr.indexOf(match);
  30647. }
  30648. /**
  30649. * Loop trough the list of modifiers and run them in order,
  30650. * each of them will then edit the data object.
  30651. * @method
  30652. * @memberof Popper.Utils
  30653. * @param {dataObject} data
  30654. * @param {Array} modifiers
  30655. * @param {String} ends - Optional modifier name used as stopper
  30656. * @returns {dataObject}
  30657. */
  30658. function runModifiers(modifiers, data, ends) {
  30659. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  30660. modifiersToRun.forEach(function (modifier) {
  30661. if (modifier['function']) {
  30662. // eslint-disable-line dot-notation
  30663. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  30664. }
  30665. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  30666. if (modifier.enabled && isFunction(fn)) {
  30667. // Add properties to offsets to make them a complete clientRect object
  30668. // we do this before each modifier to make sure the previous one doesn't
  30669. // mess with these values
  30670. data.offsets.popper = getClientRect(data.offsets.popper);
  30671. data.offsets.reference = getClientRect(data.offsets.reference);
  30672. data = fn(data, modifier);
  30673. }
  30674. });
  30675. return data;
  30676. }
  30677. /**
  30678. * Updates the position of the popper, computing the new offsets and applying
  30679. * the new style.<br />
  30680. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  30681. * @method
  30682. * @memberof Popper
  30683. */
  30684. function update() {
  30685. // if popper is destroyed, don't perform any further update
  30686. if (this.state.isDestroyed) {
  30687. return;
  30688. }
  30689. var data = {
  30690. instance: this,
  30691. styles: {},
  30692. arrowStyles: {},
  30693. attributes: {},
  30694. flipped: false,
  30695. offsets: {}
  30696. };
  30697. // compute reference element offsets
  30698. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  30699. // compute auto placement, store placement inside the data object,
  30700. // modifiers will be able to edit `placement` if needed
  30701. // and refer to originalPlacement to know the original value
  30702. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  30703. // store the computed placement inside `originalPlacement`
  30704. data.originalPlacement = data.placement;
  30705. data.positionFixed = this.options.positionFixed;
  30706. // compute the popper offsets
  30707. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  30708. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  30709. // run the modifiers
  30710. data = runModifiers(this.modifiers, data);
  30711. // the first `update` will call `onCreate` callback
  30712. // the other ones will call `onUpdate` callback
  30713. if (!this.state.isCreated) {
  30714. this.state.isCreated = true;
  30715. this.options.onCreate(data);
  30716. } else {
  30717. this.options.onUpdate(data);
  30718. }
  30719. }
  30720. /**
  30721. * Helper used to know if the given modifier is enabled.
  30722. * @method
  30723. * @memberof Popper.Utils
  30724. * @returns {Boolean}
  30725. */
  30726. function isModifierEnabled(modifiers, modifierName) {
  30727. return modifiers.some(function (_ref) {
  30728. var name = _ref.name,
  30729. enabled = _ref.enabled;
  30730. return enabled && name === modifierName;
  30731. });
  30732. }
  30733. /**
  30734. * Get the prefixed supported property name
  30735. * @method
  30736. * @memberof Popper.Utils
  30737. * @argument {String} property (camelCase)
  30738. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  30739. */
  30740. function getSupportedPropertyName(property) {
  30741. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  30742. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  30743. for (var i = 0; i < prefixes.length; i++) {
  30744. var prefix = prefixes[i];
  30745. var toCheck = prefix ? '' + prefix + upperProp : property;
  30746. if (typeof document.body.style[toCheck] !== 'undefined') {
  30747. return toCheck;
  30748. }
  30749. }
  30750. return null;
  30751. }
  30752. /**
  30753. * Destroys the popper.
  30754. * @method
  30755. * @memberof Popper
  30756. */
  30757. function destroy() {
  30758. this.state.isDestroyed = true;
  30759. // touch DOM only if `applyStyle` modifier is enabled
  30760. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  30761. this.popper.removeAttribute('x-placement');
  30762. this.popper.style.position = '';
  30763. this.popper.style.top = '';
  30764. this.popper.style.left = '';
  30765. this.popper.style.right = '';
  30766. this.popper.style.bottom = '';
  30767. this.popper.style.willChange = '';
  30768. this.popper.style[getSupportedPropertyName('transform')] = '';
  30769. }
  30770. this.disableEventListeners();
  30771. // remove the popper if user explicity asked for the deletion on destroy
  30772. // do not use `remove` because IE11 doesn't support it
  30773. if (this.options.removeOnDestroy) {
  30774. this.popper.parentNode.removeChild(this.popper);
  30775. }
  30776. return this;
  30777. }
  30778. /**
  30779. * Get the window associated with the element
  30780. * @argument {Element} element
  30781. * @returns {Window}
  30782. */
  30783. function getWindow(element) {
  30784. var ownerDocument = element.ownerDocument;
  30785. return ownerDocument ? ownerDocument.defaultView : window;
  30786. }
  30787. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  30788. var isBody = scrollParent.nodeName === 'BODY';
  30789. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  30790. target.addEventListener(event, callback, { passive: true });
  30791. if (!isBody) {
  30792. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  30793. }
  30794. scrollParents.push(target);
  30795. }
  30796. /**
  30797. * Setup needed event listeners used to update the popper position
  30798. * @method
  30799. * @memberof Popper.Utils
  30800. * @private
  30801. */
  30802. function setupEventListeners(reference, options, state, updateBound) {
  30803. // Resize event listener on window
  30804. state.updateBound = updateBound;
  30805. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  30806. // Scroll event listener on scroll parents
  30807. var scrollElement = getScrollParent(reference);
  30808. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  30809. state.scrollElement = scrollElement;
  30810. state.eventsEnabled = true;
  30811. return state;
  30812. }
  30813. /**
  30814. * It will add resize/scroll events and start recalculating
  30815. * position of the popper element when they are triggered.
  30816. * @method
  30817. * @memberof Popper
  30818. */
  30819. function enableEventListeners() {
  30820. if (!this.state.eventsEnabled) {
  30821. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  30822. }
  30823. }
  30824. /**
  30825. * Remove event listeners used to update the popper position
  30826. * @method
  30827. * @memberof Popper.Utils
  30828. * @private
  30829. */
  30830. function removeEventListeners(reference, state) {
  30831. // Remove resize event listener on window
  30832. getWindow(reference).removeEventListener('resize', state.updateBound);
  30833. // Remove scroll event listener on scroll parents
  30834. state.scrollParents.forEach(function (target) {
  30835. target.removeEventListener('scroll', state.updateBound);
  30836. });
  30837. // Reset state
  30838. state.updateBound = null;
  30839. state.scrollParents = [];
  30840. state.scrollElement = null;
  30841. state.eventsEnabled = false;
  30842. return state;
  30843. }
  30844. /**
  30845. * It will remove resize/scroll events and won't recalculate popper position
  30846. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  30847. * unless you call `update` method manually.
  30848. * @method
  30849. * @memberof Popper
  30850. */
  30851. function disableEventListeners() {
  30852. if (this.state.eventsEnabled) {
  30853. cancelAnimationFrame(this.scheduleUpdate);
  30854. this.state = removeEventListeners(this.reference, this.state);
  30855. }
  30856. }
  30857. /**
  30858. * Tells if a given input is a number
  30859. * @method
  30860. * @memberof Popper.Utils
  30861. * @param {*} input to check
  30862. * @return {Boolean}
  30863. */
  30864. function isNumeric(n) {
  30865. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  30866. }
  30867. /**
  30868. * Set the style to the given popper
  30869. * @method
  30870. * @memberof Popper.Utils
  30871. * @argument {Element} element - Element to apply the style to
  30872. * @argument {Object} styles
  30873. * Object with a list of properties and values which will be applied to the element
  30874. */
  30875. function setStyles(element, styles) {
  30876. Object.keys(styles).forEach(function (prop) {
  30877. var unit = '';
  30878. // add unit if the value is numeric and is one of the following
  30879. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  30880. unit = 'px';
  30881. }
  30882. element.style[prop] = styles[prop] + unit;
  30883. });
  30884. }
  30885. /**
  30886. * Set the attributes to the given popper
  30887. * @method
  30888. * @memberof Popper.Utils
  30889. * @argument {Element} element - Element to apply the attributes to
  30890. * @argument {Object} styles
  30891. * Object with a list of properties and values which will be applied to the element
  30892. */
  30893. function setAttributes(element, attributes) {
  30894. Object.keys(attributes).forEach(function (prop) {
  30895. var value = attributes[prop];
  30896. if (value !== false) {
  30897. element.setAttribute(prop, attributes[prop]);
  30898. } else {
  30899. element.removeAttribute(prop);
  30900. }
  30901. });
  30902. }
  30903. /**
  30904. * @function
  30905. * @memberof Modifiers
  30906. * @argument {Object} data - The data object generated by `update` method
  30907. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  30908. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  30909. * @argument {Object} options - Modifiers configuration and options
  30910. * @returns {Object} The same data object
  30911. */
  30912. function applyStyle(data) {
  30913. // any property present in `data.styles` will be applied to the popper,
  30914. // in this way we can make the 3rd party modifiers add custom styles to it
  30915. // Be aware, modifiers could override the properties defined in the previous
  30916. // lines of this modifier!
  30917. setStyles(data.instance.popper, data.styles);
  30918. // any property present in `data.attributes` will be applied to the popper,
  30919. // they will be set as HTML attributes of the element
  30920. setAttributes(data.instance.popper, data.attributes);
  30921. // if arrowElement is defined and arrowStyles has some properties
  30922. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  30923. setStyles(data.arrowElement, data.arrowStyles);
  30924. }
  30925. return data;
  30926. }
  30927. /**
  30928. * Set the x-placement attribute before everything else because it could be used
  30929. * to add margins to the popper margins needs to be calculated to get the
  30930. * correct popper offsets.
  30931. * @method
  30932. * @memberof Popper.modifiers
  30933. * @param {HTMLElement} reference - The reference element used to position the popper
  30934. * @param {HTMLElement} popper - The HTML element used as popper
  30935. * @param {Object} options - Popper.js options
  30936. */
  30937. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  30938. // compute reference element offsets
  30939. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  30940. // compute auto placement, store placement inside the data object,
  30941. // modifiers will be able to edit `placement` if needed
  30942. // and refer to originalPlacement to know the original value
  30943. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  30944. popper.setAttribute('x-placement', placement);
  30945. // Apply `position` to popper before anything else because
  30946. // without the position applied we can't guarantee correct computations
  30947. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  30948. return options;
  30949. }
  30950. /**
  30951. * @function
  30952. * @memberof Popper.Utils
  30953. * @argument {Object} data - The data object generated by `update` method
  30954. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  30955. * @returns {Object} The popper's position offsets rounded
  30956. *
  30957. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  30958. * good as it can be within reason.
  30959. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  30960. *
  30961. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  30962. * as well on High DPI screens).
  30963. *
  30964. * Firefox prefers no rounding for positioning and does not have blurriness on
  30965. * high DPI screens.
  30966. *
  30967. * Only horizontal placement and left/right values need to be considered.
  30968. */
  30969. function getRoundedOffsets(data, shouldRound) {
  30970. var _data$offsets = data.offsets,
  30971. popper = _data$offsets.popper,
  30972. reference = _data$offsets.reference;
  30973. var round = Math.round,
  30974. floor = Math.floor;
  30975. var noRound = function noRound(v) {
  30976. return v;
  30977. };
  30978. var referenceWidth = round(reference.width);
  30979. var popperWidth = round(popper.width);
  30980. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  30981. var isVariation = data.placement.indexOf('-') !== -1;
  30982. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  30983. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  30984. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  30985. var verticalToInteger = !shouldRound ? noRound : round;
  30986. return {
  30987. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  30988. top: verticalToInteger(popper.top),
  30989. bottom: verticalToInteger(popper.bottom),
  30990. right: horizontalToInteger(popper.right)
  30991. };
  30992. }
  30993. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  30994. /**
  30995. * @function
  30996. * @memberof Modifiers
  30997. * @argument {Object} data - The data object generated by `update` method
  30998. * @argument {Object} options - Modifiers configuration and options
  30999. * @returns {Object} The data object, properly modified
  31000. */
  31001. function computeStyle(data, options) {
  31002. var x = options.x,
  31003. y = options.y;
  31004. var popper = data.offsets.popper;
  31005. // Remove this legacy support in Popper.js v2
  31006. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  31007. return modifier.name === 'applyStyle';
  31008. }).gpuAcceleration;
  31009. if (legacyGpuAccelerationOption !== undefined) {
  31010. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  31011. }
  31012. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  31013. var offsetParent = getOffsetParent(data.instance.popper);
  31014. var offsetParentRect = getBoundingClientRect(offsetParent);
  31015. // Styles
  31016. var styles = {
  31017. position: popper.position
  31018. };
  31019. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  31020. var sideA = x === 'bottom' ? 'top' : 'bottom';
  31021. var sideB = y === 'right' ? 'left' : 'right';
  31022. // if gpuAcceleration is set to `true` and transform is supported,
  31023. // we use `translate3d` to apply the position to the popper we
  31024. // automatically use the supported prefixed version if needed
  31025. var prefixedProperty = getSupportedPropertyName('transform');
  31026. // now, let's make a step back and look at this code closely (wtf?)
  31027. // If the content of the popper grows once it's been positioned, it
  31028. // may happen that the popper gets misplaced because of the new content
  31029. // overflowing its reference element
  31030. // To avoid this problem, we provide two options (x and y), which allow
  31031. // the consumer to define the offset origin.
  31032. // If we position a popper on top of a reference element, we can set
  31033. // `x` to `top` to make the popper grow towards its top instead of
  31034. // its bottom.
  31035. var left = void 0,
  31036. top = void 0;
  31037. if (sideA === 'bottom') {
  31038. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  31039. // and not the bottom of the html element
  31040. if (offsetParent.nodeName === 'HTML') {
  31041. top = -offsetParent.clientHeight + offsets.bottom;
  31042. } else {
  31043. top = -offsetParentRect.height + offsets.bottom;
  31044. }
  31045. } else {
  31046. top = offsets.top;
  31047. }
  31048. if (sideB === 'right') {
  31049. if (offsetParent.nodeName === 'HTML') {
  31050. left = -offsetParent.clientWidth + offsets.right;
  31051. } else {
  31052. left = -offsetParentRect.width + offsets.right;
  31053. }
  31054. } else {
  31055. left = offsets.left;
  31056. }
  31057. if (gpuAcceleration && prefixedProperty) {
  31058. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  31059. styles[sideA] = 0;
  31060. styles[sideB] = 0;
  31061. styles.willChange = 'transform';
  31062. } else {
  31063. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  31064. var invertTop = sideA === 'bottom' ? -1 : 1;
  31065. var invertLeft = sideB === 'right' ? -1 : 1;
  31066. styles[sideA] = top * invertTop;
  31067. styles[sideB] = left * invertLeft;
  31068. styles.willChange = sideA + ', ' + sideB;
  31069. }
  31070. // Attributes
  31071. var attributes = {
  31072. 'x-placement': data.placement
  31073. };
  31074. // Update `data` attributes, styles and arrowStyles
  31075. data.attributes = _extends({}, attributes, data.attributes);
  31076. data.styles = _extends({}, styles, data.styles);
  31077. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  31078. return data;
  31079. }
  31080. /**
  31081. * Helper used to know if the given modifier depends from another one.<br />
  31082. * It checks if the needed modifier is listed and enabled.
  31083. * @method
  31084. * @memberof Popper.Utils
  31085. * @param {Array} modifiers - list of modifiers
  31086. * @param {String} requestingName - name of requesting modifier
  31087. * @param {String} requestedName - name of requested modifier
  31088. * @returns {Boolean}
  31089. */
  31090. function isModifierRequired(modifiers, requestingName, requestedName) {
  31091. var requesting = find(modifiers, function (_ref) {
  31092. var name = _ref.name;
  31093. return name === requestingName;
  31094. });
  31095. var isRequired = !!requesting && modifiers.some(function (modifier) {
  31096. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  31097. });
  31098. if (!isRequired) {
  31099. var _requesting = '`' + requestingName + '`';
  31100. var requested = '`' + requestedName + '`';
  31101. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  31102. }
  31103. return isRequired;
  31104. }
  31105. /**
  31106. * @function
  31107. * @memberof Modifiers
  31108. * @argument {Object} data - The data object generated by update method
  31109. * @argument {Object} options - Modifiers configuration and options
  31110. * @returns {Object} The data object, properly modified
  31111. */
  31112. function arrow(data, options) {
  31113. var _data$offsets$arrow;
  31114. // arrow depends on keepTogether in order to work
  31115. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  31116. return data;
  31117. }
  31118. var arrowElement = options.element;
  31119. // if arrowElement is a string, suppose it's a CSS selector
  31120. if (typeof arrowElement === 'string') {
  31121. arrowElement = data.instance.popper.querySelector(arrowElement);
  31122. // if arrowElement is not found, don't run the modifier
  31123. if (!arrowElement) {
  31124. return data;
  31125. }
  31126. } else {
  31127. // if the arrowElement isn't a query selector we must check that the
  31128. // provided DOM node is child of its popper node
  31129. if (!data.instance.popper.contains(arrowElement)) {
  31130. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  31131. return data;
  31132. }
  31133. }
  31134. var placement = data.placement.split('-')[0];
  31135. var _data$offsets = data.offsets,
  31136. popper = _data$offsets.popper,
  31137. reference = _data$offsets.reference;
  31138. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  31139. var len = isVertical ? 'height' : 'width';
  31140. var sideCapitalized = isVertical ? 'Top' : 'Left';
  31141. var side = sideCapitalized.toLowerCase();
  31142. var altSide = isVertical ? 'left' : 'top';
  31143. var opSide = isVertical ? 'bottom' : 'right';
  31144. var arrowElementSize = getOuterSizes(arrowElement)[len];
  31145. //
  31146. // extends keepTogether behavior making sure the popper and its
  31147. // reference have enough pixels in conjunction
  31148. //
  31149. // top/left side
  31150. if (reference[opSide] - arrowElementSize < popper[side]) {
  31151. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  31152. }
  31153. // bottom/right side
  31154. if (reference[side] + arrowElementSize > popper[opSide]) {
  31155. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  31156. }
  31157. data.offsets.popper = getClientRect(data.offsets.popper);
  31158. // compute center of the popper
  31159. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  31160. // Compute the sideValue using the updated popper offsets
  31161. // take popper margin in account because we don't have this info available
  31162. var css = getStyleComputedProperty(data.instance.popper);
  31163. var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10);
  31164. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10);
  31165. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  31166. // prevent arrowElement from being placed not contiguously to its popper
  31167. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  31168. data.arrowElement = arrowElement;
  31169. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  31170. return data;
  31171. }
  31172. /**
  31173. * Get the opposite placement variation of the given one
  31174. * @method
  31175. * @memberof Popper.Utils
  31176. * @argument {String} placement variation
  31177. * @returns {String} flipped placement variation
  31178. */
  31179. function getOppositeVariation(variation) {
  31180. if (variation === 'end') {
  31181. return 'start';
  31182. } else if (variation === 'start') {
  31183. return 'end';
  31184. }
  31185. return variation;
  31186. }
  31187. /**
  31188. * List of accepted placements to use as values of the `placement` option.<br />
  31189. * Valid placements are:
  31190. * - `auto`
  31191. * - `top`
  31192. * - `right`
  31193. * - `bottom`
  31194. * - `left`
  31195. *
  31196. * Each placement can have a variation from this list:
  31197. * - `-start`
  31198. * - `-end`
  31199. *
  31200. * Variations are interpreted easily if you think of them as the left to right
  31201. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  31202. * is right.<br />
  31203. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  31204. *
  31205. * Some valid examples are:
  31206. * - `top-end` (on top of reference, right aligned)
  31207. * - `right-start` (on right of reference, top aligned)
  31208. * - `bottom` (on bottom, centered)
  31209. * - `auto-end` (on the side with more space available, alignment depends by placement)
  31210. *
  31211. * @static
  31212. * @type {Array}
  31213. * @enum {String}
  31214. * @readonly
  31215. * @method placements
  31216. * @memberof Popper
  31217. */
  31218. var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
  31219. // Get rid of `auto` `auto-start` and `auto-end`
  31220. var validPlacements = placements.slice(3);
  31221. /**
  31222. * Given an initial placement, returns all the subsequent placements
  31223. * clockwise (or counter-clockwise).
  31224. *
  31225. * @method
  31226. * @memberof Popper.Utils
  31227. * @argument {String} placement - A valid placement (it accepts variations)
  31228. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  31229. * @returns {Array} placements including their variations
  31230. */
  31231. function clockwise(placement) {
  31232. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  31233. var index = validPlacements.indexOf(placement);
  31234. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  31235. return counter ? arr.reverse() : arr;
  31236. }
  31237. var BEHAVIORS = {
  31238. FLIP: 'flip',
  31239. CLOCKWISE: 'clockwise',
  31240. COUNTERCLOCKWISE: 'counterclockwise'
  31241. };
  31242. /**
  31243. * @function
  31244. * @memberof Modifiers
  31245. * @argument {Object} data - The data object generated by update method
  31246. * @argument {Object} options - Modifiers configuration and options
  31247. * @returns {Object} The data object, properly modified
  31248. */
  31249. function flip(data, options) {
  31250. // if `inner` modifier is enabled, we can't use the `flip` modifier
  31251. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  31252. return data;
  31253. }
  31254. if (data.flipped && data.placement === data.originalPlacement) {
  31255. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  31256. return data;
  31257. }
  31258. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  31259. var placement = data.placement.split('-')[0];
  31260. var placementOpposite = getOppositePlacement(placement);
  31261. var variation = data.placement.split('-')[1] || '';
  31262. var flipOrder = [];
  31263. switch (options.behavior) {
  31264. case BEHAVIORS.FLIP:
  31265. flipOrder = [placement, placementOpposite];
  31266. break;
  31267. case BEHAVIORS.CLOCKWISE:
  31268. flipOrder = clockwise(placement);
  31269. break;
  31270. case BEHAVIORS.COUNTERCLOCKWISE:
  31271. flipOrder = clockwise(placement, true);
  31272. break;
  31273. default:
  31274. flipOrder = options.behavior;
  31275. }
  31276. flipOrder.forEach(function (step, index) {
  31277. if (placement !== step || flipOrder.length === index + 1) {
  31278. return data;
  31279. }
  31280. placement = data.placement.split('-')[0];
  31281. placementOpposite = getOppositePlacement(placement);
  31282. var popperOffsets = data.offsets.popper;
  31283. var refOffsets = data.offsets.reference;
  31284. // using floor because the reference offsets may contain decimals we are not going to consider here
  31285. var floor = Math.floor;
  31286. var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
  31287. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  31288. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  31289. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  31290. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  31291. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  31292. // flip the variation if required
  31293. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  31294. // flips variation if reference element overflows boundaries
  31295. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  31296. // flips variation if popper content overflows boundaries
  31297. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  31298. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  31299. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  31300. // this boolean to detect any flip loop
  31301. data.flipped = true;
  31302. if (overlapsRef || overflowsBoundaries) {
  31303. placement = flipOrder[index + 1];
  31304. }
  31305. if (flippedVariation) {
  31306. variation = getOppositeVariation(variation);
  31307. }
  31308. data.placement = placement + (variation ? '-' + variation : '');
  31309. // this object contains `position`, we want to preserve it along with
  31310. // any additional property we may add in the future
  31311. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  31312. data = runModifiers(data.instance.modifiers, data, 'flip');
  31313. }
  31314. });
  31315. return data;
  31316. }
  31317. /**
  31318. * @function
  31319. * @memberof Modifiers
  31320. * @argument {Object} data - The data object generated by update method
  31321. * @argument {Object} options - Modifiers configuration and options
  31322. * @returns {Object} The data object, properly modified
  31323. */
  31324. function keepTogether(data) {
  31325. var _data$offsets = data.offsets,
  31326. popper = _data$offsets.popper,
  31327. reference = _data$offsets.reference;
  31328. var placement = data.placement.split('-')[0];
  31329. var floor = Math.floor;
  31330. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  31331. var side = isVertical ? 'right' : 'bottom';
  31332. var opSide = isVertical ? 'left' : 'top';
  31333. var measurement = isVertical ? 'width' : 'height';
  31334. if (popper[side] < floor(reference[opSide])) {
  31335. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  31336. }
  31337. if (popper[opSide] > floor(reference[side])) {
  31338. data.offsets.popper[opSide] = floor(reference[side]);
  31339. }
  31340. return data;
  31341. }
  31342. /**
  31343. * Converts a string containing value + unit into a px value number
  31344. * @function
  31345. * @memberof {modifiers~offset}
  31346. * @private
  31347. * @argument {String} str - Value + unit string
  31348. * @argument {String} measurement - `height` or `width`
  31349. * @argument {Object} popperOffsets
  31350. * @argument {Object} referenceOffsets
  31351. * @returns {Number|String}
  31352. * Value in pixels, or original string if no values were extracted
  31353. */
  31354. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  31355. // separate value from unit
  31356. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  31357. var value = +split[1];
  31358. var unit = split[2];
  31359. // If it's not a number it's an operator, I guess
  31360. if (!value) {
  31361. return str;
  31362. }
  31363. if (unit.indexOf('%') === 0) {
  31364. var element = void 0;
  31365. switch (unit) {
  31366. case '%p':
  31367. element = popperOffsets;
  31368. break;
  31369. case '%':
  31370. case '%r':
  31371. default:
  31372. element = referenceOffsets;
  31373. }
  31374. var rect = getClientRect(element);
  31375. return rect[measurement] / 100 * value;
  31376. } else if (unit === 'vh' || unit === 'vw') {
  31377. // if is a vh or vw, we calculate the size based on the viewport
  31378. var size = void 0;
  31379. if (unit === 'vh') {
  31380. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  31381. } else {
  31382. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  31383. }
  31384. return size / 100 * value;
  31385. } else {
  31386. // if is an explicit pixel unit, we get rid of the unit and keep the value
  31387. // if is an implicit unit, it's px, and we return just the value
  31388. return value;
  31389. }
  31390. }
  31391. /**
  31392. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  31393. * @function
  31394. * @memberof {modifiers~offset}
  31395. * @private
  31396. * @argument {String} offset
  31397. * @argument {Object} popperOffsets
  31398. * @argument {Object} referenceOffsets
  31399. * @argument {String} basePlacement
  31400. * @returns {Array} a two cells array with x and y offsets in numbers
  31401. */
  31402. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  31403. var offsets = [0, 0];
  31404. // Use height if placement is left or right and index is 0 otherwise use width
  31405. // in this way the first offset will use an axis and the second one
  31406. // will use the other one
  31407. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  31408. // Split the offset string to obtain a list of values and operands
  31409. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  31410. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  31411. return frag.trim();
  31412. });
  31413. // Detect if the offset string contains a pair of values or a single one
  31414. // they could be separated by comma or space
  31415. var divider = fragments.indexOf(find(fragments, function (frag) {
  31416. return frag.search(/,|\s/) !== -1;
  31417. }));
  31418. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  31419. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  31420. }
  31421. // If divider is found, we divide the list of values and operands to divide
  31422. // them by ofset X and Y.
  31423. var splitRegex = /\s*,\s*|\s+/;
  31424. var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
  31425. // Convert the values with units to absolute pixels to allow our computations
  31426. ops = ops.map(function (op, index) {
  31427. // Most of the units rely on the orientation of the popper
  31428. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  31429. var mergeWithPrevious = false;
  31430. return op
  31431. // This aggregates any `+` or `-` sign that aren't considered operators
  31432. // e.g.: 10 + +5 => [10, +, +5]
  31433. .reduce(function (a, b) {
  31434. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  31435. a[a.length - 1] = b;
  31436. mergeWithPrevious = true;
  31437. return a;
  31438. } else if (mergeWithPrevious) {
  31439. a[a.length - 1] += b;
  31440. mergeWithPrevious = false;
  31441. return a;
  31442. } else {
  31443. return a.concat(b);
  31444. }
  31445. }, [])
  31446. // Here we convert the string values into number values (in px)
  31447. .map(function (str) {
  31448. return toValue(str, measurement, popperOffsets, referenceOffsets);
  31449. });
  31450. });
  31451. // Loop trough the offsets arrays and execute the operations
  31452. ops.forEach(function (op, index) {
  31453. op.forEach(function (frag, index2) {
  31454. if (isNumeric(frag)) {
  31455. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  31456. }
  31457. });
  31458. });
  31459. return offsets;
  31460. }
  31461. /**
  31462. * @function
  31463. * @memberof Modifiers
  31464. * @argument {Object} data - The data object generated by update method
  31465. * @argument {Object} options - Modifiers configuration and options
  31466. * @argument {Number|String} options.offset=0
  31467. * The offset value as described in the modifier description
  31468. * @returns {Object} The data object, properly modified
  31469. */
  31470. function offset(data, _ref) {
  31471. var offset = _ref.offset;
  31472. var placement = data.placement,
  31473. _data$offsets = data.offsets,
  31474. popper = _data$offsets.popper,
  31475. reference = _data$offsets.reference;
  31476. var basePlacement = placement.split('-')[0];
  31477. var offsets = void 0;
  31478. if (isNumeric(+offset)) {
  31479. offsets = [+offset, 0];
  31480. } else {
  31481. offsets = parseOffset(offset, popper, reference, basePlacement);
  31482. }
  31483. if (basePlacement === 'left') {
  31484. popper.top += offsets[0];
  31485. popper.left -= offsets[1];
  31486. } else if (basePlacement === 'right') {
  31487. popper.top += offsets[0];
  31488. popper.left += offsets[1];
  31489. } else if (basePlacement === 'top') {
  31490. popper.left += offsets[0];
  31491. popper.top -= offsets[1];
  31492. } else if (basePlacement === 'bottom') {
  31493. popper.left += offsets[0];
  31494. popper.top += offsets[1];
  31495. }
  31496. data.popper = popper;
  31497. return data;
  31498. }
  31499. /**
  31500. * @function
  31501. * @memberof Modifiers
  31502. * @argument {Object} data - The data object generated by `update` method
  31503. * @argument {Object} options - Modifiers configuration and options
  31504. * @returns {Object} The data object, properly modified
  31505. */
  31506. function preventOverflow(data, options) {
  31507. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  31508. // If offsetParent is the reference element, we really want to
  31509. // go one step up and use the next offsetParent as reference to
  31510. // avoid to make this modifier completely useless and look like broken
  31511. if (data.instance.reference === boundariesElement) {
  31512. boundariesElement = getOffsetParent(boundariesElement);
  31513. }
  31514. // NOTE: DOM access here
  31515. // resets the popper's position so that the document size can be calculated excluding
  31516. // the size of the popper element itself
  31517. var transformProp = getSupportedPropertyName('transform');
  31518. var popperStyles = data.instance.popper.style; // assignment to help minification
  31519. var top = popperStyles.top,
  31520. left = popperStyles.left,
  31521. transform = popperStyles[transformProp];
  31522. popperStyles.top = '';
  31523. popperStyles.left = '';
  31524. popperStyles[transformProp] = '';
  31525. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  31526. // NOTE: DOM access here
  31527. // restores the original style properties after the offsets have been computed
  31528. popperStyles.top = top;
  31529. popperStyles.left = left;
  31530. popperStyles[transformProp] = transform;
  31531. options.boundaries = boundaries;
  31532. var order = options.priority;
  31533. var popper = data.offsets.popper;
  31534. var check = {
  31535. primary: function primary(placement) {
  31536. var value = popper[placement];
  31537. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  31538. value = Math.max(popper[placement], boundaries[placement]);
  31539. }
  31540. return defineProperty({}, placement, value);
  31541. },
  31542. secondary: function secondary(placement) {
  31543. var mainSide = placement === 'right' ? 'left' : 'top';
  31544. var value = popper[mainSide];
  31545. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  31546. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  31547. }
  31548. return defineProperty({}, mainSide, value);
  31549. }
  31550. };
  31551. order.forEach(function (placement) {
  31552. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  31553. popper = _extends({}, popper, check[side](placement));
  31554. });
  31555. data.offsets.popper = popper;
  31556. return data;
  31557. }
  31558. /**
  31559. * @function
  31560. * @memberof Modifiers
  31561. * @argument {Object} data - The data object generated by `update` method
  31562. * @argument {Object} options - Modifiers configuration and options
  31563. * @returns {Object} The data object, properly modified
  31564. */
  31565. function shift(data) {
  31566. var placement = data.placement;
  31567. var basePlacement = placement.split('-')[0];
  31568. var shiftvariation = placement.split('-')[1];
  31569. // if shift shiftvariation is specified, run the modifier
  31570. if (shiftvariation) {
  31571. var _data$offsets = data.offsets,
  31572. reference = _data$offsets.reference,
  31573. popper = _data$offsets.popper;
  31574. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  31575. var side = isVertical ? 'left' : 'top';
  31576. var measurement = isVertical ? 'width' : 'height';
  31577. var shiftOffsets = {
  31578. start: defineProperty({}, side, reference[side]),
  31579. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  31580. };
  31581. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  31582. }
  31583. return data;
  31584. }
  31585. /**
  31586. * @function
  31587. * @memberof Modifiers
  31588. * @argument {Object} data - The data object generated by update method
  31589. * @argument {Object} options - Modifiers configuration and options
  31590. * @returns {Object} The data object, properly modified
  31591. */
  31592. function hide(data) {
  31593. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  31594. return data;
  31595. }
  31596. var refRect = data.offsets.reference;
  31597. var bound = find(data.instance.modifiers, function (modifier) {
  31598. return modifier.name === 'preventOverflow';
  31599. }).boundaries;
  31600. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  31601. // Avoid unnecessary DOM access if visibility hasn't changed
  31602. if (data.hide === true) {
  31603. return data;
  31604. }
  31605. data.hide = true;
  31606. data.attributes['x-out-of-boundaries'] = '';
  31607. } else {
  31608. // Avoid unnecessary DOM access if visibility hasn't changed
  31609. if (data.hide === false) {
  31610. return data;
  31611. }
  31612. data.hide = false;
  31613. data.attributes['x-out-of-boundaries'] = false;
  31614. }
  31615. return data;
  31616. }
  31617. /**
  31618. * @function
  31619. * @memberof Modifiers
  31620. * @argument {Object} data - The data object generated by `update` method
  31621. * @argument {Object} options - Modifiers configuration and options
  31622. * @returns {Object} The data object, properly modified
  31623. */
  31624. function inner(data) {
  31625. var placement = data.placement;
  31626. var basePlacement = placement.split('-')[0];
  31627. var _data$offsets = data.offsets,
  31628. popper = _data$offsets.popper,
  31629. reference = _data$offsets.reference;
  31630. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  31631. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  31632. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  31633. data.placement = getOppositePlacement(placement);
  31634. data.offsets.popper = getClientRect(popper);
  31635. return data;
  31636. }
  31637. /**
  31638. * Modifier function, each modifier can have a function of this type assigned
  31639. * to its `fn` property.<br />
  31640. * These functions will be called on each update, this means that you must
  31641. * make sure they are performant enough to avoid performance bottlenecks.
  31642. *
  31643. * @function ModifierFn
  31644. * @argument {dataObject} data - The data object generated by `update` method
  31645. * @argument {Object} options - Modifiers configuration and options
  31646. * @returns {dataObject} The data object, properly modified
  31647. */
  31648. /**
  31649. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  31650. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  31651. * needed by the library.
  31652. *
  31653. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  31654. * All the other properties are configurations that could be tweaked.
  31655. * @namespace modifiers
  31656. */
  31657. var modifiers = {
  31658. /**
  31659. * Modifier used to shift the popper on the start or end of its reference
  31660. * element.<br />
  31661. * It will read the variation of the `placement` property.<br />
  31662. * It can be one either `-end` or `-start`.
  31663. * @memberof modifiers
  31664. * @inner
  31665. */
  31666. shift: {
  31667. /** @prop {number} order=100 - Index used to define the order of execution */
  31668. order: 100,
  31669. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31670. enabled: true,
  31671. /** @prop {ModifierFn} */
  31672. fn: shift
  31673. },
  31674. /**
  31675. * The `offset` modifier can shift your popper on both its axis.
  31676. *
  31677. * It accepts the following units:
  31678. * - `px` or unit-less, interpreted as pixels
  31679. * - `%` or `%r`, percentage relative to the length of the reference element
  31680. * - `%p`, percentage relative to the length of the popper element
  31681. * - `vw`, CSS viewport width unit
  31682. * - `vh`, CSS viewport height unit
  31683. *
  31684. * For length is intended the main axis relative to the placement of the popper.<br />
  31685. * This means that if the placement is `top` or `bottom`, the length will be the
  31686. * `width`. In case of `left` or `right`, it will be the `height`.
  31687. *
  31688. * You can provide a single value (as `Number` or `String`), or a pair of values
  31689. * as `String` divided by a comma or one (or more) white spaces.<br />
  31690. * The latter is a deprecated method because it leads to confusion and will be
  31691. * removed in v2.<br />
  31692. * Additionally, it accepts additions and subtractions between different units.
  31693. * Note that multiplications and divisions aren't supported.
  31694. *
  31695. * Valid examples are:
  31696. * ```
  31697. * 10
  31698. * '10%'
  31699. * '10, 10'
  31700. * '10%, 10'
  31701. * '10 + 10%'
  31702. * '10 - 5vh + 3%'
  31703. * '-10px + 5vh, 5px - 6%'
  31704. * ```
  31705. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  31706. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  31707. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  31708. *
  31709. * @memberof modifiers
  31710. * @inner
  31711. */
  31712. offset: {
  31713. /** @prop {number} order=200 - Index used to define the order of execution */
  31714. order: 200,
  31715. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31716. enabled: true,
  31717. /** @prop {ModifierFn} */
  31718. fn: offset,
  31719. /** @prop {Number|String} offset=0
  31720. * The offset value as described in the modifier description
  31721. */
  31722. offset: 0
  31723. },
  31724. /**
  31725. * Modifier used to prevent the popper from being positioned outside the boundary.
  31726. *
  31727. * A scenario exists where the reference itself is not within the boundaries.<br />
  31728. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  31729. * In this case we need to decide whether the popper should either:
  31730. *
  31731. * - detach from the reference and remain "trapped" in the boundaries, or
  31732. * - if it should ignore the boundary and "escape with its reference"
  31733. *
  31734. * When `escapeWithReference` is set to`true` and reference is completely
  31735. * outside its boundaries, the popper will overflow (or completely leave)
  31736. * the boundaries in order to remain attached to the edge of the reference.
  31737. *
  31738. * @memberof modifiers
  31739. * @inner
  31740. */
  31741. preventOverflow: {
  31742. /** @prop {number} order=300 - Index used to define the order of execution */
  31743. order: 300,
  31744. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31745. enabled: true,
  31746. /** @prop {ModifierFn} */
  31747. fn: preventOverflow,
  31748. /**
  31749. * @prop {Array} [priority=['left','right','top','bottom']]
  31750. * Popper will try to prevent overflow following these priorities by default,
  31751. * then, it could overflow on the left and on top of the `boundariesElement`
  31752. */
  31753. priority: ['left', 'right', 'top', 'bottom'],
  31754. /**
  31755. * @prop {number} padding=5
  31756. * Amount of pixel used to define a minimum distance between the boundaries
  31757. * and the popper. This makes sure the popper always has a little padding
  31758. * between the edges of its container
  31759. */
  31760. padding: 5,
  31761. /**
  31762. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  31763. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  31764. * `viewport` or any DOM element.
  31765. */
  31766. boundariesElement: 'scrollParent'
  31767. },
  31768. /**
  31769. * Modifier used to make sure the reference and its popper stay near each other
  31770. * without leaving any gap between the two. Especially useful when the arrow is
  31771. * enabled and you want to ensure that it points to its reference element.
  31772. * It cares only about the first axis. You can still have poppers with margin
  31773. * between the popper and its reference element.
  31774. * @memberof modifiers
  31775. * @inner
  31776. */
  31777. keepTogether: {
  31778. /** @prop {number} order=400 - Index used to define the order of execution */
  31779. order: 400,
  31780. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31781. enabled: true,
  31782. /** @prop {ModifierFn} */
  31783. fn: keepTogether
  31784. },
  31785. /**
  31786. * This modifier is used to move the `arrowElement` of the popper to make
  31787. * sure it is positioned between the reference element and its popper element.
  31788. * It will read the outer size of the `arrowElement` node to detect how many
  31789. * pixels of conjunction are needed.
  31790. *
  31791. * It has no effect if no `arrowElement` is provided.
  31792. * @memberof modifiers
  31793. * @inner
  31794. */
  31795. arrow: {
  31796. /** @prop {number} order=500 - Index used to define the order of execution */
  31797. order: 500,
  31798. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31799. enabled: true,
  31800. /** @prop {ModifierFn} */
  31801. fn: arrow,
  31802. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  31803. element: '[x-arrow]'
  31804. },
  31805. /**
  31806. * Modifier used to flip the popper's placement when it starts to overlap its
  31807. * reference element.
  31808. *
  31809. * Requires the `preventOverflow` modifier before it in order to work.
  31810. *
  31811. * **NOTE:** this modifier will interrupt the current update cycle and will
  31812. * restart it if it detects the need to flip the placement.
  31813. * @memberof modifiers
  31814. * @inner
  31815. */
  31816. flip: {
  31817. /** @prop {number} order=600 - Index used to define the order of execution */
  31818. order: 600,
  31819. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31820. enabled: true,
  31821. /** @prop {ModifierFn} */
  31822. fn: flip,
  31823. /**
  31824. * @prop {String|Array} behavior='flip'
  31825. * The behavior used to change the popper's placement. It can be one of
  31826. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  31827. * placements (with optional variations)
  31828. */
  31829. behavior: 'flip',
  31830. /**
  31831. * @prop {number} padding=5
  31832. * The popper will flip if it hits the edges of the `boundariesElement`
  31833. */
  31834. padding: 5,
  31835. /**
  31836. * @prop {String|HTMLElement} boundariesElement='viewport'
  31837. * The element which will define the boundaries of the popper position.
  31838. * The popper will never be placed outside of the defined boundaries
  31839. * (except if `keepTogether` is enabled)
  31840. */
  31841. boundariesElement: 'viewport',
  31842. /**
  31843. * @prop {Boolean} flipVariations=false
  31844. * The popper will switch placement variation between `-start` and `-end` when
  31845. * the reference element overlaps its boundaries.
  31846. *
  31847. * The original placement should have a set variation.
  31848. */
  31849. flipVariations: false,
  31850. /**
  31851. * @prop {Boolean} flipVariationsByContent=false
  31852. * The popper will switch placement variation between `-start` and `-end` when
  31853. * the popper element overlaps its reference boundaries.
  31854. *
  31855. * The original placement should have a set variation.
  31856. */
  31857. flipVariationsByContent: false
  31858. },
  31859. /**
  31860. * Modifier used to make the popper flow toward the inner of the reference element.
  31861. * By default, when this modifier is disabled, the popper will be placed outside
  31862. * the reference element.
  31863. * @memberof modifiers
  31864. * @inner
  31865. */
  31866. inner: {
  31867. /** @prop {number} order=700 - Index used to define the order of execution */
  31868. order: 700,
  31869. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  31870. enabled: false,
  31871. /** @prop {ModifierFn} */
  31872. fn: inner
  31873. },
  31874. /**
  31875. * Modifier used to hide the popper when its reference element is outside of the
  31876. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  31877. * be used to hide with a CSS selector the popper when its reference is
  31878. * out of boundaries.
  31879. *
  31880. * Requires the `preventOverflow` modifier before it in order to work.
  31881. * @memberof modifiers
  31882. * @inner
  31883. */
  31884. hide: {
  31885. /** @prop {number} order=800 - Index used to define the order of execution */
  31886. order: 800,
  31887. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31888. enabled: true,
  31889. /** @prop {ModifierFn} */
  31890. fn: hide
  31891. },
  31892. /**
  31893. * Computes the style that will be applied to the popper element to gets
  31894. * properly positioned.
  31895. *
  31896. * Note that this modifier will not touch the DOM, it just prepares the styles
  31897. * so that `applyStyle` modifier can apply it. This separation is useful
  31898. * in case you need to replace `applyStyle` with a custom implementation.
  31899. *
  31900. * This modifier has `850` as `order` value to maintain backward compatibility
  31901. * with previous versions of Popper.js. Expect the modifiers ordering method
  31902. * to change in future major versions of the library.
  31903. *
  31904. * @memberof modifiers
  31905. * @inner
  31906. */
  31907. computeStyle: {
  31908. /** @prop {number} order=850 - Index used to define the order of execution */
  31909. order: 850,
  31910. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31911. enabled: true,
  31912. /** @prop {ModifierFn} */
  31913. fn: computeStyle,
  31914. /**
  31915. * @prop {Boolean} gpuAcceleration=true
  31916. * If true, it uses the CSS 3D transformation to position the popper.
  31917. * Otherwise, it will use the `top` and `left` properties
  31918. */
  31919. gpuAcceleration: true,
  31920. /**
  31921. * @prop {string} [x='bottom']
  31922. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  31923. * Change this if your popper should grow in a direction different from `bottom`
  31924. */
  31925. x: 'bottom',
  31926. /**
  31927. * @prop {string} [x='left']
  31928. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  31929. * Change this if your popper should grow in a direction different from `right`
  31930. */
  31931. y: 'right'
  31932. },
  31933. /**
  31934. * Applies the computed styles to the popper element.
  31935. *
  31936. * All the DOM manipulations are limited to this modifier. This is useful in case
  31937. * you want to integrate Popper.js inside a framework or view library and you
  31938. * want to delegate all the DOM manipulations to it.
  31939. *
  31940. * Note that if you disable this modifier, you must make sure the popper element
  31941. * has its position set to `absolute` before Popper.js can do its work!
  31942. *
  31943. * Just disable this modifier and define your own to achieve the desired effect.
  31944. *
  31945. * @memberof modifiers
  31946. * @inner
  31947. */
  31948. applyStyle: {
  31949. /** @prop {number} order=900 - Index used to define the order of execution */
  31950. order: 900,
  31951. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31952. enabled: true,
  31953. /** @prop {ModifierFn} */
  31954. fn: applyStyle,
  31955. /** @prop {Function} */
  31956. onLoad: applyStyleOnLoad,
  31957. /**
  31958. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  31959. * @prop {Boolean} gpuAcceleration=true
  31960. * If true, it uses the CSS 3D transformation to position the popper.
  31961. * Otherwise, it will use the `top` and `left` properties
  31962. */
  31963. gpuAcceleration: undefined
  31964. }
  31965. };
  31966. /**
  31967. * The `dataObject` is an object containing all the information used by Popper.js.
  31968. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  31969. * @name dataObject
  31970. * @property {Object} data.instance The Popper.js instance
  31971. * @property {String} data.placement Placement applied to popper
  31972. * @property {String} data.originalPlacement Placement originally defined on init
  31973. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  31974. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  31975. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  31976. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  31977. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  31978. * @property {Object} data.boundaries Offsets of the popper boundaries
  31979. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  31980. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  31981. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  31982. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  31983. */
  31984. /**
  31985. * Default options provided to Popper.js constructor.<br />
  31986. * These can be overridden using the `options` argument of Popper.js.<br />
  31987. * To override an option, simply pass an object with the same
  31988. * structure of the `options` object, as the 3rd argument. For example:
  31989. * ```
  31990. * new Popper(ref, pop, {
  31991. * modifiers: {
  31992. * preventOverflow: { enabled: false }
  31993. * }
  31994. * })
  31995. * ```
  31996. * @type {Object}
  31997. * @static
  31998. * @memberof Popper
  31999. */
  32000. var Defaults = {
  32001. /**
  32002. * Popper's placement.
  32003. * @prop {Popper.placements} placement='bottom'
  32004. */
  32005. placement: 'bottom',
  32006. /**
  32007. * Set this to true if you want popper to position it self in 'fixed' mode
  32008. * @prop {Boolean} positionFixed=false
  32009. */
  32010. positionFixed: false,
  32011. /**
  32012. * Whether events (resize, scroll) are initially enabled.
  32013. * @prop {Boolean} eventsEnabled=true
  32014. */
  32015. eventsEnabled: true,
  32016. /**
  32017. * Set to true if you want to automatically remove the popper when
  32018. * you call the `destroy` method.
  32019. * @prop {Boolean} removeOnDestroy=false
  32020. */
  32021. removeOnDestroy: false,
  32022. /**
  32023. * Callback called when the popper is created.<br />
  32024. * By default, it is set to no-op.<br />
  32025. * Access Popper.js instance with `data.instance`.
  32026. * @prop {onCreate}
  32027. */
  32028. onCreate: function onCreate() {},
  32029. /**
  32030. * Callback called when the popper is updated. This callback is not called
  32031. * on the initialization/creation of the popper, but only on subsequent
  32032. * updates.<br />
  32033. * By default, it is set to no-op.<br />
  32034. * Access Popper.js instance with `data.instance`.
  32035. * @prop {onUpdate}
  32036. */
  32037. onUpdate: function onUpdate() {},
  32038. /**
  32039. * List of modifiers used to modify the offsets before they are applied to the popper.
  32040. * They provide most of the functionalities of Popper.js.
  32041. * @prop {modifiers}
  32042. */
  32043. modifiers: modifiers
  32044. };
  32045. /**
  32046. * @callback onCreate
  32047. * @param {dataObject} data
  32048. */
  32049. /**
  32050. * @callback onUpdate
  32051. * @param {dataObject} data
  32052. */
  32053. // Utils
  32054. // Methods
  32055. var Popper = function () {
  32056. /**
  32057. * Creates a new Popper.js instance.
  32058. * @class Popper
  32059. * @param {Element|referenceObject} reference - The reference element used to position the popper
  32060. * @param {Element} popper - The HTML / XML element used as the popper
  32061. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  32062. * @return {Object} instance - The generated Popper.js instance
  32063. */
  32064. function Popper(reference, popper) {
  32065. var _this = this;
  32066. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  32067. classCallCheck(this, Popper);
  32068. this.scheduleUpdate = function () {
  32069. return requestAnimationFrame(_this.update);
  32070. };
  32071. // make update() debounced, so that it only runs at most once-per-tick
  32072. this.update = debounce(this.update.bind(this));
  32073. // with {} we create a new object with the options inside it
  32074. this.options = _extends({}, Popper.Defaults, options);
  32075. // init state
  32076. this.state = {
  32077. isDestroyed: false,
  32078. isCreated: false,
  32079. scrollParents: []
  32080. };
  32081. // get reference and popper elements (allow jQuery wrappers)
  32082. this.reference = reference && reference.jquery ? reference[0] : reference;
  32083. this.popper = popper && popper.jquery ? popper[0] : popper;
  32084. // Deep merge modifiers options
  32085. this.options.modifiers = {};
  32086. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  32087. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  32088. });
  32089. // Refactoring modifiers' list (Object => Array)
  32090. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  32091. return _extends({
  32092. name: name
  32093. }, _this.options.modifiers[name]);
  32094. })
  32095. // sort the modifiers by order
  32096. .sort(function (a, b) {
  32097. return a.order - b.order;
  32098. });
  32099. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  32100. // such code is executed in the same order of its modifier
  32101. // they could add new properties to their options configuration
  32102. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  32103. this.modifiers.forEach(function (modifierOptions) {
  32104. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  32105. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  32106. }
  32107. });
  32108. // fire the first update to position the popper in the right place
  32109. this.update();
  32110. var eventsEnabled = this.options.eventsEnabled;
  32111. if (eventsEnabled) {
  32112. // setup event listeners, they will take care of update the position in specific situations
  32113. this.enableEventListeners();
  32114. }
  32115. this.state.eventsEnabled = eventsEnabled;
  32116. }
  32117. // We can't use class properties because they don't get listed in the
  32118. // class prototype and break stuff like Sinon stubs
  32119. createClass(Popper, [{
  32120. key: 'update',
  32121. value: function update$$1() {
  32122. return update.call(this);
  32123. }
  32124. }, {
  32125. key: 'destroy',
  32126. value: function destroy$$1() {
  32127. return destroy.call(this);
  32128. }
  32129. }, {
  32130. key: 'enableEventListeners',
  32131. value: function enableEventListeners$$1() {
  32132. return enableEventListeners.call(this);
  32133. }
  32134. }, {
  32135. key: 'disableEventListeners',
  32136. value: function disableEventListeners$$1() {
  32137. return disableEventListeners.call(this);
  32138. }
  32139. /**
  32140. * Schedules an update. It will run on the next UI update available.
  32141. * @method scheduleUpdate
  32142. * @memberof Popper
  32143. */
  32144. /**
  32145. * Collection of utilities useful when writing custom modifiers.
  32146. * Starting from version 1.7, this method is available only if you
  32147. * include `popper-utils.js` before `popper.js`.
  32148. *
  32149. * **DEPRECATION**: This way to access PopperUtils is deprecated
  32150. * and will be removed in v2! Use the PopperUtils module directly instead.
  32151. * Due to the high instability of the methods contained in Utils, we can't
  32152. * guarantee them to follow semver. Use them at your own risk!
  32153. * @static
  32154. * @private
  32155. * @type {Object}
  32156. * @deprecated since version 1.8
  32157. * @member Utils
  32158. * @memberof Popper
  32159. */
  32160. }]);
  32161. return Popper;
  32162. }();
  32163. /**
  32164. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  32165. * and lets you use it as replacement of a real DOM node.<br />
  32166. * You can use this method to position a popper relatively to a set of coordinates
  32167. * in case you don't have a DOM node to use as reference.
  32168. *
  32169. * ```
  32170. * new Popper(referenceObject, popperNode);
  32171. * ```
  32172. *
  32173. * NB: This feature isn't supported in Internet Explorer 10.
  32174. * @name referenceObject
  32175. * @property {Function} data.getBoundingClientRect
  32176. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  32177. * @property {number} data.clientWidth
  32178. * An ES6 getter that will return the width of the virtual reference element.
  32179. * @property {number} data.clientHeight
  32180. * An ES6 getter that will return the height of the virtual reference element.
  32181. */
  32182. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  32183. Popper.placements = placements;
  32184. Popper.Defaults = Defaults;
  32185. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  32186. //# sourceMappingURL=popper.js.map
  32187. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  32188. /***/ }),
  32189. /***/ "./node_modules/process/browser.js":
  32190. /*!*****************************************!*\
  32191. !*** ./node_modules/process/browser.js ***!
  32192. \*****************************************/
  32193. /*! no static exports found */
  32194. /***/ (function(module, exports) {
  32195. // shim for using process in browser
  32196. var process = module.exports = {};
  32197. // cached from whatever global is present so that test runners that stub it
  32198. // don't break things. But we need to wrap it in a try catch in case it is
  32199. // wrapped in strict mode code which doesn't define any globals. It's inside a
  32200. // function because try/catches deoptimize in certain engines.
  32201. var cachedSetTimeout;
  32202. var cachedClearTimeout;
  32203. function defaultSetTimout() {
  32204. throw new Error('setTimeout has not been defined');
  32205. }
  32206. function defaultClearTimeout () {
  32207. throw new Error('clearTimeout has not been defined');
  32208. }
  32209. (function () {
  32210. try {
  32211. if (typeof setTimeout === 'function') {
  32212. cachedSetTimeout = setTimeout;
  32213. } else {
  32214. cachedSetTimeout = defaultSetTimout;
  32215. }
  32216. } catch (e) {
  32217. cachedSetTimeout = defaultSetTimout;
  32218. }
  32219. try {
  32220. if (typeof clearTimeout === 'function') {
  32221. cachedClearTimeout = clearTimeout;
  32222. } else {
  32223. cachedClearTimeout = defaultClearTimeout;
  32224. }
  32225. } catch (e) {
  32226. cachedClearTimeout = defaultClearTimeout;
  32227. }
  32228. } ())
  32229. function runTimeout(fun) {
  32230. if (cachedSetTimeout === setTimeout) {
  32231. //normal enviroments in sane situations
  32232. return setTimeout(fun, 0);
  32233. }
  32234. // if setTimeout wasn't available but was latter defined
  32235. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  32236. cachedSetTimeout = setTimeout;
  32237. return setTimeout(fun, 0);
  32238. }
  32239. try {
  32240. // when when somebody has screwed with setTimeout but no I.E. maddness
  32241. return cachedSetTimeout(fun, 0);
  32242. } catch(e){
  32243. try {
  32244. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  32245. return cachedSetTimeout.call(null, fun, 0);
  32246. } catch(e){
  32247. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  32248. return cachedSetTimeout.call(this, fun, 0);
  32249. }
  32250. }
  32251. }
  32252. function runClearTimeout(marker) {
  32253. if (cachedClearTimeout === clearTimeout) {
  32254. //normal enviroments in sane situations
  32255. return clearTimeout(marker);
  32256. }
  32257. // if clearTimeout wasn't available but was latter defined
  32258. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  32259. cachedClearTimeout = clearTimeout;
  32260. return clearTimeout(marker);
  32261. }
  32262. try {
  32263. // when when somebody has screwed with setTimeout but no I.E. maddness
  32264. return cachedClearTimeout(marker);
  32265. } catch (e){
  32266. try {
  32267. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  32268. return cachedClearTimeout.call(null, marker);
  32269. } catch (e){
  32270. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  32271. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  32272. return cachedClearTimeout.call(this, marker);
  32273. }
  32274. }
  32275. }
  32276. var queue = [];
  32277. var draining = false;
  32278. var currentQueue;
  32279. var queueIndex = -1;
  32280. function cleanUpNextTick() {
  32281. if (!draining || !currentQueue) {
  32282. return;
  32283. }
  32284. draining = false;
  32285. if (currentQueue.length) {
  32286. queue = currentQueue.concat(queue);
  32287. } else {
  32288. queueIndex = -1;
  32289. }
  32290. if (queue.length) {
  32291. drainQueue();
  32292. }
  32293. }
  32294. function drainQueue() {
  32295. if (draining) {
  32296. return;
  32297. }
  32298. var timeout = runTimeout(cleanUpNextTick);
  32299. draining = true;
  32300. var len = queue.length;
  32301. while(len) {
  32302. currentQueue = queue;
  32303. queue = [];
  32304. while (++queueIndex < len) {
  32305. if (currentQueue) {
  32306. currentQueue[queueIndex].run();
  32307. }
  32308. }
  32309. queueIndex = -1;
  32310. len = queue.length;
  32311. }
  32312. currentQueue = null;
  32313. draining = false;
  32314. runClearTimeout(timeout);
  32315. }
  32316. process.nextTick = function (fun) {
  32317. var args = new Array(arguments.length - 1);
  32318. if (arguments.length > 1) {
  32319. for (var i = 1; i < arguments.length; i++) {
  32320. args[i - 1] = arguments[i];
  32321. }
  32322. }
  32323. queue.push(new Item(fun, args));
  32324. if (queue.length === 1 && !draining) {
  32325. runTimeout(drainQueue);
  32326. }
  32327. };
  32328. // v8 likes predictible objects
  32329. function Item(fun, array) {
  32330. this.fun = fun;
  32331. this.array = array;
  32332. }
  32333. Item.prototype.run = function () {
  32334. this.fun.apply(null, this.array);
  32335. };
  32336. process.title = 'browser';
  32337. process.browser = true;
  32338. process.env = {};
  32339. process.argv = [];
  32340. process.version = ''; // empty string to avoid regexp issues
  32341. process.versions = {};
  32342. function noop() {}
  32343. process.on = noop;
  32344. process.addListener = noop;
  32345. process.once = noop;
  32346. process.off = noop;
  32347. process.removeListener = noop;
  32348. process.removeAllListeners = noop;
  32349. process.emit = noop;
  32350. process.prependListener = noop;
  32351. process.prependOnceListener = noop;
  32352. process.listeners = function (name) { return [] }
  32353. process.binding = function (name) {
  32354. throw new Error('process.binding is not supported');
  32355. };
  32356. process.cwd = function () { return '/' };
  32357. process.chdir = function (dir) {
  32358. throw new Error('process.chdir is not supported');
  32359. };
  32360. process.umask = function() { return 0; };
  32361. /***/ }),
  32362. /***/ "./node_modules/prop-types/checkPropTypes.js":
  32363. /*!***************************************************!*\
  32364. !*** ./node_modules/prop-types/checkPropTypes.js ***!
  32365. \***************************************************/
  32366. /*! no static exports found */
  32367. /***/ (function(module, exports, __webpack_require__) {
  32368. "use strict";
  32369. /**
  32370. * Copyright (c) 2013-present, Facebook, Inc.
  32371. *
  32372. * This source code is licensed under the MIT license found in the
  32373. * LICENSE file in the root directory of this source tree.
  32374. */
  32375. var printWarning = function() {};
  32376. if (true) {
  32377. var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "./node_modules/prop-types/lib/ReactPropTypesSecret.js");
  32378. var loggedTypeFailures = {};
  32379. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  32380. printWarning = function(text) {
  32381. var message = 'Warning: ' + text;
  32382. if (typeof console !== 'undefined') {
  32383. console.error(message);
  32384. }
  32385. try {
  32386. // --- Welcome to debugging React ---
  32387. // This error was thrown as a convenience so that you can use this stack
  32388. // to find the callsite that caused this warning to fire.
  32389. throw new Error(message);
  32390. } catch (x) {}
  32391. };
  32392. }
  32393. /**
  32394. * Assert that the values match with the type specs.
  32395. * Error messages are memorized and will only be shown once.
  32396. *
  32397. * @param {object} typeSpecs Map of name to a ReactPropType
  32398. * @param {object} values Runtime values that need to be type-checked
  32399. * @param {string} location e.g. "prop", "context", "child context"
  32400. * @param {string} componentName Name of the component for error messages.
  32401. * @param {?Function} getStack Returns the component stack.
  32402. * @private
  32403. */
  32404. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  32405. if (true) {
  32406. for (var typeSpecName in typeSpecs) {
  32407. if (has(typeSpecs, typeSpecName)) {
  32408. var error;
  32409. // Prop type validation may throw. In case they do, we don't want to
  32410. // fail the render phase where it didn't fail before. So we log it.
  32411. // After these have been cleaned up, we'll let them throw.
  32412. try {
  32413. // This is intentionally an invariant that gets caught. It's the same
  32414. // behavior as without this statement except with a better message.
  32415. if (typeof typeSpecs[typeSpecName] !== 'function') {
  32416. var err = Error(
  32417. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  32418. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  32419. );
  32420. err.name = 'Invariant Violation';
  32421. throw err;
  32422. }
  32423. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
  32424. } catch (ex) {
  32425. error = ex;
  32426. }
  32427. if (error && !(error instanceof Error)) {
  32428. printWarning(
  32429. (componentName || 'React class') + ': type specification of ' +
  32430. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  32431. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  32432. 'You may have forgotten to pass an argument to the type checker ' +
  32433. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  32434. 'shape all require an argument).'
  32435. );
  32436. }
  32437. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  32438. // Only monitor this failure once because there tends to be a lot of the
  32439. // same error.
  32440. loggedTypeFailures[error.message] = true;
  32441. var stack = getStack ? getStack() : '';
  32442. printWarning(
  32443. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  32444. );
  32445. }
  32446. }
  32447. }
  32448. }
  32449. }
  32450. /**
  32451. * Resets warning cache when testing.
  32452. *
  32453. * @private
  32454. */
  32455. checkPropTypes.resetWarningCache = function() {
  32456. if (true) {
  32457. loggedTypeFailures = {};
  32458. }
  32459. }
  32460. module.exports = checkPropTypes;
  32461. /***/ }),
  32462. /***/ "./node_modules/prop-types/lib/ReactPropTypesSecret.js":
  32463. /*!*************************************************************!*\
  32464. !*** ./node_modules/prop-types/lib/ReactPropTypesSecret.js ***!
  32465. \*************************************************************/
  32466. /*! no static exports found */
  32467. /***/ (function(module, exports, __webpack_require__) {
  32468. "use strict";
  32469. /**
  32470. * Copyright (c) 2013-present, Facebook, Inc.
  32471. *
  32472. * This source code is licensed under the MIT license found in the
  32473. * LICENSE file in the root directory of this source tree.
  32474. */
  32475. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  32476. module.exports = ReactPropTypesSecret;
  32477. /***/ }),
  32478. /***/ "./node_modules/react-dom/cjs/react-dom.development.js":
  32479. /*!*************************************************************!*\
  32480. !*** ./node_modules/react-dom/cjs/react-dom.development.js ***!
  32481. \*************************************************************/
  32482. /*! no static exports found */
  32483. /***/ (function(module, exports, __webpack_require__) {
  32484. "use strict";
  32485. /** @license React v16.10.1
  32486. * react-dom.development.js
  32487. *
  32488. * Copyright (c) Facebook, Inc. and its affiliates.
  32489. *
  32490. * This source code is licensed under the MIT license found in the
  32491. * LICENSE file in the root directory of this source tree.
  32492. */
  32493. if (true) {
  32494. (function() {
  32495. 'use strict';
  32496. var React = __webpack_require__(/*! react */ "./node_modules/react/index.js");
  32497. var _assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js");
  32498. var Scheduler = __webpack_require__(/*! scheduler */ "./node_modules/scheduler/index.js");
  32499. var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "./node_modules/prop-types/checkPropTypes.js");
  32500. var tracing = __webpack_require__(/*! scheduler/tracing */ "./node_modules/scheduler/tracing.js");
  32501. // Do not require this module directly! Use normal `invariant` calls with
  32502. // template literal strings. The messages will be converted to ReactError during
  32503. // build, and in production they will be minified.
  32504. // Do not require this module directly! Use normal `invariant` calls with
  32505. // template literal strings. The messages will be converted to ReactError during
  32506. // build, and in production they will be minified.
  32507. function ReactError(error) {
  32508. error.name = 'Invariant Violation';
  32509. return error;
  32510. }
  32511. /**
  32512. * Use invariant() to assert state which your program assumes to be true.
  32513. *
  32514. * Provide sprintf-style format (only %s is supported) and arguments
  32515. * to provide information about what broke and what you were
  32516. * expecting.
  32517. *
  32518. * The invariant message will be stripped in production, but the invariant
  32519. * will remain to ensure logic does not differ in production.
  32520. */
  32521. (function () {
  32522. if (!React) {
  32523. {
  32524. throw ReactError(Error("ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM."));
  32525. }
  32526. }
  32527. })();
  32528. /**
  32529. * Injectable ordering of event plugins.
  32530. */
  32531. var eventPluginOrder = null;
  32532. /**
  32533. * Injectable mapping from names to event plugin modules.
  32534. */
  32535. var namesToPlugins = {};
  32536. /**
  32537. * Recomputes the plugin list using the injected plugins and plugin ordering.
  32538. *
  32539. * @private
  32540. */
  32541. function recomputePluginOrdering() {
  32542. if (!eventPluginOrder) {
  32543. // Wait until an `eventPluginOrder` is injected.
  32544. return;
  32545. }
  32546. for (var pluginName in namesToPlugins) {
  32547. var pluginModule = namesToPlugins[pluginName];
  32548. var pluginIndex = eventPluginOrder.indexOf(pluginName);
  32549. (function () {
  32550. if (!(pluginIndex > -1)) {
  32551. {
  32552. throw ReactError(Error("EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + pluginName + "`."));
  32553. }
  32554. }
  32555. })();
  32556. if (plugins[pluginIndex]) {
  32557. continue;
  32558. }
  32559. (function () {
  32560. if (!pluginModule.extractEvents) {
  32561. {
  32562. throw ReactError(Error("EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not."));
  32563. }
  32564. }
  32565. })();
  32566. plugins[pluginIndex] = pluginModule;
  32567. var publishedEvents = pluginModule.eventTypes;
  32568. for (var eventName in publishedEvents) {
  32569. (function () {
  32570. if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) {
  32571. {
  32572. throw ReactError(Error("EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + pluginName + "`."));
  32573. }
  32574. }
  32575. })();
  32576. }
  32577. }
  32578. }
  32579. /**
  32580. * Publishes an event so that it can be dispatched by the supplied plugin.
  32581. *
  32582. * @param {object} dispatchConfig Dispatch configuration for the event.
  32583. * @param {object} PluginModule Plugin publishing the event.
  32584. * @return {boolean} True if the event was successfully published.
  32585. * @private
  32586. */
  32587. function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
  32588. (function () {
  32589. if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) {
  32590. {
  32591. throw ReactError(Error("EventPluginHub: More than one plugin attempted to publish the same event name, `" + eventName + "`."));
  32592. }
  32593. }
  32594. })();
  32595. eventNameDispatchConfigs[eventName] = dispatchConfig;
  32596. var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
  32597. if (phasedRegistrationNames) {
  32598. for (var phaseName in phasedRegistrationNames) {
  32599. if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
  32600. var phasedRegistrationName = phasedRegistrationNames[phaseName];
  32601. publishRegistrationName(phasedRegistrationName, pluginModule, eventName);
  32602. }
  32603. }
  32604. return true;
  32605. } else if (dispatchConfig.registrationName) {
  32606. publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName);
  32607. return true;
  32608. }
  32609. return false;
  32610. }
  32611. /**
  32612. * Publishes a registration name that is used to identify dispatched events.
  32613. *
  32614. * @param {string} registrationName Registration name to add.
  32615. * @param {object} PluginModule Plugin publishing the event.
  32616. * @private
  32617. */
  32618. function publishRegistrationName(registrationName, pluginModule, eventName) {
  32619. (function () {
  32620. if (!!registrationNameModules[registrationName]) {
  32621. {
  32622. throw ReactError(Error("EventPluginHub: More than one plugin attempted to publish the same registration name, `" + registrationName + "`."));
  32623. }
  32624. }
  32625. })();
  32626. registrationNameModules[registrationName] = pluginModule;
  32627. registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
  32628. {
  32629. var lowerCasedName = registrationName.toLowerCase();
  32630. possibleRegistrationNames[lowerCasedName] = registrationName;
  32631. if (registrationName === 'onDoubleClick') {
  32632. possibleRegistrationNames.ondblclick = registrationName;
  32633. }
  32634. }
  32635. }
  32636. /**
  32637. * Registers plugins so that they can extract and dispatch events.
  32638. *
  32639. * @see {EventPluginHub}
  32640. */
  32641. /**
  32642. * Ordered list of injected plugins.
  32643. */
  32644. var plugins = [];
  32645. /**
  32646. * Mapping from event name to dispatch config
  32647. */
  32648. var eventNameDispatchConfigs = {};
  32649. /**
  32650. * Mapping from registration name to plugin module
  32651. */
  32652. var registrationNameModules = {};
  32653. /**
  32654. * Mapping from registration name to event name
  32655. */
  32656. var registrationNameDependencies = {};
  32657. /**
  32658. * Mapping from lowercase registration names to the properly cased version,
  32659. * used to warn in the case of missing event handlers. Available
  32660. * only in true.
  32661. * @type {Object}
  32662. */
  32663. var possibleRegistrationNames = {}; // Trust the developer to only use possibleRegistrationNames in true
  32664. /**
  32665. * Injects an ordering of plugins (by plugin name). This allows the ordering
  32666. * to be decoupled from injection of the actual plugins so that ordering is
  32667. * always deterministic regardless of packaging, on-the-fly injection, etc.
  32668. *
  32669. * @param {array} InjectedEventPluginOrder
  32670. * @internal
  32671. * @see {EventPluginHub.injection.injectEventPluginOrder}
  32672. */
  32673. function injectEventPluginOrder(injectedEventPluginOrder) {
  32674. (function () {
  32675. if (!!eventPluginOrder) {
  32676. {
  32677. throw ReactError(Error("EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React."));
  32678. }
  32679. }
  32680. })(); // Clone the ordering so it cannot be dynamically mutated.
  32681. eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
  32682. recomputePluginOrdering();
  32683. }
  32684. /**
  32685. * Injects plugins to be used by `EventPluginHub`. The plugin names must be
  32686. * in the ordering injected by `injectEventPluginOrder`.
  32687. *
  32688. * Plugins can be injected as part of page initialization or on-the-fly.
  32689. *
  32690. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  32691. * @internal
  32692. * @see {EventPluginHub.injection.injectEventPluginsByName}
  32693. */
  32694. function injectEventPluginsByName(injectedNamesToPlugins) {
  32695. var isOrderingDirty = false;
  32696. for (var pluginName in injectedNamesToPlugins) {
  32697. if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
  32698. continue;
  32699. }
  32700. var pluginModule = injectedNamesToPlugins[pluginName];
  32701. if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) {
  32702. (function () {
  32703. if (!!namesToPlugins[pluginName]) {
  32704. {
  32705. throw ReactError(Error("EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + pluginName + "`."));
  32706. }
  32707. }
  32708. })();
  32709. namesToPlugins[pluginName] = pluginModule;
  32710. isOrderingDirty = true;
  32711. }
  32712. }
  32713. if (isOrderingDirty) {
  32714. recomputePluginOrdering();
  32715. }
  32716. }
  32717. var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
  32718. var funcArgs = Array.prototype.slice.call(arguments, 3);
  32719. try {
  32720. func.apply(context, funcArgs);
  32721. } catch (error) {
  32722. this.onError(error);
  32723. }
  32724. };
  32725. {
  32726. // In DEV mode, we swap out invokeGuardedCallback for a special version
  32727. // that plays more nicely with the browser's DevTools. The idea is to preserve
  32728. // "Pause on exceptions" behavior. Because React wraps all user-provided
  32729. // functions in invokeGuardedCallback, and the production version of
  32730. // invokeGuardedCallback uses a try-catch, all user exceptions are treated
  32731. // like caught exceptions, and the DevTools won't pause unless the developer
  32732. // takes the extra step of enabling pause on caught exceptions. This is
  32733. // unintuitive, though, because even though React has caught the error, from
  32734. // the developer's perspective, the error is uncaught.
  32735. //
  32736. // To preserve the expected "Pause on exceptions" behavior, we don't use a
  32737. // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
  32738. // DOM node, and call the user-provided callback from inside an event handler
  32739. // for that fake event. If the callback throws, the error is "captured" using
  32740. // a global event handler. But because the error happens in a different
  32741. // event loop context, it does not interrupt the normal program flow.
  32742. // Effectively, this gives us try-catch behavior without actually using
  32743. // try-catch. Neat!
  32744. // Check that the browser supports the APIs we need to implement our special
  32745. // DEV version of invokeGuardedCallback
  32746. if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
  32747. var fakeNode = document.createElement('react');
  32748. var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
  32749. // If document doesn't exist we know for sure we will crash in this method
  32750. // when we call document.createEvent(). However this can cause confusing
  32751. // errors: https://github.com/facebookincubator/create-react-app/issues/3482
  32752. // So we preemptively throw with a better message instead.
  32753. (function () {
  32754. if (!(typeof document !== 'undefined')) {
  32755. {
  32756. throw ReactError(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."));
  32757. }
  32758. }
  32759. })();
  32760. var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We
  32761. // set this to true at the beginning, then set it to false right after
  32762. // calling the function. If the function errors, `didError` will never be
  32763. // set to false. This strategy works even if the browser is flaky and
  32764. // fails to call our global error handler, because it doesn't rely on
  32765. // the error event at all.
  32766. var didError = true; // Keeps track of the value of window.event so that we can reset it
  32767. // during the callback to let user code access window.event in the
  32768. // browsers that support it.
  32769. var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event
  32770. // dispatching: https://github.com/facebook/react/issues/13688
  32771. var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously
  32772. // dispatch our fake event using `dispatchEvent`. Inside the handler, we
  32773. // call the user-provided callback.
  32774. var funcArgs = Array.prototype.slice.call(arguments, 3);
  32775. function callCallback() {
  32776. // We immediately remove the callback from event listeners so that
  32777. // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
  32778. // nested call would trigger the fake event handlers of any call higher
  32779. // in the stack.
  32780. fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the
  32781. // window.event assignment in both IE <= 10 as they throw an error
  32782. // "Member not found" in strict mode, and in Firefox which does not
  32783. // support window.event.
  32784. if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
  32785. window.event = windowEvent;
  32786. }
  32787. func.apply(context, funcArgs);
  32788. didError = false;
  32789. } // Create a global error event handler. We use this to capture the value
  32790. // that was thrown. It's possible that this error handler will fire more
  32791. // than once; for example, if non-React code also calls `dispatchEvent`
  32792. // and a handler for that event throws. We should be resilient to most of
  32793. // those cases. Even if our error event handler fires more than once, the
  32794. // last error event is always used. If the callback actually does error,
  32795. // we know that the last error event is the correct one, because it's not
  32796. // possible for anything else to have happened in between our callback
  32797. // erroring and the code that follows the `dispatchEvent` call below. If
  32798. // the callback doesn't error, but the error event was fired, we know to
  32799. // ignore it because `didError` will be false, as described above.
  32800. var error; // Use this to track whether the error event is ever called.
  32801. var didSetError = false;
  32802. var isCrossOriginError = false;
  32803. function handleWindowError(event) {
  32804. error = event.error;
  32805. didSetError = true;
  32806. if (error === null && event.colno === 0 && event.lineno === 0) {
  32807. isCrossOriginError = true;
  32808. }
  32809. if (event.defaultPrevented) {
  32810. // Some other error handler has prevented default.
  32811. // Browsers silence the error report if this happens.
  32812. // We'll remember this to later decide whether to log it or not.
  32813. if (error != null && typeof error === 'object') {
  32814. try {
  32815. error._suppressLogging = true;
  32816. } catch (inner) {// Ignore.
  32817. }
  32818. }
  32819. }
  32820. } // Create a fake event type.
  32821. var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers
  32822. window.addEventListener('error', handleWindowError);
  32823. fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function
  32824. // errors, it will trigger our global error handler.
  32825. evt.initEvent(evtType, false, false);
  32826. fakeNode.dispatchEvent(evt);
  32827. if (windowEventDescriptor) {
  32828. Object.defineProperty(window, 'event', windowEventDescriptor);
  32829. }
  32830. if (didError) {
  32831. if (!didSetError) {
  32832. // The callback errored, but the error event never fired.
  32833. 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.');
  32834. } else if (isCrossOriginError) {
  32835. 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.');
  32836. }
  32837. this.onError(error);
  32838. } // Remove our event listeners
  32839. window.removeEventListener('error', handleWindowError);
  32840. };
  32841. invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
  32842. }
  32843. }
  32844. var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
  32845. var hasError = false;
  32846. var caughtError = null; // Used by event system to capture/rethrow the first error.
  32847. var hasRethrowError = false;
  32848. var rethrowError = null;
  32849. var reporter = {
  32850. onError: function (error) {
  32851. hasError = true;
  32852. caughtError = error;
  32853. }
  32854. };
  32855. /**
  32856. * Call a function while guarding against errors that happens within it.
  32857. * Returns an error if it throws, otherwise null.
  32858. *
  32859. * In production, this is implemented using a try-catch. The reason we don't
  32860. * use a try-catch directly is so that we can swap out a different
  32861. * implementation in DEV mode.
  32862. *
  32863. * @param {String} name of the guard to use for logging or debugging
  32864. * @param {Function} func The function to invoke
  32865. * @param {*} context The context to use when calling the function
  32866. * @param {...*} args Arguments for function
  32867. */
  32868. function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
  32869. hasError = false;
  32870. caughtError = null;
  32871. invokeGuardedCallbackImpl$1.apply(reporter, arguments);
  32872. }
  32873. /**
  32874. * Same as invokeGuardedCallback, but instead of returning an error, it stores
  32875. * it in a global so it can be rethrown by `rethrowCaughtError` later.
  32876. * TODO: See if caughtError and rethrowError can be unified.
  32877. *
  32878. * @param {String} name of the guard to use for logging or debugging
  32879. * @param {Function} func The function to invoke
  32880. * @param {*} context The context to use when calling the function
  32881. * @param {...*} args Arguments for function
  32882. */
  32883. function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) {
  32884. invokeGuardedCallback.apply(this, arguments);
  32885. if (hasError) {
  32886. var error = clearCaughtError();
  32887. if (!hasRethrowError) {
  32888. hasRethrowError = true;
  32889. rethrowError = error;
  32890. }
  32891. }
  32892. }
  32893. /**
  32894. * During execution of guarded functions we will capture the first error which
  32895. * we will rethrow to be handled by the top level error handler.
  32896. */
  32897. function rethrowCaughtError() {
  32898. if (hasRethrowError) {
  32899. var error = rethrowError;
  32900. hasRethrowError = false;
  32901. rethrowError = null;
  32902. throw error;
  32903. }
  32904. }
  32905. function hasCaughtError() {
  32906. return hasError;
  32907. }
  32908. function clearCaughtError() {
  32909. if (hasError) {
  32910. var error = caughtError;
  32911. hasError = false;
  32912. caughtError = null;
  32913. return error;
  32914. } else {
  32915. (function () {
  32916. {
  32917. {
  32918. throw ReactError(Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue."));
  32919. }
  32920. }
  32921. })();
  32922. }
  32923. }
  32924. /**
  32925. * Similar to invariant but only logs a warning if the condition is not met.
  32926. * This can be used to log issues in development environments in critical
  32927. * paths. Removing the logging code for production environments will keep the
  32928. * same logic and follow the same code paths.
  32929. */
  32930. var warningWithoutStack = function () {};
  32931. {
  32932. warningWithoutStack = function (condition, format) {
  32933. for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  32934. args[_key - 2] = arguments[_key];
  32935. }
  32936. if (format === undefined) {
  32937. throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
  32938. }
  32939. if (args.length > 8) {
  32940. // Check before the condition to catch violations early.
  32941. throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
  32942. }
  32943. if (condition) {
  32944. return;
  32945. }
  32946. if (typeof console !== 'undefined') {
  32947. var argsWithFormat = args.map(function (item) {
  32948. return '' + item;
  32949. });
  32950. argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
  32951. // breaks IE9: https://github.com/facebook/react/issues/13610
  32952. Function.prototype.apply.call(console.error, console, argsWithFormat);
  32953. }
  32954. try {
  32955. // --- Welcome to debugging React ---
  32956. // This error was thrown as a convenience so that you can use this stack
  32957. // to find the callsite that caused this warning to fire.
  32958. var argIndex = 0;
  32959. var message = 'Warning: ' + format.replace(/%s/g, function () {
  32960. return args[argIndex++];
  32961. });
  32962. throw new Error(message);
  32963. } catch (x) {}
  32964. };
  32965. }
  32966. var warningWithoutStack$1 = warningWithoutStack;
  32967. var getFiberCurrentPropsFromNode = null;
  32968. var getInstanceFromNode = null;
  32969. var getNodeFromInstance = null;
  32970. function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) {
  32971. getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl;
  32972. getInstanceFromNode = getInstanceFromNodeImpl;
  32973. getNodeFromInstance = getNodeFromInstanceImpl;
  32974. {
  32975. !(getNodeFromInstance && getInstanceFromNode) ? warningWithoutStack$1(false, 'EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
  32976. }
  32977. }
  32978. var validateEventDispatches;
  32979. {
  32980. validateEventDispatches = function (event) {
  32981. var dispatchListeners = event._dispatchListeners;
  32982. var dispatchInstances = event._dispatchInstances;
  32983. var listenersIsArr = Array.isArray(dispatchListeners);
  32984. var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
  32985. var instancesIsArr = Array.isArray(dispatchInstances);
  32986. var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
  32987. !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warningWithoutStack$1(false, 'EventPluginUtils: Invalid `event`.') : void 0;
  32988. };
  32989. }
  32990. /**
  32991. * Dispatch the event to the listener.
  32992. * @param {SyntheticEvent} event SyntheticEvent to handle
  32993. * @param {function} listener Application-level callback
  32994. * @param {*} inst Internal component instance
  32995. */
  32996. function executeDispatch(event, listener, inst) {
  32997. var type = event.type || 'unknown-event';
  32998. event.currentTarget = getNodeFromInstance(inst);
  32999. invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
  33000. event.currentTarget = null;
  33001. }
  33002. /**
  33003. * Standard/simple iteration through an event's collected dispatches.
  33004. */
  33005. function executeDispatchesInOrder(event) {
  33006. var dispatchListeners = event._dispatchListeners;
  33007. var dispatchInstances = event._dispatchInstances;
  33008. {
  33009. validateEventDispatches(event);
  33010. }
  33011. if (Array.isArray(dispatchListeners)) {
  33012. for (var i = 0; i < dispatchListeners.length; i++) {
  33013. if (event.isPropagationStopped()) {
  33014. break;
  33015. } // Listeners and Instances are two parallel arrays that are always in sync.
  33016. executeDispatch(event, dispatchListeners[i], dispatchInstances[i]);
  33017. }
  33018. } else if (dispatchListeners) {
  33019. executeDispatch(event, dispatchListeners, dispatchInstances);
  33020. }
  33021. event._dispatchListeners = null;
  33022. event._dispatchInstances = null;
  33023. }
  33024. /**
  33025. * @see executeDispatchesInOrderStopAtTrueImpl
  33026. */
  33027. /**
  33028. * Execution of a "direct" dispatch - there must be at most one dispatch
  33029. * accumulated on the event or it is considered an error. It doesn't really make
  33030. * sense for an event with multiple dispatches (bubbled) to keep track of the
  33031. * return values at each dispatch execution, but it does tend to make sense when
  33032. * dealing with "direct" dispatches.
  33033. *
  33034. * @return {*} The return value of executing the single dispatch.
  33035. */
  33036. /**
  33037. * @param {SyntheticEvent} event
  33038. * @return {boolean} True iff number of dispatches accumulated is greater than 0.
  33039. */
  33040. /**
  33041. * Accumulates items that must not be null or undefined into the first one. This
  33042. * is used to conserve memory by avoiding array allocations, and thus sacrifices
  33043. * API cleanness. Since `current` can be null before being passed in and not
  33044. * null after this function, make sure to assign it back to `current`:
  33045. *
  33046. * `a = accumulateInto(a, b);`
  33047. *
  33048. * This API should be sparingly used. Try `accumulate` for something cleaner.
  33049. *
  33050. * @return {*|array<*>} An accumulation of items.
  33051. */
  33052. function accumulateInto(current, next) {
  33053. (function () {
  33054. if (!(next != null)) {
  33055. {
  33056. throw ReactError(Error("accumulateInto(...): Accumulated items must not be null or undefined."));
  33057. }
  33058. }
  33059. })();
  33060. if (current == null) {
  33061. return next;
  33062. } // Both are not empty. Warning: Never call x.concat(y) when you are not
  33063. // certain that x is an Array (x could be a string with concat method).
  33064. if (Array.isArray(current)) {
  33065. if (Array.isArray(next)) {
  33066. current.push.apply(current, next);
  33067. return current;
  33068. }
  33069. current.push(next);
  33070. return current;
  33071. }
  33072. if (Array.isArray(next)) {
  33073. // A bit too dangerous to mutate `next`.
  33074. return [current].concat(next);
  33075. }
  33076. return [current, next];
  33077. }
  33078. /**
  33079. * @param {array} arr an "accumulation" of items which is either an Array or
  33080. * a single item. Useful when paired with the `accumulate` module. This is a
  33081. * simple utility that allows us to reason about a collection of items, but
  33082. * handling the case when there is exactly one item (and we do not need to
  33083. * allocate an array).
  33084. * @param {function} cb Callback invoked with each element or a collection.
  33085. * @param {?} [scope] Scope used as `this` in a callback.
  33086. */
  33087. function forEachAccumulated(arr, cb, scope) {
  33088. if (Array.isArray(arr)) {
  33089. arr.forEach(cb, scope);
  33090. } else if (arr) {
  33091. cb.call(scope, arr);
  33092. }
  33093. }
  33094. /**
  33095. * Internal queue of events that have accumulated their dispatches and are
  33096. * waiting to have their dispatches executed.
  33097. */
  33098. var eventQueue = null;
  33099. /**
  33100. * Dispatches an event and releases it back into the pool, unless persistent.
  33101. *
  33102. * @param {?object} event Synthetic event to be dispatched.
  33103. * @private
  33104. */
  33105. var executeDispatchesAndRelease = function (event) {
  33106. if (event) {
  33107. executeDispatchesInOrder(event);
  33108. if (!event.isPersistent()) {
  33109. event.constructor.release(event);
  33110. }
  33111. }
  33112. };
  33113. var executeDispatchesAndReleaseTopLevel = function (e) {
  33114. return executeDispatchesAndRelease(e);
  33115. };
  33116. function runEventsInBatch(events) {
  33117. if (events !== null) {
  33118. eventQueue = accumulateInto(eventQueue, events);
  33119. } // Set `eventQueue` to null before processing it so that we can tell if more
  33120. // events get enqueued while processing.
  33121. var processingEventQueue = eventQueue;
  33122. eventQueue = null;
  33123. if (!processingEventQueue) {
  33124. return;
  33125. }
  33126. forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
  33127. (function () {
  33128. if (!!eventQueue) {
  33129. {
  33130. throw ReactError(Error("processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented."));
  33131. }
  33132. }
  33133. })(); // This would be a good time to rethrow if any of the event handlers threw.
  33134. rethrowCaughtError();
  33135. }
  33136. function isInteractive(tag) {
  33137. return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
  33138. }
  33139. function shouldPreventMouseEvent(name, type, props) {
  33140. switch (name) {
  33141. case 'onClick':
  33142. case 'onClickCapture':
  33143. case 'onDoubleClick':
  33144. case 'onDoubleClickCapture':
  33145. case 'onMouseDown':
  33146. case 'onMouseDownCapture':
  33147. case 'onMouseMove':
  33148. case 'onMouseMoveCapture':
  33149. case 'onMouseUp':
  33150. case 'onMouseUpCapture':
  33151. return !!(props.disabled && isInteractive(type));
  33152. default:
  33153. return false;
  33154. }
  33155. }
  33156. /**
  33157. * This is a unified interface for event plugins to be installed and configured.
  33158. *
  33159. * Event plugins can implement the following properties:
  33160. *
  33161. * `extractEvents` {function(string, DOMEventTarget, string, object): *}
  33162. * Required. When a top-level event is fired, this method is expected to
  33163. * extract synthetic events that will in turn be queued and dispatched.
  33164. *
  33165. * `eventTypes` {object}
  33166. * Optional, plugins that fire events must publish a mapping of registration
  33167. * names that are used to register listeners. Values of this mapping must
  33168. * be objects that contain `registrationName` or `phasedRegistrationNames`.
  33169. *
  33170. * `executeDispatch` {function(object, function, string)}
  33171. * Optional, allows plugins to override how an event gets dispatched. By
  33172. * default, the listener is simply invoked.
  33173. *
  33174. * Each plugin that is injected into `EventsPluginHub` is immediately operable.
  33175. *
  33176. * @public
  33177. */
  33178. /**
  33179. * Methods for injecting dependencies.
  33180. */
  33181. var injection = {
  33182. /**
  33183. * @param {array} InjectedEventPluginOrder
  33184. * @public
  33185. */
  33186. injectEventPluginOrder: injectEventPluginOrder,
  33187. /**
  33188. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  33189. */
  33190. injectEventPluginsByName: injectEventPluginsByName
  33191. };
  33192. /**
  33193. * @param {object} inst The instance, which is the source of events.
  33194. * @param {string} registrationName Name of listener (e.g. `onClick`).
  33195. * @return {?function} The stored callback.
  33196. */
  33197. function getListener(inst, registrationName) {
  33198. var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
  33199. // live here; needs to be moved to a better place soon
  33200. var stateNode = inst.stateNode;
  33201. if (!stateNode) {
  33202. // Work in progress (ex: onload events in incremental mode).
  33203. return null;
  33204. }
  33205. var props = getFiberCurrentPropsFromNode(stateNode);
  33206. if (!props) {
  33207. // Work in progress.
  33208. return null;
  33209. }
  33210. listener = props[registrationName];
  33211. if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
  33212. return null;
  33213. }
  33214. (function () {
  33215. if (!(!listener || typeof listener === 'function')) {
  33216. {
  33217. throw ReactError(Error("Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type."));
  33218. }
  33219. }
  33220. })();
  33221. return listener;
  33222. }
  33223. /**
  33224. * Allows registered plugins an opportunity to extract events from top-level
  33225. * native browser events.
  33226. *
  33227. * @return {*} An accumulation of synthetic events.
  33228. * @internal
  33229. */
  33230. function extractPluginEvents(topLevelType, eventSystemFlags, targetInst, nativeEvent, nativeEventTarget) {
  33231. var events = null;
  33232. for (var i = 0; i < plugins.length; i++) {
  33233. // Not every plugin in the ordering may be loaded at runtime.
  33234. var possiblePlugin = plugins[i];
  33235. if (possiblePlugin) {
  33236. var extractedEvents = possiblePlugin.extractEvents(topLevelType, eventSystemFlags, targetInst, nativeEvent, nativeEventTarget);
  33237. if (extractedEvents) {
  33238. events = accumulateInto(events, extractedEvents);
  33239. }
  33240. }
  33241. }
  33242. return events;
  33243. }
  33244. function runExtractedPluginEventsInBatch(topLevelType, eventSystemFlags, targetInst, nativeEvent, nativeEventTarget) {
  33245. var events = extractPluginEvents(topLevelType, eventSystemFlags, targetInst, nativeEvent, nativeEventTarget);
  33246. runEventsInBatch(events);
  33247. }
  33248. var FunctionComponent = 0;
  33249. var ClassComponent = 1;
  33250. var IndeterminateComponent = 2; // Before we know whether it is function or class
  33251. var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
  33252. var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
  33253. var HostComponent = 5;
  33254. var HostText = 6;
  33255. var Fragment = 7;
  33256. var Mode = 8;
  33257. var ContextConsumer = 9;
  33258. var ContextProvider = 10;
  33259. var ForwardRef = 11;
  33260. var Profiler = 12;
  33261. var SuspenseComponent = 13;
  33262. var MemoComponent = 14;
  33263. var SimpleMemoComponent = 15;
  33264. var LazyComponent = 16;
  33265. var IncompleteClassComponent = 17;
  33266. var DehydratedFragment = 18;
  33267. var SuspenseListComponent = 19;
  33268. var FundamentalComponent = 20;
  33269. var ScopeComponent = 21;
  33270. 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.
  33271. // Current owner and dispatcher used to share the same ref,
  33272. // but PR #14548 split them out to better support the react-debug-tools package.
  33273. if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
  33274. ReactSharedInternals.ReactCurrentDispatcher = {
  33275. current: null
  33276. };
  33277. }
  33278. if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
  33279. ReactSharedInternals.ReactCurrentBatchConfig = {
  33280. suspense: null
  33281. };
  33282. }
  33283. var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
  33284. var describeComponentFrame = function (name, source, ownerName) {
  33285. var sourceInfo = '';
  33286. if (source) {
  33287. var path = source.fileName;
  33288. var fileName = path.replace(BEFORE_SLASH_RE, '');
  33289. {
  33290. // In DEV, include code for a common special case:
  33291. // prefer "folder/index.js" instead of just "index.js".
  33292. if (/^index\./.test(fileName)) {
  33293. var match = path.match(BEFORE_SLASH_RE);
  33294. if (match) {
  33295. var pathBeforeSlash = match[1];
  33296. if (pathBeforeSlash) {
  33297. var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
  33298. fileName = folderName + '/' + fileName;
  33299. }
  33300. }
  33301. }
  33302. }
  33303. sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
  33304. } else if (ownerName) {
  33305. sourceInfo = ' (created by ' + ownerName + ')';
  33306. }
  33307. return '\n in ' + (name || 'Unknown') + sourceInfo;
  33308. };
  33309. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  33310. // nor polyfill, then a plain number is used for performance.
  33311. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  33312. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  33313. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  33314. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  33315. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  33316. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  33317. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  33318. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  33319. // (unstable) APIs that have been removed. Can we remove the symbols?
  33320. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  33321. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  33322. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  33323. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  33324. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  33325. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  33326. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  33327. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  33328. var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
  33329. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  33330. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  33331. function getIteratorFn(maybeIterable) {
  33332. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  33333. return null;
  33334. }
  33335. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  33336. if (typeof maybeIterator === 'function') {
  33337. return maybeIterator;
  33338. }
  33339. return null;
  33340. }
  33341. /**
  33342. * Similar to invariant but only logs a warning if the condition is not met.
  33343. * This can be used to log issues in development environments in critical
  33344. * paths. Removing the logging code for production environments will keep the
  33345. * same logic and follow the same code paths.
  33346. */
  33347. var warning = warningWithoutStack$1;
  33348. {
  33349. warning = function (condition, format) {
  33350. if (condition) {
  33351. return;
  33352. }
  33353. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  33354. var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args
  33355. for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  33356. args[_key - 2] = arguments[_key];
  33357. }
  33358. warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack]));
  33359. };
  33360. }
  33361. var warning$1 = warning;
  33362. var Uninitialized = -1;
  33363. var Pending = 0;
  33364. var Resolved = 1;
  33365. var Rejected = 2;
  33366. function refineResolvedLazyComponent(lazyComponent) {
  33367. return lazyComponent._status === Resolved ? lazyComponent._result : null;
  33368. }
  33369. function initializeLazyComponentType(lazyComponent) {
  33370. if (lazyComponent._status === Uninitialized) {
  33371. lazyComponent._status = Pending;
  33372. var ctor = lazyComponent._ctor;
  33373. var thenable = ctor();
  33374. lazyComponent._result = thenable;
  33375. thenable.then(function (moduleObject) {
  33376. if (lazyComponent._status === Pending) {
  33377. var defaultExport = moduleObject.default;
  33378. {
  33379. if (defaultExport === undefined) {
  33380. warning$1(false, '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);
  33381. }
  33382. }
  33383. lazyComponent._status = Resolved;
  33384. lazyComponent._result = defaultExport;
  33385. }
  33386. }, function (error) {
  33387. if (lazyComponent._status === Pending) {
  33388. lazyComponent._status = Rejected;
  33389. lazyComponent._result = error;
  33390. }
  33391. });
  33392. }
  33393. }
  33394. function getWrappedName(outerType, innerType, wrapperName) {
  33395. var functionName = innerType.displayName || innerType.name || '';
  33396. return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
  33397. }
  33398. function getComponentName(type) {
  33399. if (type == null) {
  33400. // Host root, text node or just invalid type.
  33401. return null;
  33402. }
  33403. {
  33404. if (typeof type.tag === 'number') {
  33405. warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  33406. }
  33407. }
  33408. if (typeof type === 'function') {
  33409. return type.displayName || type.name || null;
  33410. }
  33411. if (typeof type === 'string') {
  33412. return type;
  33413. }
  33414. switch (type) {
  33415. case REACT_FRAGMENT_TYPE:
  33416. return 'Fragment';
  33417. case REACT_PORTAL_TYPE:
  33418. return 'Portal';
  33419. case REACT_PROFILER_TYPE:
  33420. return "Profiler";
  33421. case REACT_STRICT_MODE_TYPE:
  33422. return 'StrictMode';
  33423. case REACT_SUSPENSE_TYPE:
  33424. return 'Suspense';
  33425. case REACT_SUSPENSE_LIST_TYPE:
  33426. return 'SuspenseList';
  33427. }
  33428. if (typeof type === 'object') {
  33429. switch (type.$$typeof) {
  33430. case REACT_CONTEXT_TYPE:
  33431. return 'Context.Consumer';
  33432. case REACT_PROVIDER_TYPE:
  33433. return 'Context.Provider';
  33434. case REACT_FORWARD_REF_TYPE:
  33435. return getWrappedName(type, type.render, 'ForwardRef');
  33436. case REACT_MEMO_TYPE:
  33437. return getComponentName(type.type);
  33438. case REACT_LAZY_TYPE:
  33439. {
  33440. var thenable = type;
  33441. var resolvedThenable = refineResolvedLazyComponent(thenable);
  33442. if (resolvedThenable) {
  33443. return getComponentName(resolvedThenable);
  33444. }
  33445. break;
  33446. }
  33447. }
  33448. }
  33449. return null;
  33450. }
  33451. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  33452. function describeFiber(fiber) {
  33453. switch (fiber.tag) {
  33454. case HostRoot:
  33455. case HostPortal:
  33456. case HostText:
  33457. case Fragment:
  33458. case ContextProvider:
  33459. case ContextConsumer:
  33460. return '';
  33461. default:
  33462. var owner = fiber._debugOwner;
  33463. var source = fiber._debugSource;
  33464. var name = getComponentName(fiber.type);
  33465. var ownerName = null;
  33466. if (owner) {
  33467. ownerName = getComponentName(owner.type);
  33468. }
  33469. return describeComponentFrame(name, source, ownerName);
  33470. }
  33471. }
  33472. function getStackByFiberInDevAndProd(workInProgress) {
  33473. var info = '';
  33474. var node = workInProgress;
  33475. do {
  33476. info += describeFiber(node);
  33477. node = node.return;
  33478. } while (node);
  33479. return info;
  33480. }
  33481. var current = null;
  33482. var phase = null;
  33483. function getCurrentFiberOwnerNameInDevOrNull() {
  33484. {
  33485. if (current === null) {
  33486. return null;
  33487. }
  33488. var owner = current._debugOwner;
  33489. if (owner !== null && typeof owner !== 'undefined') {
  33490. return getComponentName(owner.type);
  33491. }
  33492. }
  33493. return null;
  33494. }
  33495. function getCurrentFiberStackInDev() {
  33496. {
  33497. if (current === null) {
  33498. return '';
  33499. } // Safe because if current fiber exists, we are reconciling,
  33500. // and it is guaranteed to be the work-in-progress version.
  33501. return getStackByFiberInDevAndProd(current);
  33502. }
  33503. return '';
  33504. }
  33505. function resetCurrentFiber() {
  33506. {
  33507. ReactDebugCurrentFrame.getCurrentStack = null;
  33508. current = null;
  33509. phase = null;
  33510. }
  33511. }
  33512. function setCurrentFiber(fiber) {
  33513. {
  33514. ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
  33515. current = fiber;
  33516. phase = null;
  33517. }
  33518. }
  33519. function setCurrentPhase(lifeCyclePhase) {
  33520. {
  33521. phase = lifeCyclePhase;
  33522. }
  33523. }
  33524. var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
  33525. function endsWith(subject, search) {
  33526. var length = subject.length;
  33527. return subject.substring(length - search.length, length) === search;
  33528. }
  33529. var PLUGIN_EVENT_SYSTEM = 1;
  33530. var RESPONDER_EVENT_SYSTEM = 1 << 1;
  33531. var IS_PASSIVE = 1 << 2;
  33532. var IS_ACTIVE = 1 << 3;
  33533. var PASSIVE_NOT_SUPPORTED = 1 << 4;
  33534. var IS_REPLAYED = 1 << 5;
  33535. var restoreImpl = null;
  33536. var restoreTarget = null;
  33537. var restoreQueue = null;
  33538. function restoreStateOfTarget(target) {
  33539. // We perform this translation at the end of the event loop so that we
  33540. // always receive the correct fiber here
  33541. var internalInstance = getInstanceFromNode(target);
  33542. if (!internalInstance) {
  33543. // Unmounted
  33544. return;
  33545. }
  33546. (function () {
  33547. if (!(typeof restoreImpl === 'function')) {
  33548. {
  33549. throw ReactError(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."));
  33550. }
  33551. }
  33552. })();
  33553. var props = getFiberCurrentPropsFromNode(internalInstance.stateNode);
  33554. restoreImpl(internalInstance.stateNode, internalInstance.type, props);
  33555. }
  33556. function setRestoreImplementation(impl) {
  33557. restoreImpl = impl;
  33558. }
  33559. function enqueueStateRestore(target) {
  33560. if (restoreTarget) {
  33561. if (restoreQueue) {
  33562. restoreQueue.push(target);
  33563. } else {
  33564. restoreQueue = [target];
  33565. }
  33566. } else {
  33567. restoreTarget = target;
  33568. }
  33569. }
  33570. function needsStateRestore() {
  33571. return restoreTarget !== null || restoreQueue !== null;
  33572. }
  33573. function restoreStateIfNeeded() {
  33574. if (!restoreTarget) {
  33575. return;
  33576. }
  33577. var target = restoreTarget;
  33578. var queuedTargets = restoreQueue;
  33579. restoreTarget = null;
  33580. restoreQueue = null;
  33581. restoreStateOfTarget(target);
  33582. if (queuedTargets) {
  33583. for (var i = 0; i < queuedTargets.length; i++) {
  33584. restoreStateOfTarget(queuedTargets[i]);
  33585. }
  33586. }
  33587. }
  33588. var enableUserTimingAPI = true; // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
  33589. var debugRenderPhaseSideEffects = false; // In some cases, StrictMode should also double-render lifecycles.
  33590. // This can be confusing for tests though,
  33591. // And it can be bad for performance in production.
  33592. // This feature flag can be used to control the behavior:
  33593. var debugRenderPhaseSideEffectsForStrictMode = true; // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  33594. // replay the begin phase of a failed component inside invokeGuardedCallback.
  33595. var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  33596. var warnAboutDeprecatedLifecycles = true; // Gather advanced timing metrics for Profiler subtrees.
  33597. var enableProfilerTimer = true; // Trace which interactions trigger each commit.
  33598. var enableSchedulerTracing = true; // Only used in www builds.
  33599. var enableSuspenseServerRenderer = false; // TODO: true? Here it might just be false.
  33600. var enableSelectiveHydration = false; // Only used in www builds.
  33601. // Only used in www builds.
  33602. // Disable javascript: URL strings in href for XSS protection.
  33603. var disableJavaScriptURLs = false; // React Fire: prevent the value and checked attributes from syncing
  33604. // with their related DOM properties
  33605. var disableInputAttributeSyncing = false; // These APIs will no longer be "unstable" in the upcoming 16.7 release,
  33606. // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
  33607. var enableStableConcurrentModeAPIs = false;
  33608. var warnAboutShorthandPropertyCollision = false; // See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
  33609. // This is a flag so we can fix warnings in RN core before turning it on
  33610. // Experimental React Flare event system and event components support.
  33611. var enableFlareAPI = false; // Experimental Host Component support.
  33612. var enableFundamentalAPI = false; // Experimental Scope support.
  33613. var enableScopeAPI = false; // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
  33614. // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
  33615. // Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
  33616. var warnAboutUnmockedScheduler = false; // For tests, we flush suspense fallbacks in an act scope;
  33617. // *except* in some of our own tests, where we test incremental loading states.
  33618. var flushSuspenseFallbacksInTests = true; // Changes priority of some events like mousemove to user-blocking priority,
  33619. // but without making them discrete. The flag exists in case it causes
  33620. // starvation problems.
  33621. var enableUserBlockingEvents = false; // Add a callback property to suspense to notify which promises are currently
  33622. // in the update queue. This allows reporting and tracing of what is causing
  33623. // the user to see a loading state.
  33624. // Also allows hydration callbacks to fire when a dehydrated boundary gets
  33625. // hydrated or deleted.
  33626. var enableSuspenseCallback = false; // Part of the simplification of React.createElement so we can eventually move
  33627. // from React.createElement to React.jsx
  33628. // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
  33629. var warnAboutDefaultPropsOnFunctionComponents = false;
  33630. var warnAboutStringRefs = false;
  33631. var disableLegacyContext = false;
  33632. var disableSchedulerTimeoutBasedOnReactExpirationTime = false;
  33633. var enableTrustedTypesIntegration = false;
  33634. // the renderer. Such as when we're dispatching events or if third party
  33635. // libraries need to call batchedUpdates. Eventually, this API will go away when
  33636. // everything is batched by default. We'll then have a similar API to opt-out of
  33637. // scheduled work and instead do synchronous work.
  33638. // Defaults
  33639. var batchedUpdatesImpl = function (fn, bookkeeping) {
  33640. return fn(bookkeeping);
  33641. };
  33642. var discreteUpdatesImpl = function (fn, a, b, c) {
  33643. return fn(a, b, c);
  33644. };
  33645. var flushDiscreteUpdatesImpl = function () {};
  33646. var batchedEventUpdatesImpl = batchedUpdatesImpl;
  33647. var isInsideEventHandler = false;
  33648. var isBatchingEventUpdates = false;
  33649. function finishEventHandler() {
  33650. // Here we wait until all updates have propagated, which is important
  33651. // when using controlled components within layers:
  33652. // https://github.com/facebook/react/issues/1698
  33653. // Then we restore state of any controlled component.
  33654. var controlledComponentsHavePendingUpdates = needsStateRestore();
  33655. if (controlledComponentsHavePendingUpdates) {
  33656. // If a controlled event was fired, we may need to restore the state of
  33657. // the DOM node back to the controlled value. This is necessary when React
  33658. // bails out of the update without touching the DOM.
  33659. flushDiscreteUpdatesImpl();
  33660. restoreStateIfNeeded();
  33661. }
  33662. }
  33663. function batchedUpdates(fn, bookkeeping) {
  33664. if (isInsideEventHandler) {
  33665. // If we are currently inside another batch, we need to wait until it
  33666. // fully completes before restoring state.
  33667. return fn(bookkeeping);
  33668. }
  33669. isInsideEventHandler = true;
  33670. try {
  33671. return batchedUpdatesImpl(fn, bookkeeping);
  33672. } finally {
  33673. isInsideEventHandler = false;
  33674. finishEventHandler();
  33675. }
  33676. }
  33677. function batchedEventUpdates(fn, a, b) {
  33678. if (isBatchingEventUpdates) {
  33679. // If we are currently inside another batch, we need to wait until it
  33680. // fully completes before restoring state.
  33681. return fn(a, b);
  33682. }
  33683. isBatchingEventUpdates = true;
  33684. try {
  33685. return batchedEventUpdatesImpl(fn, a, b);
  33686. } finally {
  33687. isBatchingEventUpdates = false;
  33688. finishEventHandler();
  33689. }
  33690. } // This is for the React Flare event system
  33691. function executeUserEventHandler(fn, value) {
  33692. var previouslyInEventHandler = isInsideEventHandler;
  33693. try {
  33694. isInsideEventHandler = true;
  33695. var type = typeof value === 'object' && value !== null ? value.type : '';
  33696. invokeGuardedCallbackAndCatchFirstError(type, fn, undefined, value);
  33697. } finally {
  33698. isInsideEventHandler = previouslyInEventHandler;
  33699. }
  33700. }
  33701. function discreteUpdates(fn, a, b, c) {
  33702. var prevIsInsideEventHandler = isInsideEventHandler;
  33703. isInsideEventHandler = true;
  33704. try {
  33705. return discreteUpdatesImpl(fn, a, b, c);
  33706. } finally {
  33707. isInsideEventHandler = prevIsInsideEventHandler;
  33708. if (!isInsideEventHandler) {
  33709. finishEventHandler();
  33710. }
  33711. }
  33712. }
  33713. var lastFlushedEventTimeStamp = 0;
  33714. function flushDiscreteUpdatesIfNeeded(timeStamp) {
  33715. // event.timeStamp isn't overly reliable due to inconsistencies in
  33716. // how different browsers have historically provided the time stamp.
  33717. // Some browsers provide high-resolution time stamps for all events,
  33718. // some provide low-resolution time stamps for all events. FF < 52
  33719. // even mixes both time stamps together. Some browsers even report
  33720. // negative time stamps or time stamps that are 0 (iOS9) in some cases.
  33721. // Given we are only comparing two time stamps with equality (!==),
  33722. // we are safe from the resolution differences. If the time stamp is 0
  33723. // we bail-out of preventing the flush, which can affect semantics,
  33724. // such as if an earlier flush removes or adds event listeners that
  33725. // are fired in the subsequent flush. However, this is the same
  33726. // behaviour as we had before this change, so the risks are low.
  33727. if (!isInsideEventHandler && (!enableFlareAPI || timeStamp === 0 || lastFlushedEventTimeStamp !== timeStamp)) {
  33728. lastFlushedEventTimeStamp = timeStamp;
  33729. flushDiscreteUpdatesImpl();
  33730. }
  33731. }
  33732. function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) {
  33733. batchedUpdatesImpl = _batchedUpdatesImpl;
  33734. discreteUpdatesImpl = _discreteUpdatesImpl;
  33735. flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl;
  33736. batchedEventUpdatesImpl = _batchedEventUpdatesImpl;
  33737. }
  33738. var DiscreteEvent = 0;
  33739. var UserBlockingEvent = 1;
  33740. var ContinuousEvent = 2;
  33741. // CommonJS interop named imports.
  33742. var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
  33743. var runWithPriority = Scheduler.unstable_runWithPriority;
  33744. var listenToResponderEventTypesImpl;
  33745. function setListenToResponderEventTypes(_listenToResponderEventTypesImpl) {
  33746. listenToResponderEventTypesImpl = _listenToResponderEventTypesImpl;
  33747. }
  33748. var activeTimeouts = new Map();
  33749. var rootEventTypesToEventResponderInstances = new Map();
  33750. var DoNotPropagateToNextResponder = 0;
  33751. var PropagateToNextResponder = 1;
  33752. var currentTimeStamp = 0;
  33753. var currentTimers = new Map();
  33754. var currentInstance = null;
  33755. var currentTimerIDCounter = 0;
  33756. var currentDocument = null;
  33757. var currentPropagationBehavior = DoNotPropagateToNextResponder;
  33758. var eventResponderContext = {
  33759. dispatchEvent: function (eventValue, eventListener, eventPriority) {
  33760. validateResponderContext();
  33761. validateEventValue(eventValue);
  33762. switch (eventPriority) {
  33763. case DiscreteEvent:
  33764. {
  33765. flushDiscreteUpdatesIfNeeded(currentTimeStamp);
  33766. discreteUpdates(function () {
  33767. return executeUserEventHandler(eventListener, eventValue);
  33768. });
  33769. break;
  33770. }
  33771. case UserBlockingEvent:
  33772. {
  33773. if (enableUserBlockingEvents) {
  33774. runWithPriority(UserBlockingPriority, function () {
  33775. return executeUserEventHandler(eventListener, eventValue);
  33776. });
  33777. } else {
  33778. executeUserEventHandler(eventListener, eventValue);
  33779. }
  33780. break;
  33781. }
  33782. case ContinuousEvent:
  33783. {
  33784. executeUserEventHandler(eventListener, eventValue);
  33785. break;
  33786. }
  33787. }
  33788. },
  33789. isTargetWithinResponder: function (target) {
  33790. validateResponderContext();
  33791. if (target != null) {
  33792. var fiber = getClosestInstanceFromNode(target);
  33793. var responderFiber = currentInstance.fiber;
  33794. while (fiber !== null) {
  33795. if (fiber === responderFiber || fiber.alternate === responderFiber) {
  33796. return true;
  33797. }
  33798. fiber = fiber.return;
  33799. }
  33800. }
  33801. return false;
  33802. },
  33803. isTargetWithinResponderScope: function (target) {
  33804. validateResponderContext();
  33805. var componentInstance = currentInstance;
  33806. var responder = componentInstance.responder;
  33807. if (target != null) {
  33808. var fiber = getClosestInstanceFromNode(target);
  33809. var responderFiber = currentInstance.fiber;
  33810. while (fiber !== null) {
  33811. if (fiber === responderFiber || fiber.alternate === responderFiber) {
  33812. return true;
  33813. }
  33814. if (doesFiberHaveResponder(fiber, responder)) {
  33815. return false;
  33816. }
  33817. fiber = fiber.return;
  33818. }
  33819. }
  33820. return false;
  33821. },
  33822. isTargetWithinNode: function (childTarget, parentTarget) {
  33823. validateResponderContext();
  33824. var childFiber = getClosestInstanceFromNode(childTarget);
  33825. var parentFiber = getClosestInstanceFromNode(parentTarget);
  33826. if (childFiber != null && parentFiber != null) {
  33827. var parentAlternateFiber = parentFiber.alternate;
  33828. var node = childFiber;
  33829. while (node !== null) {
  33830. if (node === parentFiber || node === parentAlternateFiber) {
  33831. return true;
  33832. }
  33833. node = node.return;
  33834. }
  33835. return false;
  33836. } // Fallback to DOM APIs
  33837. return parentTarget.contains(childTarget);
  33838. },
  33839. addRootEventTypes: function (rootEventTypes) {
  33840. validateResponderContext();
  33841. listenToResponderEventTypesImpl(rootEventTypes, currentDocument);
  33842. for (var i = 0; i < rootEventTypes.length; i++) {
  33843. var rootEventType = rootEventTypes[i];
  33844. var eventResponderInstance = currentInstance;
  33845. registerRootEventType(rootEventType, eventResponderInstance);
  33846. }
  33847. },
  33848. removeRootEventTypes: function (rootEventTypes) {
  33849. validateResponderContext();
  33850. for (var i = 0; i < rootEventTypes.length; i++) {
  33851. var rootEventType = rootEventTypes[i];
  33852. var rootEventResponders = rootEventTypesToEventResponderInstances.get(rootEventType);
  33853. var rootEventTypesSet = currentInstance.rootEventTypes;
  33854. if (rootEventTypesSet !== null) {
  33855. rootEventTypesSet.delete(rootEventType);
  33856. }
  33857. if (rootEventResponders !== undefined) {
  33858. rootEventResponders.delete(currentInstance);
  33859. }
  33860. }
  33861. },
  33862. setTimeout: function (func, delay) {
  33863. validateResponderContext();
  33864. if (currentTimers === null) {
  33865. currentTimers = new Map();
  33866. }
  33867. var timeout = currentTimers.get(delay);
  33868. var timerId = currentTimerIDCounter++;
  33869. if (timeout === undefined) {
  33870. var timers = new Map();
  33871. var id = setTimeout(function () {
  33872. processTimers(timers, delay);
  33873. }, delay);
  33874. timeout = {
  33875. id: id,
  33876. timers: timers
  33877. };
  33878. currentTimers.set(delay, timeout);
  33879. }
  33880. timeout.timers.set(timerId, {
  33881. instance: currentInstance,
  33882. func: func,
  33883. id: timerId,
  33884. timeStamp: currentTimeStamp
  33885. });
  33886. activeTimeouts.set(timerId, timeout);
  33887. return timerId;
  33888. },
  33889. clearTimeout: function (timerId) {
  33890. validateResponderContext();
  33891. var timeout = activeTimeouts.get(timerId);
  33892. if (timeout !== undefined) {
  33893. var timers = timeout.timers;
  33894. timers.delete(timerId);
  33895. if (timers.size === 0) {
  33896. clearTimeout(timeout.id);
  33897. }
  33898. }
  33899. },
  33900. getActiveDocument: getActiveDocument,
  33901. objectAssign: _assign,
  33902. getTimeStamp: function () {
  33903. validateResponderContext();
  33904. return currentTimeStamp;
  33905. },
  33906. isTargetWithinHostComponent: function (target, elementType) {
  33907. validateResponderContext();
  33908. var fiber = getClosestInstanceFromNode(target);
  33909. while (fiber !== null) {
  33910. if (fiber.tag === HostComponent && fiber.type === elementType) {
  33911. return true;
  33912. }
  33913. fiber = fiber.return;
  33914. }
  33915. return false;
  33916. },
  33917. continuePropagation: function () {
  33918. currentPropagationBehavior = PropagateToNextResponder;
  33919. },
  33920. enqueueStateRestore: enqueueStateRestore,
  33921. getResponderNode: function () {
  33922. validateResponderContext();
  33923. var responderFiber = currentInstance.fiber;
  33924. if (responderFiber.tag === ScopeComponent) {
  33925. return null;
  33926. }
  33927. return responderFiber.stateNode;
  33928. }
  33929. };
  33930. function validateEventValue(eventValue) {
  33931. if (typeof eventValue === 'object' && eventValue !== null) {
  33932. var target = eventValue.target,
  33933. type = eventValue.type,
  33934. timeStamp = eventValue.timeStamp;
  33935. if (target == null || type == null || timeStamp == null) {
  33936. throw new Error('context.dispatchEvent: "target", "timeStamp", and "type" fields on event object are required.');
  33937. }
  33938. var showWarning = function (name) {
  33939. {
  33940. warning$1(false, '%s is not available on event objects created from event responder modules (React Flare). ' + 'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.%s }`', name, name);
  33941. }
  33942. };
  33943. eventValue.isDefaultPrevented = function () {
  33944. {
  33945. showWarning('isDefaultPrevented()');
  33946. }
  33947. };
  33948. eventValue.isPropagationStopped = function () {
  33949. {
  33950. showWarning('isPropagationStopped()');
  33951. }
  33952. }; // $FlowFixMe: we don't need value, Flow thinks we do
  33953. Object.defineProperty(eventValue, 'nativeEvent', {
  33954. get: function () {
  33955. {
  33956. showWarning('nativeEvent');
  33957. }
  33958. }
  33959. });
  33960. }
  33961. }
  33962. function doesFiberHaveResponder(fiber, responder) {
  33963. var tag = fiber.tag;
  33964. if (tag === HostComponent || tag === ScopeComponent) {
  33965. var dependencies = fiber.dependencies;
  33966. if (dependencies !== null) {
  33967. var respondersMap = dependencies.responders;
  33968. if (respondersMap !== null && respondersMap.has(responder)) {
  33969. return true;
  33970. }
  33971. }
  33972. }
  33973. return false;
  33974. }
  33975. function getActiveDocument() {
  33976. return currentDocument;
  33977. }
  33978. function processTimers(timers, delay) {
  33979. var timersArr = Array.from(timers.values());
  33980. var previousInstance = currentInstance;
  33981. var previousTimers = currentTimers;
  33982. try {
  33983. batchedEventUpdates(function () {
  33984. for (var i = 0; i < timersArr.length; i++) {
  33985. var _timersArr$i = timersArr[i],
  33986. instance = _timersArr$i.instance,
  33987. func = _timersArr$i.func,
  33988. id = _timersArr$i.id,
  33989. timeStamp = _timersArr$i.timeStamp;
  33990. currentInstance = instance;
  33991. currentTimeStamp = timeStamp + delay;
  33992. try {
  33993. func();
  33994. } finally {
  33995. activeTimeouts.delete(id);
  33996. }
  33997. }
  33998. });
  33999. } finally {
  34000. currentTimers = previousTimers;
  34001. currentInstance = previousInstance;
  34002. currentTimeStamp = 0;
  34003. }
  34004. }
  34005. function createDOMResponderEvent(topLevelType, nativeEvent, nativeEventTarget, passive, passiveSupported) {
  34006. var _ref = nativeEvent,
  34007. buttons = _ref.buttons,
  34008. pointerType = _ref.pointerType;
  34009. var eventPointerType = '';
  34010. if (pointerType !== undefined) {
  34011. eventPointerType = pointerType;
  34012. } else if (nativeEvent.key !== undefined) {
  34013. eventPointerType = 'keyboard';
  34014. } else if (buttons !== undefined) {
  34015. eventPointerType = 'mouse';
  34016. } else if (nativeEvent.changedTouches !== undefined) {
  34017. eventPointerType = 'touch';
  34018. }
  34019. return {
  34020. nativeEvent: nativeEvent,
  34021. passive: passive,
  34022. passiveSupported: passiveSupported,
  34023. pointerType: eventPointerType,
  34024. target: nativeEventTarget,
  34025. type: topLevelType
  34026. };
  34027. }
  34028. function responderEventTypesContainType(eventTypes, type) {
  34029. for (var i = 0, len = eventTypes.length; i < len; i++) {
  34030. if (eventTypes[i] === type) {
  34031. return true;
  34032. }
  34033. }
  34034. return false;
  34035. }
  34036. function validateResponderTargetEventTypes(eventType, responder) {
  34037. var targetEventTypes = responder.targetEventTypes; // Validate the target event type exists on the responder
  34038. if (targetEventTypes !== null) {
  34039. return responderEventTypesContainType(targetEventTypes, eventType);
  34040. }
  34041. return false;
  34042. }
  34043. function traverseAndHandleEventResponderInstances(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags) {
  34044. var isPassiveEvent = (eventSystemFlags & IS_PASSIVE) !== 0;
  34045. var isPassiveSupported = (eventSystemFlags & PASSIVE_NOT_SUPPORTED) === 0;
  34046. var isPassive = isPassiveEvent || !isPassiveSupported;
  34047. var eventType = isPassive ? topLevelType : topLevelType + '_active'; // Trigger event responders in this order:
  34048. // - Bubble target responder phase
  34049. // - Root responder phase
  34050. var visitedResponders = new Set();
  34051. var responderEvent = createDOMResponderEvent(topLevelType, nativeEvent, nativeEventTarget, isPassiveEvent, isPassiveSupported);
  34052. var node = targetFiber;
  34053. var insidePortal = false;
  34054. while (node !== null) {
  34055. var _node = node,
  34056. dependencies = _node.dependencies,
  34057. tag = _node.tag;
  34058. if (tag === HostPortal) {
  34059. insidePortal = true;
  34060. } else if ((tag === HostComponent || tag === ScopeComponent) && dependencies !== null) {
  34061. var respondersMap = dependencies.responders;
  34062. if (respondersMap !== null) {
  34063. var responderInstances = Array.from(respondersMap.values());
  34064. for (var i = 0, length = responderInstances.length; i < length; i++) {
  34065. var responderInstance = responderInstances[i];
  34066. var props = responderInstance.props,
  34067. responder = responderInstance.responder,
  34068. state = responderInstance.state;
  34069. if (!visitedResponders.has(responder) && validateResponderTargetEventTypes(eventType, responder) && (!insidePortal || responder.targetPortalPropagation)) {
  34070. visitedResponders.add(responder);
  34071. var onEvent = responder.onEvent;
  34072. if (onEvent !== null) {
  34073. currentInstance = responderInstance;
  34074. onEvent(responderEvent, eventResponderContext, props, state);
  34075. if (currentPropagationBehavior === PropagateToNextResponder) {
  34076. visitedResponders.delete(responder);
  34077. currentPropagationBehavior = DoNotPropagateToNextResponder;
  34078. }
  34079. }
  34080. }
  34081. }
  34082. }
  34083. }
  34084. node = node.return;
  34085. } // Root phase
  34086. var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(eventType);
  34087. if (rootEventResponderInstances !== undefined) {
  34088. var _responderInstances = Array.from(rootEventResponderInstances);
  34089. for (var _i = 0; _i < _responderInstances.length; _i++) {
  34090. var _responderInstance = _responderInstances[_i];
  34091. var props = _responderInstance.props,
  34092. responder = _responderInstance.responder,
  34093. state = _responderInstance.state;
  34094. var onRootEvent = responder.onRootEvent;
  34095. if (onRootEvent !== null) {
  34096. currentInstance = _responderInstance;
  34097. onRootEvent(responderEvent, eventResponderContext, props, state);
  34098. }
  34099. }
  34100. }
  34101. }
  34102. function mountEventResponder(responder, responderInstance, props, state) {
  34103. var onMount = responder.onMount;
  34104. if (onMount !== null) {
  34105. var previousInstance = currentInstance;
  34106. var previousTimers = currentTimers;
  34107. currentInstance = responderInstance;
  34108. try {
  34109. batchedEventUpdates(function () {
  34110. onMount(eventResponderContext, props, state);
  34111. });
  34112. } finally {
  34113. currentInstance = previousInstance;
  34114. currentTimers = previousTimers;
  34115. }
  34116. }
  34117. }
  34118. function unmountEventResponder(responderInstance) {
  34119. var responder = responderInstance.responder;
  34120. var onUnmount = responder.onUnmount;
  34121. if (onUnmount !== null) {
  34122. var props = responderInstance.props,
  34123. state = responderInstance.state;
  34124. var previousInstance = currentInstance;
  34125. var previousTimers = currentTimers;
  34126. currentInstance = responderInstance;
  34127. try {
  34128. batchedEventUpdates(function () {
  34129. onUnmount(eventResponderContext, props, state);
  34130. });
  34131. } finally {
  34132. currentInstance = previousInstance;
  34133. currentTimers = previousTimers;
  34134. }
  34135. }
  34136. var rootEventTypesSet = responderInstance.rootEventTypes;
  34137. if (rootEventTypesSet !== null) {
  34138. var rootEventTypes = Array.from(rootEventTypesSet);
  34139. for (var i = 0; i < rootEventTypes.length; i++) {
  34140. var topLevelEventType = rootEventTypes[i];
  34141. var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(topLevelEventType);
  34142. if (rootEventResponderInstances !== undefined) {
  34143. rootEventResponderInstances.delete(responderInstance);
  34144. }
  34145. }
  34146. }
  34147. }
  34148. function validateResponderContext() {
  34149. (function () {
  34150. if (!(currentInstance !== null)) {
  34151. {
  34152. throw ReactError(Error("An event responder context was used outside of an event cycle. Use context.setTimeout() to use asynchronous responder context outside of event cycle ."));
  34153. }
  34154. }
  34155. })();
  34156. }
  34157. function dispatchEventForResponderEventSystem(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags) {
  34158. if (enableFlareAPI) {
  34159. var previousInstance = currentInstance;
  34160. var previousTimers = currentTimers;
  34161. var previousTimeStamp = currentTimeStamp;
  34162. var previousDocument = currentDocument;
  34163. var previousPropagationBehavior = currentPropagationBehavior;
  34164. currentPropagationBehavior = DoNotPropagateToNextResponder;
  34165. currentTimers = null; // nodeType 9 is DOCUMENT_NODE
  34166. currentDocument = nativeEventTarget.nodeType === 9 ? nativeEventTarget : nativeEventTarget.ownerDocument; // We might want to control timeStamp another way here
  34167. currentTimeStamp = nativeEvent.timeStamp;
  34168. try {
  34169. batchedEventUpdates(function () {
  34170. traverseAndHandleEventResponderInstances(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags);
  34171. });
  34172. } finally {
  34173. currentTimers = previousTimers;
  34174. currentInstance = previousInstance;
  34175. currentTimeStamp = previousTimeStamp;
  34176. currentDocument = previousDocument;
  34177. currentPropagationBehavior = previousPropagationBehavior;
  34178. }
  34179. }
  34180. }
  34181. function addRootEventTypesForResponderInstance(responderInstance, rootEventTypes) {
  34182. for (var i = 0; i < rootEventTypes.length; i++) {
  34183. var rootEventType = rootEventTypes[i];
  34184. registerRootEventType(rootEventType, responderInstance);
  34185. }
  34186. }
  34187. function registerRootEventType(rootEventType, eventResponderInstance) {
  34188. var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(rootEventType);
  34189. if (rootEventResponderInstances === undefined) {
  34190. rootEventResponderInstances = new Set();
  34191. rootEventTypesToEventResponderInstances.set(rootEventType, rootEventResponderInstances);
  34192. }
  34193. var rootEventTypesSet = eventResponderInstance.rootEventTypes;
  34194. if (rootEventTypesSet === null) {
  34195. rootEventTypesSet = eventResponderInstance.rootEventTypes = new Set();
  34196. }
  34197. (function () {
  34198. if (!!rootEventTypesSet.has(rootEventType)) {
  34199. {
  34200. throw ReactError(Error("addRootEventTypes() found a duplicate root event type of \"" + rootEventType + "\". This might be because the event type exists in the event responder \"rootEventTypes\" array or because of a previous addRootEventTypes() using this root event type."));
  34201. }
  34202. }
  34203. })();
  34204. rootEventTypesSet.add(rootEventType);
  34205. rootEventResponderInstances.add(eventResponderInstance);
  34206. }
  34207. // A reserved attribute.
  34208. // It is handled by React separately and shouldn't be written to the DOM.
  34209. var RESERVED = 0; // A simple string attribute.
  34210. // Attributes that aren't in the whitelist are presumed to have this type.
  34211. var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called
  34212. // "enumerated" attributes with "true" and "false" as possible values.
  34213. // When true, it should be set to a "true" string.
  34214. // When false, it should be set to a "false" string.
  34215. var BOOLEANISH_STRING = 2; // A real boolean attribute.
  34216. // When true, it should be present (set either to an empty string or its name).
  34217. // When false, it should be omitted.
  34218. var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value.
  34219. // When true, it should be present (set either to an empty string or its name).
  34220. // When false, it should be omitted.
  34221. // For any other value, should be present with that value.
  34222. var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric.
  34223. // When falsy, it should be removed.
  34224. var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric.
  34225. // When falsy, it should be removed.
  34226. var POSITIVE_NUMERIC = 6;
  34227. /* eslint-disable max-len */
  34228. 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";
  34229. /* eslint-enable max-len */
  34230. var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
  34231. var ROOT_ATTRIBUTE_NAME = 'data-reactroot';
  34232. var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
  34233. var hasOwnProperty = Object.prototype.hasOwnProperty;
  34234. var illegalAttributeNameCache = {};
  34235. var validatedAttributeNameCache = {};
  34236. function isAttributeNameSafe(attributeName) {
  34237. if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) {
  34238. return true;
  34239. }
  34240. if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) {
  34241. return false;
  34242. }
  34243. if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
  34244. validatedAttributeNameCache[attributeName] = true;
  34245. return true;
  34246. }
  34247. illegalAttributeNameCache[attributeName] = true;
  34248. {
  34249. warning$1(false, 'Invalid attribute name: `%s`', attributeName);
  34250. }
  34251. return false;
  34252. }
  34253. function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
  34254. if (propertyInfo !== null) {
  34255. return propertyInfo.type === RESERVED;
  34256. }
  34257. if (isCustomComponentTag) {
  34258. return false;
  34259. }
  34260. if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
  34261. return true;
  34262. }
  34263. return false;
  34264. }
  34265. function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
  34266. if (propertyInfo !== null && propertyInfo.type === RESERVED) {
  34267. return false;
  34268. }
  34269. switch (typeof value) {
  34270. case 'function': // $FlowIssue symbol is perfectly valid here
  34271. case 'symbol':
  34272. // eslint-disable-line
  34273. return true;
  34274. case 'boolean':
  34275. {
  34276. if (isCustomComponentTag) {
  34277. return false;
  34278. }
  34279. if (propertyInfo !== null) {
  34280. return !propertyInfo.acceptsBooleans;
  34281. } else {
  34282. var prefix = name.toLowerCase().slice(0, 5);
  34283. return prefix !== 'data-' && prefix !== 'aria-';
  34284. }
  34285. }
  34286. default:
  34287. return false;
  34288. }
  34289. }
  34290. function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
  34291. if (value === null || typeof value === 'undefined') {
  34292. return true;
  34293. }
  34294. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
  34295. return true;
  34296. }
  34297. if (isCustomComponentTag) {
  34298. return false;
  34299. }
  34300. if (propertyInfo !== null) {
  34301. switch (propertyInfo.type) {
  34302. case BOOLEAN:
  34303. return !value;
  34304. case OVERLOADED_BOOLEAN:
  34305. return value === false;
  34306. case NUMERIC:
  34307. return isNaN(value);
  34308. case POSITIVE_NUMERIC:
  34309. return isNaN(value) || value < 1;
  34310. }
  34311. }
  34312. return false;
  34313. }
  34314. function getPropertyInfo(name) {
  34315. return properties.hasOwnProperty(name) ? properties[name] : null;
  34316. }
  34317. function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL) {
  34318. this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
  34319. this.attributeName = attributeName;
  34320. this.attributeNamespace = attributeNamespace;
  34321. this.mustUseProperty = mustUseProperty;
  34322. this.propertyName = name;
  34323. this.type = type;
  34324. this.sanitizeURL = sanitizeURL;
  34325. } // When adding attributes to this list, be sure to also add them to
  34326. // the `possibleStandardNames` module to ensure casing and incorrect
  34327. // name warnings.
  34328. var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM.
  34329. ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular
  34330. // elements (not just inputs). Now that ReactDOMInput assigns to the
  34331. // defaultValue property -- do we need this?
  34332. 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'].forEach(function (name) {
  34333. properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
  34334. name, // attributeName
  34335. null, // attributeNamespace
  34336. false);
  34337. }); // A few React string attributes have a different name.
  34338. // This is a mapping from React prop names to the attribute names.
  34339. [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
  34340. var name = _ref[0],
  34341. attributeName = _ref[1];
  34342. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  34343. attributeName, // attributeName
  34344. null, // attributeNamespace
  34345. false);
  34346. }); // These are "enumerated" HTML attributes that accept "true" and "false".
  34347. // In React, we let users pass `true` and `false` even though technically
  34348. // these aren't boolean attributes (they are coerced to strings).
  34349. ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
  34350. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  34351. name.toLowerCase(), // attributeName
  34352. null, // attributeNamespace
  34353. false);
  34354. }); // These are "enumerated" SVG attributes that accept "true" and "false".
  34355. // In React, we let users pass `true` and `false` even though technically
  34356. // these aren't boolean attributes (they are coerced to strings).
  34357. // Since these are SVG attributes, their attribute names are case-sensitive.
  34358. ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
  34359. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  34360. name, // attributeName
  34361. null, // attributeNamespace
  34362. false);
  34363. }); // These are HTML boolean attributes.
  34364. ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM
  34365. // on the client side because the browsers are inconsistent. Instead we call focus().
  34366. 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata
  34367. 'itemScope'].forEach(function (name) {
  34368. properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
  34369. name.toLowerCase(), // attributeName
  34370. null, // attributeNamespace
  34371. false);
  34372. }); // These are the few React props that we set as DOM properties
  34373. // rather than attributes. These are all booleans.
  34374. ['checked', // Note: `option.selected` is not updated if `select.multiple` is
  34375. // disabled with `removeAttribute`. We have special logic for handling this.
  34376. 'multiple', 'muted', 'selected'].forEach(function (name) {
  34377. properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
  34378. name, // attributeName
  34379. null, // attributeNamespace
  34380. false);
  34381. }); // These are HTML attributes that are "overloaded booleans": they behave like
  34382. // booleans, but can also accept a string value.
  34383. ['capture', 'download'].forEach(function (name) {
  34384. properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
  34385. name, // attributeName
  34386. null, // attributeNamespace
  34387. false);
  34388. }); // These are HTML attributes that must be positive numbers.
  34389. ['cols', 'rows', 'size', 'span'].forEach(function (name) {
  34390. properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
  34391. name, // attributeName
  34392. null, // attributeNamespace
  34393. false);
  34394. }); // These are HTML attributes that must be numbers.
  34395. ['rowSpan', 'start'].forEach(function (name) {
  34396. properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
  34397. name.toLowerCase(), // attributeName
  34398. null, // attributeNamespace
  34399. false);
  34400. });
  34401. var CAMELIZE = /[\-\:]([a-z])/g;
  34402. var capitalize = function (token) {
  34403. return token[1].toUpperCase();
  34404. }; // This is a list of all SVG attributes that need special casing, namespacing,
  34405. // or boolean value assignment. Regular attributes that just accept strings
  34406. // and have the same names are omitted, just like in the HTML whitelist.
  34407. // Some of these attributes can be hard to find. This list was created by
  34408. // scrapping the MDN documentation.
  34409. ['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'].forEach(function (attributeName) {
  34410. var name = attributeName.replace(CAMELIZE, capitalize);
  34411. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  34412. attributeName, null, // attributeNamespace
  34413. false);
  34414. }); // String SVG attributes with the xlink namespace.
  34415. ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) {
  34416. var name = attributeName.replace(CAMELIZE, capitalize);
  34417. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  34418. attributeName, 'http://www.w3.org/1999/xlink', false);
  34419. }); // String SVG attributes with the xml namespace.
  34420. ['xml:base', 'xml:lang', 'xml:space'].forEach(function (attributeName) {
  34421. var name = attributeName.replace(CAMELIZE, capitalize);
  34422. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  34423. attributeName, 'http://www.w3.org/XML/1998/namespace', false);
  34424. }); // These attribute exists both in HTML and SVG.
  34425. // The attribute name is case-sensitive in SVG so we can't just use
  34426. // the React name like we do for attributes that exist only in HTML.
  34427. ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
  34428. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  34429. attributeName.toLowerCase(), // attributeName
  34430. null, // attributeNamespace
  34431. false);
  34432. }); // These attributes accept URLs. These must not allow javascript: URLS.
  34433. // These will also need to accept Trusted Types object in the future.
  34434. var xlinkHref = 'xlinkHref';
  34435. properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
  34436. 'xlink:href', 'http://www.w3.org/1999/xlink', true);
  34437. ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
  34438. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  34439. attributeName.toLowerCase(), // attributeName
  34440. null, // attributeNamespace
  34441. true);
  34442. });
  34443. var ReactDebugCurrentFrame$1 = null;
  34444. {
  34445. ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
  34446. } // A javascript: URL can contain leading C0 control or \u0020 SPACE,
  34447. // and any newline or tab are filtered out as if they're not part of the URL.
  34448. // https://url.spec.whatwg.org/#url-parsing
  34449. // Tab or newline are defined as \r\n\t:
  34450. // https://infra.spec.whatwg.org/#ascii-tab-or-newline
  34451. // A C0 control is a code point in the range \u0000 NULL to \u001F
  34452. // INFORMATION SEPARATOR ONE, inclusive:
  34453. // https://infra.spec.whatwg.org/#c0-control-or-space
  34454. /* eslint-disable max-len */
  34455. 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;
  34456. var didWarn = false;
  34457. function sanitizeURL(url) {
  34458. if (disableJavaScriptURLs) {
  34459. (function () {
  34460. if (!!isJavaScriptProtocol.test(url)) {
  34461. {
  34462. throw ReactError(Error("React has blocked a javascript: URL as a security precaution." + (ReactDebugCurrentFrame$1.getStackAddendum())));
  34463. }
  34464. }
  34465. })();
  34466. } else if ( true && !didWarn && isJavaScriptProtocol.test(url)) {
  34467. didWarn = true;
  34468. warning$1(false, '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));
  34469. }
  34470. }
  34471. // Flow does not allow string concatenation of most non-string types. To work
  34472. // around this limitation, we use an opaque type that can only be obtained by
  34473. // passing the value through getToStringValue first.
  34474. function toString(value) {
  34475. return '' + value;
  34476. }
  34477. function getToStringValue(value) {
  34478. switch (typeof value) {
  34479. case 'boolean':
  34480. case 'number':
  34481. case 'object':
  34482. case 'string':
  34483. case 'undefined':
  34484. return value;
  34485. default:
  34486. // function, symbol are assigned as empty strings
  34487. return '';
  34488. }
  34489. }
  34490. /** Trusted value is a wrapper for "safe" values which can be assigned to DOM execution sinks. */
  34491. /**
  34492. * We allow passing objects with toString method as element attributes or in dangerouslySetInnerHTML
  34493. * and we do validations that the value is safe. Once we do validation we want to use the validated
  34494. * value instead of the object (because object.toString may return something else on next call).
  34495. *
  34496. * If application uses Trusted Types we don't stringify trusted values, but preserve them as objects.
  34497. */
  34498. var toStringOrTrustedType = toString;
  34499. if (enableTrustedTypesIntegration && typeof trustedTypes !== 'undefined') {
  34500. var isHTML = trustedTypes.isHTML;
  34501. var isScript = trustedTypes.isScript;
  34502. var isScriptURL = trustedTypes.isScriptURL; // TrustedURLs are deprecated and will be removed soon: https://github.com/WICG/trusted-types/pull/204
  34503. var isURL = trustedTypes.isURL ? trustedTypes.isURL : function (value) {
  34504. return false;
  34505. };
  34506. toStringOrTrustedType = function (value) {
  34507. if (typeof value === 'object' && (isHTML(value) || isScript(value) || isScriptURL(value) || isURL(value))) {
  34508. // Pass Trusted Types through.
  34509. return value;
  34510. }
  34511. return toString(value);
  34512. };
  34513. }
  34514. /**
  34515. * Set attribute for a node. The attribute value can be either string or
  34516. * Trusted value (if application uses Trusted Types).
  34517. */
  34518. function setAttribute(node, attributeName, attributeValue) {
  34519. node.setAttribute(attributeName, attributeValue);
  34520. }
  34521. /**
  34522. * Set attribute with namespace for a node. The attribute value can be either string or
  34523. * Trusted value (if application uses Trusted Types).
  34524. */
  34525. function setAttributeNS(node, attributeNamespace, attributeName, attributeValue) {
  34526. node.setAttributeNS(attributeNamespace, attributeName, attributeValue);
  34527. }
  34528. /**
  34529. * Get the value for a property on a node. Only used in DEV for SSR validation.
  34530. * The "expected" argument is used as a hint of what the expected value is.
  34531. * Some properties have multiple equivalent values.
  34532. */
  34533. function getValueForProperty(node, name, expected, propertyInfo) {
  34534. {
  34535. if (propertyInfo.mustUseProperty) {
  34536. var propertyName = propertyInfo.propertyName;
  34537. return node[propertyName];
  34538. } else {
  34539. if (!disableJavaScriptURLs && propertyInfo.sanitizeURL) {
  34540. // If we haven't fully disabled javascript: URLs, and if
  34541. // the hydration is successful of a javascript: URL, we
  34542. // still want to warn on the client.
  34543. sanitizeURL('' + expected);
  34544. }
  34545. var attributeName = propertyInfo.attributeName;
  34546. var stringValue = null;
  34547. if (propertyInfo.type === OVERLOADED_BOOLEAN) {
  34548. if (node.hasAttribute(attributeName)) {
  34549. var value = node.getAttribute(attributeName);
  34550. if (value === '') {
  34551. return true;
  34552. }
  34553. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  34554. return value;
  34555. }
  34556. if (value === '' + expected) {
  34557. return expected;
  34558. }
  34559. return value;
  34560. }
  34561. } else if (node.hasAttribute(attributeName)) {
  34562. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  34563. // We had an attribute but shouldn't have had one, so read it
  34564. // for the error message.
  34565. return node.getAttribute(attributeName);
  34566. }
  34567. if (propertyInfo.type === BOOLEAN) {
  34568. // If this was a boolean, it doesn't matter what the value is
  34569. // the fact that we have it is the same as the expected.
  34570. return expected;
  34571. } // Even if this property uses a namespace we use getAttribute
  34572. // because we assume its namespaced name is the same as our config.
  34573. // To use getAttributeNS we need the local name which we don't have
  34574. // in our config atm.
  34575. stringValue = node.getAttribute(attributeName);
  34576. }
  34577. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  34578. return stringValue === null ? expected : stringValue;
  34579. } else if (stringValue === '' + expected) {
  34580. return expected;
  34581. } else {
  34582. return stringValue;
  34583. }
  34584. }
  34585. }
  34586. }
  34587. /**
  34588. * Get the value for a attribute on a node. Only used in DEV for SSR validation.
  34589. * The third argument is used as a hint of what the expected value is. Some
  34590. * attributes have multiple equivalent values.
  34591. */
  34592. function getValueForAttribute(node, name, expected) {
  34593. {
  34594. if (!isAttributeNameSafe(name)) {
  34595. return;
  34596. }
  34597. if (!node.hasAttribute(name)) {
  34598. return expected === undefined ? undefined : null;
  34599. }
  34600. var value = node.getAttribute(name);
  34601. if (value === '' + expected) {
  34602. return expected;
  34603. }
  34604. return value;
  34605. }
  34606. }
  34607. /**
  34608. * Sets the value for a property on a node.
  34609. *
  34610. * @param {DOMElement} node
  34611. * @param {string} name
  34612. * @param {*} value
  34613. */
  34614. function setValueForProperty(node, name, value, isCustomComponentTag) {
  34615. var propertyInfo = getPropertyInfo(name);
  34616. if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) {
  34617. return;
  34618. }
  34619. if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) {
  34620. value = null;
  34621. } // If the prop isn't in the special list, treat it as a simple attribute.
  34622. if (isCustomComponentTag || propertyInfo === null) {
  34623. if (isAttributeNameSafe(name)) {
  34624. var _attributeName = name;
  34625. if (value === null) {
  34626. node.removeAttribute(_attributeName);
  34627. } else {
  34628. setAttribute(node, _attributeName, toStringOrTrustedType(value));
  34629. }
  34630. }
  34631. return;
  34632. }
  34633. var mustUseProperty = propertyInfo.mustUseProperty;
  34634. if (mustUseProperty) {
  34635. var propertyName = propertyInfo.propertyName;
  34636. if (value === null) {
  34637. var type = propertyInfo.type;
  34638. node[propertyName] = type === BOOLEAN ? false : '';
  34639. } else {
  34640. // Contrary to `setAttribute`, object properties are properly
  34641. // `toString`ed by IE8/9.
  34642. node[propertyName] = value;
  34643. }
  34644. return;
  34645. } // The rest are treated as attributes with special cases.
  34646. var attributeName = propertyInfo.attributeName,
  34647. attributeNamespace = propertyInfo.attributeNamespace;
  34648. if (value === null) {
  34649. node.removeAttribute(attributeName);
  34650. } else {
  34651. var _type = propertyInfo.type;
  34652. var attributeValue;
  34653. if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) {
  34654. // If attribute type is boolean, we know for sure it won't be an execution sink
  34655. // and we won't require Trusted Type here.
  34656. attributeValue = '';
  34657. } else {
  34658. // `setAttribute` with objects becomes only `[object]` in IE8/9,
  34659. // ('' + value) makes it output the correct toString()-value.
  34660. attributeValue = toStringOrTrustedType(value);
  34661. if (propertyInfo.sanitizeURL) {
  34662. sanitizeURL(attributeValue.toString());
  34663. }
  34664. }
  34665. if (attributeNamespace) {
  34666. setAttributeNS(node, attributeNamespace, attributeName, attributeValue);
  34667. } else {
  34668. setAttribute(node, attributeName, attributeValue);
  34669. }
  34670. }
  34671. }
  34672. var ReactDebugCurrentFrame$2 = null;
  34673. var ReactControlledValuePropTypes = {
  34674. checkPropTypes: null
  34675. };
  34676. {
  34677. ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame;
  34678. var hasReadOnlyValue = {
  34679. button: true,
  34680. checkbox: true,
  34681. image: true,
  34682. hidden: true,
  34683. radio: true,
  34684. reset: true,
  34685. submit: true
  34686. };
  34687. var propTypes = {
  34688. value: function (props, propName, componentName) {
  34689. if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) {
  34690. return null;
  34691. }
  34692. 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`.');
  34693. },
  34694. checked: function (props, propName, componentName) {
  34695. if (props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) {
  34696. return null;
  34697. }
  34698. 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`.');
  34699. }
  34700. };
  34701. /**
  34702. * Provide a linked `value` attribute for controlled forms. You should not use
  34703. * this outside of the ReactDOM controlled form components.
  34704. */
  34705. ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) {
  34706. checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$2.getStackAddendum);
  34707. };
  34708. }
  34709. function isCheckable(elem) {
  34710. var type = elem.type;
  34711. var nodeName = elem.nodeName;
  34712. return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio');
  34713. }
  34714. function getTracker(node) {
  34715. return node._valueTracker;
  34716. }
  34717. function detachTracker(node) {
  34718. node._valueTracker = null;
  34719. }
  34720. function getValueFromNode(node) {
  34721. var value = '';
  34722. if (!node) {
  34723. return value;
  34724. }
  34725. if (isCheckable(node)) {
  34726. value = node.checked ? 'true' : 'false';
  34727. } else {
  34728. value = node.value;
  34729. }
  34730. return value;
  34731. }
  34732. function trackValueOnNode(node) {
  34733. var valueField = isCheckable(node) ? 'checked' : 'value';
  34734. var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField);
  34735. var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail
  34736. // and don't track value will cause over reporting of changes,
  34737. // but it's better then a hard failure
  34738. // (needed for certain tests that spyOn input values and Safari)
  34739. if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') {
  34740. return;
  34741. }
  34742. var get = descriptor.get,
  34743. set = descriptor.set;
  34744. Object.defineProperty(node, valueField, {
  34745. configurable: true,
  34746. get: function () {
  34747. return get.call(this);
  34748. },
  34749. set: function (value) {
  34750. currentValue = '' + value;
  34751. set.call(this, value);
  34752. }
  34753. }); // We could've passed this the first time
  34754. // but it triggers a bug in IE11 and Edge 14/15.
  34755. // Calling defineProperty() again should be equivalent.
  34756. // https://github.com/facebook/react/issues/11768
  34757. Object.defineProperty(node, valueField, {
  34758. enumerable: descriptor.enumerable
  34759. });
  34760. var tracker = {
  34761. getValue: function () {
  34762. return currentValue;
  34763. },
  34764. setValue: function (value) {
  34765. currentValue = '' + value;
  34766. },
  34767. stopTracking: function () {
  34768. detachTracker(node);
  34769. delete node[valueField];
  34770. }
  34771. };
  34772. return tracker;
  34773. }
  34774. function track(node) {
  34775. if (getTracker(node)) {
  34776. return;
  34777. } // TODO: Once it's just Fiber we can move this to node._wrapperState
  34778. node._valueTracker = trackValueOnNode(node);
  34779. }
  34780. function updateValueIfChanged(node) {
  34781. if (!node) {
  34782. return false;
  34783. }
  34784. var tracker = getTracker(node); // if there is no tracker at this point it's unlikely
  34785. // that trying again will succeed
  34786. if (!tracker) {
  34787. return true;
  34788. }
  34789. var lastValue = tracker.getValue();
  34790. var nextValue = getValueFromNode(node);
  34791. if (nextValue !== lastValue) {
  34792. tracker.setValue(nextValue);
  34793. return true;
  34794. }
  34795. return false;
  34796. }
  34797. // TODO: direct imports like some-package/src/* are bad. Fix me.
  34798. var didWarnValueDefaultValue = false;
  34799. var didWarnCheckedDefaultChecked = false;
  34800. var didWarnControlledToUncontrolled = false;
  34801. var didWarnUncontrolledToControlled = false;
  34802. function isControlled(props) {
  34803. var usesChecked = props.type === 'checkbox' || props.type === 'radio';
  34804. return usesChecked ? props.checked != null : props.value != null;
  34805. }
  34806. /**
  34807. * Implements an <input> host component that allows setting these optional
  34808. * props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
  34809. *
  34810. * If `checked` or `value` are not supplied (or null/undefined), user actions
  34811. * that affect the checked state or value will trigger updates to the element.
  34812. *
  34813. * If they are supplied (and not null/undefined), the rendered element will not
  34814. * trigger updates to the element. Instead, the props must change in order for
  34815. * the rendered element to be updated.
  34816. *
  34817. * The rendered element will be initialized as unchecked (or `defaultChecked`)
  34818. * with an empty value (or `defaultValue`).
  34819. *
  34820. * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
  34821. */
  34822. function getHostProps(element, props) {
  34823. var node = element;
  34824. var checked = props.checked;
  34825. var hostProps = _assign({}, props, {
  34826. defaultChecked: undefined,
  34827. defaultValue: undefined,
  34828. value: undefined,
  34829. checked: checked != null ? checked : node._wrapperState.initialChecked
  34830. });
  34831. return hostProps;
  34832. }
  34833. function initWrapperState(element, props) {
  34834. {
  34835. ReactControlledValuePropTypes.checkPropTypes('input', props);
  34836. if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) {
  34837. warning$1(false, '%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);
  34838. didWarnCheckedDefaultChecked = true;
  34839. }
  34840. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
  34841. warning$1(false, '%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);
  34842. didWarnValueDefaultValue = true;
  34843. }
  34844. }
  34845. var node = element;
  34846. var defaultValue = props.defaultValue == null ? '' : props.defaultValue;
  34847. node._wrapperState = {
  34848. initialChecked: props.checked != null ? props.checked : props.defaultChecked,
  34849. initialValue: getToStringValue(props.value != null ? props.value : defaultValue),
  34850. controlled: isControlled(props)
  34851. };
  34852. }
  34853. function updateChecked(element, props) {
  34854. var node = element;
  34855. var checked = props.checked;
  34856. if (checked != null) {
  34857. setValueForProperty(node, 'checked', checked, false);
  34858. }
  34859. }
  34860. function updateWrapper(element, props) {
  34861. var node = element;
  34862. {
  34863. var controlled = isControlled(props);
  34864. if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) {
  34865. warning$1(false, '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);
  34866. didWarnUncontrolledToControlled = true;
  34867. }
  34868. if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) {
  34869. warning$1(false, '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);
  34870. didWarnControlledToUncontrolled = true;
  34871. }
  34872. }
  34873. updateChecked(element, props);
  34874. var value = getToStringValue(props.value);
  34875. var type = props.type;
  34876. if (value != null) {
  34877. if (type === 'number') {
  34878. if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible.
  34879. // eslint-disable-next-line
  34880. node.value != value) {
  34881. node.value = toString(value);
  34882. }
  34883. } else if (node.value !== toString(value)) {
  34884. node.value = toString(value);
  34885. }
  34886. } else if (type === 'submit' || type === 'reset') {
  34887. // Submit/reset inputs need the attribute removed completely to avoid
  34888. // blank-text buttons.
  34889. node.removeAttribute('value');
  34890. return;
  34891. }
  34892. if (disableInputAttributeSyncing) {
  34893. // When not syncing the value attribute, React only assigns a new value
  34894. // whenever the defaultValue React prop has changed. When not present,
  34895. // React does nothing
  34896. if (props.hasOwnProperty('defaultValue')) {
  34897. setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
  34898. }
  34899. } else {
  34900. // When syncing the value attribute, the value comes from a cascade of
  34901. // properties:
  34902. // 1. The value React property
  34903. // 2. The defaultValue React property
  34904. // 3. Otherwise there should be no change
  34905. if (props.hasOwnProperty('value')) {
  34906. setDefaultValue(node, props.type, value);
  34907. } else if (props.hasOwnProperty('defaultValue')) {
  34908. setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
  34909. }
  34910. }
  34911. if (disableInputAttributeSyncing) {
  34912. // When not syncing the checked attribute, the attribute is directly
  34913. // controllable from the defaultValue React property. It needs to be
  34914. // updated as new props come in.
  34915. if (props.defaultChecked == null) {
  34916. node.removeAttribute('checked');
  34917. } else {
  34918. node.defaultChecked = !!props.defaultChecked;
  34919. }
  34920. } else {
  34921. // When syncing the checked attribute, it only changes when it needs
  34922. // to be removed, such as transitioning from a checkbox into a text input
  34923. if (props.checked == null && props.defaultChecked != null) {
  34924. node.defaultChecked = !!props.defaultChecked;
  34925. }
  34926. }
  34927. }
  34928. function postMountWrapper(element, props, isHydrating) {
  34929. var node = element; // Do not assign value if it is already set. This prevents user text input
  34930. // from being lost during SSR hydration.
  34931. if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) {
  34932. var type = props.type;
  34933. var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the
  34934. // default value provided by the browser. See: #12872
  34935. if (isButton && (props.value === undefined || props.value === null)) {
  34936. return;
  34937. }
  34938. var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input
  34939. // from being lost during SSR hydration.
  34940. if (!isHydrating) {
  34941. if (disableInputAttributeSyncing) {
  34942. var value = getToStringValue(props.value); // When not syncing the value attribute, the value property points
  34943. // directly to the React prop. Only assign it if it exists.
  34944. if (value != null) {
  34945. // Always assign on buttons so that it is possible to assign an
  34946. // empty string to clear button text.
  34947. //
  34948. // Otherwise, do not re-assign the value property if is empty. This
  34949. // potentially avoids a DOM write and prevents Firefox (~60.0.1) from
  34950. // prematurely marking required inputs as invalid. Equality is compared
  34951. // to the current value in case the browser provided value is not an
  34952. // empty string.
  34953. if (isButton || value !== node.value) {
  34954. node.value = toString(value);
  34955. }
  34956. }
  34957. } else {
  34958. // When syncing the value attribute, the value property should use
  34959. // the wrapperState._initialValue property. This uses:
  34960. //
  34961. // 1. The value React property when present
  34962. // 2. The defaultValue React property when present
  34963. // 3. An empty string
  34964. if (initialValue !== node.value) {
  34965. node.value = initialValue;
  34966. }
  34967. }
  34968. }
  34969. if (disableInputAttributeSyncing) {
  34970. // When not syncing the value attribute, assign the value attribute
  34971. // directly from the defaultValue React property (when present)
  34972. var defaultValue = getToStringValue(props.defaultValue);
  34973. if (defaultValue != null) {
  34974. node.defaultValue = toString(defaultValue);
  34975. }
  34976. } else {
  34977. // Otherwise, the value attribute is synchronized to the property,
  34978. // so we assign defaultValue to the same thing as the value property
  34979. // assignment step above.
  34980. node.defaultValue = initialValue;
  34981. }
  34982. } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
  34983. // this is needed to work around a chrome bug where setting defaultChecked
  34984. // will sometimes influence the value of checked (even after detachment).
  34985. // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416
  34986. // We need to temporarily unset name to avoid disrupting radio button groups.
  34987. var name = node.name;
  34988. if (name !== '') {
  34989. node.name = '';
  34990. }
  34991. if (disableInputAttributeSyncing) {
  34992. // When not syncing the checked attribute, the checked property
  34993. // never gets assigned. It must be manually set. We don't want
  34994. // to do this when hydrating so that existing user input isn't
  34995. // modified
  34996. if (!isHydrating) {
  34997. updateChecked(element, props);
  34998. } // Only assign the checked attribute if it is defined. This saves
  34999. // a DOM write when controlling the checked attribute isn't needed
  35000. // (text inputs, submit/reset)
  35001. if (props.hasOwnProperty('defaultChecked')) {
  35002. node.defaultChecked = !node.defaultChecked;
  35003. node.defaultChecked = !!props.defaultChecked;
  35004. }
  35005. } else {
  35006. // When syncing the checked attribute, both the checked property and
  35007. // attribute are assigned at the same time using defaultChecked. This uses:
  35008. //
  35009. // 1. The checked React property when present
  35010. // 2. The defaultChecked React property when present
  35011. // 3. Otherwise, false
  35012. node.defaultChecked = !node.defaultChecked;
  35013. node.defaultChecked = !!node._wrapperState.initialChecked;
  35014. }
  35015. if (name !== '') {
  35016. node.name = name;
  35017. }
  35018. }
  35019. function restoreControlledState$1(element, props) {
  35020. var node = element;
  35021. updateWrapper(node, props);
  35022. updateNamedCousins(node, props);
  35023. }
  35024. function updateNamedCousins(rootNode, props) {
  35025. var name = props.name;
  35026. if (props.type === 'radio' && name != null) {
  35027. var queryRoot = rootNode;
  35028. while (queryRoot.parentNode) {
  35029. queryRoot = queryRoot.parentNode;
  35030. } // If `rootNode.form` was non-null, then we could try `form.elements`,
  35031. // but that sometimes behaves strangely in IE8. We could also try using
  35032. // `form.getElementsByName`, but that will only return direct children
  35033. // and won't include inputs that use the HTML5 `form=` attribute. Since
  35034. // the input might not even be in a form. It might not even be in the
  35035. // document. Let's just use the local `querySelectorAll` to ensure we don't
  35036. // miss anything.
  35037. var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
  35038. for (var i = 0; i < group.length; i++) {
  35039. var otherNode = group[i];
  35040. if (otherNode === rootNode || otherNode.form !== rootNode.form) {
  35041. continue;
  35042. } // This will throw if radio buttons rendered by different copies of React
  35043. // and the same name are rendered into the same form (same as #1939).
  35044. // That's probably okay; we don't support it just as we don't support
  35045. // mixing React radio buttons with non-React ones.
  35046. var otherProps = getFiberCurrentPropsFromNode$1(otherNode);
  35047. (function () {
  35048. if (!otherProps) {
  35049. {
  35050. throw ReactError(Error("ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported."));
  35051. }
  35052. }
  35053. })(); // We need update the tracked value on the named cousin since the value
  35054. // was changed but the input saw no event or value set
  35055. updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that
  35056. // was previously checked to update will cause it to be come re-checked
  35057. // as appropriate.
  35058. updateWrapper(otherNode, otherProps);
  35059. }
  35060. }
  35061. } // In Chrome, assigning defaultValue to certain input types triggers input validation.
  35062. // For number inputs, the display value loses trailing decimal points. For email inputs,
  35063. // Chrome raises "The specified value <x> is not a valid email address".
  35064. //
  35065. // Here we check to see if the defaultValue has actually changed, avoiding these problems
  35066. // when the user is inputting text
  35067. //
  35068. // https://github.com/facebook/react/issues/7253
  35069. function setDefaultValue(node, type, value) {
  35070. if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js
  35071. type !== 'number' || node.ownerDocument.activeElement !== node) {
  35072. if (value == null) {
  35073. node.defaultValue = toString(node._wrapperState.initialValue);
  35074. } else if (node.defaultValue !== toString(value)) {
  35075. node.defaultValue = toString(value);
  35076. }
  35077. }
  35078. }
  35079. var didWarnSelectedSetOnOption = false;
  35080. var didWarnInvalidChild = false;
  35081. function flattenChildren(children) {
  35082. var content = ''; // Flatten children. We'll warn if they are invalid
  35083. // during validateProps() which runs for hydration too.
  35084. // Note that this would throw on non-element objects.
  35085. // Elements are stringified (which is normally irrelevant
  35086. // but matters for <fbt>).
  35087. React.Children.forEach(children, function (child) {
  35088. if (child == null) {
  35089. return;
  35090. }
  35091. content += child; // Note: we don't warn about invalid children here.
  35092. // Instead, this is done separately below so that
  35093. // it happens during the hydration codepath too.
  35094. });
  35095. return content;
  35096. }
  35097. /**
  35098. * Implements an <option> host component that warns when `selected` is set.
  35099. */
  35100. function validateProps(element, props) {
  35101. {
  35102. // This mirrors the codepath above, but runs for hydration too.
  35103. // Warn about invalid children here so that client and hydration are consistent.
  35104. // TODO: this seems like it could cause a DEV-only throw for hydration
  35105. // if children contains a non-element object. We should try to avoid that.
  35106. if (typeof props.children === 'object' && props.children !== null) {
  35107. React.Children.forEach(props.children, function (child) {
  35108. if (child == null) {
  35109. return;
  35110. }
  35111. if (typeof child === 'string' || typeof child === 'number') {
  35112. return;
  35113. }
  35114. if (typeof child.type !== 'string') {
  35115. return;
  35116. }
  35117. if (!didWarnInvalidChild) {
  35118. didWarnInvalidChild = true;
  35119. warning$1(false, 'Only strings and numbers are supported as <option> children.');
  35120. }
  35121. });
  35122. } // TODO: Remove support for `selected` in <option>.
  35123. if (props.selected != null && !didWarnSelectedSetOnOption) {
  35124. warning$1(false, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.');
  35125. didWarnSelectedSetOnOption = true;
  35126. }
  35127. }
  35128. }
  35129. function postMountWrapper$1(element, props) {
  35130. // value="" should make a value attribute (#6219)
  35131. if (props.value != null) {
  35132. element.setAttribute('value', toString(getToStringValue(props.value)));
  35133. }
  35134. }
  35135. function getHostProps$1(element, props) {
  35136. var hostProps = _assign({
  35137. children: undefined
  35138. }, props);
  35139. var content = flattenChildren(props.children);
  35140. if (content) {
  35141. hostProps.children = content;
  35142. }
  35143. return hostProps;
  35144. }
  35145. // TODO: direct imports like some-package/src/* are bad. Fix me.
  35146. var didWarnValueDefaultValue$1;
  35147. {
  35148. didWarnValueDefaultValue$1 = false;
  35149. }
  35150. function getDeclarationErrorAddendum() {
  35151. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  35152. if (ownerName) {
  35153. return '\n\nCheck the render method of `' + ownerName + '`.';
  35154. }
  35155. return '';
  35156. }
  35157. var valuePropNames = ['value', 'defaultValue'];
  35158. /**
  35159. * Validation function for `value` and `defaultValue`.
  35160. */
  35161. function checkSelectPropTypes(props) {
  35162. ReactControlledValuePropTypes.checkPropTypes('select', props);
  35163. for (var i = 0; i < valuePropNames.length; i++) {
  35164. var propName = valuePropNames[i];
  35165. if (props[propName] == null) {
  35166. continue;
  35167. }
  35168. var isArray = Array.isArray(props[propName]);
  35169. if (props.multiple && !isArray) {
  35170. warning$1(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum());
  35171. } else if (!props.multiple && isArray) {
  35172. warning$1(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum());
  35173. }
  35174. }
  35175. }
  35176. function updateOptions(node, multiple, propValue, setDefaultSelected) {
  35177. var options = node.options;
  35178. if (multiple) {
  35179. var selectedValues = propValue;
  35180. var selectedValue = {};
  35181. for (var i = 0; i < selectedValues.length; i++) {
  35182. // Prefix to avoid chaos with special keys.
  35183. selectedValue['$' + selectedValues[i]] = true;
  35184. }
  35185. for (var _i = 0; _i < options.length; _i++) {
  35186. var selected = selectedValue.hasOwnProperty('$' + options[_i].value);
  35187. if (options[_i].selected !== selected) {
  35188. options[_i].selected = selected;
  35189. }
  35190. if (selected && setDefaultSelected) {
  35191. options[_i].defaultSelected = true;
  35192. }
  35193. }
  35194. } else {
  35195. // Do not set `select.value` as exact behavior isn't consistent across all
  35196. // browsers for all cases.
  35197. var _selectedValue = toString(getToStringValue(propValue));
  35198. var defaultSelected = null;
  35199. for (var _i2 = 0; _i2 < options.length; _i2++) {
  35200. if (options[_i2].value === _selectedValue) {
  35201. options[_i2].selected = true;
  35202. if (setDefaultSelected) {
  35203. options[_i2].defaultSelected = true;
  35204. }
  35205. return;
  35206. }
  35207. if (defaultSelected === null && !options[_i2].disabled) {
  35208. defaultSelected = options[_i2];
  35209. }
  35210. }
  35211. if (defaultSelected !== null) {
  35212. defaultSelected.selected = true;
  35213. }
  35214. }
  35215. }
  35216. /**
  35217. * Implements a <select> host component that allows optionally setting the
  35218. * props `value` and `defaultValue`. If `multiple` is false, the prop must be a
  35219. * stringable. If `multiple` is true, the prop must be an array of stringables.
  35220. *
  35221. * If `value` is not supplied (or null/undefined), user actions that change the
  35222. * selected option will trigger updates to the rendered options.
  35223. *
  35224. * If it is supplied (and not null/undefined), the rendered options will not
  35225. * update in response to user actions. Instead, the `value` prop must change in
  35226. * order for the rendered options to update.
  35227. *
  35228. * If `defaultValue` is provided, any options with the supplied values will be
  35229. * selected.
  35230. */
  35231. function getHostProps$2(element, props) {
  35232. return _assign({}, props, {
  35233. value: undefined
  35234. });
  35235. }
  35236. function initWrapperState$1(element, props) {
  35237. var node = element;
  35238. {
  35239. checkSelectPropTypes(props);
  35240. }
  35241. node._wrapperState = {
  35242. wasMultiple: !!props.multiple
  35243. };
  35244. {
  35245. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) {
  35246. warning$1(false, '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');
  35247. didWarnValueDefaultValue$1 = true;
  35248. }
  35249. }
  35250. }
  35251. function postMountWrapper$2(element, props) {
  35252. var node = element;
  35253. node.multiple = !!props.multiple;
  35254. var value = props.value;
  35255. if (value != null) {
  35256. updateOptions(node, !!props.multiple, value, false);
  35257. } else if (props.defaultValue != null) {
  35258. updateOptions(node, !!props.multiple, props.defaultValue, true);
  35259. }
  35260. }
  35261. function postUpdateWrapper(element, props) {
  35262. var node = element;
  35263. var wasMultiple = node._wrapperState.wasMultiple;
  35264. node._wrapperState.wasMultiple = !!props.multiple;
  35265. var value = props.value;
  35266. if (value != null) {
  35267. updateOptions(node, !!props.multiple, value, false);
  35268. } else if (wasMultiple !== !!props.multiple) {
  35269. // For simplicity, reapply `defaultValue` if `multiple` is toggled.
  35270. if (props.defaultValue != null) {
  35271. updateOptions(node, !!props.multiple, props.defaultValue, true);
  35272. } else {
  35273. // Revert the select back to its default unselected state.
  35274. updateOptions(node, !!props.multiple, props.multiple ? [] : '', false);
  35275. }
  35276. }
  35277. }
  35278. function restoreControlledState$2(element, props) {
  35279. var node = element;
  35280. var value = props.value;
  35281. if (value != null) {
  35282. updateOptions(node, !!props.multiple, value, false);
  35283. }
  35284. }
  35285. var didWarnValDefaultVal = false;
  35286. /**
  35287. * Implements a <textarea> host component that allows setting `value`, and
  35288. * `defaultValue`. This differs from the traditional DOM API because value is
  35289. * usually set as PCDATA children.
  35290. *
  35291. * If `value` is not supplied (or null/undefined), user actions that affect the
  35292. * value will trigger updates to the element.
  35293. *
  35294. * If `value` is supplied (and not null/undefined), the rendered element will
  35295. * not trigger updates to the element. Instead, the `value` prop must change in
  35296. * order for the rendered element to be updated.
  35297. *
  35298. * The rendered element will be initialized with an empty value, the prop
  35299. * `defaultValue` if specified, or the children content (deprecated).
  35300. */
  35301. function getHostProps$3(element, props) {
  35302. var node = element;
  35303. (function () {
  35304. if (!(props.dangerouslySetInnerHTML == null)) {
  35305. {
  35306. throw ReactError(Error("`dangerouslySetInnerHTML` does not make sense on <textarea>."));
  35307. }
  35308. }
  35309. })(); // Always set children to the same thing. In IE9, the selection range will
  35310. // get reset if `textContent` is mutated. We could add a check in setTextContent
  35311. // to only set the value if/when the value differs from the node value (which would
  35312. // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this
  35313. // solution. The value can be a boolean or object so that's why it's forced
  35314. // to be a string.
  35315. var hostProps = _assign({}, props, {
  35316. value: undefined,
  35317. defaultValue: undefined,
  35318. children: toString(node._wrapperState.initialValue)
  35319. });
  35320. return hostProps;
  35321. }
  35322. function initWrapperState$2(element, props) {
  35323. var node = element;
  35324. {
  35325. ReactControlledValuePropTypes.checkPropTypes('textarea', props);
  35326. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
  35327. warning$1(false, '%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');
  35328. didWarnValDefaultVal = true;
  35329. }
  35330. }
  35331. var initialValue = props.value; // Only bother fetching default value if we're going to use it
  35332. if (initialValue == null) {
  35333. var defaultValue = props.defaultValue; // TODO (yungsters): Remove support for children content in <textarea>.
  35334. var children = props.children;
  35335. if (children != null) {
  35336. {
  35337. warning$1(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
  35338. }
  35339. (function () {
  35340. if (!(defaultValue == null)) {
  35341. {
  35342. throw ReactError(Error("If you supply `defaultValue` on a <textarea>, do not pass children."));
  35343. }
  35344. }
  35345. })();
  35346. if (Array.isArray(children)) {
  35347. (function () {
  35348. if (!(children.length <= 1)) {
  35349. {
  35350. throw ReactError(Error("<textarea> can only have at most one child."));
  35351. }
  35352. }
  35353. })();
  35354. children = children[0];
  35355. }
  35356. defaultValue = children;
  35357. }
  35358. if (defaultValue == null) {
  35359. defaultValue = '';
  35360. }
  35361. initialValue = defaultValue;
  35362. }
  35363. node._wrapperState = {
  35364. initialValue: getToStringValue(initialValue)
  35365. };
  35366. }
  35367. function updateWrapper$1(element, props) {
  35368. var node = element;
  35369. var value = getToStringValue(props.value);
  35370. var defaultValue = getToStringValue(props.defaultValue);
  35371. if (value != null) {
  35372. // Cast `value` to a string to ensure the value is set correctly. While
  35373. // browsers typically do this as necessary, jsdom doesn't.
  35374. var newValue = toString(value); // To avoid side effects (such as losing text selection), only set value if changed
  35375. if (newValue !== node.value) {
  35376. node.value = newValue;
  35377. }
  35378. if (props.defaultValue == null && node.defaultValue !== newValue) {
  35379. node.defaultValue = newValue;
  35380. }
  35381. }
  35382. if (defaultValue != null) {
  35383. node.defaultValue = toString(defaultValue);
  35384. }
  35385. }
  35386. function postMountWrapper$3(element, props) {
  35387. var node = element; // This is in postMount because we need access to the DOM node, which is not
  35388. // available until after the component has mounted.
  35389. var textContent = node.textContent; // Only set node.value if textContent is equal to the expected
  35390. // initial value. In IE10/IE11 there is a bug where the placeholder attribute
  35391. // will populate textContent as well.
  35392. // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/
  35393. if (textContent === node._wrapperState.initialValue) {
  35394. if (textContent !== '' && textContent !== null) {
  35395. node.value = textContent;
  35396. }
  35397. }
  35398. }
  35399. function restoreControlledState$3(element, props) {
  35400. // DOM component is still mounted; update
  35401. updateWrapper$1(element, props);
  35402. }
  35403. var HTML_NAMESPACE$1 = 'http://www.w3.org/1999/xhtml';
  35404. var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
  35405. var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  35406. var Namespaces = {
  35407. html: HTML_NAMESPACE$1,
  35408. mathml: MATH_NAMESPACE,
  35409. svg: SVG_NAMESPACE
  35410. }; // Assumes there is no parent namespace.
  35411. function getIntrinsicNamespace(type) {
  35412. switch (type) {
  35413. case 'svg':
  35414. return SVG_NAMESPACE;
  35415. case 'math':
  35416. return MATH_NAMESPACE;
  35417. default:
  35418. return HTML_NAMESPACE$1;
  35419. }
  35420. }
  35421. function getChildNamespace(parentNamespace, type) {
  35422. if (parentNamespace == null || parentNamespace === HTML_NAMESPACE$1) {
  35423. // No (or default) parent namespace: potential entry point.
  35424. return getIntrinsicNamespace(type);
  35425. }
  35426. if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') {
  35427. // We're leaving SVG.
  35428. return HTML_NAMESPACE$1;
  35429. } // By default, pass namespace below.
  35430. return parentNamespace;
  35431. }
  35432. /* globals MSApp */
  35433. /**
  35434. * Create a function which has 'unsafe' privileges (required by windows8 apps)
  35435. */
  35436. var createMicrosoftUnsafeLocalFunction = function (func) {
  35437. if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
  35438. return function (arg0, arg1, arg2, arg3) {
  35439. MSApp.execUnsafeLocalFunction(function () {
  35440. return func(arg0, arg1, arg2, arg3);
  35441. });
  35442. };
  35443. } else {
  35444. return func;
  35445. }
  35446. };
  35447. var reusableSVGContainer;
  35448. /**
  35449. * Set the innerHTML property of a node
  35450. *
  35451. * @param {DOMElement} node
  35452. * @param {string} html
  35453. * @internal
  35454. */
  35455. var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
  35456. if (node.namespaceURI === Namespaces.svg) {
  35457. {
  35458. if (enableTrustedTypesIntegration) {
  35459. // TODO: reconsider the text of this warning and when it should show
  35460. // before enabling the feature flag.
  35461. !(typeof trustedTypes === 'undefined') ? warning$1(false, "Using 'dangerouslySetInnerHTML' in an svg element with " + 'Trusted Types enabled in an Internet Explorer will cause ' + 'the trusted value to be converted to string. Assigning string ' + "to 'innerHTML' will throw an error if Trusted Types are enforced. " + "You can try to wrap your svg element inside a div and use 'dangerouslySetInnerHTML' " + 'on the enclosing div instead.') : void 0;
  35462. }
  35463. }
  35464. if (!('innerHTML' in node)) {
  35465. // IE does not have innerHTML for SVG nodes, so instead we inject the
  35466. // new markup in a temp node and then move the child nodes across into
  35467. // the target node
  35468. reusableSVGContainer = reusableSVGContainer || document.createElement('div');
  35469. reusableSVGContainer.innerHTML = '<svg>' + html.valueOf().toString() + '</svg>';
  35470. var svgNode = reusableSVGContainer.firstChild;
  35471. while (node.firstChild) {
  35472. node.removeChild(node.firstChild);
  35473. }
  35474. while (svgNode.firstChild) {
  35475. node.appendChild(svgNode.firstChild);
  35476. }
  35477. return;
  35478. }
  35479. }
  35480. node.innerHTML = html;
  35481. });
  35482. /**
  35483. * HTML nodeType values that represent the type of the node
  35484. */
  35485. var ELEMENT_NODE = 1;
  35486. var TEXT_NODE = 3;
  35487. var COMMENT_NODE = 8;
  35488. var DOCUMENT_NODE = 9;
  35489. var DOCUMENT_FRAGMENT_NODE = 11;
  35490. /**
  35491. * Set the textContent property of a node. For text updates, it's faster
  35492. * to set the `nodeValue` of the Text node directly instead of using
  35493. * `.textContent` which will remove the existing node and create a new one.
  35494. *
  35495. * @param {DOMElement} node
  35496. * @param {string} text
  35497. * @internal
  35498. */
  35499. var setTextContent = function (node, text) {
  35500. if (text) {
  35501. var firstChild = node.firstChild;
  35502. if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) {
  35503. firstChild.nodeValue = text;
  35504. return;
  35505. }
  35506. }
  35507. node.textContent = text;
  35508. };
  35509. // Do not use the below two methods directly!
  35510. // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
  35511. // (It is the only module that is allowed to access these methods.)
  35512. function unsafeCastStringToDOMTopLevelType(topLevelType) {
  35513. return topLevelType;
  35514. }
  35515. function unsafeCastDOMTopLevelTypeToString(topLevelType) {
  35516. return topLevelType;
  35517. }
  35518. /**
  35519. * Generate a mapping of standard vendor prefixes using the defined style property and event name.
  35520. *
  35521. * @param {string} styleProp
  35522. * @param {string} eventName
  35523. * @returns {object}
  35524. */
  35525. function makePrefixMap(styleProp, eventName) {
  35526. var prefixes = {};
  35527. prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
  35528. prefixes['Webkit' + styleProp] = 'webkit' + eventName;
  35529. prefixes['Moz' + styleProp] = 'moz' + eventName;
  35530. return prefixes;
  35531. }
  35532. /**
  35533. * A list of event names to a configurable list of vendor prefixes.
  35534. */
  35535. var vendorPrefixes = {
  35536. animationend: makePrefixMap('Animation', 'AnimationEnd'),
  35537. animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
  35538. animationstart: makePrefixMap('Animation', 'AnimationStart'),
  35539. transitionend: makePrefixMap('Transition', 'TransitionEnd')
  35540. };
  35541. /**
  35542. * Event names that have already been detected and prefixed (if applicable).
  35543. */
  35544. var prefixedEventNames = {};
  35545. /**
  35546. * Element to check for prefixes on.
  35547. */
  35548. var style = {};
  35549. /**
  35550. * Bootstrap if a DOM exists.
  35551. */
  35552. if (canUseDOM) {
  35553. style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x,
  35554. // the un-prefixed "animation" and "transition" properties are defined on the
  35555. // style object but the events that fire will still be prefixed, so we need
  35556. // to check if the un-prefixed events are usable, and if not remove them from the map.
  35557. if (!('AnimationEvent' in window)) {
  35558. delete vendorPrefixes.animationend.animation;
  35559. delete vendorPrefixes.animationiteration.animation;
  35560. delete vendorPrefixes.animationstart.animation;
  35561. } // Same as above
  35562. if (!('TransitionEvent' in window)) {
  35563. delete vendorPrefixes.transitionend.transition;
  35564. }
  35565. }
  35566. /**
  35567. * Attempts to determine the correct vendor prefixed event name.
  35568. *
  35569. * @param {string} eventName
  35570. * @returns {string}
  35571. */
  35572. function getVendorPrefixedEventName(eventName) {
  35573. if (prefixedEventNames[eventName]) {
  35574. return prefixedEventNames[eventName];
  35575. } else if (!vendorPrefixes[eventName]) {
  35576. return eventName;
  35577. }
  35578. var prefixMap = vendorPrefixes[eventName];
  35579. for (var styleProp in prefixMap) {
  35580. if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
  35581. return prefixedEventNames[eventName] = prefixMap[styleProp];
  35582. }
  35583. }
  35584. return eventName;
  35585. }
  35586. /**
  35587. * To identify top level events in ReactDOM, we use constants defined by this
  35588. * module. This is the only module that uses the unsafe* methods to express
  35589. * that the constants actually correspond to the browser event names. This lets
  35590. * us save some bundle size by avoiding a top level type -> event name map.
  35591. * The rest of ReactDOM code should import top level types from this file.
  35592. */
  35593. var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
  35594. var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
  35595. var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
  35596. var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
  35597. var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
  35598. var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
  35599. var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
  35600. var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
  35601. var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
  35602. var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
  35603. var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
  35604. var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
  35605. var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
  35606. var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
  35607. var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
  35608. var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
  35609. var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
  35610. var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
  35611. var TOP_AUX_CLICK = unsafeCastStringToDOMTopLevelType('auxclick');
  35612. var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
  35613. var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
  35614. var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
  35615. var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
  35616. var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
  35617. var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
  35618. var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
  35619. var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
  35620. var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
  35621. var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
  35622. var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
  35623. var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
  35624. var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
  35625. var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
  35626. var TOP_GOT_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('gotpointercapture');
  35627. var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
  35628. var TOP_INVALID = unsafeCastStringToDOMTopLevelType('invalid');
  35629. var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
  35630. var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
  35631. var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
  35632. var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
  35633. var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
  35634. var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
  35635. var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
  35636. var TOP_LOST_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('lostpointercapture');
  35637. var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
  35638. var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
  35639. var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
  35640. var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
  35641. var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
  35642. var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
  35643. var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
  35644. var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
  35645. var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
  35646. var TOP_POINTER_CANCEL = unsafeCastStringToDOMTopLevelType('pointercancel');
  35647. var TOP_POINTER_DOWN = unsafeCastStringToDOMTopLevelType('pointerdown');
  35648. var TOP_POINTER_MOVE = unsafeCastStringToDOMTopLevelType('pointermove');
  35649. var TOP_POINTER_OUT = unsafeCastStringToDOMTopLevelType('pointerout');
  35650. var TOP_POINTER_OVER = unsafeCastStringToDOMTopLevelType('pointerover');
  35651. var TOP_POINTER_UP = unsafeCastStringToDOMTopLevelType('pointerup');
  35652. var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
  35653. var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
  35654. var TOP_RESET = unsafeCastStringToDOMTopLevelType('reset');
  35655. var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
  35656. var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
  35657. var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
  35658. var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
  35659. var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
  35660. var TOP_SUBMIT = unsafeCastStringToDOMTopLevelType('submit');
  35661. var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
  35662. var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
  35663. var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
  35664. var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
  35665. var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
  35666. var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
  35667. var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
  35668. var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
  35669. var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
  35670. var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
  35671. var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
  35672. var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel'); // List of events that need to be individually attached to media elements.
  35673. // Note that events in this list will *not* be listened to at the top level
  35674. // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
  35675. 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];
  35676. function getRawEventName(topLevelType) {
  35677. return unsafeCastDOMTopLevelTypeToString(topLevelType);
  35678. }
  35679. var attemptSynchronousHydration;
  35680. function setAttemptSynchronousHydration(fn) {
  35681. attemptSynchronousHydration = fn;
  35682. } // TODO: Upgrade this definition once we're on a newer version of Flow that
  35683. // has this definition built-in.
  35684. var hasScheduledReplayAttempt = false; // The queue of discrete events to be replayed.
  35685. var queuedDiscreteEvents = []; // Indicates if any continuous event targets are non-null for early bailout.
  35686. // if the last target was dehydrated.
  35687. var queuedFocus = null;
  35688. var queuedDrag = null;
  35689. var queuedMouse = null; // For pointer events there can be one latest event per pointerId.
  35690. var queuedPointers = new Map();
  35691. var queuedPointerCaptures = new Map(); // We could consider replaying selectionchange and touchmoves too.
  35692. function hasQueuedDiscreteEvents() {
  35693. return queuedDiscreteEvents.length > 0;
  35694. }
  35695. 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];
  35696. 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];
  35697. function isReplayableDiscreteEvent(eventType) {
  35698. return discreteReplayableEvents.indexOf(eventType) > -1;
  35699. }
  35700. function trapReplayableEvent(topLevelType, document, listeningSet) {
  35701. listenToTopLevel(topLevelType, document, listeningSet);
  35702. if (enableFlareAPI) {
  35703. // Trap events for the responder system.
  35704. var passiveEventKey = unsafeCastDOMTopLevelTypeToString(topLevelType) + '_passive';
  35705. if (!listeningSet.has(passiveEventKey)) {
  35706. trapEventForResponderEventSystem(document, topLevelType, true);
  35707. listeningSet.add(passiveEventKey);
  35708. } // TODO: This listens to all events as active which might have
  35709. // undesirable effects. It's also unnecessary to have both
  35710. // passive and active listeners. Instead, we could start with
  35711. // a passive and upgrade it to an active one if needed.
  35712. // For replaying purposes the active is never needed since we
  35713. // currently don't preventDefault.
  35714. var activeEventKey = unsafeCastDOMTopLevelTypeToString(topLevelType) + '_active';
  35715. if (!listeningSet.has(activeEventKey)) {
  35716. trapEventForResponderEventSystem(document, topLevelType, false);
  35717. listeningSet.add(activeEventKey);
  35718. }
  35719. }
  35720. }
  35721. function eagerlyTrapReplayableEvents(document) {
  35722. var listeningSet = getListeningSetForElement(document); // Discrete
  35723. discreteReplayableEvents.forEach(function (topLevelType) {
  35724. trapReplayableEvent(topLevelType, document, listeningSet);
  35725. }); // Continuous
  35726. continuousReplayableEvents.forEach(function (topLevelType) {
  35727. trapReplayableEvent(topLevelType, document, listeningSet);
  35728. });
  35729. }
  35730. function createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent) {
  35731. return {
  35732. blockedOn: blockedOn,
  35733. topLevelType: topLevelType,
  35734. eventSystemFlags: eventSystemFlags | IS_REPLAYED,
  35735. nativeEvent: nativeEvent
  35736. };
  35737. }
  35738. function queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent) {
  35739. var queuedEvent = createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent);
  35740. queuedDiscreteEvents.push(queuedEvent);
  35741. if (enableSelectiveHydration) {
  35742. if (queuedDiscreteEvents.length === 1) {
  35743. // If this was the first discrete event, we might be able to
  35744. // synchronously unblock it so that preventDefault still works.
  35745. while (queuedEvent.blockedOn !== null) {
  35746. var _fiber = getInstanceFromNode$1(queuedEvent.blockedOn);
  35747. if (_fiber === null) {
  35748. break;
  35749. }
  35750. attemptSynchronousHydration(_fiber);
  35751. if (queuedEvent.blockedOn === null) {
  35752. // We got unblocked by hydration. Let's try again.
  35753. replayUnblockedEvents(); // If we're reblocked, on an inner boundary, we might need
  35754. // to attempt hydrating that one.
  35755. continue;
  35756. } else {
  35757. // We're still blocked from hydation, we have to give up
  35758. // and replay later.
  35759. break;
  35760. }
  35761. }
  35762. }
  35763. }
  35764. } // Resets the replaying for this type of continuous event to no event.
  35765. function clearIfContinuousEvent(topLevelType, nativeEvent) {
  35766. switch (topLevelType) {
  35767. case TOP_FOCUS:
  35768. case TOP_BLUR:
  35769. queuedFocus = null;
  35770. break;
  35771. case TOP_DRAG_ENTER:
  35772. case TOP_DRAG_LEAVE:
  35773. queuedDrag = null;
  35774. break;
  35775. case TOP_MOUSE_OVER:
  35776. case TOP_MOUSE_OUT:
  35777. queuedMouse = null;
  35778. break;
  35779. case TOP_POINTER_OVER:
  35780. case TOP_POINTER_OUT:
  35781. {
  35782. var pointerId = nativeEvent.pointerId;
  35783. queuedPointers.delete(pointerId);
  35784. break;
  35785. }
  35786. case TOP_GOT_POINTER_CAPTURE:
  35787. case TOP_LOST_POINTER_CAPTURE:
  35788. {
  35789. var _pointerId = nativeEvent.pointerId;
  35790. queuedPointerCaptures.delete(_pointerId);
  35791. break;
  35792. }
  35793. }
  35794. }
  35795. function accumulateOrCreateQueuedReplayableEvent(existingQueuedEvent, blockedOn, topLevelType, eventSystemFlags, nativeEvent) {
  35796. if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) {
  35797. return createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent);
  35798. } // If we have already queued this exact event, then it's because
  35799. // the different event systems have different DOM event listeners.
  35800. // We can accumulate the flags and store a single event to be
  35801. // replayed.
  35802. existingQueuedEvent.eventSystemFlags |= eventSystemFlags;
  35803. return existingQueuedEvent;
  35804. }
  35805. function queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent) {
  35806. // These set relatedTarget to null because the replayed event will be treated as if we
  35807. // moved from outside the window (no target) onto the target once it hydrates.
  35808. // Instead of mutating we could clone the event.
  35809. switch (topLevelType) {
  35810. case TOP_FOCUS:
  35811. {
  35812. var focusEvent = nativeEvent;
  35813. queuedFocus = accumulateOrCreateQueuedReplayableEvent(queuedFocus, blockedOn, topLevelType, eventSystemFlags, focusEvent);
  35814. return true;
  35815. }
  35816. case TOP_DRAG_ENTER:
  35817. {
  35818. var dragEvent = nativeEvent;
  35819. queuedDrag = accumulateOrCreateQueuedReplayableEvent(queuedDrag, blockedOn, topLevelType, eventSystemFlags, dragEvent);
  35820. return true;
  35821. }
  35822. case TOP_MOUSE_OVER:
  35823. {
  35824. var mouseEvent = nativeEvent;
  35825. queuedMouse = accumulateOrCreateQueuedReplayableEvent(queuedMouse, blockedOn, topLevelType, eventSystemFlags, mouseEvent);
  35826. return true;
  35827. }
  35828. case TOP_POINTER_OVER:
  35829. {
  35830. var pointerEvent = nativeEvent;
  35831. var pointerId = pointerEvent.pointerId;
  35832. queuedPointers.set(pointerId, accumulateOrCreateQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, topLevelType, eventSystemFlags, pointerEvent));
  35833. return true;
  35834. }
  35835. case TOP_GOT_POINTER_CAPTURE:
  35836. {
  35837. var _pointerEvent = nativeEvent;
  35838. var _pointerId2 = _pointerEvent.pointerId;
  35839. queuedPointerCaptures.set(_pointerId2, accumulateOrCreateQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, topLevelType, eventSystemFlags, _pointerEvent));
  35840. return true;
  35841. }
  35842. }
  35843. return false;
  35844. }
  35845. function attemptReplayQueuedEvent(queuedEvent) {
  35846. if (queuedEvent.blockedOn !== null) {
  35847. return false;
  35848. }
  35849. var nextBlockedOn = attemptToDispatchEvent(queuedEvent.topLevelType, queuedEvent.eventSystemFlags, queuedEvent.nativeEvent);
  35850. if (nextBlockedOn !== null) {
  35851. // We're still blocked. Try again later.
  35852. queuedEvent.blockedOn = nextBlockedOn;
  35853. return false;
  35854. }
  35855. return true;
  35856. }
  35857. function attemptReplayQueuedEventInMap(queuedEvent, key, map) {
  35858. if (attemptReplayQueuedEvent(queuedEvent)) {
  35859. map.delete(key);
  35860. }
  35861. }
  35862. function replayUnblockedEvents() {
  35863. hasScheduledReplayAttempt = false; // First replay discrete events.
  35864. while (queuedDiscreteEvents.length > 0) {
  35865. var nextDiscreteEvent = queuedDiscreteEvents[0];
  35866. if (nextDiscreteEvent.blockedOn !== null) {
  35867. // We're still blocked.
  35868. break;
  35869. }
  35870. var nextBlockedOn = attemptToDispatchEvent(nextDiscreteEvent.topLevelType, nextDiscreteEvent.eventSystemFlags, nextDiscreteEvent.nativeEvent);
  35871. if (nextBlockedOn !== null) {
  35872. // We're still blocked. Try again later.
  35873. nextDiscreteEvent.blockedOn = nextBlockedOn;
  35874. } else {
  35875. // We've successfully replayed the first event. Let's try the next one.
  35876. queuedDiscreteEvents.shift();
  35877. }
  35878. } // Next replay any continuous events.
  35879. if (queuedFocus !== null && attemptReplayQueuedEvent(queuedFocus)) {
  35880. queuedFocus = null;
  35881. }
  35882. if (queuedDrag !== null && attemptReplayQueuedEvent(queuedDrag)) {
  35883. queuedDrag = null;
  35884. }
  35885. if (queuedMouse !== null && attemptReplayQueuedEvent(queuedMouse)) {
  35886. queuedMouse = null;
  35887. }
  35888. queuedPointers.forEach(attemptReplayQueuedEventInMap);
  35889. queuedPointerCaptures.forEach(attemptReplayQueuedEventInMap);
  35890. }
  35891. function scheduleCallbackIfUnblocked(queuedEvent, unblocked) {
  35892. if (queuedEvent.blockedOn === unblocked) {
  35893. queuedEvent.blockedOn = null;
  35894. if (!hasScheduledReplayAttempt) {
  35895. hasScheduledReplayAttempt = true; // Schedule a callback to attempt replaying as many events as are
  35896. // now unblocked. This first might not actually be unblocked yet.
  35897. // We could check it early to avoid scheduling an unnecessary callback.
  35898. Scheduler.unstable_scheduleCallback(Scheduler.unstable_NormalPriority, replayUnblockedEvents);
  35899. }
  35900. }
  35901. }
  35902. function retryIfBlockedOn(unblocked) {
  35903. // Mark anything that was blocked on this as no longer blocked
  35904. // and eligible for a replay.
  35905. if (queuedDiscreteEvents.length > 0) {
  35906. scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked); // This is a exponential search for each boundary that commits. I think it's
  35907. // worth it because we expect very few discrete events to queue up and once
  35908. // we are actually fully unblocked it will be fast to replay them.
  35909. for (var i = 1; i < queuedDiscreteEvents.length; i++) {
  35910. var queuedEvent = queuedDiscreteEvents[i];
  35911. if (queuedEvent.blockedOn === unblocked) {
  35912. queuedEvent.blockedOn = null;
  35913. }
  35914. }
  35915. }
  35916. if (queuedFocus !== null) {
  35917. scheduleCallbackIfUnblocked(queuedFocus, unblocked);
  35918. }
  35919. if (queuedDrag !== null) {
  35920. scheduleCallbackIfUnblocked(queuedDrag, unblocked);
  35921. }
  35922. if (queuedMouse !== null) {
  35923. scheduleCallbackIfUnblocked(queuedMouse, unblocked);
  35924. }
  35925. var unblock = function (queuedEvent) {
  35926. return scheduleCallbackIfUnblocked(queuedEvent, unblocked);
  35927. };
  35928. queuedPointers.forEach(unblock);
  35929. queuedPointerCaptures.forEach(unblock);
  35930. }
  35931. /**
  35932. * `ReactInstanceMap` maintains a mapping from a public facing stateful
  35933. * instance (key) and the internal representation (value). This allows public
  35934. * methods to accept the user facing instance as an argument and map them back
  35935. * to internal methods.
  35936. *
  35937. * Note that this module is currently shared and assumed to be stateless.
  35938. * If this becomes an actual Map, that will break.
  35939. */
  35940. /**
  35941. * This API should be called `delete` but we'd have to make sure to always
  35942. * transform these to strings for IE support. When this transform is fully
  35943. * supported we can rename it.
  35944. */
  35945. function get(key) {
  35946. return key._reactInternalFiber;
  35947. }
  35948. function has(key) {
  35949. return key._reactInternalFiber !== undefined;
  35950. }
  35951. function set(key, value) {
  35952. key._reactInternalFiber = value;
  35953. }
  35954. // Don't change these two values. They're used by React Dev Tools.
  35955. var NoEffect =
  35956. /* */
  35957. 0;
  35958. var PerformedWork =
  35959. /* */
  35960. 1; // You can change the rest (and add more).
  35961. var Placement =
  35962. /* */
  35963. 2;
  35964. var Update =
  35965. /* */
  35966. 4;
  35967. var PlacementAndUpdate =
  35968. /* */
  35969. 6;
  35970. var Deletion =
  35971. /* */
  35972. 8;
  35973. var ContentReset =
  35974. /* */
  35975. 16;
  35976. var Callback =
  35977. /* */
  35978. 32;
  35979. var DidCapture =
  35980. /* */
  35981. 64;
  35982. var Ref =
  35983. /* */
  35984. 128;
  35985. var Snapshot =
  35986. /* */
  35987. 256;
  35988. var Passive =
  35989. /* */
  35990. 512;
  35991. var Hydrating =
  35992. /* */
  35993. 1024;
  35994. var HydratingAndUpdate =
  35995. /* */
  35996. 1028; // Passive & Update & Callback & Ref & Snapshot
  35997. var LifecycleEffectMask =
  35998. /* */
  35999. 932; // Union of all host effects
  36000. var HostEffectMask =
  36001. /* */
  36002. 2047;
  36003. var Incomplete =
  36004. /* */
  36005. 2048;
  36006. var ShouldCapture =
  36007. /* */
  36008. 4096;
  36009. var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
  36010. function getNearestMountedFiber(fiber) {
  36011. var node = fiber;
  36012. var nearestMounted = fiber;
  36013. if (!fiber.alternate) {
  36014. // If there is no alternate, this might be a new tree that isn't inserted
  36015. // yet. If it is, then it will have a pending insertion effect on it.
  36016. var nextNode = node;
  36017. do {
  36018. node = nextNode;
  36019. if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
  36020. // This is an insertion or in-progress hydration. The nearest possible
  36021. // mounted fiber is the parent but we need to continue to figure out
  36022. // if that one is still mounted.
  36023. nearestMounted = node.return;
  36024. }
  36025. nextNode = node.return;
  36026. } while (nextNode);
  36027. } else {
  36028. while (node.return) {
  36029. node = node.return;
  36030. }
  36031. }
  36032. if (node.tag === HostRoot) {
  36033. // TODO: Check if this was a nested HostRoot when used with
  36034. // renderContainerIntoSubtree.
  36035. return nearestMounted;
  36036. } // If we didn't hit the root, that means that we're in an disconnected tree
  36037. // that has been unmounted.
  36038. return null;
  36039. }
  36040. function getSuspenseInstanceFromFiber(fiber) {
  36041. if (fiber.tag === SuspenseComponent) {
  36042. var suspenseState = fiber.memoizedState;
  36043. if (suspenseState === null) {
  36044. var current = fiber.alternate;
  36045. if (current !== null) {
  36046. suspenseState = current.memoizedState;
  36047. }
  36048. }
  36049. if (suspenseState !== null) {
  36050. return suspenseState.dehydrated;
  36051. }
  36052. }
  36053. return null;
  36054. }
  36055. function getContainerFromFiber(fiber) {
  36056. return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null;
  36057. }
  36058. function isFiberMounted(fiber) {
  36059. return getNearestMountedFiber(fiber) === fiber;
  36060. }
  36061. function isMounted(component) {
  36062. {
  36063. var owner = ReactCurrentOwner$1.current;
  36064. if (owner !== null && owner.tag === ClassComponent) {
  36065. var ownerFiber = owner;
  36066. var instance = ownerFiber.stateNode;
  36067. !instance._warnedAboutRefsInRender ? warningWithoutStack$1(false, '%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') : void 0;
  36068. instance._warnedAboutRefsInRender = true;
  36069. }
  36070. }
  36071. var fiber = get(component);
  36072. if (!fiber) {
  36073. return false;
  36074. }
  36075. return getNearestMountedFiber(fiber) === fiber;
  36076. }
  36077. function assertIsMounted(fiber) {
  36078. (function () {
  36079. if (!(getNearestMountedFiber(fiber) === fiber)) {
  36080. {
  36081. throw ReactError(Error("Unable to find node on an unmounted component."));
  36082. }
  36083. }
  36084. })();
  36085. }
  36086. function findCurrentFiberUsingSlowPath(fiber) {
  36087. var alternate = fiber.alternate;
  36088. if (!alternate) {
  36089. // If there is no alternate, then we only need to check if it is mounted.
  36090. var nearestMounted = getNearestMountedFiber(fiber);
  36091. (function () {
  36092. if (!(nearestMounted !== null)) {
  36093. {
  36094. throw ReactError(Error("Unable to find node on an unmounted component."));
  36095. }
  36096. }
  36097. })();
  36098. if (nearestMounted !== fiber) {
  36099. return null;
  36100. }
  36101. return fiber;
  36102. } // If we have two possible branches, we'll walk backwards up to the root
  36103. // to see what path the root points to. On the way we may hit one of the
  36104. // special cases and we'll deal with them.
  36105. var a = fiber;
  36106. var b = alternate;
  36107. while (true) {
  36108. var parentA = a.return;
  36109. if (parentA === null) {
  36110. // We're at the root.
  36111. break;
  36112. }
  36113. var parentB = parentA.alternate;
  36114. if (parentB === null) {
  36115. // There is no alternate. This is an unusual case. Currently, it only
  36116. // happens when a Suspense component is hidden. An extra fragment fiber
  36117. // is inserted in between the Suspense fiber and its children. Skip
  36118. // over this extra fragment fiber and proceed to the next parent.
  36119. var nextParent = parentA.return;
  36120. if (nextParent !== null) {
  36121. a = b = nextParent;
  36122. continue;
  36123. } // If there's no parent, we're at the root.
  36124. break;
  36125. } // If both copies of the parent fiber point to the same child, we can
  36126. // assume that the child is current. This happens when we bailout on low
  36127. // priority: the bailed out fiber's child reuses the current child.
  36128. if (parentA.child === parentB.child) {
  36129. var child = parentA.child;
  36130. while (child) {
  36131. if (child === a) {
  36132. // We've determined that A is the current branch.
  36133. assertIsMounted(parentA);
  36134. return fiber;
  36135. }
  36136. if (child === b) {
  36137. // We've determined that B is the current branch.
  36138. assertIsMounted(parentA);
  36139. return alternate;
  36140. }
  36141. child = child.sibling;
  36142. } // We should never have an alternate for any mounting node. So the only
  36143. // way this could possibly happen is if this was unmounted, if at all.
  36144. (function () {
  36145. {
  36146. {
  36147. throw ReactError(Error("Unable to find node on an unmounted component."));
  36148. }
  36149. }
  36150. })();
  36151. }
  36152. if (a.return !== b.return) {
  36153. // The return pointer of A and the return pointer of B point to different
  36154. // fibers. We assume that return pointers never criss-cross, so A must
  36155. // belong to the child set of A.return, and B must belong to the child
  36156. // set of B.return.
  36157. a = parentA;
  36158. b = parentB;
  36159. } else {
  36160. // The return pointers point to the same fiber. We'll have to use the
  36161. // default, slow path: scan the child sets of each parent alternate to see
  36162. // which child belongs to which set.
  36163. //
  36164. // Search parent A's child set
  36165. var didFindChild = false;
  36166. var _child = parentA.child;
  36167. while (_child) {
  36168. if (_child === a) {
  36169. didFindChild = true;
  36170. a = parentA;
  36171. b = parentB;
  36172. break;
  36173. }
  36174. if (_child === b) {
  36175. didFindChild = true;
  36176. b = parentA;
  36177. a = parentB;
  36178. break;
  36179. }
  36180. _child = _child.sibling;
  36181. }
  36182. if (!didFindChild) {
  36183. // Search parent B's child set
  36184. _child = parentB.child;
  36185. while (_child) {
  36186. if (_child === a) {
  36187. didFindChild = true;
  36188. a = parentB;
  36189. b = parentA;
  36190. break;
  36191. }
  36192. if (_child === b) {
  36193. didFindChild = true;
  36194. b = parentB;
  36195. a = parentA;
  36196. break;
  36197. }
  36198. _child = _child.sibling;
  36199. }
  36200. (function () {
  36201. if (!didFindChild) {
  36202. {
  36203. throw ReactError(Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue."));
  36204. }
  36205. }
  36206. })();
  36207. }
  36208. }
  36209. (function () {
  36210. if (!(a.alternate === b)) {
  36211. {
  36212. throw ReactError(Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue."));
  36213. }
  36214. }
  36215. })();
  36216. } // If the root is not a host container, we're in a disconnected tree. I.e.
  36217. // unmounted.
  36218. (function () {
  36219. if (!(a.tag === HostRoot)) {
  36220. {
  36221. throw ReactError(Error("Unable to find node on an unmounted component."));
  36222. }
  36223. }
  36224. })();
  36225. if (a.stateNode.current === a) {
  36226. // We've determined that A is the current branch.
  36227. return fiber;
  36228. } // Otherwise B has to be current branch.
  36229. return alternate;
  36230. }
  36231. function findCurrentHostFiber(parent) {
  36232. var currentParent = findCurrentFiberUsingSlowPath(parent);
  36233. if (!currentParent) {
  36234. return null;
  36235. } // Next we'll drill down this component to find the first HostComponent/Text.
  36236. var node = currentParent;
  36237. while (true) {
  36238. if (node.tag === HostComponent || node.tag === HostText) {
  36239. return node;
  36240. } else if (node.child) {
  36241. node.child.return = node;
  36242. node = node.child;
  36243. continue;
  36244. }
  36245. if (node === currentParent) {
  36246. return null;
  36247. }
  36248. while (!node.sibling) {
  36249. if (!node.return || node.return === currentParent) {
  36250. return null;
  36251. }
  36252. node = node.return;
  36253. }
  36254. node.sibling.return = node.return;
  36255. node = node.sibling;
  36256. } // Flow needs the return null here, but ESLint complains about it.
  36257. // eslint-disable-next-line no-unreachable
  36258. return null;
  36259. }
  36260. function findCurrentHostFiberWithNoPortals(parent) {
  36261. var currentParent = findCurrentFiberUsingSlowPath(parent);
  36262. if (!currentParent) {
  36263. return null;
  36264. } // Next we'll drill down this component to find the first HostComponent/Text.
  36265. var node = currentParent;
  36266. while (true) {
  36267. if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI && node.tag === FundamentalComponent) {
  36268. return node;
  36269. } else if (node.child && node.tag !== HostPortal) {
  36270. node.child.return = node;
  36271. node = node.child;
  36272. continue;
  36273. }
  36274. if (node === currentParent) {
  36275. return null;
  36276. }
  36277. while (!node.sibling) {
  36278. if (!node.return || node.return === currentParent) {
  36279. return null;
  36280. }
  36281. node = node.return;
  36282. }
  36283. node.sibling.return = node.return;
  36284. node = node.sibling;
  36285. } // Flow needs the return null here, but ESLint complains about it.
  36286. // eslint-disable-next-line no-unreachable
  36287. return null;
  36288. }
  36289. function addEventBubbleListener(element, eventType, listener) {
  36290. element.addEventListener(eventType, listener, false);
  36291. }
  36292. function addEventCaptureListener(element, eventType, listener) {
  36293. element.addEventListener(eventType, listener, true);
  36294. }
  36295. function addEventCaptureListenerWithPassiveFlag(element, eventType, listener, passive) {
  36296. element.addEventListener(eventType, listener, {
  36297. capture: true,
  36298. passive: passive
  36299. });
  36300. }
  36301. /**
  36302. * Gets the target node from a native browser event by accounting for
  36303. * inconsistencies in browser DOM APIs.
  36304. *
  36305. * @param {object} nativeEvent Native browser event.
  36306. * @return {DOMEventTarget} Target node.
  36307. */
  36308. function getEventTarget(nativeEvent) {
  36309. // Fallback to nativeEvent.srcElement for IE9
  36310. // https://github.com/facebook/react/issues/12506
  36311. var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963
  36312. if (target.correspondingUseElement) {
  36313. target = target.correspondingUseElement;
  36314. } // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
  36315. // @see http://www.quirksmode.org/js/events_properties.html
  36316. return target.nodeType === TEXT_NODE ? target.parentNode : target;
  36317. }
  36318. function getParent(inst) {
  36319. do {
  36320. inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
  36321. // That is depending on if we want nested subtrees (layers) to bubble
  36322. // events to their parent. We could also go through parentNode on the
  36323. // host node but that wouldn't work for React Native and doesn't let us
  36324. // do the portal feature.
  36325. } while (inst && inst.tag !== HostComponent);
  36326. if (inst) {
  36327. return inst;
  36328. }
  36329. return null;
  36330. }
  36331. /**
  36332. * Return the lowest common ancestor of A and B, or null if they are in
  36333. * different trees.
  36334. */
  36335. function getLowestCommonAncestor(instA, instB) {
  36336. var depthA = 0;
  36337. for (var tempA = instA; tempA; tempA = getParent(tempA)) {
  36338. depthA++;
  36339. }
  36340. var depthB = 0;
  36341. for (var tempB = instB; tempB; tempB = getParent(tempB)) {
  36342. depthB++;
  36343. } // If A is deeper, crawl up.
  36344. while (depthA - depthB > 0) {
  36345. instA = getParent(instA);
  36346. depthA--;
  36347. } // If B is deeper, crawl up.
  36348. while (depthB - depthA > 0) {
  36349. instB = getParent(instB);
  36350. depthB--;
  36351. } // Walk in lockstep until we find a match.
  36352. var depth = depthA;
  36353. while (depth--) {
  36354. if (instA === instB || instA === instB.alternate) {
  36355. return instA;
  36356. }
  36357. instA = getParent(instA);
  36358. instB = getParent(instB);
  36359. }
  36360. return null;
  36361. }
  36362. /**
  36363. * Return if A is an ancestor of B.
  36364. */
  36365. /**
  36366. * Return the parent instance of the passed-in instance.
  36367. */
  36368. /**
  36369. * Simulates the traversal of a two-phase, capture/bubble event dispatch.
  36370. */
  36371. function traverseTwoPhase(inst, fn, arg) {
  36372. var path = [];
  36373. while (inst) {
  36374. path.push(inst);
  36375. inst = getParent(inst);
  36376. }
  36377. var i;
  36378. for (i = path.length; i-- > 0;) {
  36379. fn(path[i], 'captured', arg);
  36380. }
  36381. for (i = 0; i < path.length; i++) {
  36382. fn(path[i], 'bubbled', arg);
  36383. }
  36384. }
  36385. /**
  36386. * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
  36387. * should would receive a `mouseEnter` or `mouseLeave` event.
  36388. *
  36389. * Does not invoke the callback on the nearest common ancestor because nothing
  36390. * "entered" or "left" that element.
  36391. */
  36392. function traverseEnterLeave(from, to, fn, argFrom, argTo) {
  36393. var common = from && to ? getLowestCommonAncestor(from, to) : null;
  36394. var pathFrom = [];
  36395. while (true) {
  36396. if (!from) {
  36397. break;
  36398. }
  36399. if (from === common) {
  36400. break;
  36401. }
  36402. var alternate = from.alternate;
  36403. if (alternate !== null && alternate === common) {
  36404. break;
  36405. }
  36406. pathFrom.push(from);
  36407. from = getParent(from);
  36408. }
  36409. var pathTo = [];
  36410. while (true) {
  36411. if (!to) {
  36412. break;
  36413. }
  36414. if (to === common) {
  36415. break;
  36416. }
  36417. var _alternate = to.alternate;
  36418. if (_alternate !== null && _alternate === common) {
  36419. break;
  36420. }
  36421. pathTo.push(to);
  36422. to = getParent(to);
  36423. }
  36424. for (var i = 0; i < pathFrom.length; i++) {
  36425. fn(pathFrom[i], 'bubbled', argFrom);
  36426. }
  36427. for (var _i = pathTo.length; _i-- > 0;) {
  36428. fn(pathTo[_i], 'captured', argTo);
  36429. }
  36430. }
  36431. /**
  36432. * Some event types have a notion of different registration names for different
  36433. * "phases" of propagation. This finds listeners by a given phase.
  36434. */
  36435. function listenerAtPhase(inst, event, propagationPhase) {
  36436. var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
  36437. return getListener(inst, registrationName);
  36438. }
  36439. /**
  36440. * A small set of propagation patterns, each of which will accept a small amount
  36441. * of information, and generate a set of "dispatch ready event objects" - which
  36442. * are sets of events that have already been annotated with a set of dispatched
  36443. * listener functions/ids. The API is designed this way to discourage these
  36444. * propagation strategies from actually executing the dispatches, since we
  36445. * always want to collect the entire set of dispatches before executing even a
  36446. * single one.
  36447. */
  36448. /**
  36449. * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
  36450. * here, allows us to not have to bind or create functions for each event.
  36451. * Mutating the event's members allows us to not have to create a wrapping
  36452. * "dispatch" object that pairs the event with the listener.
  36453. */
  36454. function accumulateDirectionalDispatches(inst, phase, event) {
  36455. {
  36456. !inst ? warningWithoutStack$1(false, 'Dispatching inst must not be null') : void 0;
  36457. }
  36458. var listener = listenerAtPhase(inst, event, phase);
  36459. if (listener) {
  36460. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  36461. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  36462. }
  36463. }
  36464. /**
  36465. * Collect dispatches (must be entirely collected before dispatching - see unit
  36466. * tests). Lazily allocate the array to conserve memory. We must loop through
  36467. * each event and perform the traversal for each one. We cannot perform a
  36468. * single traversal for the entire collection of events because each event may
  36469. * have a different target.
  36470. */
  36471. function accumulateTwoPhaseDispatchesSingle(event) {
  36472. if (event && event.dispatchConfig.phasedRegistrationNames) {
  36473. traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
  36474. }
  36475. }
  36476. /**
  36477. * Accumulates without regard to direction, does not look for phased
  36478. * registration names. Same as `accumulateDirectDispatchesSingle` but without
  36479. * requiring that the `dispatchMarker` be the same as the dispatched ID.
  36480. */
  36481. function accumulateDispatches(inst, ignoredDirection, event) {
  36482. if (inst && event && event.dispatchConfig.registrationName) {
  36483. var registrationName = event.dispatchConfig.registrationName;
  36484. var listener = getListener(inst, registrationName);
  36485. if (listener) {
  36486. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  36487. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  36488. }
  36489. }
  36490. }
  36491. /**
  36492. * Accumulates dispatches on an `SyntheticEvent`, but only for the
  36493. * `dispatchMarker`.
  36494. * @param {SyntheticEvent} event
  36495. */
  36496. function accumulateDirectDispatchesSingle(event) {
  36497. if (event && event.dispatchConfig.registrationName) {
  36498. accumulateDispatches(event._targetInst, null, event);
  36499. }
  36500. }
  36501. function accumulateTwoPhaseDispatches(events) {
  36502. forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
  36503. }
  36504. function accumulateEnterLeaveDispatches(leave, enter, from, to) {
  36505. traverseEnterLeave(from, to, accumulateDispatches, leave, enter);
  36506. }
  36507. function accumulateDirectDispatches(events) {
  36508. forEachAccumulated(events, accumulateDirectDispatchesSingle);
  36509. }
  36510. /* eslint valid-typeof: 0 */
  36511. var EVENT_POOL_SIZE = 10;
  36512. /**
  36513. * @interface Event
  36514. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  36515. */
  36516. var EventInterface = {
  36517. type: null,
  36518. target: null,
  36519. // currentTarget is set when dispatching; no use in copying it here
  36520. currentTarget: function () {
  36521. return null;
  36522. },
  36523. eventPhase: null,
  36524. bubbles: null,
  36525. cancelable: null,
  36526. timeStamp: function (event) {
  36527. return event.timeStamp || Date.now();
  36528. },
  36529. defaultPrevented: null,
  36530. isTrusted: null
  36531. };
  36532. function functionThatReturnsTrue() {
  36533. return true;
  36534. }
  36535. function functionThatReturnsFalse() {
  36536. return false;
  36537. }
  36538. /**
  36539. * Synthetic events are dispatched by event plugins, typically in response to a
  36540. * top-level event delegation handler.
  36541. *
  36542. * These systems should generally use pooling to reduce the frequency of garbage
  36543. * collection. The system should check `isPersistent` to determine whether the
  36544. * event should be released into the pool after being dispatched. Users that
  36545. * need a persisted event should invoke `persist`.
  36546. *
  36547. * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
  36548. * normalizing browser quirks. Subclasses do not necessarily have to implement a
  36549. * DOM interface; custom application-specific events can also subclass this.
  36550. *
  36551. * @param {object} dispatchConfig Configuration used to dispatch this event.
  36552. * @param {*} targetInst Marker identifying the event target.
  36553. * @param {object} nativeEvent Native browser event.
  36554. * @param {DOMEventTarget} nativeEventTarget Target node.
  36555. */
  36556. function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
  36557. {
  36558. // these have a getter/setter for warnings
  36559. delete this.nativeEvent;
  36560. delete this.preventDefault;
  36561. delete this.stopPropagation;
  36562. delete this.isDefaultPrevented;
  36563. delete this.isPropagationStopped;
  36564. }
  36565. this.dispatchConfig = dispatchConfig;
  36566. this._targetInst = targetInst;
  36567. this.nativeEvent = nativeEvent;
  36568. var Interface = this.constructor.Interface;
  36569. for (var propName in Interface) {
  36570. if (!Interface.hasOwnProperty(propName)) {
  36571. continue;
  36572. }
  36573. {
  36574. delete this[propName]; // this has a getter/setter for warnings
  36575. }
  36576. var normalize = Interface[propName];
  36577. if (normalize) {
  36578. this[propName] = normalize(nativeEvent);
  36579. } else {
  36580. if (propName === 'target') {
  36581. this.target = nativeEventTarget;
  36582. } else {
  36583. this[propName] = nativeEvent[propName];
  36584. }
  36585. }
  36586. }
  36587. var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
  36588. if (defaultPrevented) {
  36589. this.isDefaultPrevented = functionThatReturnsTrue;
  36590. } else {
  36591. this.isDefaultPrevented = functionThatReturnsFalse;
  36592. }
  36593. this.isPropagationStopped = functionThatReturnsFalse;
  36594. return this;
  36595. }
  36596. _assign(SyntheticEvent.prototype, {
  36597. preventDefault: function () {
  36598. this.defaultPrevented = true;
  36599. var event = this.nativeEvent;
  36600. if (!event) {
  36601. return;
  36602. }
  36603. if (event.preventDefault) {
  36604. event.preventDefault();
  36605. } else if (typeof event.returnValue !== 'unknown') {
  36606. event.returnValue = false;
  36607. }
  36608. this.isDefaultPrevented = functionThatReturnsTrue;
  36609. },
  36610. stopPropagation: function () {
  36611. var event = this.nativeEvent;
  36612. if (!event) {
  36613. return;
  36614. }
  36615. if (event.stopPropagation) {
  36616. event.stopPropagation();
  36617. } else if (typeof event.cancelBubble !== 'unknown') {
  36618. // The ChangeEventPlugin registers a "propertychange" event for
  36619. // IE. This event does not support bubbling or cancelling, and
  36620. // any references to cancelBubble throw "Member not found". A
  36621. // typeof check of "unknown" circumvents this issue (and is also
  36622. // IE specific).
  36623. event.cancelBubble = true;
  36624. }
  36625. this.isPropagationStopped = functionThatReturnsTrue;
  36626. },
  36627. /**
  36628. * We release all dispatched `SyntheticEvent`s after each event loop, adding
  36629. * them back into the pool. This allows a way to hold onto a reference that
  36630. * won't be added back into the pool.
  36631. */
  36632. persist: function () {
  36633. this.isPersistent = functionThatReturnsTrue;
  36634. },
  36635. /**
  36636. * Checks if this event should be released back into the pool.
  36637. *
  36638. * @return {boolean} True if this should not be released, false otherwise.
  36639. */
  36640. isPersistent: functionThatReturnsFalse,
  36641. /**
  36642. * `PooledClass` looks for `destructor` on each instance it releases.
  36643. */
  36644. destructor: function () {
  36645. var Interface = this.constructor.Interface;
  36646. for (var propName in Interface) {
  36647. {
  36648. Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
  36649. }
  36650. }
  36651. this.dispatchConfig = null;
  36652. this._targetInst = null;
  36653. this.nativeEvent = null;
  36654. this.isDefaultPrevented = functionThatReturnsFalse;
  36655. this.isPropagationStopped = functionThatReturnsFalse;
  36656. this._dispatchListeners = null;
  36657. this._dispatchInstances = null;
  36658. {
  36659. Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
  36660. Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
  36661. Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
  36662. Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
  36663. Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
  36664. }
  36665. }
  36666. });
  36667. SyntheticEvent.Interface = EventInterface;
  36668. /**
  36669. * Helper to reduce boilerplate when creating subclasses.
  36670. */
  36671. SyntheticEvent.extend = function (Interface) {
  36672. var Super = this;
  36673. var E = function () {};
  36674. E.prototype = Super.prototype;
  36675. var prototype = new E();
  36676. function Class() {
  36677. return Super.apply(this, arguments);
  36678. }
  36679. _assign(prototype, Class.prototype);
  36680. Class.prototype = prototype;
  36681. Class.prototype.constructor = Class;
  36682. Class.Interface = _assign({}, Super.Interface, Interface);
  36683. Class.extend = Super.extend;
  36684. addEventPoolingTo(Class);
  36685. return Class;
  36686. };
  36687. addEventPoolingTo(SyntheticEvent);
  36688. /**
  36689. * Helper to nullify syntheticEvent instance properties when destructing
  36690. *
  36691. * @param {String} propName
  36692. * @param {?object} getVal
  36693. * @return {object} defineProperty object
  36694. */
  36695. function getPooledWarningPropertyDefinition(propName, getVal) {
  36696. var isFunction = typeof getVal === 'function';
  36697. return {
  36698. configurable: true,
  36699. set: set,
  36700. get: get
  36701. };
  36702. function set(val) {
  36703. var action = isFunction ? 'setting the method' : 'setting the property';
  36704. warn(action, 'This is effectively a no-op');
  36705. return val;
  36706. }
  36707. function get() {
  36708. var action = isFunction ? 'accessing the method' : 'accessing the property';
  36709. var result = isFunction ? 'This is a no-op function' : 'This is set to null';
  36710. warn(action, result);
  36711. return getVal;
  36712. }
  36713. function warn(action, result) {
  36714. var warningCondition = false;
  36715. !warningCondition ? warningWithoutStack$1(false, "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) : void 0;
  36716. }
  36717. }
  36718. function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
  36719. var EventConstructor = this;
  36720. if (EventConstructor.eventPool.length) {
  36721. var instance = EventConstructor.eventPool.pop();
  36722. EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
  36723. return instance;
  36724. }
  36725. return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
  36726. }
  36727. function releasePooledEvent(event) {
  36728. var EventConstructor = this;
  36729. (function () {
  36730. if (!(event instanceof EventConstructor)) {
  36731. {
  36732. throw ReactError(Error("Trying to release an event instance into a pool of a different type."));
  36733. }
  36734. }
  36735. })();
  36736. event.destructor();
  36737. if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
  36738. EventConstructor.eventPool.push(event);
  36739. }
  36740. }
  36741. function addEventPoolingTo(EventConstructor) {
  36742. EventConstructor.eventPool = [];
  36743. EventConstructor.getPooled = getPooledEvent;
  36744. EventConstructor.release = releasePooledEvent;
  36745. }
  36746. /**
  36747. * @interface Event
  36748. * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
  36749. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
  36750. */
  36751. var SyntheticAnimationEvent = SyntheticEvent.extend({
  36752. animationName: null,
  36753. elapsedTime: null,
  36754. pseudoElement: null
  36755. });
  36756. /**
  36757. * @interface Event
  36758. * @see http://www.w3.org/TR/clipboard-apis/
  36759. */
  36760. var SyntheticClipboardEvent = SyntheticEvent.extend({
  36761. clipboardData: function (event) {
  36762. return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
  36763. }
  36764. });
  36765. var SyntheticUIEvent = SyntheticEvent.extend({
  36766. view: null,
  36767. detail: null
  36768. });
  36769. /**
  36770. * @interface FocusEvent
  36771. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  36772. */
  36773. var SyntheticFocusEvent = SyntheticUIEvent.extend({
  36774. relatedTarget: null
  36775. });
  36776. /**
  36777. * `charCode` represents the actual "character code" and is safe to use with
  36778. * `String.fromCharCode`. As such, only keys that correspond to printable
  36779. * characters produce a valid `charCode`, the only exception to this is Enter.
  36780. * The Tab-key is considered non-printable and does not have a `charCode`,
  36781. * presumably because it does not produce a tab-character in browsers.
  36782. *
  36783. * @param {object} nativeEvent Native browser event.
  36784. * @return {number} Normalized `charCode` property.
  36785. */
  36786. function getEventCharCode(nativeEvent) {
  36787. var charCode;
  36788. var keyCode = nativeEvent.keyCode;
  36789. if ('charCode' in nativeEvent) {
  36790. charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`.
  36791. if (charCode === 0 && keyCode === 13) {
  36792. charCode = 13;
  36793. }
  36794. } else {
  36795. // IE8 does not implement `charCode`, but `keyCode` has the correct value.
  36796. charCode = keyCode;
  36797. } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux)
  36798. // report Enter as charCode 10 when ctrl is pressed.
  36799. if (charCode === 10) {
  36800. charCode = 13;
  36801. } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
  36802. // Must not discard the (non-)printable Enter-key.
  36803. if (charCode >= 32 || charCode === 13) {
  36804. return charCode;
  36805. }
  36806. return 0;
  36807. }
  36808. /**
  36809. * Normalization of deprecated HTML5 `key` values
  36810. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  36811. */
  36812. var normalizeKey = {
  36813. Esc: 'Escape',
  36814. Spacebar: ' ',
  36815. Left: 'ArrowLeft',
  36816. Up: 'ArrowUp',
  36817. Right: 'ArrowRight',
  36818. Down: 'ArrowDown',
  36819. Del: 'Delete',
  36820. Win: 'OS',
  36821. Menu: 'ContextMenu',
  36822. Apps: 'ContextMenu',
  36823. Scroll: 'ScrollLock',
  36824. MozPrintableKey: 'Unidentified'
  36825. };
  36826. /**
  36827. * Translation from legacy `keyCode` to HTML5 `key`
  36828. * Only special keys supported, all others depend on keyboard layout or browser
  36829. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  36830. */
  36831. var translateToKey = {
  36832. '8': 'Backspace',
  36833. '9': 'Tab',
  36834. '12': 'Clear',
  36835. '13': 'Enter',
  36836. '16': 'Shift',
  36837. '17': 'Control',
  36838. '18': 'Alt',
  36839. '19': 'Pause',
  36840. '20': 'CapsLock',
  36841. '27': 'Escape',
  36842. '32': ' ',
  36843. '33': 'PageUp',
  36844. '34': 'PageDown',
  36845. '35': 'End',
  36846. '36': 'Home',
  36847. '37': 'ArrowLeft',
  36848. '38': 'ArrowUp',
  36849. '39': 'ArrowRight',
  36850. '40': 'ArrowDown',
  36851. '45': 'Insert',
  36852. '46': 'Delete',
  36853. '112': 'F1',
  36854. '113': 'F2',
  36855. '114': 'F3',
  36856. '115': 'F4',
  36857. '116': 'F5',
  36858. '117': 'F6',
  36859. '118': 'F7',
  36860. '119': 'F8',
  36861. '120': 'F9',
  36862. '121': 'F10',
  36863. '122': 'F11',
  36864. '123': 'F12',
  36865. '144': 'NumLock',
  36866. '145': 'ScrollLock',
  36867. '224': 'Meta'
  36868. };
  36869. /**
  36870. * @param {object} nativeEvent Native browser event.
  36871. * @return {string} Normalized `key` property.
  36872. */
  36873. function getEventKey(nativeEvent) {
  36874. if (nativeEvent.key) {
  36875. // Normalize inconsistent values reported by browsers due to
  36876. // implementations of a working draft specification.
  36877. // FireFox implements `key` but returns `MozPrintableKey` for all
  36878. // printable characters (normalized to `Unidentified`), ignore it.
  36879. var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
  36880. if (key !== 'Unidentified') {
  36881. return key;
  36882. }
  36883. } // Browser does not implement `key`, polyfill as much of it as we can.
  36884. if (nativeEvent.type === 'keypress') {
  36885. var charCode = getEventCharCode(nativeEvent); // The enter-key is technically both printable and non-printable and can
  36886. // thus be captured by `keypress`, no other non-printable key should.
  36887. return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
  36888. }
  36889. if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
  36890. // While user keyboard layout determines the actual meaning of each
  36891. // `keyCode` value, almost all function keys have a universal value.
  36892. return translateToKey[nativeEvent.keyCode] || 'Unidentified';
  36893. }
  36894. return '';
  36895. }
  36896. /**
  36897. * Translation from modifier key to the associated property in the event.
  36898. * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
  36899. */
  36900. var modifierKeyToProp = {
  36901. Alt: 'altKey',
  36902. Control: 'ctrlKey',
  36903. Meta: 'metaKey',
  36904. Shift: 'shiftKey'
  36905. }; // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support
  36906. // getModifierState. If getModifierState is not supported, we map it to a set of
  36907. // modifier keys exposed by the event. In this case, Lock-keys are not supported.
  36908. function modifierStateGetter(keyArg) {
  36909. var syntheticEvent = this;
  36910. var nativeEvent = syntheticEvent.nativeEvent;
  36911. if (nativeEvent.getModifierState) {
  36912. return nativeEvent.getModifierState(keyArg);
  36913. }
  36914. var keyProp = modifierKeyToProp[keyArg];
  36915. return keyProp ? !!nativeEvent[keyProp] : false;
  36916. }
  36917. function getEventModifierState(nativeEvent) {
  36918. return modifierStateGetter;
  36919. }
  36920. /**
  36921. * @interface KeyboardEvent
  36922. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  36923. */
  36924. var SyntheticKeyboardEvent = SyntheticUIEvent.extend({
  36925. key: getEventKey,
  36926. location: null,
  36927. ctrlKey: null,
  36928. shiftKey: null,
  36929. altKey: null,
  36930. metaKey: null,
  36931. repeat: null,
  36932. locale: null,
  36933. getModifierState: getEventModifierState,
  36934. // Legacy Interface
  36935. charCode: function (event) {
  36936. // `charCode` is the result of a KeyPress event and represents the value of
  36937. // the actual printable character.
  36938. // KeyPress is deprecated, but its replacement is not yet final and not
  36939. // implemented in any major browser. Only KeyPress has charCode.
  36940. if (event.type === 'keypress') {
  36941. return getEventCharCode(event);
  36942. }
  36943. return 0;
  36944. },
  36945. keyCode: function (event) {
  36946. // `keyCode` is the result of a KeyDown/Up event and represents the value of
  36947. // physical keyboard key.
  36948. // The actual meaning of the value depends on the users' keyboard layout
  36949. // which cannot be detected. Assuming that it is a US keyboard layout
  36950. // provides a surprisingly accurate mapping for US and European users.
  36951. // Due to this, it is left to the user to implement at this time.
  36952. if (event.type === 'keydown' || event.type === 'keyup') {
  36953. return event.keyCode;
  36954. }
  36955. return 0;
  36956. },
  36957. which: function (event) {
  36958. // `which` is an alias for either `keyCode` or `charCode` depending on the
  36959. // type of the event.
  36960. if (event.type === 'keypress') {
  36961. return getEventCharCode(event);
  36962. }
  36963. if (event.type === 'keydown' || event.type === 'keyup') {
  36964. return event.keyCode;
  36965. }
  36966. return 0;
  36967. }
  36968. });
  36969. var previousScreenX = 0;
  36970. var previousScreenY = 0; // Use flags to signal movementX/Y has already been set
  36971. var isMovementXSet = false;
  36972. var isMovementYSet = false;
  36973. /**
  36974. * @interface MouseEvent
  36975. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  36976. */
  36977. var SyntheticMouseEvent = SyntheticUIEvent.extend({
  36978. screenX: null,
  36979. screenY: null,
  36980. clientX: null,
  36981. clientY: null,
  36982. pageX: null,
  36983. pageY: null,
  36984. ctrlKey: null,
  36985. shiftKey: null,
  36986. altKey: null,
  36987. metaKey: null,
  36988. getModifierState: getEventModifierState,
  36989. button: null,
  36990. buttons: null,
  36991. relatedTarget: function (event) {
  36992. return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement);
  36993. },
  36994. movementX: function (event) {
  36995. if ('movementX' in event) {
  36996. return event.movementX;
  36997. }
  36998. var screenX = previousScreenX;
  36999. previousScreenX = event.screenX;
  37000. if (!isMovementXSet) {
  37001. isMovementXSet = true;
  37002. return 0;
  37003. }
  37004. return event.type === 'mousemove' ? event.screenX - screenX : 0;
  37005. },
  37006. movementY: function (event) {
  37007. if ('movementY' in event) {
  37008. return event.movementY;
  37009. }
  37010. var screenY = previousScreenY;
  37011. previousScreenY = event.screenY;
  37012. if (!isMovementYSet) {
  37013. isMovementYSet = true;
  37014. return 0;
  37015. }
  37016. return event.type === 'mousemove' ? event.screenY - screenY : 0;
  37017. }
  37018. });
  37019. /**
  37020. * @interface PointerEvent
  37021. * @see http://www.w3.org/TR/pointerevents/
  37022. */
  37023. var SyntheticPointerEvent = SyntheticMouseEvent.extend({
  37024. pointerId: null,
  37025. width: null,
  37026. height: null,
  37027. pressure: null,
  37028. tangentialPressure: null,
  37029. tiltX: null,
  37030. tiltY: null,
  37031. twist: null,
  37032. pointerType: null,
  37033. isPrimary: null
  37034. });
  37035. /**
  37036. * @interface DragEvent
  37037. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  37038. */
  37039. var SyntheticDragEvent = SyntheticMouseEvent.extend({
  37040. dataTransfer: null
  37041. });
  37042. /**
  37043. * @interface TouchEvent
  37044. * @see http://www.w3.org/TR/touch-events/
  37045. */
  37046. var SyntheticTouchEvent = SyntheticUIEvent.extend({
  37047. touches: null,
  37048. targetTouches: null,
  37049. changedTouches: null,
  37050. altKey: null,
  37051. metaKey: null,
  37052. ctrlKey: null,
  37053. shiftKey: null,
  37054. getModifierState: getEventModifierState
  37055. });
  37056. /**
  37057. * @interface Event
  37058. * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
  37059. * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent
  37060. */
  37061. var SyntheticTransitionEvent = SyntheticEvent.extend({
  37062. propertyName: null,
  37063. elapsedTime: null,
  37064. pseudoElement: null
  37065. });
  37066. /**
  37067. * @interface WheelEvent
  37068. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  37069. */
  37070. var SyntheticWheelEvent = SyntheticMouseEvent.extend({
  37071. deltaX: function (event) {
  37072. return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
  37073. 'wheelDeltaX' in event ? -event.wheelDeltaX : 0;
  37074. },
  37075. deltaY: function (event) {
  37076. return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
  37077. 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
  37078. 'wheelDelta' in event ? -event.wheelDelta : 0;
  37079. },
  37080. deltaZ: null,
  37081. // Browsers without "deltaMode" is reporting in raw wheel delta where one
  37082. // notch on the scroll is always +/- 120, roughly equivalent to pixels.
  37083. // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
  37084. // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
  37085. deltaMode: null
  37086. });
  37087. /**
  37088. * Turns
  37089. * ['abort', ...]
  37090. * into
  37091. * eventTypes = {
  37092. * 'abort': {
  37093. * phasedRegistrationNames: {
  37094. * bubbled: 'onAbort',
  37095. * captured: 'onAbortCapture',
  37096. * },
  37097. * dependencies: [TOP_ABORT],
  37098. * },
  37099. * ...
  37100. * };
  37101. * topLevelEventsToDispatchConfig = new Map([
  37102. * [TOP_ABORT, { sameConfig }],
  37103. * ]);
  37104. */
  37105. var eventTuples = [// Discrete events
  37106. [TOP_BLUR, 'blur', DiscreteEvent], [TOP_CANCEL, 'cancel', DiscreteEvent], [TOP_CLICK, 'click', DiscreteEvent], [TOP_CLOSE, 'close', DiscreteEvent], [TOP_CONTEXT_MENU, 'contextMenu', DiscreteEvent], [TOP_COPY, 'copy', DiscreteEvent], [TOP_CUT, 'cut', DiscreteEvent], [TOP_AUX_CLICK, 'auxClick', DiscreteEvent], [TOP_DOUBLE_CLICK, 'doubleClick', DiscreteEvent], [TOP_DRAG_END, 'dragEnd', DiscreteEvent], [TOP_DRAG_START, 'dragStart', DiscreteEvent], [TOP_DROP, 'drop', DiscreteEvent], [TOP_FOCUS, 'focus', DiscreteEvent], [TOP_INPUT, 'input', DiscreteEvent], [TOP_INVALID, 'invalid', DiscreteEvent], [TOP_KEY_DOWN, 'keyDown', DiscreteEvent], [TOP_KEY_PRESS, 'keyPress', DiscreteEvent], [TOP_KEY_UP, 'keyUp', DiscreteEvent], [TOP_MOUSE_DOWN, 'mouseDown', DiscreteEvent], [TOP_MOUSE_UP, 'mouseUp', DiscreteEvent], [TOP_PASTE, 'paste', DiscreteEvent], [TOP_PAUSE, 'pause', DiscreteEvent], [TOP_PLAY, 'play', DiscreteEvent], [TOP_POINTER_CANCEL, 'pointerCancel', DiscreteEvent], [TOP_POINTER_DOWN, 'pointerDown', DiscreteEvent], [TOP_POINTER_UP, 'pointerUp', DiscreteEvent], [TOP_RATE_CHANGE, 'rateChange', DiscreteEvent], [TOP_RESET, 'reset', DiscreteEvent], [TOP_SEEKED, 'seeked', DiscreteEvent], [TOP_SUBMIT, 'submit', DiscreteEvent], [TOP_TOUCH_CANCEL, 'touchCancel', DiscreteEvent], [TOP_TOUCH_END, 'touchEnd', DiscreteEvent], [TOP_TOUCH_START, 'touchStart', DiscreteEvent], [TOP_VOLUME_CHANGE, 'volumeChange', DiscreteEvent], // User-blocking events
  37107. [TOP_DRAG, 'drag', UserBlockingEvent], [TOP_DRAG_ENTER, 'dragEnter', UserBlockingEvent], [TOP_DRAG_EXIT, 'dragExit', UserBlockingEvent], [TOP_DRAG_LEAVE, 'dragLeave', UserBlockingEvent], [TOP_DRAG_OVER, 'dragOver', UserBlockingEvent], [TOP_MOUSE_MOVE, 'mouseMove', UserBlockingEvent], [TOP_MOUSE_OUT, 'mouseOut', UserBlockingEvent], [TOP_MOUSE_OVER, 'mouseOver', UserBlockingEvent], [TOP_POINTER_MOVE, 'pointerMove', UserBlockingEvent], [TOP_POINTER_OUT, 'pointerOut', UserBlockingEvent], [TOP_POINTER_OVER, 'pointerOver', UserBlockingEvent], [TOP_SCROLL, 'scroll', UserBlockingEvent], [TOP_TOGGLE, 'toggle', UserBlockingEvent], [TOP_TOUCH_MOVE, 'touchMove', UserBlockingEvent], [TOP_WHEEL, 'wheel', UserBlockingEvent], // Continuous events
  37108. [TOP_ABORT, 'abort', ContinuousEvent], [TOP_ANIMATION_END, 'animationEnd', ContinuousEvent], [TOP_ANIMATION_ITERATION, 'animationIteration', ContinuousEvent], [TOP_ANIMATION_START, 'animationStart', ContinuousEvent], [TOP_CAN_PLAY, 'canPlay', ContinuousEvent], [TOP_CAN_PLAY_THROUGH, 'canPlayThrough', ContinuousEvent], [TOP_DURATION_CHANGE, 'durationChange', ContinuousEvent], [TOP_EMPTIED, 'emptied', ContinuousEvent], [TOP_ENCRYPTED, 'encrypted', ContinuousEvent], [TOP_ENDED, 'ended', ContinuousEvent], [TOP_ERROR, 'error', ContinuousEvent], [TOP_GOT_POINTER_CAPTURE, 'gotPointerCapture', ContinuousEvent], [TOP_LOAD, 'load', ContinuousEvent], [TOP_LOADED_DATA, 'loadedData', ContinuousEvent], [TOP_LOADED_METADATA, 'loadedMetadata', ContinuousEvent], [TOP_LOAD_START, 'loadStart', ContinuousEvent], [TOP_LOST_POINTER_CAPTURE, 'lostPointerCapture', ContinuousEvent], [TOP_PLAYING, 'playing', ContinuousEvent], [TOP_PROGRESS, 'progress', ContinuousEvent], [TOP_SEEKING, 'seeking', ContinuousEvent], [TOP_STALLED, 'stalled', ContinuousEvent], [TOP_SUSPEND, 'suspend', ContinuousEvent], [TOP_TIME_UPDATE, 'timeUpdate', ContinuousEvent], [TOP_TRANSITION_END, 'transitionEnd', ContinuousEvent], [TOP_WAITING, 'waiting', ContinuousEvent]];
  37109. var eventTypes = {};
  37110. var topLevelEventsToDispatchConfig = {};
  37111. for (var i = 0; i < eventTuples.length; i++) {
  37112. var eventTuple = eventTuples[i];
  37113. var topEvent = eventTuple[0];
  37114. var event = eventTuple[1];
  37115. var eventPriority = eventTuple[2];
  37116. var capitalizedEvent = event[0].toUpperCase() + event.slice(1);
  37117. var onEvent = 'on' + capitalizedEvent;
  37118. var config = {
  37119. phasedRegistrationNames: {
  37120. bubbled: onEvent,
  37121. captured: onEvent + 'Capture'
  37122. },
  37123. dependencies: [topEvent],
  37124. eventPriority: eventPriority
  37125. };
  37126. eventTypes[event] = config;
  37127. topLevelEventsToDispatchConfig[topEvent] = config;
  37128. } // Only used in DEV for exhaustiveness validation.
  37129. 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];
  37130. var SimpleEventPlugin = {
  37131. eventTypes: eventTypes,
  37132. getEventPriority: function (topLevelType) {
  37133. var config = topLevelEventsToDispatchConfig[topLevelType];
  37134. return config !== undefined ? config.eventPriority : ContinuousEvent;
  37135. },
  37136. extractEvents: function (topLevelType, eventSystemFlags, targetInst, nativeEvent, nativeEventTarget) {
  37137. var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
  37138. if (!dispatchConfig) {
  37139. return null;
  37140. }
  37141. var EventConstructor;
  37142. switch (topLevelType) {
  37143. case TOP_KEY_PRESS:
  37144. // Firefox creates a keypress event for function keys too. This removes
  37145. // the unwanted keypress events. Enter is however both printable and
  37146. // non-printable. One would expect Tab to be as well (but it isn't).
  37147. if (getEventCharCode(nativeEvent) === 0) {
  37148. return null;
  37149. }
  37150. /* falls through */
  37151. case TOP_KEY_DOWN:
  37152. case TOP_KEY_UP:
  37153. EventConstructor = SyntheticKeyboardEvent;
  37154. break;
  37155. case TOP_BLUR:
  37156. case TOP_FOCUS:
  37157. EventConstructor = SyntheticFocusEvent;
  37158. break;
  37159. case TOP_CLICK:
  37160. // Firefox creates a click event on right mouse clicks. This removes the
  37161. // unwanted click events.
  37162. if (nativeEvent.button === 2) {
  37163. return null;
  37164. }
  37165. /* falls through */
  37166. case TOP_AUX_CLICK:
  37167. case TOP_DOUBLE_CLICK:
  37168. case TOP_MOUSE_DOWN:
  37169. case TOP_MOUSE_MOVE:
  37170. case TOP_MOUSE_UP: // TODO: Disabled elements should not respond to mouse events
  37171. /* falls through */
  37172. case TOP_MOUSE_OUT:
  37173. case TOP_MOUSE_OVER:
  37174. case TOP_CONTEXT_MENU:
  37175. EventConstructor = SyntheticMouseEvent;
  37176. break;
  37177. case TOP_DRAG:
  37178. case TOP_DRAG_END:
  37179. case TOP_DRAG_ENTER:
  37180. case TOP_DRAG_EXIT:
  37181. case TOP_DRAG_LEAVE:
  37182. case TOP_DRAG_OVER:
  37183. case TOP_DRAG_START:
  37184. case TOP_DROP:
  37185. EventConstructor = SyntheticDragEvent;
  37186. break;
  37187. case TOP_TOUCH_CANCEL:
  37188. case TOP_TOUCH_END:
  37189. case TOP_TOUCH_MOVE:
  37190. case TOP_TOUCH_START:
  37191. EventConstructor = SyntheticTouchEvent;
  37192. break;
  37193. case TOP_ANIMATION_END:
  37194. case TOP_ANIMATION_ITERATION:
  37195. case TOP_ANIMATION_START:
  37196. EventConstructor = SyntheticAnimationEvent;
  37197. break;
  37198. case TOP_TRANSITION_END:
  37199. EventConstructor = SyntheticTransitionEvent;
  37200. break;
  37201. case TOP_SCROLL:
  37202. EventConstructor = SyntheticUIEvent;
  37203. break;
  37204. case TOP_WHEEL:
  37205. EventConstructor = SyntheticWheelEvent;
  37206. break;
  37207. case TOP_COPY:
  37208. case TOP_CUT:
  37209. case TOP_PASTE:
  37210. EventConstructor = SyntheticClipboardEvent;
  37211. break;
  37212. case TOP_GOT_POINTER_CAPTURE:
  37213. case TOP_LOST_POINTER_CAPTURE:
  37214. case TOP_POINTER_CANCEL:
  37215. case TOP_POINTER_DOWN:
  37216. case TOP_POINTER_MOVE:
  37217. case TOP_POINTER_OUT:
  37218. case TOP_POINTER_OVER:
  37219. case TOP_POINTER_UP:
  37220. EventConstructor = SyntheticPointerEvent;
  37221. break;
  37222. default:
  37223. {
  37224. if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) {
  37225. warningWithoutStack$1(false, 'SimpleEventPlugin: Unhandled event type, `%s`. This warning ' + 'is likely caused by a bug in React. Please file an issue.', topLevelType);
  37226. }
  37227. } // HTML Events
  37228. // @see http://www.w3.org/TR/html5/index.html#events-0
  37229. EventConstructor = SyntheticEvent;
  37230. break;
  37231. }
  37232. var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget);
  37233. accumulateTwoPhaseDispatches(event);
  37234. return event;
  37235. }
  37236. };
  37237. var passiveBrowserEventsSupported = false; // Check if browser support events with passive listeners
  37238. // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
  37239. if (enableFlareAPI && canUseDOM) {
  37240. try {
  37241. var options = {}; // $FlowFixMe: Ignore Flow complaining about needing a value
  37242. Object.defineProperty(options, 'passive', {
  37243. get: function () {
  37244. passiveBrowserEventsSupported = true;
  37245. }
  37246. });
  37247. window.addEventListener('test', options, options);
  37248. window.removeEventListener('test', options, options);
  37249. } catch (e) {
  37250. passiveBrowserEventsSupported = false;
  37251. }
  37252. }
  37253. // Intentionally not named imports because Rollup would use dynamic dispatch for
  37254. // CommonJS interop named imports.
  37255. var UserBlockingPriority$1 = Scheduler.unstable_UserBlockingPriority;
  37256. var runWithPriority$1 = Scheduler.unstable_runWithPriority;
  37257. var getEventPriority = SimpleEventPlugin.getEventPriority;
  37258. var CALLBACK_BOOKKEEPING_POOL_SIZE = 10;
  37259. var callbackBookkeepingPool = [];
  37260. /**
  37261. * Find the deepest React component completely containing the root of the
  37262. * passed-in instance (for use when entire React trees are nested within each
  37263. * other). If React trees are not nested, returns null.
  37264. */
  37265. function findRootContainerNode(inst) {
  37266. if (inst.tag === HostRoot) {
  37267. return inst.stateNode.containerInfo;
  37268. } // TODO: It may be a good idea to cache this to prevent unnecessary DOM
  37269. // traversal, but caching is difficult to do correctly without using a
  37270. // mutation observer to listen for all DOM changes.
  37271. while (inst.return) {
  37272. inst = inst.return;
  37273. }
  37274. if (inst.tag !== HostRoot) {
  37275. // This can happen if we're in a detached tree.
  37276. return null;
  37277. }
  37278. return inst.stateNode.containerInfo;
  37279. } // Used to store ancestor hierarchy in top level callback
  37280. function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags) {
  37281. if (callbackBookkeepingPool.length) {
  37282. var instance = callbackBookkeepingPool.pop();
  37283. instance.topLevelType = topLevelType;
  37284. instance.eventSystemFlags = eventSystemFlags;
  37285. instance.nativeEvent = nativeEvent;
  37286. instance.targetInst = targetInst;
  37287. return instance;
  37288. }
  37289. return {
  37290. topLevelType: topLevelType,
  37291. eventSystemFlags: eventSystemFlags,
  37292. nativeEvent: nativeEvent,
  37293. targetInst: targetInst,
  37294. ancestors: []
  37295. };
  37296. }
  37297. function releaseTopLevelCallbackBookKeeping(instance) {
  37298. instance.topLevelType = null;
  37299. instance.nativeEvent = null;
  37300. instance.targetInst = null;
  37301. instance.ancestors.length = 0;
  37302. if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) {
  37303. callbackBookkeepingPool.push(instance);
  37304. }
  37305. }
  37306. function handleTopLevel(bookKeeping) {
  37307. var targetInst = bookKeeping.targetInst; // Loop through the hierarchy, in case there's any nested components.
  37308. // It's important that we build the array of ancestors before calling any
  37309. // event handlers, because event handlers can modify the DOM, leading to
  37310. // inconsistencies with ReactMount's node cache. See #1105.
  37311. var ancestor = targetInst;
  37312. do {
  37313. if (!ancestor) {
  37314. var ancestors = bookKeeping.ancestors;
  37315. ancestors.push(ancestor);
  37316. break;
  37317. }
  37318. var root = findRootContainerNode(ancestor);
  37319. if (!root) {
  37320. break;
  37321. }
  37322. var tag = ancestor.tag;
  37323. if (tag === HostComponent || tag === HostText) {
  37324. bookKeeping.ancestors.push(ancestor);
  37325. }
  37326. ancestor = getClosestInstanceFromNode(root);
  37327. } while (ancestor);
  37328. for (var i = 0; i < bookKeeping.ancestors.length; i++) {
  37329. targetInst = bookKeeping.ancestors[i];
  37330. var eventTarget = getEventTarget(bookKeeping.nativeEvent);
  37331. var topLevelType = bookKeeping.topLevelType;
  37332. var nativeEvent = bookKeeping.nativeEvent;
  37333. runExtractedPluginEventsInBatch(topLevelType, bookKeeping.eventSystemFlags, targetInst, nativeEvent, eventTarget);
  37334. }
  37335. } // TODO: can we stop exporting these?
  37336. var _enabled = true;
  37337. function setEnabled(enabled) {
  37338. _enabled = !!enabled;
  37339. }
  37340. function isEnabled() {
  37341. return _enabled;
  37342. }
  37343. function trapBubbledEvent(topLevelType, element) {
  37344. trapEventForPluginEventSystem(element, topLevelType, false);
  37345. }
  37346. function trapCapturedEvent(topLevelType, element) {
  37347. trapEventForPluginEventSystem(element, topLevelType, true);
  37348. }
  37349. function trapEventForResponderEventSystem(element, topLevelType, passive) {
  37350. if (enableFlareAPI) {
  37351. var rawEventName = getRawEventName(topLevelType);
  37352. var eventFlags = RESPONDER_EVENT_SYSTEM; // If passive option is not supported, then the event will be
  37353. // active and not passive, but we flag it as using not being
  37354. // supported too. This way the responder event plugins know,
  37355. // and can provide polyfills if needed.
  37356. if (passive) {
  37357. if (passiveBrowserEventsSupported) {
  37358. eventFlags |= IS_PASSIVE;
  37359. } else {
  37360. eventFlags |= IS_ACTIVE;
  37361. eventFlags |= PASSIVE_NOT_SUPPORTED;
  37362. passive = false;
  37363. }
  37364. } else {
  37365. eventFlags |= IS_ACTIVE;
  37366. } // Check if interactive and wrap in discreteUpdates
  37367. var listener = dispatchEvent.bind(null, topLevelType, eventFlags);
  37368. if (passiveBrowserEventsSupported) {
  37369. addEventCaptureListenerWithPassiveFlag(element, rawEventName, listener, passive);
  37370. } else {
  37371. addEventCaptureListener(element, rawEventName, listener);
  37372. }
  37373. }
  37374. }
  37375. function trapEventForPluginEventSystem(element, topLevelType, capture) {
  37376. var listener;
  37377. switch (getEventPriority(topLevelType)) {
  37378. case DiscreteEvent:
  37379. listener = dispatchDiscreteEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM);
  37380. break;
  37381. case UserBlockingEvent:
  37382. listener = dispatchUserBlockingUpdate.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM);
  37383. break;
  37384. case ContinuousEvent:
  37385. default:
  37386. listener = dispatchEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM);
  37387. break;
  37388. }
  37389. var rawEventName = getRawEventName(topLevelType);
  37390. if (capture) {
  37391. addEventCaptureListener(element, rawEventName, listener);
  37392. } else {
  37393. addEventBubbleListener(element, rawEventName, listener);
  37394. }
  37395. }
  37396. function dispatchDiscreteEvent(topLevelType, eventSystemFlags, nativeEvent) {
  37397. flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp);
  37398. discreteUpdates(dispatchEvent, topLevelType, eventSystemFlags, nativeEvent);
  37399. }
  37400. function dispatchUserBlockingUpdate(topLevelType, eventSystemFlags, nativeEvent) {
  37401. if (enableUserBlockingEvents) {
  37402. runWithPriority$1(UserBlockingPriority$1, dispatchEvent.bind(null, topLevelType, eventSystemFlags, nativeEvent));
  37403. } else {
  37404. dispatchEvent(topLevelType, eventSystemFlags, nativeEvent);
  37405. }
  37406. }
  37407. function dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst) {
  37408. var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags);
  37409. try {
  37410. // Event queue being processed in the same cycle allows
  37411. // `preventDefault`.
  37412. batchedEventUpdates(handleTopLevel, bookKeeping);
  37413. } finally {
  37414. releaseTopLevelCallbackBookKeeping(bookKeeping);
  37415. }
  37416. }
  37417. function dispatchEvent(topLevelType, eventSystemFlags, nativeEvent) {
  37418. if (!_enabled) {
  37419. return;
  37420. }
  37421. if (hasQueuedDiscreteEvents() && isReplayableDiscreteEvent(topLevelType)) {
  37422. // If we already have a queue of discrete events, and this is another discrete
  37423. // event, then we can't dispatch it regardless of its target, since they
  37424. // need to dispatch in order.
  37425. queueDiscreteEvent(null, // Flags that we're not actually blocked on anything as far as we know.
  37426. topLevelType, eventSystemFlags, nativeEvent);
  37427. return;
  37428. }
  37429. var blockedOn = attemptToDispatchEvent(topLevelType, eventSystemFlags, nativeEvent);
  37430. if (blockedOn === null) {
  37431. // We successfully dispatched this event.
  37432. clearIfContinuousEvent(topLevelType, nativeEvent);
  37433. return;
  37434. }
  37435. if (isReplayableDiscreteEvent(topLevelType)) {
  37436. // This this to be replayed later once the target is available.
  37437. queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent);
  37438. return;
  37439. }
  37440. if (queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent)) {
  37441. return;
  37442. } // We need to clear only if we didn't queue because
  37443. // queueing is accummulative.
  37444. clearIfContinuousEvent(topLevelType, nativeEvent); // This is not replayable so we'll invoke it but without a target,
  37445. // in case the event system needs to trace it.
  37446. if (enableFlareAPI) {
  37447. if (eventSystemFlags & PLUGIN_EVENT_SYSTEM) {
  37448. dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, null);
  37449. }
  37450. if (eventSystemFlags & RESPONDER_EVENT_SYSTEM) {
  37451. // React Flare event system
  37452. dispatchEventForResponderEventSystem(topLevelType, null, nativeEvent, getEventTarget(nativeEvent), eventSystemFlags);
  37453. }
  37454. } else {
  37455. dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, null);
  37456. }
  37457. } // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked.
  37458. function attemptToDispatchEvent(topLevelType, eventSystemFlags, nativeEvent) {
  37459. // TODO: Warn if _enabled is false.
  37460. var nativeEventTarget = getEventTarget(nativeEvent);
  37461. var targetInst = getClosestInstanceFromNode(nativeEventTarget);
  37462. if (targetInst !== null) {
  37463. var nearestMounted = getNearestMountedFiber(targetInst);
  37464. if (nearestMounted === null) {
  37465. // This tree has been unmounted already. Dispatch without a target.
  37466. targetInst = null;
  37467. } else {
  37468. var tag = nearestMounted.tag;
  37469. if (tag === SuspenseComponent) {
  37470. var instance = getSuspenseInstanceFromFiber(nearestMounted);
  37471. if (instance !== null) {
  37472. // Queue the event to be replayed later. Abort dispatching since we
  37473. // don't want this event dispatched twice through the event system.
  37474. // TODO: If this is the first discrete event in the queue. Schedule an increased
  37475. // priority for this boundary.
  37476. return instance;
  37477. } // This shouldn't happen, something went wrong but to avoid blocking
  37478. // the whole system, dispatch the event without a target.
  37479. // TODO: Warn.
  37480. targetInst = null;
  37481. } else if (tag === HostRoot) {
  37482. var root = nearestMounted.stateNode;
  37483. if (root.hydrate) {
  37484. // If this happens during a replay something went wrong and it might block
  37485. // the whole system.
  37486. return getContainerFromFiber(nearestMounted);
  37487. }
  37488. targetInst = null;
  37489. } else if (nearestMounted !== targetInst) {
  37490. // If we get an event (ex: img onload) before committing that
  37491. // component's mount, ignore it for now (that is, treat it as if it was an
  37492. // event on a non-React tree). We might also consider queueing events and
  37493. // dispatching them after the mount.
  37494. targetInst = null;
  37495. }
  37496. }
  37497. }
  37498. if (enableFlareAPI) {
  37499. if (eventSystemFlags & PLUGIN_EVENT_SYSTEM) {
  37500. dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst);
  37501. }
  37502. if (eventSystemFlags & RESPONDER_EVENT_SYSTEM) {
  37503. // React Flare event system
  37504. dispatchEventForResponderEventSystem(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
  37505. }
  37506. } else {
  37507. dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst);
  37508. } // We're not blocked on anything.
  37509. return null;
  37510. }
  37511. /**
  37512. * Checks if an event is supported in the current execution environment.
  37513. *
  37514. * NOTE: This will not work correctly for non-generic events such as `change`,
  37515. * `reset`, `load`, `error`, and `select`.
  37516. *
  37517. * Borrows from Modernizr.
  37518. *
  37519. * @param {string} eventNameSuffix Event name, e.g. "click".
  37520. * @return {boolean} True if the event is supported.
  37521. * @internal
  37522. * @license Modernizr 3.0.0pre (Custom Build) | MIT
  37523. */
  37524. function isEventSupported(eventNameSuffix) {
  37525. if (!canUseDOM) {
  37526. return false;
  37527. }
  37528. var eventName = 'on' + eventNameSuffix;
  37529. var isSupported = eventName in document;
  37530. if (!isSupported) {
  37531. var element = document.createElement('div');
  37532. element.setAttribute(eventName, 'return;');
  37533. isSupported = typeof element[eventName] === 'function';
  37534. }
  37535. return isSupported;
  37536. }
  37537. /**
  37538. * Summary of `ReactBrowserEventEmitter` event handling:
  37539. *
  37540. * - Top-level delegation is used to trap most native browser events. This
  37541. * may only occur in the main thread and is the responsibility of
  37542. * ReactDOMEventListener, which is injected and can therefore support
  37543. * pluggable event sources. This is the only work that occurs in the main
  37544. * thread.
  37545. *
  37546. * - We normalize and de-duplicate events to account for browser quirks. This
  37547. * may be done in the worker thread.
  37548. *
  37549. * - Forward these native events (with the associated top-level type used to
  37550. * trap it) to `EventPluginHub`, which in turn will ask plugins if they want
  37551. * to extract any synthetic events.
  37552. *
  37553. * - The `EventPluginHub` will then process each event by annotating them with
  37554. * "dispatches", a sequence of listeners and IDs that care about that event.
  37555. *
  37556. * - The `EventPluginHub` then dispatches the events.
  37557. *
  37558. * Overview of React and the event system:
  37559. *
  37560. * +------------+ .
  37561. * | DOM | .
  37562. * +------------+ .
  37563. * | .
  37564. * v .
  37565. * +------------+ .
  37566. * | ReactEvent | .
  37567. * | Listener | .
  37568. * +------------+ . +-----------+
  37569. * | . +--------+|SimpleEvent|
  37570. * | . | |Plugin |
  37571. * +-----|------+ . v +-----------+
  37572. * | | | . +--------------+ +------------+
  37573. * | +-----------.--->|EventPluginHub| | Event |
  37574. * | | . | | +-----------+ | Propagators|
  37575. * | ReactEvent | . | | |TapEvent | |------------|
  37576. * | Emitter | . | |<---+|Plugin | |other plugin|
  37577. * | | . | | +-----------+ | utilities |
  37578. * | +-----------.--->| | +------------+
  37579. * | | | . +--------------+
  37580. * +-----|------+ . ^ +-----------+
  37581. * | . | |Enter/Leave|
  37582. * + . +-------+|Plugin |
  37583. * +-------------+ . +-----------+
  37584. * | application | .
  37585. * |-------------| .
  37586. * | | .
  37587. * | | .
  37588. * +-------------+ .
  37589. * .
  37590. * React Core . General Purpose Event Plugin System
  37591. */
  37592. var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
  37593. var elementListeningSets = new PossiblyWeakMap();
  37594. function getListeningSetForElement(element) {
  37595. var listeningSet = elementListeningSets.get(element);
  37596. if (listeningSet === undefined) {
  37597. listeningSet = new Set();
  37598. elementListeningSets.set(element, listeningSet);
  37599. }
  37600. return listeningSet;
  37601. }
  37602. /**
  37603. * We listen for bubbled touch events on the document object.
  37604. *
  37605. * Firefox v8.01 (and possibly others) exhibited strange behavior when
  37606. * mounting `onmousemove` events at some node that was not the document
  37607. * element. The symptoms were that if your mouse is not moving over something
  37608. * contained within that mount point (for example on the background) the
  37609. * top-level listeners for `onmousemove` won't be called. However, if you
  37610. * register the `mousemove` on the document object, then it will of course
  37611. * catch all `mousemove`s. This along with iOS quirks, justifies restricting
  37612. * top-level listeners to the document object only, at least for these
  37613. * movement types of events and possibly all events.
  37614. *
  37615. * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  37616. *
  37617. * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
  37618. * they bubble to document.
  37619. *
  37620. * @param {string} registrationName Name of listener (e.g. `onClick`).
  37621. * @param {object} mountAt Container where to mount the listener
  37622. */
  37623. function listenTo(registrationName, mountAt) {
  37624. var listeningSet = getListeningSetForElement(mountAt);
  37625. var dependencies = registrationNameDependencies[registrationName];
  37626. for (var i = 0; i < dependencies.length; i++) {
  37627. var dependency = dependencies[i];
  37628. listenToTopLevel(dependency, mountAt, listeningSet);
  37629. }
  37630. }
  37631. function listenToTopLevel(topLevelType, mountAt, listeningSet) {
  37632. if (!listeningSet.has(topLevelType)) {
  37633. switch (topLevelType) {
  37634. case TOP_SCROLL:
  37635. trapCapturedEvent(TOP_SCROLL, mountAt);
  37636. break;
  37637. case TOP_FOCUS:
  37638. case TOP_BLUR:
  37639. trapCapturedEvent(TOP_FOCUS, mountAt);
  37640. trapCapturedEvent(TOP_BLUR, mountAt); // We set the flag for a single dependency later in this function,
  37641. // but this ensures we mark both as attached rather than just one.
  37642. listeningSet.add(TOP_BLUR);
  37643. listeningSet.add(TOP_FOCUS);
  37644. break;
  37645. case TOP_CANCEL:
  37646. case TOP_CLOSE:
  37647. if (isEventSupported(getRawEventName(topLevelType))) {
  37648. trapCapturedEvent(topLevelType, mountAt);
  37649. }
  37650. break;
  37651. case TOP_INVALID:
  37652. case TOP_SUBMIT:
  37653. case TOP_RESET:
  37654. // We listen to them on the target DOM elements.
  37655. // Some of them bubble so we don't want them to fire twice.
  37656. break;
  37657. default:
  37658. // By default, listen on the top level to all non-media events.
  37659. // Media events don't bubble so adding the listener wouldn't do anything.
  37660. var isMediaEvent = mediaEventTypes.indexOf(topLevelType) !== -1;
  37661. if (!isMediaEvent) {
  37662. trapBubbledEvent(topLevelType, mountAt);
  37663. }
  37664. break;
  37665. }
  37666. listeningSet.add(topLevelType);
  37667. }
  37668. }
  37669. function isListeningToAllDependencies(registrationName, mountAt) {
  37670. var listeningSet = getListeningSetForElement(mountAt);
  37671. var dependencies = registrationNameDependencies[registrationName];
  37672. for (var i = 0; i < dependencies.length; i++) {
  37673. var dependency = dependencies[i];
  37674. if (!listeningSet.has(dependency)) {
  37675. return false;
  37676. }
  37677. }
  37678. return true;
  37679. }
  37680. // List derived from Gecko source code:
  37681. // https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js
  37682. var shorthandToLonghand = {
  37683. animation: ['animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction'],
  37684. background: ['backgroundAttachment', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundSize'],
  37685. backgroundPosition: ['backgroundPositionX', 'backgroundPositionY'],
  37686. border: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderTopColor', 'borderTopStyle', 'borderTopWidth'],
  37687. borderBlockEnd: ['borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth'],
  37688. borderBlockStart: ['borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth'],
  37689. borderBottom: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth'],
  37690. borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'],
  37691. borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'],
  37692. borderInlineEnd: ['borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth'],
  37693. borderInlineStart: ['borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth'],
  37694. borderLeft: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth'],
  37695. borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'],
  37696. borderRight: ['borderRightColor', 'borderRightStyle', 'borderRightWidth'],
  37697. borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'],
  37698. borderTop: ['borderTopColor', 'borderTopStyle', 'borderTopWidth'],
  37699. borderWidth: ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth'],
  37700. columnRule: ['columnRuleColor', 'columnRuleStyle', 'columnRuleWidth'],
  37701. columns: ['columnCount', 'columnWidth'],
  37702. flex: ['flexBasis', 'flexGrow', 'flexShrink'],
  37703. flexFlow: ['flexDirection', 'flexWrap'],
  37704. font: ['fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontLanguageOverride', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition', 'fontWeight', 'lineHeight'],
  37705. fontVariant: ['fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition'],
  37706. gap: ['columnGap', 'rowGap'],
  37707. grid: ['gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'],
  37708. gridArea: ['gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart'],
  37709. gridColumn: ['gridColumnEnd', 'gridColumnStart'],
  37710. gridColumnGap: ['columnGap'],
  37711. gridGap: ['columnGap', 'rowGap'],
  37712. gridRow: ['gridRowEnd', 'gridRowStart'],
  37713. gridRowGap: ['rowGap'],
  37714. gridTemplate: ['gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'],
  37715. listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'],
  37716. margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'],
  37717. marker: ['markerEnd', 'markerMid', 'markerStart'],
  37718. mask: ['maskClip', 'maskComposite', 'maskImage', 'maskMode', 'maskOrigin', 'maskPositionX', 'maskPositionY', 'maskRepeat', 'maskSize'],
  37719. maskPosition: ['maskPositionX', 'maskPositionY'],
  37720. outline: ['outlineColor', 'outlineStyle', 'outlineWidth'],
  37721. overflow: ['overflowX', 'overflowY'],
  37722. padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'],
  37723. placeContent: ['alignContent', 'justifyContent'],
  37724. placeItems: ['alignItems', 'justifyItems'],
  37725. placeSelf: ['alignSelf', 'justifySelf'],
  37726. textDecoration: ['textDecorationColor', 'textDecorationLine', 'textDecorationStyle'],
  37727. textEmphasis: ['textEmphasisColor', 'textEmphasisStyle'],
  37728. transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'],
  37729. wordWrap: ['overflowWrap']
  37730. };
  37731. /**
  37732. * CSS properties which accept numbers but are not in units of "px".
  37733. */
  37734. var isUnitlessNumber = {
  37735. animationIterationCount: true,
  37736. borderImageOutset: true,
  37737. borderImageSlice: true,
  37738. borderImageWidth: true,
  37739. boxFlex: true,
  37740. boxFlexGroup: true,
  37741. boxOrdinalGroup: true,
  37742. columnCount: true,
  37743. columns: true,
  37744. flex: true,
  37745. flexGrow: true,
  37746. flexPositive: true,
  37747. flexShrink: true,
  37748. flexNegative: true,
  37749. flexOrder: true,
  37750. gridArea: true,
  37751. gridRow: true,
  37752. gridRowEnd: true,
  37753. gridRowSpan: true,
  37754. gridRowStart: true,
  37755. gridColumn: true,
  37756. gridColumnEnd: true,
  37757. gridColumnSpan: true,
  37758. gridColumnStart: true,
  37759. fontWeight: true,
  37760. lineClamp: true,
  37761. lineHeight: true,
  37762. opacity: true,
  37763. order: true,
  37764. orphans: true,
  37765. tabSize: true,
  37766. widows: true,
  37767. zIndex: true,
  37768. zoom: true,
  37769. // SVG-related properties
  37770. fillOpacity: true,
  37771. floodOpacity: true,
  37772. stopOpacity: true,
  37773. strokeDasharray: true,
  37774. strokeDashoffset: true,
  37775. strokeMiterlimit: true,
  37776. strokeOpacity: true,
  37777. strokeWidth: true
  37778. };
  37779. /**
  37780. * @param {string} prefix vendor-specific prefix, eg: Webkit
  37781. * @param {string} key style name, eg: transitionDuration
  37782. * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
  37783. * WebkitTransitionDuration
  37784. */
  37785. function prefixKey(prefix, key) {
  37786. return prefix + key.charAt(0).toUpperCase() + key.substring(1);
  37787. }
  37788. /**
  37789. * Support style names that may come passed in prefixed by adding permutations
  37790. * of vendor prefixes.
  37791. */
  37792. var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
  37793. // infinite loop, because it iterates over the newly added props too.
  37794. Object.keys(isUnitlessNumber).forEach(function (prop) {
  37795. prefixes.forEach(function (prefix) {
  37796. isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
  37797. });
  37798. });
  37799. /**
  37800. * Convert a value into the proper css writable value. The style name `name`
  37801. * should be logical (no hyphens), as specified
  37802. * in `CSSProperty.isUnitlessNumber`.
  37803. *
  37804. * @param {string} name CSS property name such as `topMargin`.
  37805. * @param {*} value CSS property value such as `10px`.
  37806. * @return {string} Normalized style value with dimensions applied.
  37807. */
  37808. function dangerousStyleValue(name, value, isCustomProperty) {
  37809. // Note that we've removed escapeTextForBrowser() calls here since the
  37810. // whole string will be escaped when the attribute is injected into
  37811. // the markup. If you provide unsafe user data here they can inject
  37812. // arbitrary CSS which may be problematic (I couldn't repro this):
  37813. // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
  37814. // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
  37815. // This is not an XSS hole but instead a potential CSS injection issue
  37816. // which has lead to a greater discussion about how we're going to
  37817. // trust URLs moving forward. See #2115901
  37818. var isEmpty = value == null || typeof value === 'boolean' || value === '';
  37819. if (isEmpty) {
  37820. return '';
  37821. }
  37822. if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
  37823. return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
  37824. }
  37825. return ('' + value).trim();
  37826. }
  37827. var uppercasePattern = /([A-Z])/g;
  37828. var msPattern = /^ms-/;
  37829. /**
  37830. * Hyphenates a camelcased CSS property name, for example:
  37831. *
  37832. * > hyphenateStyleName('backgroundColor')
  37833. * < "background-color"
  37834. * > hyphenateStyleName('MozTransition')
  37835. * < "-moz-transition"
  37836. * > hyphenateStyleName('msTransition')
  37837. * < "-ms-transition"
  37838. *
  37839. * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
  37840. * is converted to `-ms-`.
  37841. */
  37842. function hyphenateStyleName(name) {
  37843. return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-');
  37844. }
  37845. var warnValidStyle = function () {};
  37846. {
  37847. // 'msTransform' is correct, but the other prefixes should be capitalized
  37848. var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
  37849. var msPattern$1 = /^-ms-/;
  37850. var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon
  37851. var badStyleValueWithSemicolonPattern = /;\s*$/;
  37852. var warnedStyleNames = {};
  37853. var warnedStyleValues = {};
  37854. var warnedForNaNValue = false;
  37855. var warnedForInfinityValue = false;
  37856. var camelize = function (string) {
  37857. return string.replace(hyphenPattern, function (_, character) {
  37858. return character.toUpperCase();
  37859. });
  37860. };
  37861. var warnHyphenatedStyleName = function (name) {
  37862. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  37863. return;
  37864. }
  37865. warnedStyleNames[name] = true;
  37866. warning$1(false, 'Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests
  37867. // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
  37868. // is converted to lowercase `ms`.
  37869. camelize(name.replace(msPattern$1, 'ms-')));
  37870. };
  37871. var warnBadVendoredStyleName = function (name) {
  37872. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  37873. return;
  37874. }
  37875. warnedStyleNames[name] = true;
  37876. warning$1(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1));
  37877. };
  37878. var warnStyleValueWithSemicolon = function (name, value) {
  37879. if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
  37880. return;
  37881. }
  37882. warnedStyleValues[value] = true;
  37883. warning$1(false, "Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ''));
  37884. };
  37885. var warnStyleValueIsNaN = function (name, value) {
  37886. if (warnedForNaNValue) {
  37887. return;
  37888. }
  37889. warnedForNaNValue = true;
  37890. warning$1(false, '`NaN` is an invalid value for the `%s` css style property.', name);
  37891. };
  37892. var warnStyleValueIsInfinity = function (name, value) {
  37893. if (warnedForInfinityValue) {
  37894. return;
  37895. }
  37896. warnedForInfinityValue = true;
  37897. warning$1(false, '`Infinity` is an invalid value for the `%s` css style property.', name);
  37898. };
  37899. warnValidStyle = function (name, value) {
  37900. if (name.indexOf('-') > -1) {
  37901. warnHyphenatedStyleName(name);
  37902. } else if (badVendoredStyleNamePattern.test(name)) {
  37903. warnBadVendoredStyleName(name);
  37904. } else if (badStyleValueWithSemicolonPattern.test(value)) {
  37905. warnStyleValueWithSemicolon(name, value);
  37906. }
  37907. if (typeof value === 'number') {
  37908. if (isNaN(value)) {
  37909. warnStyleValueIsNaN(name, value);
  37910. } else if (!isFinite(value)) {
  37911. warnStyleValueIsInfinity(name, value);
  37912. }
  37913. }
  37914. };
  37915. }
  37916. var warnValidStyle$1 = warnValidStyle;
  37917. /**
  37918. * Operations for dealing with CSS properties.
  37919. */
  37920. /**
  37921. * This creates a string that is expected to be equivalent to the style
  37922. * attribute generated by server-side rendering. It by-passes warnings and
  37923. * security checks so it's not safe to use this value for anything other than
  37924. * comparison. It is only used in DEV for SSR validation.
  37925. */
  37926. function createDangerousStringForStyles(styles) {
  37927. {
  37928. var serialized = '';
  37929. var delimiter = '';
  37930. for (var styleName in styles) {
  37931. if (!styles.hasOwnProperty(styleName)) {
  37932. continue;
  37933. }
  37934. var styleValue = styles[styleName];
  37935. if (styleValue != null) {
  37936. var isCustomProperty = styleName.indexOf('--') === 0;
  37937. serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':';
  37938. serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
  37939. delimiter = ';';
  37940. }
  37941. }
  37942. return serialized || null;
  37943. }
  37944. }
  37945. /**
  37946. * Sets the value for multiple styles on a node. If a value is specified as
  37947. * '' (empty string), the corresponding style property will be unset.
  37948. *
  37949. * @param {DOMElement} node
  37950. * @param {object} styles
  37951. */
  37952. function setValueForStyles(node, styles) {
  37953. var style = node.style;
  37954. for (var styleName in styles) {
  37955. if (!styles.hasOwnProperty(styleName)) {
  37956. continue;
  37957. }
  37958. var isCustomProperty = styleName.indexOf('--') === 0;
  37959. {
  37960. if (!isCustomProperty) {
  37961. warnValidStyle$1(styleName, styles[styleName]);
  37962. }
  37963. }
  37964. var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
  37965. if (styleName === 'float') {
  37966. styleName = 'cssFloat';
  37967. }
  37968. if (isCustomProperty) {
  37969. style.setProperty(styleName, styleValue);
  37970. } else {
  37971. style[styleName] = styleValue;
  37972. }
  37973. }
  37974. }
  37975. function isValueEmpty(value) {
  37976. return value == null || typeof value === 'boolean' || value === '';
  37977. }
  37978. /**
  37979. * Given {color: 'red', overflow: 'hidden'} returns {
  37980. * color: 'color',
  37981. * overflowX: 'overflow',
  37982. * overflowY: 'overflow',
  37983. * }. This can be read as "the overflowY property was set by the overflow
  37984. * shorthand". That is, the values are the property that each was derived from.
  37985. */
  37986. function expandShorthandMap(styles) {
  37987. var expanded = {};
  37988. for (var key in styles) {
  37989. var longhands = shorthandToLonghand[key] || [key];
  37990. for (var i = 0; i < longhands.length; i++) {
  37991. expanded[longhands[i]] = key;
  37992. }
  37993. }
  37994. return expanded;
  37995. }
  37996. /**
  37997. * When mixing shorthand and longhand property names, we warn during updates if
  37998. * we expect an incorrect result to occur. In particular, we warn for:
  37999. *
  38000. * Updating a shorthand property (longhand gets overwritten):
  38001. * {font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'}
  38002. * becomes .style.font = 'baz'
  38003. * Removing a shorthand property (longhand gets lost too):
  38004. * {font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'}
  38005. * becomes .style.font = ''
  38006. * Removing a longhand property (should revert to shorthand; doesn't):
  38007. * {font: 'foo', fontVariant: 'bar'} -> {font: 'foo'}
  38008. * becomes .style.fontVariant = ''
  38009. */
  38010. function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) {
  38011. if (!warnAboutShorthandPropertyCollision) {
  38012. return;
  38013. }
  38014. if (!nextStyles) {
  38015. return;
  38016. }
  38017. var expandedUpdates = expandShorthandMap(styleUpdates);
  38018. var expandedStyles = expandShorthandMap(nextStyles);
  38019. var warnedAbout = {};
  38020. for (var key in expandedUpdates) {
  38021. var originalKey = expandedUpdates[key];
  38022. var correctOriginalKey = expandedStyles[key];
  38023. if (correctOriginalKey && originalKey !== correctOriginalKey) {
  38024. var warningKey = originalKey + ',' + correctOriginalKey;
  38025. if (warnedAbout[warningKey]) {
  38026. continue;
  38027. }
  38028. warnedAbout[warningKey] = true;
  38029. warning$1(false, '%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);
  38030. }
  38031. }
  38032. }
  38033. // For HTML, certain tags should omit their close tag. We keep a whitelist for
  38034. // those special-case tags.
  38035. var omittedCloseTags = {
  38036. area: true,
  38037. base: true,
  38038. br: true,
  38039. col: true,
  38040. embed: true,
  38041. hr: true,
  38042. img: true,
  38043. input: true,
  38044. keygen: true,
  38045. link: true,
  38046. meta: true,
  38047. param: true,
  38048. source: true,
  38049. track: true,
  38050. wbr: true // NOTE: menuitem's close tag should be omitted, but that causes problems.
  38051. };
  38052. // `omittedCloseTags` except that `menuitem` should still have its closing tag.
  38053. var voidElementTags = _assign({
  38054. menuitem: true
  38055. }, omittedCloseTags);
  38056. // or add stack by default to invariants where possible.
  38057. var HTML$1 = '__html';
  38058. var ReactDebugCurrentFrame$3 = null;
  38059. {
  38060. ReactDebugCurrentFrame$3 = ReactSharedInternals.ReactDebugCurrentFrame;
  38061. }
  38062. function assertValidProps(tag, props) {
  38063. if (!props) {
  38064. return;
  38065. } // Note the use of `==` which checks for null or undefined.
  38066. if (voidElementTags[tag]) {
  38067. (function () {
  38068. if (!(props.children == null && props.dangerouslySetInnerHTML == null)) {
  38069. {
  38070. throw ReactError(Error(tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`." + (ReactDebugCurrentFrame$3.getStackAddendum())));
  38071. }
  38072. }
  38073. })();
  38074. }
  38075. if (props.dangerouslySetInnerHTML != null) {
  38076. (function () {
  38077. if (!(props.children == null)) {
  38078. {
  38079. throw ReactError(Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`."));
  38080. }
  38081. }
  38082. })();
  38083. (function () {
  38084. if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML$1 in props.dangerouslySetInnerHTML)) {
  38085. {
  38086. throw ReactError(Error("`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information."));
  38087. }
  38088. }
  38089. })();
  38090. }
  38091. {
  38092. !(props.suppressContentEditableWarning || !props.contentEditable || props.children == null) ? warning$1(false, '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.') : void 0;
  38093. }
  38094. (function () {
  38095. if (!(props.style == null || typeof props.style === 'object')) {
  38096. {
  38097. throw ReactError(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())));
  38098. }
  38099. }
  38100. })();
  38101. }
  38102. function isCustomComponent(tagName, props) {
  38103. if (tagName.indexOf('-') === -1) {
  38104. return typeof props.is === 'string';
  38105. }
  38106. switch (tagName) {
  38107. // These are reserved SVG and MathML elements.
  38108. // We don't mind this whitelist too much because we expect it to never grow.
  38109. // The alternative is to track the namespace in a few places which is convoluted.
  38110. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
  38111. case 'annotation-xml':
  38112. case 'color-profile':
  38113. case 'font-face':
  38114. case 'font-face-src':
  38115. case 'font-face-uri':
  38116. case 'font-face-format':
  38117. case 'font-face-name':
  38118. case 'missing-glyph':
  38119. return false;
  38120. default:
  38121. return true;
  38122. }
  38123. }
  38124. // When adding attributes to the HTML or SVG whitelist, be sure to
  38125. // also add them to this module to ensure casing and incorrect name
  38126. // warnings.
  38127. var possibleStandardNames = {
  38128. // HTML
  38129. accept: 'accept',
  38130. acceptcharset: 'acceptCharset',
  38131. 'accept-charset': 'acceptCharset',
  38132. accesskey: 'accessKey',
  38133. action: 'action',
  38134. allowfullscreen: 'allowFullScreen',
  38135. alt: 'alt',
  38136. as: 'as',
  38137. async: 'async',
  38138. autocapitalize: 'autoCapitalize',
  38139. autocomplete: 'autoComplete',
  38140. autocorrect: 'autoCorrect',
  38141. autofocus: 'autoFocus',
  38142. autoplay: 'autoPlay',
  38143. autosave: 'autoSave',
  38144. capture: 'capture',
  38145. cellpadding: 'cellPadding',
  38146. cellspacing: 'cellSpacing',
  38147. challenge: 'challenge',
  38148. charset: 'charSet',
  38149. checked: 'checked',
  38150. children: 'children',
  38151. cite: 'cite',
  38152. class: 'className',
  38153. classid: 'classID',
  38154. classname: 'className',
  38155. cols: 'cols',
  38156. colspan: 'colSpan',
  38157. content: 'content',
  38158. contenteditable: 'contentEditable',
  38159. contextmenu: 'contextMenu',
  38160. controls: 'controls',
  38161. controlslist: 'controlsList',
  38162. coords: 'coords',
  38163. crossorigin: 'crossOrigin',
  38164. dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
  38165. data: 'data',
  38166. datetime: 'dateTime',
  38167. default: 'default',
  38168. defaultchecked: 'defaultChecked',
  38169. defaultvalue: 'defaultValue',
  38170. defer: 'defer',
  38171. dir: 'dir',
  38172. disabled: 'disabled',
  38173. disablepictureinpicture: 'disablePictureInPicture',
  38174. download: 'download',
  38175. draggable: 'draggable',
  38176. enctype: 'encType',
  38177. for: 'htmlFor',
  38178. form: 'form',
  38179. formmethod: 'formMethod',
  38180. formaction: 'formAction',
  38181. formenctype: 'formEncType',
  38182. formnovalidate: 'formNoValidate',
  38183. formtarget: 'formTarget',
  38184. frameborder: 'frameBorder',
  38185. headers: 'headers',
  38186. height: 'height',
  38187. hidden: 'hidden',
  38188. high: 'high',
  38189. href: 'href',
  38190. hreflang: 'hrefLang',
  38191. htmlfor: 'htmlFor',
  38192. httpequiv: 'httpEquiv',
  38193. 'http-equiv': 'httpEquiv',
  38194. icon: 'icon',
  38195. id: 'id',
  38196. innerhtml: 'innerHTML',
  38197. inputmode: 'inputMode',
  38198. integrity: 'integrity',
  38199. is: 'is',
  38200. itemid: 'itemID',
  38201. itemprop: 'itemProp',
  38202. itemref: 'itemRef',
  38203. itemscope: 'itemScope',
  38204. itemtype: 'itemType',
  38205. keyparams: 'keyParams',
  38206. keytype: 'keyType',
  38207. kind: 'kind',
  38208. label: 'label',
  38209. lang: 'lang',
  38210. list: 'list',
  38211. loop: 'loop',
  38212. low: 'low',
  38213. manifest: 'manifest',
  38214. marginwidth: 'marginWidth',
  38215. marginheight: 'marginHeight',
  38216. max: 'max',
  38217. maxlength: 'maxLength',
  38218. media: 'media',
  38219. mediagroup: 'mediaGroup',
  38220. method: 'method',
  38221. min: 'min',
  38222. minlength: 'minLength',
  38223. multiple: 'multiple',
  38224. muted: 'muted',
  38225. name: 'name',
  38226. nomodule: 'noModule',
  38227. nonce: 'nonce',
  38228. novalidate: 'noValidate',
  38229. open: 'open',
  38230. optimum: 'optimum',
  38231. pattern: 'pattern',
  38232. placeholder: 'placeholder',
  38233. playsinline: 'playsInline',
  38234. poster: 'poster',
  38235. preload: 'preload',
  38236. profile: 'profile',
  38237. radiogroup: 'radioGroup',
  38238. readonly: 'readOnly',
  38239. referrerpolicy: 'referrerPolicy',
  38240. rel: 'rel',
  38241. required: 'required',
  38242. reversed: 'reversed',
  38243. role: 'role',
  38244. rows: 'rows',
  38245. rowspan: 'rowSpan',
  38246. sandbox: 'sandbox',
  38247. scope: 'scope',
  38248. scoped: 'scoped',
  38249. scrolling: 'scrolling',
  38250. seamless: 'seamless',
  38251. selected: 'selected',
  38252. shape: 'shape',
  38253. size: 'size',
  38254. sizes: 'sizes',
  38255. span: 'span',
  38256. spellcheck: 'spellCheck',
  38257. src: 'src',
  38258. srcdoc: 'srcDoc',
  38259. srclang: 'srcLang',
  38260. srcset: 'srcSet',
  38261. start: 'start',
  38262. step: 'step',
  38263. style: 'style',
  38264. summary: 'summary',
  38265. tabindex: 'tabIndex',
  38266. target: 'target',
  38267. title: 'title',
  38268. type: 'type',
  38269. usemap: 'useMap',
  38270. value: 'value',
  38271. width: 'width',
  38272. wmode: 'wmode',
  38273. wrap: 'wrap',
  38274. // SVG
  38275. about: 'about',
  38276. accentheight: 'accentHeight',
  38277. 'accent-height': 'accentHeight',
  38278. accumulate: 'accumulate',
  38279. additive: 'additive',
  38280. alignmentbaseline: 'alignmentBaseline',
  38281. 'alignment-baseline': 'alignmentBaseline',
  38282. allowreorder: 'allowReorder',
  38283. alphabetic: 'alphabetic',
  38284. amplitude: 'amplitude',
  38285. arabicform: 'arabicForm',
  38286. 'arabic-form': 'arabicForm',
  38287. ascent: 'ascent',
  38288. attributename: 'attributeName',
  38289. attributetype: 'attributeType',
  38290. autoreverse: 'autoReverse',
  38291. azimuth: 'azimuth',
  38292. basefrequency: 'baseFrequency',
  38293. baselineshift: 'baselineShift',
  38294. 'baseline-shift': 'baselineShift',
  38295. baseprofile: 'baseProfile',
  38296. bbox: 'bbox',
  38297. begin: 'begin',
  38298. bias: 'bias',
  38299. by: 'by',
  38300. calcmode: 'calcMode',
  38301. capheight: 'capHeight',
  38302. 'cap-height': 'capHeight',
  38303. clip: 'clip',
  38304. clippath: 'clipPath',
  38305. 'clip-path': 'clipPath',
  38306. clippathunits: 'clipPathUnits',
  38307. cliprule: 'clipRule',
  38308. 'clip-rule': 'clipRule',
  38309. color: 'color',
  38310. colorinterpolation: 'colorInterpolation',
  38311. 'color-interpolation': 'colorInterpolation',
  38312. colorinterpolationfilters: 'colorInterpolationFilters',
  38313. 'color-interpolation-filters': 'colorInterpolationFilters',
  38314. colorprofile: 'colorProfile',
  38315. 'color-profile': 'colorProfile',
  38316. colorrendering: 'colorRendering',
  38317. 'color-rendering': 'colorRendering',
  38318. contentscripttype: 'contentScriptType',
  38319. contentstyletype: 'contentStyleType',
  38320. cursor: 'cursor',
  38321. cx: 'cx',
  38322. cy: 'cy',
  38323. d: 'd',
  38324. datatype: 'datatype',
  38325. decelerate: 'decelerate',
  38326. descent: 'descent',
  38327. diffuseconstant: 'diffuseConstant',
  38328. direction: 'direction',
  38329. display: 'display',
  38330. divisor: 'divisor',
  38331. dominantbaseline: 'dominantBaseline',
  38332. 'dominant-baseline': 'dominantBaseline',
  38333. dur: 'dur',
  38334. dx: 'dx',
  38335. dy: 'dy',
  38336. edgemode: 'edgeMode',
  38337. elevation: 'elevation',
  38338. enablebackground: 'enableBackground',
  38339. 'enable-background': 'enableBackground',
  38340. end: 'end',
  38341. exponent: 'exponent',
  38342. externalresourcesrequired: 'externalResourcesRequired',
  38343. fill: 'fill',
  38344. fillopacity: 'fillOpacity',
  38345. 'fill-opacity': 'fillOpacity',
  38346. fillrule: 'fillRule',
  38347. 'fill-rule': 'fillRule',
  38348. filter: 'filter',
  38349. filterres: 'filterRes',
  38350. filterunits: 'filterUnits',
  38351. floodopacity: 'floodOpacity',
  38352. 'flood-opacity': 'floodOpacity',
  38353. floodcolor: 'floodColor',
  38354. 'flood-color': 'floodColor',
  38355. focusable: 'focusable',
  38356. fontfamily: 'fontFamily',
  38357. 'font-family': 'fontFamily',
  38358. fontsize: 'fontSize',
  38359. 'font-size': 'fontSize',
  38360. fontsizeadjust: 'fontSizeAdjust',
  38361. 'font-size-adjust': 'fontSizeAdjust',
  38362. fontstretch: 'fontStretch',
  38363. 'font-stretch': 'fontStretch',
  38364. fontstyle: 'fontStyle',
  38365. 'font-style': 'fontStyle',
  38366. fontvariant: 'fontVariant',
  38367. 'font-variant': 'fontVariant',
  38368. fontweight: 'fontWeight',
  38369. 'font-weight': 'fontWeight',
  38370. format: 'format',
  38371. from: 'from',
  38372. fx: 'fx',
  38373. fy: 'fy',
  38374. g1: 'g1',
  38375. g2: 'g2',
  38376. glyphname: 'glyphName',
  38377. 'glyph-name': 'glyphName',
  38378. glyphorientationhorizontal: 'glyphOrientationHorizontal',
  38379. 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
  38380. glyphorientationvertical: 'glyphOrientationVertical',
  38381. 'glyph-orientation-vertical': 'glyphOrientationVertical',
  38382. glyphref: 'glyphRef',
  38383. gradienttransform: 'gradientTransform',
  38384. gradientunits: 'gradientUnits',
  38385. hanging: 'hanging',
  38386. horizadvx: 'horizAdvX',
  38387. 'horiz-adv-x': 'horizAdvX',
  38388. horizoriginx: 'horizOriginX',
  38389. 'horiz-origin-x': 'horizOriginX',
  38390. ideographic: 'ideographic',
  38391. imagerendering: 'imageRendering',
  38392. 'image-rendering': 'imageRendering',
  38393. in2: 'in2',
  38394. in: 'in',
  38395. inlist: 'inlist',
  38396. intercept: 'intercept',
  38397. k1: 'k1',
  38398. k2: 'k2',
  38399. k3: 'k3',
  38400. k4: 'k4',
  38401. k: 'k',
  38402. kernelmatrix: 'kernelMatrix',
  38403. kernelunitlength: 'kernelUnitLength',
  38404. kerning: 'kerning',
  38405. keypoints: 'keyPoints',
  38406. keysplines: 'keySplines',
  38407. keytimes: 'keyTimes',
  38408. lengthadjust: 'lengthAdjust',
  38409. letterspacing: 'letterSpacing',
  38410. 'letter-spacing': 'letterSpacing',
  38411. lightingcolor: 'lightingColor',
  38412. 'lighting-color': 'lightingColor',
  38413. limitingconeangle: 'limitingConeAngle',
  38414. local: 'local',
  38415. markerend: 'markerEnd',
  38416. 'marker-end': 'markerEnd',
  38417. markerheight: 'markerHeight',
  38418. markermid: 'markerMid',
  38419. 'marker-mid': 'markerMid',
  38420. markerstart: 'markerStart',
  38421. 'marker-start': 'markerStart',
  38422. markerunits: 'markerUnits',
  38423. markerwidth: 'markerWidth',
  38424. mask: 'mask',
  38425. maskcontentunits: 'maskContentUnits',
  38426. maskunits: 'maskUnits',
  38427. mathematical: 'mathematical',
  38428. mode: 'mode',
  38429. numoctaves: 'numOctaves',
  38430. offset: 'offset',
  38431. opacity: 'opacity',
  38432. operator: 'operator',
  38433. order: 'order',
  38434. orient: 'orient',
  38435. orientation: 'orientation',
  38436. origin: 'origin',
  38437. overflow: 'overflow',
  38438. overlineposition: 'overlinePosition',
  38439. 'overline-position': 'overlinePosition',
  38440. overlinethickness: 'overlineThickness',
  38441. 'overline-thickness': 'overlineThickness',
  38442. paintorder: 'paintOrder',
  38443. 'paint-order': 'paintOrder',
  38444. panose1: 'panose1',
  38445. 'panose-1': 'panose1',
  38446. pathlength: 'pathLength',
  38447. patterncontentunits: 'patternContentUnits',
  38448. patterntransform: 'patternTransform',
  38449. patternunits: 'patternUnits',
  38450. pointerevents: 'pointerEvents',
  38451. 'pointer-events': 'pointerEvents',
  38452. points: 'points',
  38453. pointsatx: 'pointsAtX',
  38454. pointsaty: 'pointsAtY',
  38455. pointsatz: 'pointsAtZ',
  38456. prefix: 'prefix',
  38457. preservealpha: 'preserveAlpha',
  38458. preserveaspectratio: 'preserveAspectRatio',
  38459. primitiveunits: 'primitiveUnits',
  38460. property: 'property',
  38461. r: 'r',
  38462. radius: 'radius',
  38463. refx: 'refX',
  38464. refy: 'refY',
  38465. renderingintent: 'renderingIntent',
  38466. 'rendering-intent': 'renderingIntent',
  38467. repeatcount: 'repeatCount',
  38468. repeatdur: 'repeatDur',
  38469. requiredextensions: 'requiredExtensions',
  38470. requiredfeatures: 'requiredFeatures',
  38471. resource: 'resource',
  38472. restart: 'restart',
  38473. result: 'result',
  38474. results: 'results',
  38475. rotate: 'rotate',
  38476. rx: 'rx',
  38477. ry: 'ry',
  38478. scale: 'scale',
  38479. security: 'security',
  38480. seed: 'seed',
  38481. shaperendering: 'shapeRendering',
  38482. 'shape-rendering': 'shapeRendering',
  38483. slope: 'slope',
  38484. spacing: 'spacing',
  38485. specularconstant: 'specularConstant',
  38486. specularexponent: 'specularExponent',
  38487. speed: 'speed',
  38488. spreadmethod: 'spreadMethod',
  38489. startoffset: 'startOffset',
  38490. stddeviation: 'stdDeviation',
  38491. stemh: 'stemh',
  38492. stemv: 'stemv',
  38493. stitchtiles: 'stitchTiles',
  38494. stopcolor: 'stopColor',
  38495. 'stop-color': 'stopColor',
  38496. stopopacity: 'stopOpacity',
  38497. 'stop-opacity': 'stopOpacity',
  38498. strikethroughposition: 'strikethroughPosition',
  38499. 'strikethrough-position': 'strikethroughPosition',
  38500. strikethroughthickness: 'strikethroughThickness',
  38501. 'strikethrough-thickness': 'strikethroughThickness',
  38502. string: 'string',
  38503. stroke: 'stroke',
  38504. strokedasharray: 'strokeDasharray',
  38505. 'stroke-dasharray': 'strokeDasharray',
  38506. strokedashoffset: 'strokeDashoffset',
  38507. 'stroke-dashoffset': 'strokeDashoffset',
  38508. strokelinecap: 'strokeLinecap',
  38509. 'stroke-linecap': 'strokeLinecap',
  38510. strokelinejoin: 'strokeLinejoin',
  38511. 'stroke-linejoin': 'strokeLinejoin',
  38512. strokemiterlimit: 'strokeMiterlimit',
  38513. 'stroke-miterlimit': 'strokeMiterlimit',
  38514. strokewidth: 'strokeWidth',
  38515. 'stroke-width': 'strokeWidth',
  38516. strokeopacity: 'strokeOpacity',
  38517. 'stroke-opacity': 'strokeOpacity',
  38518. suppresscontenteditablewarning: 'suppressContentEditableWarning',
  38519. suppresshydrationwarning: 'suppressHydrationWarning',
  38520. surfacescale: 'surfaceScale',
  38521. systemlanguage: 'systemLanguage',
  38522. tablevalues: 'tableValues',
  38523. targetx: 'targetX',
  38524. targety: 'targetY',
  38525. textanchor: 'textAnchor',
  38526. 'text-anchor': 'textAnchor',
  38527. textdecoration: 'textDecoration',
  38528. 'text-decoration': 'textDecoration',
  38529. textlength: 'textLength',
  38530. textrendering: 'textRendering',
  38531. 'text-rendering': 'textRendering',
  38532. to: 'to',
  38533. transform: 'transform',
  38534. typeof: 'typeof',
  38535. u1: 'u1',
  38536. u2: 'u2',
  38537. underlineposition: 'underlinePosition',
  38538. 'underline-position': 'underlinePosition',
  38539. underlinethickness: 'underlineThickness',
  38540. 'underline-thickness': 'underlineThickness',
  38541. unicode: 'unicode',
  38542. unicodebidi: 'unicodeBidi',
  38543. 'unicode-bidi': 'unicodeBidi',
  38544. unicoderange: 'unicodeRange',
  38545. 'unicode-range': 'unicodeRange',
  38546. unitsperem: 'unitsPerEm',
  38547. 'units-per-em': 'unitsPerEm',
  38548. unselectable: 'unselectable',
  38549. valphabetic: 'vAlphabetic',
  38550. 'v-alphabetic': 'vAlphabetic',
  38551. values: 'values',
  38552. vectoreffect: 'vectorEffect',
  38553. 'vector-effect': 'vectorEffect',
  38554. version: 'version',
  38555. vertadvy: 'vertAdvY',
  38556. 'vert-adv-y': 'vertAdvY',
  38557. vertoriginx: 'vertOriginX',
  38558. 'vert-origin-x': 'vertOriginX',
  38559. vertoriginy: 'vertOriginY',
  38560. 'vert-origin-y': 'vertOriginY',
  38561. vhanging: 'vHanging',
  38562. 'v-hanging': 'vHanging',
  38563. videographic: 'vIdeographic',
  38564. 'v-ideographic': 'vIdeographic',
  38565. viewbox: 'viewBox',
  38566. viewtarget: 'viewTarget',
  38567. visibility: 'visibility',
  38568. vmathematical: 'vMathematical',
  38569. 'v-mathematical': 'vMathematical',
  38570. vocab: 'vocab',
  38571. widths: 'widths',
  38572. wordspacing: 'wordSpacing',
  38573. 'word-spacing': 'wordSpacing',
  38574. writingmode: 'writingMode',
  38575. 'writing-mode': 'writingMode',
  38576. x1: 'x1',
  38577. x2: 'x2',
  38578. x: 'x',
  38579. xchannelselector: 'xChannelSelector',
  38580. xheight: 'xHeight',
  38581. 'x-height': 'xHeight',
  38582. xlinkactuate: 'xlinkActuate',
  38583. 'xlink:actuate': 'xlinkActuate',
  38584. xlinkarcrole: 'xlinkArcrole',
  38585. 'xlink:arcrole': 'xlinkArcrole',
  38586. xlinkhref: 'xlinkHref',
  38587. 'xlink:href': 'xlinkHref',
  38588. xlinkrole: 'xlinkRole',
  38589. 'xlink:role': 'xlinkRole',
  38590. xlinkshow: 'xlinkShow',
  38591. 'xlink:show': 'xlinkShow',
  38592. xlinktitle: 'xlinkTitle',
  38593. 'xlink:title': 'xlinkTitle',
  38594. xlinktype: 'xlinkType',
  38595. 'xlink:type': 'xlinkType',
  38596. xmlbase: 'xmlBase',
  38597. 'xml:base': 'xmlBase',
  38598. xmllang: 'xmlLang',
  38599. 'xml:lang': 'xmlLang',
  38600. xmlns: 'xmlns',
  38601. 'xml:space': 'xmlSpace',
  38602. xmlnsxlink: 'xmlnsXlink',
  38603. 'xmlns:xlink': 'xmlnsXlink',
  38604. xmlspace: 'xmlSpace',
  38605. y1: 'y1',
  38606. y2: 'y2',
  38607. y: 'y',
  38608. ychannelselector: 'yChannelSelector',
  38609. z: 'z',
  38610. zoomandpan: 'zoomAndPan'
  38611. };
  38612. var ariaProperties = {
  38613. 'aria-current': 0,
  38614. // state
  38615. 'aria-details': 0,
  38616. 'aria-disabled': 0,
  38617. // state
  38618. 'aria-hidden': 0,
  38619. // state
  38620. 'aria-invalid': 0,
  38621. // state
  38622. 'aria-keyshortcuts': 0,
  38623. 'aria-label': 0,
  38624. 'aria-roledescription': 0,
  38625. // Widget Attributes
  38626. 'aria-autocomplete': 0,
  38627. 'aria-checked': 0,
  38628. 'aria-expanded': 0,
  38629. 'aria-haspopup': 0,
  38630. 'aria-level': 0,
  38631. 'aria-modal': 0,
  38632. 'aria-multiline': 0,
  38633. 'aria-multiselectable': 0,
  38634. 'aria-orientation': 0,
  38635. 'aria-placeholder': 0,
  38636. 'aria-pressed': 0,
  38637. 'aria-readonly': 0,
  38638. 'aria-required': 0,
  38639. 'aria-selected': 0,
  38640. 'aria-sort': 0,
  38641. 'aria-valuemax': 0,
  38642. 'aria-valuemin': 0,
  38643. 'aria-valuenow': 0,
  38644. 'aria-valuetext': 0,
  38645. // Live Region Attributes
  38646. 'aria-atomic': 0,
  38647. 'aria-busy': 0,
  38648. 'aria-live': 0,
  38649. 'aria-relevant': 0,
  38650. // Drag-and-Drop Attributes
  38651. 'aria-dropeffect': 0,
  38652. 'aria-grabbed': 0,
  38653. // Relationship Attributes
  38654. 'aria-activedescendant': 0,
  38655. 'aria-colcount': 0,
  38656. 'aria-colindex': 0,
  38657. 'aria-colspan': 0,
  38658. 'aria-controls': 0,
  38659. 'aria-describedby': 0,
  38660. 'aria-errormessage': 0,
  38661. 'aria-flowto': 0,
  38662. 'aria-labelledby': 0,
  38663. 'aria-owns': 0,
  38664. 'aria-posinset': 0,
  38665. 'aria-rowcount': 0,
  38666. 'aria-rowindex': 0,
  38667. 'aria-rowspan': 0,
  38668. 'aria-setsize': 0
  38669. };
  38670. var warnedProperties = {};
  38671. var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  38672. var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  38673. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  38674. function validateProperty(tagName, name) {
  38675. if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) {
  38676. return true;
  38677. }
  38678. if (rARIACamel.test(name)) {
  38679. var ariaName = 'aria-' + name.slice(4).toLowerCase();
  38680. var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  38681. // DOM properties, then it is an invalid aria-* attribute.
  38682. if (correctName == null) {
  38683. warning$1(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name);
  38684. warnedProperties[name] = true;
  38685. return true;
  38686. } // aria-* attributes should be lowercase; suggest the lowercase version.
  38687. if (name !== correctName) {
  38688. warning$1(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName);
  38689. warnedProperties[name] = true;
  38690. return true;
  38691. }
  38692. }
  38693. if (rARIA.test(name)) {
  38694. var lowerCasedName = name.toLowerCase();
  38695. var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  38696. // DOM properties, then it is an invalid aria-* attribute.
  38697. if (standardName == null) {
  38698. warnedProperties[name] = true;
  38699. return false;
  38700. } // aria-* attributes should be lowercase; suggest the lowercase version.
  38701. if (name !== standardName) {
  38702. warning$1(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName);
  38703. warnedProperties[name] = true;
  38704. return true;
  38705. }
  38706. }
  38707. return true;
  38708. }
  38709. function warnInvalidARIAProps(type, props) {
  38710. var invalidProps = [];
  38711. for (var key in props) {
  38712. var isValid = validateProperty(type, key);
  38713. if (!isValid) {
  38714. invalidProps.push(key);
  38715. }
  38716. }
  38717. var unknownPropString = invalidProps.map(function (prop) {
  38718. return '`' + prop + '`';
  38719. }).join(', ');
  38720. if (invalidProps.length === 1) {
  38721. warning$1(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
  38722. } else if (invalidProps.length > 1) {
  38723. warning$1(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
  38724. }
  38725. }
  38726. function validateProperties(type, props) {
  38727. if (isCustomComponent(type, props)) {
  38728. return;
  38729. }
  38730. warnInvalidARIAProps(type, props);
  38731. }
  38732. var didWarnValueNull = false;
  38733. function validateProperties$1(type, props) {
  38734. if (type !== 'input' && type !== 'textarea' && type !== 'select') {
  38735. return;
  38736. }
  38737. if (props != null && props.value === null && !didWarnValueNull) {
  38738. didWarnValueNull = true;
  38739. if (type === 'select' && props.multiple) {
  38740. warning$1(false, '`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);
  38741. } else {
  38742. warning$1(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type);
  38743. }
  38744. }
  38745. }
  38746. var validateProperty$1 = function () {};
  38747. {
  38748. var warnedProperties$1 = {};
  38749. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  38750. var EVENT_NAME_REGEX = /^on./;
  38751. var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
  38752. var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  38753. var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  38754. validateProperty$1 = function (tagName, name, value, canUseEventSystem) {
  38755. if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
  38756. return true;
  38757. }
  38758. var lowerCasedName = name.toLowerCase();
  38759. if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
  38760. warning$1(false, '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.');
  38761. warnedProperties$1[name] = true;
  38762. return true;
  38763. } // We can't rely on the event system being injected on the server.
  38764. if (canUseEventSystem) {
  38765. if (registrationNameModules.hasOwnProperty(name)) {
  38766. return true;
  38767. }
  38768. var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
  38769. if (registrationName != null) {
  38770. warning$1(false, 'Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName);
  38771. warnedProperties$1[name] = true;
  38772. return true;
  38773. }
  38774. if (EVENT_NAME_REGEX.test(name)) {
  38775. warning$1(false, 'Unknown event handler property `%s`. It will be ignored.', name);
  38776. warnedProperties$1[name] = true;
  38777. return true;
  38778. }
  38779. } else if (EVENT_NAME_REGEX.test(name)) {
  38780. // If no event plugins have been injected, we are in a server environment.
  38781. // So we can't tell if the event name is correct for sure, but we can filter
  38782. // out known bad ones like `onclick`. We can't suggest a specific replacement though.
  38783. if (INVALID_EVENT_NAME_REGEX.test(name)) {
  38784. warning$1(false, 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name);
  38785. }
  38786. warnedProperties$1[name] = true;
  38787. return true;
  38788. } // Let the ARIA attribute hook validate ARIA attributes
  38789. if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
  38790. return true;
  38791. }
  38792. if (lowerCasedName === 'innerhtml') {
  38793. warning$1(false, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
  38794. warnedProperties$1[name] = true;
  38795. return true;
  38796. }
  38797. if (lowerCasedName === 'aria') {
  38798. warning$1(false, 'The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
  38799. warnedProperties$1[name] = true;
  38800. return true;
  38801. }
  38802. if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
  38803. warning$1(false, 'Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value);
  38804. warnedProperties$1[name] = true;
  38805. return true;
  38806. }
  38807. if (typeof value === 'number' && isNaN(value)) {
  38808. warning$1(false, 'Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name);
  38809. warnedProperties$1[name] = true;
  38810. return true;
  38811. }
  38812. var propertyInfo = getPropertyInfo(name);
  38813. var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config.
  38814. if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  38815. var standardName = possibleStandardNames[lowerCasedName];
  38816. if (standardName !== name) {
  38817. warning$1(false, 'Invalid DOM property `%s`. Did you mean `%s`?', name, standardName);
  38818. warnedProperties$1[name] = true;
  38819. return true;
  38820. }
  38821. } else if (!isReserved && name !== lowerCasedName) {
  38822. // Unknown attributes should have lowercase casing since that's how they
  38823. // will be cased anyway with server rendering.
  38824. warning$1(false, '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);
  38825. warnedProperties$1[name] = true;
  38826. return true;
  38827. }
  38828. if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  38829. if (value) {
  38830. warning$1(false, '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);
  38831. } else {
  38832. warning$1(false, '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);
  38833. }
  38834. warnedProperties$1[name] = true;
  38835. return true;
  38836. } // Now that we've validated casing, do not validate
  38837. // data types for reserved props
  38838. if (isReserved) {
  38839. return true;
  38840. } // Warn when a known attribute is a bad type
  38841. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  38842. warnedProperties$1[name] = true;
  38843. return false;
  38844. } // Warn when passing the strings 'false' or 'true' into a boolean prop
  38845. if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
  38846. warning$1(false, '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);
  38847. warnedProperties$1[name] = true;
  38848. return true;
  38849. }
  38850. return true;
  38851. };
  38852. }
  38853. var warnUnknownProperties = function (type, props, canUseEventSystem) {
  38854. var unknownProps = [];
  38855. for (var key in props) {
  38856. var isValid = validateProperty$1(type, key, props[key], canUseEventSystem);
  38857. if (!isValid) {
  38858. unknownProps.push(key);
  38859. }
  38860. }
  38861. var unknownPropString = unknownProps.map(function (prop) {
  38862. return '`' + prop + '`';
  38863. }).join(', ');
  38864. if (unknownProps.length === 1) {
  38865. warning$1(false, '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);
  38866. } else if (unknownProps.length > 1) {
  38867. warning$1(false, '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);
  38868. }
  38869. };
  38870. function validateProperties$2(type, props, canUseEventSystem) {
  38871. if (isCustomComponent(type, props)) {
  38872. return;
  38873. }
  38874. warnUnknownProperties(type, props, canUseEventSystem);
  38875. }
  38876. // TODO: direct imports like some-package/src/* are bad. Fix me.
  38877. var didWarnInvalidHydration = false;
  38878. var didWarnShadyDOM = false;
  38879. var didWarnScriptTags = false;
  38880. var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML';
  38881. var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning';
  38882. var SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning';
  38883. var AUTOFOCUS = 'autoFocus';
  38884. var CHILDREN = 'children';
  38885. var STYLE$1 = 'style';
  38886. var HTML = '__html';
  38887. var LISTENERS = 'listeners';
  38888. var HTML_NAMESPACE = Namespaces.html;
  38889. var warnedUnknownTags;
  38890. var suppressHydrationWarning;
  38891. var validatePropertiesInDevelopment;
  38892. var warnForTextDifference;
  38893. var warnForPropDifference;
  38894. var warnForExtraAttributes;
  38895. var warnForInvalidEventListener;
  38896. var canDiffStyleForHydrationWarning;
  38897. var normalizeMarkupForTextOrAttribute;
  38898. var normalizeHTML;
  38899. {
  38900. warnedUnknownTags = {
  38901. // Chrome is the only major browser not shipping <time>. But as of July
  38902. // 2017 it intends to ship it due to widespread usage. We intentionally
  38903. // *don't* warn for <time> even if it's unrecognized by Chrome because
  38904. // it soon will be, and many apps have been using it anyway.
  38905. time: true,
  38906. // There are working polyfills for <dialog>. Let people use it.
  38907. dialog: true,
  38908. // Electron ships a custom <webview> tag to display external web content in
  38909. // an isolated frame and process.
  38910. // This tag is not present in non Electron environments such as JSDom which
  38911. // is often used for testing purposes.
  38912. // @see https://electronjs.org/docs/api/webview-tag
  38913. webview: true
  38914. };
  38915. validatePropertiesInDevelopment = function (type, props) {
  38916. validateProperties(type, props);
  38917. validateProperties$1(type, props);
  38918. validateProperties$2(type, props,
  38919. /* canUseEventSystem */
  38920. true);
  38921. }; // IE 11 parses & normalizes the style attribute as opposed to other
  38922. // browsers. It adds spaces and sorts the properties in some
  38923. // non-alphabetical order. Handling that would require sorting CSS
  38924. // properties in the client & server versions or applying
  38925. // `expectedStyle` to a temporary DOM node to read its `style` attribute
  38926. // normalized. Since it only affects IE, we're skipping style warnings
  38927. // in that browser completely in favor of doing all that work.
  38928. // See https://github.com/facebook/react/issues/11807
  38929. canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode; // HTML parsing normalizes CR and CRLF to LF.
  38930. // It also can turn \u0000 into \uFFFD inside attributes.
  38931. // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream
  38932. // If we have a mismatch, it might be caused by that.
  38933. // We will still patch up in this case but not fire the warning.
  38934. var NORMALIZE_NEWLINES_REGEX = /\r\n?/g;
  38935. var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g;
  38936. normalizeMarkupForTextOrAttribute = function (markup) {
  38937. var markupString = typeof markup === 'string' ? markup : '' + markup;
  38938. return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, '');
  38939. };
  38940. warnForTextDifference = function (serverText, clientText) {
  38941. if (didWarnInvalidHydration) {
  38942. return;
  38943. }
  38944. var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText);
  38945. var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText);
  38946. if (normalizedServerText === normalizedClientText) {
  38947. return;
  38948. }
  38949. didWarnInvalidHydration = true;
  38950. warningWithoutStack$1(false, 'Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText);
  38951. };
  38952. warnForPropDifference = function (propName, serverValue, clientValue) {
  38953. if (didWarnInvalidHydration) {
  38954. return;
  38955. }
  38956. var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue);
  38957. var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue);
  38958. if (normalizedServerValue === normalizedClientValue) {
  38959. return;
  38960. }
  38961. didWarnInvalidHydration = true;
  38962. warningWithoutStack$1(false, 'Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue));
  38963. };
  38964. warnForExtraAttributes = function (attributeNames) {
  38965. if (didWarnInvalidHydration) {
  38966. return;
  38967. }
  38968. didWarnInvalidHydration = true;
  38969. var names = [];
  38970. attributeNames.forEach(function (name) {
  38971. names.push(name);
  38972. });
  38973. warningWithoutStack$1(false, 'Extra attributes from the server: %s', names);
  38974. };
  38975. warnForInvalidEventListener = function (registrationName, listener) {
  38976. if (listener === false) {
  38977. warning$1(false, '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);
  38978. } else {
  38979. warning$1(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener);
  38980. }
  38981. }; // Parse the HTML and read it back to normalize the HTML string so that it
  38982. // can be used for comparison.
  38983. normalizeHTML = function (parent, html) {
  38984. // We could have created a separate document here to avoid
  38985. // re-initializing custom elements if they exist. But this breaks
  38986. // how <noscript> is being handled. So we use the same document.
  38987. // See the discussion in https://github.com/facebook/react/pull/11157.
  38988. var testElement = parent.namespaceURI === HTML_NAMESPACE ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName);
  38989. testElement.innerHTML = html;
  38990. return testElement.innerHTML;
  38991. };
  38992. }
  38993. function ensureListeningTo(rootContainerElement, registrationName) {
  38994. var isDocumentOrFragment = rootContainerElement.nodeType === DOCUMENT_NODE || rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE;
  38995. var doc = isDocumentOrFragment ? rootContainerElement : rootContainerElement.ownerDocument;
  38996. listenTo(registrationName, doc);
  38997. }
  38998. function getOwnerDocumentFromRootContainer(rootContainerElement) {
  38999. return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument;
  39000. }
  39001. function noop() {}
  39002. function trapClickOnNonInteractiveElement(node) {
  39003. // Mobile Safari does not fire properly bubble click events on
  39004. // non-interactive elements, which means delegated click listeners do not
  39005. // fire. The workaround for this bug involves attaching an empty click
  39006. // listener on the target node.
  39007. // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  39008. // Just set it using the onclick property so that we don't have to manage any
  39009. // bookkeeping for it. Not sure if we need to clear it when the listener is
  39010. // removed.
  39011. // TODO: Only do this for the relevant Safaris maybe?
  39012. node.onclick = noop;
  39013. }
  39014. function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
  39015. for (var propKey in nextProps) {
  39016. if (!nextProps.hasOwnProperty(propKey)) {
  39017. continue;
  39018. }
  39019. var nextProp = nextProps[propKey];
  39020. if (propKey === STYLE$1) {
  39021. {
  39022. if (nextProp) {
  39023. // Freeze the next style object so that we can assume it won't be
  39024. // mutated. We have already warned for this in the past.
  39025. Object.freeze(nextProp);
  39026. }
  39027. } // Relies on `updateStylesByID` not mutating `styleUpdates`.
  39028. setValueForStyles(domElement, nextProp);
  39029. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  39030. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  39031. if (nextHtml != null) {
  39032. setInnerHTML(domElement, nextHtml);
  39033. }
  39034. } else if (propKey === CHILDREN) {
  39035. if (typeof nextProp === 'string') {
  39036. // Avoid setting initial textContent when the text is empty. In IE11 setting
  39037. // textContent on a <textarea> will cause the placeholder to not
  39038. // show within the <textarea> until it has been focused and blurred again.
  39039. // https://github.com/facebook/react/issues/6731#issuecomment-254874553
  39040. var canSetTextContent = tag !== 'textarea' || nextProp !== '';
  39041. if (canSetTextContent) {
  39042. setTextContent(domElement, nextProp);
  39043. }
  39044. } else if (typeof nextProp === 'number') {
  39045. setTextContent(domElement, '' + nextProp);
  39046. }
  39047. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {// Noop
  39048. } else if (propKey === AUTOFOCUS) {// We polyfill it separately on the client during commit.
  39049. // We could have excluded it in the property list instead of
  39050. // adding a special case here, but then it wouldn't be emitted
  39051. // on server rendering (but we *do* want to emit it in SSR).
  39052. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  39053. if (nextProp != null) {
  39054. if ( true && typeof nextProp !== 'function') {
  39055. warnForInvalidEventListener(propKey, nextProp);
  39056. }
  39057. ensureListeningTo(rootContainerElement, propKey);
  39058. }
  39059. } else if (nextProp != null) {
  39060. setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
  39061. }
  39062. }
  39063. }
  39064. function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
  39065. // TODO: Handle wasCustomComponentTag
  39066. for (var i = 0; i < updatePayload.length; i += 2) {
  39067. var propKey = updatePayload[i];
  39068. var propValue = updatePayload[i + 1];
  39069. if (propKey === STYLE$1) {
  39070. setValueForStyles(domElement, propValue);
  39071. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  39072. setInnerHTML(domElement, propValue);
  39073. } else if (propKey === CHILDREN) {
  39074. setTextContent(domElement, propValue);
  39075. } else {
  39076. setValueForProperty(domElement, propKey, propValue, isCustomComponentTag);
  39077. }
  39078. }
  39079. }
  39080. function createElement(type, props, rootContainerElement, parentNamespace) {
  39081. var isCustomComponentTag; // We create tags in the namespace of their parent container, except HTML
  39082. // tags get no namespace.
  39083. var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
  39084. var domElement;
  39085. var namespaceURI = parentNamespace;
  39086. if (namespaceURI === HTML_NAMESPACE) {
  39087. namespaceURI = getIntrinsicNamespace(type);
  39088. }
  39089. if (namespaceURI === HTML_NAMESPACE) {
  39090. {
  39091. isCustomComponentTag = isCustomComponent(type, props); // Should this check be gated by parent namespace? Not sure we want to
  39092. // allow <SVG> or <mATH>.
  39093. !(isCustomComponentTag || type === type.toLowerCase()) ? warning$1(false, '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type) : void 0;
  39094. }
  39095. if (type === 'script') {
  39096. // Create the script via .innerHTML so its "parser-inserted" flag is
  39097. // set to true and it does not execute
  39098. var div = ownerDocument.createElement('div');
  39099. {
  39100. if (enableTrustedTypesIntegration && !didWarnScriptTags) {
  39101. warning$1(false, 'Encountered a script tag while rendering React component. ' + 'Scripts inside React components are never executed when rendering ' + 'on the client. Consider using template tag instead ' + '(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template).');
  39102. didWarnScriptTags = true;
  39103. }
  39104. }
  39105. div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
  39106. // This is guaranteed to yield a script element.
  39107. var firstChild = div.firstChild;
  39108. domElement = div.removeChild(firstChild);
  39109. } else if (typeof props.is === 'string') {
  39110. // $FlowIssue `createElement` should be updated for Web Components
  39111. domElement = ownerDocument.createElement(type, {
  39112. is: props.is
  39113. });
  39114. } else {
  39115. // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
  39116. // See discussion in https://github.com/facebook/react/pull/6896
  39117. // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
  39118. domElement = ownerDocument.createElement(type); // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size`
  39119. // attributes on `select`s needs to be added before `option`s are inserted.
  39120. // This prevents:
  39121. // - a bug where the `select` does not scroll to the correct option because singular
  39122. // `select` elements automatically pick the first item #13222
  39123. // - a bug where the `select` set the first item as selected despite the `size` attribute #14239
  39124. // See https://github.com/facebook/react/issues/13222
  39125. // and https://github.com/facebook/react/issues/14239
  39126. if (type === 'select') {
  39127. var node = domElement;
  39128. if (props.multiple) {
  39129. node.multiple = true;
  39130. } else if (props.size) {
  39131. // Setting a size greater than 1 causes a select to behave like `multiple=true`, where
  39132. // it is possible that no option is selected.
  39133. //
  39134. // This is only necessary when a select in "single selection mode".
  39135. node.size = props.size;
  39136. }
  39137. }
  39138. }
  39139. } else {
  39140. domElement = ownerDocument.createElementNS(namespaceURI, type);
  39141. }
  39142. {
  39143. if (namespaceURI === HTML_NAMESPACE) {
  39144. if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
  39145. warnedUnknownTags[type] = true;
  39146. warning$1(false, 'The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type);
  39147. }
  39148. }
  39149. }
  39150. return domElement;
  39151. }
  39152. function createTextNode(text, rootContainerElement) {
  39153. return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text);
  39154. }
  39155. function setInitialProperties(domElement, tag, rawProps, rootContainerElement) {
  39156. var isCustomComponentTag = isCustomComponent(tag, rawProps);
  39157. {
  39158. validatePropertiesInDevelopment(tag, rawProps);
  39159. if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
  39160. warning$1(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
  39161. didWarnShadyDOM = true;
  39162. }
  39163. } // TODO: Make sure that we check isMounted before firing any of these events.
  39164. var props;
  39165. switch (tag) {
  39166. case 'iframe':
  39167. case 'object':
  39168. case 'embed':
  39169. trapBubbledEvent(TOP_LOAD, domElement);
  39170. props = rawProps;
  39171. break;
  39172. case 'video':
  39173. case 'audio':
  39174. // Create listener for each media event
  39175. for (var i = 0; i < mediaEventTypes.length; i++) {
  39176. trapBubbledEvent(mediaEventTypes[i], domElement);
  39177. }
  39178. props = rawProps;
  39179. break;
  39180. case 'source':
  39181. trapBubbledEvent(TOP_ERROR, domElement);
  39182. props = rawProps;
  39183. break;
  39184. case 'img':
  39185. case 'image':
  39186. case 'link':
  39187. trapBubbledEvent(TOP_ERROR, domElement);
  39188. trapBubbledEvent(TOP_LOAD, domElement);
  39189. props = rawProps;
  39190. break;
  39191. case 'form':
  39192. trapBubbledEvent(TOP_RESET, domElement);
  39193. trapBubbledEvent(TOP_SUBMIT, domElement);
  39194. props = rawProps;
  39195. break;
  39196. case 'details':
  39197. trapBubbledEvent(TOP_TOGGLE, domElement);
  39198. props = rawProps;
  39199. break;
  39200. case 'input':
  39201. initWrapperState(domElement, rawProps);
  39202. props = getHostProps(domElement, rawProps);
  39203. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  39204. // to onChange. Even if there is no listener.
  39205. ensureListeningTo(rootContainerElement, 'onChange');
  39206. break;
  39207. case 'option':
  39208. validateProps(domElement, rawProps);
  39209. props = getHostProps$1(domElement, rawProps);
  39210. break;
  39211. case 'select':
  39212. initWrapperState$1(domElement, rawProps);
  39213. props = getHostProps$2(domElement, rawProps);
  39214. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  39215. // to onChange. Even if there is no listener.
  39216. ensureListeningTo(rootContainerElement, 'onChange');
  39217. break;
  39218. case 'textarea':
  39219. initWrapperState$2(domElement, rawProps);
  39220. props = getHostProps$3(domElement, rawProps);
  39221. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  39222. // to onChange. Even if there is no listener.
  39223. ensureListeningTo(rootContainerElement, 'onChange');
  39224. break;
  39225. default:
  39226. props = rawProps;
  39227. }
  39228. assertValidProps(tag, props);
  39229. setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag);
  39230. switch (tag) {
  39231. case 'input':
  39232. // TODO: Make sure we check if this is still unmounted or do any clean
  39233. // up necessary since we never stop tracking anymore.
  39234. track(domElement);
  39235. postMountWrapper(domElement, rawProps, false);
  39236. break;
  39237. case 'textarea':
  39238. // TODO: Make sure we check if this is still unmounted or do any clean
  39239. // up necessary since we never stop tracking anymore.
  39240. track(domElement);
  39241. postMountWrapper$3(domElement, rawProps);
  39242. break;
  39243. case 'option':
  39244. postMountWrapper$1(domElement, rawProps);
  39245. break;
  39246. case 'select':
  39247. postMountWrapper$2(domElement, rawProps);
  39248. break;
  39249. default:
  39250. if (typeof props.onClick === 'function') {
  39251. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  39252. trapClickOnNonInteractiveElement(domElement);
  39253. }
  39254. break;
  39255. }
  39256. } // Calculate the diff between the two objects.
  39257. function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) {
  39258. {
  39259. validatePropertiesInDevelopment(tag, nextRawProps);
  39260. }
  39261. var updatePayload = null;
  39262. var lastProps;
  39263. var nextProps;
  39264. switch (tag) {
  39265. case 'input':
  39266. lastProps = getHostProps(domElement, lastRawProps);
  39267. nextProps = getHostProps(domElement, nextRawProps);
  39268. updatePayload = [];
  39269. break;
  39270. case 'option':
  39271. lastProps = getHostProps$1(domElement, lastRawProps);
  39272. nextProps = getHostProps$1(domElement, nextRawProps);
  39273. updatePayload = [];
  39274. break;
  39275. case 'select':
  39276. lastProps = getHostProps$2(domElement, lastRawProps);
  39277. nextProps = getHostProps$2(domElement, nextRawProps);
  39278. updatePayload = [];
  39279. break;
  39280. case 'textarea':
  39281. lastProps = getHostProps$3(domElement, lastRawProps);
  39282. nextProps = getHostProps$3(domElement, nextRawProps);
  39283. updatePayload = [];
  39284. break;
  39285. default:
  39286. lastProps = lastRawProps;
  39287. nextProps = nextRawProps;
  39288. if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') {
  39289. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  39290. trapClickOnNonInteractiveElement(domElement);
  39291. }
  39292. break;
  39293. }
  39294. assertValidProps(tag, nextProps);
  39295. var propKey;
  39296. var styleName;
  39297. var styleUpdates = null;
  39298. for (propKey in lastProps) {
  39299. if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
  39300. continue;
  39301. }
  39302. if (propKey === STYLE$1) {
  39303. var lastStyle = lastProps[propKey];
  39304. for (styleName in lastStyle) {
  39305. if (lastStyle.hasOwnProperty(styleName)) {
  39306. if (!styleUpdates) {
  39307. styleUpdates = {};
  39308. }
  39309. styleUpdates[styleName] = '';
  39310. }
  39311. }
  39312. } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) {// Noop. This is handled by the clear text mechanism.
  39313. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {// Noop
  39314. } else if (propKey === AUTOFOCUS) {// Noop. It doesn't work on updates anyway.
  39315. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  39316. // This is a special case. If any listener updates we need to ensure
  39317. // that the "current" fiber pointer gets updated so we need a commit
  39318. // to update this element.
  39319. if (!updatePayload) {
  39320. updatePayload = [];
  39321. }
  39322. } else {
  39323. // For all other deleted properties we add it to the queue. We use
  39324. // the whitelist in the commit phase instead.
  39325. (updatePayload = updatePayload || []).push(propKey, null);
  39326. }
  39327. }
  39328. for (propKey in nextProps) {
  39329. var nextProp = nextProps[propKey];
  39330. var lastProp = lastProps != null ? lastProps[propKey] : undefined;
  39331. if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {
  39332. continue;
  39333. }
  39334. if (propKey === STYLE$1) {
  39335. {
  39336. if (nextProp) {
  39337. // Freeze the next style object so that we can assume it won't be
  39338. // mutated. We have already warned for this in the past.
  39339. Object.freeze(nextProp);
  39340. }
  39341. }
  39342. if (lastProp) {
  39343. // Unset styles on `lastProp` but not on `nextProp`.
  39344. for (styleName in lastProp) {
  39345. if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
  39346. if (!styleUpdates) {
  39347. styleUpdates = {};
  39348. }
  39349. styleUpdates[styleName] = '';
  39350. }
  39351. } // Update styles that changed since `lastProp`.
  39352. for (styleName in nextProp) {
  39353. if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
  39354. if (!styleUpdates) {
  39355. styleUpdates = {};
  39356. }
  39357. styleUpdates[styleName] = nextProp[styleName];
  39358. }
  39359. }
  39360. } else {
  39361. // Relies on `updateStylesByID` not mutating `styleUpdates`.
  39362. if (!styleUpdates) {
  39363. if (!updatePayload) {
  39364. updatePayload = [];
  39365. }
  39366. updatePayload.push(propKey, styleUpdates);
  39367. }
  39368. styleUpdates = nextProp;
  39369. }
  39370. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  39371. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  39372. var lastHtml = lastProp ? lastProp[HTML] : undefined;
  39373. if (nextHtml != null) {
  39374. if (lastHtml !== nextHtml) {
  39375. (updatePayload = updatePayload || []).push(propKey, toStringOrTrustedType(nextHtml));
  39376. }
  39377. } else {// TODO: It might be too late to clear this if we have children
  39378. // inserted already.
  39379. }
  39380. } else if (propKey === CHILDREN) {
  39381. if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) {
  39382. (updatePayload = updatePayload || []).push(propKey, '' + nextProp);
  39383. }
  39384. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {// Noop
  39385. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  39386. if (nextProp != null) {
  39387. // We eagerly listen to this even though we haven't committed yet.
  39388. if ( true && typeof nextProp !== 'function') {
  39389. warnForInvalidEventListener(propKey, nextProp);
  39390. }
  39391. ensureListeningTo(rootContainerElement, propKey);
  39392. }
  39393. if (!updatePayload && lastProp !== nextProp) {
  39394. // This is a special case. If any listener updates we need to ensure
  39395. // that the "current" props pointer gets updated so we need a commit
  39396. // to update this element.
  39397. updatePayload = [];
  39398. }
  39399. } else {
  39400. // For any other property we always add it to the queue and then we
  39401. // filter it out using the whitelist during the commit.
  39402. (updatePayload = updatePayload || []).push(propKey, nextProp);
  39403. }
  39404. }
  39405. if (styleUpdates) {
  39406. {
  39407. validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE$1]);
  39408. }
  39409. (updatePayload = updatePayload || []).push(STYLE$1, styleUpdates);
  39410. }
  39411. return updatePayload;
  39412. } // Apply the diff.
  39413. function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) {
  39414. // Update checked *before* name.
  39415. // In the middle of an update, it is possible to have multiple checked.
  39416. // When a checked radio tries to change name, browser makes another radio's checked false.
  39417. if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) {
  39418. updateChecked(domElement, nextRawProps);
  39419. }
  39420. var wasCustomComponentTag = isCustomComponent(tag, lastRawProps);
  39421. var isCustomComponentTag = isCustomComponent(tag, nextRawProps); // Apply the diff.
  39422. updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); // TODO: Ensure that an update gets scheduled if any of the special props
  39423. // changed.
  39424. switch (tag) {
  39425. case 'input':
  39426. // Update the wrapper around inputs *after* updating props. This has to
  39427. // happen after `updateDOMProperties`. Otherwise HTML5 input validations
  39428. // raise warnings and prevent the new value from being assigned.
  39429. updateWrapper(domElement, nextRawProps);
  39430. break;
  39431. case 'textarea':
  39432. updateWrapper$1(domElement, nextRawProps);
  39433. break;
  39434. case 'select':
  39435. // <select> value update needs to occur after <option> children
  39436. // reconciliation
  39437. postUpdateWrapper(domElement, nextRawProps);
  39438. break;
  39439. }
  39440. }
  39441. function getPossibleStandardName(propName) {
  39442. {
  39443. var lowerCasedName = propName.toLowerCase();
  39444. if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  39445. return null;
  39446. }
  39447. return possibleStandardNames[lowerCasedName] || null;
  39448. }
  39449. return null;
  39450. }
  39451. function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) {
  39452. var isCustomComponentTag;
  39453. var extraAttributeNames;
  39454. {
  39455. suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING$1] === true;
  39456. isCustomComponentTag = isCustomComponent(tag, rawProps);
  39457. validatePropertiesInDevelopment(tag, rawProps);
  39458. if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
  39459. warning$1(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
  39460. didWarnShadyDOM = true;
  39461. }
  39462. } // TODO: Make sure that we check isMounted before firing any of these events.
  39463. switch (tag) {
  39464. case 'iframe':
  39465. case 'object':
  39466. case 'embed':
  39467. trapBubbledEvent(TOP_LOAD, domElement);
  39468. break;
  39469. case 'video':
  39470. case 'audio':
  39471. // Create listener for each media event
  39472. for (var i = 0; i < mediaEventTypes.length; i++) {
  39473. trapBubbledEvent(mediaEventTypes[i], domElement);
  39474. }
  39475. break;
  39476. case 'source':
  39477. trapBubbledEvent(TOP_ERROR, domElement);
  39478. break;
  39479. case 'img':
  39480. case 'image':
  39481. case 'link':
  39482. trapBubbledEvent(TOP_ERROR, domElement);
  39483. trapBubbledEvent(TOP_LOAD, domElement);
  39484. break;
  39485. case 'form':
  39486. trapBubbledEvent(TOP_RESET, domElement);
  39487. trapBubbledEvent(TOP_SUBMIT, domElement);
  39488. break;
  39489. case 'details':
  39490. trapBubbledEvent(TOP_TOGGLE, domElement);
  39491. break;
  39492. case 'input':
  39493. initWrapperState(domElement, rawProps);
  39494. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  39495. // to onChange. Even if there is no listener.
  39496. ensureListeningTo(rootContainerElement, 'onChange');
  39497. break;
  39498. case 'option':
  39499. validateProps(domElement, rawProps);
  39500. break;
  39501. case 'select':
  39502. initWrapperState$1(domElement, rawProps);
  39503. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  39504. // to onChange. Even if there is no listener.
  39505. ensureListeningTo(rootContainerElement, 'onChange');
  39506. break;
  39507. case 'textarea':
  39508. initWrapperState$2(domElement, rawProps);
  39509. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  39510. // to onChange. Even if there is no listener.
  39511. ensureListeningTo(rootContainerElement, 'onChange');
  39512. break;
  39513. }
  39514. assertValidProps(tag, rawProps);
  39515. {
  39516. extraAttributeNames = new Set();
  39517. var attributes = domElement.attributes;
  39518. for (var _i = 0; _i < attributes.length; _i++) {
  39519. var name = attributes[_i].name.toLowerCase();
  39520. switch (name) {
  39521. // Built-in SSR attribute is whitelisted
  39522. case 'data-reactroot':
  39523. break;
  39524. // Controlled attributes are not validated
  39525. // TODO: Only ignore them on controlled tags.
  39526. case 'value':
  39527. break;
  39528. case 'checked':
  39529. break;
  39530. case 'selected':
  39531. break;
  39532. default:
  39533. // Intentionally use the original name.
  39534. // See discussion in https://github.com/facebook/react/pull/10676.
  39535. extraAttributeNames.add(attributes[_i].name);
  39536. }
  39537. }
  39538. }
  39539. var updatePayload = null;
  39540. for (var propKey in rawProps) {
  39541. if (!rawProps.hasOwnProperty(propKey)) {
  39542. continue;
  39543. }
  39544. var nextProp = rawProps[propKey];
  39545. if (propKey === CHILDREN) {
  39546. // For text content children we compare against textContent. This
  39547. // might match additional HTML that is hidden when we read it using
  39548. // textContent. E.g. "foo" will match "f<span>oo</span>" but that still
  39549. // satisfies our requirement. Our requirement is not to produce perfect
  39550. // HTML and attributes. Ideally we should preserve structure but it's
  39551. // ok not to if the visible content is still enough to indicate what
  39552. // even listeners these nodes might be wired up to.
  39553. // TODO: Warn if there is more than a single textNode as a child.
  39554. // TODO: Should we use domElement.firstChild.nodeValue to compare?
  39555. if (typeof nextProp === 'string') {
  39556. if (domElement.textContent !== nextProp) {
  39557. if ( true && !suppressHydrationWarning) {
  39558. warnForTextDifference(domElement.textContent, nextProp);
  39559. }
  39560. updatePayload = [CHILDREN, nextProp];
  39561. }
  39562. } else if (typeof nextProp === 'number') {
  39563. if (domElement.textContent !== '' + nextProp) {
  39564. if ( true && !suppressHydrationWarning) {
  39565. warnForTextDifference(domElement.textContent, nextProp);
  39566. }
  39567. updatePayload = [CHILDREN, '' + nextProp];
  39568. }
  39569. }
  39570. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  39571. if (nextProp != null) {
  39572. if ( true && typeof nextProp !== 'function') {
  39573. warnForInvalidEventListener(propKey, nextProp);
  39574. }
  39575. ensureListeningTo(rootContainerElement, propKey);
  39576. }
  39577. } else if ( true && // Convince Flow we've calculated it (it's DEV-only in this method.)
  39578. typeof isCustomComponentTag === 'boolean') {
  39579. // Validate that the properties correspond to their expected values.
  39580. var serverValue = void 0;
  39581. var propertyInfo = getPropertyInfo(propKey);
  39582. if (suppressHydrationWarning) {// Don't bother comparing. We're ignoring all these warnings.
  39583. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1 || // Controlled attributes are not validated
  39584. // TODO: Only ignore them on controlled tags.
  39585. propKey === 'value' || propKey === 'checked' || propKey === 'selected') {// Noop
  39586. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  39587. var serverHTML = domElement.innerHTML;
  39588. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  39589. var expectedHTML = normalizeHTML(domElement, nextHtml != null ? nextHtml : '');
  39590. if (expectedHTML !== serverHTML) {
  39591. warnForPropDifference(propKey, serverHTML, expectedHTML);
  39592. }
  39593. } else if (propKey === STYLE$1) {
  39594. // $FlowFixMe - Should be inferred as not undefined.
  39595. extraAttributeNames.delete(propKey);
  39596. if (canDiffStyleForHydrationWarning) {
  39597. var expectedStyle = createDangerousStringForStyles(nextProp);
  39598. serverValue = domElement.getAttribute('style');
  39599. if (expectedStyle !== serverValue) {
  39600. warnForPropDifference(propKey, serverValue, expectedStyle);
  39601. }
  39602. }
  39603. } else if (isCustomComponentTag) {
  39604. // $FlowFixMe - Should be inferred as not undefined.
  39605. extraAttributeNames.delete(propKey.toLowerCase());
  39606. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  39607. if (nextProp !== serverValue) {
  39608. warnForPropDifference(propKey, serverValue, nextProp);
  39609. }
  39610. } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) {
  39611. var isMismatchDueToBadCasing = false;
  39612. if (propertyInfo !== null) {
  39613. // $FlowFixMe - Should be inferred as not undefined.
  39614. extraAttributeNames.delete(propertyInfo.attributeName);
  39615. serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo);
  39616. } else {
  39617. var ownNamespace = parentNamespace;
  39618. if (ownNamespace === HTML_NAMESPACE) {
  39619. ownNamespace = getIntrinsicNamespace(tag);
  39620. }
  39621. if (ownNamespace === HTML_NAMESPACE) {
  39622. // $FlowFixMe - Should be inferred as not undefined.
  39623. extraAttributeNames.delete(propKey.toLowerCase());
  39624. } else {
  39625. var standardName = getPossibleStandardName(propKey);
  39626. if (standardName !== null && standardName !== propKey) {
  39627. // If an SVG prop is supplied with bad casing, it will
  39628. // be successfully parsed from HTML, but will produce a mismatch
  39629. // (and would be incorrectly rendered on the client).
  39630. // However, we already warn about bad casing elsewhere.
  39631. // So we'll skip the misleading extra mismatch warning in this case.
  39632. isMismatchDueToBadCasing = true; // $FlowFixMe - Should be inferred as not undefined.
  39633. extraAttributeNames.delete(standardName);
  39634. } // $FlowFixMe - Should be inferred as not undefined.
  39635. extraAttributeNames.delete(propKey);
  39636. }
  39637. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  39638. }
  39639. if (nextProp !== serverValue && !isMismatchDueToBadCasing) {
  39640. warnForPropDifference(propKey, serverValue, nextProp);
  39641. }
  39642. }
  39643. }
  39644. }
  39645. {
  39646. // $FlowFixMe - Should be inferred as not undefined.
  39647. if (extraAttributeNames.size > 0 && !suppressHydrationWarning) {
  39648. // $FlowFixMe - Should be inferred as not undefined.
  39649. warnForExtraAttributes(extraAttributeNames);
  39650. }
  39651. }
  39652. switch (tag) {
  39653. case 'input':
  39654. // TODO: Make sure we check if this is still unmounted or do any clean
  39655. // up necessary since we never stop tracking anymore.
  39656. track(domElement);
  39657. postMountWrapper(domElement, rawProps, true);
  39658. break;
  39659. case 'textarea':
  39660. // TODO: Make sure we check if this is still unmounted or do any clean
  39661. // up necessary since we never stop tracking anymore.
  39662. track(domElement);
  39663. postMountWrapper$3(domElement, rawProps);
  39664. break;
  39665. case 'select':
  39666. case 'option':
  39667. // For input and textarea we current always set the value property at
  39668. // post mount to force it to diverge from attributes. However, for
  39669. // option and select we don't quite do the same thing and select
  39670. // is not resilient to the DOM state changing so we don't do that here.
  39671. // TODO: Consider not doing this for input and textarea.
  39672. break;
  39673. default:
  39674. if (typeof rawProps.onClick === 'function') {
  39675. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  39676. trapClickOnNonInteractiveElement(domElement);
  39677. }
  39678. break;
  39679. }
  39680. return updatePayload;
  39681. }
  39682. function diffHydratedText(textNode, text) {
  39683. var isDifferent = textNode.nodeValue !== text;
  39684. return isDifferent;
  39685. }
  39686. function warnForUnmatchedText(textNode, text) {
  39687. {
  39688. warnForTextDifference(textNode.nodeValue, text);
  39689. }
  39690. }
  39691. function warnForDeletedHydratableElement(parentNode, child) {
  39692. {
  39693. if (didWarnInvalidHydration) {
  39694. return;
  39695. }
  39696. didWarnInvalidHydration = true;
  39697. warningWithoutStack$1(false, 'Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase());
  39698. }
  39699. }
  39700. function warnForDeletedHydratableText(parentNode, child) {
  39701. {
  39702. if (didWarnInvalidHydration) {
  39703. return;
  39704. }
  39705. didWarnInvalidHydration = true;
  39706. warningWithoutStack$1(false, 'Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase());
  39707. }
  39708. }
  39709. function warnForInsertedHydratedElement(parentNode, tag, props) {
  39710. {
  39711. if (didWarnInvalidHydration) {
  39712. return;
  39713. }
  39714. didWarnInvalidHydration = true;
  39715. warningWithoutStack$1(false, 'Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase());
  39716. }
  39717. }
  39718. function warnForInsertedHydratedText(parentNode, text) {
  39719. {
  39720. if (text === '') {
  39721. // We expect to insert empty text nodes since they're not represented in
  39722. // the HTML.
  39723. // TODO: Remove this special case if we can just avoid inserting empty
  39724. // text nodes.
  39725. return;
  39726. }
  39727. if (didWarnInvalidHydration) {
  39728. return;
  39729. }
  39730. didWarnInvalidHydration = true;
  39731. warningWithoutStack$1(false, 'Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase());
  39732. }
  39733. }
  39734. function restoreControlledState$$1(domElement, tag, props) {
  39735. switch (tag) {
  39736. case 'input':
  39737. restoreControlledState$1(domElement, props);
  39738. return;
  39739. case 'textarea':
  39740. restoreControlledState$3(domElement, props);
  39741. return;
  39742. case 'select':
  39743. restoreControlledState$2(domElement, props);
  39744. return;
  39745. }
  39746. }
  39747. function listenToEventResponderEventTypes(eventTypes, element) {
  39748. if (enableFlareAPI) {
  39749. // Get the listening Set for this element. We use this to track
  39750. // what events we're listening to.
  39751. var listeningSet = getListeningSetForElement(element); // Go through each target event type of the event responder
  39752. for (var i = 0, length = eventTypes.length; i < length; ++i) {
  39753. var eventType = eventTypes[i];
  39754. var isPassive = !endsWith(eventType, '_active');
  39755. var eventKey = isPassive ? eventType + '_passive' : eventType;
  39756. var targetEventType = isPassive ? eventType : eventType.substring(0, eventType.length - 7);
  39757. if (!listeningSet.has(eventKey)) {
  39758. trapEventForResponderEventSystem(element, targetEventType, isPassive);
  39759. listeningSet.add(eventKey);
  39760. }
  39761. }
  39762. }
  39763. } // We can remove this once the event API is stable and out of a flag
  39764. if (enableFlareAPI) {
  39765. setListenToResponderEventTypes(listenToEventResponderEventTypes);
  39766. }
  39767. function getActiveElement(doc) {
  39768. doc = doc || (typeof document !== 'undefined' ? document : undefined);
  39769. if (typeof doc === 'undefined') {
  39770. return null;
  39771. }
  39772. try {
  39773. return doc.activeElement || doc.body;
  39774. } catch (e) {
  39775. return doc.body;
  39776. }
  39777. }
  39778. /**
  39779. * Given any node return the first leaf node without children.
  39780. *
  39781. * @param {DOMElement|DOMTextNode} node
  39782. * @return {DOMElement|DOMTextNode}
  39783. */
  39784. function getLeafNode(node) {
  39785. while (node && node.firstChild) {
  39786. node = node.firstChild;
  39787. }
  39788. return node;
  39789. }
  39790. /**
  39791. * Get the next sibling within a container. This will walk up the
  39792. * DOM if a node's siblings have been exhausted.
  39793. *
  39794. * @param {DOMElement|DOMTextNode} node
  39795. * @return {?DOMElement|DOMTextNode}
  39796. */
  39797. function getSiblingNode(node) {
  39798. while (node) {
  39799. if (node.nextSibling) {
  39800. return node.nextSibling;
  39801. }
  39802. node = node.parentNode;
  39803. }
  39804. }
  39805. /**
  39806. * Get object describing the nodes which contain characters at offset.
  39807. *
  39808. * @param {DOMElement|DOMTextNode} root
  39809. * @param {number} offset
  39810. * @return {?object}
  39811. */
  39812. function getNodeForCharacterOffset(root, offset) {
  39813. var node = getLeafNode(root);
  39814. var nodeStart = 0;
  39815. var nodeEnd = 0;
  39816. while (node) {
  39817. if (node.nodeType === TEXT_NODE) {
  39818. nodeEnd = nodeStart + node.textContent.length;
  39819. if (nodeStart <= offset && nodeEnd >= offset) {
  39820. return {
  39821. node: node,
  39822. offset: offset - nodeStart
  39823. };
  39824. }
  39825. nodeStart = nodeEnd;
  39826. }
  39827. node = getLeafNode(getSiblingNode(node));
  39828. }
  39829. }
  39830. /**
  39831. * @param {DOMElement} outerNode
  39832. * @return {?object}
  39833. */
  39834. function getOffsets(outerNode) {
  39835. var ownerDocument = outerNode.ownerDocument;
  39836. var win = ownerDocument && ownerDocument.defaultView || window;
  39837. var selection = win.getSelection && win.getSelection();
  39838. if (!selection || selection.rangeCount === 0) {
  39839. return null;
  39840. }
  39841. var anchorNode = selection.anchorNode,
  39842. anchorOffset = selection.anchorOffset,
  39843. focusNode = selection.focusNode,
  39844. focusOffset = selection.focusOffset; // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the
  39845. // up/down buttons on an <input type="number">. Anonymous divs do not seem to
  39846. // expose properties, triggering a "Permission denied error" if any of its
  39847. // properties are accessed. The only seemingly possible way to avoid erroring
  39848. // is to access a property that typically works for non-anonymous divs and
  39849. // catch any error that may otherwise arise. See
  39850. // https://bugzilla.mozilla.org/show_bug.cgi?id=208427
  39851. try {
  39852. /* eslint-disable no-unused-expressions */
  39853. anchorNode.nodeType;
  39854. focusNode.nodeType;
  39855. /* eslint-enable no-unused-expressions */
  39856. } catch (e) {
  39857. return null;
  39858. }
  39859. return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset);
  39860. }
  39861. /**
  39862. * Returns {start, end} where `start` is the character/codepoint index of
  39863. * (anchorNode, anchorOffset) within the textContent of `outerNode`, and
  39864. * `end` is the index of (focusNode, focusOffset).
  39865. *
  39866. * Returns null if you pass in garbage input but we should probably just crash.
  39867. *
  39868. * Exported only for testing.
  39869. */
  39870. function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) {
  39871. var length = 0;
  39872. var start = -1;
  39873. var end = -1;
  39874. var indexWithinAnchor = 0;
  39875. var indexWithinFocus = 0;
  39876. var node = outerNode;
  39877. var parentNode = null;
  39878. outer: while (true) {
  39879. var next = null;
  39880. while (true) {
  39881. if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) {
  39882. start = length + anchorOffset;
  39883. }
  39884. if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) {
  39885. end = length + focusOffset;
  39886. }
  39887. if (node.nodeType === TEXT_NODE) {
  39888. length += node.nodeValue.length;
  39889. }
  39890. if ((next = node.firstChild) === null) {
  39891. break;
  39892. } // Moving from `node` to its first child `next`.
  39893. parentNode = node;
  39894. node = next;
  39895. }
  39896. while (true) {
  39897. if (node === outerNode) {
  39898. // If `outerNode` has children, this is always the second time visiting
  39899. // it. If it has no children, this is still the first loop, and the only
  39900. // valid selection is anchorNode and focusNode both equal to this node
  39901. // and both offsets 0, in which case we will have handled above.
  39902. break outer;
  39903. }
  39904. if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) {
  39905. start = length;
  39906. }
  39907. if (parentNode === focusNode && ++indexWithinFocus === focusOffset) {
  39908. end = length;
  39909. }
  39910. if ((next = node.nextSibling) !== null) {
  39911. break;
  39912. }
  39913. node = parentNode;
  39914. parentNode = node.parentNode;
  39915. } // Moving from `node` to its next sibling `next`.
  39916. node = next;
  39917. }
  39918. if (start === -1 || end === -1) {
  39919. // This should never happen. (Would happen if the anchor/focus nodes aren't
  39920. // actually inside the passed-in node.)
  39921. return null;
  39922. }
  39923. return {
  39924. start: start,
  39925. end: end
  39926. };
  39927. }
  39928. /**
  39929. * In modern non-IE browsers, we can support both forward and backward
  39930. * selections.
  39931. *
  39932. * Note: IE10+ supports the Selection object, but it does not support
  39933. * the `extend` method, which means that even in modern IE, it's not possible
  39934. * to programmatically create a backward selection. Thus, for all IE
  39935. * versions, we use the old IE API to create our selections.
  39936. *
  39937. * @param {DOMElement|DOMTextNode} node
  39938. * @param {object} offsets
  39939. */
  39940. function setOffsets(node, offsets) {
  39941. var doc = node.ownerDocument || document;
  39942. var win = doc && doc.defaultView || window; // Edge fails with "Object expected" in some scenarios.
  39943. // (For instance: TinyMCE editor used in a list component that supports pasting to add more,
  39944. // fails when pasting 100+ items)
  39945. if (!win.getSelection) {
  39946. return;
  39947. }
  39948. var selection = win.getSelection();
  39949. var length = node.textContent.length;
  39950. var start = Math.min(offsets.start, length);
  39951. var end = offsets.end === undefined ? start : Math.min(offsets.end, length); // IE 11 uses modern selection, but doesn't support the extend method.
  39952. // Flip backward selections, so we can set with a single range.
  39953. if (!selection.extend && start > end) {
  39954. var temp = end;
  39955. end = start;
  39956. start = temp;
  39957. }
  39958. var startMarker = getNodeForCharacterOffset(node, start);
  39959. var endMarker = getNodeForCharacterOffset(node, end);
  39960. if (startMarker && endMarker) {
  39961. if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) {
  39962. return;
  39963. }
  39964. var range = doc.createRange();
  39965. range.setStart(startMarker.node, startMarker.offset);
  39966. selection.removeAllRanges();
  39967. if (start > end) {
  39968. selection.addRange(range);
  39969. selection.extend(endMarker.node, endMarker.offset);
  39970. } else {
  39971. range.setEnd(endMarker.node, endMarker.offset);
  39972. selection.addRange(range);
  39973. }
  39974. }
  39975. }
  39976. function isTextNode(node) {
  39977. return node && node.nodeType === TEXT_NODE;
  39978. }
  39979. function containsNode(outerNode, innerNode) {
  39980. if (!outerNode || !innerNode) {
  39981. return false;
  39982. } else if (outerNode === innerNode) {
  39983. return true;
  39984. } else if (isTextNode(outerNode)) {
  39985. return false;
  39986. } else if (isTextNode(innerNode)) {
  39987. return containsNode(outerNode, innerNode.parentNode);
  39988. } else if ('contains' in outerNode) {
  39989. return outerNode.contains(innerNode);
  39990. } else if (outerNode.compareDocumentPosition) {
  39991. return !!(outerNode.compareDocumentPosition(innerNode) & 16);
  39992. } else {
  39993. return false;
  39994. }
  39995. }
  39996. function isInDocument(node) {
  39997. return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node);
  39998. }
  39999. function isSameOriginFrame(iframe) {
  40000. try {
  40001. // Accessing the contentDocument of a HTMLIframeElement can cause the browser
  40002. // to throw, e.g. if it has a cross-origin src attribute.
  40003. // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g:
  40004. // iframe.contentDocument.defaultView;
  40005. // A safety way is to access one of the cross origin properties: Window or Location
  40006. // Which might result in "SecurityError" DOM Exception and it is compatible to Safari.
  40007. // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl
  40008. return typeof iframe.contentWindow.location.href === 'string';
  40009. } catch (err) {
  40010. return false;
  40011. }
  40012. }
  40013. function getActiveElementDeep() {
  40014. var win = window;
  40015. var element = getActiveElement();
  40016. while (element instanceof win.HTMLIFrameElement) {
  40017. if (isSameOriginFrame(element)) {
  40018. win = element.contentWindow;
  40019. } else {
  40020. return element;
  40021. }
  40022. element = getActiveElement(win.document);
  40023. }
  40024. return element;
  40025. }
  40026. /**
  40027. * @ReactInputSelection: React input selection module. Based on Selection.js,
  40028. * but modified to be suitable for react and has a couple of bug fixes (doesn't
  40029. * assume buttons have range selections allowed).
  40030. * Input selection module for React.
  40031. */
  40032. /**
  40033. * @hasSelectionCapabilities: we get the element types that support selection
  40034. * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart`
  40035. * and `selectionEnd` rows.
  40036. */
  40037. function hasSelectionCapabilities(elem) {
  40038. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  40039. return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true');
  40040. }
  40041. function getSelectionInformation() {
  40042. var focusedElem = getActiveElementDeep();
  40043. return {
  40044. focusedElem: focusedElem,
  40045. selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null
  40046. };
  40047. }
  40048. /**
  40049. * @restoreSelection: If any selection information was potentially lost,
  40050. * restore it. This is useful when performing operations that could remove dom
  40051. * nodes and place them back in, resulting in focus being lost.
  40052. */
  40053. function restoreSelection(priorSelectionInformation) {
  40054. var curFocusedElem = getActiveElementDeep();
  40055. var priorFocusedElem = priorSelectionInformation.focusedElem;
  40056. var priorSelectionRange = priorSelectionInformation.selectionRange;
  40057. if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
  40058. if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) {
  40059. setSelection(priorFocusedElem, priorSelectionRange);
  40060. } // Focusing a node can change the scroll position, which is undesirable
  40061. var ancestors = [];
  40062. var ancestor = priorFocusedElem;
  40063. while (ancestor = ancestor.parentNode) {
  40064. if (ancestor.nodeType === ELEMENT_NODE) {
  40065. ancestors.push({
  40066. element: ancestor,
  40067. left: ancestor.scrollLeft,
  40068. top: ancestor.scrollTop
  40069. });
  40070. }
  40071. }
  40072. if (typeof priorFocusedElem.focus === 'function') {
  40073. priorFocusedElem.focus();
  40074. }
  40075. for (var i = 0; i < ancestors.length; i++) {
  40076. var info = ancestors[i];
  40077. info.element.scrollLeft = info.left;
  40078. info.element.scrollTop = info.top;
  40079. }
  40080. }
  40081. }
  40082. /**
  40083. * @getSelection: Gets the selection bounds of a focused textarea, input or
  40084. * contentEditable node.
  40085. * -@input: Look up selection bounds of this input
  40086. * -@return {start: selectionStart, end: selectionEnd}
  40087. */
  40088. function getSelection(input) {
  40089. var selection;
  40090. if ('selectionStart' in input) {
  40091. // Modern browser with input or textarea.
  40092. selection = {
  40093. start: input.selectionStart,
  40094. end: input.selectionEnd
  40095. };
  40096. } else {
  40097. // Content editable or old IE textarea.
  40098. selection = getOffsets(input);
  40099. }
  40100. return selection || {
  40101. start: 0,
  40102. end: 0
  40103. };
  40104. }
  40105. /**
  40106. * @setSelection: Sets the selection bounds of a textarea or input and focuses
  40107. * the input.
  40108. * -@input Set selection bounds of this input or textarea
  40109. * -@offsets Object of same form that is returned from get*
  40110. */
  40111. function setSelection(input, offsets) {
  40112. var start = offsets.start,
  40113. end = offsets.end;
  40114. if (end === undefined) {
  40115. end = start;
  40116. }
  40117. if ('selectionStart' in input) {
  40118. input.selectionStart = start;
  40119. input.selectionEnd = Math.min(end, input.value.length);
  40120. } else {
  40121. setOffsets(input, offsets);
  40122. }
  40123. }
  40124. var validateDOMNesting = function () {};
  40125. var updatedAncestorInfo = function () {};
  40126. {
  40127. // This validation code was written based on the HTML5 parsing spec:
  40128. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  40129. //
  40130. // Note: this does not catch all invalid nesting, nor does it try to (as it's
  40131. // not clear what practical benefit doing so provides); instead, we warn only
  40132. // for cases where the parser will give a parse tree differing from what React
  40133. // intended. For example, <b><div></div></b> is invalid but we don't warn
  40134. // because it still parses correctly; we do warn for other cases like nested
  40135. // <p> tags where the beginning of the second element implicitly closes the
  40136. // first, causing a confusing mess.
  40137. // https://html.spec.whatwg.org/multipage/syntax.html#special
  40138. 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
  40139. var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point
  40140. // TODO: Distinguish by namespace here -- for <title>, including it here
  40141. // errs on the side of fewer warnings
  40142. 'foreignObject', 'desc', 'title']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope
  40143. var buttonScopeTags = inScopeTags.concat(['button']); // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags
  40144. var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
  40145. var emptyAncestorInfo = {
  40146. current: null,
  40147. formTag: null,
  40148. aTagInScope: null,
  40149. buttonTagInScope: null,
  40150. nobrTagInScope: null,
  40151. pTagInButtonScope: null,
  40152. listItemTagAutoclosing: null,
  40153. dlItemTagAutoclosing: null
  40154. };
  40155. updatedAncestorInfo = function (oldInfo, tag) {
  40156. var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo);
  40157. var info = {
  40158. tag: tag
  40159. };
  40160. if (inScopeTags.indexOf(tag) !== -1) {
  40161. ancestorInfo.aTagInScope = null;
  40162. ancestorInfo.buttonTagInScope = null;
  40163. ancestorInfo.nobrTagInScope = null;
  40164. }
  40165. if (buttonScopeTags.indexOf(tag) !== -1) {
  40166. ancestorInfo.pTagInButtonScope = null;
  40167. } // See rules for 'li', 'dd', 'dt' start tags in
  40168. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  40169. if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') {
  40170. ancestorInfo.listItemTagAutoclosing = null;
  40171. ancestorInfo.dlItemTagAutoclosing = null;
  40172. }
  40173. ancestorInfo.current = info;
  40174. if (tag === 'form') {
  40175. ancestorInfo.formTag = info;
  40176. }
  40177. if (tag === 'a') {
  40178. ancestorInfo.aTagInScope = info;
  40179. }
  40180. if (tag === 'button') {
  40181. ancestorInfo.buttonTagInScope = info;
  40182. }
  40183. if (tag === 'nobr') {
  40184. ancestorInfo.nobrTagInScope = info;
  40185. }
  40186. if (tag === 'p') {
  40187. ancestorInfo.pTagInButtonScope = info;
  40188. }
  40189. if (tag === 'li') {
  40190. ancestorInfo.listItemTagAutoclosing = info;
  40191. }
  40192. if (tag === 'dd' || tag === 'dt') {
  40193. ancestorInfo.dlItemTagAutoclosing = info;
  40194. }
  40195. return ancestorInfo;
  40196. };
  40197. /**
  40198. * Returns whether
  40199. */
  40200. var isTagValidWithParent = function (tag, parentTag) {
  40201. // First, let's check if we're in an unusual parsing mode...
  40202. switch (parentTag) {
  40203. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect
  40204. case 'select':
  40205. return tag === 'option' || tag === 'optgroup' || tag === '#text';
  40206. case 'optgroup':
  40207. return tag === 'option' || tag === '#text';
  40208. // Strictly speaking, seeing an <option> doesn't mean we're in a <select>
  40209. // but
  40210. case 'option':
  40211. return tag === '#text';
  40212. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd
  40213. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption
  40214. // No special behavior since these rules fall back to "in body" mode for
  40215. // all except special table nodes which cause bad parsing behavior anyway.
  40216. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr
  40217. case 'tr':
  40218. return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template';
  40219. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody
  40220. case 'tbody':
  40221. case 'thead':
  40222. case 'tfoot':
  40223. return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template';
  40224. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup
  40225. case 'colgroup':
  40226. return tag === 'col' || tag === 'template';
  40227. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable
  40228. case 'table':
  40229. return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template';
  40230. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead
  40231. case 'head':
  40232. return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template';
  40233. // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
  40234. case 'html':
  40235. return tag === 'head' || tag === 'body' || tag === 'frameset';
  40236. case 'frameset':
  40237. return tag === 'frame';
  40238. case '#document':
  40239. return tag === 'html';
  40240. } // Probably in the "in body" parsing mode, so we outlaw only tag combos
  40241. // where the parsing rules cause implicit opens or closes to be added.
  40242. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  40243. switch (tag) {
  40244. case 'h1':
  40245. case 'h2':
  40246. case 'h3':
  40247. case 'h4':
  40248. case 'h5':
  40249. case 'h6':
  40250. return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6';
  40251. case 'rp':
  40252. case 'rt':
  40253. return impliedEndTags.indexOf(parentTag) === -1;
  40254. case 'body':
  40255. case 'caption':
  40256. case 'col':
  40257. case 'colgroup':
  40258. case 'frameset':
  40259. case 'frame':
  40260. case 'head':
  40261. case 'html':
  40262. case 'tbody':
  40263. case 'td':
  40264. case 'tfoot':
  40265. case 'th':
  40266. case 'thead':
  40267. case 'tr':
  40268. // These tags are only valid with a few parents that have special child
  40269. // parsing rules -- if we're down here, then none of those matched and
  40270. // so we allow it only if we don't know what the parent is, as all other
  40271. // cases are invalid.
  40272. return parentTag == null;
  40273. }
  40274. return true;
  40275. };
  40276. /**
  40277. * Returns whether
  40278. */
  40279. var findInvalidAncestorForTag = function (tag, ancestorInfo) {
  40280. switch (tag) {
  40281. case 'address':
  40282. case 'article':
  40283. case 'aside':
  40284. case 'blockquote':
  40285. case 'center':
  40286. case 'details':
  40287. case 'dialog':
  40288. case 'dir':
  40289. case 'div':
  40290. case 'dl':
  40291. case 'fieldset':
  40292. case 'figcaption':
  40293. case 'figure':
  40294. case 'footer':
  40295. case 'header':
  40296. case 'hgroup':
  40297. case 'main':
  40298. case 'menu':
  40299. case 'nav':
  40300. case 'ol':
  40301. case 'p':
  40302. case 'section':
  40303. case 'summary':
  40304. case 'ul':
  40305. case 'pre':
  40306. case 'listing':
  40307. case 'table':
  40308. case 'hr':
  40309. case 'xmp':
  40310. case 'h1':
  40311. case 'h2':
  40312. case 'h3':
  40313. case 'h4':
  40314. case 'h5':
  40315. case 'h6':
  40316. return ancestorInfo.pTagInButtonScope;
  40317. case 'form':
  40318. return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
  40319. case 'li':
  40320. return ancestorInfo.listItemTagAutoclosing;
  40321. case 'dd':
  40322. case 'dt':
  40323. return ancestorInfo.dlItemTagAutoclosing;
  40324. case 'button':
  40325. return ancestorInfo.buttonTagInScope;
  40326. case 'a':
  40327. // Spec says something about storing a list of markers, but it sounds
  40328. // equivalent to this check.
  40329. return ancestorInfo.aTagInScope;
  40330. case 'nobr':
  40331. return ancestorInfo.nobrTagInScope;
  40332. }
  40333. return null;
  40334. };
  40335. var didWarn$1 = {};
  40336. validateDOMNesting = function (childTag, childText, ancestorInfo) {
  40337. ancestorInfo = ancestorInfo || emptyAncestorInfo;
  40338. var parentInfo = ancestorInfo.current;
  40339. var parentTag = parentInfo && parentInfo.tag;
  40340. if (childText != null) {
  40341. !(childTag == null) ? warningWithoutStack$1(false, 'validateDOMNesting: when childText is passed, childTag should be null') : void 0;
  40342. childTag = '#text';
  40343. }
  40344. var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
  40345. var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
  40346. var invalidParentOrAncestor = invalidParent || invalidAncestor;
  40347. if (!invalidParentOrAncestor) {
  40348. return;
  40349. }
  40350. var ancestorTag = invalidParentOrAncestor.tag;
  40351. var addendum = getCurrentFiberStackInDev();
  40352. var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum;
  40353. if (didWarn$1[warnKey]) {
  40354. return;
  40355. }
  40356. didWarn$1[warnKey] = true;
  40357. var tagDisplayName = childTag;
  40358. var whitespaceInfo = '';
  40359. if (childTag === '#text') {
  40360. if (/\S/.test(childText)) {
  40361. tagDisplayName = 'Text nodes';
  40362. } else {
  40363. tagDisplayName = 'Whitespace text nodes';
  40364. whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.';
  40365. }
  40366. } else {
  40367. tagDisplayName = '<' + childTag + '>';
  40368. }
  40369. if (invalidParent) {
  40370. var info = '';
  40371. if (ancestorTag === 'table' && childTag === 'tr') {
  40372. info += ' Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by ' + 'the browser.';
  40373. }
  40374. warningWithoutStack$1(false, 'validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info, addendum);
  40375. } else {
  40376. warningWithoutStack$1(false, 'validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.%s', tagDisplayName, ancestorTag, addendum);
  40377. }
  40378. };
  40379. }
  40380. // can re-export everything from this module.
  40381. function shim() {
  40382. (function () {
  40383. {
  40384. {
  40385. throw ReactError(Error("The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue."));
  40386. }
  40387. }
  40388. })();
  40389. } // Persistence (when unsupported)
  40390. var supportsPersistence = false;
  40391. var cloneInstance = shim;
  40392. var cloneFundamentalInstance = shim;
  40393. var createContainerChildSet = shim;
  40394. var appendChildToContainerChildSet = shim;
  40395. var finalizeContainerChildren = shim;
  40396. var replaceContainerChildren = shim;
  40397. var cloneHiddenInstance = shim;
  40398. var cloneHiddenTextInstance = shim;
  40399. var SUPPRESS_HYDRATION_WARNING;
  40400. {
  40401. SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
  40402. }
  40403. var SUSPENSE_START_DATA = '$';
  40404. var SUSPENSE_END_DATA = '/$';
  40405. var SUSPENSE_PENDING_START_DATA = '$?';
  40406. var SUSPENSE_FALLBACK_START_DATA = '$!';
  40407. var STYLE = 'style';
  40408. var eventsEnabled = null;
  40409. var selectionInformation = null;
  40410. function shouldAutoFocusHostComponent(type, props) {
  40411. switch (type) {
  40412. case 'button':
  40413. case 'input':
  40414. case 'select':
  40415. case 'textarea':
  40416. return !!props.autoFocus;
  40417. }
  40418. return false;
  40419. }
  40420. function getRootHostContext(rootContainerInstance) {
  40421. var type;
  40422. var namespace;
  40423. var nodeType = rootContainerInstance.nodeType;
  40424. switch (nodeType) {
  40425. case DOCUMENT_NODE:
  40426. case DOCUMENT_FRAGMENT_NODE:
  40427. {
  40428. type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment';
  40429. var root = rootContainerInstance.documentElement;
  40430. namespace = root ? root.namespaceURI : getChildNamespace(null, '');
  40431. break;
  40432. }
  40433. default:
  40434. {
  40435. var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance;
  40436. var ownNamespace = container.namespaceURI || null;
  40437. type = container.tagName;
  40438. namespace = getChildNamespace(ownNamespace, type);
  40439. break;
  40440. }
  40441. }
  40442. {
  40443. var validatedTag = type.toLowerCase();
  40444. var ancestorInfo = updatedAncestorInfo(null, validatedTag);
  40445. return {
  40446. namespace: namespace,
  40447. ancestorInfo: ancestorInfo
  40448. };
  40449. }
  40450. return namespace;
  40451. }
  40452. function getChildHostContext(parentHostContext, type, rootContainerInstance) {
  40453. {
  40454. var parentHostContextDev = parentHostContext;
  40455. var namespace = getChildNamespace(parentHostContextDev.namespace, type);
  40456. var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type);
  40457. return {
  40458. namespace: namespace,
  40459. ancestorInfo: ancestorInfo
  40460. };
  40461. }
  40462. var parentNamespace = parentHostContext;
  40463. return getChildNamespace(parentNamespace, type);
  40464. }
  40465. function getPublicInstance(instance) {
  40466. return instance;
  40467. }
  40468. function prepareForCommit(containerInfo) {
  40469. eventsEnabled = isEnabled();
  40470. selectionInformation = getSelectionInformation();
  40471. setEnabled(false);
  40472. }
  40473. function resetAfterCommit(containerInfo) {
  40474. restoreSelection(selectionInformation);
  40475. selectionInformation = null;
  40476. setEnabled(eventsEnabled);
  40477. eventsEnabled = null;
  40478. }
  40479. function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  40480. var parentNamespace;
  40481. {
  40482. // TODO: take namespace into account when validating.
  40483. var hostContextDev = hostContext;
  40484. validateDOMNesting(type, null, hostContextDev.ancestorInfo);
  40485. if (typeof props.children === 'string' || typeof props.children === 'number') {
  40486. var string = '' + props.children;
  40487. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  40488. validateDOMNesting(null, string, ownAncestorInfo);
  40489. }
  40490. parentNamespace = hostContextDev.namespace;
  40491. }
  40492. var domElement = createElement(type, props, rootContainerInstance, parentNamespace);
  40493. precacheFiberNode(internalInstanceHandle, domElement);
  40494. updateFiberProps(domElement, props);
  40495. return domElement;
  40496. }
  40497. function appendInitialChild(parentInstance, child) {
  40498. parentInstance.appendChild(child);
  40499. }
  40500. function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) {
  40501. setInitialProperties(domElement, type, props, rootContainerInstance);
  40502. return shouldAutoFocusHostComponent(type, props);
  40503. }
  40504. function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) {
  40505. {
  40506. var hostContextDev = hostContext;
  40507. if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) {
  40508. var string = '' + newProps.children;
  40509. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  40510. validateDOMNesting(null, string, ownAncestorInfo);
  40511. }
  40512. }
  40513. return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance);
  40514. }
  40515. function shouldSetTextContent(type, props) {
  40516. 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;
  40517. }
  40518. function shouldDeprioritizeSubtree(type, props) {
  40519. return !!props.hidden;
  40520. }
  40521. function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
  40522. {
  40523. var hostContextDev = hostContext;
  40524. validateDOMNesting(null, text, hostContextDev.ancestorInfo);
  40525. }
  40526. var textNode = createTextNode(text, rootContainerInstance);
  40527. precacheFiberNode(internalInstanceHandle, textNode);
  40528. return textNode;
  40529. }
  40530. var isPrimaryRenderer = true;
  40531. var warnsIfNotActing = true; // This initialization code may run even on server environments
  40532. // if a component just imports ReactDOM (e.g. for findDOMNode).
  40533. // Some environments might not have setTimeout or clearTimeout.
  40534. var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
  40535. var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
  40536. var noTimeout = -1; // -------------------
  40537. // Mutation
  40538. // -------------------
  40539. var supportsMutation = true;
  40540. function commitMount(domElement, type, newProps, internalInstanceHandle) {
  40541. // Despite the naming that might imply otherwise, this method only
  40542. // fires if there is an `Update` effect scheduled during mounting.
  40543. // This happens if `finalizeInitialChildren` returns `true` (which it
  40544. // does to implement the `autoFocus` attribute on the client). But
  40545. // there are also other cases when this might happen (such as patching
  40546. // up text content during hydration mismatch). So we'll check this again.
  40547. if (shouldAutoFocusHostComponent(type, newProps)) {
  40548. domElement.focus();
  40549. }
  40550. }
  40551. function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) {
  40552. // Update the props handle so that we know which props are the ones with
  40553. // with current event handlers.
  40554. updateFiberProps(domElement, newProps); // Apply the diff to the DOM node.
  40555. updateProperties(domElement, updatePayload, type, oldProps, newProps);
  40556. }
  40557. function resetTextContent(domElement) {
  40558. setTextContent(domElement, '');
  40559. }
  40560. function commitTextUpdate(textInstance, oldText, newText) {
  40561. textInstance.nodeValue = newText;
  40562. }
  40563. function appendChild(parentInstance, child) {
  40564. parentInstance.appendChild(child);
  40565. }
  40566. function appendChildToContainer(container, child) {
  40567. var parentNode;
  40568. if (container.nodeType === COMMENT_NODE) {
  40569. parentNode = container.parentNode;
  40570. parentNode.insertBefore(child, container);
  40571. } else {
  40572. parentNode = container;
  40573. parentNode.appendChild(child);
  40574. } // This container might be used for a portal.
  40575. // If something inside a portal is clicked, that click should bubble
  40576. // through the React tree. However, on Mobile Safari the click would
  40577. // never bubble through the *DOM* tree unless an ancestor with onclick
  40578. // event exists. So we wouldn't see it and dispatch it.
  40579. // This is why we ensure that non React root containers have inline onclick
  40580. // defined.
  40581. // https://github.com/facebook/react/issues/11918
  40582. var reactRootContainer = container._reactRootContainer;
  40583. if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) {
  40584. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  40585. trapClickOnNonInteractiveElement(parentNode);
  40586. }
  40587. }
  40588. function insertBefore(parentInstance, child, beforeChild) {
  40589. parentInstance.insertBefore(child, beforeChild);
  40590. }
  40591. function insertInContainerBefore(container, child, beforeChild) {
  40592. if (container.nodeType === COMMENT_NODE) {
  40593. container.parentNode.insertBefore(child, beforeChild);
  40594. } else {
  40595. container.insertBefore(child, beforeChild);
  40596. }
  40597. }
  40598. function removeChild(parentInstance, child) {
  40599. parentInstance.removeChild(child);
  40600. }
  40601. function removeChildFromContainer(container, child) {
  40602. if (container.nodeType === COMMENT_NODE) {
  40603. container.parentNode.removeChild(child);
  40604. } else {
  40605. container.removeChild(child);
  40606. }
  40607. }
  40608. function clearSuspenseBoundary(parentInstance, suspenseInstance) {
  40609. var node = suspenseInstance; // Delete all nodes within this suspense boundary.
  40610. // There might be nested nodes so we need to keep track of how
  40611. // deep we are and only break out when we're back on top.
  40612. var depth = 0;
  40613. do {
  40614. var nextNode = node.nextSibling;
  40615. parentInstance.removeChild(node);
  40616. if (nextNode && nextNode.nodeType === COMMENT_NODE) {
  40617. var data = nextNode.data;
  40618. if (data === SUSPENSE_END_DATA) {
  40619. if (depth === 0) {
  40620. parentInstance.removeChild(nextNode); // Retry if any event replaying was blocked on this.
  40621. retryIfBlockedOn(suspenseInstance);
  40622. return;
  40623. } else {
  40624. depth--;
  40625. }
  40626. } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_PENDING_START_DATA || data === SUSPENSE_FALLBACK_START_DATA) {
  40627. depth++;
  40628. }
  40629. }
  40630. node = nextNode;
  40631. } while (node); // TODO: Warn, we didn't find the end comment boundary.
  40632. // Retry if any event replaying was blocked on this.
  40633. retryIfBlockedOn(suspenseInstance);
  40634. }
  40635. function clearSuspenseBoundaryFromContainer(container, suspenseInstance) {
  40636. if (container.nodeType === COMMENT_NODE) {
  40637. clearSuspenseBoundary(container.parentNode, suspenseInstance);
  40638. } else if (container.nodeType === ELEMENT_NODE) {
  40639. clearSuspenseBoundary(container, suspenseInstance);
  40640. } else {} // Document nodes should never contain suspense boundaries.
  40641. // Retry if any event replaying was blocked on this.
  40642. retryIfBlockedOn(container);
  40643. }
  40644. function hideInstance(instance) {
  40645. // TODO: Does this work for all element types? What about MathML? Should we
  40646. // pass host context to this method?
  40647. instance = instance;
  40648. var style = instance.style;
  40649. if (typeof style.setProperty === 'function') {
  40650. style.setProperty('display', 'none', 'important');
  40651. } else {
  40652. style.display = 'none';
  40653. }
  40654. }
  40655. function hideTextInstance(textInstance) {
  40656. textInstance.nodeValue = '';
  40657. }
  40658. function unhideInstance(instance, props) {
  40659. instance = instance;
  40660. var styleProp = props[STYLE];
  40661. var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null;
  40662. instance.style.display = dangerousStyleValue('display', display);
  40663. }
  40664. function unhideTextInstance(textInstance, text) {
  40665. textInstance.nodeValue = text;
  40666. } // -------------------
  40667. // Hydration
  40668. // -------------------
  40669. var supportsHydration = true;
  40670. function canHydrateInstance(instance, type, props) {
  40671. if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) {
  40672. return null;
  40673. } // This has now been refined to an element node.
  40674. return instance;
  40675. }
  40676. function canHydrateTextInstance(instance, text) {
  40677. if (text === '' || instance.nodeType !== TEXT_NODE) {
  40678. // Empty strings are not parsed by HTML so there won't be a correct match here.
  40679. return null;
  40680. } // This has now been refined to a text node.
  40681. return instance;
  40682. }
  40683. function canHydrateSuspenseInstance(instance) {
  40684. if (instance.nodeType !== COMMENT_NODE) {
  40685. // Empty strings are not parsed by HTML so there won't be a correct match here.
  40686. return null;
  40687. } // This has now been refined to a suspense node.
  40688. return instance;
  40689. }
  40690. function isSuspenseInstancePending(instance) {
  40691. return instance.data === SUSPENSE_PENDING_START_DATA;
  40692. }
  40693. function isSuspenseInstanceFallback(instance) {
  40694. return instance.data === SUSPENSE_FALLBACK_START_DATA;
  40695. }
  40696. function registerSuspenseInstanceRetry(instance, callback) {
  40697. instance._reactRetry = callback;
  40698. }
  40699. function getNextHydratable(node) {
  40700. // Skip non-hydratable nodes.
  40701. for (; node != null; node = node.nextSibling) {
  40702. var nodeType = node.nodeType;
  40703. if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) {
  40704. break;
  40705. }
  40706. if (enableSuspenseServerRenderer) {
  40707. if (nodeType === COMMENT_NODE) {
  40708. var nodeData = node.data;
  40709. if (nodeData === SUSPENSE_START_DATA || nodeData === SUSPENSE_FALLBACK_START_DATA || nodeData === SUSPENSE_PENDING_START_DATA) {
  40710. break;
  40711. }
  40712. }
  40713. }
  40714. }
  40715. return node;
  40716. }
  40717. function getNextHydratableSibling(instance) {
  40718. return getNextHydratable(instance.nextSibling);
  40719. }
  40720. function getFirstHydratableChild(parentInstance) {
  40721. return getNextHydratable(parentInstance.firstChild);
  40722. }
  40723. function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  40724. precacheFiberNode(internalInstanceHandle, instance); // TODO: Possibly defer this until the commit phase where all the events
  40725. // get attached.
  40726. updateFiberProps(instance, props);
  40727. var parentNamespace;
  40728. {
  40729. var hostContextDev = hostContext;
  40730. parentNamespace = hostContextDev.namespace;
  40731. }
  40732. return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance);
  40733. }
  40734. function hydrateTextInstance(textInstance, text, internalInstanceHandle) {
  40735. precacheFiberNode(internalInstanceHandle, textInstance);
  40736. return diffHydratedText(textInstance, text);
  40737. }
  40738. function hydrateSuspenseInstance(suspenseInstance, internalInstanceHandle) {
  40739. precacheFiberNode(internalInstanceHandle, suspenseInstance);
  40740. }
  40741. function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) {
  40742. var node = suspenseInstance.nextSibling; // Skip past all nodes within this suspense boundary.
  40743. // There might be nested nodes so we need to keep track of how
  40744. // deep we are and only break out when we're back on top.
  40745. var depth = 0;
  40746. while (node) {
  40747. if (node.nodeType === COMMENT_NODE) {
  40748. var data = node.data;
  40749. if (data === SUSPENSE_END_DATA) {
  40750. if (depth === 0) {
  40751. return getNextHydratableSibling(node);
  40752. } else {
  40753. depth--;
  40754. }
  40755. } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
  40756. depth++;
  40757. }
  40758. }
  40759. node = node.nextSibling;
  40760. } // TODO: Warn, we didn't find the end comment boundary.
  40761. return null;
  40762. } // Returns the SuspenseInstance if this node is a direct child of a
  40763. // SuspenseInstance. I.e. if its previous sibling is a Comment with
  40764. // SUSPENSE_x_START_DATA. Otherwise, null.
  40765. function getParentSuspenseInstance(targetInstance) {
  40766. var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary.
  40767. // There might be nested nodes so we need to keep track of how
  40768. // deep we are and only break out when we're back on top.
  40769. var depth = 0;
  40770. while (node) {
  40771. if (node.nodeType === COMMENT_NODE) {
  40772. var data = node.data;
  40773. if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
  40774. if (depth === 0) {
  40775. return node;
  40776. } else {
  40777. depth--;
  40778. }
  40779. } else if (data === SUSPENSE_END_DATA) {
  40780. depth++;
  40781. }
  40782. }
  40783. node = node.previousSibling;
  40784. }
  40785. return null;
  40786. }
  40787. function commitHydratedContainer(container) {
  40788. // Retry if any event replaying was blocked on this.
  40789. retryIfBlockedOn(container);
  40790. }
  40791. function commitHydratedSuspenseInstance(suspenseInstance) {
  40792. // Retry if any event replaying was blocked on this.
  40793. retryIfBlockedOn(suspenseInstance);
  40794. }
  40795. function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) {
  40796. {
  40797. warnForUnmatchedText(textInstance, text);
  40798. }
  40799. }
  40800. function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) {
  40801. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  40802. warnForUnmatchedText(textInstance, text);
  40803. }
  40804. }
  40805. function didNotHydrateContainerInstance(parentContainer, instance) {
  40806. {
  40807. if (instance.nodeType === ELEMENT_NODE) {
  40808. warnForDeletedHydratableElement(parentContainer, instance);
  40809. } else if (instance.nodeType === COMMENT_NODE) {// TODO: warnForDeletedHydratableSuspenseBoundary
  40810. } else {
  40811. warnForDeletedHydratableText(parentContainer, instance);
  40812. }
  40813. }
  40814. }
  40815. function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) {
  40816. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  40817. if (instance.nodeType === ELEMENT_NODE) {
  40818. warnForDeletedHydratableElement(parentInstance, instance);
  40819. } else if (instance.nodeType === COMMENT_NODE) {// TODO: warnForDeletedHydratableSuspenseBoundary
  40820. } else {
  40821. warnForDeletedHydratableText(parentInstance, instance);
  40822. }
  40823. }
  40824. }
  40825. function didNotFindHydratableContainerInstance(parentContainer, type, props) {
  40826. {
  40827. warnForInsertedHydratedElement(parentContainer, type, props);
  40828. }
  40829. }
  40830. function didNotFindHydratableContainerTextInstance(parentContainer, text) {
  40831. {
  40832. warnForInsertedHydratedText(parentContainer, text);
  40833. }
  40834. }
  40835. function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) {
  40836. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  40837. warnForInsertedHydratedElement(parentInstance, type, props);
  40838. }
  40839. }
  40840. function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) {
  40841. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  40842. warnForInsertedHydratedText(parentInstance, text);
  40843. }
  40844. }
  40845. function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) {
  40846. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {// TODO: warnForInsertedHydratedSuspense(parentInstance);
  40847. }
  40848. }
  40849. function mountResponderInstance(responder, responderInstance, responderProps, responderState, instance) {
  40850. // Listen to events
  40851. var doc = instance.ownerDocument;
  40852. var _ref = responder,
  40853. rootEventTypes = _ref.rootEventTypes,
  40854. targetEventTypes = _ref.targetEventTypes;
  40855. if (targetEventTypes !== null) {
  40856. listenToEventResponderEventTypes(targetEventTypes, doc);
  40857. }
  40858. if (rootEventTypes !== null) {
  40859. addRootEventTypesForResponderInstance(responderInstance, rootEventTypes);
  40860. listenToEventResponderEventTypes(rootEventTypes, doc);
  40861. }
  40862. mountEventResponder(responder, responderInstance, responderProps, responderState);
  40863. return responderInstance;
  40864. }
  40865. function unmountResponderInstance(responderInstance) {
  40866. if (enableFlareAPI) {
  40867. // TODO stop listening to targetEventTypes
  40868. unmountEventResponder(responderInstance);
  40869. }
  40870. }
  40871. function getFundamentalComponentInstance(fundamentalInstance) {
  40872. if (enableFundamentalAPI) {
  40873. var currentFiber = fundamentalInstance.currentFiber,
  40874. impl = fundamentalInstance.impl,
  40875. props = fundamentalInstance.props,
  40876. state = fundamentalInstance.state;
  40877. var instance = impl.getInstance(null, props, state);
  40878. precacheFiberNode(currentFiber, instance);
  40879. return instance;
  40880. } // Because of the flag above, this gets around the Flow error;
  40881. return null;
  40882. }
  40883. function mountFundamentalComponent(fundamentalInstance) {
  40884. if (enableFundamentalAPI) {
  40885. var impl = fundamentalInstance.impl,
  40886. instance = fundamentalInstance.instance,
  40887. props = fundamentalInstance.props,
  40888. state = fundamentalInstance.state;
  40889. var onMount = impl.onMount;
  40890. if (onMount !== undefined) {
  40891. onMount(null, instance, props, state);
  40892. }
  40893. }
  40894. }
  40895. function shouldUpdateFundamentalComponent(fundamentalInstance) {
  40896. if (enableFundamentalAPI) {
  40897. var impl = fundamentalInstance.impl,
  40898. prevProps = fundamentalInstance.prevProps,
  40899. props = fundamentalInstance.props,
  40900. state = fundamentalInstance.state;
  40901. var shouldUpdate = impl.shouldUpdate;
  40902. if (shouldUpdate !== undefined) {
  40903. return shouldUpdate(null, prevProps, props, state);
  40904. }
  40905. }
  40906. return true;
  40907. }
  40908. function updateFundamentalComponent(fundamentalInstance) {
  40909. if (enableFundamentalAPI) {
  40910. var impl = fundamentalInstance.impl,
  40911. instance = fundamentalInstance.instance,
  40912. prevProps = fundamentalInstance.prevProps,
  40913. props = fundamentalInstance.props,
  40914. state = fundamentalInstance.state;
  40915. var onUpdate = impl.onUpdate;
  40916. if (onUpdate !== undefined) {
  40917. onUpdate(null, instance, prevProps, props, state);
  40918. }
  40919. }
  40920. }
  40921. function unmountFundamentalComponent(fundamentalInstance) {
  40922. if (enableFundamentalAPI) {
  40923. var impl = fundamentalInstance.impl,
  40924. instance = fundamentalInstance.instance,
  40925. props = fundamentalInstance.props,
  40926. state = fundamentalInstance.state;
  40927. var onUnmount = impl.onUnmount;
  40928. if (onUnmount !== undefined) {
  40929. onUnmount(null, instance, props, state);
  40930. }
  40931. }
  40932. }
  40933. var randomKey = Math.random().toString(36).slice(2);
  40934. var internalInstanceKey = '__reactInternalInstance$' + randomKey;
  40935. var internalEventHandlersKey = '__reactEventHandlers$' + randomKey;
  40936. var internalContainerInstanceKey = '__reactContainere$' + randomKey;
  40937. function precacheFiberNode(hostInst, node) {
  40938. node[internalInstanceKey] = hostInst;
  40939. }
  40940. function markContainerAsRoot(hostRoot, node) {
  40941. node[internalContainerInstanceKey] = hostRoot;
  40942. } // Given a DOM node, return the closest HostComponent or HostText fiber ancestor.
  40943. // If the target node is part of a hydrated or not yet rendered subtree, then
  40944. // this may also return a SuspenseComponent or HostRoot to indicate that.
  40945. // Conceptually the HostRoot fiber is a child of the Container node. So if you
  40946. // pass the Container node as the targetNode, you wiill not actually get the
  40947. // HostRoot back. To get to the HostRoot, you need to pass a child of it.
  40948. // The same thing applies to Suspense boundaries.
  40949. function getClosestInstanceFromNode(targetNode) {
  40950. var targetInst = targetNode[internalInstanceKey];
  40951. if (targetInst) {
  40952. // Don't return HostRoot or SuspenseComponent here.
  40953. return targetInst;
  40954. } // If the direct event target isn't a React owned DOM node, we need to look
  40955. // to see if one of its parents is a React owned DOM node.
  40956. var parentNode = targetNode.parentNode;
  40957. while (parentNode) {
  40958. // We'll check if this is a container root that could include
  40959. // React nodes in the future. We need to check this first because
  40960. // if we're a child of a dehydrated container, we need to first
  40961. // find that inner container before moving on to finding the parent
  40962. // instance. Note that we don't check this field on the targetNode
  40963. // itself because the fibers are conceptually between the container
  40964. // node and the first child. It isn't surrounding the container node.
  40965. // If it's not a container, we check if it's an instance.
  40966. targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey];
  40967. if (targetInst) {
  40968. // Since this wasn't the direct target of the event, we might have
  40969. // stepped past dehydrated DOM nodes to get here. However they could
  40970. // also have been non-React nodes. We need to answer which one.
  40971. // If we the instance doesn't have any children, then there can't be
  40972. // a nested suspense boundary within it. So we can use this as a fast
  40973. // bailout. Most of the time, when people add non-React children to
  40974. // the tree, it is using a ref to a child-less DOM node.
  40975. // Normally we'd only need to check one of the fibers because if it
  40976. // has ever gone from having children to deleting them or vice versa
  40977. // it would have deleted the dehydrated boundary nested inside already.
  40978. // However, since the HostRoot starts out with an alternate it might
  40979. // have one on the alternate so we need to check in case this was a
  40980. // root.
  40981. var alternate = targetInst.alternate;
  40982. if (targetInst.child !== null || alternate !== null && alternate.child !== null) {
  40983. // Next we need to figure out if the node that skipped past is
  40984. // nested within a dehydrated boundary and if so, which one.
  40985. var suspenseInstance = getParentSuspenseInstance(targetNode);
  40986. while (suspenseInstance !== null) {
  40987. // We found a suspense instance. That means that we haven't
  40988. // hydrated it yet. Even though we leave the comments in the
  40989. // DOM after hydrating, and there are boundaries in the DOM
  40990. // that could already be hydrated, we wouldn't have found them
  40991. // through this pass since if the target is hydrated it would
  40992. // have had an internalInstanceKey on it.
  40993. // Let's get the fiber associated with the SuspenseComponent
  40994. // as the deepest instance.
  40995. var targetSuspenseInst = suspenseInstance[internalInstanceKey];
  40996. if (targetSuspenseInst) {
  40997. return targetSuspenseInst;
  40998. } // If we don't find a Fiber on the comment, it might be because
  40999. // we haven't gotten to hydrate it yet. There might still be a
  41000. // parent boundary that hasn't above this one so we need to find
  41001. // the outer most that is known.
  41002. suspenseInstance = getParentSuspenseInstance(suspenseInstance); // If we don't find one, then that should mean that the parent
  41003. // host component also hasn't hydrated yet. We can return it
  41004. // below since it will bail out on the isMounted check later.
  41005. }
  41006. }
  41007. return targetInst;
  41008. }
  41009. targetNode = parentNode;
  41010. parentNode = targetNode.parentNode;
  41011. }
  41012. return null;
  41013. }
  41014. /**
  41015. * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent
  41016. * instance, or null if the node was not rendered by this React.
  41017. */
  41018. function getInstanceFromNode$1(node) {
  41019. var inst = node[internalInstanceKey] || node[internalContainerInstanceKey];
  41020. if (inst) {
  41021. if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) {
  41022. return inst;
  41023. } else {
  41024. return null;
  41025. }
  41026. }
  41027. return null;
  41028. }
  41029. /**
  41030. * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
  41031. * DOM node.
  41032. */
  41033. function getNodeFromInstance$1(inst) {
  41034. if (inst.tag === HostComponent || inst.tag === HostText) {
  41035. // In Fiber this, is just the state node right now. We assume it will be
  41036. // a host component or host text.
  41037. return inst.stateNode;
  41038. } // Without this first invariant, passing a non-DOM-component triggers the next
  41039. // invariant for a missing parent, which is super confusing.
  41040. (function () {
  41041. {
  41042. {
  41043. throw ReactError(Error("getNodeFromInstance: Invalid argument."));
  41044. }
  41045. }
  41046. })();
  41047. }
  41048. function getFiberCurrentPropsFromNode$1(node) {
  41049. return node[internalEventHandlersKey] || null;
  41050. }
  41051. function updateFiberProps(node, props) {
  41052. node[internalEventHandlersKey] = props;
  41053. }
  41054. /**
  41055. * These variables store information about text content of a target node,
  41056. * allowing comparison of content before and after a given event.
  41057. *
  41058. * Identify the node where selection currently begins, then observe
  41059. * both its text content and its current position in the DOM. Since the
  41060. * browser may natively replace the target node during composition, we can
  41061. * use its position to find its replacement.
  41062. *
  41063. *
  41064. */
  41065. var root = null;
  41066. var startText = null;
  41067. var fallbackText = null;
  41068. function initialize(nativeEventTarget) {
  41069. root = nativeEventTarget;
  41070. startText = getText();
  41071. return true;
  41072. }
  41073. function reset() {
  41074. root = null;
  41075. startText = null;
  41076. fallbackText = null;
  41077. }
  41078. function getData() {
  41079. if (fallbackText) {
  41080. return fallbackText;
  41081. }
  41082. var start;
  41083. var startValue = startText;
  41084. var startLength = startValue.length;
  41085. var end;
  41086. var endValue = getText();
  41087. var endLength = endValue.length;
  41088. for (start = 0; start < startLength; start++) {
  41089. if (startValue[start] !== endValue[start]) {
  41090. break;
  41091. }
  41092. }
  41093. var minEnd = startLength - start;
  41094. for (end = 1; end <= minEnd; end++) {
  41095. if (startValue[startLength - end] !== endValue[endLength - end]) {
  41096. break;
  41097. }
  41098. }
  41099. var sliceTail = end > 1 ? 1 - end : undefined;
  41100. fallbackText = endValue.slice(start, sliceTail);
  41101. return fallbackText;
  41102. }
  41103. function getText() {
  41104. if ('value' in root) {
  41105. return root.value;
  41106. }
  41107. return root.textContent;
  41108. }
  41109. /**
  41110. * @interface Event
  41111. * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
  41112. */
  41113. var SyntheticCompositionEvent = SyntheticEvent.extend({
  41114. data: null
  41115. });
  41116. /**
  41117. * @interface Event
  41118. * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
  41119. * /#events-inputevents
  41120. */
  41121. var SyntheticInputEvent = SyntheticEvent.extend({
  41122. data: null
  41123. });
  41124. var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
  41125. var START_KEYCODE = 229;
  41126. var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window;
  41127. var documentMode = null;
  41128. if (canUseDOM && 'documentMode' in document) {
  41129. documentMode = document.documentMode;
  41130. } // Webkit offers a very useful `textInput` event that can be used to
  41131. // directly represent `beforeInput`. The IE `textinput` event is not as
  41132. // useful, so we don't use it.
  41133. var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode; // In IE9+, we have access to composition events, but the data supplied
  41134. // by the native compositionend event may be incorrect. Japanese ideographic
  41135. // spaces, for instance (\u3000) are not recorded correctly.
  41136. var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
  41137. var SPACEBAR_CODE = 32;
  41138. var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); // Events and their corresponding property names.
  41139. var eventTypes$1 = {
  41140. beforeInput: {
  41141. phasedRegistrationNames: {
  41142. bubbled: 'onBeforeInput',
  41143. captured: 'onBeforeInputCapture'
  41144. },
  41145. dependencies: [TOP_COMPOSITION_END, TOP_KEY_PRESS, TOP_TEXT_INPUT, TOP_PASTE]
  41146. },
  41147. compositionEnd: {
  41148. phasedRegistrationNames: {
  41149. bubbled: 'onCompositionEnd',
  41150. captured: 'onCompositionEndCapture'
  41151. },
  41152. dependencies: [TOP_BLUR, TOP_COMPOSITION_END, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  41153. },
  41154. compositionStart: {
  41155. phasedRegistrationNames: {
  41156. bubbled: 'onCompositionStart',
  41157. captured: 'onCompositionStartCapture'
  41158. },
  41159. dependencies: [TOP_BLUR, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  41160. },
  41161. compositionUpdate: {
  41162. phasedRegistrationNames: {
  41163. bubbled: 'onCompositionUpdate',
  41164. captured: 'onCompositionUpdateCapture'
  41165. },
  41166. dependencies: [TOP_BLUR, TOP_COMPOSITION_UPDATE, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  41167. }
  41168. }; // Track whether we've ever handled a keypress on the space key.
  41169. var hasSpaceKeypress = false;
  41170. /**
  41171. * Return whether a native keypress event is assumed to be a command.
  41172. * This is required because Firefox fires `keypress` events for key commands
  41173. * (cut, copy, select-all, etc.) even though no character is inserted.
  41174. */
  41175. function isKeypressCommand(nativeEvent) {
  41176. return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command.
  41177. !(nativeEvent.ctrlKey && nativeEvent.altKey);
  41178. }
  41179. /**
  41180. * Translate native top level events into event types.
  41181. *
  41182. * @param {string} topLevelType
  41183. * @return {object}
  41184. */
  41185. function getCompositionEventType(topLevelType) {
  41186. switch (topLevelType) {
  41187. case TOP_COMPOSITION_START:
  41188. return eventTypes$1.compositionStart;
  41189. case TOP_COMPOSITION_END:
  41190. return eventTypes$1.compositionEnd;
  41191. case TOP_COMPOSITION_UPDATE:
  41192. return eventTypes$1.compositionUpdate;
  41193. }
  41194. }
  41195. /**
  41196. * Does our fallback best-guess model think this event signifies that
  41197. * composition has begun?
  41198. *
  41199. * @param {string} topLevelType
  41200. * @param {object} nativeEvent
  41201. * @return {boolean}
  41202. */
  41203. function isFallbackCompositionStart(topLevelType, nativeEvent) {
  41204. return topLevelType === TOP_KEY_DOWN && nativeEvent.keyCode === START_KEYCODE;
  41205. }
  41206. /**
  41207. * Does our fallback mode think that this event is the end of composition?
  41208. *
  41209. * @param {string} topLevelType
  41210. * @param {object} nativeEvent
  41211. * @return {boolean}
  41212. */
  41213. function isFallbackCompositionEnd(topLevelType, nativeEvent) {
  41214. switch (topLevelType) {
  41215. case TOP_KEY_UP:
  41216. // Command keys insert or clear IME input.
  41217. return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
  41218. case TOP_KEY_DOWN:
  41219. // Expect IME keyCode on each keydown. If we get any other
  41220. // code we must have exited earlier.
  41221. return nativeEvent.keyCode !== START_KEYCODE;
  41222. case TOP_KEY_PRESS:
  41223. case TOP_MOUSE_DOWN:
  41224. case TOP_BLUR:
  41225. // Events are not possible without cancelling IME.
  41226. return true;
  41227. default:
  41228. return false;
  41229. }
  41230. }
  41231. /**
  41232. * Google Input Tools provides composition data via a CustomEvent,
  41233. * with the `data` property populated in the `detail` object. If this
  41234. * is available on the event object, use it. If not, this is a plain
  41235. * composition event and we have nothing special to extract.
  41236. *
  41237. * @param {object} nativeEvent
  41238. * @return {?string}
  41239. */
  41240. function getDataFromCustomEvent(nativeEvent) {
  41241. var detail = nativeEvent.detail;
  41242. if (typeof detail === 'object' && 'data' in detail) {
  41243. return detail.data;
  41244. }
  41245. return null;
  41246. }
  41247. /**
  41248. * Check if a composition event was triggered by Korean IME.
  41249. * Our fallback mode does not work well with IE's Korean IME,
  41250. * so just use native composition events when Korean IME is used.
  41251. * Although CompositionEvent.locale property is deprecated,
  41252. * it is available in IE, where our fallback mode is enabled.
  41253. *
  41254. * @param {object} nativeEvent
  41255. * @return {boolean}
  41256. */
  41257. function isUsingKoreanIME(nativeEvent) {
  41258. return nativeEvent.locale === 'ko';
  41259. } // Track the current IME composition status, if any.
  41260. var isComposing = false;
  41261. /**
  41262. * @return {?object} A SyntheticCompositionEvent.
  41263. */
  41264. function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  41265. var eventType;
  41266. var fallbackData;
  41267. if (canUseCompositionEvent) {
  41268. eventType = getCompositionEventType(topLevelType);
  41269. } else if (!isComposing) {
  41270. if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
  41271. eventType = eventTypes$1.compositionStart;
  41272. }
  41273. } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  41274. eventType = eventTypes$1.compositionEnd;
  41275. }
  41276. if (!eventType) {
  41277. return null;
  41278. }
  41279. if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) {
  41280. // The current composition is stored statically and must not be
  41281. // overwritten while composition continues.
  41282. if (!isComposing && eventType === eventTypes$1.compositionStart) {
  41283. isComposing = initialize(nativeEventTarget);
  41284. } else if (eventType === eventTypes$1.compositionEnd) {
  41285. if (isComposing) {
  41286. fallbackData = getData();
  41287. }
  41288. }
  41289. }
  41290. var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget);
  41291. if (fallbackData) {
  41292. // Inject data generated from fallback path into the synthetic event.
  41293. // This matches the property of native CompositionEventInterface.
  41294. event.data = fallbackData;
  41295. } else {
  41296. var customData = getDataFromCustomEvent(nativeEvent);
  41297. if (customData !== null) {
  41298. event.data = customData;
  41299. }
  41300. }
  41301. accumulateTwoPhaseDispatches(event);
  41302. return event;
  41303. }
  41304. /**
  41305. * @param {TopLevelType} topLevelType Number from `TopLevelType`.
  41306. * @param {object} nativeEvent Native browser event.
  41307. * @return {?string} The string corresponding to this `beforeInput` event.
  41308. */
  41309. function getNativeBeforeInputChars(topLevelType, nativeEvent) {
  41310. switch (topLevelType) {
  41311. case TOP_COMPOSITION_END:
  41312. return getDataFromCustomEvent(nativeEvent);
  41313. case TOP_KEY_PRESS:
  41314. /**
  41315. * If native `textInput` events are available, our goal is to make
  41316. * use of them. However, there is a special case: the spacebar key.
  41317. * In Webkit, preventing default on a spacebar `textInput` event
  41318. * cancels character insertion, but it *also* causes the browser
  41319. * to fall back to its default spacebar behavior of scrolling the
  41320. * page.
  41321. *
  41322. * Tracking at:
  41323. * https://code.google.com/p/chromium/issues/detail?id=355103
  41324. *
  41325. * To avoid this issue, use the keypress event as if no `textInput`
  41326. * event is available.
  41327. */
  41328. var which = nativeEvent.which;
  41329. if (which !== SPACEBAR_CODE) {
  41330. return null;
  41331. }
  41332. hasSpaceKeypress = true;
  41333. return SPACEBAR_CHAR;
  41334. case TOP_TEXT_INPUT:
  41335. // Record the characters to be added to the DOM.
  41336. var chars = nativeEvent.data; // If it's a spacebar character, assume that we have already handled
  41337. // it at the keypress level and bail immediately. Android Chrome
  41338. // doesn't give us keycodes, so we need to ignore it.
  41339. if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
  41340. return null;
  41341. }
  41342. return chars;
  41343. default:
  41344. // For other native event types, do nothing.
  41345. return null;
  41346. }
  41347. }
  41348. /**
  41349. * For browsers that do not provide the `textInput` event, extract the
  41350. * appropriate string to use for SyntheticInputEvent.
  41351. *
  41352. * @param {number} topLevelType Number from `TopLevelEventTypes`.
  41353. * @param {object} nativeEvent Native browser event.
  41354. * @return {?string} The fallback string for this `beforeInput` event.
  41355. */
  41356. function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
  41357. // If we are currently composing (IME) and using a fallback to do so,
  41358. // try to extract the composed characters from the fallback object.
  41359. // If composition event is available, we extract a string only at
  41360. // compositionevent, otherwise extract it at fallback events.
  41361. if (isComposing) {
  41362. if (topLevelType === TOP_COMPOSITION_END || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  41363. var chars = getData();
  41364. reset();
  41365. isComposing = false;
  41366. return chars;
  41367. }
  41368. return null;
  41369. }
  41370. switch (topLevelType) {
  41371. case TOP_PASTE:
  41372. // If a paste event occurs after a keypress, throw out the input
  41373. // chars. Paste events should not lead to BeforeInput events.
  41374. return null;
  41375. case TOP_KEY_PRESS:
  41376. /**
  41377. * As of v27, Firefox may fire keypress events even when no character
  41378. * will be inserted. A few possibilities:
  41379. *
  41380. * - `which` is `0`. Arrow keys, Esc key, etc.
  41381. *
  41382. * - `which` is the pressed key code, but no char is available.
  41383. * Ex: 'AltGr + d` in Polish. There is no modified character for
  41384. * this key combination and no character is inserted into the
  41385. * document, but FF fires the keypress for char code `100` anyway.
  41386. * No `input` event will occur.
  41387. *
  41388. * - `which` is the pressed key code, but a command combination is
  41389. * being used. Ex: `Cmd+C`. No character is inserted, and no
  41390. * `input` event will occur.
  41391. */
  41392. if (!isKeypressCommand(nativeEvent)) {
  41393. // IE fires the `keypress` event when a user types an emoji via
  41394. // Touch keyboard of Windows. In such a case, the `char` property
  41395. // holds an emoji character like `\uD83D\uDE0A`. Because its length
  41396. // is 2, the property `which` does not represent an emoji correctly.
  41397. // In such a case, we directly return the `char` property instead of
  41398. // using `which`.
  41399. if (nativeEvent.char && nativeEvent.char.length > 1) {
  41400. return nativeEvent.char;
  41401. } else if (nativeEvent.which) {
  41402. return String.fromCharCode(nativeEvent.which);
  41403. }
  41404. }
  41405. return null;
  41406. case TOP_COMPOSITION_END:
  41407. return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data;
  41408. default:
  41409. return null;
  41410. }
  41411. }
  41412. /**
  41413. * Extract a SyntheticInputEvent for `beforeInput`, based on either native
  41414. * `textInput` or fallback behavior.
  41415. *
  41416. * @return {?object} A SyntheticInputEvent.
  41417. */
  41418. function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  41419. var chars;
  41420. if (canUseTextInputEvent) {
  41421. chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
  41422. } else {
  41423. chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
  41424. } // If no characters are being inserted, no BeforeInput event should
  41425. // be fired.
  41426. if (!chars) {
  41427. return null;
  41428. }
  41429. var event = SyntheticInputEvent.getPooled(eventTypes$1.beforeInput, targetInst, nativeEvent, nativeEventTarget);
  41430. event.data = chars;
  41431. accumulateTwoPhaseDispatches(event);
  41432. return event;
  41433. }
  41434. /**
  41435. * Create an `onBeforeInput` event to match
  41436. * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
  41437. *
  41438. * This event plugin is based on the native `textInput` event
  41439. * available in Chrome, Safari, Opera, and IE. This event fires after
  41440. * `onKeyPress` and `onCompositionEnd`, but before `onInput`.
  41441. *
  41442. * `beforeInput` is spec'd but not implemented in any browsers, and
  41443. * the `input` event does not provide any useful information about what has
  41444. * actually been added, contrary to the spec. Thus, `textInput` is the best
  41445. * available event to identify the characters that have actually been inserted
  41446. * into the target node.
  41447. *
  41448. * This plugin is also responsible for emitting `composition` events, thus
  41449. * allowing us to share composition fallback code for both `beforeInput` and
  41450. * `composition` event types.
  41451. */
  41452. var BeforeInputEventPlugin = {
  41453. eventTypes: eventTypes$1,
  41454. extractEvents: function (topLevelType, eventSystemFlags, targetInst, nativeEvent, nativeEventTarget) {
  41455. var composition = extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  41456. var beforeInput = extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  41457. if (composition === null) {
  41458. return beforeInput;
  41459. }
  41460. if (beforeInput === null) {
  41461. return composition;
  41462. }
  41463. return [composition, beforeInput];
  41464. }
  41465. };
  41466. /**
  41467. * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
  41468. */
  41469. var supportedInputTypes = {
  41470. color: true,
  41471. date: true,
  41472. datetime: true,
  41473. 'datetime-local': true,
  41474. email: true,
  41475. month: true,
  41476. number: true,
  41477. password: true,
  41478. range: true,
  41479. search: true,
  41480. tel: true,
  41481. text: true,
  41482. time: true,
  41483. url: true,
  41484. week: true
  41485. };
  41486. function isTextInputElement(elem) {
  41487. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  41488. if (nodeName === 'input') {
  41489. return !!supportedInputTypes[elem.type];
  41490. }
  41491. if (nodeName === 'textarea') {
  41492. return true;
  41493. }
  41494. return false;
  41495. }
  41496. var eventTypes$2 = {
  41497. change: {
  41498. phasedRegistrationNames: {
  41499. bubbled: 'onChange',
  41500. captured: 'onChangeCapture'
  41501. },
  41502. dependencies: [TOP_BLUR, TOP_CHANGE, TOP_CLICK, TOP_FOCUS, TOP_INPUT, TOP_KEY_DOWN, TOP_KEY_UP, TOP_SELECTION_CHANGE]
  41503. }
  41504. };
  41505. function createAndAccumulateChangeEvent(inst, nativeEvent, target) {
  41506. var event = SyntheticEvent.getPooled(eventTypes$2.change, inst, nativeEvent, target);
  41507. event.type = 'change'; // Flag this event loop as needing state restore.
  41508. enqueueStateRestore(target);
  41509. accumulateTwoPhaseDispatches(event);
  41510. return event;
  41511. }
  41512. /**
  41513. * For IE shims
  41514. */
  41515. var activeElement = null;
  41516. var activeElementInst = null;
  41517. /**
  41518. * SECTION: handle `change` event
  41519. */
  41520. function shouldUseChangeEvent(elem) {
  41521. var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
  41522. return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
  41523. }
  41524. function manualDispatchChangeEvent(nativeEvent) {
  41525. var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent)); // If change and propertychange bubbled, we'd just bind to it like all the
  41526. // other events and have it go through ReactBrowserEventEmitter. Since it
  41527. // doesn't, we manually listen for the events and so we have to enqueue and
  41528. // process the abstract event manually.
  41529. //
  41530. // Batching is necessary here in order to ensure that all event handlers run
  41531. // before the next rerender (including event handlers attached to ancestor
  41532. // elements instead of directly on the input). Without this, controlled
  41533. // components don't work properly in conjunction with event bubbling because
  41534. // the component is rerendered and the value reverted before all the event
  41535. // handlers can run. See https://github.com/facebook/react/issues/708.
  41536. batchedUpdates(runEventInBatch, event);
  41537. }
  41538. function runEventInBatch(event) {
  41539. runEventsInBatch(event);
  41540. }
  41541. function getInstIfValueChanged(targetInst) {
  41542. var targetNode = getNodeFromInstance$1(targetInst);
  41543. if (updateValueIfChanged(targetNode)) {
  41544. return targetInst;
  41545. }
  41546. }
  41547. function getTargetInstForChangeEvent(topLevelType, targetInst) {
  41548. if (topLevelType === TOP_CHANGE) {
  41549. return targetInst;
  41550. }
  41551. }
  41552. /**
  41553. * SECTION: handle `input` event
  41554. */
  41555. var isInputEventSupported = false;
  41556. if (canUseDOM) {
  41557. // IE9 claims to support the input event but fails to trigger it when
  41558. // deleting text, so we ignore its input events.
  41559. isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9);
  41560. }
  41561. /**
  41562. * (For IE <=9) Starts tracking propertychange events on the passed-in element
  41563. * and override the value property so that we can distinguish user events from
  41564. * value changes in JS.
  41565. */
  41566. function startWatchingForValueChange(target, targetInst) {
  41567. activeElement = target;
  41568. activeElementInst = targetInst;
  41569. activeElement.attachEvent('onpropertychange', handlePropertyChange);
  41570. }
  41571. /**
  41572. * (For IE <=9) Removes the event listeners from the currently-tracked element,
  41573. * if any exists.
  41574. */
  41575. function stopWatchingForValueChange() {
  41576. if (!activeElement) {
  41577. return;
  41578. }
  41579. activeElement.detachEvent('onpropertychange', handlePropertyChange);
  41580. activeElement = null;
  41581. activeElementInst = null;
  41582. }
  41583. /**
  41584. * (For IE <=9) Handles a propertychange event, sending a `change` event if
  41585. * the value of the active element has changed.
  41586. */
  41587. function handlePropertyChange(nativeEvent) {
  41588. if (nativeEvent.propertyName !== 'value') {
  41589. return;
  41590. }
  41591. if (getInstIfValueChanged(activeElementInst)) {
  41592. manualDispatchChangeEvent(nativeEvent);
  41593. }
  41594. }
  41595. function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) {
  41596. if (topLevelType === TOP_FOCUS) {
  41597. // In IE9, propertychange fires for most input events but is buggy and
  41598. // doesn't fire when text is deleted, but conveniently, selectionchange
  41599. // appears to fire in all of the remaining cases so we catch those and
  41600. // forward the event if the value has changed
  41601. // In either case, we don't want to call the event handler if the value
  41602. // is changed from JS so we redefine a setter for `.value` that updates
  41603. // our activeElementValue variable, allowing us to ignore those changes
  41604. //
  41605. // stopWatching() should be a noop here but we call it just in case we
  41606. // missed a blur event somehow.
  41607. stopWatchingForValueChange();
  41608. startWatchingForValueChange(target, targetInst);
  41609. } else if (topLevelType === TOP_BLUR) {
  41610. stopWatchingForValueChange();
  41611. }
  41612. } // For IE8 and IE9.
  41613. function getTargetInstForInputEventPolyfill(topLevelType, targetInst) {
  41614. if (topLevelType === TOP_SELECTION_CHANGE || topLevelType === TOP_KEY_UP || topLevelType === TOP_KEY_DOWN) {
  41615. // On the selectionchange event, the target is just document which isn't
  41616. // helpful for us so just check activeElement instead.
  41617. //
  41618. // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
  41619. // propertychange on the first input event after setting `value` from a
  41620. // script and fires only keydown, keypress, keyup. Catching keyup usually
  41621. // gets it and catching keydown lets us fire an event for the first
  41622. // keystroke if user does a key repeat (it'll be a little delayed: right
  41623. // before the second keystroke). Other input methods (e.g., paste) seem to
  41624. // fire selectionchange normally.
  41625. return getInstIfValueChanged(activeElementInst);
  41626. }
  41627. }
  41628. /**
  41629. * SECTION: handle `click` event
  41630. */
  41631. function shouldUseClickEvent(elem) {
  41632. // Use the `click` event to detect changes to checkbox and radio inputs.
  41633. // This approach works across all browsers, whereas `change` does not fire
  41634. // until `blur` in IE8.
  41635. var nodeName = elem.nodeName;
  41636. return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
  41637. }
  41638. function getTargetInstForClickEvent(topLevelType, targetInst) {
  41639. if (topLevelType === TOP_CLICK) {
  41640. return getInstIfValueChanged(targetInst);
  41641. }
  41642. }
  41643. function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) {
  41644. if (topLevelType === TOP_INPUT || topLevelType === TOP_CHANGE) {
  41645. return getInstIfValueChanged(targetInst);
  41646. }
  41647. }
  41648. function handleControlledInputBlur(node) {
  41649. var state = node._wrapperState;
  41650. if (!state || !state.controlled || node.type !== 'number') {
  41651. return;
  41652. }
  41653. if (!disableInputAttributeSyncing) {
  41654. // If controlled, assign the value attribute to the current value on blur
  41655. setDefaultValue(node, 'number', node.value);
  41656. }
  41657. }
  41658. /**
  41659. * This plugin creates an `onChange` event that normalizes change events
  41660. * across form elements. This event fires at a time when it's possible to
  41661. * change the element's value without seeing a flicker.
  41662. *
  41663. * Supported elements are:
  41664. * - input (see `isTextInputElement`)
  41665. * - textarea
  41666. * - select
  41667. */
  41668. var ChangeEventPlugin = {
  41669. eventTypes: eventTypes$2,
  41670. _isInputEventSupported: isInputEventSupported,
  41671. extractEvents: function (topLevelType, eventSystemFlags, targetInst, nativeEvent, nativeEventTarget) {
  41672. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  41673. var getTargetInstFunc, handleEventFunc;
  41674. if (shouldUseChangeEvent(targetNode)) {
  41675. getTargetInstFunc = getTargetInstForChangeEvent;
  41676. } else if (isTextInputElement(targetNode)) {
  41677. if (isInputEventSupported) {
  41678. getTargetInstFunc = getTargetInstForInputOrChangeEvent;
  41679. } else {
  41680. getTargetInstFunc = getTargetInstForInputEventPolyfill;
  41681. handleEventFunc = handleEventsForInputEventPolyfill;
  41682. }
  41683. } else if (shouldUseClickEvent(targetNode)) {
  41684. getTargetInstFunc = getTargetInstForClickEvent;
  41685. }
  41686. if (getTargetInstFunc) {
  41687. var inst = getTargetInstFunc(topLevelType, targetInst);
  41688. if (inst) {
  41689. var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget);
  41690. return event;
  41691. }
  41692. }
  41693. if (handleEventFunc) {
  41694. handleEventFunc(topLevelType, targetNode, targetInst);
  41695. } // When blurring, set the value attribute for number inputs
  41696. if (topLevelType === TOP_BLUR) {
  41697. handleControlledInputBlur(targetNode);
  41698. }
  41699. }
  41700. };
  41701. /**
  41702. * Module that is injectable into `EventPluginHub`, that specifies a
  41703. * deterministic ordering of `EventPlugin`s. A convenient way to reason about
  41704. * plugins, without having to package every one of them. This is better than
  41705. * having plugins be ordered in the same order that they are injected because
  41706. * that ordering would be influenced by the packaging order.
  41707. * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
  41708. * preventing default on events is convenient in `SimpleEventPlugin` handlers.
  41709. */
  41710. var DOMEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin'];
  41711. var eventTypes$3 = {
  41712. mouseEnter: {
  41713. registrationName: 'onMouseEnter',
  41714. dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER]
  41715. },
  41716. mouseLeave: {
  41717. registrationName: 'onMouseLeave',
  41718. dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER]
  41719. },
  41720. pointerEnter: {
  41721. registrationName: 'onPointerEnter',
  41722. dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER]
  41723. },
  41724. pointerLeave: {
  41725. registrationName: 'onPointerLeave',
  41726. dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER]
  41727. }
  41728. };
  41729. var EnterLeaveEventPlugin = {
  41730. eventTypes: eventTypes$3,
  41731. /**
  41732. * For almost every interaction we care about, there will be both a top-level
  41733. * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
  41734. * we do not extract duplicate events. However, moving the mouse into the
  41735. * browser from outside will not fire a `mouseout` event. In this case, we use
  41736. * the `mouseover` top-level event.
  41737. */
  41738. extractEvents: function (topLevelType, eventSystemFlags, targetInst, nativeEvent, nativeEventTarget) {
  41739. var isOverEvent = topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER;
  41740. var isOutEvent = topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT;
  41741. if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0 && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
  41742. // If this is an over event with a target, then we've already dispatched
  41743. // the event in the out event of the other target. If this is replayed,
  41744. // then it's because we couldn't dispatch against this target previously
  41745. // so we have to do it now instead.
  41746. return null;
  41747. }
  41748. if (!isOutEvent && !isOverEvent) {
  41749. // Must not be a mouse or pointer in or out - ignoring.
  41750. return null;
  41751. }
  41752. var win;
  41753. if (nativeEventTarget.window === nativeEventTarget) {
  41754. // `nativeEventTarget` is probably a window object.
  41755. win = nativeEventTarget;
  41756. } else {
  41757. // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
  41758. var doc = nativeEventTarget.ownerDocument;
  41759. if (doc) {
  41760. win = doc.defaultView || doc.parentWindow;
  41761. } else {
  41762. win = window;
  41763. }
  41764. }
  41765. var from;
  41766. var to;
  41767. if (isOutEvent) {
  41768. from = targetInst;
  41769. var related = nativeEvent.relatedTarget || nativeEvent.toElement;
  41770. to = related ? getClosestInstanceFromNode(related) : null;
  41771. if (to !== null) {
  41772. var nearestMounted = getNearestMountedFiber(to);
  41773. if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) {
  41774. to = null;
  41775. }
  41776. }
  41777. } else {
  41778. // Moving to a node from outside the window.
  41779. from = null;
  41780. to = targetInst;
  41781. }
  41782. if (from === to) {
  41783. // Nothing pertains to our managed components.
  41784. return null;
  41785. }
  41786. var eventInterface, leaveEventType, enterEventType, eventTypePrefix;
  41787. if (topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_MOUSE_OVER) {
  41788. eventInterface = SyntheticMouseEvent;
  41789. leaveEventType = eventTypes$3.mouseLeave;
  41790. enterEventType = eventTypes$3.mouseEnter;
  41791. eventTypePrefix = 'mouse';
  41792. } else if (topLevelType === TOP_POINTER_OUT || topLevelType === TOP_POINTER_OVER) {
  41793. eventInterface = SyntheticPointerEvent;
  41794. leaveEventType = eventTypes$3.pointerLeave;
  41795. enterEventType = eventTypes$3.pointerEnter;
  41796. eventTypePrefix = 'pointer';
  41797. }
  41798. var fromNode = from == null ? win : getNodeFromInstance$1(from);
  41799. var toNode = to == null ? win : getNodeFromInstance$1(to);
  41800. var leave = eventInterface.getPooled(leaveEventType, from, nativeEvent, nativeEventTarget);
  41801. leave.type = eventTypePrefix + 'leave';
  41802. leave.target = fromNode;
  41803. leave.relatedTarget = toNode;
  41804. var enter = eventInterface.getPooled(enterEventType, to, nativeEvent, nativeEventTarget);
  41805. enter.type = eventTypePrefix + 'enter';
  41806. enter.target = toNode;
  41807. enter.relatedTarget = fromNode;
  41808. accumulateEnterLeaveDispatches(leave, enter, from, to);
  41809. return [leave, enter];
  41810. }
  41811. };
  41812. /**
  41813. * inlined Object.is polyfill to avoid requiring consumers ship their own
  41814. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  41815. */
  41816. function is(x, y) {
  41817. return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
  41818. ;
  41819. }
  41820. var is$1 = typeof Object.is === 'function' ? Object.is : is;
  41821. var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
  41822. /**
  41823. * Performs equality by iterating through keys on an object and returning false
  41824. * when any key has values which are not strictly equal between the arguments.
  41825. * Returns true when the values of all keys are strictly equal.
  41826. */
  41827. function shallowEqual(objA, objB) {
  41828. if (is$1(objA, objB)) {
  41829. return true;
  41830. }
  41831. if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
  41832. return false;
  41833. }
  41834. var keysA = Object.keys(objA);
  41835. var keysB = Object.keys(objB);
  41836. if (keysA.length !== keysB.length) {
  41837. return false;
  41838. } // Test for A's keys different from B.
  41839. for (var i = 0; i < keysA.length; i++) {
  41840. if (!hasOwnProperty$2.call(objB, keysA[i]) || !is$1(objA[keysA[i]], objB[keysA[i]])) {
  41841. return false;
  41842. }
  41843. }
  41844. return true;
  41845. }
  41846. var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11;
  41847. var eventTypes$4 = {
  41848. select: {
  41849. phasedRegistrationNames: {
  41850. bubbled: 'onSelect',
  41851. captured: 'onSelectCapture'
  41852. },
  41853. 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]
  41854. }
  41855. };
  41856. var activeElement$1 = null;
  41857. var activeElementInst$1 = null;
  41858. var lastSelection = null;
  41859. var mouseDown = false;
  41860. /**
  41861. * Get an object which is a unique representation of the current selection.
  41862. *
  41863. * The return value will not be consistent across nodes or browsers, but
  41864. * two identical selections on the same node will return identical objects.
  41865. *
  41866. * @param {DOMElement} node
  41867. * @return {object}
  41868. */
  41869. function getSelection$1(node) {
  41870. if ('selectionStart' in node && hasSelectionCapabilities(node)) {
  41871. return {
  41872. start: node.selectionStart,
  41873. end: node.selectionEnd
  41874. };
  41875. } else {
  41876. var win = node.ownerDocument && node.ownerDocument.defaultView || window;
  41877. var selection = win.getSelection();
  41878. return {
  41879. anchorNode: selection.anchorNode,
  41880. anchorOffset: selection.anchorOffset,
  41881. focusNode: selection.focusNode,
  41882. focusOffset: selection.focusOffset
  41883. };
  41884. }
  41885. }
  41886. /**
  41887. * Get document associated with the event target.
  41888. *
  41889. * @param {object} nativeEventTarget
  41890. * @return {Document}
  41891. */
  41892. function getEventTargetDocument(eventTarget) {
  41893. return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument;
  41894. }
  41895. /**
  41896. * Poll selection to see whether it's changed.
  41897. *
  41898. * @param {object} nativeEvent
  41899. * @param {object} nativeEventTarget
  41900. * @return {?SyntheticEvent}
  41901. */
  41902. function constructSelectEvent(nativeEvent, nativeEventTarget) {
  41903. // Ensure we have the right element, and that the user is not dragging a
  41904. // selection (this matches native `select` event behavior). In HTML5, select
  41905. // fires only on input and textarea thus if there's no focused element we
  41906. // won't dispatch.
  41907. var doc = getEventTargetDocument(nativeEventTarget);
  41908. if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) {
  41909. return null;
  41910. } // Only fire when selection has actually changed.
  41911. var currentSelection = getSelection$1(activeElement$1);
  41912. if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
  41913. lastSelection = currentSelection;
  41914. var syntheticEvent = SyntheticEvent.getPooled(eventTypes$4.select, activeElementInst$1, nativeEvent, nativeEventTarget);
  41915. syntheticEvent.type = 'select';
  41916. syntheticEvent.target = activeElement$1;
  41917. accumulateTwoPhaseDispatches(syntheticEvent);
  41918. return syntheticEvent;
  41919. }
  41920. return null;
  41921. }
  41922. /**
  41923. * This plugin creates an `onSelect` event that normalizes select events
  41924. * across form elements.
  41925. *
  41926. * Supported elements are:
  41927. * - input (see `isTextInputElement`)
  41928. * - textarea
  41929. * - contentEditable
  41930. *
  41931. * This differs from native browser implementations in the following ways:
  41932. * - Fires on contentEditable fields as well as inputs.
  41933. * - Fires for collapsed selection.
  41934. * - Fires after user input.
  41935. */
  41936. var SelectEventPlugin = {
  41937. eventTypes: eventTypes$4,
  41938. extractEvents: function (topLevelType, eventSystemFlags, targetInst, nativeEvent, nativeEventTarget) {
  41939. var doc = getEventTargetDocument(nativeEventTarget); // Track whether all listeners exists for this plugin. If none exist, we do
  41940. // not extract events. See #3639.
  41941. if (!doc || !isListeningToAllDependencies('onSelect', doc)) {
  41942. return null;
  41943. }
  41944. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  41945. switch (topLevelType) {
  41946. // Track the input node that has focus.
  41947. case TOP_FOCUS:
  41948. if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') {
  41949. activeElement$1 = targetNode;
  41950. activeElementInst$1 = targetInst;
  41951. lastSelection = null;
  41952. }
  41953. break;
  41954. case TOP_BLUR:
  41955. activeElement$1 = null;
  41956. activeElementInst$1 = null;
  41957. lastSelection = null;
  41958. break;
  41959. // Don't fire the event while the user is dragging. This matches the
  41960. // semantics of the native select event.
  41961. case TOP_MOUSE_DOWN:
  41962. mouseDown = true;
  41963. break;
  41964. case TOP_CONTEXT_MENU:
  41965. case TOP_MOUSE_UP:
  41966. case TOP_DRAG_END:
  41967. mouseDown = false;
  41968. return constructSelectEvent(nativeEvent, nativeEventTarget);
  41969. // Chrome and IE fire non-standard event when selection is changed (and
  41970. // sometimes when it hasn't). IE's event fires out of order with respect
  41971. // to key and input events on deletion, so we discard it.
  41972. //
  41973. // Firefox doesn't support selectionchange, so check selection status
  41974. // after each key entry. The selection changes after keydown and before
  41975. // keyup, but we check on keydown as well in the case of holding down a
  41976. // key, when multiple keydown events are fired but only one keyup is.
  41977. // This is also our approach for IE handling, for the reason above.
  41978. case TOP_SELECTION_CHANGE:
  41979. if (skipSelectionChangeEvent) {
  41980. break;
  41981. }
  41982. // falls through
  41983. case TOP_KEY_DOWN:
  41984. case TOP_KEY_UP:
  41985. return constructSelectEvent(nativeEvent, nativeEventTarget);
  41986. }
  41987. return null;
  41988. }
  41989. };
  41990. /**
  41991. * Inject modules for resolving DOM hierarchy and plugin ordering.
  41992. */
  41993. injection.injectEventPluginOrder(DOMEventPluginOrder);
  41994. setComponentTree(getFiberCurrentPropsFromNode$1, getInstanceFromNode$1, getNodeFromInstance$1);
  41995. /**
  41996. * Some important event plugins included by default (without having to require
  41997. * them).
  41998. */
  41999. injection.injectEventPluginsByName({
  42000. SimpleEventPlugin: SimpleEventPlugin,
  42001. EnterLeaveEventPlugin: EnterLeaveEventPlugin,
  42002. ChangeEventPlugin: ChangeEventPlugin,
  42003. SelectEventPlugin: SelectEventPlugin,
  42004. BeforeInputEventPlugin: BeforeInputEventPlugin
  42005. });
  42006. // Prefix measurements so that it's possible to filter them.
  42007. // Longer prefixes are hard to read in DevTools.
  42008. var reactEmoji = "\u269B";
  42009. var warningEmoji = "\u26D4";
  42010. 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.
  42011. // TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
  42012. var currentFiber = null; // If we're in the middle of user code, which fiber and method is it?
  42013. // Reusing `currentFiber` would be confusing for this because user code fiber
  42014. // can change during commit phase too, but we don't need to unwind it (since
  42015. // lifecycles in the commit phase don't resemble a tree).
  42016. var currentPhase = null;
  42017. var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem,
  42018. // so we will keep track of it, and include it in the report.
  42019. // Track commits caused by cascading updates.
  42020. var isCommitting = false;
  42021. var hasScheduledUpdateInCurrentCommit = false;
  42022. var hasScheduledUpdateInCurrentPhase = false;
  42023. var commitCountInCurrentWorkLoop = 0;
  42024. var effectCountInCurrentCommit = 0;
  42025. // to avoid stretch the commit phase with measurement overhead.
  42026. var labelsInCurrentCommit = new Set();
  42027. var formatMarkName = function (markName) {
  42028. return reactEmoji + " " + markName;
  42029. };
  42030. var formatLabel = function (label, warning) {
  42031. var prefix = warning ? warningEmoji + " " : reactEmoji + " ";
  42032. var suffix = warning ? " Warning: " + warning : '';
  42033. return "" + prefix + label + suffix;
  42034. };
  42035. var beginMark = function (markName) {
  42036. performance.mark(formatMarkName(markName));
  42037. };
  42038. var clearMark = function (markName) {
  42039. performance.clearMarks(formatMarkName(markName));
  42040. };
  42041. var endMark = function (label, markName, warning) {
  42042. var formattedMarkName = formatMarkName(markName);
  42043. var formattedLabel = formatLabel(label, warning);
  42044. try {
  42045. performance.measure(formattedLabel, formattedMarkName);
  42046. } catch (err) {} // If previous mark was missing for some reason, this will throw.
  42047. // This could only happen if React crashed in an unexpected place earlier.
  42048. // Don't pile on with more errors.
  42049. // Clear marks immediately to avoid growing buffer.
  42050. performance.clearMarks(formattedMarkName);
  42051. performance.clearMeasures(formattedLabel);
  42052. };
  42053. var getFiberMarkName = function (label, debugID) {
  42054. return label + " (#" + debugID + ")";
  42055. };
  42056. var getFiberLabel = function (componentName, isMounted, phase) {
  42057. if (phase === null) {
  42058. // These are composite component total time measurements.
  42059. return componentName + " [" + (isMounted ? 'update' : 'mount') + "]";
  42060. } else {
  42061. // Composite component methods.
  42062. return componentName + "." + phase;
  42063. }
  42064. };
  42065. var beginFiberMark = function (fiber, phase) {
  42066. var componentName = getComponentName(fiber.type) || 'Unknown';
  42067. var debugID = fiber._debugID;
  42068. var isMounted = fiber.alternate !== null;
  42069. var label = getFiberLabel(componentName, isMounted, phase);
  42070. if (isCommitting && labelsInCurrentCommit.has(label)) {
  42071. // During the commit phase, we don't show duplicate labels because
  42072. // there is a fixed overhead for every measurement, and we don't
  42073. // want to stretch the commit phase beyond necessary.
  42074. return false;
  42075. }
  42076. labelsInCurrentCommit.add(label);
  42077. var markName = getFiberMarkName(label, debugID);
  42078. beginMark(markName);
  42079. return true;
  42080. };
  42081. var clearFiberMark = function (fiber, phase) {
  42082. var componentName = getComponentName(fiber.type) || 'Unknown';
  42083. var debugID = fiber._debugID;
  42084. var isMounted = fiber.alternate !== null;
  42085. var label = getFiberLabel(componentName, isMounted, phase);
  42086. var markName = getFiberMarkName(label, debugID);
  42087. clearMark(markName);
  42088. };
  42089. var endFiberMark = function (fiber, phase, warning) {
  42090. var componentName = getComponentName(fiber.type) || 'Unknown';
  42091. var debugID = fiber._debugID;
  42092. var isMounted = fiber.alternate !== null;
  42093. var label = getFiberLabel(componentName, isMounted, phase);
  42094. var markName = getFiberMarkName(label, debugID);
  42095. endMark(label, markName, warning);
  42096. };
  42097. var shouldIgnoreFiber = function (fiber) {
  42098. // Host components should be skipped in the timeline.
  42099. // We could check typeof fiber.type, but does this work with RN?
  42100. switch (fiber.tag) {
  42101. case HostRoot:
  42102. case HostComponent:
  42103. case HostText:
  42104. case HostPortal:
  42105. case Fragment:
  42106. case ContextProvider:
  42107. case ContextConsumer:
  42108. case Mode:
  42109. return true;
  42110. default:
  42111. return false;
  42112. }
  42113. };
  42114. var clearPendingPhaseMeasurement = function () {
  42115. if (currentPhase !== null && currentPhaseFiber !== null) {
  42116. clearFiberMark(currentPhaseFiber, currentPhase);
  42117. }
  42118. currentPhaseFiber = null;
  42119. currentPhase = null;
  42120. hasScheduledUpdateInCurrentPhase = false;
  42121. };
  42122. var pauseTimers = function () {
  42123. // Stops all currently active measurements so that they can be resumed
  42124. // if we continue in a later deferred loop from the same unit of work.
  42125. var fiber = currentFiber;
  42126. while (fiber) {
  42127. if (fiber._debugIsCurrentlyTiming) {
  42128. endFiberMark(fiber, null, null);
  42129. }
  42130. fiber = fiber.return;
  42131. }
  42132. };
  42133. var resumeTimersRecursively = function (fiber) {
  42134. if (fiber.return !== null) {
  42135. resumeTimersRecursively(fiber.return);
  42136. }
  42137. if (fiber._debugIsCurrentlyTiming) {
  42138. beginFiberMark(fiber, null);
  42139. }
  42140. };
  42141. var resumeTimers = function () {
  42142. // Resumes all measurements that were active during the last deferred loop.
  42143. if (currentFiber !== null) {
  42144. resumeTimersRecursively(currentFiber);
  42145. }
  42146. };
  42147. function recordEffect() {
  42148. if (enableUserTimingAPI) {
  42149. effectCountInCurrentCommit++;
  42150. }
  42151. }
  42152. function recordScheduleUpdate() {
  42153. if (enableUserTimingAPI) {
  42154. if (isCommitting) {
  42155. hasScheduledUpdateInCurrentCommit = true;
  42156. }
  42157. if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
  42158. hasScheduledUpdateInCurrentPhase = true;
  42159. }
  42160. }
  42161. }
  42162. function startWorkTimer(fiber) {
  42163. if (enableUserTimingAPI) {
  42164. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  42165. return;
  42166. } // If we pause, this is the fiber to unwind from.
  42167. currentFiber = fiber;
  42168. if (!beginFiberMark(fiber, null)) {
  42169. return;
  42170. }
  42171. fiber._debugIsCurrentlyTiming = true;
  42172. }
  42173. }
  42174. function cancelWorkTimer(fiber) {
  42175. if (enableUserTimingAPI) {
  42176. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  42177. return;
  42178. } // Remember we shouldn't complete measurement for this fiber.
  42179. // Otherwise flamechart will be deep even for small updates.
  42180. fiber._debugIsCurrentlyTiming = false;
  42181. clearFiberMark(fiber, null);
  42182. }
  42183. }
  42184. function stopWorkTimer(fiber) {
  42185. if (enableUserTimingAPI) {
  42186. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  42187. return;
  42188. } // If we pause, its parent is the fiber to unwind from.
  42189. currentFiber = fiber.return;
  42190. if (!fiber._debugIsCurrentlyTiming) {
  42191. return;
  42192. }
  42193. fiber._debugIsCurrentlyTiming = false;
  42194. endFiberMark(fiber, null, null);
  42195. }
  42196. }
  42197. function stopFailedWorkTimer(fiber) {
  42198. if (enableUserTimingAPI) {
  42199. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  42200. return;
  42201. } // If we pause, its parent is the fiber to unwind from.
  42202. currentFiber = fiber.return;
  42203. if (!fiber._debugIsCurrentlyTiming) {
  42204. return;
  42205. }
  42206. fiber._debugIsCurrentlyTiming = false;
  42207. var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
  42208. endFiberMark(fiber, null, warning);
  42209. }
  42210. }
  42211. function startPhaseTimer(fiber, phase) {
  42212. if (enableUserTimingAPI) {
  42213. if (!supportsUserTiming) {
  42214. return;
  42215. }
  42216. clearPendingPhaseMeasurement();
  42217. if (!beginFiberMark(fiber, phase)) {
  42218. return;
  42219. }
  42220. currentPhaseFiber = fiber;
  42221. currentPhase = phase;
  42222. }
  42223. }
  42224. function stopPhaseTimer() {
  42225. if (enableUserTimingAPI) {
  42226. if (!supportsUserTiming) {
  42227. return;
  42228. }
  42229. if (currentPhase !== null && currentPhaseFiber !== null) {
  42230. var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
  42231. endFiberMark(currentPhaseFiber, currentPhase, warning);
  42232. }
  42233. currentPhase = null;
  42234. currentPhaseFiber = null;
  42235. }
  42236. }
  42237. function startWorkLoopTimer(nextUnitOfWork) {
  42238. if (enableUserTimingAPI) {
  42239. currentFiber = nextUnitOfWork;
  42240. if (!supportsUserTiming) {
  42241. return;
  42242. }
  42243. commitCountInCurrentWorkLoop = 0; // This is top level call.
  42244. // Any other measurements are performed within.
  42245. beginMark('(React Tree Reconciliation)'); // Resume any measurements that were in progress during the last loop.
  42246. resumeTimers();
  42247. }
  42248. }
  42249. function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
  42250. if (enableUserTimingAPI) {
  42251. if (!supportsUserTiming) {
  42252. return;
  42253. }
  42254. var warning = null;
  42255. if (interruptedBy !== null) {
  42256. if (interruptedBy.tag === HostRoot) {
  42257. warning = 'A top-level update interrupted the previous render';
  42258. } else {
  42259. var componentName = getComponentName(interruptedBy.type) || 'Unknown';
  42260. warning = "An update to " + componentName + " interrupted the previous render";
  42261. }
  42262. } else if (commitCountInCurrentWorkLoop > 1) {
  42263. warning = 'There were cascading updates';
  42264. }
  42265. commitCountInCurrentWorkLoop = 0;
  42266. var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)'; // Pause any measurements until the next loop.
  42267. pauseTimers();
  42268. endMark(label, '(React Tree Reconciliation)', warning);
  42269. }
  42270. }
  42271. function startCommitTimer() {
  42272. if (enableUserTimingAPI) {
  42273. if (!supportsUserTiming) {
  42274. return;
  42275. }
  42276. isCommitting = true;
  42277. hasScheduledUpdateInCurrentCommit = false;
  42278. labelsInCurrentCommit.clear();
  42279. beginMark('(Committing Changes)');
  42280. }
  42281. }
  42282. function stopCommitTimer() {
  42283. if (enableUserTimingAPI) {
  42284. if (!supportsUserTiming) {
  42285. return;
  42286. }
  42287. var warning = null;
  42288. if (hasScheduledUpdateInCurrentCommit) {
  42289. warning = 'Lifecycle hook scheduled a cascading update';
  42290. } else if (commitCountInCurrentWorkLoop > 0) {
  42291. warning = 'Caused by a cascading update in earlier commit';
  42292. }
  42293. hasScheduledUpdateInCurrentCommit = false;
  42294. commitCountInCurrentWorkLoop++;
  42295. isCommitting = false;
  42296. labelsInCurrentCommit.clear();
  42297. endMark('(Committing Changes)', '(Committing Changes)', warning);
  42298. }
  42299. }
  42300. function startCommitSnapshotEffectsTimer() {
  42301. if (enableUserTimingAPI) {
  42302. if (!supportsUserTiming) {
  42303. return;
  42304. }
  42305. effectCountInCurrentCommit = 0;
  42306. beginMark('(Committing Snapshot Effects)');
  42307. }
  42308. }
  42309. function stopCommitSnapshotEffectsTimer() {
  42310. if (enableUserTimingAPI) {
  42311. if (!supportsUserTiming) {
  42312. return;
  42313. }
  42314. var count = effectCountInCurrentCommit;
  42315. effectCountInCurrentCommit = 0;
  42316. endMark("(Committing Snapshot Effects: " + count + " Total)", '(Committing Snapshot Effects)', null);
  42317. }
  42318. }
  42319. function startCommitHostEffectsTimer() {
  42320. if (enableUserTimingAPI) {
  42321. if (!supportsUserTiming) {
  42322. return;
  42323. }
  42324. effectCountInCurrentCommit = 0;
  42325. beginMark('(Committing Host Effects)');
  42326. }
  42327. }
  42328. function stopCommitHostEffectsTimer() {
  42329. if (enableUserTimingAPI) {
  42330. if (!supportsUserTiming) {
  42331. return;
  42332. }
  42333. var count = effectCountInCurrentCommit;
  42334. effectCountInCurrentCommit = 0;
  42335. endMark("(Committing Host Effects: " + count + " Total)", '(Committing Host Effects)', null);
  42336. }
  42337. }
  42338. function startCommitLifeCyclesTimer() {
  42339. if (enableUserTimingAPI) {
  42340. if (!supportsUserTiming) {
  42341. return;
  42342. }
  42343. effectCountInCurrentCommit = 0;
  42344. beginMark('(Calling Lifecycle Methods)');
  42345. }
  42346. }
  42347. function stopCommitLifeCyclesTimer() {
  42348. if (enableUserTimingAPI) {
  42349. if (!supportsUserTiming) {
  42350. return;
  42351. }
  42352. var count = effectCountInCurrentCommit;
  42353. effectCountInCurrentCommit = 0;
  42354. endMark("(Calling Lifecycle Methods: " + count + " Total)", '(Calling Lifecycle Methods)', null);
  42355. }
  42356. }
  42357. var valueStack = [];
  42358. var fiberStack;
  42359. {
  42360. fiberStack = [];
  42361. }
  42362. var index = -1;
  42363. function createCursor(defaultValue) {
  42364. return {
  42365. current: defaultValue
  42366. };
  42367. }
  42368. function pop(cursor, fiber) {
  42369. if (index < 0) {
  42370. {
  42371. warningWithoutStack$1(false, 'Unexpected pop.');
  42372. }
  42373. return;
  42374. }
  42375. {
  42376. if (fiber !== fiberStack[index]) {
  42377. warningWithoutStack$1(false, 'Unexpected Fiber popped.');
  42378. }
  42379. }
  42380. cursor.current = valueStack[index];
  42381. valueStack[index] = null;
  42382. {
  42383. fiberStack[index] = null;
  42384. }
  42385. index--;
  42386. }
  42387. function push(cursor, value, fiber) {
  42388. index++;
  42389. valueStack[index] = cursor.current;
  42390. {
  42391. fiberStack[index] = fiber;
  42392. }
  42393. cursor.current = value;
  42394. }
  42395. var warnedAboutMissingGetChildContext;
  42396. {
  42397. warnedAboutMissingGetChildContext = {};
  42398. }
  42399. var emptyContextObject = {};
  42400. {
  42401. Object.freeze(emptyContextObject);
  42402. } // A cursor to the current merged context object on the stack.
  42403. var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed.
  42404. var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack.
  42405. // We use this to get access to the parent context after we have already
  42406. // pushed the next context provider, and now need to merge their contexts.
  42407. var previousContext = emptyContextObject;
  42408. function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
  42409. if (disableLegacyContext) {
  42410. return emptyContextObject;
  42411. } else {
  42412. if (didPushOwnContextIfProvider && isContextProvider(Component)) {
  42413. // If the fiber is a context provider itself, when we read its context
  42414. // we may have already pushed its own child context on the stack. A context
  42415. // provider should not "see" its own child context. Therefore we read the
  42416. // previous (parent) context instead for a context provider.
  42417. return previousContext;
  42418. }
  42419. return contextStackCursor.current;
  42420. }
  42421. }
  42422. function cacheContext(workInProgress, unmaskedContext, maskedContext) {
  42423. if (disableLegacyContext) {
  42424. return;
  42425. } else {
  42426. var instance = workInProgress.stateNode;
  42427. instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
  42428. instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
  42429. }
  42430. }
  42431. function getMaskedContext(workInProgress, unmaskedContext) {
  42432. if (disableLegacyContext) {
  42433. return emptyContextObject;
  42434. } else {
  42435. var type = workInProgress.type;
  42436. var contextTypes = type.contextTypes;
  42437. if (!contextTypes) {
  42438. return emptyContextObject;
  42439. } // Avoid recreating masked context unless unmasked context has changed.
  42440. // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
  42441. // This may trigger infinite loops if componentWillReceiveProps calls setState.
  42442. var instance = workInProgress.stateNode;
  42443. if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
  42444. return instance.__reactInternalMemoizedMaskedChildContext;
  42445. }
  42446. var context = {};
  42447. for (var key in contextTypes) {
  42448. context[key] = unmaskedContext[key];
  42449. }
  42450. {
  42451. var name = getComponentName(type) || 'Unknown';
  42452. checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
  42453. } // Cache unmasked context so we can avoid recreating masked context unless necessary.
  42454. // Context is created before the class component is instantiated so check for instance.
  42455. if (instance) {
  42456. cacheContext(workInProgress, unmaskedContext, context);
  42457. }
  42458. return context;
  42459. }
  42460. }
  42461. function hasContextChanged() {
  42462. if (disableLegacyContext) {
  42463. return false;
  42464. } else {
  42465. return didPerformWorkStackCursor.current;
  42466. }
  42467. }
  42468. function isContextProvider(type) {
  42469. if (disableLegacyContext) {
  42470. return false;
  42471. } else {
  42472. var childContextTypes = type.childContextTypes;
  42473. return childContextTypes !== null && childContextTypes !== undefined;
  42474. }
  42475. }
  42476. function popContext(fiber) {
  42477. if (disableLegacyContext) {
  42478. return;
  42479. } else {
  42480. pop(didPerformWorkStackCursor, fiber);
  42481. pop(contextStackCursor, fiber);
  42482. }
  42483. }
  42484. function popTopLevelContextObject(fiber) {
  42485. if (disableLegacyContext) {
  42486. return;
  42487. } else {
  42488. pop(didPerformWorkStackCursor, fiber);
  42489. pop(contextStackCursor, fiber);
  42490. }
  42491. }
  42492. function pushTopLevelContextObject(fiber, context, didChange) {
  42493. if (disableLegacyContext) {
  42494. return;
  42495. } else {
  42496. (function () {
  42497. if (!(contextStackCursor.current === emptyContextObject)) {
  42498. {
  42499. throw ReactError(Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue."));
  42500. }
  42501. }
  42502. })();
  42503. push(contextStackCursor, context, fiber);
  42504. push(didPerformWorkStackCursor, didChange, fiber);
  42505. }
  42506. }
  42507. function processChildContext(fiber, type, parentContext) {
  42508. if (disableLegacyContext) {
  42509. return parentContext;
  42510. } else {
  42511. var instance = fiber.stateNode;
  42512. var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future.
  42513. // It has only been added in Fiber to match the (unintentional) behavior in Stack.
  42514. if (typeof instance.getChildContext !== 'function') {
  42515. {
  42516. var componentName = getComponentName(type) || 'Unknown';
  42517. if (!warnedAboutMissingGetChildContext[componentName]) {
  42518. warnedAboutMissingGetChildContext[componentName] = true;
  42519. warningWithoutStack$1(false, '%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);
  42520. }
  42521. }
  42522. return parentContext;
  42523. }
  42524. var childContext;
  42525. {
  42526. setCurrentPhase('getChildContext');
  42527. }
  42528. startPhaseTimer(fiber, 'getChildContext');
  42529. childContext = instance.getChildContext();
  42530. stopPhaseTimer();
  42531. {
  42532. setCurrentPhase(null);
  42533. }
  42534. for (var contextKey in childContext) {
  42535. (function () {
  42536. if (!(contextKey in childContextTypes)) {
  42537. {
  42538. throw ReactError(Error((getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes."));
  42539. }
  42540. }
  42541. })();
  42542. }
  42543. {
  42544. var name = getComponentName(type) || 'Unknown';
  42545. checkPropTypes(childContextTypes, childContext, 'child context', name, // In practice, there is one case in which we won't get a stack. It's when
  42546. // somebody calls unstable_renderSubtreeIntoContainer() and we process
  42547. // context from the parent component instance. The stack will be missing
  42548. // because it's outside of the reconciliation, and so the pointer has not
  42549. // been set. This is rare and doesn't matter. We'll also remove that API.
  42550. getCurrentFiberStackInDev);
  42551. }
  42552. return _assign({}, parentContext, {}, childContext);
  42553. }
  42554. }
  42555. function pushContextProvider(workInProgress) {
  42556. if (disableLegacyContext) {
  42557. return false;
  42558. } else {
  42559. var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity.
  42560. // If the instance does not exist yet, we will push null at first,
  42561. // and replace it on the stack later when invalidating the context.
  42562. var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later.
  42563. // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates.
  42564. previousContext = contextStackCursor.current;
  42565. push(contextStackCursor, memoizedMergedChildContext, workInProgress);
  42566. push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
  42567. return true;
  42568. }
  42569. }
  42570. function invalidateContextProvider(workInProgress, type, didChange) {
  42571. if (disableLegacyContext) {
  42572. return;
  42573. } else {
  42574. var instance = workInProgress.stateNode;
  42575. (function () {
  42576. if (!instance) {
  42577. {
  42578. throw ReactError(Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue."));
  42579. }
  42580. }
  42581. })();
  42582. if (didChange) {
  42583. // Merge parent and own context.
  42584. // Skip this if we're not updating due to sCU.
  42585. // This avoids unnecessarily recomputing memoized values.
  42586. var mergedContext = processChildContext(workInProgress, type, previousContext);
  42587. instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one.
  42588. // It is important to unwind the context in the reverse order.
  42589. pop(didPerformWorkStackCursor, workInProgress);
  42590. pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed.
  42591. push(contextStackCursor, mergedContext, workInProgress);
  42592. push(didPerformWorkStackCursor, didChange, workInProgress);
  42593. } else {
  42594. pop(didPerformWorkStackCursor, workInProgress);
  42595. push(didPerformWorkStackCursor, didChange, workInProgress);
  42596. }
  42597. }
  42598. }
  42599. function findCurrentUnmaskedContext(fiber) {
  42600. if (disableLegacyContext) {
  42601. return emptyContextObject;
  42602. } else {
  42603. // Currently this is only used with renderSubtreeIntoContainer; not sure if it
  42604. // makes sense elsewhere
  42605. (function () {
  42606. if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
  42607. {
  42608. throw ReactError(Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."));
  42609. }
  42610. }
  42611. })();
  42612. var node = fiber;
  42613. do {
  42614. switch (node.tag) {
  42615. case HostRoot:
  42616. return node.stateNode.context;
  42617. case ClassComponent:
  42618. {
  42619. var Component = node.type;
  42620. if (isContextProvider(Component)) {
  42621. return node.stateNode.__reactInternalMemoizedMergedChildContext;
  42622. }
  42623. break;
  42624. }
  42625. }
  42626. node = node.return;
  42627. } while (node !== null);
  42628. (function () {
  42629. {
  42630. {
  42631. throw ReactError(Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."));
  42632. }
  42633. }
  42634. })();
  42635. }
  42636. }
  42637. var LegacyRoot = 0;
  42638. var BatchedRoot = 1;
  42639. var ConcurrentRoot = 2;
  42640. // Intentionally not named imports because Rollup would use dynamic dispatch for
  42641. // CommonJS interop named imports.
  42642. var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority;
  42643. var Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback;
  42644. var Scheduler_cancelCallback = Scheduler.unstable_cancelCallback;
  42645. var Scheduler_shouldYield = Scheduler.unstable_shouldYield;
  42646. var Scheduler_requestPaint = Scheduler.unstable_requestPaint;
  42647. var Scheduler_now = Scheduler.unstable_now;
  42648. var Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel;
  42649. var Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority;
  42650. var Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
  42651. var Scheduler_NormalPriority = Scheduler.unstable_NormalPriority;
  42652. var Scheduler_LowPriority = Scheduler.unstable_LowPriority;
  42653. var Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
  42654. if (enableSchedulerTracing) {
  42655. // Provide explicit error message when production+profiling bundle of e.g.
  42656. // react-dom is used with production (non-profiling) bundle of
  42657. // scheduler/tracing
  42658. (function () {
  42659. if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
  42660. {
  42661. throw ReactError(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"));
  42662. }
  42663. }
  42664. })();
  42665. }
  42666. var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use
  42667. // ascending numbers so we can compare them like numbers. They start at 90 to
  42668. // avoid clashing with Scheduler's priorities.
  42669. var ImmediatePriority = 99;
  42670. var UserBlockingPriority$2 = 98;
  42671. var NormalPriority = 97;
  42672. var LowPriority = 96;
  42673. var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only.
  42674. var NoPriority = 90;
  42675. var shouldYield = Scheduler_shouldYield;
  42676. var requestPaint = // Fall back gracefully if we're running an older version of Scheduler.
  42677. Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {};
  42678. var syncQueue = null;
  42679. var immediateQueueCallbackNode = null;
  42680. var isFlushingSyncQueue = false;
  42681. var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
  42682. // This will be the case for modern browsers that support `performance.now`. In
  42683. // older browsers, Scheduler falls back to `Date.now`, which returns a Unix
  42684. // timestamp. In that case, subtract the module initialization time to simulate
  42685. // the behavior of performance.now and keep our times small enough to fit
  42686. // within 32 bits.
  42687. // TODO: Consider lifting this into Scheduler.
  42688. var now = initialTimeMs < 10000 ? Scheduler_now : function () {
  42689. return Scheduler_now() - initialTimeMs;
  42690. };
  42691. function getCurrentPriorityLevel() {
  42692. switch (Scheduler_getCurrentPriorityLevel()) {
  42693. case Scheduler_ImmediatePriority:
  42694. return ImmediatePriority;
  42695. case Scheduler_UserBlockingPriority:
  42696. return UserBlockingPriority$2;
  42697. case Scheduler_NormalPriority:
  42698. return NormalPriority;
  42699. case Scheduler_LowPriority:
  42700. return LowPriority;
  42701. case Scheduler_IdlePriority:
  42702. return IdlePriority;
  42703. default:
  42704. (function () {
  42705. {
  42706. {
  42707. throw ReactError(Error("Unknown priority level."));
  42708. }
  42709. }
  42710. })();
  42711. }
  42712. }
  42713. function reactPriorityToSchedulerPriority(reactPriorityLevel) {
  42714. switch (reactPriorityLevel) {
  42715. case ImmediatePriority:
  42716. return Scheduler_ImmediatePriority;
  42717. case UserBlockingPriority$2:
  42718. return Scheduler_UserBlockingPriority;
  42719. case NormalPriority:
  42720. return Scheduler_NormalPriority;
  42721. case LowPriority:
  42722. return Scheduler_LowPriority;
  42723. case IdlePriority:
  42724. return Scheduler_IdlePriority;
  42725. default:
  42726. (function () {
  42727. {
  42728. {
  42729. throw ReactError(Error("Unknown priority level."));
  42730. }
  42731. }
  42732. })();
  42733. }
  42734. }
  42735. function runWithPriority$2(reactPriorityLevel, fn) {
  42736. var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
  42737. return Scheduler_runWithPriority(priorityLevel, fn);
  42738. }
  42739. function scheduleCallback(reactPriorityLevel, callback, options) {
  42740. var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
  42741. return Scheduler_scheduleCallback(priorityLevel, callback, options);
  42742. }
  42743. function scheduleSyncCallback(callback) {
  42744. // Push this callback into an internal queue. We'll flush these either in
  42745. // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
  42746. if (syncQueue === null) {
  42747. syncQueue = [callback]; // Flush the queue in the next tick, at the earliest.
  42748. immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl);
  42749. } else {
  42750. // Push onto existing queue. Don't need to schedule a callback because
  42751. // we already scheduled one when we created the queue.
  42752. syncQueue.push(callback);
  42753. }
  42754. return fakeCallbackNode;
  42755. }
  42756. function cancelCallback(callbackNode) {
  42757. if (callbackNode !== fakeCallbackNode) {
  42758. Scheduler_cancelCallback(callbackNode);
  42759. }
  42760. }
  42761. function flushSyncCallbackQueue() {
  42762. if (immediateQueueCallbackNode !== null) {
  42763. var node = immediateQueueCallbackNode;
  42764. immediateQueueCallbackNode = null;
  42765. Scheduler_cancelCallback(node);
  42766. }
  42767. flushSyncCallbackQueueImpl();
  42768. }
  42769. function flushSyncCallbackQueueImpl() {
  42770. if (!isFlushingSyncQueue && syncQueue !== null) {
  42771. // Prevent re-entrancy.
  42772. isFlushingSyncQueue = true;
  42773. var i = 0;
  42774. try {
  42775. var _isSync = true;
  42776. var queue = syncQueue;
  42777. runWithPriority$2(ImmediatePriority, function () {
  42778. for (; i < queue.length; i++) {
  42779. var callback = queue[i];
  42780. do {
  42781. callback = callback(_isSync);
  42782. } while (callback !== null);
  42783. }
  42784. });
  42785. syncQueue = null;
  42786. } catch (error) {
  42787. // If something throws, leave the remaining callbacks on the queue.
  42788. if (syncQueue !== null) {
  42789. syncQueue = syncQueue.slice(i + 1);
  42790. } // Resume flushing in the next tick
  42791. Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue);
  42792. throw error;
  42793. } finally {
  42794. isFlushingSyncQueue = false;
  42795. }
  42796. }
  42797. }
  42798. var NoMode = 0;
  42799. var StrictMode = 1; // TODO: Remove BatchedMode and ConcurrentMode by reading from the root
  42800. // tag instead
  42801. var BatchedMode = 2;
  42802. var ConcurrentMode = 4;
  42803. var ProfileMode = 8;
  42804. // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
  42805. // Math.pow(2, 30) - 1
  42806. // 0b111111111111111111111111111111
  42807. var MAX_SIGNED_31_BIT_INT = 1073741823;
  42808. var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that
  42809. // Never work can be committed in an inconsistent state without tearing the UI.
  42810. // The main example is offscreen content, like a hidden subtree. So one possible
  42811. // name is Offscreen. However, it also includes dehydrated Suspense boundaries,
  42812. // which are inconsistent in the sense that they haven't finished yet, but
  42813. // aren't visibly inconsistent because the server rendered HTML matches what the
  42814. // hydrated tree would look like.
  42815. var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in
  42816. // order to be consistent.
  42817. var Idle = 2;
  42818. var Sync = MAX_SIGNED_31_BIT_INT;
  42819. var Batched = Sync - 1;
  42820. var UNIT_SIZE = 10;
  42821. var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms.
  42822. function msToExpirationTime(ms) {
  42823. // Always add an offset so that we don't clash with the magic number for NoWork.
  42824. return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
  42825. }
  42826. function expirationTimeToMs(expirationTime) {
  42827. return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
  42828. }
  42829. function ceiling(num, precision) {
  42830. return ((num / precision | 0) + 1) * precision;
  42831. }
  42832. function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
  42833. return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
  42834. } // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update
  42835. // the names to reflect.
  42836. var LOW_PRIORITY_EXPIRATION = 5000;
  42837. var LOW_PRIORITY_BATCH_SIZE = 250;
  42838. function computeAsyncExpiration(currentTime) {
  42839. return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
  42840. }
  42841. function computeSuspenseExpiration(currentTime, timeoutMs) {
  42842. // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time?
  42843. return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE);
  42844. } // We intentionally set a higher expiration time for interactive updates in
  42845. // dev than in production.
  42846. //
  42847. // If the main thread is being blocked so long that you hit the expiration,
  42848. // it's a problem that could be solved with better scheduling.
  42849. //
  42850. // People will be more likely to notice this and fix it with the long
  42851. // expiration time in development.
  42852. //
  42853. // In production we opt for better UX at the risk of masking scheduling
  42854. // problems, by expiring fast.
  42855. var HIGH_PRIORITY_EXPIRATION = 500;
  42856. var HIGH_PRIORITY_BATCH_SIZE = 100;
  42857. function computeInteractiveExpiration(currentTime) {
  42858. return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
  42859. }
  42860. function inferPriorityFromExpirationTime(currentTime, expirationTime) {
  42861. if (expirationTime === Sync) {
  42862. return ImmediatePriority;
  42863. }
  42864. if (expirationTime === Never || expirationTime === Idle) {
  42865. return IdlePriority;
  42866. }
  42867. var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime);
  42868. if (msUntil <= 0) {
  42869. return ImmediatePriority;
  42870. }
  42871. if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) {
  42872. return UserBlockingPriority$2;
  42873. }
  42874. if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) {
  42875. return NormalPriority;
  42876. } // TODO: Handle LowPriority
  42877. // Assume anything lower has idle priority
  42878. return IdlePriority;
  42879. }
  42880. /**
  42881. * Forked from fbjs/warning:
  42882. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  42883. *
  42884. * Only change is we use console.warn instead of console.error,
  42885. * and do nothing when 'console' is not supported.
  42886. * This really simplifies the code.
  42887. * ---
  42888. * Similar to invariant but only logs a warning if the condition is not met.
  42889. * This can be used to log issues in development environments in critical
  42890. * paths. Removing the logging code for production environments will keep the
  42891. * same logic and follow the same code paths.
  42892. */
  42893. var lowPriorityWarningWithoutStack = function () {};
  42894. {
  42895. var printWarning = function (format) {
  42896. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  42897. args[_key - 1] = arguments[_key];
  42898. }
  42899. var argIndex = 0;
  42900. var message = 'Warning: ' + format.replace(/%s/g, function () {
  42901. return args[argIndex++];
  42902. });
  42903. if (typeof console !== 'undefined') {
  42904. console.warn(message);
  42905. }
  42906. try {
  42907. // --- Welcome to debugging React ---
  42908. // This error was thrown as a convenience so that you can use this stack
  42909. // to find the callsite that caused this warning to fire.
  42910. throw new Error(message);
  42911. } catch (x) {}
  42912. };
  42913. lowPriorityWarningWithoutStack = function (condition, format) {
  42914. if (format === undefined) {
  42915. throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
  42916. }
  42917. if (!condition) {
  42918. for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  42919. args[_key2 - 2] = arguments[_key2];
  42920. }
  42921. printWarning.apply(void 0, [format].concat(args));
  42922. }
  42923. };
  42924. }
  42925. var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
  42926. var ReactStrictModeWarnings = {
  42927. recordUnsafeLifecycleWarnings: function (fiber, instance) {},
  42928. flushPendingUnsafeLifecycleWarnings: function () {},
  42929. recordLegacyContextWarning: function (fiber, instance) {},
  42930. flushLegacyContextWarning: function () {},
  42931. discardPendingWarnings: function () {}
  42932. };
  42933. {
  42934. var findStrictRoot = function (fiber) {
  42935. var maybeStrictRoot = null;
  42936. var node = fiber;
  42937. while (node !== null) {
  42938. if (node.mode & StrictMode) {
  42939. maybeStrictRoot = node;
  42940. }
  42941. node = node.return;
  42942. }
  42943. return maybeStrictRoot;
  42944. };
  42945. var setToSortedString = function (set) {
  42946. var array = [];
  42947. set.forEach(function (value) {
  42948. array.push(value);
  42949. });
  42950. return array.sort().join(', ');
  42951. };
  42952. var pendingComponentWillMountWarnings = [];
  42953. var pendingUNSAFE_ComponentWillMountWarnings = [];
  42954. var pendingComponentWillReceivePropsWarnings = [];
  42955. var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  42956. var pendingComponentWillUpdateWarnings = [];
  42957. var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about.
  42958. var didWarnAboutUnsafeLifecycles = new Set();
  42959. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
  42960. // Dedup strategy: Warn once per component.
  42961. if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
  42962. return;
  42963. }
  42964. if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components.
  42965. instance.componentWillMount.__suppressDeprecationWarning !== true) {
  42966. pendingComponentWillMountWarnings.push(fiber);
  42967. }
  42968. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') {
  42969. pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
  42970. }
  42971. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  42972. pendingComponentWillReceivePropsWarnings.push(fiber);
  42973. }
  42974. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  42975. pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
  42976. }
  42977. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  42978. pendingComponentWillUpdateWarnings.push(fiber);
  42979. }
  42980. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') {
  42981. pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
  42982. }
  42983. };
  42984. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
  42985. // We do an initial pass to gather component names
  42986. var componentWillMountUniqueNames = new Set();
  42987. if (pendingComponentWillMountWarnings.length > 0) {
  42988. pendingComponentWillMountWarnings.forEach(function (fiber) {
  42989. componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
  42990. didWarnAboutUnsafeLifecycles.add(fiber.type);
  42991. });
  42992. pendingComponentWillMountWarnings = [];
  42993. }
  42994. var UNSAFE_componentWillMountUniqueNames = new Set();
  42995. if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
  42996. pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) {
  42997. UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
  42998. didWarnAboutUnsafeLifecycles.add(fiber.type);
  42999. });
  43000. pendingUNSAFE_ComponentWillMountWarnings = [];
  43001. }
  43002. var componentWillReceivePropsUniqueNames = new Set();
  43003. if (pendingComponentWillReceivePropsWarnings.length > 0) {
  43004. pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
  43005. componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
  43006. didWarnAboutUnsafeLifecycles.add(fiber.type);
  43007. });
  43008. pendingComponentWillReceivePropsWarnings = [];
  43009. }
  43010. var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
  43011. if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
  43012. pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) {
  43013. UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
  43014. didWarnAboutUnsafeLifecycles.add(fiber.type);
  43015. });
  43016. pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  43017. }
  43018. var componentWillUpdateUniqueNames = new Set();
  43019. if (pendingComponentWillUpdateWarnings.length > 0) {
  43020. pendingComponentWillUpdateWarnings.forEach(function (fiber) {
  43021. componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
  43022. didWarnAboutUnsafeLifecycles.add(fiber.type);
  43023. });
  43024. pendingComponentWillUpdateWarnings = [];
  43025. }
  43026. var UNSAFE_componentWillUpdateUniqueNames = new Set();
  43027. if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
  43028. pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) {
  43029. UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
  43030. didWarnAboutUnsafeLifecycles.add(fiber.type);
  43031. });
  43032. pendingUNSAFE_ComponentWillUpdateWarnings = [];
  43033. } // Finally, we flush all the warnings
  43034. // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
  43035. if (UNSAFE_componentWillMountUniqueNames.size > 0) {
  43036. var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
  43037. warningWithoutStack$1(false, '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);
  43038. }
  43039. if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
  43040. var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
  43041. warningWithoutStack$1(false, '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);
  43042. }
  43043. if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
  43044. var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
  43045. warningWithoutStack$1(false, '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);
  43046. }
  43047. if (componentWillMountUniqueNames.size > 0) {
  43048. var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
  43049. lowPriorityWarningWithoutStack$1(false, '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);
  43050. }
  43051. if (componentWillReceivePropsUniqueNames.size > 0) {
  43052. var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
  43053. lowPriorityWarningWithoutStack$1(false, '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);
  43054. }
  43055. if (componentWillUpdateUniqueNames.size > 0) {
  43056. var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
  43057. lowPriorityWarningWithoutStack$1(false, '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);
  43058. }
  43059. };
  43060. var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about.
  43061. var didWarnAboutLegacyContext = new Set();
  43062. ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
  43063. var strictRoot = findStrictRoot(fiber);
  43064. if (strictRoot === null) {
  43065. warningWithoutStack$1(false, '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.');
  43066. return;
  43067. } // Dedup strategy: Warn once per component.
  43068. if (didWarnAboutLegacyContext.has(fiber.type)) {
  43069. return;
  43070. }
  43071. var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
  43072. if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
  43073. if (warningsForRoot === undefined) {
  43074. warningsForRoot = [];
  43075. pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
  43076. }
  43077. warningsForRoot.push(fiber);
  43078. }
  43079. };
  43080. ReactStrictModeWarnings.flushLegacyContextWarning = function () {
  43081. pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
  43082. var uniqueNames = new Set();
  43083. fiberArray.forEach(function (fiber) {
  43084. uniqueNames.add(getComponentName(fiber.type) || 'Component');
  43085. didWarnAboutLegacyContext.add(fiber.type);
  43086. });
  43087. var sortedNames = setToSortedString(uniqueNames);
  43088. var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
  43089. warningWithoutStack$1(false, '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, strictRootComponentStack);
  43090. });
  43091. };
  43092. ReactStrictModeWarnings.discardPendingWarnings = function () {
  43093. pendingComponentWillMountWarnings = [];
  43094. pendingUNSAFE_ComponentWillMountWarnings = [];
  43095. pendingComponentWillReceivePropsWarnings = [];
  43096. pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  43097. pendingComponentWillUpdateWarnings = [];
  43098. pendingUNSAFE_ComponentWillUpdateWarnings = [];
  43099. pendingLegacyContextWarning = new Map();
  43100. };
  43101. }
  43102. var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
  43103. var failedBoundaries = null;
  43104. var setRefreshHandler = function (handler) {
  43105. {
  43106. resolveFamily = handler;
  43107. }
  43108. };
  43109. function resolveFunctionForHotReloading(type) {
  43110. {
  43111. if (resolveFamily === null) {
  43112. // Hot reloading is disabled.
  43113. return type;
  43114. }
  43115. var family = resolveFamily(type);
  43116. if (family === undefined) {
  43117. return type;
  43118. } // Use the latest known implementation.
  43119. return family.current;
  43120. }
  43121. }
  43122. function resolveClassForHotReloading(type) {
  43123. // No implementation differences.
  43124. return resolveFunctionForHotReloading(type);
  43125. }
  43126. function resolveForwardRefForHotReloading(type) {
  43127. {
  43128. if (resolveFamily === null) {
  43129. // Hot reloading is disabled.
  43130. return type;
  43131. }
  43132. var family = resolveFamily(type);
  43133. if (family === undefined) {
  43134. // Check if we're dealing with a real forwardRef. Don't want to crash early.
  43135. if (type !== null && type !== undefined && typeof type.render === 'function') {
  43136. // ForwardRef is special because its resolved .type is an object,
  43137. // but it's possible that we only have its inner render function in the map.
  43138. // If that inner render function is different, we'll build a new forwardRef type.
  43139. var currentRender = resolveFunctionForHotReloading(type.render);
  43140. if (type.render !== currentRender) {
  43141. var syntheticType = {
  43142. $$typeof: REACT_FORWARD_REF_TYPE,
  43143. render: currentRender
  43144. };
  43145. if (type.displayName !== undefined) {
  43146. syntheticType.displayName = type.displayName;
  43147. }
  43148. return syntheticType;
  43149. }
  43150. }
  43151. return type;
  43152. } // Use the latest known implementation.
  43153. return family.current;
  43154. }
  43155. }
  43156. function isCompatibleFamilyForHotReloading(fiber, element) {
  43157. {
  43158. if (resolveFamily === null) {
  43159. // Hot reloading is disabled.
  43160. return false;
  43161. }
  43162. var prevType = fiber.elementType;
  43163. var nextType = element.type; // If we got here, we know types aren't === equal.
  43164. var needsCompareFamilies = false;
  43165. var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null;
  43166. switch (fiber.tag) {
  43167. case ClassComponent:
  43168. {
  43169. if (typeof nextType === 'function') {
  43170. needsCompareFamilies = true;
  43171. }
  43172. break;
  43173. }
  43174. case FunctionComponent:
  43175. {
  43176. if (typeof nextType === 'function') {
  43177. needsCompareFamilies = true;
  43178. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  43179. // We don't know the inner type yet.
  43180. // We're going to assume that the lazy inner type is stable,
  43181. // and so it is sufficient to avoid reconciling it away.
  43182. // We're not going to unwrap or actually use the new lazy type.
  43183. needsCompareFamilies = true;
  43184. }
  43185. break;
  43186. }
  43187. case ForwardRef:
  43188. {
  43189. if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
  43190. needsCompareFamilies = true;
  43191. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  43192. needsCompareFamilies = true;
  43193. }
  43194. break;
  43195. }
  43196. case MemoComponent:
  43197. case SimpleMemoComponent:
  43198. {
  43199. if ($$typeofNextType === REACT_MEMO_TYPE) {
  43200. // TODO: if it was but can no longer be simple,
  43201. // we shouldn't set this.
  43202. needsCompareFamilies = true;
  43203. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  43204. needsCompareFamilies = true;
  43205. }
  43206. break;
  43207. }
  43208. default:
  43209. return false;
  43210. } // Check if both types have a family and it's the same one.
  43211. if (needsCompareFamilies) {
  43212. // Note: memo() and forwardRef() we'll compare outer rather than inner type.
  43213. // This means both of them need to be registered to preserve state.
  43214. // If we unwrapped and compared the inner types for wrappers instead,
  43215. // then we would risk falsely saying two separate memo(Foo)
  43216. // calls are equivalent because they wrap the same Foo function.
  43217. var prevFamily = resolveFamily(prevType);
  43218. if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
  43219. return true;
  43220. }
  43221. }
  43222. return false;
  43223. }
  43224. }
  43225. function markFailedErrorBoundaryForHotReloading(fiber) {
  43226. {
  43227. if (resolveFamily === null) {
  43228. // Hot reloading is disabled.
  43229. return;
  43230. }
  43231. if (typeof WeakSet !== 'function') {
  43232. return;
  43233. }
  43234. if (failedBoundaries === null) {
  43235. failedBoundaries = new WeakSet();
  43236. }
  43237. failedBoundaries.add(fiber);
  43238. }
  43239. }
  43240. var scheduleRefresh = function (root, update) {
  43241. {
  43242. if (resolveFamily === null) {
  43243. // Hot reloading is disabled.
  43244. return;
  43245. }
  43246. var staleFamilies = update.staleFamilies,
  43247. updatedFamilies = update.updatedFamilies;
  43248. flushPassiveEffects();
  43249. flushSync(function () {
  43250. scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies);
  43251. });
  43252. }
  43253. };
  43254. var scheduleRoot = function (root, element) {
  43255. {
  43256. if (root.context !== emptyContextObject) {
  43257. // Super edge case: root has a legacy _renderSubtree context
  43258. // but we don't know the parentComponent so we can't pass it.
  43259. // Just ignore. We'll delete this with _renderSubtree code path later.
  43260. return;
  43261. }
  43262. flushPassiveEffects();
  43263. updateContainerAtExpirationTime(element, root, null, Sync, null);
  43264. }
  43265. };
  43266. function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
  43267. {
  43268. var alternate = fiber.alternate,
  43269. child = fiber.child,
  43270. sibling = fiber.sibling,
  43271. tag = fiber.tag,
  43272. type = fiber.type;
  43273. var candidateType = null;
  43274. switch (tag) {
  43275. case FunctionComponent:
  43276. case SimpleMemoComponent:
  43277. case ClassComponent:
  43278. candidateType = type;
  43279. break;
  43280. case ForwardRef:
  43281. candidateType = type.render;
  43282. break;
  43283. default:
  43284. break;
  43285. }
  43286. if (resolveFamily === null) {
  43287. throw new Error('Expected resolveFamily to be set during hot reload.');
  43288. }
  43289. var needsRender = false;
  43290. var needsRemount = false;
  43291. if (candidateType !== null) {
  43292. var family = resolveFamily(candidateType);
  43293. if (family !== undefined) {
  43294. if (staleFamilies.has(family)) {
  43295. needsRemount = true;
  43296. } else if (updatedFamilies.has(family)) {
  43297. if (tag === ClassComponent) {
  43298. needsRemount = true;
  43299. } else {
  43300. needsRender = true;
  43301. }
  43302. }
  43303. }
  43304. }
  43305. if (failedBoundaries !== null) {
  43306. if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
  43307. needsRemount = true;
  43308. }
  43309. }
  43310. if (needsRemount) {
  43311. fiber._debugNeedsRemount = true;
  43312. }
  43313. if (needsRemount || needsRender) {
  43314. scheduleWork(fiber, Sync);
  43315. }
  43316. if (child !== null && !needsRemount) {
  43317. scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
  43318. }
  43319. if (sibling !== null) {
  43320. scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
  43321. }
  43322. }
  43323. }
  43324. var findHostInstancesForRefresh = function (root, families) {
  43325. {
  43326. var hostInstances = new Set();
  43327. var types = new Set(families.map(function (family) {
  43328. return family.current;
  43329. }));
  43330. findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances);
  43331. return hostInstances;
  43332. }
  43333. };
  43334. function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
  43335. {
  43336. var child = fiber.child,
  43337. sibling = fiber.sibling,
  43338. tag = fiber.tag,
  43339. type = fiber.type;
  43340. var candidateType = null;
  43341. switch (tag) {
  43342. case FunctionComponent:
  43343. case SimpleMemoComponent:
  43344. case ClassComponent:
  43345. candidateType = type;
  43346. break;
  43347. case ForwardRef:
  43348. candidateType = type.render;
  43349. break;
  43350. default:
  43351. break;
  43352. }
  43353. var didMatch = false;
  43354. if (candidateType !== null) {
  43355. if (types.has(candidateType)) {
  43356. didMatch = true;
  43357. }
  43358. }
  43359. if (didMatch) {
  43360. // We have a match. This only drills down to the closest host components.
  43361. // There's no need to search deeper because for the purpose of giving
  43362. // visual feedback, "flashing" outermost parent rectangles is sufficient.
  43363. findHostInstancesForFiberShallowly(fiber, hostInstances);
  43364. } else {
  43365. // If there's no match, maybe there will be one further down in the child tree.
  43366. if (child !== null) {
  43367. findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
  43368. }
  43369. }
  43370. if (sibling !== null) {
  43371. findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
  43372. }
  43373. }
  43374. }
  43375. function findHostInstancesForFiberShallowly(fiber, hostInstances) {
  43376. {
  43377. var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
  43378. if (foundHostInstances) {
  43379. return;
  43380. } // If we didn't find any host children, fallback to closest host parent.
  43381. var node = fiber;
  43382. while (true) {
  43383. switch (node.tag) {
  43384. case HostComponent:
  43385. hostInstances.add(node.stateNode);
  43386. return;
  43387. case HostPortal:
  43388. hostInstances.add(node.stateNode.containerInfo);
  43389. return;
  43390. case HostRoot:
  43391. hostInstances.add(node.stateNode.containerInfo);
  43392. return;
  43393. }
  43394. if (node.return === null) {
  43395. throw new Error('Expected to reach root first.');
  43396. }
  43397. node = node.return;
  43398. }
  43399. }
  43400. }
  43401. function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
  43402. {
  43403. var node = fiber;
  43404. var foundHostInstances = false;
  43405. while (true) {
  43406. if (node.tag === HostComponent) {
  43407. // We got a match.
  43408. foundHostInstances = true;
  43409. hostInstances.add(node.stateNode); // There may still be more, so keep searching.
  43410. } else if (node.child !== null) {
  43411. node.child.return = node;
  43412. node = node.child;
  43413. continue;
  43414. }
  43415. if (node === fiber) {
  43416. return foundHostInstances;
  43417. }
  43418. while (node.sibling === null) {
  43419. if (node.return === null || node.return === fiber) {
  43420. return foundHostInstances;
  43421. }
  43422. node = node.return;
  43423. }
  43424. node.sibling.return = node.return;
  43425. node = node.sibling;
  43426. }
  43427. }
  43428. return false;
  43429. }
  43430. function resolveDefaultProps(Component, baseProps) {
  43431. if (Component && Component.defaultProps) {
  43432. // Resolve default props. Taken from ReactElement
  43433. var props = _assign({}, baseProps);
  43434. var defaultProps = Component.defaultProps;
  43435. for (var propName in defaultProps) {
  43436. if (props[propName] === undefined) {
  43437. props[propName] = defaultProps[propName];
  43438. }
  43439. }
  43440. return props;
  43441. }
  43442. return baseProps;
  43443. }
  43444. function readLazyComponentType(lazyComponent) {
  43445. initializeLazyComponentType(lazyComponent);
  43446. if (lazyComponent._status !== Resolved) {
  43447. throw lazyComponent._result;
  43448. }
  43449. return lazyComponent._result;
  43450. }
  43451. var valueCursor = createCursor(null);
  43452. var rendererSigil;
  43453. {
  43454. // Use this to detect multiple renderers using the same context
  43455. rendererSigil = {};
  43456. }
  43457. var currentlyRenderingFiber = null;
  43458. var lastContextDependency = null;
  43459. var lastContextWithAllBitsObserved = null;
  43460. var isDisallowedContextReadInDEV = false;
  43461. function resetContextDependencies() {
  43462. // This is called right before React yields execution, to ensure `readContext`
  43463. // cannot be called outside the render phase.
  43464. currentlyRenderingFiber = null;
  43465. lastContextDependency = null;
  43466. lastContextWithAllBitsObserved = null;
  43467. {
  43468. isDisallowedContextReadInDEV = false;
  43469. }
  43470. }
  43471. function enterDisallowedContextReadInDEV() {
  43472. {
  43473. isDisallowedContextReadInDEV = true;
  43474. }
  43475. }
  43476. function exitDisallowedContextReadInDEV() {
  43477. {
  43478. isDisallowedContextReadInDEV = false;
  43479. }
  43480. }
  43481. function pushProvider(providerFiber, nextValue) {
  43482. var context = providerFiber.type._context;
  43483. if (isPrimaryRenderer) {
  43484. push(valueCursor, context._currentValue, providerFiber);
  43485. context._currentValue = nextValue;
  43486. {
  43487. !(context._currentRenderer === undefined || context._currentRenderer === null || context._currentRenderer === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
  43488. context._currentRenderer = rendererSigil;
  43489. }
  43490. } else {
  43491. push(valueCursor, context._currentValue2, providerFiber);
  43492. context._currentValue2 = nextValue;
  43493. {
  43494. !(context._currentRenderer2 === undefined || context._currentRenderer2 === null || context._currentRenderer2 === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
  43495. context._currentRenderer2 = rendererSigil;
  43496. }
  43497. }
  43498. }
  43499. function popProvider(providerFiber) {
  43500. var currentValue = valueCursor.current;
  43501. pop(valueCursor, providerFiber);
  43502. var context = providerFiber.type._context;
  43503. if (isPrimaryRenderer) {
  43504. context._currentValue = currentValue;
  43505. } else {
  43506. context._currentValue2 = currentValue;
  43507. }
  43508. }
  43509. function calculateChangedBits(context, newValue, oldValue) {
  43510. if (is$1(oldValue, newValue)) {
  43511. // No change
  43512. return 0;
  43513. } else {
  43514. var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
  43515. {
  43516. !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) ? warning$1(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0;
  43517. }
  43518. return changedBits | 0;
  43519. }
  43520. }
  43521. function scheduleWorkOnParentPath(parent, renderExpirationTime) {
  43522. // Update the child expiration time of all the ancestors, including
  43523. // the alternates.
  43524. var node = parent;
  43525. while (node !== null) {
  43526. var alternate = node.alternate;
  43527. if (node.childExpirationTime < renderExpirationTime) {
  43528. node.childExpirationTime = renderExpirationTime;
  43529. if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
  43530. alternate.childExpirationTime = renderExpirationTime;
  43531. }
  43532. } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
  43533. alternate.childExpirationTime = renderExpirationTime;
  43534. } else {
  43535. // Neither alternate was updated, which means the rest of the
  43536. // ancestor path already has sufficient priority.
  43537. break;
  43538. }
  43539. node = node.return;
  43540. }
  43541. }
  43542. function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
  43543. var fiber = workInProgress.child;
  43544. if (fiber !== null) {
  43545. // Set the return pointer of the child to the work-in-progress fiber.
  43546. fiber.return = workInProgress;
  43547. }
  43548. while (fiber !== null) {
  43549. var nextFiber = void 0; // Visit this fiber.
  43550. var list = fiber.dependencies;
  43551. if (list !== null) {
  43552. nextFiber = fiber.child;
  43553. var dependency = list.firstContext;
  43554. while (dependency !== null) {
  43555. // Check if the context matches.
  43556. if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
  43557. // Match! Schedule an update on this fiber.
  43558. if (fiber.tag === ClassComponent) {
  43559. // Schedule a force update on the work-in-progress.
  43560. var update = createUpdate(renderExpirationTime, null);
  43561. update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the
  43562. // update to the current fiber, too, which means it will persist even if
  43563. // this render is thrown away. Since it's a race condition, not sure it's
  43564. // worth fixing.
  43565. enqueueUpdate(fiber, update);
  43566. }
  43567. if (fiber.expirationTime < renderExpirationTime) {
  43568. fiber.expirationTime = renderExpirationTime;
  43569. }
  43570. var alternate = fiber.alternate;
  43571. if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
  43572. alternate.expirationTime = renderExpirationTime;
  43573. }
  43574. scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too.
  43575. if (list.expirationTime < renderExpirationTime) {
  43576. list.expirationTime = renderExpirationTime;
  43577. } // Since we already found a match, we can stop traversing the
  43578. // dependency list.
  43579. break;
  43580. }
  43581. dependency = dependency.next;
  43582. }
  43583. } else if (fiber.tag === ContextProvider) {
  43584. // Don't scan deeper if this is a matching provider
  43585. nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
  43586. } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedFragment) {
  43587. // If a dehydrated suspense bounudary is in this subtree, we don't know
  43588. // if it will have any context consumers in it. The best we can do is
  43589. // mark it as having updates.
  43590. var parentSuspense = fiber.return;
  43591. (function () {
  43592. if (!(parentSuspense !== null)) {
  43593. {
  43594. throw ReactError(Error("We just came from a parent so we must have had a parent. This is a bug in React."));
  43595. }
  43596. }
  43597. })();
  43598. if (parentSuspense.expirationTime < renderExpirationTime) {
  43599. parentSuspense.expirationTime = renderExpirationTime;
  43600. }
  43601. var _alternate = parentSuspense.alternate;
  43602. if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
  43603. _alternate.expirationTime = renderExpirationTime;
  43604. } // This is intentionally passing this fiber as the parent
  43605. // because we want to schedule this fiber as having work
  43606. // on its children. We'll use the childExpirationTime on
  43607. // this fiber to indicate that a context has changed.
  43608. scheduleWorkOnParentPath(parentSuspense, renderExpirationTime);
  43609. nextFiber = fiber.sibling;
  43610. } else {
  43611. // Traverse down.
  43612. nextFiber = fiber.child;
  43613. }
  43614. if (nextFiber !== null) {
  43615. // Set the return pointer of the child to the work-in-progress fiber.
  43616. nextFiber.return = fiber;
  43617. } else {
  43618. // No child. Traverse to next sibling.
  43619. nextFiber = fiber;
  43620. while (nextFiber !== null) {
  43621. if (nextFiber === workInProgress) {
  43622. // We're back to the root of this subtree. Exit.
  43623. nextFiber = null;
  43624. break;
  43625. }
  43626. var sibling = nextFiber.sibling;
  43627. if (sibling !== null) {
  43628. // Set the return pointer of the sibling to the work-in-progress fiber.
  43629. sibling.return = nextFiber.return;
  43630. nextFiber = sibling;
  43631. break;
  43632. } // No more siblings. Traverse up.
  43633. nextFiber = nextFiber.return;
  43634. }
  43635. }
  43636. fiber = nextFiber;
  43637. }
  43638. }
  43639. function prepareToReadContext(workInProgress, renderExpirationTime) {
  43640. currentlyRenderingFiber = workInProgress;
  43641. lastContextDependency = null;
  43642. lastContextWithAllBitsObserved = null;
  43643. var dependencies = workInProgress.dependencies;
  43644. if (dependencies !== null) {
  43645. var firstContext = dependencies.firstContext;
  43646. if (firstContext !== null) {
  43647. if (dependencies.expirationTime >= renderExpirationTime) {
  43648. // Context list has a pending update. Mark that this fiber performed work.
  43649. markWorkInProgressReceivedUpdate();
  43650. } // Reset the work-in-progress list
  43651. dependencies.firstContext = null;
  43652. }
  43653. }
  43654. }
  43655. function readContext(context, observedBits) {
  43656. {
  43657. // This warning would fire if you read context inside a Hook like useMemo.
  43658. // Unlike the class check below, it's not enforced in production for perf.
  43659. !!isDisallowedContextReadInDEV ? warning$1(false, '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().') : void 0;
  43660. }
  43661. if (lastContextWithAllBitsObserved === context) {// Nothing to do. We already observe everything in this context.
  43662. } else if (observedBits === false || observedBits === 0) {// Do not observe any updates.
  43663. } else {
  43664. var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types.
  43665. if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) {
  43666. // Observe all updates.
  43667. lastContextWithAllBitsObserved = context;
  43668. resolvedObservedBits = MAX_SIGNED_31_BIT_INT;
  43669. } else {
  43670. resolvedObservedBits = observedBits;
  43671. }
  43672. var contextItem = {
  43673. context: context,
  43674. observedBits: resolvedObservedBits,
  43675. next: null
  43676. };
  43677. if (lastContextDependency === null) {
  43678. (function () {
  43679. if (!(currentlyRenderingFiber !== null)) {
  43680. {
  43681. throw ReactError(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()."));
  43682. }
  43683. }
  43684. })(); // This is the first dependency for this component. Create a new list.
  43685. lastContextDependency = contextItem;
  43686. currentlyRenderingFiber.dependencies = {
  43687. expirationTime: NoWork,
  43688. firstContext: contextItem,
  43689. responders: null
  43690. };
  43691. } else {
  43692. // Append a new context item.
  43693. lastContextDependency = lastContextDependency.next = contextItem;
  43694. }
  43695. }
  43696. return isPrimaryRenderer ? context._currentValue : context._currentValue2;
  43697. }
  43698. // UpdateQueue is a linked list of prioritized updates.
  43699. //
  43700. // Like fibers, update queues come in pairs: a current queue, which represents
  43701. // the visible state of the screen, and a work-in-progress queue, which can be
  43702. // mutated and processed asynchronously before it is committed — a form of
  43703. // double buffering. If a work-in-progress render is discarded before finishing,
  43704. // we create a new work-in-progress by cloning the current queue.
  43705. //
  43706. // Both queues share a persistent, singly-linked list structure. To schedule an
  43707. // update, we append it to the end of both queues. Each queue maintains a
  43708. // pointer to first update in the persistent list that hasn't been processed.
  43709. // The work-in-progress pointer always has a position equal to or greater than
  43710. // the current queue, since we always work on that one. The current queue's
  43711. // pointer is only updated during the commit phase, when we swap in the
  43712. // work-in-progress.
  43713. //
  43714. // For example:
  43715. //
  43716. // Current pointer: A - B - C - D - E - F
  43717. // Work-in-progress pointer: D - E - F
  43718. // ^
  43719. // The work-in-progress queue has
  43720. // processed more updates than current.
  43721. //
  43722. // The reason we append to both queues is because otherwise we might drop
  43723. // updates without ever processing them. For example, if we only add updates to
  43724. // the work-in-progress queue, some updates could be lost whenever a work-in
  43725. // -progress render restarts by cloning from current. Similarly, if we only add
  43726. // updates to the current queue, the updates will be lost whenever an already
  43727. // in-progress queue commits and swaps with the current queue. However, by
  43728. // adding to both queues, we guarantee that the update will be part of the next
  43729. // work-in-progress. (And because the work-in-progress queue becomes the
  43730. // current queue once it commits, there's no danger of applying the same
  43731. // update twice.)
  43732. //
  43733. // Prioritization
  43734. // --------------
  43735. //
  43736. // Updates are not sorted by priority, but by insertion; new updates are always
  43737. // appended to the end of the list.
  43738. //
  43739. // The priority is still important, though. When processing the update queue
  43740. // during the render phase, only the updates with sufficient priority are
  43741. // included in the result. If we skip an update because it has insufficient
  43742. // priority, it remains in the queue to be processed later, during a lower
  43743. // priority render. Crucially, all updates subsequent to a skipped update also
  43744. // remain in the queue *regardless of their priority*. That means high priority
  43745. // updates are sometimes processed twice, at two separate priorities. We also
  43746. // keep track of a base state, that represents the state before the first
  43747. // update in the queue is applied.
  43748. //
  43749. // For example:
  43750. //
  43751. // Given a base state of '', and the following queue of updates
  43752. //
  43753. // A1 - B2 - C1 - D2
  43754. //
  43755. // where the number indicates the priority, and the update is applied to the
  43756. // previous state by appending a letter, React will process these updates as
  43757. // two separate renders, one per distinct priority level:
  43758. //
  43759. // First render, at priority 1:
  43760. // Base state: ''
  43761. // Updates: [A1, C1]
  43762. // Result state: 'AC'
  43763. //
  43764. // Second render, at priority 2:
  43765. // Base state: 'A' <- The base state does not include C1,
  43766. // because B2 was skipped.
  43767. // Updates: [B2, C1, D2] <- C1 was rebased on top of B2
  43768. // Result state: 'ABCD'
  43769. //
  43770. // Because we process updates in insertion order, and rebase high priority
  43771. // updates when preceding updates are skipped, the final result is deterministic
  43772. // regardless of priority. Intermediate state may vary according to system
  43773. // resources, but the final state is always the same.
  43774. var UpdateState = 0;
  43775. var ReplaceState = 1;
  43776. var ForceUpdate = 2;
  43777. var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`.
  43778. // It should only be read right after calling `processUpdateQueue`, via
  43779. // `checkHasForceUpdateAfterProcessing`.
  43780. var hasForceUpdate = false;
  43781. var didWarnUpdateInsideUpdate;
  43782. var currentlyProcessingQueue;
  43783. {
  43784. didWarnUpdateInsideUpdate = false;
  43785. currentlyProcessingQueue = null;
  43786. }
  43787. function createUpdateQueue(baseState) {
  43788. var queue = {
  43789. baseState: baseState,
  43790. firstUpdate: null,
  43791. lastUpdate: null,
  43792. firstCapturedUpdate: null,
  43793. lastCapturedUpdate: null,
  43794. firstEffect: null,
  43795. lastEffect: null,
  43796. firstCapturedEffect: null,
  43797. lastCapturedEffect: null
  43798. };
  43799. return queue;
  43800. }
  43801. function cloneUpdateQueue(currentQueue) {
  43802. var queue = {
  43803. baseState: currentQueue.baseState,
  43804. firstUpdate: currentQueue.firstUpdate,
  43805. lastUpdate: currentQueue.lastUpdate,
  43806. // TODO: With resuming, if we bail out and resuse the child tree, we should
  43807. // keep these effects.
  43808. firstCapturedUpdate: null,
  43809. lastCapturedUpdate: null,
  43810. firstEffect: null,
  43811. lastEffect: null,
  43812. firstCapturedEffect: null,
  43813. lastCapturedEffect: null
  43814. };
  43815. return queue;
  43816. }
  43817. function createUpdate(expirationTime, suspenseConfig) {
  43818. var update = {
  43819. expirationTime: expirationTime,
  43820. suspenseConfig: suspenseConfig,
  43821. tag: UpdateState,
  43822. payload: null,
  43823. callback: null,
  43824. next: null,
  43825. nextEffect: null
  43826. };
  43827. {
  43828. update.priority = getCurrentPriorityLevel();
  43829. }
  43830. return update;
  43831. }
  43832. function appendUpdateToQueue(queue, update) {
  43833. // Append the update to the end of the list.
  43834. if (queue.lastUpdate === null) {
  43835. // Queue is empty
  43836. queue.firstUpdate = queue.lastUpdate = update;
  43837. } else {
  43838. queue.lastUpdate.next = update;
  43839. queue.lastUpdate = update;
  43840. }
  43841. }
  43842. function enqueueUpdate(fiber, update) {
  43843. // Update queues are created lazily.
  43844. var alternate = fiber.alternate;
  43845. var queue1;
  43846. var queue2;
  43847. if (alternate === null) {
  43848. // There's only one fiber.
  43849. queue1 = fiber.updateQueue;
  43850. queue2 = null;
  43851. if (queue1 === null) {
  43852. queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
  43853. }
  43854. } else {
  43855. // There are two owners.
  43856. queue1 = fiber.updateQueue;
  43857. queue2 = alternate.updateQueue;
  43858. if (queue1 === null) {
  43859. if (queue2 === null) {
  43860. // Neither fiber has an update queue. Create new ones.
  43861. queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
  43862. queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState);
  43863. } else {
  43864. // Only one fiber has an update queue. Clone to create a new one.
  43865. queue1 = fiber.updateQueue = cloneUpdateQueue(queue2);
  43866. }
  43867. } else {
  43868. if (queue2 === null) {
  43869. // Only one fiber has an update queue. Clone to create a new one.
  43870. queue2 = alternate.updateQueue = cloneUpdateQueue(queue1);
  43871. } else {// Both owners have an update queue.
  43872. }
  43873. }
  43874. }
  43875. if (queue2 === null || queue1 === queue2) {
  43876. // There's only a single queue.
  43877. appendUpdateToQueue(queue1, update);
  43878. } else {
  43879. // There are two queues. We need to append the update to both queues,
  43880. // while accounting for the persistent structure of the list — we don't
  43881. // want the same update to be added multiple times.
  43882. if (queue1.lastUpdate === null || queue2.lastUpdate === null) {
  43883. // One of the queues is not empty. We must add the update to both queues.
  43884. appendUpdateToQueue(queue1, update);
  43885. appendUpdateToQueue(queue2, update);
  43886. } else {
  43887. // Both queues are non-empty. The last update is the same in both lists,
  43888. // because of structural sharing. So, only append to one of the lists.
  43889. appendUpdateToQueue(queue1, update); // But we still need to update the `lastUpdate` pointer of queue2.
  43890. queue2.lastUpdate = update;
  43891. }
  43892. }
  43893. {
  43894. if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
  43895. warningWithoutStack$1(false, '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.');
  43896. didWarnUpdateInsideUpdate = true;
  43897. }
  43898. }
  43899. }
  43900. function enqueueCapturedUpdate(workInProgress, update) {
  43901. // Captured updates go into a separate list, and only on the work-in-
  43902. // progress queue.
  43903. var workInProgressQueue = workInProgress.updateQueue;
  43904. if (workInProgressQueue === null) {
  43905. workInProgressQueue = workInProgress.updateQueue = createUpdateQueue(workInProgress.memoizedState);
  43906. } else {
  43907. // TODO: I put this here rather than createWorkInProgress so that we don't
  43908. // clone the queue unnecessarily. There's probably a better way to
  43909. // structure this.
  43910. workInProgressQueue = ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue);
  43911. } // Append the update to the end of the list.
  43912. if (workInProgressQueue.lastCapturedUpdate === null) {
  43913. // This is the first render phase update
  43914. workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update;
  43915. } else {
  43916. workInProgressQueue.lastCapturedUpdate.next = update;
  43917. workInProgressQueue.lastCapturedUpdate = update;
  43918. }
  43919. }
  43920. function ensureWorkInProgressQueueIsAClone(workInProgress, queue) {
  43921. var current = workInProgress.alternate;
  43922. if (current !== null) {
  43923. // If the work-in-progress queue is equal to the current queue,
  43924. // we need to clone it first.
  43925. if (queue === current.updateQueue) {
  43926. queue = workInProgress.updateQueue = cloneUpdateQueue(queue);
  43927. }
  43928. }
  43929. return queue;
  43930. }
  43931. function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
  43932. switch (update.tag) {
  43933. case ReplaceState:
  43934. {
  43935. var payload = update.payload;
  43936. if (typeof payload === 'function') {
  43937. // Updater function
  43938. {
  43939. enterDisallowedContextReadInDEV();
  43940. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  43941. payload.call(instance, prevState, nextProps);
  43942. }
  43943. }
  43944. var nextState = payload.call(instance, prevState, nextProps);
  43945. {
  43946. exitDisallowedContextReadInDEV();
  43947. }
  43948. return nextState;
  43949. } // State object
  43950. return payload;
  43951. }
  43952. case CaptureUpdate:
  43953. {
  43954. workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
  43955. }
  43956. // Intentional fallthrough
  43957. case UpdateState:
  43958. {
  43959. var _payload = update.payload;
  43960. var partialState;
  43961. if (typeof _payload === 'function') {
  43962. // Updater function
  43963. {
  43964. enterDisallowedContextReadInDEV();
  43965. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  43966. _payload.call(instance, prevState, nextProps);
  43967. }
  43968. }
  43969. partialState = _payload.call(instance, prevState, nextProps);
  43970. {
  43971. exitDisallowedContextReadInDEV();
  43972. }
  43973. } else {
  43974. // Partial state object
  43975. partialState = _payload;
  43976. }
  43977. if (partialState === null || partialState === undefined) {
  43978. // Null and undefined are treated as no-ops.
  43979. return prevState;
  43980. } // Merge the partial state and the previous state.
  43981. return _assign({}, prevState, partialState);
  43982. }
  43983. case ForceUpdate:
  43984. {
  43985. hasForceUpdate = true;
  43986. return prevState;
  43987. }
  43988. }
  43989. return prevState;
  43990. }
  43991. function processUpdateQueue(workInProgress, queue, props, instance, renderExpirationTime) {
  43992. hasForceUpdate = false;
  43993. queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue);
  43994. {
  43995. currentlyProcessingQueue = queue;
  43996. } // These values may change as we process the queue.
  43997. var newBaseState = queue.baseState;
  43998. var newFirstUpdate = null;
  43999. var newExpirationTime = NoWork; // Iterate through the list of updates to compute the result.
  44000. var update = queue.firstUpdate;
  44001. var resultState = newBaseState;
  44002. while (update !== null) {
  44003. var updateExpirationTime = update.expirationTime;
  44004. if (updateExpirationTime < renderExpirationTime) {
  44005. // This update does not have sufficient priority. Skip it.
  44006. if (newFirstUpdate === null) {
  44007. // This is the first skipped update. It will be the first update in
  44008. // the new list.
  44009. newFirstUpdate = update; // Since this is the first update that was skipped, the current result
  44010. // is the new base state.
  44011. newBaseState = resultState;
  44012. } // Since this update will remain in the list, update the remaining
  44013. // expiration time.
  44014. if (newExpirationTime < updateExpirationTime) {
  44015. newExpirationTime = updateExpirationTime;
  44016. }
  44017. } else {
  44018. // This update does have sufficient priority.
  44019. // Mark the event time of this update as relevant to this render pass.
  44020. // TODO: This should ideally use the true event time of this update rather than
  44021. // its priority which is a derived and not reverseable value.
  44022. // TODO: We should skip this update if it was already committed but currently
  44023. // we have no way of detecting the difference between a committed and suspended
  44024. // update here.
  44025. markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process it and compute a new result.
  44026. resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
  44027. var callback = update.callback;
  44028. if (callback !== null) {
  44029. workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render.
  44030. update.nextEffect = null;
  44031. if (queue.lastEffect === null) {
  44032. queue.firstEffect = queue.lastEffect = update;
  44033. } else {
  44034. queue.lastEffect.nextEffect = update;
  44035. queue.lastEffect = update;
  44036. }
  44037. }
  44038. } // Continue to the next update.
  44039. update = update.next;
  44040. } // Separately, iterate though the list of captured updates.
  44041. var newFirstCapturedUpdate = null;
  44042. update = queue.firstCapturedUpdate;
  44043. while (update !== null) {
  44044. var _updateExpirationTime = update.expirationTime;
  44045. if (_updateExpirationTime < renderExpirationTime) {
  44046. // This update does not have sufficient priority. Skip it.
  44047. if (newFirstCapturedUpdate === null) {
  44048. // This is the first skipped captured update. It will be the first
  44049. // update in the new list.
  44050. newFirstCapturedUpdate = update; // If this is the first update that was skipped, the current result is
  44051. // the new base state.
  44052. if (newFirstUpdate === null) {
  44053. newBaseState = resultState;
  44054. }
  44055. } // Since this update will remain in the list, update the remaining
  44056. // expiration time.
  44057. if (newExpirationTime < _updateExpirationTime) {
  44058. newExpirationTime = _updateExpirationTime;
  44059. }
  44060. } else {
  44061. // This update does have sufficient priority. Process it and compute
  44062. // a new result.
  44063. resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
  44064. var _callback = update.callback;
  44065. if (_callback !== null) {
  44066. workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render.
  44067. update.nextEffect = null;
  44068. if (queue.lastCapturedEffect === null) {
  44069. queue.firstCapturedEffect = queue.lastCapturedEffect = update;
  44070. } else {
  44071. queue.lastCapturedEffect.nextEffect = update;
  44072. queue.lastCapturedEffect = update;
  44073. }
  44074. }
  44075. }
  44076. update = update.next;
  44077. }
  44078. if (newFirstUpdate === null) {
  44079. queue.lastUpdate = null;
  44080. }
  44081. if (newFirstCapturedUpdate === null) {
  44082. queue.lastCapturedUpdate = null;
  44083. } else {
  44084. workInProgress.effectTag |= Callback;
  44085. }
  44086. if (newFirstUpdate === null && newFirstCapturedUpdate === null) {
  44087. // We processed every update, without skipping. That means the new base
  44088. // state is the same as the result state.
  44089. newBaseState = resultState;
  44090. }
  44091. queue.baseState = newBaseState;
  44092. queue.firstUpdate = newFirstUpdate;
  44093. queue.firstCapturedUpdate = newFirstCapturedUpdate; // Set the remaining expiration time to be whatever is remaining in the queue.
  44094. // This should be fine because the only two other things that contribute to
  44095. // expiration time are props and context. We're already in the middle of the
  44096. // begin phase by the time we start processing the queue, so we've already
  44097. // dealt with the props. Context in components that specify
  44098. // shouldComponentUpdate is tricky; but we'll have to account for
  44099. // that regardless.
  44100. markUnprocessedUpdateTime(newExpirationTime);
  44101. workInProgress.expirationTime = newExpirationTime;
  44102. workInProgress.memoizedState = resultState;
  44103. {
  44104. currentlyProcessingQueue = null;
  44105. }
  44106. }
  44107. function callCallback(callback, context) {
  44108. (function () {
  44109. if (!(typeof callback === 'function')) {
  44110. {
  44111. throw ReactError(Error("Invalid argument passed as callback. Expected a function. Instead received: " + callback));
  44112. }
  44113. }
  44114. })();
  44115. callback.call(context);
  44116. }
  44117. function resetHasForceUpdateBeforeProcessing() {
  44118. hasForceUpdate = false;
  44119. }
  44120. function checkHasForceUpdateAfterProcessing() {
  44121. return hasForceUpdate;
  44122. }
  44123. function commitUpdateQueue(finishedWork, finishedQueue, instance, renderExpirationTime) {
  44124. // If the finished render included captured updates, and there are still
  44125. // lower priority updates left over, we need to keep the captured updates
  44126. // in the queue so that they are rebased and not dropped once we process the
  44127. // queue again at the lower priority.
  44128. if (finishedQueue.firstCapturedUpdate !== null) {
  44129. // Join the captured update list to the end of the normal list.
  44130. if (finishedQueue.lastUpdate !== null) {
  44131. finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate;
  44132. finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate;
  44133. } // Clear the list of captured updates.
  44134. finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null;
  44135. } // Commit the effects
  44136. commitUpdateEffects(finishedQueue.firstEffect, instance);
  44137. finishedQueue.firstEffect = finishedQueue.lastEffect = null;
  44138. commitUpdateEffects(finishedQueue.firstCapturedEffect, instance);
  44139. finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null;
  44140. }
  44141. function commitUpdateEffects(effect, instance) {
  44142. while (effect !== null) {
  44143. var callback = effect.callback;
  44144. if (callback !== null) {
  44145. effect.callback = null;
  44146. callCallback(callback, instance);
  44147. }
  44148. effect = effect.nextEffect;
  44149. }
  44150. }
  44151. var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
  44152. function requestCurrentSuspenseConfig() {
  44153. return ReactCurrentBatchConfig.suspense;
  44154. }
  44155. var fakeInternalInstance = {};
  44156. var isArray$1 = Array.isArray; // React.Component uses a shared frozen object by default.
  44157. // We'll use it to determine whether we need to initialize legacy refs.
  44158. var emptyRefsObject = new React.Component().refs;
  44159. var didWarnAboutStateAssignmentForComponent;
  44160. var didWarnAboutUninitializedState;
  44161. var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
  44162. var didWarnAboutLegacyLifecyclesAndDerivedState;
  44163. var didWarnAboutUndefinedDerivedState;
  44164. var warnOnUndefinedDerivedState;
  44165. var warnOnInvalidCallback$1;
  44166. var didWarnAboutDirectlyAssigningPropsToState;
  44167. var didWarnAboutContextTypeAndContextTypes;
  44168. var didWarnAboutInvalidateContextType;
  44169. {
  44170. didWarnAboutStateAssignmentForComponent = new Set();
  44171. didWarnAboutUninitializedState = new Set();
  44172. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
  44173. didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
  44174. didWarnAboutDirectlyAssigningPropsToState = new Set();
  44175. didWarnAboutUndefinedDerivedState = new Set();
  44176. didWarnAboutContextTypeAndContextTypes = new Set();
  44177. didWarnAboutInvalidateContextType = new Set();
  44178. var didWarnOnInvalidCallback = new Set();
  44179. warnOnInvalidCallback$1 = function (callback, callerName) {
  44180. if (callback === null || typeof callback === 'function') {
  44181. return;
  44182. }
  44183. var key = callerName + "_" + callback;
  44184. if (!didWarnOnInvalidCallback.has(key)) {
  44185. didWarnOnInvalidCallback.add(key);
  44186. warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
  44187. }
  44188. };
  44189. warnOnUndefinedDerivedState = function (type, partialState) {
  44190. if (partialState === undefined) {
  44191. var componentName = getComponentName(type) || 'Component';
  44192. if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
  44193. didWarnAboutUndefinedDerivedState.add(componentName);
  44194. warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
  44195. }
  44196. }
  44197. }; // This is so gross but it's at least non-critical and can be removed if
  44198. // it causes problems. This is meant to give a nicer error message for
  44199. // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
  44200. // ...)) which otherwise throws a "_processChildContext is not a function"
  44201. // exception.
  44202. Object.defineProperty(fakeInternalInstance, '_processChildContext', {
  44203. enumerable: false,
  44204. value: function () {
  44205. (function () {
  44206. {
  44207. {
  44208. throw ReactError(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)."));
  44209. }
  44210. }
  44211. })();
  44212. }
  44213. });
  44214. Object.freeze(fakeInternalInstance);
  44215. }
  44216. function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
  44217. var prevState = workInProgress.memoizedState;
  44218. {
  44219. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  44220. // Invoke the function an extra time to help detect side-effects.
  44221. getDerivedStateFromProps(nextProps, prevState);
  44222. }
  44223. }
  44224. var partialState = getDerivedStateFromProps(nextProps, prevState);
  44225. {
  44226. warnOnUndefinedDerivedState(ctor, partialState);
  44227. } // Merge the partial state and the previous state.
  44228. var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
  44229. workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the
  44230. // base state.
  44231. var updateQueue = workInProgress.updateQueue;
  44232. if (updateQueue !== null && workInProgress.expirationTime === NoWork) {
  44233. updateQueue.baseState = memoizedState;
  44234. }
  44235. }
  44236. var classComponentUpdater = {
  44237. isMounted: isMounted,
  44238. enqueueSetState: function (inst, payload, callback) {
  44239. var fiber = get(inst);
  44240. var currentTime = requestCurrentTime();
  44241. var suspenseConfig = requestCurrentSuspenseConfig();
  44242. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  44243. var update = createUpdate(expirationTime, suspenseConfig);
  44244. update.payload = payload;
  44245. if (callback !== undefined && callback !== null) {
  44246. {
  44247. warnOnInvalidCallback$1(callback, 'setState');
  44248. }
  44249. update.callback = callback;
  44250. }
  44251. enqueueUpdate(fiber, update);
  44252. scheduleWork(fiber, expirationTime);
  44253. },
  44254. enqueueReplaceState: function (inst, payload, callback) {
  44255. var fiber = get(inst);
  44256. var currentTime = requestCurrentTime();
  44257. var suspenseConfig = requestCurrentSuspenseConfig();
  44258. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  44259. var update = createUpdate(expirationTime, suspenseConfig);
  44260. update.tag = ReplaceState;
  44261. update.payload = payload;
  44262. if (callback !== undefined && callback !== null) {
  44263. {
  44264. warnOnInvalidCallback$1(callback, 'replaceState');
  44265. }
  44266. update.callback = callback;
  44267. }
  44268. enqueueUpdate(fiber, update);
  44269. scheduleWork(fiber, expirationTime);
  44270. },
  44271. enqueueForceUpdate: function (inst, callback) {
  44272. var fiber = get(inst);
  44273. var currentTime = requestCurrentTime();
  44274. var suspenseConfig = requestCurrentSuspenseConfig();
  44275. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  44276. var update = createUpdate(expirationTime, suspenseConfig);
  44277. update.tag = ForceUpdate;
  44278. if (callback !== undefined && callback !== null) {
  44279. {
  44280. warnOnInvalidCallback$1(callback, 'forceUpdate');
  44281. }
  44282. update.callback = callback;
  44283. }
  44284. enqueueUpdate(fiber, update);
  44285. scheduleWork(fiber, expirationTime);
  44286. }
  44287. };
  44288. function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
  44289. var instance = workInProgress.stateNode;
  44290. if (typeof instance.shouldComponentUpdate === 'function') {
  44291. startPhaseTimer(workInProgress, 'shouldComponentUpdate');
  44292. var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
  44293. stopPhaseTimer();
  44294. {
  44295. !(shouldUpdate !== undefined) ? warningWithoutStack$1(false, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component') : void 0;
  44296. }
  44297. return shouldUpdate;
  44298. }
  44299. if (ctor.prototype && ctor.prototype.isPureReactComponent) {
  44300. return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
  44301. }
  44302. return true;
  44303. }
  44304. function checkClassInstance(workInProgress, ctor, newProps) {
  44305. var instance = workInProgress.stateNode;
  44306. {
  44307. var name = getComponentName(ctor) || 'Component';
  44308. var renderPresent = instance.render;
  44309. if (!renderPresent) {
  44310. if (ctor.prototype && typeof ctor.prototype.render === 'function') {
  44311. warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
  44312. } else {
  44313. warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
  44314. }
  44315. }
  44316. var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
  44317. !noGetInitialStateOnES6 ? warningWithoutStack$1(false, '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) : void 0;
  44318. var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
  44319. !noGetDefaultPropsOnES6 ? warningWithoutStack$1(false, '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) : void 0;
  44320. var noInstancePropTypes = !instance.propTypes;
  44321. !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
  44322. var noInstanceContextType = !instance.contextType;
  44323. !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
  44324. if (disableLegacyContext) {
  44325. if (ctor.childContextTypes) {
  44326. warningWithoutStack$1(false, '%s uses the legacy childContextTypes API which is no longer supported. ' + 'Use React.createContext() instead.', name);
  44327. }
  44328. if (ctor.contextTypes) {
  44329. warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with static contextType instead.', name);
  44330. }
  44331. } else {
  44332. var noInstanceContextTypes = !instance.contextTypes;
  44333. !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
  44334. if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
  44335. didWarnAboutContextTypeAndContextTypes.add(ctor);
  44336. warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
  44337. }
  44338. }
  44339. var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
  44340. !noComponentShouldUpdate ? warningWithoutStack$1(false, '%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) : void 0;
  44341. if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
  44342. warningWithoutStack$1(false, '%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');
  44343. }
  44344. var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
  44345. !noComponentDidUnmount ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
  44346. var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
  44347. !noComponentDidReceiveProps ? warningWithoutStack$1(false, '%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) : void 0;
  44348. var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
  44349. !noComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
  44350. var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
  44351. !noUnsafeComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
  44352. var hasMutatedProps = instance.props !== newProps;
  44353. !(instance.props === undefined || !hasMutatedProps) ? warningWithoutStack$1(false, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name) : void 0;
  44354. var noInstanceDefaultProps = !instance.defaultProps;
  44355. !noInstanceDefaultProps ? warningWithoutStack$1(false, '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) : void 0;
  44356. if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
  44357. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
  44358. warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
  44359. }
  44360. var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
  44361. !noInstanceGetDerivedStateFromProps ? warningWithoutStack$1(false, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
  44362. var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
  44363. !noInstanceGetDerivedStateFromCatch ? warningWithoutStack$1(false, '%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
  44364. var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
  44365. !noStaticGetSnapshotBeforeUpdate ? warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name) : void 0;
  44366. var _state = instance.state;
  44367. if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
  44368. warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
  44369. }
  44370. if (typeof instance.getChildContext === 'function') {
  44371. !(typeof ctor.childContextTypes === 'object') ? warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
  44372. }
  44373. }
  44374. }
  44375. function adoptClassInstance(workInProgress, instance) {
  44376. instance.updater = classComponentUpdater;
  44377. workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates
  44378. set(instance, workInProgress);
  44379. {
  44380. instance._reactInternalInstance = fakeInternalInstance;
  44381. }
  44382. }
  44383. function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
  44384. var isLegacyContextConsumer = false;
  44385. var unmaskedContext = emptyContextObject;
  44386. var context = emptyContextObject;
  44387. var contextType = ctor.contextType;
  44388. {
  44389. if ('contextType' in ctor) {
  44390. var isValid = // Allow null for conditional declaration
  44391. contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
  44392. if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
  44393. didWarnAboutInvalidateContextType.add(ctor);
  44394. var addendum = '';
  44395. if (contextType === undefined) {
  44396. 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.';
  44397. } else if (typeof contextType !== 'object') {
  44398. addendum = ' However, it is set to a ' + typeof contextType + '.';
  44399. } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
  44400. addendum = ' Did you accidentally pass the Context.Provider instead?';
  44401. } else if (contextType._context !== undefined) {
  44402. // <Context.Consumer>
  44403. addendum = ' Did you accidentally pass the Context.Consumer instead?';
  44404. } else {
  44405. addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
  44406. }
  44407. warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
  44408. }
  44409. }
  44410. }
  44411. if (typeof contextType === 'object' && contextType !== null) {
  44412. context = readContext(contextType);
  44413. } else if (!disableLegacyContext) {
  44414. unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  44415. var contextTypes = ctor.contextTypes;
  44416. isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
  44417. context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
  44418. } // Instantiate twice to help detect side-effects.
  44419. {
  44420. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  44421. new ctor(props, context); // eslint-disable-line no-new
  44422. }
  44423. }
  44424. var instance = new ctor(props, context);
  44425. var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
  44426. adoptClassInstance(workInProgress, instance);
  44427. {
  44428. if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
  44429. var componentName = getComponentName(ctor) || 'Component';
  44430. if (!didWarnAboutUninitializedState.has(componentName)) {
  44431. didWarnAboutUninitializedState.add(componentName);
  44432. warningWithoutStack$1(false, '`%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);
  44433. }
  44434. } // If new component APIs are defined, "unsafe" lifecycles won't be called.
  44435. // Warn about these lifecycles if they are present.
  44436. // Don't warn about react-lifecycles-compat polyfilled methods though.
  44437. if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
  44438. var foundWillMountName = null;
  44439. var foundWillReceivePropsName = null;
  44440. var foundWillUpdateName = null;
  44441. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
  44442. foundWillMountName = 'componentWillMount';
  44443. } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
  44444. foundWillMountName = 'UNSAFE_componentWillMount';
  44445. }
  44446. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  44447. foundWillReceivePropsName = 'componentWillReceiveProps';
  44448. } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  44449. foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
  44450. }
  44451. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  44452. foundWillUpdateName = 'componentWillUpdate';
  44453. } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  44454. foundWillUpdateName = 'UNSAFE_componentWillUpdate';
  44455. }
  44456. if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
  44457. var _componentName = getComponentName(ctor) || 'Component';
  44458. var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
  44459. if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
  44460. didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
  44461. warningWithoutStack$1(false, '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 : '');
  44462. }
  44463. }
  44464. }
  44465. } // Cache unmasked context so we can avoid recreating masked context unless necessary.
  44466. // ReactFiberContext usually updates this cache but can't for newly-created instances.
  44467. if (isLegacyContextConsumer) {
  44468. cacheContext(workInProgress, unmaskedContext, context);
  44469. }
  44470. return instance;
  44471. }
  44472. function callComponentWillMount(workInProgress, instance) {
  44473. startPhaseTimer(workInProgress, 'componentWillMount');
  44474. var oldState = instance.state;
  44475. if (typeof instance.componentWillMount === 'function') {
  44476. instance.componentWillMount();
  44477. }
  44478. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  44479. instance.UNSAFE_componentWillMount();
  44480. }
  44481. stopPhaseTimer();
  44482. if (oldState !== instance.state) {
  44483. {
  44484. warningWithoutStack$1(false, '%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component');
  44485. }
  44486. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  44487. }
  44488. }
  44489. function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
  44490. var oldState = instance.state;
  44491. startPhaseTimer(workInProgress, 'componentWillReceiveProps');
  44492. if (typeof instance.componentWillReceiveProps === 'function') {
  44493. instance.componentWillReceiveProps(newProps, nextContext);
  44494. }
  44495. if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  44496. instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
  44497. }
  44498. stopPhaseTimer();
  44499. if (instance.state !== oldState) {
  44500. {
  44501. var componentName = getComponentName(workInProgress.type) || 'Component';
  44502. if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
  44503. didWarnAboutStateAssignmentForComponent.add(componentName);
  44504. warningWithoutStack$1(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
  44505. }
  44506. }
  44507. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  44508. }
  44509. } // Invokes the mount life-cycles on a previously never rendered instance.
  44510. function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
  44511. {
  44512. checkClassInstance(workInProgress, ctor, newProps);
  44513. }
  44514. var instance = workInProgress.stateNode;
  44515. instance.props = newProps;
  44516. instance.state = workInProgress.memoizedState;
  44517. instance.refs = emptyRefsObject;
  44518. var contextType = ctor.contextType;
  44519. if (typeof contextType === 'object' && contextType !== null) {
  44520. instance.context = readContext(contextType);
  44521. } else if (disableLegacyContext) {
  44522. instance.context = emptyContextObject;
  44523. } else {
  44524. var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  44525. instance.context = getMaskedContext(workInProgress, unmaskedContext);
  44526. }
  44527. {
  44528. if (instance.state === newProps) {
  44529. var componentName = getComponentName(ctor) || 'Component';
  44530. if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
  44531. didWarnAboutDirectlyAssigningPropsToState.add(componentName);
  44532. warningWithoutStack$1(false, '%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);
  44533. }
  44534. }
  44535. if (workInProgress.mode & StrictMode) {
  44536. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
  44537. }
  44538. if (warnAboutDeprecatedLifecycles) {
  44539. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
  44540. }
  44541. }
  44542. var updateQueue = workInProgress.updateQueue;
  44543. if (updateQueue !== null) {
  44544. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  44545. instance.state = workInProgress.memoizedState;
  44546. }
  44547. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  44548. if (typeof getDerivedStateFromProps === 'function') {
  44549. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  44550. instance.state = workInProgress.memoizedState;
  44551. } // In order to support react-lifecycles-compat polyfilled components,
  44552. // Unsafe lifecycles should not be invoked for components using the new APIs.
  44553. if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  44554. callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's
  44555. // process them now.
  44556. updateQueue = workInProgress.updateQueue;
  44557. if (updateQueue !== null) {
  44558. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  44559. instance.state = workInProgress.memoizedState;
  44560. }
  44561. }
  44562. if (typeof instance.componentDidMount === 'function') {
  44563. workInProgress.effectTag |= Update;
  44564. }
  44565. }
  44566. function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
  44567. var instance = workInProgress.stateNode;
  44568. var oldProps = workInProgress.memoizedProps;
  44569. instance.props = oldProps;
  44570. var oldContext = instance.context;
  44571. var contextType = ctor.contextType;
  44572. var nextContext = emptyContextObject;
  44573. if (typeof contextType === 'object' && contextType !== null) {
  44574. nextContext = readContext(contextType);
  44575. } else if (!disableLegacyContext) {
  44576. var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  44577. nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
  44578. }
  44579. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  44580. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
  44581. // ever the previously attempted to render - not the "current". However,
  44582. // during componentDidUpdate we pass the "current" props.
  44583. // In order to support react-lifecycles-compat polyfilled components,
  44584. // Unsafe lifecycles should not be invoked for components using the new APIs.
  44585. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  44586. if (oldProps !== newProps || oldContext !== nextContext) {
  44587. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  44588. }
  44589. }
  44590. resetHasForceUpdateBeforeProcessing();
  44591. var oldState = workInProgress.memoizedState;
  44592. var newState = instance.state = oldState;
  44593. var updateQueue = workInProgress.updateQueue;
  44594. if (updateQueue !== null) {
  44595. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  44596. newState = workInProgress.memoizedState;
  44597. }
  44598. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  44599. // If an update was already in progress, we should schedule an Update
  44600. // effect even though we're bailing out, so that cWU/cDU are called.
  44601. if (typeof instance.componentDidMount === 'function') {
  44602. workInProgress.effectTag |= Update;
  44603. }
  44604. return false;
  44605. }
  44606. if (typeof getDerivedStateFromProps === 'function') {
  44607. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  44608. newState = workInProgress.memoizedState;
  44609. }
  44610. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  44611. if (shouldUpdate) {
  44612. // In order to support react-lifecycles-compat polyfilled components,
  44613. // Unsafe lifecycles should not be invoked for components using the new APIs.
  44614. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  44615. startPhaseTimer(workInProgress, 'componentWillMount');
  44616. if (typeof instance.componentWillMount === 'function') {
  44617. instance.componentWillMount();
  44618. }
  44619. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  44620. instance.UNSAFE_componentWillMount();
  44621. }
  44622. stopPhaseTimer();
  44623. }
  44624. if (typeof instance.componentDidMount === 'function') {
  44625. workInProgress.effectTag |= Update;
  44626. }
  44627. } else {
  44628. // If an update was already in progress, we should schedule an Update
  44629. // effect even though we're bailing out, so that cWU/cDU are called.
  44630. if (typeof instance.componentDidMount === 'function') {
  44631. workInProgress.effectTag |= Update;
  44632. } // If shouldComponentUpdate returned false, we should still update the
  44633. // memoized state to indicate that this work can be reused.
  44634. workInProgress.memoizedProps = newProps;
  44635. workInProgress.memoizedState = newState;
  44636. } // Update the existing instance's state, props, and context pointers even
  44637. // if shouldComponentUpdate returns false.
  44638. instance.props = newProps;
  44639. instance.state = newState;
  44640. instance.context = nextContext;
  44641. return shouldUpdate;
  44642. } // Invokes the update life-cycles and returns false if it shouldn't rerender.
  44643. function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
  44644. var instance = workInProgress.stateNode;
  44645. var oldProps = workInProgress.memoizedProps;
  44646. instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
  44647. var oldContext = instance.context;
  44648. var contextType = ctor.contextType;
  44649. var nextContext = emptyContextObject;
  44650. if (typeof contextType === 'object' && contextType !== null) {
  44651. nextContext = readContext(contextType);
  44652. } else if (!disableLegacyContext) {
  44653. var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  44654. nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
  44655. }
  44656. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  44657. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
  44658. // ever the previously attempted to render - not the "current". However,
  44659. // during componentDidUpdate we pass the "current" props.
  44660. // In order to support react-lifecycles-compat polyfilled components,
  44661. // Unsafe lifecycles should not be invoked for components using the new APIs.
  44662. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  44663. if (oldProps !== newProps || oldContext !== nextContext) {
  44664. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  44665. }
  44666. }
  44667. resetHasForceUpdateBeforeProcessing();
  44668. var oldState = workInProgress.memoizedState;
  44669. var newState = instance.state = oldState;
  44670. var updateQueue = workInProgress.updateQueue;
  44671. if (updateQueue !== null) {
  44672. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  44673. newState = workInProgress.memoizedState;
  44674. }
  44675. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  44676. // If an update was already in progress, we should schedule an Update
  44677. // effect even though we're bailing out, so that cWU/cDU are called.
  44678. if (typeof instance.componentDidUpdate === 'function') {
  44679. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  44680. workInProgress.effectTag |= Update;
  44681. }
  44682. }
  44683. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  44684. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  44685. workInProgress.effectTag |= Snapshot;
  44686. }
  44687. }
  44688. return false;
  44689. }
  44690. if (typeof getDerivedStateFromProps === 'function') {
  44691. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  44692. newState = workInProgress.memoizedState;
  44693. }
  44694. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  44695. if (shouldUpdate) {
  44696. // In order to support react-lifecycles-compat polyfilled components,
  44697. // Unsafe lifecycles should not be invoked for components using the new APIs.
  44698. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
  44699. startPhaseTimer(workInProgress, 'componentWillUpdate');
  44700. if (typeof instance.componentWillUpdate === 'function') {
  44701. instance.componentWillUpdate(newProps, newState, nextContext);
  44702. }
  44703. if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  44704. instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
  44705. }
  44706. stopPhaseTimer();
  44707. }
  44708. if (typeof instance.componentDidUpdate === 'function') {
  44709. workInProgress.effectTag |= Update;
  44710. }
  44711. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  44712. workInProgress.effectTag |= Snapshot;
  44713. }
  44714. } else {
  44715. // If an update was already in progress, we should schedule an Update
  44716. // effect even though we're bailing out, so that cWU/cDU are called.
  44717. if (typeof instance.componentDidUpdate === 'function') {
  44718. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  44719. workInProgress.effectTag |= Update;
  44720. }
  44721. }
  44722. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  44723. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  44724. workInProgress.effectTag |= Snapshot;
  44725. }
  44726. } // If shouldComponentUpdate returned false, we should still update the
  44727. // memoized props/state to indicate that this work can be reused.
  44728. workInProgress.memoizedProps = newProps;
  44729. workInProgress.memoizedState = newState;
  44730. } // Update the existing instance's state, props, and context pointers even
  44731. // if shouldComponentUpdate returns false.
  44732. instance.props = newProps;
  44733. instance.state = newState;
  44734. instance.context = nextContext;
  44735. return shouldUpdate;
  44736. }
  44737. var didWarnAboutMaps;
  44738. var didWarnAboutGenerators;
  44739. var didWarnAboutStringRefs;
  44740. var ownerHasKeyUseWarning;
  44741. var ownerHasFunctionTypeWarning;
  44742. var warnForMissingKey = function (child) {};
  44743. {
  44744. didWarnAboutMaps = false;
  44745. didWarnAboutGenerators = false;
  44746. didWarnAboutStringRefs = {};
  44747. /**
  44748. * Warn if there's no key explicitly set on dynamic arrays of children or
  44749. * object keys are not valid. This allows us to keep track of children between
  44750. * updates.
  44751. */
  44752. ownerHasKeyUseWarning = {};
  44753. ownerHasFunctionTypeWarning = {};
  44754. warnForMissingKey = function (child) {
  44755. if (child === null || typeof child !== 'object') {
  44756. return;
  44757. }
  44758. if (!child._store || child._store.validated || child.key != null) {
  44759. return;
  44760. }
  44761. (function () {
  44762. if (!(typeof child._store === 'object')) {
  44763. {
  44764. throw ReactError(Error("React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue."));
  44765. }
  44766. }
  44767. })();
  44768. child._store.validated = true;
  44769. var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
  44770. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  44771. return;
  44772. }
  44773. ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
  44774. warning$1(false, 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
  44775. };
  44776. }
  44777. var isArray = Array.isArray;
  44778. function coerceRef(returnFiber, current$$1, element) {
  44779. var mixedRef = element.ref;
  44780. if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
  44781. {
  44782. // TODO: Clean this up once we turn on the string ref warning for
  44783. // everyone, because the strict mode case will no longer be relevant
  44784. if (returnFiber.mode & StrictMode || warnAboutStringRefs) {
  44785. var componentName = getComponentName(returnFiber.type) || 'Component';
  44786. if (!didWarnAboutStringRefs[componentName]) {
  44787. if (warnAboutStringRefs) {
  44788. warningWithoutStack$1(false, 'Component "%s" contains the string ref "%s". Support for string refs ' + 'will be removed in a future major release. We recommend using ' + 'useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', componentName, mixedRef, getStackByFiberInDevAndProd(returnFiber));
  44789. } else {
  44790. warningWithoutStack$1(false, '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));
  44791. }
  44792. didWarnAboutStringRefs[componentName] = true;
  44793. }
  44794. }
  44795. }
  44796. if (element._owner) {
  44797. var owner = element._owner;
  44798. var inst;
  44799. if (owner) {
  44800. var ownerFiber = owner;
  44801. (function () {
  44802. if (!(ownerFiber.tag === ClassComponent)) {
  44803. {
  44804. throw ReactError(Error("Function components cannot have refs. Did you mean to use React.forwardRef()?"));
  44805. }
  44806. }
  44807. })();
  44808. inst = ownerFiber.stateNode;
  44809. }
  44810. (function () {
  44811. if (!inst) {
  44812. {
  44813. throw ReactError(Error("Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue."));
  44814. }
  44815. }
  44816. })();
  44817. var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref
  44818. if (current$$1 !== null && current$$1.ref !== null && typeof current$$1.ref === 'function' && current$$1.ref._stringRef === stringRef) {
  44819. return current$$1.ref;
  44820. }
  44821. var ref = function (value) {
  44822. var refs = inst.refs;
  44823. if (refs === emptyRefsObject) {
  44824. // This is a lazy pooled frozen object, so we need to initialize.
  44825. refs = inst.refs = {};
  44826. }
  44827. if (value === null) {
  44828. delete refs[stringRef];
  44829. } else {
  44830. refs[stringRef] = value;
  44831. }
  44832. };
  44833. ref._stringRef = stringRef;
  44834. return ref;
  44835. } else {
  44836. (function () {
  44837. if (!(typeof mixedRef === 'string')) {
  44838. {
  44839. throw ReactError(Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null."));
  44840. }
  44841. }
  44842. })();
  44843. (function () {
  44844. if (!element._owner) {
  44845. {
  44846. throw ReactError(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."));
  44847. }
  44848. }
  44849. })();
  44850. }
  44851. }
  44852. return mixedRef;
  44853. }
  44854. function throwOnInvalidObjectType(returnFiber, newChild) {
  44855. if (returnFiber.type !== 'textarea') {
  44856. var addendum = '';
  44857. {
  44858. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
  44859. }
  44860. (function () {
  44861. {
  44862. {
  44863. throw ReactError(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));
  44864. }
  44865. }
  44866. })();
  44867. }
  44868. }
  44869. function warnOnFunctionType() {
  44870. 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();
  44871. if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
  44872. return;
  44873. }
  44874. ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
  44875. warning$1(false, '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.');
  44876. } // This wrapper function exists because I expect to clone the code in each path
  44877. // to be able to optimize each path individually by branching early. This needs
  44878. // a compiler or we can do it manually. Helpers that don't need this branching
  44879. // live outside of this function.
  44880. function ChildReconciler(shouldTrackSideEffects) {
  44881. function deleteChild(returnFiber, childToDelete) {
  44882. if (!shouldTrackSideEffects) {
  44883. // Noop.
  44884. return;
  44885. } // Deletions are added in reversed order so we add it to the front.
  44886. // At this point, the return fiber's effect list is empty except for
  44887. // deletions, so we can just append the deletion to the list. The remaining
  44888. // effects aren't added until the complete phase. Once we implement
  44889. // resuming, this may not be true.
  44890. var last = returnFiber.lastEffect;
  44891. if (last !== null) {
  44892. last.nextEffect = childToDelete;
  44893. returnFiber.lastEffect = childToDelete;
  44894. } else {
  44895. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  44896. }
  44897. childToDelete.nextEffect = null;
  44898. childToDelete.effectTag = Deletion;
  44899. }
  44900. function deleteRemainingChildren(returnFiber, currentFirstChild) {
  44901. if (!shouldTrackSideEffects) {
  44902. // Noop.
  44903. return null;
  44904. } // TODO: For the shouldClone case, this could be micro-optimized a bit by
  44905. // assuming that after the first child we've already added everything.
  44906. var childToDelete = currentFirstChild;
  44907. while (childToDelete !== null) {
  44908. deleteChild(returnFiber, childToDelete);
  44909. childToDelete = childToDelete.sibling;
  44910. }
  44911. return null;
  44912. }
  44913. function mapRemainingChildren(returnFiber, currentFirstChild) {
  44914. // Add the remaining children to a temporary map so that we can find them by
  44915. // keys quickly. Implicit (null) keys get added to this set with their index
  44916. // instead.
  44917. var existingChildren = new Map();
  44918. var existingChild = currentFirstChild;
  44919. while (existingChild !== null) {
  44920. if (existingChild.key !== null) {
  44921. existingChildren.set(existingChild.key, existingChild);
  44922. } else {
  44923. existingChildren.set(existingChild.index, existingChild);
  44924. }
  44925. existingChild = existingChild.sibling;
  44926. }
  44927. return existingChildren;
  44928. }
  44929. function useFiber(fiber, pendingProps, expirationTime) {
  44930. // We currently set sibling to null and index to 0 here because it is easy
  44931. // to forget to do before returning it. E.g. for the single child case.
  44932. var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
  44933. clone.index = 0;
  44934. clone.sibling = null;
  44935. return clone;
  44936. }
  44937. function placeChild(newFiber, lastPlacedIndex, newIndex) {
  44938. newFiber.index = newIndex;
  44939. if (!shouldTrackSideEffects) {
  44940. // Noop.
  44941. return lastPlacedIndex;
  44942. }
  44943. var current$$1 = newFiber.alternate;
  44944. if (current$$1 !== null) {
  44945. var oldIndex = current$$1.index;
  44946. if (oldIndex < lastPlacedIndex) {
  44947. // This is a move.
  44948. newFiber.effectTag = Placement;
  44949. return lastPlacedIndex;
  44950. } else {
  44951. // This item can stay in place.
  44952. return oldIndex;
  44953. }
  44954. } else {
  44955. // This is an insertion.
  44956. newFiber.effectTag = Placement;
  44957. return lastPlacedIndex;
  44958. }
  44959. }
  44960. function placeSingleChild(newFiber) {
  44961. // This is simpler for the single child case. We only need to do a
  44962. // placement for inserting new children.
  44963. if (shouldTrackSideEffects && newFiber.alternate === null) {
  44964. newFiber.effectTag = Placement;
  44965. }
  44966. return newFiber;
  44967. }
  44968. function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {
  44969. if (current$$1 === null || current$$1.tag !== HostText) {
  44970. // Insert
  44971. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  44972. created.return = returnFiber;
  44973. return created;
  44974. } else {
  44975. // Update
  44976. var existing = useFiber(current$$1, textContent, expirationTime);
  44977. existing.return = returnFiber;
  44978. return existing;
  44979. }
  44980. }
  44981. function updateElement(returnFiber, current$$1, element, expirationTime) {
  44982. if (current$$1 !== null && (current$$1.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
  44983. isCompatibleFamilyForHotReloading(current$$1, element)))) {
  44984. // Move based on index
  44985. var existing = useFiber(current$$1, element.props, expirationTime);
  44986. existing.ref = coerceRef(returnFiber, current$$1, element);
  44987. existing.return = returnFiber;
  44988. {
  44989. existing._debugSource = element._source;
  44990. existing._debugOwner = element._owner;
  44991. }
  44992. return existing;
  44993. } else {
  44994. // Insert
  44995. var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
  44996. created.ref = coerceRef(returnFiber, current$$1, element);
  44997. created.return = returnFiber;
  44998. return created;
  44999. }
  45000. }
  45001. function updatePortal(returnFiber, current$$1, portal, expirationTime) {
  45002. if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {
  45003. // Insert
  45004. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  45005. created.return = returnFiber;
  45006. return created;
  45007. } else {
  45008. // Update
  45009. var existing = useFiber(current$$1, portal.children || [], expirationTime);
  45010. existing.return = returnFiber;
  45011. return existing;
  45012. }
  45013. }
  45014. function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {
  45015. if (current$$1 === null || current$$1.tag !== Fragment) {
  45016. // Insert
  45017. var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
  45018. created.return = returnFiber;
  45019. return created;
  45020. } else {
  45021. // Update
  45022. var existing = useFiber(current$$1, fragment, expirationTime);
  45023. existing.return = returnFiber;
  45024. return existing;
  45025. }
  45026. }
  45027. function createChild(returnFiber, newChild, expirationTime) {
  45028. if (typeof newChild === 'string' || typeof newChild === 'number') {
  45029. // Text nodes don't have keys. If the previous node is implicitly keyed
  45030. // we can continue to replace it without aborting even if it is not a text
  45031. // node.
  45032. var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
  45033. created.return = returnFiber;
  45034. return created;
  45035. }
  45036. if (typeof newChild === 'object' && newChild !== null) {
  45037. switch (newChild.$$typeof) {
  45038. case REACT_ELEMENT_TYPE:
  45039. {
  45040. var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
  45041. _created.ref = coerceRef(returnFiber, null, newChild);
  45042. _created.return = returnFiber;
  45043. return _created;
  45044. }
  45045. case REACT_PORTAL_TYPE:
  45046. {
  45047. var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
  45048. _created2.return = returnFiber;
  45049. return _created2;
  45050. }
  45051. }
  45052. if (isArray(newChild) || getIteratorFn(newChild)) {
  45053. var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
  45054. _created3.return = returnFiber;
  45055. return _created3;
  45056. }
  45057. throwOnInvalidObjectType(returnFiber, newChild);
  45058. }
  45059. {
  45060. if (typeof newChild === 'function') {
  45061. warnOnFunctionType();
  45062. }
  45063. }
  45064. return null;
  45065. }
  45066. function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
  45067. // Update the fiber if the keys match, otherwise return null.
  45068. var key = oldFiber !== null ? oldFiber.key : null;
  45069. if (typeof newChild === 'string' || typeof newChild === 'number') {
  45070. // Text nodes don't have keys. If the previous node is implicitly keyed
  45071. // we can continue to replace it without aborting even if it is not a text
  45072. // node.
  45073. if (key !== null) {
  45074. return null;
  45075. }
  45076. return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
  45077. }
  45078. if (typeof newChild === 'object' && newChild !== null) {
  45079. switch (newChild.$$typeof) {
  45080. case REACT_ELEMENT_TYPE:
  45081. {
  45082. if (newChild.key === key) {
  45083. if (newChild.type === REACT_FRAGMENT_TYPE) {
  45084. return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
  45085. }
  45086. return updateElement(returnFiber, oldFiber, newChild, expirationTime);
  45087. } else {
  45088. return null;
  45089. }
  45090. }
  45091. case REACT_PORTAL_TYPE:
  45092. {
  45093. if (newChild.key === key) {
  45094. return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
  45095. } else {
  45096. return null;
  45097. }
  45098. }
  45099. }
  45100. if (isArray(newChild) || getIteratorFn(newChild)) {
  45101. if (key !== null) {
  45102. return null;
  45103. }
  45104. return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
  45105. }
  45106. throwOnInvalidObjectType(returnFiber, newChild);
  45107. }
  45108. {
  45109. if (typeof newChild === 'function') {
  45110. warnOnFunctionType();
  45111. }
  45112. }
  45113. return null;
  45114. }
  45115. function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
  45116. if (typeof newChild === 'string' || typeof newChild === 'number') {
  45117. // Text nodes don't have keys, so we neither have to check the old nor
  45118. // new node for the key. If both are text nodes, they match.
  45119. var matchedFiber = existingChildren.get(newIdx) || null;
  45120. return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
  45121. }
  45122. if (typeof newChild === 'object' && newChild !== null) {
  45123. switch (newChild.$$typeof) {
  45124. case REACT_ELEMENT_TYPE:
  45125. {
  45126. var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  45127. if (newChild.type === REACT_FRAGMENT_TYPE) {
  45128. return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
  45129. }
  45130. return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
  45131. }
  45132. case REACT_PORTAL_TYPE:
  45133. {
  45134. var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  45135. return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
  45136. }
  45137. }
  45138. if (isArray(newChild) || getIteratorFn(newChild)) {
  45139. var _matchedFiber3 = existingChildren.get(newIdx) || null;
  45140. return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
  45141. }
  45142. throwOnInvalidObjectType(returnFiber, newChild);
  45143. }
  45144. {
  45145. if (typeof newChild === 'function') {
  45146. warnOnFunctionType();
  45147. }
  45148. }
  45149. return null;
  45150. }
  45151. /**
  45152. * Warns if there is a duplicate or missing key
  45153. */
  45154. function warnOnInvalidKey(child, knownKeys) {
  45155. {
  45156. if (typeof child !== 'object' || child === null) {
  45157. return knownKeys;
  45158. }
  45159. switch (child.$$typeof) {
  45160. case REACT_ELEMENT_TYPE:
  45161. case REACT_PORTAL_TYPE:
  45162. warnForMissingKey(child);
  45163. var key = child.key;
  45164. if (typeof key !== 'string') {
  45165. break;
  45166. }
  45167. if (knownKeys === null) {
  45168. knownKeys = new Set();
  45169. knownKeys.add(key);
  45170. break;
  45171. }
  45172. if (!knownKeys.has(key)) {
  45173. knownKeys.add(key);
  45174. break;
  45175. }
  45176. warning$1(false, '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);
  45177. break;
  45178. default:
  45179. break;
  45180. }
  45181. }
  45182. return knownKeys;
  45183. }
  45184. function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
  45185. // This algorithm can't optimize by searching from both ends since we
  45186. // don't have backpointers on fibers. I'm trying to see how far we can get
  45187. // with that model. If it ends up not being worth the tradeoffs, we can
  45188. // add it later.
  45189. // Even with a two ended optimization, we'd want to optimize for the case
  45190. // where there are few changes and brute force the comparison instead of
  45191. // going for the Map. It'd like to explore hitting that path first in
  45192. // forward-only mode and only go for the Map once we notice that we need
  45193. // lots of look ahead. This doesn't handle reversal as well as two ended
  45194. // search but that's unusual. Besides, for the two ended optimization to
  45195. // work on Iterables, we'd need to copy the whole set.
  45196. // In this first iteration, we'll just live with hitting the bad case
  45197. // (adding everything to a Map) in for every insert/move.
  45198. // If you change this code, also update reconcileChildrenIterator() which
  45199. // uses the same algorithm.
  45200. {
  45201. // First, validate keys.
  45202. var knownKeys = null;
  45203. for (var i = 0; i < newChildren.length; i++) {
  45204. var child = newChildren[i];
  45205. knownKeys = warnOnInvalidKey(child, knownKeys);
  45206. }
  45207. }
  45208. var resultingFirstChild = null;
  45209. var previousNewFiber = null;
  45210. var oldFiber = currentFirstChild;
  45211. var lastPlacedIndex = 0;
  45212. var newIdx = 0;
  45213. var nextOldFiber = null;
  45214. for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
  45215. if (oldFiber.index > newIdx) {
  45216. nextOldFiber = oldFiber;
  45217. oldFiber = null;
  45218. } else {
  45219. nextOldFiber = oldFiber.sibling;
  45220. }
  45221. var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
  45222. if (newFiber === null) {
  45223. // TODO: This breaks on empty slots like null children. That's
  45224. // unfortunate because it triggers the slow path all the time. We need
  45225. // a better way to communicate whether this was a miss or null,
  45226. // boolean, undefined, etc.
  45227. if (oldFiber === null) {
  45228. oldFiber = nextOldFiber;
  45229. }
  45230. break;
  45231. }
  45232. if (shouldTrackSideEffects) {
  45233. if (oldFiber && newFiber.alternate === null) {
  45234. // We matched the slot, but we didn't reuse the existing fiber, so we
  45235. // need to delete the existing child.
  45236. deleteChild(returnFiber, oldFiber);
  45237. }
  45238. }
  45239. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  45240. if (previousNewFiber === null) {
  45241. // TODO: Move out of the loop. This only happens for the first run.
  45242. resultingFirstChild = newFiber;
  45243. } else {
  45244. // TODO: Defer siblings if we're not at the right index for this slot.
  45245. // I.e. if we had null values before, then we want to defer this
  45246. // for each null value. However, we also don't want to call updateSlot
  45247. // with the previous one.
  45248. previousNewFiber.sibling = newFiber;
  45249. }
  45250. previousNewFiber = newFiber;
  45251. oldFiber = nextOldFiber;
  45252. }
  45253. if (newIdx === newChildren.length) {
  45254. // We've reached the end of the new children. We can delete the rest.
  45255. deleteRemainingChildren(returnFiber, oldFiber);
  45256. return resultingFirstChild;
  45257. }
  45258. if (oldFiber === null) {
  45259. // If we don't have any more existing children we can choose a fast path
  45260. // since the rest will all be insertions.
  45261. for (; newIdx < newChildren.length; newIdx++) {
  45262. var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
  45263. if (_newFiber === null) {
  45264. continue;
  45265. }
  45266. lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
  45267. if (previousNewFiber === null) {
  45268. // TODO: Move out of the loop. This only happens for the first run.
  45269. resultingFirstChild = _newFiber;
  45270. } else {
  45271. previousNewFiber.sibling = _newFiber;
  45272. }
  45273. previousNewFiber = _newFiber;
  45274. }
  45275. return resultingFirstChild;
  45276. } // Add all children to a key map for quick lookups.
  45277. var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
  45278. for (; newIdx < newChildren.length; newIdx++) {
  45279. var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
  45280. if (_newFiber2 !== null) {
  45281. if (shouldTrackSideEffects) {
  45282. if (_newFiber2.alternate !== null) {
  45283. // The new fiber is a work in progress, but if there exists a
  45284. // current, that means that we reused the fiber. We need to delete
  45285. // it from the child list so that we don't add it to the deletion
  45286. // list.
  45287. existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
  45288. }
  45289. }
  45290. lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
  45291. if (previousNewFiber === null) {
  45292. resultingFirstChild = _newFiber2;
  45293. } else {
  45294. previousNewFiber.sibling = _newFiber2;
  45295. }
  45296. previousNewFiber = _newFiber2;
  45297. }
  45298. }
  45299. if (shouldTrackSideEffects) {
  45300. // Any existing children that weren't consumed above were deleted. We need
  45301. // to add them to the deletion list.
  45302. existingChildren.forEach(function (child) {
  45303. return deleteChild(returnFiber, child);
  45304. });
  45305. }
  45306. return resultingFirstChild;
  45307. }
  45308. function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
  45309. // This is the same implementation as reconcileChildrenArray(),
  45310. // but using the iterator instead.
  45311. var iteratorFn = getIteratorFn(newChildrenIterable);
  45312. (function () {
  45313. if (!(typeof iteratorFn === 'function')) {
  45314. {
  45315. throw ReactError(Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue."));
  45316. }
  45317. }
  45318. })();
  45319. {
  45320. // We don't support rendering Generators because it's a mutation.
  45321. // See https://github.com/facebook/react/issues/12995
  45322. if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag
  45323. newChildrenIterable[Symbol.toStringTag] === 'Generator') {
  45324. !didWarnAboutGenerators ? warning$1(false, '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.') : void 0;
  45325. didWarnAboutGenerators = true;
  45326. } // Warn about using Maps as children
  45327. if (newChildrenIterable.entries === iteratorFn) {
  45328. !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
  45329. didWarnAboutMaps = true;
  45330. } // First, validate keys.
  45331. // We'll get a different iterator later for the main pass.
  45332. var _newChildren = iteratorFn.call(newChildrenIterable);
  45333. if (_newChildren) {
  45334. var knownKeys = null;
  45335. var _step = _newChildren.next();
  45336. for (; !_step.done; _step = _newChildren.next()) {
  45337. var child = _step.value;
  45338. knownKeys = warnOnInvalidKey(child, knownKeys);
  45339. }
  45340. }
  45341. }
  45342. var newChildren = iteratorFn.call(newChildrenIterable);
  45343. (function () {
  45344. if (!(newChildren != null)) {
  45345. {
  45346. throw ReactError(Error("An iterable object provided no iterator."));
  45347. }
  45348. }
  45349. })();
  45350. var resultingFirstChild = null;
  45351. var previousNewFiber = null;
  45352. var oldFiber = currentFirstChild;
  45353. var lastPlacedIndex = 0;
  45354. var newIdx = 0;
  45355. var nextOldFiber = null;
  45356. var step = newChildren.next();
  45357. for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
  45358. if (oldFiber.index > newIdx) {
  45359. nextOldFiber = oldFiber;
  45360. oldFiber = null;
  45361. } else {
  45362. nextOldFiber = oldFiber.sibling;
  45363. }
  45364. var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
  45365. if (newFiber === null) {
  45366. // TODO: This breaks on empty slots like null children. That's
  45367. // unfortunate because it triggers the slow path all the time. We need
  45368. // a better way to communicate whether this was a miss or null,
  45369. // boolean, undefined, etc.
  45370. if (oldFiber === null) {
  45371. oldFiber = nextOldFiber;
  45372. }
  45373. break;
  45374. }
  45375. if (shouldTrackSideEffects) {
  45376. if (oldFiber && newFiber.alternate === null) {
  45377. // We matched the slot, but we didn't reuse the existing fiber, so we
  45378. // need to delete the existing child.
  45379. deleteChild(returnFiber, oldFiber);
  45380. }
  45381. }
  45382. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  45383. if (previousNewFiber === null) {
  45384. // TODO: Move out of the loop. This only happens for the first run.
  45385. resultingFirstChild = newFiber;
  45386. } else {
  45387. // TODO: Defer siblings if we're not at the right index for this slot.
  45388. // I.e. if we had null values before, then we want to defer this
  45389. // for each null value. However, we also don't want to call updateSlot
  45390. // with the previous one.
  45391. previousNewFiber.sibling = newFiber;
  45392. }
  45393. previousNewFiber = newFiber;
  45394. oldFiber = nextOldFiber;
  45395. }
  45396. if (step.done) {
  45397. // We've reached the end of the new children. We can delete the rest.
  45398. deleteRemainingChildren(returnFiber, oldFiber);
  45399. return resultingFirstChild;
  45400. }
  45401. if (oldFiber === null) {
  45402. // If we don't have any more existing children we can choose a fast path
  45403. // since the rest will all be insertions.
  45404. for (; !step.done; newIdx++, step = newChildren.next()) {
  45405. var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
  45406. if (_newFiber3 === null) {
  45407. continue;
  45408. }
  45409. lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
  45410. if (previousNewFiber === null) {
  45411. // TODO: Move out of the loop. This only happens for the first run.
  45412. resultingFirstChild = _newFiber3;
  45413. } else {
  45414. previousNewFiber.sibling = _newFiber3;
  45415. }
  45416. previousNewFiber = _newFiber3;
  45417. }
  45418. return resultingFirstChild;
  45419. } // Add all children to a key map for quick lookups.
  45420. var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
  45421. for (; !step.done; newIdx++, step = newChildren.next()) {
  45422. var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
  45423. if (_newFiber4 !== null) {
  45424. if (shouldTrackSideEffects) {
  45425. if (_newFiber4.alternate !== null) {
  45426. // The new fiber is a work in progress, but if there exists a
  45427. // current, that means that we reused the fiber. We need to delete
  45428. // it from the child list so that we don't add it to the deletion
  45429. // list.
  45430. existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
  45431. }
  45432. }
  45433. lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
  45434. if (previousNewFiber === null) {
  45435. resultingFirstChild = _newFiber4;
  45436. } else {
  45437. previousNewFiber.sibling = _newFiber4;
  45438. }
  45439. previousNewFiber = _newFiber4;
  45440. }
  45441. }
  45442. if (shouldTrackSideEffects) {
  45443. // Any existing children that weren't consumed above were deleted. We need
  45444. // to add them to the deletion list.
  45445. existingChildren.forEach(function (child) {
  45446. return deleteChild(returnFiber, child);
  45447. });
  45448. }
  45449. return resultingFirstChild;
  45450. }
  45451. function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
  45452. // There's no need to check for keys on text nodes since we don't have a
  45453. // way to define them.
  45454. if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
  45455. // We already have an existing node so let's just update it and delete
  45456. // the rest.
  45457. deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
  45458. var existing = useFiber(currentFirstChild, textContent, expirationTime);
  45459. existing.return = returnFiber;
  45460. return existing;
  45461. } // The existing first child is not a text node so we need to create one
  45462. // and delete the existing ones.
  45463. deleteRemainingChildren(returnFiber, currentFirstChild);
  45464. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  45465. created.return = returnFiber;
  45466. return created;
  45467. }
  45468. function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
  45469. var key = element.key;
  45470. var child = currentFirstChild;
  45471. while (child !== null) {
  45472. // TODO: If key === null and child.key === null, then this only applies to
  45473. // the first item in the list.
  45474. if (child.key === key) {
  45475. if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
  45476. isCompatibleFamilyForHotReloading(child, element))) {
  45477. deleteRemainingChildren(returnFiber, child.sibling);
  45478. var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
  45479. existing.ref = coerceRef(returnFiber, child, element);
  45480. existing.return = returnFiber;
  45481. {
  45482. existing._debugSource = element._source;
  45483. existing._debugOwner = element._owner;
  45484. }
  45485. return existing;
  45486. } else {
  45487. deleteRemainingChildren(returnFiber, child);
  45488. break;
  45489. }
  45490. } else {
  45491. deleteChild(returnFiber, child);
  45492. }
  45493. child = child.sibling;
  45494. }
  45495. if (element.type === REACT_FRAGMENT_TYPE) {
  45496. var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
  45497. created.return = returnFiber;
  45498. return created;
  45499. } else {
  45500. var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
  45501. _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
  45502. _created4.return = returnFiber;
  45503. return _created4;
  45504. }
  45505. }
  45506. function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
  45507. var key = portal.key;
  45508. var child = currentFirstChild;
  45509. while (child !== null) {
  45510. // TODO: If key === null and child.key === null, then this only applies to
  45511. // the first item in the list.
  45512. if (child.key === key) {
  45513. if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
  45514. deleteRemainingChildren(returnFiber, child.sibling);
  45515. var existing = useFiber(child, portal.children || [], expirationTime);
  45516. existing.return = returnFiber;
  45517. return existing;
  45518. } else {
  45519. deleteRemainingChildren(returnFiber, child);
  45520. break;
  45521. }
  45522. } else {
  45523. deleteChild(returnFiber, child);
  45524. }
  45525. child = child.sibling;
  45526. }
  45527. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  45528. created.return = returnFiber;
  45529. return created;
  45530. } // This API will tag the children with the side-effect of the reconciliation
  45531. // itself. They will be added to the side-effect list as we pass through the
  45532. // children and the parent.
  45533. function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
  45534. // This function is not recursive.
  45535. // If the top level item is an array, we treat it as a set of children,
  45536. // not as a fragment. Nested arrays on the other hand will be treated as
  45537. // fragment nodes. Recursion happens at the normal flow.
  45538. // Handle top level unkeyed fragments as if they were arrays.
  45539. // This leads to an ambiguity between <>{[...]}</> and <>...</>.
  45540. // We treat the ambiguous cases above the same.
  45541. var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
  45542. if (isUnkeyedTopLevelFragment) {
  45543. newChild = newChild.props.children;
  45544. } // Handle object types
  45545. var isObject = typeof newChild === 'object' && newChild !== null;
  45546. if (isObject) {
  45547. switch (newChild.$$typeof) {
  45548. case REACT_ELEMENT_TYPE:
  45549. return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
  45550. case REACT_PORTAL_TYPE:
  45551. return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
  45552. }
  45553. }
  45554. if (typeof newChild === 'string' || typeof newChild === 'number') {
  45555. return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
  45556. }
  45557. if (isArray(newChild)) {
  45558. return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
  45559. }
  45560. if (getIteratorFn(newChild)) {
  45561. return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
  45562. }
  45563. if (isObject) {
  45564. throwOnInvalidObjectType(returnFiber, newChild);
  45565. }
  45566. {
  45567. if (typeof newChild === 'function') {
  45568. warnOnFunctionType();
  45569. }
  45570. }
  45571. if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
  45572. // If the new child is undefined, and the return fiber is a composite
  45573. // component, throw an error. If Fiber return types are disabled,
  45574. // we already threw above.
  45575. switch (returnFiber.tag) {
  45576. case ClassComponent:
  45577. {
  45578. {
  45579. var instance = returnFiber.stateNode;
  45580. if (instance.render._isMockFunction) {
  45581. // We allow auto-mocks to proceed as if they're returning null.
  45582. break;
  45583. }
  45584. }
  45585. }
  45586. // Intentionally fall through to the next case, which handles both
  45587. // functions and classes
  45588. // eslint-disable-next-lined no-fallthrough
  45589. case FunctionComponent:
  45590. {
  45591. var Component = returnFiber.type;
  45592. (function () {
  45593. {
  45594. {
  45595. throw ReactError(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."));
  45596. }
  45597. }
  45598. })();
  45599. }
  45600. }
  45601. } // Remaining cases are all treated as empty.
  45602. return deleteRemainingChildren(returnFiber, currentFirstChild);
  45603. }
  45604. return reconcileChildFibers;
  45605. }
  45606. var reconcileChildFibers = ChildReconciler(true);
  45607. var mountChildFibers = ChildReconciler(false);
  45608. function cloneChildFibers(current$$1, workInProgress) {
  45609. (function () {
  45610. if (!(current$$1 === null || workInProgress.child === current$$1.child)) {
  45611. {
  45612. throw ReactError(Error("Resuming work not yet implemented."));
  45613. }
  45614. }
  45615. })();
  45616. if (workInProgress.child === null) {
  45617. return;
  45618. }
  45619. var currentChild = workInProgress.child;
  45620. var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
  45621. workInProgress.child = newChild;
  45622. newChild.return = workInProgress;
  45623. while (currentChild.sibling !== null) {
  45624. currentChild = currentChild.sibling;
  45625. newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
  45626. newChild.return = workInProgress;
  45627. }
  45628. newChild.sibling = null;
  45629. } // Reset a workInProgress child set to prepare it for a second pass.
  45630. function resetChildFibers(workInProgress, renderExpirationTime) {
  45631. var child = workInProgress.child;
  45632. while (child !== null) {
  45633. resetWorkInProgress(child, renderExpirationTime);
  45634. child = child.sibling;
  45635. }
  45636. }
  45637. var NO_CONTEXT = {};
  45638. var contextStackCursor$1 = createCursor(NO_CONTEXT);
  45639. var contextFiberStackCursor = createCursor(NO_CONTEXT);
  45640. var rootInstanceStackCursor = createCursor(NO_CONTEXT);
  45641. function requiredContext(c) {
  45642. (function () {
  45643. if (!(c !== NO_CONTEXT)) {
  45644. {
  45645. throw ReactError(Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."));
  45646. }
  45647. }
  45648. })();
  45649. return c;
  45650. }
  45651. function getRootHostContainer() {
  45652. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  45653. return rootInstance;
  45654. }
  45655. function pushHostContainer(fiber, nextRootInstance) {
  45656. // Push current root instance onto the stack;
  45657. // This allows us to reset root when portals are popped.
  45658. push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it.
  45659. // This enables us to pop only Fibers that provide unique contexts.
  45660. push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack.
  45661. // However, we can't just call getRootHostContext() and push it because
  45662. // we'd have a different number of entries on the stack depending on
  45663. // whether getRootHostContext() throws somewhere in renderer code or not.
  45664. // So we push an empty value first. This lets us safely unwind on errors.
  45665. push(contextStackCursor$1, NO_CONTEXT, fiber);
  45666. var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it.
  45667. pop(contextStackCursor$1, fiber);
  45668. push(contextStackCursor$1, nextRootContext, fiber);
  45669. }
  45670. function popHostContainer(fiber) {
  45671. pop(contextStackCursor$1, fiber);
  45672. pop(contextFiberStackCursor, fiber);
  45673. pop(rootInstanceStackCursor, fiber);
  45674. }
  45675. function getHostContext() {
  45676. var context = requiredContext(contextStackCursor$1.current);
  45677. return context;
  45678. }
  45679. function pushHostContext(fiber) {
  45680. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  45681. var context = requiredContext(contextStackCursor$1.current);
  45682. var nextContext = getChildHostContext(context, fiber.type, rootInstance); // Don't push this Fiber's context unless it's unique.
  45683. if (context === nextContext) {
  45684. return;
  45685. } // Track the context and the Fiber that provided it.
  45686. // This enables us to pop only Fibers that provide unique contexts.
  45687. push(contextFiberStackCursor, fiber, fiber);
  45688. push(contextStackCursor$1, nextContext, fiber);
  45689. }
  45690. function popHostContext(fiber) {
  45691. // Do not pop unless this Fiber provided the current context.
  45692. // pushHostContext() only pushes Fibers that provide unique contexts.
  45693. if (contextFiberStackCursor.current !== fiber) {
  45694. return;
  45695. }
  45696. pop(contextStackCursor$1, fiber);
  45697. pop(contextFiberStackCursor, fiber);
  45698. }
  45699. var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is
  45700. // inherited deeply down the subtree. The upper bits only affect
  45701. // this immediate suspense boundary and gets reset each new
  45702. // boundary or suspense list.
  45703. var SubtreeSuspenseContextMask = 1; // Subtree Flags:
  45704. // InvisibleParentSuspenseContext indicates that one of our parent Suspense
  45705. // boundaries is not currently showing visible main content.
  45706. // Either because it is already showing a fallback or is not mounted at all.
  45707. // We can use this to determine if it is desirable to trigger a fallback at
  45708. // the parent. If not, then we might need to trigger undesirable boundaries
  45709. // and/or suspend the commit to avoid hiding the parent content.
  45710. var InvisibleParentSuspenseContext = 1; // Shallow Flags:
  45711. // ForceSuspenseFallback can be used by SuspenseList to force newly added
  45712. // items into their fallback state during one of the render passes.
  45713. var ForceSuspenseFallback = 2;
  45714. var suspenseStackCursor = createCursor(DefaultSuspenseContext);
  45715. function hasSuspenseContext(parentContext, flag) {
  45716. return (parentContext & flag) !== 0;
  45717. }
  45718. function setDefaultShallowSuspenseContext(parentContext) {
  45719. return parentContext & SubtreeSuspenseContextMask;
  45720. }
  45721. function setShallowSuspenseContext(parentContext, shallowContext) {
  45722. return parentContext & SubtreeSuspenseContextMask | shallowContext;
  45723. }
  45724. function addSubtreeSuspenseContext(parentContext, subtreeContext) {
  45725. return parentContext | subtreeContext;
  45726. }
  45727. function pushSuspenseContext(fiber, newContext) {
  45728. push(suspenseStackCursor, newContext, fiber);
  45729. }
  45730. function popSuspenseContext(fiber) {
  45731. pop(suspenseStackCursor, fiber);
  45732. }
  45733. function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
  45734. // If it was the primary children that just suspended, capture and render the
  45735. // fallback. Otherwise, don't capture and bubble to the next boundary.
  45736. var nextState = workInProgress.memoizedState;
  45737. if (nextState !== null) {
  45738. if (nextState.dehydrated !== null) {
  45739. // A dehydrated boundary always captures.
  45740. return true;
  45741. }
  45742. return false;
  45743. }
  45744. var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop.
  45745. if (props.fallback === undefined) {
  45746. return false;
  45747. } // Regular boundaries always capture.
  45748. if (props.unstable_avoidThisFallback !== true) {
  45749. return true;
  45750. } // If it's a boundary we should avoid, then we prefer to bubble up to the
  45751. // parent boundary if it is currently invisible.
  45752. if (hasInvisibleParent) {
  45753. return false;
  45754. } // If the parent is not able to handle it, we must handle it.
  45755. return true;
  45756. }
  45757. function findFirstSuspended(row) {
  45758. var node = row;
  45759. while (node !== null) {
  45760. if (node.tag === SuspenseComponent) {
  45761. var state = node.memoizedState;
  45762. if (state !== null) {
  45763. var dehydrated = state.dehydrated;
  45764. if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) {
  45765. return node;
  45766. }
  45767. }
  45768. } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't
  45769. // keep track of whether it suspended or not.
  45770. node.memoizedProps.revealOrder !== undefined) {
  45771. var didSuspend = (node.effectTag & DidCapture) !== NoEffect;
  45772. if (didSuspend) {
  45773. return node;
  45774. }
  45775. } else if (node.child !== null) {
  45776. node.child.return = node;
  45777. node = node.child;
  45778. continue;
  45779. }
  45780. if (node === row) {
  45781. return null;
  45782. }
  45783. while (node.sibling === null) {
  45784. if (node.return === null || node.return === row) {
  45785. return null;
  45786. }
  45787. node = node.return;
  45788. }
  45789. node.sibling.return = node.return;
  45790. node = node.sibling;
  45791. }
  45792. return null;
  45793. }
  45794. var emptyObject = {};
  45795. var isArray$2 = Array.isArray;
  45796. function createResponderInstance(responder, responderProps, responderState, fiber) {
  45797. return {
  45798. fiber: fiber,
  45799. props: responderProps,
  45800. responder: responder,
  45801. rootEventTypes: null,
  45802. state: responderState
  45803. };
  45804. }
  45805. function mountEventResponder$1(responder, responderProps, fiber, respondersMap, rootContainerInstance) {
  45806. var responderState = emptyObject;
  45807. var getInitialState = responder.getInitialState;
  45808. if (getInitialState !== null) {
  45809. responderState = getInitialState(responderProps);
  45810. }
  45811. var responderInstance = createResponderInstance(responder, responderProps, responderState, fiber);
  45812. if (!rootContainerInstance) {
  45813. var node = fiber;
  45814. while (node !== null) {
  45815. var tag = node.tag;
  45816. if (tag === HostComponent) {
  45817. rootContainerInstance = node.stateNode;
  45818. break;
  45819. } else if (tag === HostRoot) {
  45820. rootContainerInstance = node.stateNode.containerInfo;
  45821. break;
  45822. }
  45823. node = node.return;
  45824. }
  45825. }
  45826. mountResponderInstance(responder, responderInstance, responderProps, responderState, rootContainerInstance);
  45827. respondersMap.set(responder, responderInstance);
  45828. }
  45829. function updateEventListener(listener, fiber, visistedResponders, respondersMap, rootContainerInstance) {
  45830. var responder;
  45831. var props;
  45832. if (listener) {
  45833. responder = listener.responder;
  45834. props = listener.props;
  45835. }
  45836. (function () {
  45837. if (!(responder && responder.$$typeof === REACT_RESPONDER_TYPE)) {
  45838. {
  45839. throw ReactError(Error("An invalid value was used as an event listener. Expect one or many event listeners created via React.unstable_useResponder()."));
  45840. }
  45841. }
  45842. })();
  45843. var listenerProps = props;
  45844. if (visistedResponders.has(responder)) {
  45845. // show warning
  45846. {
  45847. warning$1(false, 'Duplicate event responder "%s" found in event listeners. ' + 'Event listeners passed to elements cannot use the same event responder more than once.', responder.displayName);
  45848. }
  45849. return;
  45850. }
  45851. visistedResponders.add(responder);
  45852. var responderInstance = respondersMap.get(responder);
  45853. if (responderInstance === undefined) {
  45854. // Mount (happens in either complete or commit phase)
  45855. mountEventResponder$1(responder, listenerProps, fiber, respondersMap, rootContainerInstance);
  45856. } else {
  45857. // Update (happens during commit phase only)
  45858. responderInstance.props = listenerProps;
  45859. responderInstance.fiber = fiber;
  45860. }
  45861. }
  45862. function updateEventListeners(listeners, fiber, rootContainerInstance) {
  45863. var visistedResponders = new Set();
  45864. var dependencies = fiber.dependencies;
  45865. if (listeners != null) {
  45866. if (dependencies === null) {
  45867. dependencies = fiber.dependencies = {
  45868. expirationTime: NoWork,
  45869. firstContext: null,
  45870. responders: new Map()
  45871. };
  45872. }
  45873. var respondersMap = dependencies.responders;
  45874. if (respondersMap === null) {
  45875. respondersMap = new Map();
  45876. }
  45877. if (isArray$2(listeners)) {
  45878. for (var i = 0, length = listeners.length; i < length; i++) {
  45879. var listener = listeners[i];
  45880. updateEventListener(listener, fiber, visistedResponders, respondersMap, rootContainerInstance);
  45881. }
  45882. } else {
  45883. updateEventListener(listeners, fiber, visistedResponders, respondersMap, rootContainerInstance);
  45884. }
  45885. }
  45886. if (dependencies !== null) {
  45887. var _respondersMap = dependencies.responders;
  45888. if (_respondersMap !== null) {
  45889. // Unmount
  45890. var mountedResponders = Array.from(_respondersMap.keys());
  45891. for (var _i = 0, _length = mountedResponders.length; _i < _length; _i++) {
  45892. var mountedResponder = mountedResponders[_i];
  45893. if (!visistedResponders.has(mountedResponder)) {
  45894. var responderInstance = _respondersMap.get(mountedResponder);
  45895. unmountResponderInstance(responderInstance);
  45896. _respondersMap.delete(mountedResponder);
  45897. }
  45898. }
  45899. }
  45900. }
  45901. }
  45902. function createResponderListener(responder, props) {
  45903. var eventResponderListener = {
  45904. responder: responder,
  45905. props: props
  45906. };
  45907. {
  45908. Object.freeze(eventResponderListener);
  45909. }
  45910. return eventResponderListener;
  45911. }
  45912. var NoEffect$1 =
  45913. /* */
  45914. 0;
  45915. var UnmountSnapshot =
  45916. /* */
  45917. 2;
  45918. var UnmountMutation =
  45919. /* */
  45920. 4;
  45921. var MountMutation =
  45922. /* */
  45923. 8;
  45924. var UnmountLayout =
  45925. /* */
  45926. 16;
  45927. var MountLayout =
  45928. /* */
  45929. 32;
  45930. var MountPassive =
  45931. /* */
  45932. 64;
  45933. var UnmountPassive =
  45934. /* */
  45935. 128;
  45936. var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
  45937. var didWarnAboutMismatchedHooksForComponent;
  45938. {
  45939. didWarnAboutMismatchedHooksForComponent = new Set();
  45940. }
  45941. // These are set right before calling the component.
  45942. var renderExpirationTime$1 = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from
  45943. // the work-in-progress hook.
  45944. var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The
  45945. // current hook list is the list that belongs to the current fiber. The
  45946. // work-in-progress hook list is a new list that will be added to the
  45947. // work-in-progress fiber.
  45948. var currentHook = null;
  45949. var nextCurrentHook = null;
  45950. var firstWorkInProgressHook = null;
  45951. var workInProgressHook = null;
  45952. var nextWorkInProgressHook = null;
  45953. var remainingExpirationTime = NoWork;
  45954. var componentUpdateQueue = null;
  45955. var sideEffectTag = 0; // Updates scheduled during render will trigger an immediate re-render at the
  45956. // end of the current pass. We can't store these updates on the normal queue,
  45957. // because if the work is aborted, they should be discarded. Because this is
  45958. // a relatively rare case, we also don't want to add an additional field to
  45959. // either the hook or queue object types. So we store them in a lazily create
  45960. // map of queue -> render-phase updates, which are discarded once the component
  45961. // completes without re-rendering.
  45962. // Whether an update was scheduled during the currently executing render pass.
  45963. var didScheduleRenderPhaseUpdate = false; // Lazily created map of render-phase updates
  45964. var renderPhaseUpdates = null; // Counter to prevent infinite loops.
  45965. var numberOfReRenders = 0;
  45966. var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook
  45967. var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders.
  45968. // The list stores the order of hooks used during the initial render (mount).
  45969. // Subsequent renders (updates) reference this list.
  45970. var hookTypesDev = null;
  45971. var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore
  45972. // the dependencies for Hooks that need them (e.g. useEffect or useMemo).
  45973. // When true, such Hooks will always be "remounted". Only used during hot reload.
  45974. var ignorePreviousDependencies = false;
  45975. function mountHookTypesDev() {
  45976. {
  45977. var hookName = currentHookNameInDev;
  45978. if (hookTypesDev === null) {
  45979. hookTypesDev = [hookName];
  45980. } else {
  45981. hookTypesDev.push(hookName);
  45982. }
  45983. }
  45984. }
  45985. function updateHookTypesDev() {
  45986. {
  45987. var hookName = currentHookNameInDev;
  45988. if (hookTypesDev !== null) {
  45989. hookTypesUpdateIndexDev++;
  45990. if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
  45991. warnOnHookMismatchInDev(hookName);
  45992. }
  45993. }
  45994. }
  45995. }
  45996. function checkDepsAreArrayDev(deps) {
  45997. {
  45998. if (deps !== undefined && deps !== null && !Array.isArray(deps)) {
  45999. // Verify deps, but only on mount to avoid extra checks.
  46000. // It's unlikely their type would change as usually you define them inline.
  46001. warning$1(false, '%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);
  46002. }
  46003. }
  46004. }
  46005. function warnOnHookMismatchInDev(currentHookName) {
  46006. {
  46007. var componentName = getComponentName(currentlyRenderingFiber$1.type);
  46008. if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
  46009. didWarnAboutMismatchedHooksForComponent.add(componentName);
  46010. if (hookTypesDev !== null) {
  46011. var table = '';
  46012. var secondColumnStart = 30;
  46013. for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
  46014. var oldHookName = hookTypesDev[i];
  46015. var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
  46016. var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up
  46017. // lol @ IE not supporting String#repeat
  46018. while (row.length < secondColumnStart) {
  46019. row += ' ';
  46020. }
  46021. row += newHookName + '\n';
  46022. table += row;
  46023. }
  46024. warning$1(false, '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);
  46025. }
  46026. }
  46027. }
  46028. }
  46029. function throwInvalidHookError() {
  46030. (function () {
  46031. {
  46032. {
  46033. throw ReactError(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."));
  46034. }
  46035. }
  46036. })();
  46037. }
  46038. function areHookInputsEqual(nextDeps, prevDeps) {
  46039. {
  46040. if (ignorePreviousDependencies) {
  46041. // Only true when this component is being hot reloaded.
  46042. return false;
  46043. }
  46044. }
  46045. if (prevDeps === null) {
  46046. {
  46047. warning$1(false, '%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);
  46048. }
  46049. return false;
  46050. }
  46051. {
  46052. // Don't bother comparing lengths in prod because these arrays should be
  46053. // passed inline.
  46054. if (nextDeps.length !== prevDeps.length) {
  46055. warning$1(false, '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(', ') + "]");
  46056. }
  46057. }
  46058. for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
  46059. if (is$1(nextDeps[i], prevDeps[i])) {
  46060. continue;
  46061. }
  46062. return false;
  46063. }
  46064. return true;
  46065. }
  46066. function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
  46067. renderExpirationTime$1 = nextRenderExpirationTime;
  46068. currentlyRenderingFiber$1 = workInProgress;
  46069. nextCurrentHook = current !== null ? current.memoizedState : null;
  46070. {
  46071. hookTypesDev = current !== null ? current._debugHookTypes : null;
  46072. hookTypesUpdateIndexDev = -1; // Used for hot reloading:
  46073. ignorePreviousDependencies = current !== null && current.type !== workInProgress.type;
  46074. } // The following should have already been reset
  46075. // currentHook = null;
  46076. // workInProgressHook = null;
  46077. // remainingExpirationTime = NoWork;
  46078. // componentUpdateQueue = null;
  46079. // didScheduleRenderPhaseUpdate = false;
  46080. // renderPhaseUpdates = null;
  46081. // numberOfReRenders = 0;
  46082. // sideEffectTag = 0;
  46083. // TODO Warn if no hooks are used at all during mount, then some are used during update.
  46084. // Currently we will identify the update render as a mount because nextCurrentHook === null.
  46085. // This is tricky because it's valid for certain types of components (e.g. React.lazy)
  46086. // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
  46087. // Non-stateful hooks (e.g. context) don't get added to memoizedState,
  46088. // so nextCurrentHook would be null during updates and mounts.
  46089. {
  46090. if (nextCurrentHook !== null) {
  46091. ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
  46092. } else if (hookTypesDev !== null) {
  46093. // This dispatcher handles an edge case where a component is updating,
  46094. // but no stateful hooks have been used.
  46095. // We want to match the production code behavior (which will use HooksDispatcherOnMount),
  46096. // but with the extra DEV validation to ensure hooks ordering hasn't changed.
  46097. // This dispatcher does that.
  46098. ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
  46099. } else {
  46100. ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
  46101. }
  46102. }
  46103. var children = Component(props, refOrContext);
  46104. if (didScheduleRenderPhaseUpdate) {
  46105. do {
  46106. didScheduleRenderPhaseUpdate = false;
  46107. numberOfReRenders += 1;
  46108. {
  46109. // Even when hot reloading, allow dependencies to stabilize
  46110. // after first render to prevent infinite render phase updates.
  46111. ignorePreviousDependencies = false;
  46112. } // Start over from the beginning of the list
  46113. nextCurrentHook = current !== null ? current.memoizedState : null;
  46114. nextWorkInProgressHook = firstWorkInProgressHook;
  46115. currentHook = null;
  46116. workInProgressHook = null;
  46117. componentUpdateQueue = null;
  46118. {
  46119. // Also validate hook order for cascading updates.
  46120. hookTypesUpdateIndexDev = -1;
  46121. }
  46122. ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
  46123. children = Component(props, refOrContext);
  46124. } while (didScheduleRenderPhaseUpdate);
  46125. renderPhaseUpdates = null;
  46126. numberOfReRenders = 0;
  46127. } // We can assume the previous dispatcher is always this one, since we set it
  46128. // at the beginning of the render phase and there's no re-entrancy.
  46129. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
  46130. var renderedWork = currentlyRenderingFiber$1;
  46131. renderedWork.memoizedState = firstWorkInProgressHook;
  46132. renderedWork.expirationTime = remainingExpirationTime;
  46133. renderedWork.updateQueue = componentUpdateQueue;
  46134. renderedWork.effectTag |= sideEffectTag;
  46135. {
  46136. renderedWork._debugHookTypes = hookTypesDev;
  46137. } // This check uses currentHook so that it works the same in DEV and prod bundles.
  46138. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
  46139. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
  46140. renderExpirationTime$1 = NoWork;
  46141. currentlyRenderingFiber$1 = null;
  46142. currentHook = null;
  46143. nextCurrentHook = null;
  46144. firstWorkInProgressHook = null;
  46145. workInProgressHook = null;
  46146. nextWorkInProgressHook = null;
  46147. {
  46148. currentHookNameInDev = null;
  46149. hookTypesDev = null;
  46150. hookTypesUpdateIndexDev = -1;
  46151. }
  46152. remainingExpirationTime = NoWork;
  46153. componentUpdateQueue = null;
  46154. sideEffectTag = 0; // These were reset above
  46155. // didScheduleRenderPhaseUpdate = false;
  46156. // renderPhaseUpdates = null;
  46157. // numberOfReRenders = 0;
  46158. (function () {
  46159. if (!!didRenderTooFewHooks) {
  46160. {
  46161. throw ReactError(Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement."));
  46162. }
  46163. }
  46164. })();
  46165. return children;
  46166. }
  46167. function bailoutHooks(current, workInProgress, expirationTime) {
  46168. workInProgress.updateQueue = current.updateQueue;
  46169. workInProgress.effectTag &= ~(Passive | Update);
  46170. if (current.expirationTime <= expirationTime) {
  46171. current.expirationTime = NoWork;
  46172. }
  46173. }
  46174. function resetHooks() {
  46175. // We can assume the previous dispatcher is always this one, since we set it
  46176. // at the beginning of the render phase and there's no re-entrancy.
  46177. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; // This is used to reset the state of this module when a component throws.
  46178. // It's also called inside mountIndeterminateComponent if we determine the
  46179. // component is a module-style component.
  46180. renderExpirationTime$1 = NoWork;
  46181. currentlyRenderingFiber$1 = null;
  46182. currentHook = null;
  46183. nextCurrentHook = null;
  46184. firstWorkInProgressHook = null;
  46185. workInProgressHook = null;
  46186. nextWorkInProgressHook = null;
  46187. {
  46188. hookTypesDev = null;
  46189. hookTypesUpdateIndexDev = -1;
  46190. currentHookNameInDev = null;
  46191. }
  46192. remainingExpirationTime = NoWork;
  46193. componentUpdateQueue = null;
  46194. sideEffectTag = 0;
  46195. didScheduleRenderPhaseUpdate = false;
  46196. renderPhaseUpdates = null;
  46197. numberOfReRenders = 0;
  46198. }
  46199. function mountWorkInProgressHook() {
  46200. var hook = {
  46201. memoizedState: null,
  46202. baseState: null,
  46203. queue: null,
  46204. baseUpdate: null,
  46205. next: null
  46206. };
  46207. if (workInProgressHook === null) {
  46208. // This is the first hook in the list
  46209. firstWorkInProgressHook = workInProgressHook = hook;
  46210. } else {
  46211. // Append to the end of the list
  46212. workInProgressHook = workInProgressHook.next = hook;
  46213. }
  46214. return workInProgressHook;
  46215. }
  46216. function updateWorkInProgressHook() {
  46217. // This function is used both for updates and for re-renders triggered by a
  46218. // render phase update. It assumes there is either a current hook we can
  46219. // clone, or a work-in-progress hook from a previous render pass that we can
  46220. // use as a base. When we reach the end of the base list, we must switch to
  46221. // the dispatcher used for mounts.
  46222. if (nextWorkInProgressHook !== null) {
  46223. // There's already a work-in-progress. Reuse it.
  46224. workInProgressHook = nextWorkInProgressHook;
  46225. nextWorkInProgressHook = workInProgressHook.next;
  46226. currentHook = nextCurrentHook;
  46227. nextCurrentHook = currentHook !== null ? currentHook.next : null;
  46228. } else {
  46229. // Clone from the current hook.
  46230. (function () {
  46231. if (!(nextCurrentHook !== null)) {
  46232. {
  46233. throw ReactError(Error("Rendered more hooks than during the previous render."));
  46234. }
  46235. }
  46236. })();
  46237. currentHook = nextCurrentHook;
  46238. var newHook = {
  46239. memoizedState: currentHook.memoizedState,
  46240. baseState: currentHook.baseState,
  46241. queue: currentHook.queue,
  46242. baseUpdate: currentHook.baseUpdate,
  46243. next: null
  46244. };
  46245. if (workInProgressHook === null) {
  46246. // This is the first hook in the list.
  46247. workInProgressHook = firstWorkInProgressHook = newHook;
  46248. } else {
  46249. // Append to the end of the list.
  46250. workInProgressHook = workInProgressHook.next = newHook;
  46251. }
  46252. nextCurrentHook = currentHook.next;
  46253. }
  46254. return workInProgressHook;
  46255. }
  46256. function createFunctionComponentUpdateQueue() {
  46257. return {
  46258. lastEffect: null
  46259. };
  46260. }
  46261. function basicStateReducer(state, action) {
  46262. return typeof action === 'function' ? action(state) : action;
  46263. }
  46264. function mountReducer(reducer, initialArg, init) {
  46265. var hook = mountWorkInProgressHook();
  46266. var initialState;
  46267. if (init !== undefined) {
  46268. initialState = init(initialArg);
  46269. } else {
  46270. initialState = initialArg;
  46271. }
  46272. hook.memoizedState = hook.baseState = initialState;
  46273. var queue = hook.queue = {
  46274. last: null,
  46275. dispatch: null,
  46276. lastRenderedReducer: reducer,
  46277. lastRenderedState: initialState
  46278. };
  46279. var dispatch = queue.dispatch = dispatchAction.bind(null, // Flow doesn't know this is non-null, but we do.
  46280. currentlyRenderingFiber$1, queue);
  46281. return [hook.memoizedState, dispatch];
  46282. }
  46283. function updateReducer(reducer, initialArg, init) {
  46284. var hook = updateWorkInProgressHook();
  46285. var queue = hook.queue;
  46286. (function () {
  46287. if (!(queue !== null)) {
  46288. {
  46289. throw ReactError(Error("Should have a queue. This is likely a bug in React. Please file an issue."));
  46290. }
  46291. }
  46292. })();
  46293. queue.lastRenderedReducer = reducer;
  46294. if (numberOfReRenders > 0) {
  46295. // This is a re-render. Apply the new render phase updates to the previous
  46296. // work-in-progress hook.
  46297. var _dispatch = queue.dispatch;
  46298. if (renderPhaseUpdates !== null) {
  46299. // Render phase updates are stored in a map of queue -> linked list
  46300. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  46301. if (firstRenderPhaseUpdate !== undefined) {
  46302. renderPhaseUpdates.delete(queue);
  46303. var newState = hook.memoizedState;
  46304. var update = firstRenderPhaseUpdate;
  46305. do {
  46306. // Process this render phase update. We don't have to check the
  46307. // priority because it will always be the same as the current
  46308. // render's.
  46309. var action = update.action;
  46310. newState = reducer(newState, action);
  46311. update = update.next;
  46312. } while (update !== null); // Mark that the fiber performed work, but only if the new state is
  46313. // different from the current state.
  46314. if (!is$1(newState, hook.memoizedState)) {
  46315. markWorkInProgressReceivedUpdate();
  46316. }
  46317. hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to
  46318. // the base state unless the queue is empty.
  46319. // TODO: Not sure if this is the desired semantics, but it's what we
  46320. // do for gDSFP. I can't remember why.
  46321. if (hook.baseUpdate === queue.last) {
  46322. hook.baseState = newState;
  46323. }
  46324. queue.lastRenderedState = newState;
  46325. return [newState, _dispatch];
  46326. }
  46327. }
  46328. return [hook.memoizedState, _dispatch];
  46329. } // The last update in the entire queue
  46330. var last = queue.last; // The last update that is part of the base state.
  46331. var baseUpdate = hook.baseUpdate;
  46332. var baseState = hook.baseState; // Find the first unprocessed update.
  46333. var first;
  46334. if (baseUpdate !== null) {
  46335. if (last !== null) {
  46336. // For the first update, the queue is a circular linked list where
  46337. // `queue.last.next = queue.first`. Once the first update commits, and
  46338. // the `baseUpdate` is no longer empty, we can unravel the list.
  46339. last.next = null;
  46340. }
  46341. first = baseUpdate.next;
  46342. } else {
  46343. first = last !== null ? last.next : null;
  46344. }
  46345. if (first !== null) {
  46346. var _newState = baseState;
  46347. var newBaseState = null;
  46348. var newBaseUpdate = null;
  46349. var prevUpdate = baseUpdate;
  46350. var _update = first;
  46351. var didSkip = false;
  46352. do {
  46353. var updateExpirationTime = _update.expirationTime;
  46354. if (updateExpirationTime < renderExpirationTime$1) {
  46355. // Priority is insufficient. Skip this update. If this is the first
  46356. // skipped update, the previous update/state is the new base
  46357. // update/state.
  46358. if (!didSkip) {
  46359. didSkip = true;
  46360. newBaseUpdate = prevUpdate;
  46361. newBaseState = _newState;
  46362. } // Update the remaining priority in the queue.
  46363. if (updateExpirationTime > remainingExpirationTime) {
  46364. remainingExpirationTime = updateExpirationTime;
  46365. markUnprocessedUpdateTime(remainingExpirationTime);
  46366. }
  46367. } else {
  46368. // This update does have sufficient priority.
  46369. // Mark the event time of this update as relevant to this render pass.
  46370. // TODO: This should ideally use the true event time of this update rather than
  46371. // its priority which is a derived and not reverseable value.
  46372. // TODO: We should skip this update if it was already committed but currently
  46373. // we have no way of detecting the difference between a committed and suspended
  46374. // update here.
  46375. markRenderEventTimeAndConfig(updateExpirationTime, _update.suspenseConfig); // Process this update.
  46376. if (_update.eagerReducer === reducer) {
  46377. // If this update was processed eagerly, and its reducer matches the
  46378. // current reducer, we can use the eagerly computed state.
  46379. _newState = _update.eagerState;
  46380. } else {
  46381. var _action = _update.action;
  46382. _newState = reducer(_newState, _action);
  46383. }
  46384. }
  46385. prevUpdate = _update;
  46386. _update = _update.next;
  46387. } while (_update !== null && _update !== first);
  46388. if (!didSkip) {
  46389. newBaseUpdate = prevUpdate;
  46390. newBaseState = _newState;
  46391. } // Mark that the fiber performed work, but only if the new state is
  46392. // different from the current state.
  46393. if (!is$1(_newState, hook.memoizedState)) {
  46394. markWorkInProgressReceivedUpdate();
  46395. }
  46396. hook.memoizedState = _newState;
  46397. hook.baseUpdate = newBaseUpdate;
  46398. hook.baseState = newBaseState;
  46399. queue.lastRenderedState = _newState;
  46400. }
  46401. var dispatch = queue.dispatch;
  46402. return [hook.memoizedState, dispatch];
  46403. }
  46404. function mountState(initialState) {
  46405. var hook = mountWorkInProgressHook();
  46406. if (typeof initialState === 'function') {
  46407. initialState = initialState();
  46408. }
  46409. hook.memoizedState = hook.baseState = initialState;
  46410. var queue = hook.queue = {
  46411. last: null,
  46412. dispatch: null,
  46413. lastRenderedReducer: basicStateReducer,
  46414. lastRenderedState: initialState
  46415. };
  46416. var dispatch = queue.dispatch = dispatchAction.bind(null, // Flow doesn't know this is non-null, but we do.
  46417. currentlyRenderingFiber$1, queue);
  46418. return [hook.memoizedState, dispatch];
  46419. }
  46420. function updateState(initialState) {
  46421. return updateReducer(basicStateReducer, initialState);
  46422. }
  46423. function pushEffect(tag, create, destroy, deps) {
  46424. var effect = {
  46425. tag: tag,
  46426. create: create,
  46427. destroy: destroy,
  46428. deps: deps,
  46429. // Circular
  46430. next: null
  46431. };
  46432. if (componentUpdateQueue === null) {
  46433. componentUpdateQueue = createFunctionComponentUpdateQueue();
  46434. componentUpdateQueue.lastEffect = effect.next = effect;
  46435. } else {
  46436. var lastEffect = componentUpdateQueue.lastEffect;
  46437. if (lastEffect === null) {
  46438. componentUpdateQueue.lastEffect = effect.next = effect;
  46439. } else {
  46440. var firstEffect = lastEffect.next;
  46441. lastEffect.next = effect;
  46442. effect.next = firstEffect;
  46443. componentUpdateQueue.lastEffect = effect;
  46444. }
  46445. }
  46446. return effect;
  46447. }
  46448. function mountRef(initialValue) {
  46449. var hook = mountWorkInProgressHook();
  46450. var ref = {
  46451. current: initialValue
  46452. };
  46453. {
  46454. Object.seal(ref);
  46455. }
  46456. hook.memoizedState = ref;
  46457. return ref;
  46458. }
  46459. function updateRef(initialValue) {
  46460. var hook = updateWorkInProgressHook();
  46461. return hook.memoizedState;
  46462. }
  46463. function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
  46464. var hook = mountWorkInProgressHook();
  46465. var nextDeps = deps === undefined ? null : deps;
  46466. sideEffectTag |= fiberEffectTag;
  46467. hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps);
  46468. }
  46469. function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
  46470. var hook = updateWorkInProgressHook();
  46471. var nextDeps = deps === undefined ? null : deps;
  46472. var destroy = undefined;
  46473. if (currentHook !== null) {
  46474. var prevEffect = currentHook.memoizedState;
  46475. destroy = prevEffect.destroy;
  46476. if (nextDeps !== null) {
  46477. var prevDeps = prevEffect.deps;
  46478. if (areHookInputsEqual(nextDeps, prevDeps)) {
  46479. pushEffect(NoEffect$1, create, destroy, nextDeps);
  46480. return;
  46481. }
  46482. }
  46483. }
  46484. sideEffectTag |= fiberEffectTag;
  46485. hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps);
  46486. }
  46487. function mountEffect(create, deps) {
  46488. {
  46489. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  46490. if ('undefined' !== typeof jest) {
  46491. warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
  46492. }
  46493. }
  46494. return mountEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
  46495. }
  46496. function updateEffect(create, deps) {
  46497. {
  46498. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  46499. if ('undefined' !== typeof jest) {
  46500. warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
  46501. }
  46502. }
  46503. return updateEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
  46504. }
  46505. function mountLayoutEffect(create, deps) {
  46506. return mountEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
  46507. }
  46508. function updateLayoutEffect(create, deps) {
  46509. return updateEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
  46510. }
  46511. function imperativeHandleEffect(create, ref) {
  46512. if (typeof ref === 'function') {
  46513. var refCallback = ref;
  46514. var _inst = create();
  46515. refCallback(_inst);
  46516. return function () {
  46517. refCallback(null);
  46518. };
  46519. } else if (ref !== null && ref !== undefined) {
  46520. var refObject = ref;
  46521. {
  46522. !refObject.hasOwnProperty('current') ? warning$1(false, '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(', ') + '}') : void 0;
  46523. }
  46524. var _inst2 = create();
  46525. refObject.current = _inst2;
  46526. return function () {
  46527. refObject.current = null;
  46528. };
  46529. }
  46530. }
  46531. function mountImperativeHandle(ref, create, deps) {
  46532. {
  46533. !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
  46534. } // TODO: If deps are provided, should we skip comparing the ref itself?
  46535. var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
  46536. return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
  46537. }
  46538. function updateImperativeHandle(ref, create, deps) {
  46539. {
  46540. !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
  46541. } // TODO: If deps are provided, should we skip comparing the ref itself?
  46542. var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
  46543. return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
  46544. }
  46545. function mountDebugValue(value, formatterFn) {// This hook is normally a no-op.
  46546. // The react-debug-hooks package injects its own implementation
  46547. // so that e.g. DevTools can display custom hook values.
  46548. }
  46549. var updateDebugValue = mountDebugValue;
  46550. function mountCallback(callback, deps) {
  46551. var hook = mountWorkInProgressHook();
  46552. var nextDeps = deps === undefined ? null : deps;
  46553. hook.memoizedState = [callback, nextDeps];
  46554. return callback;
  46555. }
  46556. function updateCallback(callback, deps) {
  46557. var hook = updateWorkInProgressHook();
  46558. var nextDeps = deps === undefined ? null : deps;
  46559. var prevState = hook.memoizedState;
  46560. if (prevState !== null) {
  46561. if (nextDeps !== null) {
  46562. var prevDeps = prevState[1];
  46563. if (areHookInputsEqual(nextDeps, prevDeps)) {
  46564. return prevState[0];
  46565. }
  46566. }
  46567. }
  46568. hook.memoizedState = [callback, nextDeps];
  46569. return callback;
  46570. }
  46571. function mountMemo(nextCreate, deps) {
  46572. var hook = mountWorkInProgressHook();
  46573. var nextDeps = deps === undefined ? null : deps;
  46574. var nextValue = nextCreate();
  46575. hook.memoizedState = [nextValue, nextDeps];
  46576. return nextValue;
  46577. }
  46578. function updateMemo(nextCreate, deps) {
  46579. var hook = updateWorkInProgressHook();
  46580. var nextDeps = deps === undefined ? null : deps;
  46581. var prevState = hook.memoizedState;
  46582. if (prevState !== null) {
  46583. // Assume these are defined. If they're not, areHookInputsEqual will warn.
  46584. if (nextDeps !== null) {
  46585. var prevDeps = prevState[1];
  46586. if (areHookInputsEqual(nextDeps, prevDeps)) {
  46587. return prevState[0];
  46588. }
  46589. }
  46590. }
  46591. var nextValue = nextCreate();
  46592. hook.memoizedState = [nextValue, nextDeps];
  46593. return nextValue;
  46594. }
  46595. function dispatchAction(fiber, queue, action) {
  46596. (function () {
  46597. if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
  46598. {
  46599. throw ReactError(Error("Too many re-renders. React limits the number of renders to prevent an infinite loop."));
  46600. }
  46601. }
  46602. })();
  46603. {
  46604. !(typeof arguments[3] !== 'function') ? warning$1(false, "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().') : void 0;
  46605. }
  46606. var alternate = fiber.alternate;
  46607. if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
  46608. // This is a render phase update. Stash it in a lazily-created map of
  46609. // queue -> linked list of updates. After this render pass, we'll restart
  46610. // and apply the stashed updates on top of the work-in-progress hook.
  46611. didScheduleRenderPhaseUpdate = true;
  46612. var update = {
  46613. expirationTime: renderExpirationTime$1,
  46614. suspenseConfig: null,
  46615. action: action,
  46616. eagerReducer: null,
  46617. eagerState: null,
  46618. next: null
  46619. };
  46620. {
  46621. update.priority = getCurrentPriorityLevel();
  46622. }
  46623. if (renderPhaseUpdates === null) {
  46624. renderPhaseUpdates = new Map();
  46625. }
  46626. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  46627. if (firstRenderPhaseUpdate === undefined) {
  46628. renderPhaseUpdates.set(queue, update);
  46629. } else {
  46630. // Append the update to the end of the list.
  46631. var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
  46632. while (lastRenderPhaseUpdate.next !== null) {
  46633. lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
  46634. }
  46635. lastRenderPhaseUpdate.next = update;
  46636. }
  46637. } else {
  46638. var currentTime = requestCurrentTime();
  46639. var suspenseConfig = requestCurrentSuspenseConfig();
  46640. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  46641. var _update2 = {
  46642. expirationTime: expirationTime,
  46643. suspenseConfig: suspenseConfig,
  46644. action: action,
  46645. eagerReducer: null,
  46646. eagerState: null,
  46647. next: null
  46648. };
  46649. {
  46650. _update2.priority = getCurrentPriorityLevel();
  46651. } // Append the update to the end of the list.
  46652. var last = queue.last;
  46653. if (last === null) {
  46654. // This is the first update. Create a circular list.
  46655. _update2.next = _update2;
  46656. } else {
  46657. var first = last.next;
  46658. if (first !== null) {
  46659. // Still circular.
  46660. _update2.next = first;
  46661. }
  46662. last.next = _update2;
  46663. }
  46664. queue.last = _update2;
  46665. if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) {
  46666. // The queue is currently empty, which means we can eagerly compute the
  46667. // next state before entering the render phase. If the new state is the
  46668. // same as the current state, we may be able to bail out entirely.
  46669. var lastRenderedReducer = queue.lastRenderedReducer;
  46670. if (lastRenderedReducer !== null) {
  46671. var prevDispatcher;
  46672. {
  46673. prevDispatcher = ReactCurrentDispatcher$1.current;
  46674. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  46675. }
  46676. try {
  46677. var currentState = queue.lastRenderedState;
  46678. var eagerState = lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute
  46679. // it, on the update object. If the reducer hasn't changed by the
  46680. // time we enter the render phase, then the eager state can be used
  46681. // without calling the reducer again.
  46682. _update2.eagerReducer = lastRenderedReducer;
  46683. _update2.eagerState = eagerState;
  46684. if (is$1(eagerState, currentState)) {
  46685. // Fast path. We can bail out without scheduling React to re-render.
  46686. // It's still possible that we'll need to rebase this update later,
  46687. // if the component re-renders for a different reason and by that
  46688. // time the reducer has changed.
  46689. return;
  46690. }
  46691. } catch (error) {// Suppress the error. It will throw again in the render phase.
  46692. } finally {
  46693. {
  46694. ReactCurrentDispatcher$1.current = prevDispatcher;
  46695. }
  46696. }
  46697. }
  46698. }
  46699. {
  46700. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  46701. if ('undefined' !== typeof jest) {
  46702. warnIfNotScopedWithMatchingAct(fiber);
  46703. warnIfNotCurrentlyActingUpdatesInDev(fiber);
  46704. }
  46705. }
  46706. scheduleWork(fiber, expirationTime);
  46707. }
  46708. }
  46709. var ContextOnlyDispatcher = {
  46710. readContext: readContext,
  46711. useCallback: throwInvalidHookError,
  46712. useContext: throwInvalidHookError,
  46713. useEffect: throwInvalidHookError,
  46714. useImperativeHandle: throwInvalidHookError,
  46715. useLayoutEffect: throwInvalidHookError,
  46716. useMemo: throwInvalidHookError,
  46717. useReducer: throwInvalidHookError,
  46718. useRef: throwInvalidHookError,
  46719. useState: throwInvalidHookError,
  46720. useDebugValue: throwInvalidHookError,
  46721. useResponder: throwInvalidHookError
  46722. };
  46723. var HooksDispatcherOnMountInDEV = null;
  46724. var HooksDispatcherOnMountWithHookTypesInDEV = null;
  46725. var HooksDispatcherOnUpdateInDEV = null;
  46726. var InvalidNestedHooksDispatcherOnMountInDEV = null;
  46727. var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
  46728. {
  46729. var warnInvalidContextAccess = function () {
  46730. warning$1(false, '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().');
  46731. };
  46732. var warnInvalidHookAccess = function () {
  46733. warning$1(false, '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');
  46734. };
  46735. HooksDispatcherOnMountInDEV = {
  46736. readContext: function (context, observedBits) {
  46737. return readContext(context, observedBits);
  46738. },
  46739. useCallback: function (callback, deps) {
  46740. currentHookNameInDev = 'useCallback';
  46741. mountHookTypesDev();
  46742. checkDepsAreArrayDev(deps);
  46743. return mountCallback(callback, deps);
  46744. },
  46745. useContext: function (context, observedBits) {
  46746. currentHookNameInDev = 'useContext';
  46747. mountHookTypesDev();
  46748. return readContext(context, observedBits);
  46749. },
  46750. useEffect: function (create, deps) {
  46751. currentHookNameInDev = 'useEffect';
  46752. mountHookTypesDev();
  46753. checkDepsAreArrayDev(deps);
  46754. return mountEffect(create, deps);
  46755. },
  46756. useImperativeHandle: function (ref, create, deps) {
  46757. currentHookNameInDev = 'useImperativeHandle';
  46758. mountHookTypesDev();
  46759. checkDepsAreArrayDev(deps);
  46760. return mountImperativeHandle(ref, create, deps);
  46761. },
  46762. useLayoutEffect: function (create, deps) {
  46763. currentHookNameInDev = 'useLayoutEffect';
  46764. mountHookTypesDev();
  46765. checkDepsAreArrayDev(deps);
  46766. return mountLayoutEffect(create, deps);
  46767. },
  46768. useMemo: function (create, deps) {
  46769. currentHookNameInDev = 'useMemo';
  46770. mountHookTypesDev();
  46771. checkDepsAreArrayDev(deps);
  46772. var prevDispatcher = ReactCurrentDispatcher$1.current;
  46773. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  46774. try {
  46775. return mountMemo(create, deps);
  46776. } finally {
  46777. ReactCurrentDispatcher$1.current = prevDispatcher;
  46778. }
  46779. },
  46780. useReducer: function (reducer, initialArg, init) {
  46781. currentHookNameInDev = 'useReducer';
  46782. mountHookTypesDev();
  46783. var prevDispatcher = ReactCurrentDispatcher$1.current;
  46784. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  46785. try {
  46786. return mountReducer(reducer, initialArg, init);
  46787. } finally {
  46788. ReactCurrentDispatcher$1.current = prevDispatcher;
  46789. }
  46790. },
  46791. useRef: function (initialValue) {
  46792. currentHookNameInDev = 'useRef';
  46793. mountHookTypesDev();
  46794. return mountRef(initialValue);
  46795. },
  46796. useState: function (initialState) {
  46797. currentHookNameInDev = 'useState';
  46798. mountHookTypesDev();
  46799. var prevDispatcher = ReactCurrentDispatcher$1.current;
  46800. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  46801. try {
  46802. return mountState(initialState);
  46803. } finally {
  46804. ReactCurrentDispatcher$1.current = prevDispatcher;
  46805. }
  46806. },
  46807. useDebugValue: function (value, formatterFn) {
  46808. currentHookNameInDev = 'useDebugValue';
  46809. mountHookTypesDev();
  46810. return mountDebugValue(value, formatterFn);
  46811. },
  46812. useResponder: function (responder, props) {
  46813. currentHookNameInDev = 'useResponder';
  46814. mountHookTypesDev();
  46815. return createResponderListener(responder, props);
  46816. }
  46817. };
  46818. HooksDispatcherOnMountWithHookTypesInDEV = {
  46819. readContext: function (context, observedBits) {
  46820. return readContext(context, observedBits);
  46821. },
  46822. useCallback: function (callback, deps) {
  46823. currentHookNameInDev = 'useCallback';
  46824. updateHookTypesDev();
  46825. return mountCallback(callback, deps);
  46826. },
  46827. useContext: function (context, observedBits) {
  46828. currentHookNameInDev = 'useContext';
  46829. updateHookTypesDev();
  46830. return readContext(context, observedBits);
  46831. },
  46832. useEffect: function (create, deps) {
  46833. currentHookNameInDev = 'useEffect';
  46834. updateHookTypesDev();
  46835. return mountEffect(create, deps);
  46836. },
  46837. useImperativeHandle: function (ref, create, deps) {
  46838. currentHookNameInDev = 'useImperativeHandle';
  46839. updateHookTypesDev();
  46840. return mountImperativeHandle(ref, create, deps);
  46841. },
  46842. useLayoutEffect: function (create, deps) {
  46843. currentHookNameInDev = 'useLayoutEffect';
  46844. updateHookTypesDev();
  46845. return mountLayoutEffect(create, deps);
  46846. },
  46847. useMemo: function (create, deps) {
  46848. currentHookNameInDev = 'useMemo';
  46849. updateHookTypesDev();
  46850. var prevDispatcher = ReactCurrentDispatcher$1.current;
  46851. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  46852. try {
  46853. return mountMemo(create, deps);
  46854. } finally {
  46855. ReactCurrentDispatcher$1.current = prevDispatcher;
  46856. }
  46857. },
  46858. useReducer: function (reducer, initialArg, init) {
  46859. currentHookNameInDev = 'useReducer';
  46860. updateHookTypesDev();
  46861. var prevDispatcher = ReactCurrentDispatcher$1.current;
  46862. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  46863. try {
  46864. return mountReducer(reducer, initialArg, init);
  46865. } finally {
  46866. ReactCurrentDispatcher$1.current = prevDispatcher;
  46867. }
  46868. },
  46869. useRef: function (initialValue) {
  46870. currentHookNameInDev = 'useRef';
  46871. updateHookTypesDev();
  46872. return mountRef(initialValue);
  46873. },
  46874. useState: function (initialState) {
  46875. currentHookNameInDev = 'useState';
  46876. updateHookTypesDev();
  46877. var prevDispatcher = ReactCurrentDispatcher$1.current;
  46878. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  46879. try {
  46880. return mountState(initialState);
  46881. } finally {
  46882. ReactCurrentDispatcher$1.current = prevDispatcher;
  46883. }
  46884. },
  46885. useDebugValue: function (value, formatterFn) {
  46886. currentHookNameInDev = 'useDebugValue';
  46887. updateHookTypesDev();
  46888. return mountDebugValue(value, formatterFn);
  46889. },
  46890. useResponder: function (responder, props) {
  46891. currentHookNameInDev = 'useResponder';
  46892. updateHookTypesDev();
  46893. return createResponderListener(responder, props);
  46894. }
  46895. };
  46896. HooksDispatcherOnUpdateInDEV = {
  46897. readContext: function (context, observedBits) {
  46898. return readContext(context, observedBits);
  46899. },
  46900. useCallback: function (callback, deps) {
  46901. currentHookNameInDev = 'useCallback';
  46902. updateHookTypesDev();
  46903. return updateCallback(callback, deps);
  46904. },
  46905. useContext: function (context, observedBits) {
  46906. currentHookNameInDev = 'useContext';
  46907. updateHookTypesDev();
  46908. return readContext(context, observedBits);
  46909. },
  46910. useEffect: function (create, deps) {
  46911. currentHookNameInDev = 'useEffect';
  46912. updateHookTypesDev();
  46913. return updateEffect(create, deps);
  46914. },
  46915. useImperativeHandle: function (ref, create, deps) {
  46916. currentHookNameInDev = 'useImperativeHandle';
  46917. updateHookTypesDev();
  46918. return updateImperativeHandle(ref, create, deps);
  46919. },
  46920. useLayoutEffect: function (create, deps) {
  46921. currentHookNameInDev = 'useLayoutEffect';
  46922. updateHookTypesDev();
  46923. return updateLayoutEffect(create, deps);
  46924. },
  46925. useMemo: function (create, deps) {
  46926. currentHookNameInDev = 'useMemo';
  46927. updateHookTypesDev();
  46928. var prevDispatcher = ReactCurrentDispatcher$1.current;
  46929. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  46930. try {
  46931. return updateMemo(create, deps);
  46932. } finally {
  46933. ReactCurrentDispatcher$1.current = prevDispatcher;
  46934. }
  46935. },
  46936. useReducer: function (reducer, initialArg, init) {
  46937. currentHookNameInDev = 'useReducer';
  46938. updateHookTypesDev();
  46939. var prevDispatcher = ReactCurrentDispatcher$1.current;
  46940. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  46941. try {
  46942. return updateReducer(reducer, initialArg, init);
  46943. } finally {
  46944. ReactCurrentDispatcher$1.current = prevDispatcher;
  46945. }
  46946. },
  46947. useRef: function (initialValue) {
  46948. currentHookNameInDev = 'useRef';
  46949. updateHookTypesDev();
  46950. return updateRef(initialValue);
  46951. },
  46952. useState: function (initialState) {
  46953. currentHookNameInDev = 'useState';
  46954. updateHookTypesDev();
  46955. var prevDispatcher = ReactCurrentDispatcher$1.current;
  46956. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  46957. try {
  46958. return updateState(initialState);
  46959. } finally {
  46960. ReactCurrentDispatcher$1.current = prevDispatcher;
  46961. }
  46962. },
  46963. useDebugValue: function (value, formatterFn) {
  46964. currentHookNameInDev = 'useDebugValue';
  46965. updateHookTypesDev();
  46966. return updateDebugValue(value, formatterFn);
  46967. },
  46968. useResponder: function (responder, props) {
  46969. currentHookNameInDev = 'useResponder';
  46970. updateHookTypesDev();
  46971. return createResponderListener(responder, props);
  46972. }
  46973. };
  46974. InvalidNestedHooksDispatcherOnMountInDEV = {
  46975. readContext: function (context, observedBits) {
  46976. warnInvalidContextAccess();
  46977. return readContext(context, observedBits);
  46978. },
  46979. useCallback: function (callback, deps) {
  46980. currentHookNameInDev = 'useCallback';
  46981. warnInvalidHookAccess();
  46982. mountHookTypesDev();
  46983. return mountCallback(callback, deps);
  46984. },
  46985. useContext: function (context, observedBits) {
  46986. currentHookNameInDev = 'useContext';
  46987. warnInvalidHookAccess();
  46988. mountHookTypesDev();
  46989. return readContext(context, observedBits);
  46990. },
  46991. useEffect: function (create, deps) {
  46992. currentHookNameInDev = 'useEffect';
  46993. warnInvalidHookAccess();
  46994. mountHookTypesDev();
  46995. return mountEffect(create, deps);
  46996. },
  46997. useImperativeHandle: function (ref, create, deps) {
  46998. currentHookNameInDev = 'useImperativeHandle';
  46999. warnInvalidHookAccess();
  47000. mountHookTypesDev();
  47001. return mountImperativeHandle(ref, create, deps);
  47002. },
  47003. useLayoutEffect: function (create, deps) {
  47004. currentHookNameInDev = 'useLayoutEffect';
  47005. warnInvalidHookAccess();
  47006. mountHookTypesDev();
  47007. return mountLayoutEffect(create, deps);
  47008. },
  47009. useMemo: function (create, deps) {
  47010. currentHookNameInDev = 'useMemo';
  47011. warnInvalidHookAccess();
  47012. mountHookTypesDev();
  47013. var prevDispatcher = ReactCurrentDispatcher$1.current;
  47014. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  47015. try {
  47016. return mountMemo(create, deps);
  47017. } finally {
  47018. ReactCurrentDispatcher$1.current = prevDispatcher;
  47019. }
  47020. },
  47021. useReducer: function (reducer, initialArg, init) {
  47022. currentHookNameInDev = 'useReducer';
  47023. warnInvalidHookAccess();
  47024. mountHookTypesDev();
  47025. var prevDispatcher = ReactCurrentDispatcher$1.current;
  47026. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  47027. try {
  47028. return mountReducer(reducer, initialArg, init);
  47029. } finally {
  47030. ReactCurrentDispatcher$1.current = prevDispatcher;
  47031. }
  47032. },
  47033. useRef: function (initialValue) {
  47034. currentHookNameInDev = 'useRef';
  47035. warnInvalidHookAccess();
  47036. mountHookTypesDev();
  47037. return mountRef(initialValue);
  47038. },
  47039. useState: function (initialState) {
  47040. currentHookNameInDev = 'useState';
  47041. warnInvalidHookAccess();
  47042. mountHookTypesDev();
  47043. var prevDispatcher = ReactCurrentDispatcher$1.current;
  47044. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  47045. try {
  47046. return mountState(initialState);
  47047. } finally {
  47048. ReactCurrentDispatcher$1.current = prevDispatcher;
  47049. }
  47050. },
  47051. useDebugValue: function (value, formatterFn) {
  47052. currentHookNameInDev = 'useDebugValue';
  47053. warnInvalidHookAccess();
  47054. mountHookTypesDev();
  47055. return mountDebugValue(value, formatterFn);
  47056. },
  47057. useResponder: function (responder, props) {
  47058. currentHookNameInDev = 'useResponder';
  47059. warnInvalidHookAccess();
  47060. mountHookTypesDev();
  47061. return createResponderListener(responder, props);
  47062. }
  47063. };
  47064. InvalidNestedHooksDispatcherOnUpdateInDEV = {
  47065. readContext: function (context, observedBits) {
  47066. warnInvalidContextAccess();
  47067. return readContext(context, observedBits);
  47068. },
  47069. useCallback: function (callback, deps) {
  47070. currentHookNameInDev = 'useCallback';
  47071. warnInvalidHookAccess();
  47072. updateHookTypesDev();
  47073. return updateCallback(callback, deps);
  47074. },
  47075. useContext: function (context, observedBits) {
  47076. currentHookNameInDev = 'useContext';
  47077. warnInvalidHookAccess();
  47078. updateHookTypesDev();
  47079. return readContext(context, observedBits);
  47080. },
  47081. useEffect: function (create, deps) {
  47082. currentHookNameInDev = 'useEffect';
  47083. warnInvalidHookAccess();
  47084. updateHookTypesDev();
  47085. return updateEffect(create, deps);
  47086. },
  47087. useImperativeHandle: function (ref, create, deps) {
  47088. currentHookNameInDev = 'useImperativeHandle';
  47089. warnInvalidHookAccess();
  47090. updateHookTypesDev();
  47091. return updateImperativeHandle(ref, create, deps);
  47092. },
  47093. useLayoutEffect: function (create, deps) {
  47094. currentHookNameInDev = 'useLayoutEffect';
  47095. warnInvalidHookAccess();
  47096. updateHookTypesDev();
  47097. return updateLayoutEffect(create, deps);
  47098. },
  47099. useMemo: function (create, deps) {
  47100. currentHookNameInDev = 'useMemo';
  47101. warnInvalidHookAccess();
  47102. updateHookTypesDev();
  47103. var prevDispatcher = ReactCurrentDispatcher$1.current;
  47104. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  47105. try {
  47106. return updateMemo(create, deps);
  47107. } finally {
  47108. ReactCurrentDispatcher$1.current = prevDispatcher;
  47109. }
  47110. },
  47111. useReducer: function (reducer, initialArg, init) {
  47112. currentHookNameInDev = 'useReducer';
  47113. warnInvalidHookAccess();
  47114. updateHookTypesDev();
  47115. var prevDispatcher = ReactCurrentDispatcher$1.current;
  47116. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  47117. try {
  47118. return updateReducer(reducer, initialArg, init);
  47119. } finally {
  47120. ReactCurrentDispatcher$1.current = prevDispatcher;
  47121. }
  47122. },
  47123. useRef: function (initialValue) {
  47124. currentHookNameInDev = 'useRef';
  47125. warnInvalidHookAccess();
  47126. updateHookTypesDev();
  47127. return updateRef(initialValue);
  47128. },
  47129. useState: function (initialState) {
  47130. currentHookNameInDev = 'useState';
  47131. warnInvalidHookAccess();
  47132. updateHookTypesDev();
  47133. var prevDispatcher = ReactCurrentDispatcher$1.current;
  47134. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  47135. try {
  47136. return updateState(initialState);
  47137. } finally {
  47138. ReactCurrentDispatcher$1.current = prevDispatcher;
  47139. }
  47140. },
  47141. useDebugValue: function (value, formatterFn) {
  47142. currentHookNameInDev = 'useDebugValue';
  47143. warnInvalidHookAccess();
  47144. updateHookTypesDev();
  47145. return updateDebugValue(value, formatterFn);
  47146. },
  47147. useResponder: function (responder, props) {
  47148. currentHookNameInDev = 'useResponder';
  47149. warnInvalidHookAccess();
  47150. updateHookTypesDev();
  47151. return createResponderListener(responder, props);
  47152. }
  47153. };
  47154. }
  47155. // CommonJS interop named imports.
  47156. var now$1 = Scheduler.unstable_now;
  47157. var commitTime = 0;
  47158. var profilerStartTime = -1;
  47159. function getCommitTime() {
  47160. return commitTime;
  47161. }
  47162. function recordCommitTime() {
  47163. if (!enableProfilerTimer) {
  47164. return;
  47165. }
  47166. commitTime = now$1();
  47167. }
  47168. function startProfilerTimer(fiber) {
  47169. if (!enableProfilerTimer) {
  47170. return;
  47171. }
  47172. profilerStartTime = now$1();
  47173. if (fiber.actualStartTime < 0) {
  47174. fiber.actualStartTime = now$1();
  47175. }
  47176. }
  47177. function stopProfilerTimerIfRunning(fiber) {
  47178. if (!enableProfilerTimer) {
  47179. return;
  47180. }
  47181. profilerStartTime = -1;
  47182. }
  47183. function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
  47184. if (!enableProfilerTimer) {
  47185. return;
  47186. }
  47187. if (profilerStartTime >= 0) {
  47188. var elapsedTime = now$1() - profilerStartTime;
  47189. fiber.actualDuration += elapsedTime;
  47190. if (overrideBaseTime) {
  47191. fiber.selfBaseDuration = elapsedTime;
  47192. }
  47193. profilerStartTime = -1;
  47194. }
  47195. }
  47196. // This may have been an insertion or a hydration.
  47197. var hydrationParentFiber = null;
  47198. var nextHydratableInstance = null;
  47199. var isHydrating = false;
  47200. function warnIfHydrating() {
  47201. {
  47202. !!isHydrating ? warning$1(false, 'We should not be hydrating here. This is a bug in React. Please file a bug.') : void 0;
  47203. }
  47204. }
  47205. function enterHydrationState(fiber) {
  47206. if (!supportsHydration) {
  47207. return false;
  47208. }
  47209. var parentInstance = fiber.stateNode.containerInfo;
  47210. nextHydratableInstance = getFirstHydratableChild(parentInstance);
  47211. hydrationParentFiber = fiber;
  47212. isHydrating = true;
  47213. return true;
  47214. }
  47215. function reenterHydrationStateFromDehydratedSuspenseInstance(fiber, suspenseInstance) {
  47216. if (!supportsHydration) {
  47217. return false;
  47218. }
  47219. nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
  47220. popToNextHostParent(fiber);
  47221. isHydrating = true;
  47222. return true;
  47223. }
  47224. function deleteHydratableInstance(returnFiber, instance) {
  47225. {
  47226. switch (returnFiber.tag) {
  47227. case HostRoot:
  47228. didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
  47229. break;
  47230. case HostComponent:
  47231. didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
  47232. break;
  47233. }
  47234. }
  47235. var childToDelete = createFiberFromHostInstanceForDeletion();
  47236. childToDelete.stateNode = instance;
  47237. childToDelete.return = returnFiber;
  47238. childToDelete.effectTag = Deletion; // This might seem like it belongs on progressedFirstDeletion. However,
  47239. // these children are not part of the reconciliation list of children.
  47240. // Even if we abort and rereconcile the children, that will try to hydrate
  47241. // again and the nodes are still in the host tree so these will be
  47242. // recreated.
  47243. if (returnFiber.lastEffect !== null) {
  47244. returnFiber.lastEffect.nextEffect = childToDelete;
  47245. returnFiber.lastEffect = childToDelete;
  47246. } else {
  47247. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  47248. }
  47249. }
  47250. function insertNonHydratedInstance(returnFiber, fiber) {
  47251. fiber.effectTag = fiber.effectTag & ~Hydrating | Placement;
  47252. {
  47253. switch (returnFiber.tag) {
  47254. case HostRoot:
  47255. {
  47256. var parentContainer = returnFiber.stateNode.containerInfo;
  47257. switch (fiber.tag) {
  47258. case HostComponent:
  47259. var type = fiber.type;
  47260. var props = fiber.pendingProps;
  47261. didNotFindHydratableContainerInstance(parentContainer, type, props);
  47262. break;
  47263. case HostText:
  47264. var text = fiber.pendingProps;
  47265. didNotFindHydratableContainerTextInstance(parentContainer, text);
  47266. break;
  47267. case SuspenseComponent:
  47268. break;
  47269. }
  47270. break;
  47271. }
  47272. case HostComponent:
  47273. {
  47274. var parentType = returnFiber.type;
  47275. var parentProps = returnFiber.memoizedProps;
  47276. var parentInstance = returnFiber.stateNode;
  47277. switch (fiber.tag) {
  47278. case HostComponent:
  47279. var _type = fiber.type;
  47280. var _props = fiber.pendingProps;
  47281. didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props);
  47282. break;
  47283. case HostText:
  47284. var _text = fiber.pendingProps;
  47285. didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
  47286. break;
  47287. case SuspenseComponent:
  47288. didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
  47289. break;
  47290. }
  47291. break;
  47292. }
  47293. default:
  47294. return;
  47295. }
  47296. }
  47297. }
  47298. function tryHydrate(fiber, nextInstance) {
  47299. switch (fiber.tag) {
  47300. case HostComponent:
  47301. {
  47302. var type = fiber.type;
  47303. var props = fiber.pendingProps;
  47304. var instance = canHydrateInstance(nextInstance, type, props);
  47305. if (instance !== null) {
  47306. fiber.stateNode = instance;
  47307. return true;
  47308. }
  47309. return false;
  47310. }
  47311. case HostText:
  47312. {
  47313. var text = fiber.pendingProps;
  47314. var textInstance = canHydrateTextInstance(nextInstance, text);
  47315. if (textInstance !== null) {
  47316. fiber.stateNode = textInstance;
  47317. return true;
  47318. }
  47319. return false;
  47320. }
  47321. case SuspenseComponent:
  47322. {
  47323. if (enableSuspenseServerRenderer) {
  47324. var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
  47325. if (suspenseInstance !== null) {
  47326. var suspenseState = {
  47327. dehydrated: suspenseInstance,
  47328. retryTime: Never
  47329. };
  47330. fiber.memoizedState = suspenseState; // Store the dehydrated fragment as a child fiber.
  47331. // This simplifies the code for getHostSibling and deleting nodes,
  47332. // since it doesn't have to consider all Suspense boundaries and
  47333. // check if they're dehydrated ones or not.
  47334. var dehydratedFragment = createFiberFromDehydratedFragment(suspenseInstance);
  47335. dehydratedFragment.return = fiber;
  47336. fiber.child = dehydratedFragment;
  47337. return true;
  47338. }
  47339. }
  47340. return false;
  47341. }
  47342. default:
  47343. return false;
  47344. }
  47345. }
  47346. function tryToClaimNextHydratableInstance(fiber) {
  47347. if (!isHydrating) {
  47348. return;
  47349. }
  47350. var nextInstance = nextHydratableInstance;
  47351. if (!nextInstance) {
  47352. // Nothing to hydrate. Make it an insertion.
  47353. insertNonHydratedInstance(hydrationParentFiber, fiber);
  47354. isHydrating = false;
  47355. hydrationParentFiber = fiber;
  47356. return;
  47357. }
  47358. var firstAttemptedInstance = nextInstance;
  47359. if (!tryHydrate(fiber, nextInstance)) {
  47360. // If we can't hydrate this instance let's try the next one.
  47361. // We use this as a heuristic. It's based on intuition and not data so it
  47362. // might be flawed or unnecessary.
  47363. nextInstance = getNextHydratableSibling(firstAttemptedInstance);
  47364. if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
  47365. // Nothing to hydrate. Make it an insertion.
  47366. insertNonHydratedInstance(hydrationParentFiber, fiber);
  47367. isHydrating = false;
  47368. hydrationParentFiber = fiber;
  47369. return;
  47370. } // We matched the next one, we'll now assume that the first one was
  47371. // superfluous and we'll delete it. Since we can't eagerly delete it
  47372. // we'll have to schedule a deletion. To do that, this node needs a dummy
  47373. // fiber associated with it.
  47374. deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
  47375. }
  47376. hydrationParentFiber = fiber;
  47377. nextHydratableInstance = getFirstHydratableChild(nextInstance);
  47378. }
  47379. function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
  47380. if (!supportsHydration) {
  47381. (function () {
  47382. {
  47383. {
  47384. throw ReactError(Error("Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
  47385. }
  47386. }
  47387. })();
  47388. }
  47389. var instance = fiber.stateNode;
  47390. var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); // TODO: Type this specific to this type of component.
  47391. fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
  47392. // is a new ref we mark this as an update.
  47393. if (updatePayload !== null) {
  47394. return true;
  47395. }
  47396. return false;
  47397. }
  47398. function prepareToHydrateHostTextInstance(fiber) {
  47399. if (!supportsHydration) {
  47400. (function () {
  47401. {
  47402. {
  47403. throw ReactError(Error("Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
  47404. }
  47405. }
  47406. })();
  47407. }
  47408. var textInstance = fiber.stateNode;
  47409. var textContent = fiber.memoizedProps;
  47410. var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
  47411. {
  47412. if (shouldUpdate) {
  47413. // We assume that prepareToHydrateHostTextInstance is called in a context where the
  47414. // hydration parent is the parent host component of this host text.
  47415. var returnFiber = hydrationParentFiber;
  47416. if (returnFiber !== null) {
  47417. switch (returnFiber.tag) {
  47418. case HostRoot:
  47419. {
  47420. var parentContainer = returnFiber.stateNode.containerInfo;
  47421. didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
  47422. break;
  47423. }
  47424. case HostComponent:
  47425. {
  47426. var parentType = returnFiber.type;
  47427. var parentProps = returnFiber.memoizedProps;
  47428. var parentInstance = returnFiber.stateNode;
  47429. didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
  47430. break;
  47431. }
  47432. }
  47433. }
  47434. }
  47435. }
  47436. return shouldUpdate;
  47437. }
  47438. function prepareToHydrateHostSuspenseInstance(fiber) {
  47439. if (!supportsHydration) {
  47440. (function () {
  47441. {
  47442. {
  47443. throw ReactError(Error("Expected prepareToHydrateHostSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
  47444. }
  47445. }
  47446. })();
  47447. }
  47448. var suspenseState = fiber.memoizedState;
  47449. var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
  47450. (function () {
  47451. if (!suspenseInstance) {
  47452. {
  47453. throw ReactError(Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue."));
  47454. }
  47455. }
  47456. })();
  47457. hydrateSuspenseInstance(suspenseInstance, fiber);
  47458. }
  47459. function skipPastDehydratedSuspenseInstance(fiber) {
  47460. if (!supportsHydration) {
  47461. (function () {
  47462. {
  47463. {
  47464. throw ReactError(Error("Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
  47465. }
  47466. }
  47467. })();
  47468. }
  47469. var suspenseState = fiber.memoizedState;
  47470. var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
  47471. if (suspenseInstance === null) {
  47472. // This Suspense boundary was hydrated without a match.
  47473. return nextHydratableInstance;
  47474. }
  47475. return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
  47476. }
  47477. function popToNextHostParent(fiber) {
  47478. var parent = fiber.return;
  47479. while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) {
  47480. parent = parent.return;
  47481. }
  47482. hydrationParentFiber = parent;
  47483. }
  47484. function popHydrationState(fiber) {
  47485. if (!supportsHydration) {
  47486. return false;
  47487. }
  47488. if (fiber !== hydrationParentFiber) {
  47489. // We're deeper than the current hydration context, inside an inserted
  47490. // tree.
  47491. return false;
  47492. }
  47493. if (!isHydrating) {
  47494. // If we're not currently hydrating but we're in a hydration context, then
  47495. // we were an insertion and now need to pop up reenter hydration of our
  47496. // siblings.
  47497. popToNextHostParent(fiber);
  47498. isHydrating = true;
  47499. return false;
  47500. }
  47501. var type = fiber.type; // If we have any remaining hydratable nodes, we need to delete them now.
  47502. // We only do this deeper than head and body since they tend to have random
  47503. // other nodes in them. We also ignore components with pure text content in
  47504. // side of them.
  47505. // TODO: Better heuristic.
  47506. if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
  47507. var nextInstance = nextHydratableInstance;
  47508. while (nextInstance) {
  47509. deleteHydratableInstance(fiber, nextInstance);
  47510. nextInstance = getNextHydratableSibling(nextInstance);
  47511. }
  47512. }
  47513. popToNextHostParent(fiber);
  47514. if (fiber.tag === SuspenseComponent) {
  47515. nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber);
  47516. } else {
  47517. nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
  47518. }
  47519. return true;
  47520. }
  47521. function resetHydrationState() {
  47522. if (!supportsHydration) {
  47523. return;
  47524. }
  47525. hydrationParentFiber = null;
  47526. nextHydratableInstance = null;
  47527. isHydrating = false;
  47528. }
  47529. var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner;
  47530. var didReceiveUpdate = false;
  47531. var didWarnAboutBadClass;
  47532. var didWarnAboutModulePatternComponent;
  47533. var didWarnAboutContextTypeOnFunctionComponent;
  47534. var didWarnAboutGetDerivedStateOnFunctionComponent;
  47535. var didWarnAboutFunctionRefs;
  47536. var didWarnAboutReassigningProps;
  47537. var didWarnAboutMaxDuration;
  47538. var didWarnAboutRevealOrder;
  47539. var didWarnAboutTailOptions;
  47540. var didWarnAboutDefaultPropsOnFunctionComponent;
  47541. {
  47542. didWarnAboutBadClass = {};
  47543. didWarnAboutModulePatternComponent = {};
  47544. didWarnAboutContextTypeOnFunctionComponent = {};
  47545. didWarnAboutGetDerivedStateOnFunctionComponent = {};
  47546. didWarnAboutFunctionRefs = {};
  47547. didWarnAboutReassigningProps = false;
  47548. didWarnAboutMaxDuration = false;
  47549. didWarnAboutRevealOrder = {};
  47550. didWarnAboutTailOptions = {};
  47551. didWarnAboutDefaultPropsOnFunctionComponent = {};
  47552. }
  47553. function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime) {
  47554. if (current$$1 === null) {
  47555. // If this is a fresh new component that hasn't been rendered yet, we
  47556. // won't update its child set by applying minimal side-effects. Instead,
  47557. // we will add them all to the child before it gets rendered. That means
  47558. // we can optimize this reconciliation pass by not tracking side-effects.
  47559. workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  47560. } else {
  47561. // If the current child is the same as the work in progress, it means that
  47562. // we haven't yet started any work on these children. Therefore, we use
  47563. // the clone algorithm to create a copy of all the current children.
  47564. // If we had any progressed work already, that is invalid at this point so
  47565. // let's throw it out.
  47566. workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, nextChildren, renderExpirationTime);
  47567. }
  47568. }
  47569. function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime) {
  47570. // This function is fork of reconcileChildren. It's used in cases where we
  47571. // want to reconcile without matching against the existing set. This has the
  47572. // effect of all current children being unmounted; even if the type and key
  47573. // are the same, the old child is unmounted and a new child is created.
  47574. //
  47575. // To do this, we're going to go through the reconcile algorithm twice. In
  47576. // the first pass, we schedule a deletion for all the current children by
  47577. // passing null.
  47578. workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime); // In the second pass, we mount the new children. The trick here is that we
  47579. // pass null in place of where we usually pass the current child set. This has
  47580. // the effect of remounting all children regardless of whether their their
  47581. // identity matches.
  47582. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  47583. }
  47584. function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  47585. // TODO: current can be non-null here even if the component
  47586. // hasn't yet mounted. This happens after the first render suspends.
  47587. // We'll need to figure out if this is fine or can cause issues.
  47588. {
  47589. if (workInProgress.type !== workInProgress.elementType) {
  47590. // Lazy component props can't be validated in createElement
  47591. // because they're only guaranteed to be resolved here.
  47592. var innerPropTypes = Component.propTypes;
  47593. if (innerPropTypes) {
  47594. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  47595. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  47596. }
  47597. }
  47598. }
  47599. var render = Component.render;
  47600. var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
  47601. var nextChildren;
  47602. prepareToReadContext(workInProgress, renderExpirationTime);
  47603. {
  47604. ReactCurrentOwner$3.current = workInProgress;
  47605. setCurrentPhase('render');
  47606. nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
  47607. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  47608. // Only double-render components with Hooks
  47609. if (workInProgress.memoizedState !== null) {
  47610. nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
  47611. }
  47612. }
  47613. setCurrentPhase(null);
  47614. }
  47615. if (current$$1 !== null && !didReceiveUpdate) {
  47616. bailoutHooks(current$$1, workInProgress, renderExpirationTime);
  47617. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  47618. } // React DevTools reads this flag.
  47619. workInProgress.effectTag |= PerformedWork;
  47620. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  47621. return workInProgress.child;
  47622. }
  47623. function updateMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
  47624. if (current$$1 === null) {
  47625. var type = Component.type;
  47626. if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either.
  47627. Component.defaultProps === undefined) {
  47628. var resolvedType = type;
  47629. {
  47630. resolvedType = resolveFunctionForHotReloading(type);
  47631. } // If this is a plain function component without default props,
  47632. // and with only the default shallow comparison, we upgrade it
  47633. // to a SimpleMemoComponent to allow fast path updates.
  47634. workInProgress.tag = SimpleMemoComponent;
  47635. workInProgress.type = resolvedType;
  47636. {
  47637. validateFunctionComponentInDev(workInProgress, type);
  47638. }
  47639. return updateSimpleMemoComponent(current$$1, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime);
  47640. }
  47641. {
  47642. var innerPropTypes = type.propTypes;
  47643. if (innerPropTypes) {
  47644. // Inner memo component props aren't currently validated in createElement.
  47645. // We could move it there, but we'd still need this for lazy code path.
  47646. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  47647. 'prop', getComponentName(type), getCurrentFiberStackInDev);
  47648. }
  47649. }
  47650. var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
  47651. child.ref = workInProgress.ref;
  47652. child.return = workInProgress;
  47653. workInProgress.child = child;
  47654. return child;
  47655. }
  47656. {
  47657. var _type = Component.type;
  47658. var _innerPropTypes = _type.propTypes;
  47659. if (_innerPropTypes) {
  47660. // Inner memo component props aren't currently validated in createElement.
  47661. // We could move it there, but we'd still need this for lazy code path.
  47662. checkPropTypes(_innerPropTypes, nextProps, // Resolved props
  47663. 'prop', getComponentName(_type), getCurrentFiberStackInDev);
  47664. }
  47665. }
  47666. var currentChild = current$$1.child; // This is always exactly one child
  47667. if (updateExpirationTime < renderExpirationTime) {
  47668. // This will be the props with resolved defaultProps,
  47669. // unlike current.memoizedProps which will be the unresolved ones.
  47670. var prevProps = currentChild.memoizedProps; // Default to shallow comparison
  47671. var compare = Component.compare;
  47672. compare = compare !== null ? compare : shallowEqual;
  47673. if (compare(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
  47674. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  47675. }
  47676. } // React DevTools reads this flag.
  47677. workInProgress.effectTag |= PerformedWork;
  47678. var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
  47679. newChild.ref = workInProgress.ref;
  47680. newChild.return = workInProgress;
  47681. workInProgress.child = newChild;
  47682. return newChild;
  47683. }
  47684. function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
  47685. // TODO: current can be non-null here even if the component
  47686. // hasn't yet mounted. This happens when the inner render suspends.
  47687. // We'll need to figure out if this is fine or can cause issues.
  47688. {
  47689. if (workInProgress.type !== workInProgress.elementType) {
  47690. // Lazy component props can't be validated in createElement
  47691. // because they're only guaranteed to be resolved here.
  47692. var outerMemoType = workInProgress.elementType;
  47693. if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
  47694. // We warn when you define propTypes on lazy()
  47695. // so let's just skip over it to find memo() outer wrapper.
  47696. // Inner props for memo are validated later.
  47697. outerMemoType = refineResolvedLazyComponent(outerMemoType);
  47698. }
  47699. var outerPropTypes = outerMemoType && outerMemoType.propTypes;
  47700. if (outerPropTypes) {
  47701. checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
  47702. 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
  47703. } // Inner propTypes will be validated in the function component path.
  47704. }
  47705. }
  47706. if (current$$1 !== null) {
  47707. var prevProps = current$$1.memoizedProps;
  47708. if (shallowEqual(prevProps, nextProps) && current$$1.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload:
  47709. workInProgress.type === current$$1.type)) {
  47710. didReceiveUpdate = false;
  47711. if (updateExpirationTime < renderExpirationTime) {
  47712. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  47713. }
  47714. }
  47715. }
  47716. return updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
  47717. }
  47718. function updateFragment(current$$1, workInProgress, renderExpirationTime) {
  47719. var nextChildren = workInProgress.pendingProps;
  47720. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  47721. return workInProgress.child;
  47722. }
  47723. function updateMode(current$$1, workInProgress, renderExpirationTime) {
  47724. var nextChildren = workInProgress.pendingProps.children;
  47725. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  47726. return workInProgress.child;
  47727. }
  47728. function updateProfiler(current$$1, workInProgress, renderExpirationTime) {
  47729. if (enableProfilerTimer) {
  47730. workInProgress.effectTag |= Update;
  47731. }
  47732. var nextProps = workInProgress.pendingProps;
  47733. var nextChildren = nextProps.children;
  47734. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  47735. return workInProgress.child;
  47736. }
  47737. function markRef(current$$1, workInProgress) {
  47738. var ref = workInProgress.ref;
  47739. if (current$$1 === null && ref !== null || current$$1 !== null && current$$1.ref !== ref) {
  47740. // Schedule a Ref effect
  47741. workInProgress.effectTag |= Ref;
  47742. }
  47743. }
  47744. function updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  47745. {
  47746. if (workInProgress.type !== workInProgress.elementType) {
  47747. // Lazy component props can't be validated in createElement
  47748. // because they're only guaranteed to be resolved here.
  47749. var innerPropTypes = Component.propTypes;
  47750. if (innerPropTypes) {
  47751. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  47752. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  47753. }
  47754. }
  47755. }
  47756. var context;
  47757. if (!disableLegacyContext) {
  47758. var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
  47759. context = getMaskedContext(workInProgress, unmaskedContext);
  47760. }
  47761. var nextChildren;
  47762. prepareToReadContext(workInProgress, renderExpirationTime);
  47763. {
  47764. ReactCurrentOwner$3.current = workInProgress;
  47765. setCurrentPhase('render');
  47766. nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
  47767. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  47768. // Only double-render components with Hooks
  47769. if (workInProgress.memoizedState !== null) {
  47770. nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
  47771. }
  47772. }
  47773. setCurrentPhase(null);
  47774. }
  47775. if (current$$1 !== null && !didReceiveUpdate) {
  47776. bailoutHooks(current$$1, workInProgress, renderExpirationTime);
  47777. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  47778. } // React DevTools reads this flag.
  47779. workInProgress.effectTag |= PerformedWork;
  47780. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  47781. return workInProgress.child;
  47782. }
  47783. function updateClassComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  47784. {
  47785. if (workInProgress.type !== workInProgress.elementType) {
  47786. // Lazy component props can't be validated in createElement
  47787. // because they're only guaranteed to be resolved here.
  47788. var innerPropTypes = Component.propTypes;
  47789. if (innerPropTypes) {
  47790. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  47791. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  47792. }
  47793. }
  47794. } // Push context providers early to prevent context stack mismatches.
  47795. // During mounting we don't know the child context yet as the instance doesn't exist.
  47796. // We will invalidate the child context in finishClassComponent() right after rendering.
  47797. var hasContext;
  47798. if (isContextProvider(Component)) {
  47799. hasContext = true;
  47800. pushContextProvider(workInProgress);
  47801. } else {
  47802. hasContext = false;
  47803. }
  47804. prepareToReadContext(workInProgress, renderExpirationTime);
  47805. var instance = workInProgress.stateNode;
  47806. var shouldUpdate;
  47807. if (instance === null) {
  47808. if (current$$1 !== null) {
  47809. // An class component without an instance only mounts if it suspended
  47810. // inside a non- concurrent tree, in an inconsistent state. We want to
  47811. // tree it like a new mount, even though an empty version of it already
  47812. // committed. Disconnect the alternate pointers.
  47813. current$$1.alternate = null;
  47814. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  47815. workInProgress.effectTag |= Placement;
  47816. } // In the initial pass we might need to construct the instance.
  47817. constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  47818. mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  47819. shouldUpdate = true;
  47820. } else if (current$$1 === null) {
  47821. // In a resume, we'll already have an instance we can reuse.
  47822. shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  47823. } else {
  47824. shouldUpdate = updateClassInstance(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
  47825. }
  47826. var nextUnitOfWork = finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
  47827. {
  47828. var inst = workInProgress.stateNode;
  47829. if (inst.props !== nextProps) {
  47830. !didWarnAboutReassigningProps ? warning$1(false, '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') : void 0;
  47831. didWarnAboutReassigningProps = true;
  47832. }
  47833. }
  47834. return nextUnitOfWork;
  47835. }
  47836. function finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
  47837. // Refs should update even if shouldComponentUpdate returns false
  47838. markRef(current$$1, workInProgress);
  47839. var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
  47840. if (!shouldUpdate && !didCaptureError) {
  47841. // Context providers should defer to sCU for rendering
  47842. if (hasContext) {
  47843. invalidateContextProvider(workInProgress, Component, false);
  47844. }
  47845. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  47846. }
  47847. var instance = workInProgress.stateNode; // Rerender
  47848. ReactCurrentOwner$3.current = workInProgress;
  47849. var nextChildren;
  47850. if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
  47851. // If we captured an error, but getDerivedStateFrom catch is not defined,
  47852. // unmount all the children. componentDidCatch will schedule an update to
  47853. // re-render a fallback. This is temporary until we migrate everyone to
  47854. // the new API.
  47855. // TODO: Warn in a future release.
  47856. nextChildren = null;
  47857. if (enableProfilerTimer) {
  47858. stopProfilerTimerIfRunning(workInProgress);
  47859. }
  47860. } else {
  47861. {
  47862. setCurrentPhase('render');
  47863. nextChildren = instance.render();
  47864. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  47865. instance.render();
  47866. }
  47867. setCurrentPhase(null);
  47868. }
  47869. } // React DevTools reads this flag.
  47870. workInProgress.effectTag |= PerformedWork;
  47871. if (current$$1 !== null && didCaptureError) {
  47872. // If we're recovering from an error, reconcile without reusing any of
  47873. // the existing children. Conceptually, the normal children and the children
  47874. // that are shown on error are two different sets, so we shouldn't reuse
  47875. // normal children even if their identities match.
  47876. forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime);
  47877. } else {
  47878. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  47879. } // Memoize state using the values we just used to render.
  47880. // TODO: Restructure so we never read values from the instance.
  47881. workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it.
  47882. if (hasContext) {
  47883. invalidateContextProvider(workInProgress, Component, true);
  47884. }
  47885. return workInProgress.child;
  47886. }
  47887. function pushHostRootContext(workInProgress) {
  47888. var root = workInProgress.stateNode;
  47889. if (root.pendingContext) {
  47890. pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
  47891. } else if (root.context) {
  47892. // Should always be set
  47893. pushTopLevelContextObject(workInProgress, root.context, false);
  47894. }
  47895. pushHostContainer(workInProgress, root.containerInfo);
  47896. }
  47897. function updateHostRoot(current$$1, workInProgress, renderExpirationTime) {
  47898. pushHostRootContext(workInProgress);
  47899. var updateQueue = workInProgress.updateQueue;
  47900. (function () {
  47901. if (!(updateQueue !== null)) {
  47902. {
  47903. throw ReactError(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."));
  47904. }
  47905. }
  47906. })();
  47907. var nextProps = workInProgress.pendingProps;
  47908. var prevState = workInProgress.memoizedState;
  47909. var prevChildren = prevState !== null ? prevState.element : null;
  47910. processUpdateQueue(workInProgress, updateQueue, nextProps, null, renderExpirationTime);
  47911. var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property
  47912. // being called "element".
  47913. var nextChildren = nextState.element;
  47914. if (nextChildren === prevChildren) {
  47915. // If the state is the same as before, that's a bailout because we had
  47916. // no work that expires at this time.
  47917. resetHydrationState();
  47918. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  47919. }
  47920. var root = workInProgress.stateNode;
  47921. if (root.hydrate && enterHydrationState(workInProgress)) {
  47922. // If we don't have any current children this might be the first pass.
  47923. // We always try to hydrate. If this isn't a hydration pass there won't
  47924. // be any children to hydrate which is effectively the same thing as
  47925. // not hydrating.
  47926. var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  47927. workInProgress.child = child;
  47928. var node = child;
  47929. while (node) {
  47930. // Mark each child as hydrating. This is a fast path to know whether this
  47931. // tree is part of a hydrating tree. This is used to determine if a child
  47932. // node has fully mounted yet, and for scheduling event replaying.
  47933. // Conceptually this is similar to Placement in that a new subtree is
  47934. // inserted into the React tree here. It just happens to not need DOM
  47935. // mutations because it already exists.
  47936. node.effectTag = node.effectTag & ~Placement | Hydrating;
  47937. node = node.sibling;
  47938. }
  47939. } else {
  47940. // Otherwise reset hydration state in case we aborted and resumed another
  47941. // root.
  47942. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  47943. resetHydrationState();
  47944. }
  47945. return workInProgress.child;
  47946. }
  47947. function updateHostComponent(current$$1, workInProgress, renderExpirationTime) {
  47948. pushHostContext(workInProgress);
  47949. if (current$$1 === null) {
  47950. tryToClaimNextHydratableInstance(workInProgress);
  47951. }
  47952. var type = workInProgress.type;
  47953. var nextProps = workInProgress.pendingProps;
  47954. var prevProps = current$$1 !== null ? current$$1.memoizedProps : null;
  47955. var nextChildren = nextProps.children;
  47956. var isDirectTextChild = shouldSetTextContent(type, nextProps);
  47957. if (isDirectTextChild) {
  47958. // We special case a direct text child of a host node. This is a common
  47959. // case. We won't handle it as a reified child. We will instead handle
  47960. // this in the host environment that also have access to this prop. That
  47961. // avoids allocating another HostText fiber and traversing it.
  47962. nextChildren = null;
  47963. } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
  47964. // If we're switching from a direct text child to a normal child, or to
  47965. // empty, we need to schedule the text content to be reset.
  47966. workInProgress.effectTag |= ContentReset;
  47967. }
  47968. markRef(current$$1, workInProgress); // Check the host config to see if the children are offscreen/hidden.
  47969. if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(type, nextProps)) {
  47970. if (enableSchedulerTracing) {
  47971. markSpawnedWork(Never);
  47972. } // Schedule this fiber to re-render at offscreen priority. Then bailout.
  47973. workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
  47974. return null;
  47975. }
  47976. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  47977. return workInProgress.child;
  47978. }
  47979. function updateHostText(current$$1, workInProgress) {
  47980. if (current$$1 === null) {
  47981. tryToClaimNextHydratableInstance(workInProgress);
  47982. } // Nothing to do here. This is terminal. We'll do the completion step
  47983. // immediately after.
  47984. return null;
  47985. }
  47986. function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
  47987. if (_current !== null) {
  47988. // An lazy component only mounts if it suspended inside a non-
  47989. // concurrent tree, in an inconsistent state. We want to treat it like
  47990. // a new mount, even though an empty version of it already committed.
  47991. // Disconnect the alternate pointers.
  47992. _current.alternate = null;
  47993. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  47994. workInProgress.effectTag |= Placement;
  47995. }
  47996. var props = workInProgress.pendingProps; // We can't start a User Timing measurement with correct label yet.
  47997. // Cancel and resume right after we know the tag.
  47998. cancelWorkTimer(workInProgress);
  47999. var Component = readLazyComponentType(elementType); // Store the unwrapped component in the type.
  48000. workInProgress.type = Component;
  48001. var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
  48002. startWorkTimer(workInProgress);
  48003. var resolvedProps = resolveDefaultProps(Component, props);
  48004. var child;
  48005. switch (resolvedTag) {
  48006. case FunctionComponent:
  48007. {
  48008. {
  48009. validateFunctionComponentInDev(workInProgress, Component);
  48010. workInProgress.type = Component = resolveFunctionForHotReloading(Component);
  48011. }
  48012. child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  48013. break;
  48014. }
  48015. case ClassComponent:
  48016. {
  48017. {
  48018. workInProgress.type = Component = resolveClassForHotReloading(Component);
  48019. }
  48020. child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  48021. break;
  48022. }
  48023. case ForwardRef:
  48024. {
  48025. {
  48026. workInProgress.type = Component = resolveForwardRefForHotReloading(Component);
  48027. }
  48028. child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  48029. break;
  48030. }
  48031. case MemoComponent:
  48032. {
  48033. {
  48034. if (workInProgress.type !== workInProgress.elementType) {
  48035. var outerPropTypes = Component.propTypes;
  48036. if (outerPropTypes) {
  48037. checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only
  48038. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  48039. }
  48040. }
  48041. }
  48042. child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
  48043. updateExpirationTime, renderExpirationTime);
  48044. break;
  48045. }
  48046. default:
  48047. {
  48048. var hint = '';
  48049. {
  48050. if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
  48051. hint = ' Did you wrap a component in React.lazy() more than once?';
  48052. }
  48053. } // This message intentionally doesn't mention ForwardRef or MemoComponent
  48054. // because the fact that it's a separate type of work is an
  48055. // implementation detail.
  48056. (function () {
  48057. {
  48058. {
  48059. throw ReactError(Error("Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint));
  48060. }
  48061. }
  48062. })();
  48063. }
  48064. }
  48065. return child;
  48066. }
  48067. function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
  48068. if (_current !== null) {
  48069. // An incomplete component only mounts if it suspended inside a non-
  48070. // concurrent tree, in an inconsistent state. We want to treat it like
  48071. // a new mount, even though an empty version of it already committed.
  48072. // Disconnect the alternate pointers.
  48073. _current.alternate = null;
  48074. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  48075. workInProgress.effectTag |= Placement;
  48076. } // Promote the fiber to a class and try rendering again.
  48077. workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent`
  48078. // Push context providers early to prevent context stack mismatches.
  48079. // During mounting we don't know the child context yet as the instance doesn't exist.
  48080. // We will invalidate the child context in finishClassComponent() right after rendering.
  48081. var hasContext;
  48082. if (isContextProvider(Component)) {
  48083. hasContext = true;
  48084. pushContextProvider(workInProgress);
  48085. } else {
  48086. hasContext = false;
  48087. }
  48088. prepareToReadContext(workInProgress, renderExpirationTime);
  48089. constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  48090. mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  48091. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
  48092. }
  48093. function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
  48094. if (_current !== null) {
  48095. // An indeterminate component only mounts if it suspended inside a non-
  48096. // concurrent tree, in an inconsistent state. We want to treat it like
  48097. // a new mount, even though an empty version of it already committed.
  48098. // Disconnect the alternate pointers.
  48099. _current.alternate = null;
  48100. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  48101. workInProgress.effectTag |= Placement;
  48102. }
  48103. var props = workInProgress.pendingProps;
  48104. var context;
  48105. if (!disableLegacyContext) {
  48106. var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
  48107. context = getMaskedContext(workInProgress, unmaskedContext);
  48108. }
  48109. prepareToReadContext(workInProgress, renderExpirationTime);
  48110. var value;
  48111. {
  48112. if (Component.prototype && typeof Component.prototype.render === 'function') {
  48113. var componentName = getComponentName(Component) || 'Unknown';
  48114. if (!didWarnAboutBadClass[componentName]) {
  48115. warningWithoutStack$1(false, "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);
  48116. didWarnAboutBadClass[componentName] = true;
  48117. }
  48118. }
  48119. if (workInProgress.mode & StrictMode) {
  48120. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
  48121. }
  48122. ReactCurrentOwner$3.current = workInProgress;
  48123. value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
  48124. } // React DevTools reads this flag.
  48125. workInProgress.effectTag |= PerformedWork;
  48126. if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  48127. {
  48128. var _componentName = getComponentName(Component) || 'Unknown';
  48129. if (!didWarnAboutModulePatternComponent[_componentName]) {
  48130. warningWithoutStack$1(false, '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);
  48131. didWarnAboutModulePatternComponent[_componentName] = true;
  48132. }
  48133. } // Proceed under the assumption that this is a class instance
  48134. workInProgress.tag = ClassComponent; // Throw out any hooks that were used.
  48135. resetHooks(); // Push context providers early to prevent context stack mismatches.
  48136. // During mounting we don't know the child context yet as the instance doesn't exist.
  48137. // We will invalidate the child context in finishClassComponent() right after rendering.
  48138. var hasContext = false;
  48139. if (isContextProvider(Component)) {
  48140. hasContext = true;
  48141. pushContextProvider(workInProgress);
  48142. } else {
  48143. hasContext = false;
  48144. }
  48145. workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
  48146. var getDerivedStateFromProps = Component.getDerivedStateFromProps;
  48147. if (typeof getDerivedStateFromProps === 'function') {
  48148. applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
  48149. }
  48150. adoptClassInstance(workInProgress, value);
  48151. mountClassInstance(workInProgress, Component, props, renderExpirationTime);
  48152. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
  48153. } else {
  48154. // Proceed under the assumption that this is a function component
  48155. workInProgress.tag = FunctionComponent;
  48156. {
  48157. if (disableLegacyContext && Component.contextTypes) {
  48158. warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with React.useContext() instead.', getComponentName(Component) || 'Unknown');
  48159. }
  48160. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  48161. // Only double-render components with Hooks
  48162. if (workInProgress.memoizedState !== null) {
  48163. value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
  48164. }
  48165. }
  48166. }
  48167. reconcileChildren(null, workInProgress, value, renderExpirationTime);
  48168. {
  48169. validateFunctionComponentInDev(workInProgress, Component);
  48170. }
  48171. return workInProgress.child;
  48172. }
  48173. }
  48174. function validateFunctionComponentInDev(workInProgress, Component) {
  48175. if (Component) {
  48176. !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
  48177. }
  48178. if (workInProgress.ref !== null) {
  48179. var info = '';
  48180. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  48181. if (ownerName) {
  48182. info += '\n\nCheck the render method of `' + ownerName + '`.';
  48183. }
  48184. var warningKey = ownerName || workInProgress._debugID || '';
  48185. var debugSource = workInProgress._debugSource;
  48186. if (debugSource) {
  48187. warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
  48188. }
  48189. if (!didWarnAboutFunctionRefs[warningKey]) {
  48190. didWarnAboutFunctionRefs[warningKey] = true;
  48191. warning$1(false, 'Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
  48192. }
  48193. }
  48194. if (warnAboutDefaultPropsOnFunctionComponents && Component.defaultProps !== undefined) {
  48195. var componentName = getComponentName(Component) || 'Unknown';
  48196. if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
  48197. warningWithoutStack$1(false, '%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);
  48198. didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
  48199. }
  48200. }
  48201. if (typeof Component.getDerivedStateFromProps === 'function') {
  48202. var _componentName2 = getComponentName(Component) || 'Unknown';
  48203. if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) {
  48204. warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', _componentName2);
  48205. didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true;
  48206. }
  48207. }
  48208. if (typeof Component.contextType === 'object' && Component.contextType !== null) {
  48209. var _componentName3 = getComponentName(Component) || 'Unknown';
  48210. if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) {
  48211. warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName3);
  48212. didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true;
  48213. }
  48214. }
  48215. }
  48216. var SUSPENDED_MARKER = {
  48217. dehydrated: null,
  48218. retryTime: Never
  48219. };
  48220. function shouldRemainOnFallback(suspenseContext, current$$1, workInProgress) {
  48221. // If the context is telling us that we should show a fallback, and we're not
  48222. // already showing content, then we should show the fallback instead.
  48223. return hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && (current$$1 === null || current$$1.memoizedState !== null);
  48224. }
  48225. function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
  48226. var mode = workInProgress.mode;
  48227. var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend.
  48228. {
  48229. if (shouldSuspend(workInProgress)) {
  48230. workInProgress.effectTag |= DidCapture;
  48231. }
  48232. }
  48233. var suspenseContext = suspenseStackCursor.current;
  48234. var nextDidTimeout = false;
  48235. var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect;
  48236. if (didSuspend || shouldRemainOnFallback(suspenseContext, current$$1, workInProgress)) {
  48237. // Something in this boundary's subtree already suspended. Switch to
  48238. // rendering the fallback children.
  48239. nextDidTimeout = true;
  48240. workInProgress.effectTag &= ~DidCapture;
  48241. } else {
  48242. // Attempting the main content
  48243. if (current$$1 === null || current$$1.memoizedState !== null) {
  48244. // This is a new mount or this boundary is already showing a fallback state.
  48245. // Mark this subtree context as having at least one invisible parent that could
  48246. // handle the fallback state.
  48247. // Boundaries without fallbacks or should be avoided are not considered since
  48248. // they cannot handle preferred fallback states.
  48249. if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) {
  48250. suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
  48251. }
  48252. }
  48253. }
  48254. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  48255. pushSuspenseContext(workInProgress, suspenseContext);
  48256. {
  48257. if ('maxDuration' in nextProps) {
  48258. if (!didWarnAboutMaxDuration) {
  48259. didWarnAboutMaxDuration = true;
  48260. warning$1(false, 'maxDuration has been removed from React. ' + 'Remove the maxDuration prop.');
  48261. }
  48262. }
  48263. } // This next part is a bit confusing. If the children timeout, we switch to
  48264. // showing the fallback children in place of the "primary" children.
  48265. // However, we don't want to delete the primary children because then their
  48266. // state will be lost (both the React state and the host state, e.g.
  48267. // uncontrolled form inputs). Instead we keep them mounted and hide them.
  48268. // Both the fallback children AND the primary children are rendered at the
  48269. // same time. Once the primary children are un-suspended, we can delete
  48270. // the fallback children — don't need to preserve their state.
  48271. //
  48272. // The two sets of children are siblings in the host environment, but
  48273. // semantically, for purposes of reconciliation, they are two separate sets.
  48274. // So we store them using two fragment fibers.
  48275. //
  48276. // However, we want to avoid allocating extra fibers for every placeholder.
  48277. // They're only necessary when the children time out, because that's the
  48278. // only time when both sets are mounted.
  48279. //
  48280. // So, the extra fragment fibers are only used if the children time out.
  48281. // Otherwise, we render the primary children directly. This requires some
  48282. // custom reconciliation logic to preserve the state of the primary
  48283. // children. It's essentially a very basic form of re-parenting.
  48284. if (current$$1 === null) {
  48285. if (enableSuspenseServerRenderer) {
  48286. // If we're currently hydrating, try to hydrate this boundary.
  48287. // But only if this has a fallback.
  48288. if (nextProps.fallback !== undefined) {
  48289. tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component.
  48290. var suspenseState = workInProgress.memoizedState;
  48291. if (suspenseState !== null) {
  48292. var dehydrated = suspenseState.dehydrated;
  48293. if (dehydrated !== null) {
  48294. return mountDehydratedSuspenseComponent(workInProgress, dehydrated, renderExpirationTime);
  48295. }
  48296. }
  48297. }
  48298. } // This is the initial mount. This branch is pretty simple because there's
  48299. // no previous state that needs to be preserved.
  48300. if (nextDidTimeout) {
  48301. // Mount separate fragments for primary and fallback children.
  48302. var nextFallbackChildren = nextProps.fallback;
  48303. var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
  48304. primaryChildFragment.return = workInProgress;
  48305. if ((workInProgress.mode & BatchedMode) === NoMode) {
  48306. // Outside of batched mode, we commit the effects from the
  48307. // partially completed, timed-out tree, too.
  48308. var progressedState = workInProgress.memoizedState;
  48309. var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
  48310. primaryChildFragment.child = progressedPrimaryChild;
  48311. var progressedChild = progressedPrimaryChild;
  48312. while (progressedChild !== null) {
  48313. progressedChild.return = primaryChildFragment;
  48314. progressedChild = progressedChild.sibling;
  48315. }
  48316. }
  48317. var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
  48318. fallbackChildFragment.return = workInProgress;
  48319. primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the
  48320. // fallback children.
  48321. workInProgress.memoizedState = SUSPENDED_MARKER;
  48322. workInProgress.child = primaryChildFragment;
  48323. return fallbackChildFragment;
  48324. } else {
  48325. // Mount the primary children without an intermediate fragment fiber.
  48326. var nextPrimaryChildren = nextProps.children;
  48327. workInProgress.memoizedState = null;
  48328. return workInProgress.child = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
  48329. }
  48330. } else {
  48331. // This is an update. This branch is more complicated because we need to
  48332. // ensure the state of the primary children is preserved.
  48333. var prevState = current$$1.memoizedState;
  48334. if (prevState !== null) {
  48335. if (enableSuspenseServerRenderer) {
  48336. var _dehydrated = prevState.dehydrated;
  48337. if (_dehydrated !== null) {
  48338. if (!didSuspend) {
  48339. return updateDehydratedSuspenseComponent(current$$1, workInProgress, _dehydrated, prevState, renderExpirationTime);
  48340. } else if (workInProgress.memoizedState !== null) {
  48341. // Something suspended and we should still be in dehydrated mode.
  48342. // Leave the existing child in place.
  48343. workInProgress.child = current$$1.child; // The dehydrated completion pass expects this flag to be there
  48344. // but the normal suspense pass doesn't.
  48345. workInProgress.effectTag |= DidCapture;
  48346. return null;
  48347. } else {
  48348. // Suspended but we should no longer be in dehydrated mode.
  48349. // Therefore we now have to render the fallback. Wrap the children
  48350. // in a fragment fiber to keep them separate from the fallback
  48351. // children.
  48352. var _nextFallbackChildren = nextProps.fallback;
  48353. var _primaryChildFragment = createFiberFromFragment( // It shouldn't matter what the pending props are because we aren't
  48354. // going to render this fragment.
  48355. null, mode, NoWork, null);
  48356. _primaryChildFragment.return = workInProgress; // This is always null since we never want the previous child
  48357. // that we're not going to hydrate.
  48358. _primaryChildFragment.child = null;
  48359. if ((workInProgress.mode & BatchedMode) === NoMode) {
  48360. // Outside of batched mode, we commit the effects from the
  48361. // partially completed, timed-out tree, too.
  48362. var _progressedChild = _primaryChildFragment.child = workInProgress.child;
  48363. while (_progressedChild !== null) {
  48364. _progressedChild.return = _primaryChildFragment;
  48365. _progressedChild = _progressedChild.sibling;
  48366. }
  48367. } else {
  48368. // We will have dropped the effect list which contains the deletion.
  48369. // We need to reconcile to delete the current child.
  48370. reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime);
  48371. } // Because primaryChildFragment is a new fiber that we're inserting as the
  48372. // parent of a new tree, we need to set its treeBaseDuration.
  48373. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  48374. // treeBaseDuration is the sum of all the child tree base durations.
  48375. var treeBaseDuration = 0;
  48376. var hiddenChild = _primaryChildFragment.child;
  48377. while (hiddenChild !== null) {
  48378. treeBaseDuration += hiddenChild.treeBaseDuration;
  48379. hiddenChild = hiddenChild.sibling;
  48380. }
  48381. _primaryChildFragment.treeBaseDuration = treeBaseDuration;
  48382. } // Create a fragment from the fallback children, too.
  48383. var _fallbackChildFragment = createFiberFromFragment(_nextFallbackChildren, mode, renderExpirationTime, null);
  48384. _fallbackChildFragment.return = workInProgress;
  48385. _primaryChildFragment.sibling = _fallbackChildFragment;
  48386. _fallbackChildFragment.effectTag |= Placement;
  48387. _primaryChildFragment.childExpirationTime = NoWork;
  48388. workInProgress.memoizedState = SUSPENDED_MARKER;
  48389. workInProgress.child = _primaryChildFragment; // Skip the primary children, and continue working on the
  48390. // fallback children.
  48391. return _fallbackChildFragment;
  48392. }
  48393. }
  48394. } // The current tree already timed out. That means each child set is
  48395. // wrapped in a fragment fiber.
  48396. var currentPrimaryChildFragment = current$$1.child;
  48397. var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
  48398. if (nextDidTimeout) {
  48399. // Still timed out. Reuse the current primary children by cloning
  48400. // its fragment. We're going to skip over these entirely.
  48401. var _nextFallbackChildren2 = nextProps.fallback;
  48402. var _primaryChildFragment2 = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
  48403. _primaryChildFragment2.return = workInProgress;
  48404. if ((workInProgress.mode & BatchedMode) === NoMode) {
  48405. // Outside of batched mode, we commit the effects from the
  48406. // partially completed, timed-out tree, too.
  48407. var _progressedState = workInProgress.memoizedState;
  48408. var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
  48409. if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
  48410. _primaryChildFragment2.child = _progressedPrimaryChild;
  48411. var _progressedChild2 = _progressedPrimaryChild;
  48412. while (_progressedChild2 !== null) {
  48413. _progressedChild2.return = _primaryChildFragment2;
  48414. _progressedChild2 = _progressedChild2.sibling;
  48415. }
  48416. }
  48417. } // Because primaryChildFragment is a new fiber that we're inserting as the
  48418. // parent of a new tree, we need to set its treeBaseDuration.
  48419. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  48420. // treeBaseDuration is the sum of all the child tree base durations.
  48421. var _treeBaseDuration = 0;
  48422. var _hiddenChild = _primaryChildFragment2.child;
  48423. while (_hiddenChild !== null) {
  48424. _treeBaseDuration += _hiddenChild.treeBaseDuration;
  48425. _hiddenChild = _hiddenChild.sibling;
  48426. }
  48427. _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
  48428. } // Clone the fallback child fragment, too. These we'll continue
  48429. // working on.
  48430. var _fallbackChildFragment2 = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren2, currentFallbackChildFragment.expirationTime);
  48431. _fallbackChildFragment2.return = workInProgress;
  48432. _primaryChildFragment2.sibling = _fallbackChildFragment2;
  48433. _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
  48434. // fallback children.
  48435. workInProgress.memoizedState = SUSPENDED_MARKER;
  48436. workInProgress.child = _primaryChildFragment2;
  48437. return _fallbackChildFragment2;
  48438. } else {
  48439. // No longer suspended. Switch back to showing the primary children,
  48440. // and remove the intermediate fragment fiber.
  48441. var _nextPrimaryChildren = nextProps.children;
  48442. var currentPrimaryChild = currentPrimaryChildFragment.child;
  48443. var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime); // If this render doesn't suspend, we need to delete the fallback
  48444. // children. Wait until the complete phase, after we've confirmed the
  48445. // fallback is no longer needed.
  48446. // TODO: Would it be better to store the fallback fragment on
  48447. // the stateNode?
  48448. // Continue rendering the children, like we normally do.
  48449. workInProgress.memoizedState = null;
  48450. return workInProgress.child = primaryChild;
  48451. }
  48452. } else {
  48453. // The current tree has not already timed out. That means the primary
  48454. // children are not wrapped in a fragment fiber.
  48455. var _currentPrimaryChild = current$$1.child;
  48456. if (nextDidTimeout) {
  48457. // Timed out. Wrap the children in a fragment fiber to keep them
  48458. // separate from the fallback children.
  48459. var _nextFallbackChildren3 = nextProps.fallback;
  48460. var _primaryChildFragment3 = createFiberFromFragment( // It shouldn't matter what the pending props are because we aren't
  48461. // going to render this fragment.
  48462. null, mode, NoWork, null);
  48463. _primaryChildFragment3.return = workInProgress;
  48464. _primaryChildFragment3.child = _currentPrimaryChild;
  48465. if (_currentPrimaryChild !== null) {
  48466. _currentPrimaryChild.return = _primaryChildFragment3;
  48467. } // Even though we're creating a new fiber, there are no new children,
  48468. // because we're reusing an already mounted tree. So we don't need to
  48469. // schedule a placement.
  48470. // primaryChildFragment.effectTag |= Placement;
  48471. if ((workInProgress.mode & BatchedMode) === NoMode) {
  48472. // Outside of batched mode, we commit the effects from the
  48473. // partially completed, timed-out tree, too.
  48474. var _progressedState2 = workInProgress.memoizedState;
  48475. var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
  48476. _primaryChildFragment3.child = _progressedPrimaryChild2;
  48477. var _progressedChild3 = _progressedPrimaryChild2;
  48478. while (_progressedChild3 !== null) {
  48479. _progressedChild3.return = _primaryChildFragment3;
  48480. _progressedChild3 = _progressedChild3.sibling;
  48481. }
  48482. } // Because primaryChildFragment is a new fiber that we're inserting as the
  48483. // parent of a new tree, we need to set its treeBaseDuration.
  48484. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  48485. // treeBaseDuration is the sum of all the child tree base durations.
  48486. var _treeBaseDuration2 = 0;
  48487. var _hiddenChild2 = _primaryChildFragment3.child;
  48488. while (_hiddenChild2 !== null) {
  48489. _treeBaseDuration2 += _hiddenChild2.treeBaseDuration;
  48490. _hiddenChild2 = _hiddenChild2.sibling;
  48491. }
  48492. _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2;
  48493. } // Create a fragment from the fallback children, too.
  48494. var _fallbackChildFragment3 = createFiberFromFragment(_nextFallbackChildren3, mode, renderExpirationTime, null);
  48495. _fallbackChildFragment3.return = workInProgress;
  48496. _primaryChildFragment3.sibling = _fallbackChildFragment3;
  48497. _fallbackChildFragment3.effectTag |= Placement;
  48498. _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
  48499. // fallback children.
  48500. workInProgress.memoizedState = SUSPENDED_MARKER;
  48501. workInProgress.child = _primaryChildFragment3;
  48502. return _fallbackChildFragment3;
  48503. } else {
  48504. // Still haven't timed out. Continue rendering the children, like we
  48505. // normally do.
  48506. workInProgress.memoizedState = null;
  48507. var _nextPrimaryChildren2 = nextProps.children;
  48508. return workInProgress.child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
  48509. }
  48510. }
  48511. }
  48512. }
  48513. function retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime) {
  48514. // We're now not suspended nor dehydrated.
  48515. workInProgress.memoizedState = null; // Retry with the full children.
  48516. var nextProps = workInProgress.pendingProps;
  48517. var nextChildren = nextProps.children; // This will ensure that the children get Placement effects and
  48518. // that the old child gets a Deletion effect.
  48519. // We could also call forceUnmountCurrentAndReconcile.
  48520. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  48521. return workInProgress.child;
  48522. }
  48523. function mountDehydratedSuspenseComponent(workInProgress, suspenseInstance, renderExpirationTime) {
  48524. // During the first pass, we'll bail out and not drill into the children.
  48525. // Instead, we'll leave the content in place and try to hydrate it later.
  48526. if ((workInProgress.mode & BatchedMode) === NoMode) {
  48527. {
  48528. warning$1(false, 'Cannot hydrate Suspense in legacy mode. Switch from ' + 'ReactDOM.hydrate(element, container) to ' + 'ReactDOM.unstable_createSyncRoot(container, { hydrate: true })' + '.render(element) or remove the Suspense components from ' + 'the server rendered components.');
  48529. }
  48530. workInProgress.expirationTime = Sync;
  48531. } else if (isSuspenseInstanceFallback(suspenseInstance)) {
  48532. // This is a client-only boundary. Since we won't get any content from the server
  48533. // for this, we need to schedule that at a higher priority based on when it would
  48534. // have timed out. In theory we could render it in this pass but it would have the
  48535. // wrong priority associated with it and will prevent hydration of parent path.
  48536. // Instead, we'll leave work left on it to render it in a separate commit.
  48537. // TODO This time should be the time at which the server rendered response that is
  48538. // a parent to this boundary was displayed. However, since we currently don't have
  48539. // a protocol to transfer that time, we'll just estimate it by using the current
  48540. // time. This will mean that Suspense timeouts are slightly shifted to later than
  48541. // they should be.
  48542. var serverDisplayTime = requestCurrentTime(); // Schedule a normal pri update to render this content.
  48543. var newExpirationTime = computeAsyncExpiration(serverDisplayTime);
  48544. if (enableSchedulerTracing) {
  48545. markSpawnedWork(newExpirationTime);
  48546. }
  48547. workInProgress.expirationTime = newExpirationTime;
  48548. } else {
  48549. // We'll continue hydrating the rest at offscreen priority since we'll already
  48550. // be showing the right content coming from the server, it is no rush.
  48551. workInProgress.expirationTime = Never;
  48552. if (enableSchedulerTracing) {
  48553. markSpawnedWork(Never);
  48554. }
  48555. }
  48556. return null;
  48557. }
  48558. function updateDehydratedSuspenseComponent(current$$1, workInProgress, suspenseInstance, suspenseState, renderExpirationTime) {
  48559. // We should never be hydrating at this point because it is the first pass,
  48560. // but after we've already committed once.
  48561. warnIfHydrating();
  48562. if ((workInProgress.mode & BatchedMode) === NoMode) {
  48563. return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
  48564. }
  48565. if (isSuspenseInstanceFallback(suspenseInstance)) {
  48566. // This boundary is in a permanent fallback state. In this case, we'll never
  48567. // get an update and we'll never be able to hydrate the final content. Let's just try the
  48568. // client side render instead.
  48569. return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
  48570. } // We use childExpirationTime to indicate that a child might depend on context, so if
  48571. // any context has changed, we need to treat is as if the input might have changed.
  48572. var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
  48573. if (didReceiveUpdate || hasContextChanged$$1) {
  48574. // This boundary has changed since the first render. This means that we are now unable to
  48575. // hydrate it. We might still be able to hydrate it using an earlier expiration time, if
  48576. // we are rendering at lower expiration than sync.
  48577. if (renderExpirationTime < Sync) {
  48578. if (suspenseState.retryTime <= renderExpirationTime) {
  48579. // This render is even higher pri than we've seen before, let's try again
  48580. // at even higher pri.
  48581. var attemptHydrationAtExpirationTime = renderExpirationTime + 1;
  48582. suspenseState.retryTime = attemptHydrationAtExpirationTime;
  48583. scheduleWork(current$$1, attemptHydrationAtExpirationTime); // TODO: Early abort this render.
  48584. } else {// We have already tried to ping at a higher priority than we're rendering with
  48585. // so if we got here, we must have failed to hydrate at those levels. We must
  48586. // now give up. Instead, we're going to delete the whole subtree and instead inject
  48587. // a new real Suspense boundary to take its place, which may render content
  48588. // or fallback. This might suspend for a while and if it does we might still have
  48589. // an opportunity to hydrate before this pass commits.
  48590. }
  48591. } // If we have scheduled higher pri work above, this will probably just abort the render
  48592. // since we now have higher priority work, but in case it doesn't, we need to prepare to
  48593. // render something, if we time out. Even if that requires us to delete everything and
  48594. // skip hydration.
  48595. // Delay having to do this as long as the suspense timeout allows us.
  48596. renderDidSuspendDelayIfPossible();
  48597. return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
  48598. } else if (isSuspenseInstancePending(suspenseInstance)) {
  48599. // This component is still pending more data from the server, so we can't hydrate its
  48600. // content. We treat it as if this component suspended itself. It might seem as if
  48601. // we could just try to render it client-side instead. However, this will perform a
  48602. // lot of unnecessary work and is unlikely to complete since it often will suspend
  48603. // on missing data anyway. Additionally, the server might be able to render more
  48604. // than we can on the client yet. In that case we'd end up with more fallback states
  48605. // on the client than if we just leave it alone. If the server times out or errors
  48606. // these should update this boundary to the permanent Fallback state instead.
  48607. // Mark it as having captured (i.e. suspended).
  48608. workInProgress.effectTag |= DidCapture; // Leave the child in place. I.e. the dehydrated fragment.
  48609. workInProgress.child = current$$1.child; // Register a callback to retry this boundary once the server has sent the result.
  48610. registerSuspenseInstanceRetry(suspenseInstance, retryDehydratedSuspenseBoundary.bind(null, current$$1));
  48611. return null;
  48612. } else {
  48613. // This is the first attempt.
  48614. reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress, suspenseInstance);
  48615. var nextProps = workInProgress.pendingProps;
  48616. var nextChildren = nextProps.children;
  48617. var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  48618. var node = child;
  48619. while (node) {
  48620. // Mark each child as hydrating. This is a fast path to know whether this
  48621. // tree is part of a hydrating tree. This is used to determine if a child
  48622. // node has fully mounted yet, and for scheduling event replaying.
  48623. // Conceptually this is similar to Placement in that a new subtree is
  48624. // inserted into the React tree here. It just happens to not need DOM
  48625. // mutations because it already exists.
  48626. node.effectTag |= Hydrating;
  48627. node = node.sibling;
  48628. }
  48629. workInProgress.child = child;
  48630. return workInProgress.child;
  48631. }
  48632. }
  48633. function propagateSuspenseContextChange(workInProgress, firstChild, renderExpirationTime) {
  48634. // Mark any Suspense boundaries with fallbacks as having work to do.
  48635. // If they were previously forced into fallbacks, they may now be able
  48636. // to unblock.
  48637. var node = firstChild;
  48638. while (node !== null) {
  48639. if (node.tag === SuspenseComponent) {
  48640. var state = node.memoizedState;
  48641. if (state !== null) {
  48642. if (node.expirationTime < renderExpirationTime) {
  48643. node.expirationTime = renderExpirationTime;
  48644. }
  48645. var alternate = node.alternate;
  48646. if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
  48647. alternate.expirationTime = renderExpirationTime;
  48648. }
  48649. scheduleWorkOnParentPath(node.return, renderExpirationTime);
  48650. }
  48651. } else if (node.child !== null) {
  48652. node.child.return = node;
  48653. node = node.child;
  48654. continue;
  48655. }
  48656. if (node === workInProgress) {
  48657. return;
  48658. }
  48659. while (node.sibling === null) {
  48660. if (node.return === null || node.return === workInProgress) {
  48661. return;
  48662. }
  48663. node = node.return;
  48664. }
  48665. node.sibling.return = node.return;
  48666. node = node.sibling;
  48667. }
  48668. }
  48669. function findLastContentRow(firstChild) {
  48670. // This is going to find the last row among these children that is already
  48671. // showing content on the screen, as opposed to being in fallback state or
  48672. // new. If a row has multiple Suspense boundaries, any of them being in the
  48673. // fallback state, counts as the whole row being in a fallback state.
  48674. // Note that the "rows" will be workInProgress, but any nested children
  48675. // will still be current since we haven't rendered them yet. The mounted
  48676. // order may not be the same as the new order. We use the new order.
  48677. var row = firstChild;
  48678. var lastContentRow = null;
  48679. while (row !== null) {
  48680. var currentRow = row.alternate; // New rows can't be content rows.
  48681. if (currentRow !== null && findFirstSuspended(currentRow) === null) {
  48682. lastContentRow = row;
  48683. }
  48684. row = row.sibling;
  48685. }
  48686. return lastContentRow;
  48687. }
  48688. function validateRevealOrder(revealOrder) {
  48689. {
  48690. if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) {
  48691. didWarnAboutRevealOrder[revealOrder] = true;
  48692. if (typeof revealOrder === 'string') {
  48693. switch (revealOrder.toLowerCase()) {
  48694. case 'together':
  48695. case 'forwards':
  48696. case 'backwards':
  48697. {
  48698. warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
  48699. break;
  48700. }
  48701. case 'forward':
  48702. case 'backward':
  48703. {
  48704. warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
  48705. break;
  48706. }
  48707. default:
  48708. warning$1(false, '"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
  48709. break;
  48710. }
  48711. } else {
  48712. warning$1(false, '%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
  48713. }
  48714. }
  48715. }
  48716. }
  48717. function validateTailOptions(tailMode, revealOrder) {
  48718. {
  48719. if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
  48720. if (tailMode !== 'collapsed' && tailMode !== 'hidden') {
  48721. didWarnAboutTailOptions[tailMode] = true;
  48722. warning$1(false, '"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode);
  48723. } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') {
  48724. didWarnAboutTailOptions[tailMode] = true;
  48725. warning$1(false, '<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode);
  48726. }
  48727. }
  48728. }
  48729. }
  48730. function validateSuspenseListNestedChild(childSlot, index) {
  48731. {
  48732. var isArray = Array.isArray(childSlot);
  48733. var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function';
  48734. if (isArray || isIterable) {
  48735. var type = isArray ? 'array' : 'iterable';
  48736. warning$1(false, '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);
  48737. return false;
  48738. }
  48739. }
  48740. return true;
  48741. }
  48742. function validateSuspenseListChildren(children, revealOrder) {
  48743. {
  48744. if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) {
  48745. if (Array.isArray(children)) {
  48746. for (var i = 0; i < children.length; i++) {
  48747. if (!validateSuspenseListNestedChild(children[i], i)) {
  48748. return;
  48749. }
  48750. }
  48751. } else {
  48752. var iteratorFn = getIteratorFn(children);
  48753. if (typeof iteratorFn === 'function') {
  48754. var childrenIterator = iteratorFn.call(children);
  48755. if (childrenIterator) {
  48756. var step = childrenIterator.next();
  48757. var _i = 0;
  48758. for (; !step.done; step = childrenIterator.next()) {
  48759. if (!validateSuspenseListNestedChild(step.value, _i)) {
  48760. return;
  48761. }
  48762. _i++;
  48763. }
  48764. }
  48765. } else {
  48766. warning$1(false, '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);
  48767. }
  48768. }
  48769. }
  48770. }
  48771. }
  48772. function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode) {
  48773. var renderState = workInProgress.memoizedState;
  48774. if (renderState === null) {
  48775. workInProgress.memoizedState = {
  48776. isBackwards: isBackwards,
  48777. rendering: null,
  48778. last: lastContentRow,
  48779. tail: tail,
  48780. tailExpiration: 0,
  48781. tailMode: tailMode
  48782. };
  48783. } else {
  48784. // We can reuse the existing object from previous renders.
  48785. renderState.isBackwards = isBackwards;
  48786. renderState.rendering = null;
  48787. renderState.last = lastContentRow;
  48788. renderState.tail = tail;
  48789. renderState.tailExpiration = 0;
  48790. renderState.tailMode = tailMode;
  48791. }
  48792. } // This can end up rendering this component multiple passes.
  48793. // The first pass splits the children fibers into two sets. A head and tail.
  48794. // We first render the head. If anything is in fallback state, we do another
  48795. // pass through beginWork to rerender all children (including the tail) with
  48796. // the force suspend context. If the first render didn't have anything in
  48797. // in fallback state. Then we render each row in the tail one-by-one.
  48798. // That happens in the completeWork phase without going back to beginWork.
  48799. function updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime) {
  48800. var nextProps = workInProgress.pendingProps;
  48801. var revealOrder = nextProps.revealOrder;
  48802. var tailMode = nextProps.tail;
  48803. var newChildren = nextProps.children;
  48804. validateRevealOrder(revealOrder);
  48805. validateTailOptions(tailMode, revealOrder);
  48806. validateSuspenseListChildren(newChildren, revealOrder);
  48807. reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
  48808. var suspenseContext = suspenseStackCursor.current;
  48809. var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
  48810. if (shouldForceFallback) {
  48811. suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
  48812. workInProgress.effectTag |= DidCapture;
  48813. } else {
  48814. var didSuspendBefore = current$$1 !== null && (current$$1.effectTag & DidCapture) !== NoEffect;
  48815. if (didSuspendBefore) {
  48816. // If we previously forced a fallback, we need to schedule work
  48817. // on any nested boundaries to let them know to try to render
  48818. // again. This is the same as context updating.
  48819. propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime);
  48820. }
  48821. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  48822. }
  48823. pushSuspenseContext(workInProgress, suspenseContext);
  48824. if ((workInProgress.mode & BatchedMode) === NoMode) {
  48825. // Outside of batched mode, SuspenseList doesn't work so we just
  48826. // use make it a noop by treating it as the default revealOrder.
  48827. workInProgress.memoizedState = null;
  48828. } else {
  48829. switch (revealOrder) {
  48830. case 'forwards':
  48831. {
  48832. var lastContentRow = findLastContentRow(workInProgress.child);
  48833. var tail;
  48834. if (lastContentRow === null) {
  48835. // The whole list is part of the tail.
  48836. // TODO: We could fast path by just rendering the tail now.
  48837. tail = workInProgress.child;
  48838. workInProgress.child = null;
  48839. } else {
  48840. // Disconnect the tail rows after the content row.
  48841. // We're going to render them separately later.
  48842. tail = lastContentRow.sibling;
  48843. lastContentRow.sibling = null;
  48844. }
  48845. initSuspenseListRenderState(workInProgress, false, // isBackwards
  48846. tail, lastContentRow, tailMode);
  48847. break;
  48848. }
  48849. case 'backwards':
  48850. {
  48851. // We're going to find the first row that has existing content.
  48852. // At the same time we're going to reverse the list of everything
  48853. // we pass in the meantime. That's going to be our tail in reverse
  48854. // order.
  48855. var _tail = null;
  48856. var row = workInProgress.child;
  48857. workInProgress.child = null;
  48858. while (row !== null) {
  48859. var currentRow = row.alternate; // New rows can't be content rows.
  48860. if (currentRow !== null && findFirstSuspended(currentRow) === null) {
  48861. // This is the beginning of the main content.
  48862. workInProgress.child = row;
  48863. break;
  48864. }
  48865. var nextRow = row.sibling;
  48866. row.sibling = _tail;
  48867. _tail = row;
  48868. row = nextRow;
  48869. } // TODO: If workInProgress.child is null, we can continue on the tail immediately.
  48870. initSuspenseListRenderState(workInProgress, true, // isBackwards
  48871. _tail, null, // last
  48872. tailMode);
  48873. break;
  48874. }
  48875. case 'together':
  48876. {
  48877. initSuspenseListRenderState(workInProgress, false, // isBackwards
  48878. null, // tail
  48879. null, // last
  48880. undefined);
  48881. break;
  48882. }
  48883. default:
  48884. {
  48885. // The default reveal order is the same as not having
  48886. // a boundary.
  48887. workInProgress.memoizedState = null;
  48888. }
  48889. }
  48890. }
  48891. return workInProgress.child;
  48892. }
  48893. function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
  48894. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  48895. var nextChildren = workInProgress.pendingProps;
  48896. if (current$$1 === null) {
  48897. // Portals are special because we don't append the children during mount
  48898. // but at commit. Therefore we need to track insertions which the normal
  48899. // flow doesn't do during mount. This doesn't happen at the root because
  48900. // the root always starts with a "current" with a null child.
  48901. // TODO: Consider unifying this with how the root works.
  48902. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  48903. } else {
  48904. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  48905. }
  48906. return workInProgress.child;
  48907. }
  48908. function updateContextProvider(current$$1, workInProgress, renderExpirationTime) {
  48909. var providerType = workInProgress.type;
  48910. var context = providerType._context;
  48911. var newProps = workInProgress.pendingProps;
  48912. var oldProps = workInProgress.memoizedProps;
  48913. var newValue = newProps.value;
  48914. {
  48915. var providerPropTypes = workInProgress.type.propTypes;
  48916. if (providerPropTypes) {
  48917. checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
  48918. }
  48919. }
  48920. pushProvider(workInProgress, newValue);
  48921. if (oldProps !== null) {
  48922. var oldValue = oldProps.value;
  48923. var changedBits = calculateChangedBits(context, newValue, oldValue);
  48924. if (changedBits === 0) {
  48925. // No change. Bailout early if children are the same.
  48926. if (oldProps.children === newProps.children && !hasContextChanged()) {
  48927. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  48928. }
  48929. } else {
  48930. // The context value changed. Search for matching consumers and schedule
  48931. // them to update.
  48932. propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
  48933. }
  48934. }
  48935. var newChildren = newProps.children;
  48936. reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
  48937. return workInProgress.child;
  48938. }
  48939. var hasWarnedAboutUsingContextAsConsumer = false;
  48940. function updateContextConsumer(current$$1, workInProgress, renderExpirationTime) {
  48941. var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In
  48942. // DEV mode, we create a separate object for Context.Consumer that acts
  48943. // like a proxy to Context. This proxy object adds unnecessary code in PROD
  48944. // so we use the old behaviour (Context.Consumer references Context) to
  48945. // reduce size and overhead. The separate object references context via
  48946. // a property called "_context", which also gives us the ability to check
  48947. // in DEV mode if this property exists or not and warn if it does not.
  48948. {
  48949. if (context._context === undefined) {
  48950. // This may be because it's a Context (rather than a Consumer).
  48951. // Or it may be because it's older React where they're the same thing.
  48952. // We only want to warn if we're sure it's a new React.
  48953. if (context !== context.Consumer) {
  48954. if (!hasWarnedAboutUsingContextAsConsumer) {
  48955. hasWarnedAboutUsingContextAsConsumer = true;
  48956. warning$1(false, 'Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
  48957. }
  48958. }
  48959. } else {
  48960. context = context._context;
  48961. }
  48962. }
  48963. var newProps = workInProgress.pendingProps;
  48964. var render = newProps.children;
  48965. {
  48966. !(typeof render === 'function') ? warningWithoutStack$1(false, '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.') : void 0;
  48967. }
  48968. prepareToReadContext(workInProgress, renderExpirationTime);
  48969. var newValue = readContext(context, newProps.unstable_observedBits);
  48970. var newChildren;
  48971. {
  48972. ReactCurrentOwner$3.current = workInProgress;
  48973. setCurrentPhase('render');
  48974. newChildren = render(newValue);
  48975. setCurrentPhase(null);
  48976. } // React DevTools reads this flag.
  48977. workInProgress.effectTag |= PerformedWork;
  48978. reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
  48979. return workInProgress.child;
  48980. }
  48981. function updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime) {
  48982. var fundamentalImpl = workInProgress.type.impl;
  48983. if (fundamentalImpl.reconcileChildren === false) {
  48984. return null;
  48985. }
  48986. var nextProps = workInProgress.pendingProps;
  48987. var nextChildren = nextProps.children;
  48988. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  48989. return workInProgress.child;
  48990. }
  48991. function updateScopeComponent(current$$1, workInProgress, renderExpirationTime) {
  48992. var nextProps = workInProgress.pendingProps;
  48993. var nextChildren = nextProps.children;
  48994. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  48995. return workInProgress.child;
  48996. }
  48997. function markWorkInProgressReceivedUpdate() {
  48998. didReceiveUpdate = true;
  48999. }
  49000. function bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime) {
  49001. cancelWorkTimer(workInProgress);
  49002. if (current$$1 !== null) {
  49003. // Reuse previous dependencies
  49004. workInProgress.dependencies = current$$1.dependencies;
  49005. }
  49006. if (enableProfilerTimer) {
  49007. // Don't update "base" render times for bailouts.
  49008. stopProfilerTimerIfRunning(workInProgress);
  49009. }
  49010. var updateExpirationTime = workInProgress.expirationTime;
  49011. if (updateExpirationTime !== NoWork) {
  49012. markUnprocessedUpdateTime(updateExpirationTime);
  49013. } // Check if the children have any pending work.
  49014. var childExpirationTime = workInProgress.childExpirationTime;
  49015. if (childExpirationTime < renderExpirationTime) {
  49016. // The children don't have any work either. We can skip them.
  49017. // TODO: Once we add back resuming, we should check if the children are
  49018. // a work-in-progress set. If so, we need to transfer their effects.
  49019. return null;
  49020. } else {
  49021. // This fiber doesn't have work, but its subtree does. Clone the child
  49022. // fibers and continue.
  49023. cloneChildFibers(current$$1, workInProgress);
  49024. return workInProgress.child;
  49025. }
  49026. }
  49027. function remountFiber(current$$1, oldWorkInProgress, newWorkInProgress) {
  49028. {
  49029. var returnFiber = oldWorkInProgress.return;
  49030. if (returnFiber === null) {
  49031. throw new Error('Cannot swap the root fiber.');
  49032. } // Disconnect from the old current.
  49033. // It will get deleted.
  49034. current$$1.alternate = null;
  49035. oldWorkInProgress.alternate = null; // Connect to the new tree.
  49036. newWorkInProgress.index = oldWorkInProgress.index;
  49037. newWorkInProgress.sibling = oldWorkInProgress.sibling;
  49038. newWorkInProgress.return = oldWorkInProgress.return;
  49039. newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it.
  49040. if (oldWorkInProgress === returnFiber.child) {
  49041. returnFiber.child = newWorkInProgress;
  49042. } else {
  49043. var prevSibling = returnFiber.child;
  49044. if (prevSibling === null) {
  49045. throw new Error('Expected parent to have a child.');
  49046. }
  49047. while (prevSibling.sibling !== oldWorkInProgress) {
  49048. prevSibling = prevSibling.sibling;
  49049. if (prevSibling === null) {
  49050. throw new Error('Expected to find the previous sibling.');
  49051. }
  49052. }
  49053. prevSibling.sibling = newWorkInProgress;
  49054. } // Delete the old fiber and place the new one.
  49055. // Since the old fiber is disconnected, we have to schedule it manually.
  49056. var last = returnFiber.lastEffect;
  49057. if (last !== null) {
  49058. last.nextEffect = current$$1;
  49059. returnFiber.lastEffect = current$$1;
  49060. } else {
  49061. returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
  49062. }
  49063. current$$1.nextEffect = null;
  49064. current$$1.effectTag = Deletion;
  49065. newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber.
  49066. return newWorkInProgress;
  49067. }
  49068. }
  49069. function beginWork$1(current$$1, workInProgress, renderExpirationTime) {
  49070. var updateExpirationTime = workInProgress.expirationTime;
  49071. {
  49072. if (workInProgress._debugNeedsRemount && current$$1 !== null) {
  49073. // This will restart the begin phase with a new fiber.
  49074. return remountFiber(current$$1, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime));
  49075. }
  49076. }
  49077. if (current$$1 !== null) {
  49078. var oldProps = current$$1.memoizedProps;
  49079. var newProps = workInProgress.pendingProps;
  49080. if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload:
  49081. workInProgress.type !== current$$1.type)) {
  49082. // If props or context changed, mark the fiber as having performed work.
  49083. // This may be unset if the props are determined to be equal later (memo).
  49084. didReceiveUpdate = true;
  49085. } else if (updateExpirationTime < renderExpirationTime) {
  49086. didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering
  49087. // the begin phase. There's still some bookkeeping we that needs to be done
  49088. // in this optimized path, mostly pushing stuff onto the stack.
  49089. switch (workInProgress.tag) {
  49090. case HostRoot:
  49091. pushHostRootContext(workInProgress);
  49092. resetHydrationState();
  49093. break;
  49094. case HostComponent:
  49095. pushHostContext(workInProgress);
  49096. if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type, newProps)) {
  49097. if (enableSchedulerTracing) {
  49098. markSpawnedWork(Never);
  49099. } // Schedule this fiber to re-render at offscreen priority. Then bailout.
  49100. workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
  49101. return null;
  49102. }
  49103. break;
  49104. case ClassComponent:
  49105. {
  49106. var Component = workInProgress.type;
  49107. if (isContextProvider(Component)) {
  49108. pushContextProvider(workInProgress);
  49109. }
  49110. break;
  49111. }
  49112. case HostPortal:
  49113. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  49114. break;
  49115. case ContextProvider:
  49116. {
  49117. var newValue = workInProgress.memoizedProps.value;
  49118. pushProvider(workInProgress, newValue);
  49119. break;
  49120. }
  49121. case Profiler:
  49122. if (enableProfilerTimer) {
  49123. workInProgress.effectTag |= Update;
  49124. }
  49125. break;
  49126. case SuspenseComponent:
  49127. {
  49128. var state = workInProgress.memoizedState;
  49129. if (state !== null) {
  49130. if (enableSuspenseServerRenderer) {
  49131. if (state.dehydrated !== null) {
  49132. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // We know that this component will suspend again because if it has
  49133. // been unsuspended it has committed as a resolved Suspense component.
  49134. // If it needs to be retried, it should have work scheduled on it.
  49135. workInProgress.effectTag |= DidCapture;
  49136. break;
  49137. }
  49138. } // If this boundary is currently timed out, we need to decide
  49139. // whether to retry the primary children, or to skip over it and
  49140. // go straight to the fallback. Check the priority of the primary
  49141. // child fragment.
  49142. var primaryChildFragment = workInProgress.child;
  49143. var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
  49144. if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
  49145. // The primary children have pending work. Use the normal path
  49146. // to attempt to render the primary children again.
  49147. return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
  49148. } else {
  49149. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient
  49150. // priority. Bailout.
  49151. var child = bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  49152. if (child !== null) {
  49153. // The fallback children have pending work. Skip over the
  49154. // primary children and work on the fallback.
  49155. return child.sibling;
  49156. } else {
  49157. return null;
  49158. }
  49159. }
  49160. } else {
  49161. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
  49162. }
  49163. break;
  49164. }
  49165. case SuspenseListComponent:
  49166. {
  49167. var didSuspendBefore = (current$$1.effectTag & DidCapture) !== NoEffect;
  49168. var hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
  49169. if (didSuspendBefore) {
  49170. if (hasChildWork) {
  49171. // If something was in fallback state last time, and we have all the
  49172. // same children then we're still in progressive loading state.
  49173. // Something might get unblocked by state updates or retries in the
  49174. // tree which will affect the tail. So we need to use the normal
  49175. // path to compute the correct tail.
  49176. return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
  49177. } // If none of the children had any work, that means that none of
  49178. // them got retried so they'll still be blocked in the same way
  49179. // as before. We can fast bail out.
  49180. workInProgress.effectTag |= DidCapture;
  49181. } // If nothing suspended before and we're rendering the same children,
  49182. // then the tail doesn't matter. Anything new that suspends will work
  49183. // in the "together" mode, so we can continue from the state we had.
  49184. var renderState = workInProgress.memoizedState;
  49185. if (renderState !== null) {
  49186. // Reset to the "together" mode in case we've started a different
  49187. // update in the past but didn't complete it.
  49188. renderState.rendering = null;
  49189. renderState.tail = null;
  49190. }
  49191. pushSuspenseContext(workInProgress, suspenseStackCursor.current);
  49192. if (hasChildWork) {
  49193. break;
  49194. } else {
  49195. // If none of the children had any work, that means that none of
  49196. // them got retried so they'll still be blocked in the same way
  49197. // as before. We can fast bail out.
  49198. return null;
  49199. }
  49200. }
  49201. }
  49202. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  49203. } else {
  49204. // An update was scheduled on this fiber, but there are no new props
  49205. // nor legacy context. Set this to false. If an update queue or context
  49206. // consumer produces a changed value, it will set this to true. Otherwise,
  49207. // the component will assume the children have not changed and bail out.
  49208. didReceiveUpdate = false;
  49209. }
  49210. } else {
  49211. didReceiveUpdate = false;
  49212. } // Before entering the begin phase, clear the expiration time.
  49213. workInProgress.expirationTime = NoWork;
  49214. switch (workInProgress.tag) {
  49215. case IndeterminateComponent:
  49216. {
  49217. return mountIndeterminateComponent(current$$1, workInProgress, workInProgress.type, renderExpirationTime);
  49218. }
  49219. case LazyComponent:
  49220. {
  49221. var elementType = workInProgress.elementType;
  49222. return mountLazyComponent(current$$1, workInProgress, elementType, updateExpirationTime, renderExpirationTime);
  49223. }
  49224. case FunctionComponent:
  49225. {
  49226. var _Component = workInProgress.type;
  49227. var unresolvedProps = workInProgress.pendingProps;
  49228. var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
  49229. return updateFunctionComponent(current$$1, workInProgress, _Component, resolvedProps, renderExpirationTime);
  49230. }
  49231. case ClassComponent:
  49232. {
  49233. var _Component2 = workInProgress.type;
  49234. var _unresolvedProps = workInProgress.pendingProps;
  49235. var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
  49236. return updateClassComponent(current$$1, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
  49237. }
  49238. case HostRoot:
  49239. return updateHostRoot(current$$1, workInProgress, renderExpirationTime);
  49240. case HostComponent:
  49241. return updateHostComponent(current$$1, workInProgress, renderExpirationTime);
  49242. case HostText:
  49243. return updateHostText(current$$1, workInProgress);
  49244. case SuspenseComponent:
  49245. return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
  49246. case HostPortal:
  49247. return updatePortalComponent(current$$1, workInProgress, renderExpirationTime);
  49248. case ForwardRef:
  49249. {
  49250. var type = workInProgress.type;
  49251. var _unresolvedProps2 = workInProgress.pendingProps;
  49252. var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
  49253. return updateForwardRef(current$$1, workInProgress, type, _resolvedProps2, renderExpirationTime);
  49254. }
  49255. case Fragment:
  49256. return updateFragment(current$$1, workInProgress, renderExpirationTime);
  49257. case Mode:
  49258. return updateMode(current$$1, workInProgress, renderExpirationTime);
  49259. case Profiler:
  49260. return updateProfiler(current$$1, workInProgress, renderExpirationTime);
  49261. case ContextProvider:
  49262. return updateContextProvider(current$$1, workInProgress, renderExpirationTime);
  49263. case ContextConsumer:
  49264. return updateContextConsumer(current$$1, workInProgress, renderExpirationTime);
  49265. case MemoComponent:
  49266. {
  49267. var _type2 = workInProgress.type;
  49268. var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.
  49269. var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
  49270. {
  49271. if (workInProgress.type !== workInProgress.elementType) {
  49272. var outerPropTypes = _type2.propTypes;
  49273. if (outerPropTypes) {
  49274. checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only
  49275. 'prop', getComponentName(_type2), getCurrentFiberStackInDev);
  49276. }
  49277. }
  49278. }
  49279. _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
  49280. return updateMemoComponent(current$$1, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);
  49281. }
  49282. case SimpleMemoComponent:
  49283. {
  49284. return updateSimpleMemoComponent(current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
  49285. }
  49286. case IncompleteClassComponent:
  49287. {
  49288. var _Component3 = workInProgress.type;
  49289. var _unresolvedProps4 = workInProgress.pendingProps;
  49290. var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
  49291. return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
  49292. }
  49293. case SuspenseListComponent:
  49294. {
  49295. return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
  49296. }
  49297. case FundamentalComponent:
  49298. {
  49299. if (enableFundamentalAPI) {
  49300. return updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime);
  49301. }
  49302. break;
  49303. }
  49304. case ScopeComponent:
  49305. {
  49306. if (enableScopeAPI) {
  49307. return updateScopeComponent(current$$1, workInProgress, renderExpirationTime);
  49308. }
  49309. break;
  49310. }
  49311. }
  49312. (function () {
  49313. {
  49314. {
  49315. throw ReactError(Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue."));
  49316. }
  49317. }
  49318. })();
  49319. }
  49320. function createFundamentalStateInstance(currentFiber, props, impl, state) {
  49321. return {
  49322. currentFiber: currentFiber,
  49323. impl: impl,
  49324. instance: null,
  49325. prevProps: null,
  49326. props: props,
  49327. state: state
  49328. };
  49329. }
  49330. function isFiberSuspenseAndTimedOut(fiber) {
  49331. return fiber.tag === SuspenseComponent && fiber.memoizedState !== null;
  49332. }
  49333. function getSuspenseFallbackChild(fiber) {
  49334. return fiber.child.sibling.child;
  49335. }
  49336. function collectScopedNodes(node, fn, scopedNodes) {
  49337. if (enableScopeAPI) {
  49338. if (node.tag === HostComponent) {
  49339. var _type = node.type,
  49340. memoizedProps = node.memoizedProps;
  49341. if (fn(_type, memoizedProps) === true) {
  49342. scopedNodes.push(getPublicInstance(node.stateNode));
  49343. }
  49344. }
  49345. var child = node.child;
  49346. if (isFiberSuspenseAndTimedOut(node)) {
  49347. child = getSuspenseFallbackChild(node);
  49348. }
  49349. if (child !== null) {
  49350. collectScopedNodesFromChildren(child, fn, scopedNodes);
  49351. }
  49352. }
  49353. }
  49354. function collectScopedNodesFromChildren(startingChild, fn, scopedNodes) {
  49355. var child = startingChild;
  49356. while (child !== null) {
  49357. collectScopedNodes(child, fn, scopedNodes);
  49358. child = child.sibling;
  49359. }
  49360. }
  49361. function collectNearestScopeMethods(node, scope, childrenScopes) {
  49362. if (isValidScopeNode(node, scope)) {
  49363. childrenScopes.push(node.stateNode.methods);
  49364. } else {
  49365. var child = node.child;
  49366. if (isFiberSuspenseAndTimedOut(node)) {
  49367. child = getSuspenseFallbackChild(node);
  49368. }
  49369. if (child !== null) {
  49370. collectNearestChildScopeMethods(child, scope, childrenScopes);
  49371. }
  49372. }
  49373. }
  49374. function collectNearestChildScopeMethods(startingChild, scope, childrenScopes) {
  49375. var child = startingChild;
  49376. while (child !== null) {
  49377. collectNearestScopeMethods(child, scope, childrenScopes);
  49378. child = child.sibling;
  49379. }
  49380. }
  49381. function isValidScopeNode(node, scope) {
  49382. return node.tag === ScopeComponent && node.type === scope;
  49383. }
  49384. function createScopeMethods(scope, instance) {
  49385. var fn = scope.fn;
  49386. return {
  49387. getChildren: function () {
  49388. var currentFiber = instance.fiber;
  49389. var child = currentFiber.child;
  49390. var childrenScopes = [];
  49391. if (child !== null) {
  49392. collectNearestChildScopeMethods(child, scope, childrenScopes);
  49393. }
  49394. return childrenScopes.length === 0 ? null : childrenScopes;
  49395. },
  49396. getChildrenFromRoot: function () {
  49397. var currentFiber = instance.fiber;
  49398. var node = currentFiber;
  49399. while (node !== null) {
  49400. var parent = node.return;
  49401. if (parent === null) {
  49402. break;
  49403. }
  49404. node = parent;
  49405. if (node.tag === ScopeComponent && node.type === scope) {
  49406. break;
  49407. }
  49408. }
  49409. var childrenScopes = [];
  49410. collectNearestChildScopeMethods(node.child, scope, childrenScopes);
  49411. return childrenScopes.length === 0 ? null : childrenScopes;
  49412. },
  49413. getParent: function () {
  49414. var node = instance.fiber.return;
  49415. while (node !== null) {
  49416. if (node.tag === ScopeComponent && node.type === scope) {
  49417. return node.stateNode.methods;
  49418. }
  49419. node = node.return;
  49420. }
  49421. return null;
  49422. },
  49423. getProps: function () {
  49424. var currentFiber = instance.fiber;
  49425. return currentFiber.memoizedProps;
  49426. },
  49427. getScopedNodes: function () {
  49428. var currentFiber = instance.fiber;
  49429. var child = currentFiber.child;
  49430. var scopedNodes = [];
  49431. if (child !== null) {
  49432. collectScopedNodesFromChildren(child, fn, scopedNodes);
  49433. }
  49434. return scopedNodes.length === 0 ? null : scopedNodes;
  49435. }
  49436. };
  49437. }
  49438. function markUpdate(workInProgress) {
  49439. // Tag the fiber with an update effect. This turns a Placement into
  49440. // a PlacementAndUpdate.
  49441. workInProgress.effectTag |= Update;
  49442. }
  49443. function markRef$1(workInProgress) {
  49444. workInProgress.effectTag |= Ref;
  49445. }
  49446. var appendAllChildren;
  49447. var updateHostContainer;
  49448. var updateHostComponent$1;
  49449. var updateHostText$1;
  49450. if (supportsMutation) {
  49451. // Mutation mode
  49452. appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
  49453. // We only have the top Fiber that was created but we need recurse down its
  49454. // children to find all the terminal nodes.
  49455. var node = workInProgress.child;
  49456. while (node !== null) {
  49457. if (node.tag === HostComponent || node.tag === HostText) {
  49458. appendInitialChild(parent, node.stateNode);
  49459. } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
  49460. appendInitialChild(parent, node.stateNode.instance);
  49461. } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
  49462. // down its children. Instead, we'll get insertions from each child in
  49463. // the portal directly.
  49464. } else if (node.child !== null) {
  49465. node.child.return = node;
  49466. node = node.child;
  49467. continue;
  49468. }
  49469. if (node === workInProgress) {
  49470. return;
  49471. }
  49472. while (node.sibling === null) {
  49473. if (node.return === null || node.return === workInProgress) {
  49474. return;
  49475. }
  49476. node = node.return;
  49477. }
  49478. node.sibling.return = node.return;
  49479. node = node.sibling;
  49480. }
  49481. };
  49482. updateHostContainer = function (workInProgress) {// Noop
  49483. };
  49484. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  49485. // If we have an alternate, that means this is an update and we need to
  49486. // schedule a side-effect to do the updates.
  49487. var oldProps = current.memoizedProps;
  49488. if (oldProps === newProps) {
  49489. // In mutation mode, this is sufficient for a bailout because
  49490. // we won't touch this node even if children changed.
  49491. return;
  49492. } // If we get updated because one of our children updated, we don't
  49493. // have newProps so we'll have to reuse them.
  49494. // TODO: Split the update API as separate for the props vs. children.
  49495. // Even better would be if children weren't special cased at all tho.
  49496. var instance = workInProgress.stateNode;
  49497. var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host
  49498. // component is hitting the resume path. Figure out why. Possibly
  49499. // related to `hidden`.
  49500. var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); // TODO: Type this specific to this type of component.
  49501. workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
  49502. // is a new ref we mark this as an update. All the work is done in commitWork.
  49503. if (updatePayload) {
  49504. markUpdate(workInProgress);
  49505. }
  49506. };
  49507. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  49508. // If the text differs, mark it as an update. All the work in done in commitWork.
  49509. if (oldText !== newText) {
  49510. markUpdate(workInProgress);
  49511. }
  49512. };
  49513. } else if (supportsPersistence) {
  49514. // Persistent host tree mode
  49515. appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
  49516. // We only have the top Fiber that was created but we need recurse down its
  49517. // children to find all the terminal nodes.
  49518. var node = workInProgress.child;
  49519. while (node !== null) {
  49520. // eslint-disable-next-line no-labels
  49521. branches: if (node.tag === HostComponent) {
  49522. var instance = node.stateNode;
  49523. if (needsVisibilityToggle && isHidden) {
  49524. // This child is inside a timed out tree. Hide it.
  49525. var props = node.memoizedProps;
  49526. var type = node.type;
  49527. instance = cloneHiddenInstance(instance, type, props, node);
  49528. }
  49529. appendInitialChild(parent, instance);
  49530. } else if (node.tag === HostText) {
  49531. var _instance = node.stateNode;
  49532. if (needsVisibilityToggle && isHidden) {
  49533. // This child is inside a timed out tree. Hide it.
  49534. var text = node.memoizedProps;
  49535. _instance = cloneHiddenTextInstance(_instance, text, node);
  49536. }
  49537. appendInitialChild(parent, _instance);
  49538. } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
  49539. var _instance2 = node.stateNode.instance;
  49540. if (needsVisibilityToggle && isHidden) {
  49541. // This child is inside a timed out tree. Hide it.
  49542. var _props = node.memoizedProps;
  49543. var _type = node.type;
  49544. _instance2 = cloneHiddenInstance(_instance2, _type, _props, node);
  49545. }
  49546. appendInitialChild(parent, _instance2);
  49547. } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
  49548. // down its children. Instead, we'll get insertions from each child in
  49549. // the portal directly.
  49550. } else if (node.tag === SuspenseComponent) {
  49551. if ((node.effectTag & Update) !== NoEffect) {
  49552. // Need to toggle the visibility of the primary children.
  49553. var newIsHidden = node.memoizedState !== null;
  49554. if (newIsHidden) {
  49555. var primaryChildParent = node.child;
  49556. if (primaryChildParent !== null) {
  49557. if (primaryChildParent.child !== null) {
  49558. primaryChildParent.child.return = primaryChildParent;
  49559. appendAllChildren(parent, primaryChildParent, true, newIsHidden);
  49560. }
  49561. var fallbackChildParent = primaryChildParent.sibling;
  49562. if (fallbackChildParent !== null) {
  49563. fallbackChildParent.return = node;
  49564. node = fallbackChildParent;
  49565. continue;
  49566. }
  49567. }
  49568. }
  49569. }
  49570. if (node.child !== null) {
  49571. // Continue traversing like normal
  49572. node.child.return = node;
  49573. node = node.child;
  49574. continue;
  49575. }
  49576. } else if (node.child !== null) {
  49577. node.child.return = node;
  49578. node = node.child;
  49579. continue;
  49580. } // $FlowFixMe This is correct but Flow is confused by the labeled break.
  49581. node = node;
  49582. if (node === workInProgress) {
  49583. return;
  49584. }
  49585. while (node.sibling === null) {
  49586. if (node.return === null || node.return === workInProgress) {
  49587. return;
  49588. }
  49589. node = node.return;
  49590. }
  49591. node.sibling.return = node.return;
  49592. node = node.sibling;
  49593. }
  49594. }; // An unfortunate fork of appendAllChildren because we have two different parent types.
  49595. var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
  49596. // We only have the top Fiber that was created but we need recurse down its
  49597. // children to find all the terminal nodes.
  49598. var node = workInProgress.child;
  49599. while (node !== null) {
  49600. // eslint-disable-next-line no-labels
  49601. branches: if (node.tag === HostComponent) {
  49602. var instance = node.stateNode;
  49603. if (needsVisibilityToggle && isHidden) {
  49604. // This child is inside a timed out tree. Hide it.
  49605. var props = node.memoizedProps;
  49606. var type = node.type;
  49607. instance = cloneHiddenInstance(instance, type, props, node);
  49608. }
  49609. appendChildToContainerChildSet(containerChildSet, instance);
  49610. } else if (node.tag === HostText) {
  49611. var _instance3 = node.stateNode;
  49612. if (needsVisibilityToggle && isHidden) {
  49613. // This child is inside a timed out tree. Hide it.
  49614. var text = node.memoizedProps;
  49615. _instance3 = cloneHiddenTextInstance(_instance3, text, node);
  49616. }
  49617. appendChildToContainerChildSet(containerChildSet, _instance3);
  49618. } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
  49619. var _instance4 = node.stateNode.instance;
  49620. if (needsVisibilityToggle && isHidden) {
  49621. // This child is inside a timed out tree. Hide it.
  49622. var _props2 = node.memoizedProps;
  49623. var _type2 = node.type;
  49624. _instance4 = cloneHiddenInstance(_instance4, _type2, _props2, node);
  49625. }
  49626. appendChildToContainerChildSet(containerChildSet, _instance4);
  49627. } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
  49628. // down its children. Instead, we'll get insertions from each child in
  49629. // the portal directly.
  49630. } else if (node.tag === SuspenseComponent) {
  49631. if ((node.effectTag & Update) !== NoEffect) {
  49632. // Need to toggle the visibility of the primary children.
  49633. var newIsHidden = node.memoizedState !== null;
  49634. if (newIsHidden) {
  49635. var primaryChildParent = node.child;
  49636. if (primaryChildParent !== null) {
  49637. if (primaryChildParent.child !== null) {
  49638. primaryChildParent.child.return = primaryChildParent;
  49639. appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
  49640. }
  49641. var fallbackChildParent = primaryChildParent.sibling;
  49642. if (fallbackChildParent !== null) {
  49643. fallbackChildParent.return = node;
  49644. node = fallbackChildParent;
  49645. continue;
  49646. }
  49647. }
  49648. }
  49649. }
  49650. if (node.child !== null) {
  49651. // Continue traversing like normal
  49652. node.child.return = node;
  49653. node = node.child;
  49654. continue;
  49655. }
  49656. } else if (node.child !== null) {
  49657. node.child.return = node;
  49658. node = node.child;
  49659. continue;
  49660. } // $FlowFixMe This is correct but Flow is confused by the labeled break.
  49661. node = node;
  49662. if (node === workInProgress) {
  49663. return;
  49664. }
  49665. while (node.sibling === null) {
  49666. if (node.return === null || node.return === workInProgress) {
  49667. return;
  49668. }
  49669. node = node.return;
  49670. }
  49671. node.sibling.return = node.return;
  49672. node = node.sibling;
  49673. }
  49674. };
  49675. updateHostContainer = function (workInProgress) {
  49676. var portalOrRoot = workInProgress.stateNode;
  49677. var childrenUnchanged = workInProgress.firstEffect === null;
  49678. if (childrenUnchanged) {// No changes, just reuse the existing instance.
  49679. } else {
  49680. var container = portalOrRoot.containerInfo;
  49681. var newChildSet = createContainerChildSet(container); // If children might have changed, we have to add them all to the set.
  49682. appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
  49683. portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container.
  49684. markUpdate(workInProgress);
  49685. finalizeContainerChildren(container, newChildSet);
  49686. }
  49687. };
  49688. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  49689. var currentInstance = current.stateNode;
  49690. var oldProps = current.memoizedProps; // If there are no effects associated with this node, then none of our children had any updates.
  49691. // This guarantees that we can reuse all of them.
  49692. var childrenUnchanged = workInProgress.firstEffect === null;
  49693. if (childrenUnchanged && oldProps === newProps) {
  49694. // No changes, just reuse the existing instance.
  49695. // Note that this might release a previous clone.
  49696. workInProgress.stateNode = currentInstance;
  49697. return;
  49698. }
  49699. var recyclableInstance = workInProgress.stateNode;
  49700. var currentHostContext = getHostContext();
  49701. var updatePayload = null;
  49702. if (oldProps !== newProps) {
  49703. updatePayload = prepareUpdate(recyclableInstance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
  49704. }
  49705. if (childrenUnchanged && updatePayload === null) {
  49706. // No changes, just reuse the existing instance.
  49707. // Note that this might release a previous clone.
  49708. workInProgress.stateNode = currentInstance;
  49709. return;
  49710. }
  49711. var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance);
  49712. if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) {
  49713. markUpdate(workInProgress);
  49714. }
  49715. workInProgress.stateNode = newInstance;
  49716. if (childrenUnchanged) {
  49717. // If there are no other effects in this tree, we need to flag this node as having one.
  49718. // Even though we're not going to use it for anything.
  49719. // Otherwise parents won't know that there are new children to propagate upwards.
  49720. markUpdate(workInProgress);
  49721. } else {
  49722. // If children might have changed, we have to add them all to the set.
  49723. appendAllChildren(newInstance, workInProgress, false, false);
  49724. }
  49725. };
  49726. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  49727. if (oldText !== newText) {
  49728. // If the text content differs, we'll create a new text instance for it.
  49729. var rootContainerInstance = getRootHostContainer();
  49730. var currentHostContext = getHostContext();
  49731. workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress); // We'll have to mark it as having an effect, even though we won't use the effect for anything.
  49732. // This lets the parents know that at least one of their children has changed.
  49733. markUpdate(workInProgress);
  49734. }
  49735. };
  49736. } else {
  49737. // No host operations
  49738. updateHostContainer = function (workInProgress) {// Noop
  49739. };
  49740. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {// Noop
  49741. };
  49742. updateHostText$1 = function (current, workInProgress, oldText, newText) {// Noop
  49743. };
  49744. }
  49745. function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
  49746. switch (renderState.tailMode) {
  49747. case 'hidden':
  49748. {
  49749. // Any insertions at the end of the tail list after this point
  49750. // should be invisible. If there are already mounted boundaries
  49751. // anything before them are not considered for collapsing.
  49752. // Therefore we need to go through the whole tail to find if
  49753. // there are any.
  49754. var tailNode = renderState.tail;
  49755. var lastTailNode = null;
  49756. while (tailNode !== null) {
  49757. if (tailNode.alternate !== null) {
  49758. lastTailNode = tailNode;
  49759. }
  49760. tailNode = tailNode.sibling;
  49761. } // Next we're simply going to delete all insertions after the
  49762. // last rendered item.
  49763. if (lastTailNode === null) {
  49764. // All remaining items in the tail are insertions.
  49765. renderState.tail = null;
  49766. } else {
  49767. // Detach the insertion after the last node that was already
  49768. // inserted.
  49769. lastTailNode.sibling = null;
  49770. }
  49771. break;
  49772. }
  49773. case 'collapsed':
  49774. {
  49775. // Any insertions at the end of the tail list after this point
  49776. // should be invisible. If there are already mounted boundaries
  49777. // anything before them are not considered for collapsing.
  49778. // Therefore we need to go through the whole tail to find if
  49779. // there are any.
  49780. var _tailNode = renderState.tail;
  49781. var _lastTailNode = null;
  49782. while (_tailNode !== null) {
  49783. if (_tailNode.alternate !== null) {
  49784. _lastTailNode = _tailNode;
  49785. }
  49786. _tailNode = _tailNode.sibling;
  49787. } // Next we're simply going to delete all insertions after the
  49788. // last rendered item.
  49789. if (_lastTailNode === null) {
  49790. // All remaining items in the tail are insertions.
  49791. if (!hasRenderedATailFallback && renderState.tail !== null) {
  49792. // We suspended during the head. We want to show at least one
  49793. // row at the tail. So we'll keep on and cut off the rest.
  49794. renderState.tail.sibling = null;
  49795. } else {
  49796. renderState.tail = null;
  49797. }
  49798. } else {
  49799. // Detach the insertion after the last node that was already
  49800. // inserted.
  49801. _lastTailNode.sibling = null;
  49802. }
  49803. break;
  49804. }
  49805. }
  49806. }
  49807. function completeWork(current, workInProgress, renderExpirationTime) {
  49808. var newProps = workInProgress.pendingProps;
  49809. switch (workInProgress.tag) {
  49810. case IndeterminateComponent:
  49811. break;
  49812. case LazyComponent:
  49813. break;
  49814. case SimpleMemoComponent:
  49815. case FunctionComponent:
  49816. break;
  49817. case ClassComponent:
  49818. {
  49819. var Component = workInProgress.type;
  49820. if (isContextProvider(Component)) {
  49821. popContext(workInProgress);
  49822. }
  49823. break;
  49824. }
  49825. case HostRoot:
  49826. {
  49827. popHostContainer(workInProgress);
  49828. popTopLevelContextObject(workInProgress);
  49829. var fiberRoot = workInProgress.stateNode;
  49830. if (fiberRoot.pendingContext) {
  49831. fiberRoot.context = fiberRoot.pendingContext;
  49832. fiberRoot.pendingContext = null;
  49833. }
  49834. if (current === null || current.child === null) {
  49835. // If we hydrated, pop so that we can delete any remaining children
  49836. // that weren't hydrated.
  49837. var wasHydrated = popHydrationState(workInProgress);
  49838. if (wasHydrated) {
  49839. // If we hydrated, then we'll need to schedule an update for
  49840. // the commit side-effects on the root.
  49841. markUpdate(workInProgress);
  49842. }
  49843. }
  49844. updateHostContainer(workInProgress);
  49845. break;
  49846. }
  49847. case HostComponent:
  49848. {
  49849. popHostContext(workInProgress);
  49850. var rootContainerInstance = getRootHostContainer();
  49851. var type = workInProgress.type;
  49852. if (current !== null && workInProgress.stateNode != null) {
  49853. updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
  49854. if (enableFlareAPI) {
  49855. var prevListeners = current.memoizedProps.listeners;
  49856. var nextListeners = newProps.listeners;
  49857. if (prevListeners !== nextListeners) {
  49858. markUpdate(workInProgress);
  49859. }
  49860. }
  49861. if (current.ref !== workInProgress.ref) {
  49862. markRef$1(workInProgress);
  49863. }
  49864. } else {
  49865. if (!newProps) {
  49866. (function () {
  49867. if (!(workInProgress.stateNode !== null)) {
  49868. {
  49869. throw ReactError(Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."));
  49870. }
  49871. }
  49872. })(); // This can happen when we abort work.
  49873. break;
  49874. }
  49875. var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context
  49876. // "stack" as the parent. Then append children as we go in beginWork
  49877. // or completeWork depending on we want to add then top->down or
  49878. // bottom->up. Top->down is faster in IE11.
  49879. var _wasHydrated = popHydrationState(workInProgress);
  49880. if (_wasHydrated) {
  49881. // TODO: Move this and createInstance step into the beginPhase
  49882. // to consolidate.
  49883. if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
  49884. // If changes to the hydrated node needs to be applied at the
  49885. // commit-phase we mark this as such.
  49886. markUpdate(workInProgress);
  49887. }
  49888. if (enableFlareAPI) {
  49889. var listeners = newProps.listeners;
  49890. if (listeners != null) {
  49891. updateEventListeners(listeners, workInProgress, rootContainerInstance);
  49892. }
  49893. }
  49894. } else {
  49895. var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
  49896. appendAllChildren(instance, workInProgress, false, false); // This needs to be set before we mount Flare event listeners
  49897. workInProgress.stateNode = instance;
  49898. if (enableFlareAPI) {
  49899. var _listeners = newProps.listeners;
  49900. if (_listeners != null) {
  49901. updateEventListeners(_listeners, workInProgress, rootContainerInstance);
  49902. }
  49903. } // Certain renderers require commit-time effects for initial mount.
  49904. // (eg DOM renderer supports auto-focus for certain elements).
  49905. // Make sure such renderers get scheduled for later work.
  49906. if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance, currentHostContext)) {
  49907. markUpdate(workInProgress);
  49908. }
  49909. }
  49910. if (workInProgress.ref !== null) {
  49911. // If there is a ref on a host node we need to schedule a callback
  49912. markRef$1(workInProgress);
  49913. }
  49914. }
  49915. break;
  49916. }
  49917. case HostText:
  49918. {
  49919. var newText = newProps;
  49920. if (current && workInProgress.stateNode != null) {
  49921. var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need
  49922. // to schedule a side-effect to do the updates.
  49923. updateHostText$1(current, workInProgress, oldText, newText);
  49924. } else {
  49925. if (typeof newText !== 'string') {
  49926. (function () {
  49927. if (!(workInProgress.stateNode !== null)) {
  49928. {
  49929. throw ReactError(Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."));
  49930. }
  49931. }
  49932. })(); // This can happen when we abort work.
  49933. }
  49934. var _rootContainerInstance = getRootHostContainer();
  49935. var _currentHostContext = getHostContext();
  49936. var _wasHydrated2 = popHydrationState(workInProgress);
  49937. if (_wasHydrated2) {
  49938. if (prepareToHydrateHostTextInstance(workInProgress)) {
  49939. markUpdate(workInProgress);
  49940. }
  49941. } else {
  49942. workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
  49943. }
  49944. }
  49945. break;
  49946. }
  49947. case ForwardRef:
  49948. break;
  49949. case SuspenseComponent:
  49950. {
  49951. popSuspenseContext(workInProgress);
  49952. var nextState = workInProgress.memoizedState;
  49953. if (enableSuspenseServerRenderer) {
  49954. if (nextState !== null && nextState.dehydrated !== null) {
  49955. if (current === null) {
  49956. var _wasHydrated3 = popHydrationState(workInProgress);
  49957. (function () {
  49958. if (!_wasHydrated3) {
  49959. {
  49960. throw ReactError(Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React."));
  49961. }
  49962. }
  49963. })();
  49964. prepareToHydrateHostSuspenseInstance(workInProgress);
  49965. if (enableSchedulerTracing) {
  49966. markSpawnedWork(Never);
  49967. }
  49968. return null;
  49969. } else {
  49970. // We should never have been in a hydration state if we didn't have a current.
  49971. // However, in some of those paths, we might have reentered a hydration state
  49972. // and then we might be inside a hydration state. In that case, we'll need to
  49973. // exit out of it.
  49974. resetHydrationState();
  49975. if ((workInProgress.effectTag & DidCapture) === NoEffect) {
  49976. // This boundary did not suspend so it's now hydrated and unsuspended.
  49977. workInProgress.memoizedState = null;
  49978. } // If nothing suspended, we need to schedule an effect to mark this boundary
  49979. // as having hydrated so events know that they're free be invoked.
  49980. // It's also a signal to replay events and the suspense callback.
  49981. // If something suspended, schedule an effect to attach retry listeners.
  49982. // So we might as well always mark this.
  49983. workInProgress.effectTag |= Update;
  49984. return null;
  49985. }
  49986. }
  49987. }
  49988. if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
  49989. // Something suspended. Re-render with the fallback children.
  49990. workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list.
  49991. return workInProgress;
  49992. }
  49993. var nextDidTimeout = nextState !== null;
  49994. var prevDidTimeout = false;
  49995. if (current === null) {
  49996. // In cases where we didn't find a suitable hydration boundary we never
  49997. // put this in dehydrated mode, but we still need to pop the hydration
  49998. // state since we might be inside the insertion tree.
  49999. popHydrationState(workInProgress);
  50000. } else {
  50001. var prevState = current.memoizedState;
  50002. prevDidTimeout = prevState !== null;
  50003. if (!nextDidTimeout && prevState !== null) {
  50004. // We just switched from the fallback to the normal children.
  50005. // Delete the fallback.
  50006. // TODO: Would it be better to store the fallback fragment on
  50007. // the stateNode during the begin phase?
  50008. var currentFallbackChild = current.child.sibling;
  50009. if (currentFallbackChild !== null) {
  50010. // Deletions go at the beginning of the return fiber's effect list
  50011. var first = workInProgress.firstEffect;
  50012. if (first !== null) {
  50013. workInProgress.firstEffect = currentFallbackChild;
  50014. currentFallbackChild.nextEffect = first;
  50015. } else {
  50016. workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
  50017. currentFallbackChild.nextEffect = null;
  50018. }
  50019. currentFallbackChild.effectTag = Deletion;
  50020. }
  50021. }
  50022. }
  50023. if (nextDidTimeout && !prevDidTimeout) {
  50024. // If this subtreee is running in batched mode we can suspend,
  50025. // otherwise we won't suspend.
  50026. // TODO: This will still suspend a synchronous tree if anything
  50027. // in the concurrent tree already suspended during this render.
  50028. // This is a known bug.
  50029. if ((workInProgress.mode & BatchedMode) !== NoMode) {
  50030. // TODO: Move this back to throwException because this is too late
  50031. // if this is a large tree which is common for initial loads. We
  50032. // don't know if we should restart a render or not until we get
  50033. // this marker, and this is too late.
  50034. // If this render already had a ping or lower pri updates,
  50035. // and this is the first time we know we're going to suspend we
  50036. // should be able to immediately restart from within throwException.
  50037. var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
  50038. if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
  50039. // If this was in an invisible tree or a new render, then showing
  50040. // this boundary is ok.
  50041. renderDidSuspend();
  50042. } else {
  50043. // Otherwise, we're going to have to hide content so we should
  50044. // suspend for longer if possible.
  50045. renderDidSuspendDelayIfPossible();
  50046. }
  50047. }
  50048. }
  50049. if (supportsPersistence) {
  50050. // TODO: Only schedule updates if not prevDidTimeout.
  50051. if (nextDidTimeout) {
  50052. // If this boundary just timed out, schedule an effect to attach a
  50053. // retry listener to the proimse. This flag is also used to hide the
  50054. // primary children.
  50055. workInProgress.effectTag |= Update;
  50056. }
  50057. }
  50058. if (supportsMutation) {
  50059. // TODO: Only schedule updates if these values are non equal, i.e. it changed.
  50060. if (nextDidTimeout || prevDidTimeout) {
  50061. // If this boundary just timed out, schedule an effect to attach a
  50062. // retry listener to the proimse. This flag is also used to hide the
  50063. // primary children. In mutation mode, we also need the flag to
  50064. // *unhide* children that were previously hidden, so check if the
  50065. // is currently timed out, too.
  50066. workInProgress.effectTag |= Update;
  50067. }
  50068. }
  50069. if (enableSuspenseCallback && workInProgress.updateQueue !== null && workInProgress.memoizedProps.suspenseCallback != null) {
  50070. // Always notify the callback
  50071. workInProgress.effectTag |= Update;
  50072. }
  50073. break;
  50074. }
  50075. case Fragment:
  50076. break;
  50077. case Mode:
  50078. break;
  50079. case Profiler:
  50080. break;
  50081. case HostPortal:
  50082. popHostContainer(workInProgress);
  50083. updateHostContainer(workInProgress);
  50084. break;
  50085. case ContextProvider:
  50086. // Pop provider fiber
  50087. popProvider(workInProgress);
  50088. break;
  50089. case ContextConsumer:
  50090. break;
  50091. case MemoComponent:
  50092. break;
  50093. case IncompleteClassComponent:
  50094. {
  50095. // Same as class component case. I put it down here so that the tags are
  50096. // sequential to ensure this switch is compiled to a jump table.
  50097. var _Component = workInProgress.type;
  50098. if (isContextProvider(_Component)) {
  50099. popContext(workInProgress);
  50100. }
  50101. break;
  50102. }
  50103. case SuspenseListComponent:
  50104. {
  50105. popSuspenseContext(workInProgress);
  50106. var renderState = workInProgress.memoizedState;
  50107. if (renderState === null) {
  50108. // We're running in the default, "independent" mode. We don't do anything
  50109. // in this mode.
  50110. break;
  50111. }
  50112. var didSuspendAlready = (workInProgress.effectTag & DidCapture) !== NoEffect;
  50113. var renderedTail = renderState.rendering;
  50114. if (renderedTail === null) {
  50115. // We just rendered the head.
  50116. if (!didSuspendAlready) {
  50117. // This is the first pass. We need to figure out if anything is still
  50118. // suspended in the rendered set.
  50119. // If new content unsuspended, but there's still some content that
  50120. // didn't. Then we need to do a second pass that forces everything
  50121. // to keep showing their fallbacks.
  50122. // We might be suspended if something in this render pass suspended, or
  50123. // something in the previous committed pass suspended. Otherwise,
  50124. // there's no chance so we can skip the expensive call to
  50125. // findFirstSuspended.
  50126. var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.effectTag & DidCapture) === NoEffect);
  50127. if (!cannotBeSuspended) {
  50128. var row = workInProgress.child;
  50129. while (row !== null) {
  50130. var suspended = findFirstSuspended(row);
  50131. if (suspended !== null) {
  50132. didSuspendAlready = true;
  50133. workInProgress.effectTag |= DidCapture;
  50134. cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as
  50135. // part of the second pass. In that case nothing will subscribe to
  50136. // its thennables. Instead, we'll transfer its thennables to the
  50137. // SuspenseList so that it can retry if they resolve.
  50138. // There might be multiple of these in the list but since we're
  50139. // going to wait for all of them anyway, it doesn't really matter
  50140. // which ones gets to ping. In theory we could get clever and keep
  50141. // track of how many dependencies remain but it gets tricky because
  50142. // in the meantime, we can add/remove/change items and dependencies.
  50143. // We might bail out of the loop before finding any but that
  50144. // doesn't matter since that means that the other boundaries that
  50145. // we did find already has their listeners attached.
  50146. var newThennables = suspended.updateQueue;
  50147. if (newThennables !== null) {
  50148. workInProgress.updateQueue = newThennables;
  50149. workInProgress.effectTag |= Update;
  50150. } // Rerender the whole list, but this time, we'll force fallbacks
  50151. // to stay in place.
  50152. // Reset the effect list before doing the second pass since that's now invalid.
  50153. workInProgress.firstEffect = workInProgress.lastEffect = null; // Reset the child fibers to their original state.
  50154. resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately
  50155. // rerender the children.
  50156. pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
  50157. return workInProgress.child;
  50158. }
  50159. row = row.sibling;
  50160. }
  50161. }
  50162. } else {
  50163. cutOffTailIfNeeded(renderState, false);
  50164. } // Next we're going to render the tail.
  50165. } else {
  50166. // Append the rendered row to the child list.
  50167. if (!didSuspendAlready) {
  50168. var _suspended = findFirstSuspended(renderedTail);
  50169. if (_suspended !== null) {
  50170. workInProgress.effectTag |= DidCapture;
  50171. didSuspendAlready = true;
  50172. cutOffTailIfNeeded(renderState, true); // This might have been modified.
  50173. if (renderState.tail === null && renderState.tailMode === 'hidden') {
  50174. // We need to delete the row we just rendered.
  50175. // Ensure we transfer the update queue to the parent.
  50176. var _newThennables = _suspended.updateQueue;
  50177. if (_newThennables !== null) {
  50178. workInProgress.updateQueue = _newThennables;
  50179. workInProgress.effectTag |= Update;
  50180. } // Reset the effect list to what it w as before we rendered this
  50181. // child. The nested children have already appended themselves.
  50182. var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point.
  50183. if (lastEffect !== null) {
  50184. lastEffect.nextEffect = null;
  50185. } // We're done.
  50186. return null;
  50187. }
  50188. } else if (now() > renderState.tailExpiration && renderExpirationTime > Never) {
  50189. // We have now passed our CPU deadline and we'll just give up further
  50190. // attempts to render the main content and only render fallbacks.
  50191. // The assumption is that this is usually faster.
  50192. workInProgress.effectTag |= DidCapture;
  50193. didSuspendAlready = true;
  50194. cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
  50195. // to get it started back up to attempt the next item. If we can show
  50196. // them, then they really have the same priority as this render.
  50197. // So we'll pick it back up the very next render pass once we've had
  50198. // an opportunity to yield for paint.
  50199. var nextPriority = renderExpirationTime - 1;
  50200. workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority;
  50201. if (enableSchedulerTracing) {
  50202. markSpawnedWork(nextPriority);
  50203. }
  50204. }
  50205. }
  50206. if (renderState.isBackwards) {
  50207. // The effect list of the backwards tail will have been added
  50208. // to the end. This breaks the guarantee that life-cycles fire in
  50209. // sibling order but that isn't a strong guarantee promised by React.
  50210. // Especially since these might also just pop in during future commits.
  50211. // Append to the beginning of the list.
  50212. renderedTail.sibling = workInProgress.child;
  50213. workInProgress.child = renderedTail;
  50214. } else {
  50215. var previousSibling = renderState.last;
  50216. if (previousSibling !== null) {
  50217. previousSibling.sibling = renderedTail;
  50218. } else {
  50219. workInProgress.child = renderedTail;
  50220. }
  50221. renderState.last = renderedTail;
  50222. }
  50223. }
  50224. if (renderState.tail !== null) {
  50225. // We still have tail rows to render.
  50226. if (renderState.tailExpiration === 0) {
  50227. // Heuristic for how long we're willing to spend rendering rows
  50228. // until we just give up and show what we have so far.
  50229. var TAIL_EXPIRATION_TIMEOUT_MS = 500;
  50230. renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS;
  50231. } // Pop a row.
  50232. var next = renderState.tail;
  50233. renderState.rendering = next;
  50234. renderState.tail = next.sibling;
  50235. renderState.lastEffect = workInProgress.lastEffect;
  50236. next.sibling = null; // Restore the context.
  50237. // TODO: We can probably just avoid popping it instead and only
  50238. // setting it the first time we go from not suspended to suspended.
  50239. var suspenseContext = suspenseStackCursor.current;
  50240. if (didSuspendAlready) {
  50241. suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
  50242. } else {
  50243. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  50244. }
  50245. pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row.
  50246. return next;
  50247. }
  50248. break;
  50249. }
  50250. case FundamentalComponent:
  50251. {
  50252. if (enableFundamentalAPI) {
  50253. var fundamentalImpl = workInProgress.type.impl;
  50254. var fundamentalInstance = workInProgress.stateNode;
  50255. if (fundamentalInstance === null) {
  50256. var getInitialState = fundamentalImpl.getInitialState;
  50257. var fundamentalState;
  50258. if (getInitialState !== undefined) {
  50259. fundamentalState = getInitialState(newProps);
  50260. }
  50261. fundamentalInstance = workInProgress.stateNode = createFundamentalStateInstance(workInProgress, newProps, fundamentalImpl, fundamentalState || {});
  50262. var _instance5 = getFundamentalComponentInstance(fundamentalInstance);
  50263. fundamentalInstance.instance = _instance5;
  50264. if (fundamentalImpl.reconcileChildren === false) {
  50265. return null;
  50266. }
  50267. appendAllChildren(_instance5, workInProgress, false, false);
  50268. mountFundamentalComponent(fundamentalInstance);
  50269. } else {
  50270. // We fire update in commit phase
  50271. var prevProps = fundamentalInstance.props;
  50272. fundamentalInstance.prevProps = prevProps;
  50273. fundamentalInstance.props = newProps;
  50274. fundamentalInstance.currentFiber = workInProgress;
  50275. if (supportsPersistence) {
  50276. var _instance6 = cloneFundamentalInstance(fundamentalInstance);
  50277. fundamentalInstance.instance = _instance6;
  50278. appendAllChildren(_instance6, workInProgress, false, false);
  50279. }
  50280. var shouldUpdate = shouldUpdateFundamentalComponent(fundamentalInstance);
  50281. if (shouldUpdate) {
  50282. markUpdate(workInProgress);
  50283. }
  50284. }
  50285. }
  50286. break;
  50287. }
  50288. case ScopeComponent:
  50289. {
  50290. if (enableScopeAPI) {
  50291. if (current === null) {
  50292. var _type3 = workInProgress.type;
  50293. var scopeInstance = {
  50294. fiber: workInProgress,
  50295. methods: null
  50296. };
  50297. workInProgress.stateNode = scopeInstance;
  50298. scopeInstance.methods = createScopeMethods(_type3, scopeInstance);
  50299. if (enableFlareAPI) {
  50300. var _listeners2 = newProps.listeners;
  50301. if (_listeners2 != null) {
  50302. var _rootContainerInstance2 = getRootHostContainer();
  50303. updateEventListeners(_listeners2, workInProgress, _rootContainerInstance2);
  50304. }
  50305. }
  50306. if (workInProgress.ref !== null) {
  50307. markRef$1(workInProgress);
  50308. markUpdate(workInProgress);
  50309. }
  50310. } else {
  50311. if (enableFlareAPI) {
  50312. var _prevListeners = current.memoizedProps.listeners;
  50313. var _nextListeners = newProps.listeners;
  50314. if (_prevListeners !== _nextListeners || workInProgress.ref !== null) {
  50315. markUpdate(workInProgress);
  50316. }
  50317. } else {
  50318. if (workInProgress.ref !== null) {
  50319. markUpdate(workInProgress);
  50320. }
  50321. }
  50322. if (current.ref !== workInProgress.ref) {
  50323. markRef$1(workInProgress);
  50324. }
  50325. }
  50326. }
  50327. break;
  50328. }
  50329. default:
  50330. (function () {
  50331. {
  50332. {
  50333. throw ReactError(Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue."));
  50334. }
  50335. }
  50336. })();
  50337. }
  50338. return null;
  50339. }
  50340. function unwindWork(workInProgress, renderExpirationTime) {
  50341. switch (workInProgress.tag) {
  50342. case ClassComponent:
  50343. {
  50344. var Component = workInProgress.type;
  50345. if (isContextProvider(Component)) {
  50346. popContext(workInProgress);
  50347. }
  50348. var effectTag = workInProgress.effectTag;
  50349. if (effectTag & ShouldCapture) {
  50350. workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
  50351. return workInProgress;
  50352. }
  50353. return null;
  50354. }
  50355. case HostRoot:
  50356. {
  50357. popHostContainer(workInProgress);
  50358. popTopLevelContextObject(workInProgress);
  50359. var _effectTag = workInProgress.effectTag;
  50360. (function () {
  50361. if (!((_effectTag & DidCapture) === NoEffect)) {
  50362. {
  50363. throw ReactError(Error("The root failed to unmount after an error. This is likely a bug in React. Please file an issue."));
  50364. }
  50365. }
  50366. })();
  50367. workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
  50368. return workInProgress;
  50369. }
  50370. case HostComponent:
  50371. {
  50372. // TODO: popHydrationState
  50373. popHostContext(workInProgress);
  50374. return null;
  50375. }
  50376. case SuspenseComponent:
  50377. {
  50378. popSuspenseContext(workInProgress);
  50379. if (enableSuspenseServerRenderer) {
  50380. var suspenseState = workInProgress.memoizedState;
  50381. if (suspenseState !== null && suspenseState.dehydrated !== null) {
  50382. (function () {
  50383. if (!(workInProgress.alternate !== null)) {
  50384. {
  50385. throw ReactError(Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue."));
  50386. }
  50387. }
  50388. })();
  50389. resetHydrationState();
  50390. }
  50391. }
  50392. var _effectTag2 = workInProgress.effectTag;
  50393. if (_effectTag2 & ShouldCapture) {
  50394. workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture; // Captured a suspense effect. Re-render the boundary.
  50395. return workInProgress;
  50396. }
  50397. return null;
  50398. }
  50399. case SuspenseListComponent:
  50400. {
  50401. popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been
  50402. // caught by a nested boundary. If not, it should bubble through.
  50403. return null;
  50404. }
  50405. case HostPortal:
  50406. popHostContainer(workInProgress);
  50407. return null;
  50408. case ContextProvider:
  50409. popProvider(workInProgress);
  50410. return null;
  50411. default:
  50412. return null;
  50413. }
  50414. }
  50415. function unwindInterruptedWork(interruptedWork) {
  50416. switch (interruptedWork.tag) {
  50417. case ClassComponent:
  50418. {
  50419. var childContextTypes = interruptedWork.type.childContextTypes;
  50420. if (childContextTypes !== null && childContextTypes !== undefined) {
  50421. popContext(interruptedWork);
  50422. }
  50423. break;
  50424. }
  50425. case HostRoot:
  50426. {
  50427. popHostContainer(interruptedWork);
  50428. popTopLevelContextObject(interruptedWork);
  50429. break;
  50430. }
  50431. case HostComponent:
  50432. {
  50433. popHostContext(interruptedWork);
  50434. break;
  50435. }
  50436. case HostPortal:
  50437. popHostContainer(interruptedWork);
  50438. break;
  50439. case SuspenseComponent:
  50440. popSuspenseContext(interruptedWork);
  50441. break;
  50442. case SuspenseListComponent:
  50443. popSuspenseContext(interruptedWork);
  50444. break;
  50445. case ContextProvider:
  50446. popProvider(interruptedWork);
  50447. break;
  50448. default:
  50449. break;
  50450. }
  50451. }
  50452. function createCapturedValue(value, source) {
  50453. // If the value is an error, call this function immediately after it is thrown
  50454. // so the stack is accurate.
  50455. return {
  50456. value: value,
  50457. source: source,
  50458. stack: getStackByFiberInDevAndProd(source)
  50459. };
  50460. }
  50461. // This module is forked in different environments.
  50462. // By default, return `true` to log errors to the console.
  50463. // Forks can return `false` if this isn't desirable.
  50464. function showErrorDialog(capturedError) {
  50465. return true;
  50466. }
  50467. function logCapturedError(capturedError) {
  50468. var logError = showErrorDialog(capturedError); // Allow injected showErrorDialog() to prevent default console.error logging.
  50469. // This enables renderers like ReactNative to better manage redbox behavior.
  50470. if (logError === false) {
  50471. return;
  50472. }
  50473. var error = capturedError.error;
  50474. {
  50475. var componentName = capturedError.componentName,
  50476. componentStack = capturedError.componentStack,
  50477. errorBoundaryName = capturedError.errorBoundaryName,
  50478. errorBoundaryFound = capturedError.errorBoundaryFound,
  50479. willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling
  50480. // `preventDefault()` in window `error` handler.
  50481. // We record this information as an expando on the error.
  50482. if (error != null && error._suppressLogging) {
  50483. if (errorBoundaryFound && willRetry) {
  50484. // The error is recoverable and was silenced.
  50485. // Ignore it and don't print the stack addendum.
  50486. // This is handy for testing error boundaries without noise.
  50487. return;
  50488. } // The error is fatal. Since the silencing might have
  50489. // been accidental, we'll surface it anyway.
  50490. // However, the browser would have silenced the original error
  50491. // so we'll print it first, and then print the stack addendum.
  50492. console.error(error); // For a more detailed description of this block, see:
  50493. // https://github.com/facebook/react/pull/13384
  50494. }
  50495. var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:';
  50496. var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
  50497. if (errorBoundaryFound && errorBoundaryName) {
  50498. if (willRetry) {
  50499. errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
  50500. } else {
  50501. errorBoundaryMessage = "This error was initially handled by the error boundary " + errorBoundaryName + ".\n" + "Recreating the tree from scratch failed so React will unmount the tree.";
  50502. }
  50503. } else {
  50504. 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.';
  50505. }
  50506. var combinedMessage = "" + componentNameMessage + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack.
  50507. // We don't include the original error message and JS stack because the browser
  50508. // has already printed it. Even if the application swallows the error, it is still
  50509. // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
  50510. console.error(combinedMessage);
  50511. }
  50512. }
  50513. var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
  50514. {
  50515. didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
  50516. }
  50517. var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
  50518. function logError(boundary, errorInfo) {
  50519. var source = errorInfo.source;
  50520. var stack = errorInfo.stack;
  50521. if (stack === null && source !== null) {
  50522. stack = getStackByFiberInDevAndProd(source);
  50523. }
  50524. var capturedError = {
  50525. componentName: source !== null ? getComponentName(source.type) : null,
  50526. componentStack: stack !== null ? stack : '',
  50527. error: errorInfo.value,
  50528. errorBoundary: null,
  50529. errorBoundaryName: null,
  50530. errorBoundaryFound: false,
  50531. willRetry: false
  50532. };
  50533. if (boundary !== null && boundary.tag === ClassComponent) {
  50534. capturedError.errorBoundary = boundary.stateNode;
  50535. capturedError.errorBoundaryName = getComponentName(boundary.type);
  50536. capturedError.errorBoundaryFound = true;
  50537. capturedError.willRetry = true;
  50538. }
  50539. try {
  50540. logCapturedError(capturedError);
  50541. } catch (e) {
  50542. // This method must not throw, or React internal state will get messed up.
  50543. // If console.error is overridden, or logCapturedError() shows a dialog that throws,
  50544. // we want to report this error outside of the normal stack as a last resort.
  50545. // https://github.com/facebook/react/issues/13188
  50546. setTimeout(function () {
  50547. throw e;
  50548. });
  50549. }
  50550. }
  50551. var callComponentWillUnmountWithTimer = function (current$$1, instance) {
  50552. startPhaseTimer(current$$1, 'componentWillUnmount');
  50553. instance.props = current$$1.memoizedProps;
  50554. instance.state = current$$1.memoizedState;
  50555. instance.componentWillUnmount();
  50556. stopPhaseTimer();
  50557. }; // Capture errors so they don't interrupt unmounting.
  50558. function safelyCallComponentWillUnmount(current$$1, instance) {
  50559. {
  50560. invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current$$1, instance);
  50561. if (hasCaughtError()) {
  50562. var unmountError = clearCaughtError();
  50563. captureCommitPhaseError(current$$1, unmountError);
  50564. }
  50565. }
  50566. }
  50567. function safelyDetachRef(current$$1) {
  50568. var ref = current$$1.ref;
  50569. if (ref !== null) {
  50570. if (typeof ref === 'function') {
  50571. {
  50572. invokeGuardedCallback(null, ref, null, null);
  50573. if (hasCaughtError()) {
  50574. var refError = clearCaughtError();
  50575. captureCommitPhaseError(current$$1, refError);
  50576. }
  50577. }
  50578. } else {
  50579. ref.current = null;
  50580. }
  50581. }
  50582. }
  50583. function safelyCallDestroy(current$$1, destroy) {
  50584. {
  50585. invokeGuardedCallback(null, destroy, null);
  50586. if (hasCaughtError()) {
  50587. var error = clearCaughtError();
  50588. captureCommitPhaseError(current$$1, error);
  50589. }
  50590. }
  50591. }
  50592. function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
  50593. switch (finishedWork.tag) {
  50594. case FunctionComponent:
  50595. case ForwardRef:
  50596. case SimpleMemoComponent:
  50597. {
  50598. commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork);
  50599. return;
  50600. }
  50601. case ClassComponent:
  50602. {
  50603. if (finishedWork.effectTag & Snapshot) {
  50604. if (current$$1 !== null) {
  50605. var prevProps = current$$1.memoizedProps;
  50606. var prevState = current$$1.memoizedState;
  50607. startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
  50608. var instance = finishedWork.stateNode; // We could update instance props and state here,
  50609. // but instead we rely on them being set during last render.
  50610. // TODO: revisit this when we implement resuming.
  50611. {
  50612. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  50613. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, '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') : void 0;
  50614. !(instance.state === finishedWork.memoizedState) ? warning$1(false, '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') : void 0;
  50615. }
  50616. }
  50617. var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
  50618. {
  50619. var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
  50620. if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
  50621. didWarnSet.add(finishedWork.type);
  50622. warningWithoutStack$1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
  50623. }
  50624. }
  50625. instance.__reactInternalSnapshotBeforeUpdate = snapshot;
  50626. stopPhaseTimer();
  50627. }
  50628. }
  50629. return;
  50630. }
  50631. case HostRoot:
  50632. case HostComponent:
  50633. case HostText:
  50634. case HostPortal:
  50635. case IncompleteClassComponent:
  50636. // Nothing to do for these component types
  50637. return;
  50638. default:
  50639. {
  50640. (function () {
  50641. {
  50642. {
  50643. throw ReactError(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."));
  50644. }
  50645. }
  50646. })();
  50647. }
  50648. }
  50649. }
  50650. function commitHookEffectList(unmountTag, mountTag, finishedWork) {
  50651. var updateQueue = finishedWork.updateQueue;
  50652. var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
  50653. if (lastEffect !== null) {
  50654. var firstEffect = lastEffect.next;
  50655. var effect = firstEffect;
  50656. do {
  50657. if ((effect.tag & unmountTag) !== NoEffect$1) {
  50658. // Unmount
  50659. var destroy = effect.destroy;
  50660. effect.destroy = undefined;
  50661. if (destroy !== undefined) {
  50662. destroy();
  50663. }
  50664. }
  50665. if ((effect.tag & mountTag) !== NoEffect$1) {
  50666. // Mount
  50667. var create = effect.create;
  50668. effect.destroy = create();
  50669. {
  50670. var _destroy = effect.destroy;
  50671. if (_destroy !== undefined && typeof _destroy !== 'function') {
  50672. var addendum = void 0;
  50673. if (_destroy === null) {
  50674. addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
  50675. } else if (typeof _destroy.then === 'function') {
  50676. 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';
  50677. } else {
  50678. addendum = ' You returned: ' + _destroy;
  50679. }
  50680. warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
  50681. }
  50682. }
  50683. }
  50684. effect = effect.next;
  50685. } while (effect !== firstEffect);
  50686. }
  50687. }
  50688. function commitPassiveHookEffects(finishedWork) {
  50689. if ((finishedWork.effectTag & Passive) !== NoEffect) {
  50690. switch (finishedWork.tag) {
  50691. case FunctionComponent:
  50692. case ForwardRef:
  50693. case SimpleMemoComponent:
  50694. {
  50695. commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork);
  50696. commitHookEffectList(NoEffect$1, MountPassive, finishedWork);
  50697. break;
  50698. }
  50699. default:
  50700. break;
  50701. }
  50702. }
  50703. }
  50704. function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpirationTime) {
  50705. switch (finishedWork.tag) {
  50706. case FunctionComponent:
  50707. case ForwardRef:
  50708. case SimpleMemoComponent:
  50709. {
  50710. commitHookEffectList(UnmountLayout, MountLayout, finishedWork);
  50711. break;
  50712. }
  50713. case ClassComponent:
  50714. {
  50715. var instance = finishedWork.stateNode;
  50716. if (finishedWork.effectTag & Update) {
  50717. if (current$$1 === null) {
  50718. startPhaseTimer(finishedWork, 'componentDidMount'); // We could update instance props and state here,
  50719. // but instead we rely on them being set during last render.
  50720. // TODO: revisit this when we implement resuming.
  50721. {
  50722. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  50723. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, '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') : void 0;
  50724. !(instance.state === finishedWork.memoizedState) ? warning$1(false, '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') : void 0;
  50725. }
  50726. }
  50727. instance.componentDidMount();
  50728. stopPhaseTimer();
  50729. } else {
  50730. var prevProps = finishedWork.elementType === finishedWork.type ? current$$1.memoizedProps : resolveDefaultProps(finishedWork.type, current$$1.memoizedProps);
  50731. var prevState = current$$1.memoizedState;
  50732. startPhaseTimer(finishedWork, 'componentDidUpdate'); // We could update instance props and state here,
  50733. // but instead we rely on them being set during last render.
  50734. // TODO: revisit this when we implement resuming.
  50735. {
  50736. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  50737. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, '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') : void 0;
  50738. !(instance.state === finishedWork.memoizedState) ? warning$1(false, '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') : void 0;
  50739. }
  50740. }
  50741. instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
  50742. stopPhaseTimer();
  50743. }
  50744. }
  50745. var updateQueue = finishedWork.updateQueue;
  50746. if (updateQueue !== null) {
  50747. {
  50748. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  50749. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, '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') : void 0;
  50750. !(instance.state === finishedWork.memoizedState) ? warning$1(false, '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') : void 0;
  50751. }
  50752. } // We could update instance props and state here,
  50753. // but instead we rely on them being set during last render.
  50754. // TODO: revisit this when we implement resuming.
  50755. commitUpdateQueue(finishedWork, updateQueue, instance, committedExpirationTime);
  50756. }
  50757. return;
  50758. }
  50759. case HostRoot:
  50760. {
  50761. var _updateQueue = finishedWork.updateQueue;
  50762. if (_updateQueue !== null) {
  50763. var _instance = null;
  50764. if (finishedWork.child !== null) {
  50765. switch (finishedWork.child.tag) {
  50766. case HostComponent:
  50767. _instance = getPublicInstance(finishedWork.child.stateNode);
  50768. break;
  50769. case ClassComponent:
  50770. _instance = finishedWork.child.stateNode;
  50771. break;
  50772. }
  50773. }
  50774. commitUpdateQueue(finishedWork, _updateQueue, _instance, committedExpirationTime);
  50775. }
  50776. return;
  50777. }
  50778. case HostComponent:
  50779. {
  50780. var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted
  50781. // (eg DOM renderer may schedule auto-focus for inputs and form controls).
  50782. // These effects should only be committed when components are first mounted,
  50783. // aka when there is no current/alternate.
  50784. if (current$$1 === null && finishedWork.effectTag & Update) {
  50785. var type = finishedWork.type;
  50786. var props = finishedWork.memoizedProps;
  50787. commitMount(_instance2, type, props, finishedWork);
  50788. }
  50789. return;
  50790. }
  50791. case HostText:
  50792. {
  50793. // We have no life-cycles associated with text.
  50794. return;
  50795. }
  50796. case HostPortal:
  50797. {
  50798. // We have no life-cycles associated with portals.
  50799. return;
  50800. }
  50801. case Profiler:
  50802. {
  50803. if (enableProfilerTimer) {
  50804. var onRender = finishedWork.memoizedProps.onRender;
  50805. if (typeof onRender === 'function') {
  50806. if (enableSchedulerTracing) {
  50807. onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
  50808. } else {
  50809. onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime());
  50810. }
  50811. }
  50812. }
  50813. return;
  50814. }
  50815. case SuspenseComponent:
  50816. {
  50817. commitSuspenseHydrationCallbacks(finishedRoot, finishedWork);
  50818. return;
  50819. }
  50820. case SuspenseListComponent:
  50821. case IncompleteClassComponent:
  50822. case FundamentalComponent:
  50823. case ScopeComponent:
  50824. return;
  50825. default:
  50826. {
  50827. (function () {
  50828. {
  50829. {
  50830. throw ReactError(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."));
  50831. }
  50832. }
  50833. })();
  50834. }
  50835. }
  50836. }
  50837. function hideOrUnhideAllChildren(finishedWork, isHidden) {
  50838. if (supportsMutation) {
  50839. // We only have the top Fiber that was inserted but we need to recurse down its
  50840. // children to find all the terminal nodes.
  50841. var node = finishedWork;
  50842. while (true) {
  50843. if (node.tag === HostComponent) {
  50844. var instance = node.stateNode;
  50845. if (isHidden) {
  50846. hideInstance(instance);
  50847. } else {
  50848. unhideInstance(node.stateNode, node.memoizedProps);
  50849. }
  50850. } else if (node.tag === HostText) {
  50851. var _instance3 = node.stateNode;
  50852. if (isHidden) {
  50853. hideTextInstance(_instance3);
  50854. } else {
  50855. unhideTextInstance(_instance3, node.memoizedProps);
  50856. }
  50857. } else if (node.tag === SuspenseComponent && node.memoizedState !== null && node.memoizedState.dehydrated === null) {
  50858. // Found a nested Suspense component that timed out. Skip over the
  50859. // primary child fragment, which should remain hidden.
  50860. var fallbackChildFragment = node.child.sibling;
  50861. fallbackChildFragment.return = node;
  50862. node = fallbackChildFragment;
  50863. continue;
  50864. } else if (node.child !== null) {
  50865. node.child.return = node;
  50866. node = node.child;
  50867. continue;
  50868. }
  50869. if (node === finishedWork) {
  50870. return;
  50871. }
  50872. while (node.sibling === null) {
  50873. if (node.return === null || node.return === finishedWork) {
  50874. return;
  50875. }
  50876. node = node.return;
  50877. }
  50878. node.sibling.return = node.return;
  50879. node = node.sibling;
  50880. }
  50881. }
  50882. }
  50883. function commitAttachRef(finishedWork) {
  50884. var ref = finishedWork.ref;
  50885. if (ref !== null) {
  50886. var instance = finishedWork.stateNode;
  50887. var instanceToUse;
  50888. switch (finishedWork.tag) {
  50889. case HostComponent:
  50890. instanceToUse = getPublicInstance(instance);
  50891. break;
  50892. default:
  50893. instanceToUse = instance;
  50894. } // Moved outside to ensure DCE works with this flag
  50895. if (enableScopeAPI && finishedWork.tag === ScopeComponent) {
  50896. instanceToUse = instance.methods;
  50897. }
  50898. if (typeof ref === 'function') {
  50899. ref(instanceToUse);
  50900. } else {
  50901. {
  50902. if (!ref.hasOwnProperty('current')) {
  50903. warningWithoutStack$1(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
  50904. }
  50905. }
  50906. ref.current = instanceToUse;
  50907. }
  50908. }
  50909. }
  50910. function commitDetachRef(current$$1) {
  50911. var currentRef = current$$1.ref;
  50912. if (currentRef !== null) {
  50913. if (typeof currentRef === 'function') {
  50914. currentRef(null);
  50915. } else {
  50916. currentRef.current = null;
  50917. }
  50918. }
  50919. } // User-originating errors (lifecycles and refs) should not interrupt
  50920. // deletion, so don't let them throw. Host-originating errors should
  50921. // interrupt deletion, so it's okay
  50922. function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) {
  50923. onCommitUnmount(current$$1);
  50924. switch (current$$1.tag) {
  50925. case FunctionComponent:
  50926. case ForwardRef:
  50927. case MemoComponent:
  50928. case SimpleMemoComponent:
  50929. {
  50930. var updateQueue = current$$1.updateQueue;
  50931. if (updateQueue !== null) {
  50932. var lastEffect = updateQueue.lastEffect;
  50933. if (lastEffect !== null) {
  50934. var firstEffect = lastEffect.next; // When the owner fiber is deleted, the destroy function of a passive
  50935. // effect hook is called during the synchronous commit phase. This is
  50936. // a concession to implementation complexity. Calling it in the
  50937. // passive effect phase (like they usually are, when dependencies
  50938. // change during an update) would require either traversing the
  50939. // children of the deleted fiber again, or including unmount effects
  50940. // as part of the fiber effect list.
  50941. //
  50942. // Because this is during the sync commit phase, we need to change
  50943. // the priority.
  50944. //
  50945. // TODO: Reconsider this implementation trade off.
  50946. var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel;
  50947. runWithPriority$2(priorityLevel, function () {
  50948. var effect = firstEffect;
  50949. do {
  50950. var destroy = effect.destroy;
  50951. if (destroy !== undefined) {
  50952. safelyCallDestroy(current$$1, destroy);
  50953. }
  50954. effect = effect.next;
  50955. } while (effect !== firstEffect);
  50956. });
  50957. }
  50958. }
  50959. break;
  50960. }
  50961. case ClassComponent:
  50962. {
  50963. safelyDetachRef(current$$1);
  50964. var instance = current$$1.stateNode;
  50965. if (typeof instance.componentWillUnmount === 'function') {
  50966. safelyCallComponentWillUnmount(current$$1, instance);
  50967. }
  50968. return;
  50969. }
  50970. case HostComponent:
  50971. {
  50972. if (enableFlareAPI) {
  50973. var dependencies = current$$1.dependencies;
  50974. if (dependencies !== null) {
  50975. var respondersMap = dependencies.responders;
  50976. if (respondersMap !== null) {
  50977. var responderInstances = Array.from(respondersMap.values());
  50978. for (var i = 0, length = responderInstances.length; i < length; i++) {
  50979. var responderInstance = responderInstances[i];
  50980. unmountResponderInstance(responderInstance);
  50981. }
  50982. dependencies.responders = null;
  50983. }
  50984. }
  50985. }
  50986. safelyDetachRef(current$$1);
  50987. return;
  50988. }
  50989. case HostPortal:
  50990. {
  50991. // TODO: this is recursive.
  50992. // We are also not using this parent because
  50993. // the portal will get pushed immediately.
  50994. if (supportsMutation) {
  50995. unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel);
  50996. } else if (supportsPersistence) {
  50997. emptyPortalContainer(current$$1);
  50998. }
  50999. return;
  51000. }
  51001. case FundamentalComponent:
  51002. {
  51003. if (enableFundamentalAPI) {
  51004. var fundamentalInstance = current$$1.stateNode;
  51005. if (fundamentalInstance !== null) {
  51006. unmountFundamentalComponent(fundamentalInstance);
  51007. current$$1.stateNode = null;
  51008. }
  51009. }
  51010. return;
  51011. }
  51012. case DehydratedFragment:
  51013. {
  51014. if (enableSuspenseCallback) {
  51015. var hydrationCallbacks = finishedRoot.hydrationCallbacks;
  51016. if (hydrationCallbacks !== null) {
  51017. var onDeleted = hydrationCallbacks.onDeleted;
  51018. if (onDeleted) {
  51019. onDeleted(current$$1.stateNode);
  51020. }
  51021. }
  51022. }
  51023. return;
  51024. }
  51025. case ScopeComponent:
  51026. {
  51027. if (enableScopeAPI) {
  51028. safelyDetachRef(current$$1);
  51029. }
  51030. }
  51031. }
  51032. }
  51033. function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
  51034. // While we're inside a removed host node we don't want to call
  51035. // removeChild on the inner nodes because they're removed by the top
  51036. // call anyway. We also want to call componentWillUnmount on all
  51037. // composites before this host node is removed from the tree. Therefore
  51038. // we do an inner loop while we're still inside the host node.
  51039. var node = root;
  51040. while (true) {
  51041. commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes.
  51042. // Skip portals because commitUnmount() currently visits them recursively.
  51043. if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above.
  51044. // If we don't use mutation we drill down into portals here instead.
  51045. !supportsMutation || node.tag !== HostPortal)) {
  51046. node.child.return = node;
  51047. node = node.child;
  51048. continue;
  51049. }
  51050. if (node === root) {
  51051. return;
  51052. }
  51053. while (node.sibling === null) {
  51054. if (node.return === null || node.return === root) {
  51055. return;
  51056. }
  51057. node = node.return;
  51058. }
  51059. node.sibling.return = node.return;
  51060. node = node.sibling;
  51061. }
  51062. }
  51063. function detachFiber(current$$1) {
  51064. var alternate = current$$1.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we
  51065. // should clear the child pointer of the parent alternate to let this
  51066. // get GC:ed but we don't know which for sure which parent is the current
  51067. // one so we'll settle for GC:ing the subtree of this child. This child
  51068. // itself will be GC:ed when the parent updates the next time.
  51069. current$$1.return = null;
  51070. current$$1.child = null;
  51071. current$$1.memoizedState = null;
  51072. current$$1.updateQueue = null;
  51073. current$$1.dependencies = null;
  51074. current$$1.alternate = null;
  51075. current$$1.firstEffect = null;
  51076. current$$1.lastEffect = null;
  51077. current$$1.pendingProps = null;
  51078. current$$1.memoizedProps = null;
  51079. if (alternate !== null) {
  51080. detachFiber(alternate);
  51081. }
  51082. }
  51083. function emptyPortalContainer(current$$1) {
  51084. if (!supportsPersistence) {
  51085. return;
  51086. }
  51087. var portal = current$$1.stateNode;
  51088. var containerInfo = portal.containerInfo;
  51089. var emptyChildSet = createContainerChildSet(containerInfo);
  51090. replaceContainerChildren(containerInfo, emptyChildSet);
  51091. }
  51092. function commitContainer(finishedWork) {
  51093. if (!supportsPersistence) {
  51094. return;
  51095. }
  51096. switch (finishedWork.tag) {
  51097. case ClassComponent:
  51098. case HostComponent:
  51099. case HostText:
  51100. case FundamentalComponent:
  51101. {
  51102. return;
  51103. }
  51104. case HostRoot:
  51105. case HostPortal:
  51106. {
  51107. var portalOrRoot = finishedWork.stateNode;
  51108. var containerInfo = portalOrRoot.containerInfo,
  51109. pendingChildren = portalOrRoot.pendingChildren;
  51110. replaceContainerChildren(containerInfo, pendingChildren);
  51111. return;
  51112. }
  51113. default:
  51114. {
  51115. (function () {
  51116. {
  51117. {
  51118. throw ReactError(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."));
  51119. }
  51120. }
  51121. })();
  51122. }
  51123. }
  51124. }
  51125. function getHostParentFiber(fiber) {
  51126. var parent = fiber.return;
  51127. while (parent !== null) {
  51128. if (isHostParent(parent)) {
  51129. return parent;
  51130. }
  51131. parent = parent.return;
  51132. }
  51133. (function () {
  51134. {
  51135. {
  51136. throw ReactError(Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue."));
  51137. }
  51138. }
  51139. })();
  51140. }
  51141. function isHostParent(fiber) {
  51142. return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
  51143. }
  51144. function getHostSibling(fiber) {
  51145. // We're going to search forward into the tree until we find a sibling host
  51146. // node. Unfortunately, if multiple insertions are done in a row we have to
  51147. // search past them. This leads to exponential search for the next sibling.
  51148. // TODO: Find a more efficient way to do this.
  51149. var node = fiber;
  51150. siblings: while (true) {
  51151. // If we didn't find anything, let's try the next sibling.
  51152. while (node.sibling === null) {
  51153. if (node.return === null || isHostParent(node.return)) {
  51154. // If we pop out of the root or hit the parent the fiber we are the
  51155. // last sibling.
  51156. return null;
  51157. }
  51158. node = node.return;
  51159. }
  51160. node.sibling.return = node.return;
  51161. node = node.sibling;
  51162. while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) {
  51163. // If it is not host node and, we might have a host node inside it.
  51164. // Try to search down until we find one.
  51165. if (node.effectTag & Placement) {
  51166. // If we don't have a child, try the siblings instead.
  51167. continue siblings;
  51168. } // If we don't have a child, try the siblings instead.
  51169. // We also skip portals because they are not part of this host tree.
  51170. if (node.child === null || node.tag === HostPortal) {
  51171. continue siblings;
  51172. } else {
  51173. node.child.return = node;
  51174. node = node.child;
  51175. }
  51176. } // Check if this host node is stable or about to be placed.
  51177. if (!(node.effectTag & Placement)) {
  51178. // Found it!
  51179. return node.stateNode;
  51180. }
  51181. }
  51182. }
  51183. function commitPlacement(finishedWork) {
  51184. if (!supportsMutation) {
  51185. return;
  51186. } // Recursively insert all host nodes into the parent.
  51187. var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together.
  51188. var parent;
  51189. var isContainer;
  51190. var parentStateNode = parentFiber.stateNode;
  51191. switch (parentFiber.tag) {
  51192. case HostComponent:
  51193. parent = parentStateNode;
  51194. isContainer = false;
  51195. break;
  51196. case HostRoot:
  51197. parent = parentStateNode.containerInfo;
  51198. isContainer = true;
  51199. break;
  51200. case HostPortal:
  51201. parent = parentStateNode.containerInfo;
  51202. isContainer = true;
  51203. break;
  51204. case FundamentalComponent:
  51205. if (enableFundamentalAPI) {
  51206. parent = parentStateNode.instance;
  51207. isContainer = false;
  51208. }
  51209. // eslint-disable-next-line-no-fallthrough
  51210. default:
  51211. (function () {
  51212. {
  51213. {
  51214. throw ReactError(Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue."));
  51215. }
  51216. }
  51217. })();
  51218. }
  51219. if (parentFiber.effectTag & ContentReset) {
  51220. // Reset the text content of the parent before doing any insertions
  51221. resetTextContent(parent); // Clear ContentReset from the effect tag
  51222. parentFiber.effectTag &= ~ContentReset;
  51223. }
  51224. var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its
  51225. // children to find all the terminal nodes.
  51226. var node = finishedWork;
  51227. while (true) {
  51228. var isHost = node.tag === HostComponent || node.tag === HostText;
  51229. if (isHost || enableFundamentalAPI && node.tag === FundamentalComponent) {
  51230. var stateNode = isHost ? node.stateNode : node.stateNode.instance;
  51231. if (before) {
  51232. if (isContainer) {
  51233. insertInContainerBefore(parent, stateNode, before);
  51234. } else {
  51235. insertBefore(parent, stateNode, before);
  51236. }
  51237. } else {
  51238. if (isContainer) {
  51239. appendChildToContainer(parent, stateNode);
  51240. } else {
  51241. appendChild(parent, stateNode);
  51242. }
  51243. }
  51244. } else if (node.tag === HostPortal) {// If the insertion itself is a portal, then we don't want to traverse
  51245. // down its children. Instead, we'll get insertions from each child in
  51246. // the portal directly.
  51247. } else if (node.child !== null) {
  51248. node.child.return = node;
  51249. node = node.child;
  51250. continue;
  51251. }
  51252. if (node === finishedWork) {
  51253. return;
  51254. }
  51255. while (node.sibling === null) {
  51256. if (node.return === null || node.return === finishedWork) {
  51257. return;
  51258. }
  51259. node = node.return;
  51260. }
  51261. node.sibling.return = node.return;
  51262. node = node.sibling;
  51263. }
  51264. }
  51265. function unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel) {
  51266. // We only have the top Fiber that was deleted but we need to recurse down its
  51267. // children to find all the terminal nodes.
  51268. var node = current$$1; // Each iteration, currentParent is populated with node's host parent if not
  51269. // currentParentIsValid.
  51270. var currentParentIsValid = false; // Note: these two variables *must* always be updated together.
  51271. var currentParent;
  51272. var currentParentIsContainer;
  51273. while (true) {
  51274. if (!currentParentIsValid) {
  51275. var parent = node.return;
  51276. findParent: while (true) {
  51277. (function () {
  51278. if (!(parent !== null)) {
  51279. {
  51280. throw ReactError(Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue."));
  51281. }
  51282. }
  51283. })();
  51284. var parentStateNode = parent.stateNode;
  51285. switch (parent.tag) {
  51286. case HostComponent:
  51287. currentParent = parentStateNode;
  51288. currentParentIsContainer = false;
  51289. break findParent;
  51290. case HostRoot:
  51291. currentParent = parentStateNode.containerInfo;
  51292. currentParentIsContainer = true;
  51293. break findParent;
  51294. case HostPortal:
  51295. currentParent = parentStateNode.containerInfo;
  51296. currentParentIsContainer = true;
  51297. break findParent;
  51298. case FundamentalComponent:
  51299. if (enableFundamentalAPI) {
  51300. currentParent = parentStateNode.instance;
  51301. currentParentIsContainer = false;
  51302. }
  51303. }
  51304. parent = parent.return;
  51305. }
  51306. currentParentIsValid = true;
  51307. }
  51308. if (node.tag === HostComponent || node.tag === HostText) {
  51309. commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the
  51310. // node from the tree.
  51311. if (currentParentIsContainer) {
  51312. removeChildFromContainer(currentParent, node.stateNode);
  51313. } else {
  51314. removeChild(currentParent, node.stateNode);
  51315. } // Don't visit children because we already visited them.
  51316. } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
  51317. var fundamentalNode = node.stateNode.instance;
  51318. commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the
  51319. // node from the tree.
  51320. if (currentParentIsContainer) {
  51321. removeChildFromContainer(currentParent, fundamentalNode);
  51322. } else {
  51323. removeChild(currentParent, fundamentalNode);
  51324. }
  51325. } else if (enableSuspenseServerRenderer && node.tag === DehydratedFragment) {
  51326. if (enableSuspenseCallback) {
  51327. var hydrationCallbacks = finishedRoot.hydrationCallbacks;
  51328. if (hydrationCallbacks !== null) {
  51329. var onDeleted = hydrationCallbacks.onDeleted;
  51330. if (onDeleted) {
  51331. onDeleted(node.stateNode);
  51332. }
  51333. }
  51334. } // Delete the dehydrated suspense boundary and all of its content.
  51335. if (currentParentIsContainer) {
  51336. clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
  51337. } else {
  51338. clearSuspenseBoundary(currentParent, node.stateNode);
  51339. }
  51340. } else if (node.tag === HostPortal) {
  51341. if (node.child !== null) {
  51342. // When we go into a portal, it becomes the parent to remove from.
  51343. // We will reassign it back when we pop the portal on the way up.
  51344. currentParent = node.stateNode.containerInfo;
  51345. currentParentIsContainer = true; // Visit children because portals might contain host components.
  51346. node.child.return = node;
  51347. node = node.child;
  51348. continue;
  51349. }
  51350. } else {
  51351. commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because we may find more host components below.
  51352. if (node.child !== null) {
  51353. node.child.return = node;
  51354. node = node.child;
  51355. continue;
  51356. }
  51357. }
  51358. if (node === current$$1) {
  51359. return;
  51360. }
  51361. while (node.sibling === null) {
  51362. if (node.return === null || node.return === current$$1) {
  51363. return;
  51364. }
  51365. node = node.return;
  51366. if (node.tag === HostPortal) {
  51367. // When we go out of the portal, we need to restore the parent.
  51368. // Since we don't keep a stack of them, we will search for it.
  51369. currentParentIsValid = false;
  51370. }
  51371. }
  51372. node.sibling.return = node.return;
  51373. node = node.sibling;
  51374. }
  51375. }
  51376. function commitDeletion(finishedRoot, current$$1, renderPriorityLevel) {
  51377. if (supportsMutation) {
  51378. // Recursively delete all host nodes from the parent.
  51379. // Detach refs and call componentWillUnmount() on the whole subtree.
  51380. unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel);
  51381. } else {
  51382. // Detach refs and call componentWillUnmount() on the whole subtree.
  51383. commitNestedUnmounts(finishedRoot, current$$1, renderPriorityLevel);
  51384. }
  51385. detachFiber(current$$1);
  51386. }
  51387. function commitWork(current$$1, finishedWork) {
  51388. if (!supportsMutation) {
  51389. switch (finishedWork.tag) {
  51390. case FunctionComponent:
  51391. case ForwardRef:
  51392. case MemoComponent:
  51393. case SimpleMemoComponent:
  51394. {
  51395. // Note: We currently never use MountMutation, but useLayout uses
  51396. // UnmountMutation.
  51397. commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
  51398. return;
  51399. }
  51400. case Profiler:
  51401. {
  51402. return;
  51403. }
  51404. case SuspenseComponent:
  51405. {
  51406. commitSuspenseComponent(finishedWork);
  51407. attachSuspenseRetryListeners(finishedWork);
  51408. return;
  51409. }
  51410. case SuspenseListComponent:
  51411. {
  51412. attachSuspenseRetryListeners(finishedWork);
  51413. return;
  51414. }
  51415. case HostRoot:
  51416. {
  51417. if (supportsHydration) {
  51418. var root = finishedWork.stateNode;
  51419. if (root.hydrate) {
  51420. // We've just hydrated. No need to hydrate again.
  51421. root.hydrate = false;
  51422. commitHydratedContainer(root.containerInfo);
  51423. }
  51424. }
  51425. break;
  51426. }
  51427. }
  51428. commitContainer(finishedWork);
  51429. return;
  51430. }
  51431. switch (finishedWork.tag) {
  51432. case FunctionComponent:
  51433. case ForwardRef:
  51434. case MemoComponent:
  51435. case SimpleMemoComponent:
  51436. {
  51437. // Note: We currently never use MountMutation, but useLayout uses
  51438. // UnmountMutation.
  51439. commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
  51440. return;
  51441. }
  51442. case ClassComponent:
  51443. {
  51444. return;
  51445. }
  51446. case HostComponent:
  51447. {
  51448. var instance = finishedWork.stateNode;
  51449. if (instance != null) {
  51450. // Commit the work prepared earlier.
  51451. var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
  51452. // as the newProps. The updatePayload will contain the real change in
  51453. // this case.
  51454. var oldProps = current$$1 !== null ? current$$1.memoizedProps : newProps;
  51455. var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components.
  51456. var updatePayload = finishedWork.updateQueue;
  51457. finishedWork.updateQueue = null;
  51458. if (updatePayload !== null) {
  51459. commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork);
  51460. }
  51461. if (enableFlareAPI) {
  51462. var prevListeners = oldProps.listeners;
  51463. var nextListeners = newProps.listeners;
  51464. if (prevListeners !== nextListeners) {
  51465. updateEventListeners(nextListeners, finishedWork, null);
  51466. }
  51467. }
  51468. }
  51469. return;
  51470. }
  51471. case HostText:
  51472. {
  51473. (function () {
  51474. if (!(finishedWork.stateNode !== null)) {
  51475. {
  51476. throw ReactError(Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue."));
  51477. }
  51478. }
  51479. })();
  51480. var textInstance = finishedWork.stateNode;
  51481. var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
  51482. // as the newProps. The updatePayload will contain the real change in
  51483. // this case.
  51484. var oldText = current$$1 !== null ? current$$1.memoizedProps : newText;
  51485. commitTextUpdate(textInstance, oldText, newText);
  51486. return;
  51487. }
  51488. case HostRoot:
  51489. {
  51490. if (supportsHydration) {
  51491. var _root = finishedWork.stateNode;
  51492. if (_root.hydrate) {
  51493. // We've just hydrated. No need to hydrate again.
  51494. _root.hydrate = false;
  51495. commitHydratedContainer(_root.containerInfo);
  51496. }
  51497. }
  51498. return;
  51499. }
  51500. case Profiler:
  51501. {
  51502. return;
  51503. }
  51504. case SuspenseComponent:
  51505. {
  51506. commitSuspenseComponent(finishedWork);
  51507. attachSuspenseRetryListeners(finishedWork);
  51508. return;
  51509. }
  51510. case SuspenseListComponent:
  51511. {
  51512. attachSuspenseRetryListeners(finishedWork);
  51513. return;
  51514. }
  51515. case IncompleteClassComponent:
  51516. {
  51517. return;
  51518. }
  51519. case FundamentalComponent:
  51520. {
  51521. if (enableFundamentalAPI) {
  51522. var fundamentalInstance = finishedWork.stateNode;
  51523. updateFundamentalComponent(fundamentalInstance);
  51524. }
  51525. return;
  51526. }
  51527. case ScopeComponent:
  51528. {
  51529. if (enableScopeAPI) {
  51530. var scopeInstance = finishedWork.stateNode;
  51531. scopeInstance.fiber = finishedWork;
  51532. if (enableFlareAPI) {
  51533. var _newProps = finishedWork.memoizedProps;
  51534. var _oldProps = current$$1 !== null ? current$$1.memoizedProps : _newProps;
  51535. var _prevListeners = _oldProps.listeners;
  51536. var _nextListeners = _newProps.listeners;
  51537. if (_prevListeners !== _nextListeners) {
  51538. updateEventListeners(_nextListeners, finishedWork, null);
  51539. }
  51540. }
  51541. }
  51542. return;
  51543. }
  51544. default:
  51545. {
  51546. (function () {
  51547. {
  51548. {
  51549. throw ReactError(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."));
  51550. }
  51551. }
  51552. })();
  51553. }
  51554. }
  51555. }
  51556. function commitSuspenseComponent(finishedWork) {
  51557. var newState = finishedWork.memoizedState;
  51558. var newDidTimeout;
  51559. var primaryChildParent = finishedWork;
  51560. if (newState === null) {
  51561. newDidTimeout = false;
  51562. } else {
  51563. newDidTimeout = true;
  51564. primaryChildParent = finishedWork.child;
  51565. markCommitTimeOfFallback();
  51566. }
  51567. if (supportsMutation && primaryChildParent !== null) {
  51568. hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
  51569. }
  51570. if (enableSuspenseCallback && newState !== null) {
  51571. var suspenseCallback = finishedWork.memoizedProps.suspenseCallback;
  51572. if (typeof suspenseCallback === 'function') {
  51573. var thenables = finishedWork.updateQueue;
  51574. if (thenables !== null) {
  51575. suspenseCallback(new Set(thenables));
  51576. }
  51577. } else {
  51578. if (suspenseCallback !== undefined) {
  51579. warning$1(false, 'Unexpected type for suspenseCallback.');
  51580. }
  51581. }
  51582. }
  51583. }
  51584. function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) {
  51585. if (!supportsHydration) {
  51586. return;
  51587. }
  51588. var newState = finishedWork.memoizedState;
  51589. if (newState === null) {
  51590. var current$$1 = finishedWork.alternate;
  51591. if (current$$1 !== null) {
  51592. var prevState = current$$1.memoizedState;
  51593. if (prevState !== null) {
  51594. var suspenseInstance = prevState.dehydrated;
  51595. if (suspenseInstance !== null) {
  51596. commitHydratedSuspenseInstance(suspenseInstance);
  51597. if (enableSuspenseCallback) {
  51598. var hydrationCallbacks = finishedRoot.hydrationCallbacks;
  51599. if (hydrationCallbacks !== null) {
  51600. var onHydrated = hydrationCallbacks.onHydrated;
  51601. if (onHydrated) {
  51602. onHydrated(suspenseInstance);
  51603. }
  51604. }
  51605. }
  51606. }
  51607. }
  51608. }
  51609. }
  51610. }
  51611. function attachSuspenseRetryListeners(finishedWork) {
  51612. // If this boundary just timed out, then it will have a set of thenables.
  51613. // For each thenable, attach a listener so that when it resolves, React
  51614. // attempts to re-render the boundary in the primary (pre-timeout) state.
  51615. var thenables = finishedWork.updateQueue;
  51616. if (thenables !== null) {
  51617. finishedWork.updateQueue = null;
  51618. var retryCache = finishedWork.stateNode;
  51619. if (retryCache === null) {
  51620. retryCache = finishedWork.stateNode = new PossiblyWeakSet();
  51621. }
  51622. thenables.forEach(function (thenable) {
  51623. // Memoize using the boundary fiber to prevent redundant listeners.
  51624. var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
  51625. if (!retryCache.has(thenable)) {
  51626. if (enableSchedulerTracing) {
  51627. if (thenable.__reactDoNotTraceInteractions !== true) {
  51628. retry = tracing.unstable_wrap(retry);
  51629. }
  51630. }
  51631. retryCache.add(thenable);
  51632. thenable.then(retry, retry);
  51633. }
  51634. });
  51635. }
  51636. }
  51637. function commitResetTextContent(current$$1) {
  51638. if (!supportsMutation) {
  51639. return;
  51640. }
  51641. resetTextContent(current$$1.stateNode);
  51642. }
  51643. var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map;
  51644. function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
  51645. var update = createUpdate(expirationTime, null); // Unmount the root by rendering null.
  51646. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property
  51647. // being called "element".
  51648. update.payload = {
  51649. element: null
  51650. };
  51651. var error = errorInfo.value;
  51652. update.callback = function () {
  51653. onUncaughtError(error);
  51654. logError(fiber, errorInfo);
  51655. };
  51656. return update;
  51657. }
  51658. function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
  51659. var update = createUpdate(expirationTime, null);
  51660. update.tag = CaptureUpdate;
  51661. var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
  51662. if (typeof getDerivedStateFromError === 'function') {
  51663. var error = errorInfo.value;
  51664. update.payload = function () {
  51665. logError(fiber, errorInfo);
  51666. return getDerivedStateFromError(error);
  51667. };
  51668. }
  51669. var inst = fiber.stateNode;
  51670. if (inst !== null && typeof inst.componentDidCatch === 'function') {
  51671. update.callback = function callback() {
  51672. {
  51673. markFailedErrorBoundaryForHotReloading(fiber);
  51674. }
  51675. if (typeof getDerivedStateFromError !== 'function') {
  51676. // To preserve the preexisting retry behavior of error boundaries,
  51677. // we keep track of which ones already failed during this batch.
  51678. // This gets reset before we yield back to the browser.
  51679. // TODO: Warn in strict mode if getDerivedStateFromError is
  51680. // not defined.
  51681. markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined
  51682. logError(fiber, errorInfo);
  51683. }
  51684. var error = errorInfo.value;
  51685. var stack = errorInfo.stack;
  51686. this.componentDidCatch(error, {
  51687. componentStack: stack !== null ? stack : ''
  51688. });
  51689. {
  51690. if (typeof getDerivedStateFromError !== 'function') {
  51691. // If componentDidCatch is the only error boundary method defined,
  51692. // then it needs to call setState to recover from errors.
  51693. // If no state update is scheduled then the boundary will swallow the error.
  51694. !(fiber.expirationTime === Sync) ? warningWithoutStack$1(false, '%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') : void 0;
  51695. }
  51696. }
  51697. };
  51698. } else {
  51699. update.callback = function () {
  51700. markFailedErrorBoundaryForHotReloading(fiber);
  51701. };
  51702. }
  51703. return update;
  51704. }
  51705. function attachPingListener(root, renderExpirationTime, thenable) {
  51706. // Attach a listener to the promise to "ping" the root and retry. But
  51707. // only if one does not already exist for the current render expiration
  51708. // time (which acts like a "thread ID" here).
  51709. var pingCache = root.pingCache;
  51710. var threadIDs;
  51711. if (pingCache === null) {
  51712. pingCache = root.pingCache = new PossiblyWeakMap$1();
  51713. threadIDs = new Set();
  51714. pingCache.set(thenable, threadIDs);
  51715. } else {
  51716. threadIDs = pingCache.get(thenable);
  51717. if (threadIDs === undefined) {
  51718. threadIDs = new Set();
  51719. pingCache.set(thenable, threadIDs);
  51720. }
  51721. }
  51722. if (!threadIDs.has(renderExpirationTime)) {
  51723. // Memoize using the thread ID to prevent redundant listeners.
  51724. threadIDs.add(renderExpirationTime);
  51725. var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
  51726. thenable.then(ping, ping);
  51727. }
  51728. }
  51729. function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
  51730. // The source fiber did not complete.
  51731. sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid.
  51732. sourceFiber.firstEffect = sourceFiber.lastEffect = null;
  51733. if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
  51734. // This is a thenable.
  51735. var thenable = value;
  51736. checkForWrongSuspensePriorityInDEV(sourceFiber);
  51737. var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext); // Schedule the nearest Suspense to re-render the timed out view.
  51738. var _workInProgress = returnFiber;
  51739. do {
  51740. if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) {
  51741. // Found the nearest boundary.
  51742. // Stash the promise on the boundary fiber. If the boundary times out, we'll
  51743. // attach another listener to flip the boundary back to its normal state.
  51744. var thenables = _workInProgress.updateQueue;
  51745. if (thenables === null) {
  51746. var updateQueue = new Set();
  51747. updateQueue.add(thenable);
  51748. _workInProgress.updateQueue = updateQueue;
  51749. } else {
  51750. thenables.add(thenable);
  51751. } // If the boundary is outside of batched mode, we should *not*
  51752. // suspend the commit. Pretend as if the suspended component rendered
  51753. // null and keep rendering. In the commit phase, we'll schedule a
  51754. // subsequent synchronous update to re-render the Suspense.
  51755. //
  51756. // Note: It doesn't matter whether the component that suspended was
  51757. // inside a batched mode tree. If the Suspense is outside of it, we
  51758. // should *not* suspend the commit.
  51759. if ((_workInProgress.mode & BatchedMode) === NoMode) {
  51760. _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete.
  51761. // But we shouldn't call any lifecycle methods or callbacks. Remove
  51762. // all lifecycle effect tags.
  51763. sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
  51764. if (sourceFiber.tag === ClassComponent) {
  51765. var currentSourceFiber = sourceFiber.alternate;
  51766. if (currentSourceFiber === null) {
  51767. // This is a new mount. Change the tag so it's not mistaken for a
  51768. // completed class component. For example, we should not call
  51769. // componentWillUnmount if it is deleted.
  51770. sourceFiber.tag = IncompleteClassComponent;
  51771. } else {
  51772. // When we try rendering again, we should not reuse the current fiber,
  51773. // since it's known to be in an inconsistent state. Use a force update to
  51774. // prevent a bail out.
  51775. var update = createUpdate(Sync, null);
  51776. update.tag = ForceUpdate;
  51777. enqueueUpdate(sourceFiber, update);
  51778. }
  51779. } // The source fiber did not complete. Mark it with Sync priority to
  51780. // indicate that it still has pending work.
  51781. sourceFiber.expirationTime = Sync; // Exit without suspending.
  51782. return;
  51783. } // Confirmed that the boundary is in a concurrent mode tree. Continue
  51784. // with the normal suspend path.
  51785. //
  51786. // After this we'll use a set of heuristics to determine whether this
  51787. // render pass will run to completion or restart or "suspend" the commit.
  51788. // The actual logic for this is spread out in different places.
  51789. //
  51790. // This first principle is that if we're going to suspend when we complete
  51791. // a root, then we should also restart if we get an update or ping that
  51792. // might unsuspend it, and vice versa. The only reason to suspend is
  51793. // because you think you might want to restart before committing. However,
  51794. // it doesn't make sense to restart only while in the period we're suspended.
  51795. //
  51796. // Restarting too aggressively is also not good because it starves out any
  51797. // intermediate loading state. So we use heuristics to determine when.
  51798. // Suspense Heuristics
  51799. //
  51800. // If nothing threw a Promise or all the same fallbacks are already showing,
  51801. // then don't suspend/restart.
  51802. //
  51803. // If this is an initial render of a new tree of Suspense boundaries and
  51804. // those trigger a fallback, then don't suspend/restart. We want to ensure
  51805. // that we can show the initial loading state as quickly as possible.
  51806. //
  51807. // If we hit a "Delayed" case, such as when we'd switch from content back into
  51808. // a fallback, then we should always suspend/restart. SuspenseConfig applies to
  51809. // this case. If none is defined, JND is used instead.
  51810. //
  51811. // If we're already showing a fallback and it gets "retried", allowing us to show
  51812. // another level, but there's still an inner boundary that would show a fallback,
  51813. // then we suspend/restart for 500ms since the last time we showed a fallback
  51814. // anywhere in the tree. This effectively throttles progressive loading into a
  51815. // consistent train of commits. This also gives us an opportunity to restart to
  51816. // get to the completed state slightly earlier.
  51817. //
  51818. // If there's ambiguity due to batching it's resolved in preference of:
  51819. // 1) "delayed", 2) "initial render", 3) "retry".
  51820. //
  51821. // We want to ensure that a "busy" state doesn't get force committed. We want to
  51822. // ensure that new initial loading states can commit as soon as possible.
  51823. attachPingListener(root, renderExpirationTime, thenable);
  51824. _workInProgress.effectTag |= ShouldCapture;
  51825. _workInProgress.expirationTime = renderExpirationTime;
  51826. return;
  51827. } // This boundary already captured during this render. Continue to the next
  51828. // boundary.
  51829. _workInProgress = _workInProgress.return;
  51830. } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode.
  51831. // TODO: Use invariant so the message is stripped in prod?
  51832. 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));
  51833. } // We didn't find a boundary that could handle this type of exception. Start
  51834. // over and traverse parent path again, this time treating the exception
  51835. // as an error.
  51836. renderDidError();
  51837. value = createCapturedValue(value, sourceFiber);
  51838. var workInProgress = returnFiber;
  51839. do {
  51840. switch (workInProgress.tag) {
  51841. case HostRoot:
  51842. {
  51843. var _errorInfo = value;
  51844. workInProgress.effectTag |= ShouldCapture;
  51845. workInProgress.expirationTime = renderExpirationTime;
  51846. var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
  51847. enqueueCapturedUpdate(workInProgress, _update);
  51848. return;
  51849. }
  51850. case ClassComponent:
  51851. // Capture and retry
  51852. var errorInfo = value;
  51853. var ctor = workInProgress.type;
  51854. var instance = workInProgress.stateNode;
  51855. if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
  51856. workInProgress.effectTag |= ShouldCapture;
  51857. workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state
  51858. var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
  51859. enqueueCapturedUpdate(workInProgress, _update2);
  51860. return;
  51861. }
  51862. break;
  51863. default:
  51864. break;
  51865. }
  51866. workInProgress = workInProgress.return;
  51867. } while (workInProgress !== null);
  51868. }
  51869. var ceil = Math.ceil;
  51870. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  51871. var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
  51872. var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
  51873. var NoContext =
  51874. /* */
  51875. 0;
  51876. var BatchedContext =
  51877. /* */
  51878. 1;
  51879. var EventContext =
  51880. /* */
  51881. 2;
  51882. var DiscreteEventContext =
  51883. /* */
  51884. 4;
  51885. var LegacyUnbatchedContext =
  51886. /* */
  51887. 8;
  51888. var RenderContext =
  51889. /* */
  51890. 16;
  51891. var CommitContext =
  51892. /* */
  51893. 32;
  51894. var RootIncomplete = 0;
  51895. var RootFatalErrored = 1;
  51896. var RootErrored = 2;
  51897. var RootSuspended = 3;
  51898. var RootSuspendedWithDelay = 4;
  51899. var RootCompleted = 5;
  51900. var RootLocked = 6;
  51901. // Describes where we are in the React execution stack
  51902. var executionContext = NoContext; // The root we're working on
  51903. var workInProgressRoot = null; // The fiber we're working on
  51904. var workInProgress = null; // The expiration time we're rendering
  51905. var renderExpirationTime = NoWork; // Whether to root completed, errored, suspended, etc.
  51906. var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown
  51907. var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render.
  51908. // This is conceptually a time stamp but expressed in terms of an ExpirationTime
  51909. // because we deal mostly with expiration times in the hot path, so this avoids
  51910. // the conversion happening in the hot path.
  51911. var workInProgressRootLatestProcessedExpirationTime = Sync;
  51912. var workInProgressRootLatestSuspenseTimeout = Sync;
  51913. var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only
  51914. // includes unprocessed updates, not work in bailed out children.
  51915. var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately.
  51916. // This flag determines if it might be worthwhile to restart if an opportunity
  51917. // happens latere.
  51918. var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train
  51919. // model where we don't commit new loading states in too quick succession.
  51920. var globalMostRecentFallbackTime = 0;
  51921. var FALLBACK_THROTTLE_MS = 500;
  51922. var nextEffect = null;
  51923. var hasUncaughtError = false;
  51924. var firstUncaughtError = null;
  51925. var legacyErrorBoundariesThatAlreadyFailed = null;
  51926. var rootDoesHavePassiveEffects = false;
  51927. var rootWithPendingPassiveEffects = null;
  51928. var pendingPassiveEffectsRenderPriority = NoPriority;
  51929. var pendingPassiveEffectsExpirationTime = NoWork;
  51930. var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates
  51931. var NESTED_UPDATE_LIMIT = 50;
  51932. var nestedUpdateCount = 0;
  51933. var rootWithNestedUpdates = null;
  51934. var NESTED_PASSIVE_UPDATE_LIMIT = 50;
  51935. var nestedPassiveUpdateCount = 0;
  51936. var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times
  51937. // during the commit phase. This enables them to be traced across components
  51938. // that spawn new work during render. E.g. hidden boundaries, suspended SSR
  51939. // hydration or SuspenseList.
  51940. var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start
  51941. // time). However, if two updates are scheduled within the same event, we
  51942. // should treat their start times as simultaneous, even if the actual clock
  51943. // time has advanced between the first and second call.
  51944. // In other words, because expiration times determine how updates are batched,
  51945. // we want all updates of like priority that occur within the same event to
  51946. // receive the same expiration time. Otherwise we get tearing.
  51947. var currentEventTime = NoWork;
  51948. function requestCurrentTime() {
  51949. if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
  51950. // We're inside React, so it's fine to read the actual time.
  51951. return msToExpirationTime(now());
  51952. } // We're not inside React, so we may be in the middle of a browser event.
  51953. if (currentEventTime !== NoWork) {
  51954. // Use the same start time for all updates until we enter React again.
  51955. return currentEventTime;
  51956. } // This is the first update since React yielded. Compute a new start time.
  51957. currentEventTime = msToExpirationTime(now());
  51958. return currentEventTime;
  51959. }
  51960. function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
  51961. var mode = fiber.mode;
  51962. if ((mode & BatchedMode) === NoMode) {
  51963. return Sync;
  51964. }
  51965. var priorityLevel = getCurrentPriorityLevel();
  51966. if ((mode & ConcurrentMode) === NoMode) {
  51967. return priorityLevel === ImmediatePriority ? Sync : Batched;
  51968. }
  51969. if ((executionContext & RenderContext) !== NoContext) {
  51970. // Use whatever time we're already rendering
  51971. // TODO: Should there be a way to opt out, like with `runWithPriority`?
  51972. return renderExpirationTime;
  51973. }
  51974. var expirationTime;
  51975. if (suspenseConfig !== null) {
  51976. // Compute an expiration time based on the Suspense timeout.
  51977. expirationTime = computeSuspenseExpiration(currentTime, suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
  51978. } else {
  51979. // Compute an expiration time based on the Scheduler priority.
  51980. switch (priorityLevel) {
  51981. case ImmediatePriority:
  51982. expirationTime = Sync;
  51983. break;
  51984. case UserBlockingPriority$2:
  51985. // TODO: Rename this to computeUserBlockingExpiration
  51986. expirationTime = computeInteractiveExpiration(currentTime);
  51987. break;
  51988. case NormalPriority:
  51989. case LowPriority:
  51990. // TODO: Handle LowPriority
  51991. // TODO: Rename this to... something better.
  51992. expirationTime = computeAsyncExpiration(currentTime);
  51993. break;
  51994. case IdlePriority:
  51995. expirationTime = Idle;
  51996. break;
  51997. default:
  51998. (function () {
  51999. {
  52000. {
  52001. throw ReactError(Error("Expected a valid priority level"));
  52002. }
  52003. }
  52004. })();
  52005. }
  52006. } // If we're in the middle of rendering a tree, do not update at the same
  52007. // expiration time that is already rendering.
  52008. // TODO: We shouldn't have to do this if the update is on a different root.
  52009. // Refactor computeExpirationForFiber + scheduleUpdate so we have access to
  52010. // the root when we check for this condition.
  52011. if (workInProgressRoot !== null && expirationTime === renderExpirationTime) {
  52012. // This is a trick to move this update into a separate batch
  52013. expirationTime -= 1;
  52014. }
  52015. return expirationTime;
  52016. }
  52017. var lastUniqueAsyncExpiration = NoWork;
  52018. function computeUniqueAsyncExpiration() {
  52019. var currentTime = requestCurrentTime();
  52020. var result = computeAsyncExpiration(currentTime);
  52021. if (result <= lastUniqueAsyncExpiration) {
  52022. // Since we assume the current time monotonically increases, we only hit
  52023. // this branch when computeUniqueAsyncExpiration is fired multiple times
  52024. // within a 200ms window (or whatever the async bucket size is).
  52025. result -= 1;
  52026. }
  52027. lastUniqueAsyncExpiration = result;
  52028. return result;
  52029. }
  52030. function scheduleUpdateOnFiber(fiber, expirationTime) {
  52031. checkForNestedUpdates();
  52032. warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber);
  52033. var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
  52034. if (root === null) {
  52035. warnAboutUpdateOnUnmountedFiberInDEV(fiber);
  52036. return;
  52037. }
  52038. checkForInterruption(fiber, expirationTime);
  52039. recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the
  52040. // priority as an argument to that function and this one.
  52041. var priorityLevel = getCurrentPriorityLevel();
  52042. if (expirationTime === Sync) {
  52043. if ( // Check if we're inside unbatchedUpdates
  52044. (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
  52045. (executionContext & (RenderContext | CommitContext)) === NoContext) {
  52046. // Register pending interactions on the root to avoid losing traced interaction data.
  52047. schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
  52048. // root inside of batchedUpdates should be synchronous, but layout updates
  52049. // should be deferred until the end of the batch.
  52050. performSyncWorkOnRoot(root);
  52051. } else {
  52052. ensureRootIsScheduled(root);
  52053. schedulePendingInteractions(root, expirationTime);
  52054. if (executionContext === NoContext) {
  52055. // Flush the synchronous work now, unless we're already working or inside
  52056. // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
  52057. // scheduleCallbackForFiber to preserve the ability to schedule a callback
  52058. // without immediately flushing it. We only do this for user-initiated
  52059. // updates, to preserve historical behavior of sync mode.
  52060. flushSyncCallbackQueue();
  52061. }
  52062. }
  52063. } else {
  52064. ensureRootIsScheduled(root);
  52065. schedulePendingInteractions(root, expirationTime);
  52066. }
  52067. if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered
  52068. // discrete, even inside a discrete event.
  52069. priorityLevel === UserBlockingPriority$2 || priorityLevel === ImmediatePriority)) {
  52070. // This is the result of a discrete event. Track the lowest priority
  52071. // discrete update per root so we can flush them early, if needed.
  52072. if (rootsWithPendingDiscreteUpdates === null) {
  52073. rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
  52074. } else {
  52075. var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
  52076. if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
  52077. rootsWithPendingDiscreteUpdates.set(root, expirationTime);
  52078. }
  52079. }
  52080. }
  52081. }
  52082. var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending
  52083. // work without treating it as a typical update that originates from an event;
  52084. // e.g. retrying a Suspense boundary isn't an update, but it does schedule work
  52085. // on a fiber.
  52086. function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
  52087. // Update the source fiber's expiration time
  52088. if (fiber.expirationTime < expirationTime) {
  52089. fiber.expirationTime = expirationTime;
  52090. }
  52091. var alternate = fiber.alternate;
  52092. if (alternate !== null && alternate.expirationTime < expirationTime) {
  52093. alternate.expirationTime = expirationTime;
  52094. } // Walk the parent path to the root and update the child expiration time.
  52095. var node = fiber.return;
  52096. var root = null;
  52097. if (node === null && fiber.tag === HostRoot) {
  52098. root = fiber.stateNode;
  52099. } else {
  52100. while (node !== null) {
  52101. alternate = node.alternate;
  52102. if (node.childExpirationTime < expirationTime) {
  52103. node.childExpirationTime = expirationTime;
  52104. if (alternate !== null && alternate.childExpirationTime < expirationTime) {
  52105. alternate.childExpirationTime = expirationTime;
  52106. }
  52107. } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
  52108. alternate.childExpirationTime = expirationTime;
  52109. }
  52110. if (node.return === null && node.tag === HostRoot) {
  52111. root = node.stateNode;
  52112. break;
  52113. }
  52114. node = node.return;
  52115. }
  52116. }
  52117. if (root !== null) {
  52118. if (workInProgressRoot === root) {
  52119. // Received an update to a tree that's in the middle of rendering. Mark
  52120. // that's unprocessed work on this root.
  52121. markUnprocessedUpdateTime(expirationTime);
  52122. if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
  52123. // The root already suspended with a delay, which means this render
  52124. // definitely won't finish. Since we have a new update, let's mark it as
  52125. // suspended now, right before marking the incoming update. This has the
  52126. // effect of interrupting the current render and switching to the update.
  52127. // TODO: This happens to work when receiving an update during the render
  52128. // phase, because of the trick inside computeExpirationForFiber to
  52129. // subtract 1 from `renderExpirationTime` to move it into a
  52130. // separate bucket. But we should probably model it with an exception,
  52131. // using the same mechanism we use to force hydration of a subtree.
  52132. // TODO: This does not account for low pri updates that were already
  52133. // scheduled before the root started rendering. Need to track the next
  52134. // pending expiration time (perhaps by backtracking the return path) and
  52135. // then trigger a restart in the `renderDidSuspendDelayIfPossible` path.
  52136. markRootSuspendedAtTime(root, renderExpirationTime);
  52137. }
  52138. } // Mark that the root has a pending update.
  52139. markRootUpdatedAtTime(root, expirationTime);
  52140. }
  52141. return root;
  52142. }
  52143. function getNextRootExpirationTimeToWorkOn(root) {
  52144. // Determines the next expiration time that the root should render, taking
  52145. // into account levels that may be suspended, or levels that may have
  52146. // received a ping.
  52147. var lastExpiredTime = root.lastExpiredTime;
  52148. if (lastExpiredTime !== NoWork) {
  52149. return lastExpiredTime;
  52150. } // "Pending" refers to any update that hasn't committed yet, including if it
  52151. // suspended. The "suspended" range is therefore a subset.
  52152. var firstPendingTime = root.firstPendingTime;
  52153. if (!isRootSuspendedAtTime(root, firstPendingTime)) {
  52154. // The highest priority pending time is not suspended. Let's work on that.
  52155. return firstPendingTime;
  52156. } // If the first pending time is suspended, check if there's a lower priority
  52157. // pending level that we know about. Or check if we received a ping. Work
  52158. // on whichever is higher priority.
  52159. var lastPingedTime = root.lastPingedTime;
  52160. var nextKnownPendingLevel = root.nextKnownPendingLevel;
  52161. return lastPingedTime > nextKnownPendingLevel ? lastPingedTime : nextKnownPendingLevel;
  52162. } // Use this function to schedule a task for a root. There's only one task per
  52163. // root; if a task was already scheduled, we'll check to make sure the
  52164. // expiration time of the existing task is the same as the expiration time of
  52165. // the next level that the root has work on. This function is called on every
  52166. // update, and right before exiting a task.
  52167. function ensureRootIsScheduled(root) {
  52168. var lastExpiredTime = root.lastExpiredTime;
  52169. if (lastExpiredTime !== NoWork) {
  52170. // Special case: Expired work should flush synchronously.
  52171. root.callbackExpirationTime = Sync;
  52172. root.callbackPriority = ImmediatePriority;
  52173. root.callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
  52174. return;
  52175. }
  52176. var expirationTime = getNextRootExpirationTimeToWorkOn(root);
  52177. var existingCallbackNode = root.callbackNode;
  52178. if (expirationTime === NoWork) {
  52179. // There's nothing to work on.
  52180. if (existingCallbackNode !== null) {
  52181. root.callbackNode = null;
  52182. root.callbackExpirationTime = NoWork;
  52183. root.callbackPriority = NoPriority;
  52184. }
  52185. return;
  52186. } // TODO: If this is an update, we already read the current time. Pass the
  52187. // time as an argument.
  52188. var currentTime = requestCurrentTime();
  52189. var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime); // If there's an existing render task, confirm it has the correct priority and
  52190. // expiration time. Otherwise, we'll cancel it and schedule a new one.
  52191. if (existingCallbackNode !== null) {
  52192. var existingCallbackPriority = root.callbackPriority;
  52193. var existingCallbackExpirationTime = root.callbackExpirationTime;
  52194. if ( // Callback must have the exact same expiration time.
  52195. existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority.
  52196. existingCallbackPriority >= priorityLevel) {
  52197. // Existing callback is sufficient.
  52198. return;
  52199. } // Need to schedule a new task.
  52200. // TODO: Instead of scheduling a new task, we should be able to change the
  52201. // priority of the existing one.
  52202. cancelCallback(existingCallbackNode);
  52203. }
  52204. root.callbackExpirationTime = expirationTime;
  52205. root.callbackPriority = priorityLevel;
  52206. var callbackNode;
  52207. if (expirationTime === Sync) {
  52208. // Sync React callbacks are scheduled on a special internal queue
  52209. callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
  52210. } else if (disableSchedulerTimeoutBasedOnReactExpirationTime) {
  52211. callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root));
  52212. } else {
  52213. callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects
  52214. // ordering because tasks are processed in timeout order.
  52215. {
  52216. timeout: expirationTimeToMs(expirationTime) - now()
  52217. });
  52218. }
  52219. root.callbackNode = callbackNode;
  52220. } // This is the entry point for every concurrent task, i.e. anything that
  52221. // goes through Scheduler.
  52222. function performConcurrentWorkOnRoot(root, didTimeout) {
  52223. // Since we know we're in a React event, we can clear the current
  52224. // event time. The next update will compute a new event time.
  52225. currentEventTime = NoWork;
  52226. if (didTimeout) {
  52227. // The render task took too long to complete. Mark the current time as
  52228. // expired to synchronously render all expired work in a single batch.
  52229. var currentTime = requestCurrentTime();
  52230. markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback.
  52231. ensureRootIsScheduled(root);
  52232. return null;
  52233. } // Determine the next expiration time to work on, using the fields stored
  52234. // on the root.
  52235. var expirationTime = getNextRootExpirationTimeToWorkOn(root);
  52236. if (expirationTime !== NoWork) {
  52237. var originalCallbackNode = root.callbackNode;
  52238. (function () {
  52239. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  52240. {
  52241. throw ReactError(Error("Should not already be working."));
  52242. }
  52243. }
  52244. })();
  52245. flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack
  52246. // and prepare a fresh one. Otherwise we'll continue where we left off.
  52247. if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
  52248. prepareFreshStack(root, expirationTime);
  52249. startWorkOnPendingInteractions(root, expirationTime);
  52250. } // If we have a work-in-progress fiber, it means there's still work to do
  52251. // in this root.
  52252. if (workInProgress !== null) {
  52253. var prevExecutionContext = executionContext;
  52254. executionContext |= RenderContext;
  52255. var prevDispatcher = pushDispatcher(root);
  52256. var prevInteractions = pushInteractions(root);
  52257. startWorkLoopTimer(workInProgress);
  52258. do {
  52259. try {
  52260. workLoopConcurrent();
  52261. break;
  52262. } catch (thrownValue) {
  52263. handleError(root, thrownValue);
  52264. }
  52265. } while (true);
  52266. resetContextDependencies();
  52267. executionContext = prevExecutionContext;
  52268. popDispatcher(prevDispatcher);
  52269. if (enableSchedulerTracing) {
  52270. popInteractions(prevInteractions);
  52271. }
  52272. if (workInProgressRootExitStatus === RootFatalErrored) {
  52273. var fatalError = workInProgressRootFatalError;
  52274. stopInterruptedWorkLoopTimer();
  52275. prepareFreshStack(root, expirationTime);
  52276. markRootSuspendedAtTime(root, expirationTime);
  52277. ensureRootIsScheduled(root);
  52278. throw fatalError;
  52279. }
  52280. if (workInProgress !== null) {
  52281. // There's still work left over. Exit without committing.
  52282. stopInterruptedWorkLoopTimer();
  52283. } else {
  52284. // We now have a consistent tree. The next step is either to commit it,
  52285. // or, if something suspended, wait to commit it after a timeout.
  52286. stopFinishedWorkLoopTimer();
  52287. var finishedWork = root.finishedWork = root.current.alternate;
  52288. root.finishedExpirationTime = expirationTime;
  52289. resolveLocksOnRoot(root, expirationTime);
  52290. finishConcurrentRender(root, finishedWork, workInProgressRootExitStatus, expirationTime);
  52291. }
  52292. ensureRootIsScheduled(root);
  52293. if (root.callbackNode === originalCallbackNode) {
  52294. // The task node scheduled for this root is the same one that's
  52295. // currently executed. Need to return a continuation.
  52296. return performConcurrentWorkOnRoot.bind(null, root);
  52297. }
  52298. }
  52299. }
  52300. return null;
  52301. }
  52302. function finishConcurrentRender(root, finishedWork, exitStatus, expirationTime) {
  52303. // Set this to null to indicate there's no in-progress render.
  52304. workInProgressRoot = null;
  52305. switch (exitStatus) {
  52306. case RootIncomplete:
  52307. case RootFatalErrored:
  52308. {
  52309. (function () {
  52310. {
  52311. {
  52312. throw ReactError(Error("Root did not complete. This is a bug in React."));
  52313. }
  52314. }
  52315. })();
  52316. }
  52317. // Flow knows about invariant, so it complains if I add a break
  52318. // statement, but eslint doesn't know about invariant, so it complains
  52319. // if I do. eslint-disable-next-line no-fallthrough
  52320. case RootErrored:
  52321. {
  52322. if (expirationTime !== Idle) {
  52323. // If this was an async render, the error may have happened due to
  52324. // a mutation in a concurrent event. Try rendering one more time,
  52325. // synchronously, to see if the error goes away. If there are
  52326. // lower priority updates, let's include those, too, in case they
  52327. // fix the inconsistency. Render at Idle to include all updates.
  52328. markRootExpiredAtTime(root, Idle);
  52329. break;
  52330. } // Commit the root in its errored state.
  52331. commitRoot(root);
  52332. break;
  52333. }
  52334. case RootSuspended:
  52335. {
  52336. markRootSuspendedAtTime(root, expirationTime);
  52337. var lastSuspendedTime = root.lastSuspendedTime;
  52338. if (expirationTime === lastSuspendedTime) {
  52339. root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
  52340. }
  52341. flushSuspensePriorityWarningInDEV(); // We have an acceptable loading state. We need to figure out if we
  52342. // should immediately commit it or wait a bit.
  52343. // If we have processed new updates during this render, we may now
  52344. // have a new loading state ready. We want to ensure that we commit
  52345. // that as soon as possible.
  52346. var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync;
  52347. if (hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope
  52348. !( true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
  52349. // If we have not processed any new updates during this pass, then
  52350. // this is either a retry of an existing fallback state or a
  52351. // hidden tree. Hidden trees shouldn't be batched with other work
  52352. // and after that's fixed it can only be a retry. We're going to
  52353. // throttle committing retries so that we don't show too many
  52354. // loading states too quickly.
  52355. var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time.
  52356. if (msUntilTimeout > 10) {
  52357. if (workInProgressRootHasPendingPing) {
  52358. var lastPingedTime = root.lastPingedTime;
  52359. if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) {
  52360. // This render was pinged but we didn't get to restart
  52361. // earlier so try restarting now instead.
  52362. root.lastPingedTime = expirationTime;
  52363. prepareFreshStack(root, expirationTime);
  52364. break;
  52365. }
  52366. }
  52367. var nextTime = getNextRootExpirationTimeToWorkOn(root);
  52368. if (nextTime !== NoWork && nextTime !== expirationTime) {
  52369. // There's additional work on this root.
  52370. break;
  52371. }
  52372. if (lastSuspendedTime !== NoWork && lastSuspendedTime !== expirationTime) {
  52373. // We should prefer to render the fallback of at the last
  52374. // suspended level. Ping the last suspended level to try
  52375. // rendering it again.
  52376. root.lastPingedTime = lastSuspendedTime;
  52377. break;
  52378. } // The render is suspended, it hasn't timed out, and there's no
  52379. // lower priority work to do. Instead of committing the fallback
  52380. // immediately, wait for more data to arrive.
  52381. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout);
  52382. break;
  52383. }
  52384. } // The work expired. Commit immediately.
  52385. commitRoot(root);
  52386. break;
  52387. }
  52388. case RootSuspendedWithDelay:
  52389. {
  52390. markRootSuspendedAtTime(root, expirationTime);
  52391. var _lastSuspendedTime = root.lastSuspendedTime;
  52392. if (expirationTime === _lastSuspendedTime) {
  52393. root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
  52394. }
  52395. flushSuspensePriorityWarningInDEV();
  52396. if ( // do not delay if we're inside an act() scope
  52397. !( true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
  52398. // We're suspended in a state that should be avoided. We'll try to
  52399. // avoid committing it for as long as the timeouts let us.
  52400. if (workInProgressRootHasPendingPing) {
  52401. var _lastPingedTime = root.lastPingedTime;
  52402. if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) {
  52403. // This render was pinged but we didn't get to restart earlier
  52404. // so try restarting now instead.
  52405. root.lastPingedTime = expirationTime;
  52406. prepareFreshStack(root, expirationTime);
  52407. break;
  52408. }
  52409. }
  52410. var _nextTime = getNextRootExpirationTimeToWorkOn(root);
  52411. if (_nextTime !== NoWork && _nextTime !== expirationTime) {
  52412. // There's additional work on this root.
  52413. break;
  52414. }
  52415. if (_lastSuspendedTime !== NoWork && _lastSuspendedTime !== expirationTime) {
  52416. // We should prefer to render the fallback of at the last
  52417. // suspended level. Ping the last suspended level to try
  52418. // rendering it again.
  52419. root.lastPingedTime = _lastSuspendedTime;
  52420. break;
  52421. }
  52422. var _msUntilTimeout;
  52423. if (workInProgressRootLatestSuspenseTimeout !== Sync) {
  52424. // We have processed a suspense config whose expiration time we
  52425. // can use as the timeout.
  52426. _msUntilTimeout = expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now();
  52427. } else if (workInProgressRootLatestProcessedExpirationTime === Sync) {
  52428. // This should never normally happen because only new updates
  52429. // cause delayed states, so we should have processed something.
  52430. // However, this could also happen in an offscreen tree.
  52431. _msUntilTimeout = 0;
  52432. } else {
  52433. // If we don't have a suspense config, we're going to use a
  52434. // heuristic to determine how long we can suspend.
  52435. var eventTimeMs = inferTimeFromExpirationTime(workInProgressRootLatestProcessedExpirationTime);
  52436. var currentTimeMs = now();
  52437. var timeUntilExpirationMs = expirationTimeToMs(expirationTime) - currentTimeMs;
  52438. var timeElapsed = currentTimeMs - eventTimeMs;
  52439. if (timeElapsed < 0) {
  52440. // We get this wrong some time since we estimate the time.
  52441. timeElapsed = 0;
  52442. }
  52443. _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the
  52444. // event time is exact instead of inferred from expiration time
  52445. // we don't need this.
  52446. if (timeUntilExpirationMs < _msUntilTimeout) {
  52447. _msUntilTimeout = timeUntilExpirationMs;
  52448. }
  52449. } // Don't bother with a very short suspense time.
  52450. if (_msUntilTimeout > 10) {
  52451. // The render is suspended, it hasn't timed out, and there's no
  52452. // lower priority work to do. Instead of committing the fallback
  52453. // immediately, wait for more data to arrive.
  52454. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout);
  52455. break;
  52456. }
  52457. } // The work expired. Commit immediately.
  52458. commitRoot(root);
  52459. break;
  52460. }
  52461. case RootCompleted:
  52462. {
  52463. // The work completed. Ready to commit.
  52464. if ( // do not delay if we're inside an act() scope
  52465. !( true && flushSuspenseFallbacksInTests && IsThisRendererActing.current) && workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null) {
  52466. // If we have exceeded the minimum loading delay, which probably
  52467. // means we have shown a spinner already, we might have to suspend
  52468. // a bit longer to ensure that the spinner is shown for
  52469. // enough time.
  52470. var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(workInProgressRootLatestProcessedExpirationTime, expirationTime, workInProgressRootCanSuspendUsingConfig);
  52471. if (_msUntilTimeout2 > 10) {
  52472. markRootSuspendedAtTime(root, expirationTime);
  52473. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout2);
  52474. break;
  52475. }
  52476. }
  52477. commitRoot(root);
  52478. break;
  52479. }
  52480. case RootLocked:
  52481. {
  52482. // This root has a lock that prevents it from committing. Exit. If
  52483. // we begin work on the root again, without any intervening updates,
  52484. // it will finish without doing additional work.
  52485. markRootSuspendedAtTime(root, expirationTime);
  52486. break;
  52487. }
  52488. default:
  52489. {
  52490. (function () {
  52491. {
  52492. {
  52493. throw ReactError(Error("Unknown root exit status."));
  52494. }
  52495. }
  52496. })();
  52497. }
  52498. }
  52499. } // This is the entry point for synchronous tasks that don't go
  52500. // through Scheduler
  52501. function performSyncWorkOnRoot(root) {
  52502. // Check if there's expired work on this root. Otherwise, render at Sync.
  52503. var lastExpiredTime = root.lastExpiredTime;
  52504. var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync;
  52505. if (root.finishedExpirationTime === expirationTime) {
  52506. // There's already a pending commit at this expiration time.
  52507. // TODO: This is poorly factored. This case only exists for the
  52508. // batch.commit() API.
  52509. commitRoot(root);
  52510. } else {
  52511. (function () {
  52512. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  52513. {
  52514. throw ReactError(Error("Should not already be working."));
  52515. }
  52516. }
  52517. })();
  52518. flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack
  52519. // and prepare a fresh one. Otherwise we'll continue where we left off.
  52520. if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
  52521. prepareFreshStack(root, expirationTime);
  52522. startWorkOnPendingInteractions(root, expirationTime);
  52523. } // If we have a work-in-progress fiber, it means there's still work to do
  52524. // in this root.
  52525. if (workInProgress !== null) {
  52526. var prevExecutionContext = executionContext;
  52527. executionContext |= RenderContext;
  52528. var prevDispatcher = pushDispatcher(root);
  52529. var prevInteractions = pushInteractions(root);
  52530. startWorkLoopTimer(workInProgress);
  52531. do {
  52532. try {
  52533. workLoopSync();
  52534. break;
  52535. } catch (thrownValue) {
  52536. handleError(root, thrownValue);
  52537. }
  52538. } while (true);
  52539. resetContextDependencies();
  52540. executionContext = prevExecutionContext;
  52541. popDispatcher(prevDispatcher);
  52542. if (enableSchedulerTracing) {
  52543. popInteractions(prevInteractions);
  52544. }
  52545. if (workInProgressRootExitStatus === RootFatalErrored) {
  52546. var fatalError = workInProgressRootFatalError;
  52547. stopInterruptedWorkLoopTimer();
  52548. prepareFreshStack(root, expirationTime);
  52549. markRootSuspendedAtTime(root, expirationTime);
  52550. ensureRootIsScheduled(root);
  52551. throw fatalError;
  52552. }
  52553. if (workInProgress !== null) {
  52554. // This is a sync render, so we should have finished the whole tree.
  52555. (function () {
  52556. {
  52557. {
  52558. throw ReactError(Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."));
  52559. }
  52560. }
  52561. })();
  52562. } else {
  52563. // We now have a consistent tree. Because this is a sync render, we
  52564. // will commit it even if something suspended. The only exception is
  52565. // if the root is locked (using the unstable_createBatch API).
  52566. stopFinishedWorkLoopTimer();
  52567. root.finishedWork = root.current.alternate;
  52568. root.finishedExpirationTime = expirationTime;
  52569. resolveLocksOnRoot(root, expirationTime);
  52570. finishSyncRender(root, workInProgressRootExitStatus, expirationTime);
  52571. } // Before exiting, make sure there's a callback scheduled for the next
  52572. // pending level.
  52573. ensureRootIsScheduled(root);
  52574. }
  52575. }
  52576. return null;
  52577. }
  52578. function finishSyncRender(root, exitStatus, expirationTime) {
  52579. if (exitStatus === RootLocked) {
  52580. // This root has a lock that prevents it from committing. Exit. If we
  52581. // begin work on the root again, without any intervening updates, it
  52582. // will finish without doing additional work.
  52583. markRootSuspendedAtTime(root, expirationTime);
  52584. } else {
  52585. // Set this to null to indicate there's no in-progress render.
  52586. workInProgressRoot = null;
  52587. {
  52588. if (exitStatus === RootSuspended || exitStatus === RootSuspendedWithDelay) {
  52589. flushSuspensePriorityWarningInDEV();
  52590. }
  52591. }
  52592. commitRoot(root);
  52593. }
  52594. }
  52595. function flushRoot(root, expirationTime) {
  52596. if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
  52597. (function () {
  52598. {
  52599. {
  52600. throw ReactError(Error("work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method."));
  52601. }
  52602. }
  52603. })();
  52604. }
  52605. markRootExpiredAtTime(root, expirationTime);
  52606. ensureRootIsScheduled(root);
  52607. flushSyncCallbackQueue();
  52608. }
  52609. function flushDiscreteUpdates() {
  52610. // TODO: Should be able to flush inside batchedUpdates, but not inside `act`.
  52611. // However, `act` uses `batchedUpdates`, so there's no way to distinguish
  52612. // those two cases. Need to fix this before exposing flushDiscreteUpdates
  52613. // as a public API.
  52614. if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) {
  52615. if ( true && (executionContext & RenderContext) !== NoContext) {
  52616. warning$1(false, 'unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.');
  52617. } // We're already rendering, so we can't synchronously flush pending work.
  52618. // This is probably a nested event dispatch triggered by a lifecycle/effect,
  52619. // like `el.focus()`. Exit.
  52620. return;
  52621. }
  52622. flushPendingDiscreteUpdates(); // If the discrete updates scheduled passive effects, flush them now so that
  52623. // they fire before the next serial event.
  52624. flushPassiveEffects();
  52625. }
  52626. function resolveLocksOnRoot(root, expirationTime) {
  52627. var firstBatch = root.firstBatch;
  52628. if (firstBatch !== null && firstBatch._defer && firstBatch._expirationTime >= expirationTime) {
  52629. scheduleCallback(NormalPriority, function () {
  52630. firstBatch._onComplete();
  52631. return null;
  52632. });
  52633. workInProgressRootExitStatus = RootLocked;
  52634. }
  52635. }
  52636. function flushPendingDiscreteUpdates() {
  52637. if (rootsWithPendingDiscreteUpdates !== null) {
  52638. // For each root with pending discrete updates, schedule a callback to
  52639. // immediately flush them.
  52640. var roots = rootsWithPendingDiscreteUpdates;
  52641. rootsWithPendingDiscreteUpdates = null;
  52642. roots.forEach(function (expirationTime, root) {
  52643. markRootExpiredAtTime(root, expirationTime);
  52644. ensureRootIsScheduled(root);
  52645. }); // Now flush the immediate queue.
  52646. flushSyncCallbackQueue();
  52647. }
  52648. }
  52649. function batchedUpdates$1(fn, a) {
  52650. var prevExecutionContext = executionContext;
  52651. executionContext |= BatchedContext;
  52652. try {
  52653. return fn(a);
  52654. } finally {
  52655. executionContext = prevExecutionContext;
  52656. if (executionContext === NoContext) {
  52657. // Flush the immediate callbacks that were scheduled during this batch
  52658. flushSyncCallbackQueue();
  52659. }
  52660. }
  52661. }
  52662. function batchedEventUpdates$1(fn, a) {
  52663. var prevExecutionContext = executionContext;
  52664. executionContext |= EventContext;
  52665. try {
  52666. return fn(a);
  52667. } finally {
  52668. executionContext = prevExecutionContext;
  52669. if (executionContext === NoContext) {
  52670. // Flush the immediate callbacks that were scheduled during this batch
  52671. flushSyncCallbackQueue();
  52672. }
  52673. }
  52674. }
  52675. function discreteUpdates$1(fn, a, b, c) {
  52676. var prevExecutionContext = executionContext;
  52677. executionContext |= DiscreteEventContext;
  52678. try {
  52679. // Should this
  52680. return runWithPriority$2(UserBlockingPriority$2, fn.bind(null, a, b, c));
  52681. } finally {
  52682. executionContext = prevExecutionContext;
  52683. if (executionContext === NoContext) {
  52684. // Flush the immediate callbacks that were scheduled during this batch
  52685. flushSyncCallbackQueue();
  52686. }
  52687. }
  52688. }
  52689. function unbatchedUpdates(fn, a) {
  52690. var prevExecutionContext = executionContext;
  52691. executionContext &= ~BatchedContext;
  52692. executionContext |= LegacyUnbatchedContext;
  52693. try {
  52694. return fn(a);
  52695. } finally {
  52696. executionContext = prevExecutionContext;
  52697. if (executionContext === NoContext) {
  52698. // Flush the immediate callbacks that were scheduled during this batch
  52699. flushSyncCallbackQueue();
  52700. }
  52701. }
  52702. }
  52703. function flushSync(fn, a) {
  52704. if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
  52705. (function () {
  52706. {
  52707. {
  52708. throw ReactError(Error("flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering."));
  52709. }
  52710. }
  52711. })();
  52712. }
  52713. var prevExecutionContext = executionContext;
  52714. executionContext |= BatchedContext;
  52715. try {
  52716. return runWithPriority$2(ImmediatePriority, fn.bind(null, a));
  52717. } finally {
  52718. executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch.
  52719. // Note that this will happen even if batchedUpdates is higher up
  52720. // the stack.
  52721. flushSyncCallbackQueue();
  52722. }
  52723. }
  52724. function flushControlled(fn) {
  52725. var prevExecutionContext = executionContext;
  52726. executionContext |= BatchedContext;
  52727. try {
  52728. runWithPriority$2(ImmediatePriority, fn);
  52729. } finally {
  52730. executionContext = prevExecutionContext;
  52731. if (executionContext === NoContext) {
  52732. // Flush the immediate callbacks that were scheduled during this batch
  52733. flushSyncCallbackQueue();
  52734. }
  52735. }
  52736. }
  52737. function prepareFreshStack(root, expirationTime) {
  52738. root.finishedWork = null;
  52739. root.finishedExpirationTime = NoWork;
  52740. var timeoutHandle = root.timeoutHandle;
  52741. if (timeoutHandle !== noTimeout) {
  52742. // The root previous suspended and scheduled a timeout to commit a fallback
  52743. // state. Now that we have additional work, cancel the timeout.
  52744. root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
  52745. cancelTimeout(timeoutHandle);
  52746. }
  52747. if (workInProgress !== null) {
  52748. var interruptedWork = workInProgress.return;
  52749. while (interruptedWork !== null) {
  52750. unwindInterruptedWork(interruptedWork);
  52751. interruptedWork = interruptedWork.return;
  52752. }
  52753. }
  52754. workInProgressRoot = root;
  52755. workInProgress = createWorkInProgress(root.current, null, expirationTime);
  52756. renderExpirationTime = expirationTime;
  52757. workInProgressRootExitStatus = RootIncomplete;
  52758. workInProgressRootFatalError = null;
  52759. workInProgressRootLatestProcessedExpirationTime = Sync;
  52760. workInProgressRootLatestSuspenseTimeout = Sync;
  52761. workInProgressRootCanSuspendUsingConfig = null;
  52762. workInProgressRootNextUnprocessedUpdateTime = NoWork;
  52763. workInProgressRootHasPendingPing = false;
  52764. if (enableSchedulerTracing) {
  52765. spawnedWorkDuringRender = null;
  52766. }
  52767. {
  52768. ReactStrictModeWarnings.discardPendingWarnings();
  52769. componentsThatTriggeredHighPriSuspend = null;
  52770. }
  52771. }
  52772. function handleError(root, thrownValue) {
  52773. do {
  52774. try {
  52775. // Reset module-level state that was set during the render phase.
  52776. resetContextDependencies();
  52777. resetHooks();
  52778. if (workInProgress === null || workInProgress.return === null) {
  52779. // Expected to be working on a non-root fiber. This is a fatal error
  52780. // because there's no ancestor that can handle it; the root is
  52781. // supposed to capture all errors that weren't caught by an error
  52782. // boundary.
  52783. workInProgressRootExitStatus = RootFatalErrored;
  52784. workInProgressRootFatalError = thrownValue;
  52785. return null;
  52786. }
  52787. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  52788. // Record the time spent rendering before an error was thrown. This
  52789. // avoids inaccurate Profiler durations in the case of a
  52790. // suspended render.
  52791. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
  52792. }
  52793. throwException(root, workInProgress.return, workInProgress, thrownValue, renderExpirationTime);
  52794. workInProgress = completeUnitOfWork(workInProgress);
  52795. } catch (yetAnotherThrownValue) {
  52796. // Something in the return path also threw.
  52797. thrownValue = yetAnotherThrownValue;
  52798. continue;
  52799. } // Return to the normal work loop.
  52800. return;
  52801. } while (true);
  52802. }
  52803. function pushDispatcher(root) {
  52804. var prevDispatcher = ReactCurrentDispatcher.current;
  52805. ReactCurrentDispatcher.current = ContextOnlyDispatcher;
  52806. if (prevDispatcher === null) {
  52807. // The React isomorphic package does not include a default dispatcher.
  52808. // Instead the first renderer will lazily attach one, in order to give
  52809. // nicer error messages.
  52810. return ContextOnlyDispatcher;
  52811. } else {
  52812. return prevDispatcher;
  52813. }
  52814. }
  52815. function popDispatcher(prevDispatcher) {
  52816. ReactCurrentDispatcher.current = prevDispatcher;
  52817. }
  52818. function pushInteractions(root) {
  52819. if (enableSchedulerTracing) {
  52820. var prevInteractions = tracing.__interactionsRef.current;
  52821. tracing.__interactionsRef.current = root.memoizedInteractions;
  52822. return prevInteractions;
  52823. }
  52824. return null;
  52825. }
  52826. function popInteractions(prevInteractions) {
  52827. if (enableSchedulerTracing) {
  52828. tracing.__interactionsRef.current = prevInteractions;
  52829. }
  52830. }
  52831. function markCommitTimeOfFallback() {
  52832. globalMostRecentFallbackTime = now();
  52833. }
  52834. function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
  52835. if (expirationTime < workInProgressRootLatestProcessedExpirationTime && expirationTime > Idle) {
  52836. workInProgressRootLatestProcessedExpirationTime = expirationTime;
  52837. }
  52838. if (suspenseConfig !== null) {
  52839. if (expirationTime < workInProgressRootLatestSuspenseTimeout && expirationTime > Idle) {
  52840. workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad.
  52841. workInProgressRootCanSuspendUsingConfig = suspenseConfig;
  52842. }
  52843. }
  52844. }
  52845. function markUnprocessedUpdateTime(expirationTime) {
  52846. if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) {
  52847. workInProgressRootNextUnprocessedUpdateTime = expirationTime;
  52848. }
  52849. }
  52850. function renderDidSuspend() {
  52851. if (workInProgressRootExitStatus === RootIncomplete) {
  52852. workInProgressRootExitStatus = RootSuspended;
  52853. }
  52854. }
  52855. function renderDidSuspendDelayIfPossible() {
  52856. if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
  52857. workInProgressRootExitStatus = RootSuspendedWithDelay;
  52858. } // Check if there's a lower priority update somewhere else in the tree.
  52859. if (workInProgressRootNextUnprocessedUpdateTime !== NoWork && workInProgressRoot !== null) {
  52860. // Mark the current render as suspended, and then mark that there's a
  52861. // pending update.
  52862. // TODO: This should immediately interrupt the current render, instead
  52863. // of waiting until the next time we yield.
  52864. markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime);
  52865. markRootUpdatedAtTime(workInProgressRoot, workInProgressRootNextUnprocessedUpdateTime);
  52866. }
  52867. }
  52868. function renderDidError() {
  52869. if (workInProgressRootExitStatus !== RootCompleted) {
  52870. workInProgressRootExitStatus = RootErrored;
  52871. }
  52872. } // Called during render to determine if anything has suspended.
  52873. // Returns false if we're not sure.
  52874. function renderHasNotSuspendedYet() {
  52875. // If something errored or completed, we can't really be sure,
  52876. // so those are false.
  52877. return workInProgressRootExitStatus === RootIncomplete;
  52878. }
  52879. function inferTimeFromExpirationTime(expirationTime) {
  52880. // We don't know exactly when the update was scheduled, but we can infer an
  52881. // approximate start time from the expiration time.
  52882. var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
  52883. return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
  52884. }
  52885. function inferTimeFromExpirationTimeWithSuspenseConfig(expirationTime, suspenseConfig) {
  52886. // We don't know exactly when the update was scheduled, but we can infer an
  52887. // approximate start time from the expiration time by subtracting the timeout
  52888. // that was added to the event time.
  52889. var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
  52890. return earliestExpirationTimeMs - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
  52891. } // The work loop is an extremely hot path. Tell Closure not to inline it.
  52892. /** @noinline */
  52893. function workLoopSync() {
  52894. // Already timed out, so perform work without checking if we need to yield.
  52895. while (workInProgress !== null) {
  52896. workInProgress = performUnitOfWork(workInProgress);
  52897. }
  52898. }
  52899. /** @noinline */
  52900. function workLoopConcurrent() {
  52901. // Perform work until Scheduler asks us to yield
  52902. while (workInProgress !== null && !shouldYield()) {
  52903. workInProgress = performUnitOfWork(workInProgress);
  52904. }
  52905. }
  52906. function performUnitOfWork(unitOfWork) {
  52907. // The current, flushed, state of this fiber is the alternate. Ideally
  52908. // nothing should rely on this, but relying on it here means that we don't
  52909. // need an additional field on the work in progress.
  52910. var current$$1 = unitOfWork.alternate;
  52911. startWorkTimer(unitOfWork);
  52912. setCurrentFiber(unitOfWork);
  52913. var next;
  52914. if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode) {
  52915. startProfilerTimer(unitOfWork);
  52916. next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
  52917. stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
  52918. } else {
  52919. next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
  52920. }
  52921. resetCurrentFiber();
  52922. unitOfWork.memoizedProps = unitOfWork.pendingProps;
  52923. if (next === null) {
  52924. // If this doesn't spawn new work, complete the current work.
  52925. next = completeUnitOfWork(unitOfWork);
  52926. }
  52927. ReactCurrentOwner$2.current = null;
  52928. return next;
  52929. }
  52930. function completeUnitOfWork(unitOfWork) {
  52931. // Attempt to complete the current unit of work, then move to the next
  52932. // sibling. If there are no more siblings, return to the parent fiber.
  52933. workInProgress = unitOfWork;
  52934. do {
  52935. // The current, flushed, state of this fiber is the alternate. Ideally
  52936. // nothing should rely on this, but relying on it here means that we don't
  52937. // need an additional field on the work in progress.
  52938. var current$$1 = workInProgress.alternate;
  52939. var returnFiber = workInProgress.return; // Check if the work completed or if something threw.
  52940. if ((workInProgress.effectTag & Incomplete) === NoEffect) {
  52941. setCurrentFiber(workInProgress);
  52942. var next = void 0;
  52943. if (!enableProfilerTimer || (workInProgress.mode & ProfileMode) === NoMode) {
  52944. next = completeWork(current$$1, workInProgress, renderExpirationTime);
  52945. } else {
  52946. startProfilerTimer(workInProgress);
  52947. next = completeWork(current$$1, workInProgress, renderExpirationTime); // Update render duration assuming we didn't error.
  52948. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
  52949. }
  52950. stopWorkTimer(workInProgress);
  52951. resetCurrentFiber();
  52952. resetChildExpirationTime(workInProgress);
  52953. if (next !== null) {
  52954. // Completing this fiber spawned new work. Work on that next.
  52955. return next;
  52956. }
  52957. if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete
  52958. (returnFiber.effectTag & Incomplete) === NoEffect) {
  52959. // Append all the effects of the subtree and this fiber onto the effect
  52960. // list of the parent. The completion order of the children affects the
  52961. // side-effect order.
  52962. if (returnFiber.firstEffect === null) {
  52963. returnFiber.firstEffect = workInProgress.firstEffect;
  52964. }
  52965. if (workInProgress.lastEffect !== null) {
  52966. if (returnFiber.lastEffect !== null) {
  52967. returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
  52968. }
  52969. returnFiber.lastEffect = workInProgress.lastEffect;
  52970. } // If this fiber had side-effects, we append it AFTER the children's
  52971. // side-effects. We can perform certain side-effects earlier if needed,
  52972. // by doing multiple passes over the effect list. We don't want to
  52973. // schedule our own side-effect on our own list because if end up
  52974. // reusing children we'll schedule this effect onto itself since we're
  52975. // at the end.
  52976. var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect
  52977. // list. PerformedWork effect is read by React DevTools but shouldn't be
  52978. // committed.
  52979. if (effectTag > PerformedWork) {
  52980. if (returnFiber.lastEffect !== null) {
  52981. returnFiber.lastEffect.nextEffect = workInProgress;
  52982. } else {
  52983. returnFiber.firstEffect = workInProgress;
  52984. }
  52985. returnFiber.lastEffect = workInProgress;
  52986. }
  52987. }
  52988. } else {
  52989. // This fiber did not complete because something threw. Pop values off
  52990. // the stack without entering the complete phase. If this is a boundary,
  52991. // capture values if possible.
  52992. var _next = unwindWork(workInProgress, renderExpirationTime); // Because this fiber did not complete, don't reset its expiration time.
  52993. if (enableProfilerTimer && (workInProgress.mode & ProfileMode) !== NoMode) {
  52994. // Record the render duration for the fiber that errored.
  52995. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing.
  52996. var actualDuration = workInProgress.actualDuration;
  52997. var child = workInProgress.child;
  52998. while (child !== null) {
  52999. actualDuration += child.actualDuration;
  53000. child = child.sibling;
  53001. }
  53002. workInProgress.actualDuration = actualDuration;
  53003. }
  53004. if (_next !== null) {
  53005. // If completing this work spawned new work, do that next. We'll come
  53006. // back here again.
  53007. // Since we're restarting, remove anything that is not a host effect
  53008. // from the effect tag.
  53009. // TODO: The name stopFailedWorkTimer is misleading because Suspense
  53010. // also captures and restarts.
  53011. stopFailedWorkTimer(workInProgress);
  53012. _next.effectTag &= HostEffectMask;
  53013. return _next;
  53014. }
  53015. stopWorkTimer(workInProgress);
  53016. if (returnFiber !== null) {
  53017. // Mark the parent fiber as incomplete and clear its effect list.
  53018. returnFiber.firstEffect = returnFiber.lastEffect = null;
  53019. returnFiber.effectTag |= Incomplete;
  53020. }
  53021. }
  53022. var siblingFiber = workInProgress.sibling;
  53023. if (siblingFiber !== null) {
  53024. // If there is more work to do in this returnFiber, do that next.
  53025. return siblingFiber;
  53026. } // Otherwise, return to the parent
  53027. workInProgress = returnFiber;
  53028. } while (workInProgress !== null); // We've reached the root.
  53029. if (workInProgressRootExitStatus === RootIncomplete) {
  53030. workInProgressRootExitStatus = RootCompleted;
  53031. }
  53032. return null;
  53033. }
  53034. function getRemainingExpirationTime(fiber) {
  53035. var updateExpirationTime = fiber.expirationTime;
  53036. var childExpirationTime = fiber.childExpirationTime;
  53037. return updateExpirationTime > childExpirationTime ? updateExpirationTime : childExpirationTime;
  53038. }
  53039. function resetChildExpirationTime(completedWork) {
  53040. if (renderExpirationTime !== Never && completedWork.childExpirationTime === Never) {
  53041. // The children of this component are hidden. Don't bubble their
  53042. // expiration times.
  53043. return;
  53044. }
  53045. var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time.
  53046. if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoMode) {
  53047. // In profiling mode, resetChildExpirationTime is also used to reset
  53048. // profiler durations.
  53049. var actualDuration = completedWork.actualDuration;
  53050. var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will
  53051. // only be updated if work is done on the fiber (i.e. it doesn't bailout).
  53052. // When work is done, it should bubble to the parent's actualDuration. If
  53053. // the fiber has not been cloned though, (meaning no work was done), then
  53054. // this value will reflect the amount of time spent working on a previous
  53055. // render. In that case it should not bubble. We determine whether it was
  53056. // cloned by comparing the child pointer.
  53057. var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
  53058. var child = completedWork.child;
  53059. while (child !== null) {
  53060. var childUpdateExpirationTime = child.expirationTime;
  53061. var childChildExpirationTime = child.childExpirationTime;
  53062. if (childUpdateExpirationTime > newChildExpirationTime) {
  53063. newChildExpirationTime = childUpdateExpirationTime;
  53064. }
  53065. if (childChildExpirationTime > newChildExpirationTime) {
  53066. newChildExpirationTime = childChildExpirationTime;
  53067. }
  53068. if (shouldBubbleActualDurations) {
  53069. actualDuration += child.actualDuration;
  53070. }
  53071. treeBaseDuration += child.treeBaseDuration;
  53072. child = child.sibling;
  53073. }
  53074. completedWork.actualDuration = actualDuration;
  53075. completedWork.treeBaseDuration = treeBaseDuration;
  53076. } else {
  53077. var _child = completedWork.child;
  53078. while (_child !== null) {
  53079. var _childUpdateExpirationTime = _child.expirationTime;
  53080. var _childChildExpirationTime = _child.childExpirationTime;
  53081. if (_childUpdateExpirationTime > newChildExpirationTime) {
  53082. newChildExpirationTime = _childUpdateExpirationTime;
  53083. }
  53084. if (_childChildExpirationTime > newChildExpirationTime) {
  53085. newChildExpirationTime = _childChildExpirationTime;
  53086. }
  53087. _child = _child.sibling;
  53088. }
  53089. }
  53090. completedWork.childExpirationTime = newChildExpirationTime;
  53091. }
  53092. function commitRoot(root) {
  53093. var renderPriorityLevel = getCurrentPriorityLevel();
  53094. runWithPriority$2(ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel));
  53095. return null;
  53096. }
  53097. function commitRootImpl(root, renderPriorityLevel) {
  53098. flushPassiveEffects();
  53099. flushRenderPhaseStrictModeWarningsInDEV();
  53100. (function () {
  53101. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  53102. {
  53103. throw ReactError(Error("Should not already be working."));
  53104. }
  53105. }
  53106. })();
  53107. var finishedWork = root.finishedWork;
  53108. var expirationTime = root.finishedExpirationTime;
  53109. if (finishedWork === null) {
  53110. return null;
  53111. }
  53112. root.finishedWork = null;
  53113. root.finishedExpirationTime = NoWork;
  53114. (function () {
  53115. if (!(finishedWork !== root.current)) {
  53116. {
  53117. throw ReactError(Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."));
  53118. }
  53119. }
  53120. })(); // commitRoot never returns a continuation; it always finishes synchronously.
  53121. // So we can clear these now to allow a new callback to be scheduled.
  53122. root.callbackNode = null;
  53123. root.callbackExpirationTime = NoWork;
  53124. root.callbackPriority = NoPriority;
  53125. root.nextKnownPendingLevel = NoWork;
  53126. startCommitTimer(); // Update the first and last pending times on this root. The new first
  53127. // pending time is whatever is left on the root fiber.
  53128. var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(finishedWork);
  53129. markRootFinishedAtTime(root, expirationTime, remainingExpirationTimeBeforeCommit);
  53130. if (root === workInProgressRoot) {
  53131. // We can reset these now that they are finished.
  53132. workInProgressRoot = null;
  53133. workInProgress = null;
  53134. renderExpirationTime = NoWork;
  53135. } else {} // This indicates that the last root we worked on is not the same one that
  53136. // we're committing now. This most commonly happens when a suspended root
  53137. // times out.
  53138. // Get the list of effects.
  53139. var firstEffect;
  53140. if (finishedWork.effectTag > PerformedWork) {
  53141. // A fiber's effect list consists only of its children, not itself. So if
  53142. // the root has an effect, we need to add it to the end of the list. The
  53143. // resulting list is the set that would belong to the root's parent, if it
  53144. // had one; that is, all the effects in the tree including the root.
  53145. if (finishedWork.lastEffect !== null) {
  53146. finishedWork.lastEffect.nextEffect = finishedWork;
  53147. firstEffect = finishedWork.firstEffect;
  53148. } else {
  53149. firstEffect = finishedWork;
  53150. }
  53151. } else {
  53152. // There is no effect on the root.
  53153. firstEffect = finishedWork.firstEffect;
  53154. }
  53155. if (firstEffect !== null) {
  53156. var prevExecutionContext = executionContext;
  53157. executionContext |= CommitContext;
  53158. var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles
  53159. ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass
  53160. // of the effect list for each phase: all mutation effects come before all
  53161. // layout effects, and so on.
  53162. // The first phase a "before mutation" phase. We use this phase to read the
  53163. // state of the host tree right before we mutate it. This is where
  53164. // getSnapshotBeforeUpdate is called.
  53165. startCommitSnapshotEffectsTimer();
  53166. prepareForCommit(root.containerInfo);
  53167. nextEffect = firstEffect;
  53168. do {
  53169. {
  53170. invokeGuardedCallback(null, commitBeforeMutationEffects, null);
  53171. if (hasCaughtError()) {
  53172. (function () {
  53173. if (!(nextEffect !== null)) {
  53174. {
  53175. throw ReactError(Error("Should be working on an effect."));
  53176. }
  53177. }
  53178. })();
  53179. var error = clearCaughtError();
  53180. captureCommitPhaseError(nextEffect, error);
  53181. nextEffect = nextEffect.nextEffect;
  53182. }
  53183. }
  53184. } while (nextEffect !== null);
  53185. stopCommitSnapshotEffectsTimer();
  53186. if (enableProfilerTimer) {
  53187. // Mark the current commit time to be shared by all Profilers in this
  53188. // batch. This enables them to be grouped later.
  53189. recordCommitTime();
  53190. } // The next phase is the mutation phase, where we mutate the host tree.
  53191. startCommitHostEffectsTimer();
  53192. nextEffect = firstEffect;
  53193. do {
  53194. {
  53195. invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel);
  53196. if (hasCaughtError()) {
  53197. (function () {
  53198. if (!(nextEffect !== null)) {
  53199. {
  53200. throw ReactError(Error("Should be working on an effect."));
  53201. }
  53202. }
  53203. })();
  53204. var _error = clearCaughtError();
  53205. captureCommitPhaseError(nextEffect, _error);
  53206. nextEffect = nextEffect.nextEffect;
  53207. }
  53208. }
  53209. } while (nextEffect !== null);
  53210. stopCommitHostEffectsTimer();
  53211. resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after
  53212. // the mutation phase, so that the previous tree is still current during
  53213. // componentWillUnmount, but before the layout phase, so that the finished
  53214. // work is current during componentDidMount/Update.
  53215. root.current = finishedWork; // The next phase is the layout phase, where we call effects that read
  53216. // the host tree after it's been mutated. The idiomatic use case for this is
  53217. // layout, but class component lifecycles also fire here for legacy reasons.
  53218. startCommitLifeCyclesTimer();
  53219. nextEffect = firstEffect;
  53220. do {
  53221. {
  53222. invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime);
  53223. if (hasCaughtError()) {
  53224. (function () {
  53225. if (!(nextEffect !== null)) {
  53226. {
  53227. throw ReactError(Error("Should be working on an effect."));
  53228. }
  53229. }
  53230. })();
  53231. var _error2 = clearCaughtError();
  53232. captureCommitPhaseError(nextEffect, _error2);
  53233. nextEffect = nextEffect.nextEffect;
  53234. }
  53235. }
  53236. } while (nextEffect !== null);
  53237. stopCommitLifeCyclesTimer();
  53238. nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an
  53239. // opportunity to paint.
  53240. requestPaint();
  53241. if (enableSchedulerTracing) {
  53242. popInteractions(prevInteractions);
  53243. }
  53244. executionContext = prevExecutionContext;
  53245. } else {
  53246. // No effects.
  53247. root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were
  53248. // no effects.
  53249. // TODO: Maybe there's a better way to report this.
  53250. startCommitSnapshotEffectsTimer();
  53251. stopCommitSnapshotEffectsTimer();
  53252. if (enableProfilerTimer) {
  53253. recordCommitTime();
  53254. }
  53255. startCommitHostEffectsTimer();
  53256. stopCommitHostEffectsTimer();
  53257. startCommitLifeCyclesTimer();
  53258. stopCommitLifeCyclesTimer();
  53259. }
  53260. stopCommitTimer();
  53261. var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
  53262. if (rootDoesHavePassiveEffects) {
  53263. // This commit has passive effects. Stash a reference to them. But don't
  53264. // schedule a callback until after flushing layout work.
  53265. rootDoesHavePassiveEffects = false;
  53266. rootWithPendingPassiveEffects = root;
  53267. pendingPassiveEffectsExpirationTime = expirationTime;
  53268. pendingPassiveEffectsRenderPriority = renderPriorityLevel;
  53269. } else {
  53270. // We are done with the effect chain at this point so let's clear the
  53271. // nextEffect pointers to assist with GC. If we have passive effects, we'll
  53272. // clear this in flushPassiveEffects.
  53273. nextEffect = firstEffect;
  53274. while (nextEffect !== null) {
  53275. var nextNextEffect = nextEffect.nextEffect;
  53276. nextEffect.nextEffect = null;
  53277. nextEffect = nextNextEffect;
  53278. }
  53279. } // Check if there's remaining work on this root
  53280. var remainingExpirationTime = root.firstPendingTime;
  53281. if (remainingExpirationTime !== NoWork) {
  53282. if (enableSchedulerTracing) {
  53283. if (spawnedWorkDuringRender !== null) {
  53284. var expirationTimes = spawnedWorkDuringRender;
  53285. spawnedWorkDuringRender = null;
  53286. for (var i = 0; i < expirationTimes.length; i++) {
  53287. scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions);
  53288. }
  53289. }
  53290. schedulePendingInteractions(root, remainingExpirationTime);
  53291. }
  53292. } else {
  53293. // If there's no remaining work, we can clear the set of already failed
  53294. // error boundaries.
  53295. legacyErrorBoundariesThatAlreadyFailed = null;
  53296. }
  53297. if (enableSchedulerTracing) {
  53298. if (!rootDidHavePassiveEffects) {
  53299. // If there are no passive effects, then we can complete the pending interactions.
  53300. // Otherwise, we'll wait until after the passive effects are flushed.
  53301. // Wait to do this until after remaining work has been scheduled,
  53302. // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
  53303. finishPendingInteractions(root, expirationTime);
  53304. }
  53305. }
  53306. if (remainingExpirationTime === Sync) {
  53307. // Count the number of times the root synchronously re-renders without
  53308. // finishing. If there are too many, it indicates an infinite update loop.
  53309. if (root === rootWithNestedUpdates) {
  53310. nestedUpdateCount++;
  53311. } else {
  53312. nestedUpdateCount = 0;
  53313. rootWithNestedUpdates = root;
  53314. }
  53315. } else {
  53316. nestedUpdateCount = 0;
  53317. }
  53318. onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any
  53319. // additional work on this root is scheduled.
  53320. ensureRootIsScheduled(root);
  53321. if (hasUncaughtError) {
  53322. hasUncaughtError = false;
  53323. var _error3 = firstUncaughtError;
  53324. firstUncaughtError = null;
  53325. throw _error3;
  53326. }
  53327. if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
  53328. // This is a legacy edge case. We just committed the initial mount of
  53329. // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
  53330. // synchronously, but layout updates should be deferred until the end
  53331. // of the batch.
  53332. return null;
  53333. } // If layout work was scheduled, flush it now.
  53334. flushSyncCallbackQueue();
  53335. return null;
  53336. }
  53337. function commitBeforeMutationEffects() {
  53338. while (nextEffect !== null) {
  53339. var effectTag = nextEffect.effectTag;
  53340. if ((effectTag & Snapshot) !== NoEffect) {
  53341. setCurrentFiber(nextEffect);
  53342. recordEffect();
  53343. var current$$1 = nextEffect.alternate;
  53344. commitBeforeMutationLifeCycles(current$$1, nextEffect);
  53345. resetCurrentFiber();
  53346. }
  53347. if ((effectTag & Passive) !== NoEffect) {
  53348. // If there are passive effects, schedule a callback to flush at
  53349. // the earliest opportunity.
  53350. if (!rootDoesHavePassiveEffects) {
  53351. rootDoesHavePassiveEffects = true;
  53352. scheduleCallback(NormalPriority, function () {
  53353. flushPassiveEffects();
  53354. return null;
  53355. });
  53356. }
  53357. }
  53358. nextEffect = nextEffect.nextEffect;
  53359. }
  53360. }
  53361. function commitMutationEffects(root, renderPriorityLevel) {
  53362. // TODO: Should probably move the bulk of this function to commitWork.
  53363. while (nextEffect !== null) {
  53364. setCurrentFiber(nextEffect);
  53365. var effectTag = nextEffect.effectTag;
  53366. if (effectTag & ContentReset) {
  53367. commitResetTextContent(nextEffect);
  53368. }
  53369. if (effectTag & Ref) {
  53370. var current$$1 = nextEffect.alternate;
  53371. if (current$$1 !== null) {
  53372. commitDetachRef(current$$1);
  53373. }
  53374. } // The following switch statement is only concerned about placement,
  53375. // updates, and deletions. To avoid needing to add a case for every possible
  53376. // bitmap value, we remove the secondary effects from the effect tag and
  53377. // switch on that value.
  53378. var primaryEffectTag = effectTag & (Placement | Update | Deletion | Hydrating);
  53379. switch (primaryEffectTag) {
  53380. case Placement:
  53381. {
  53382. commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
  53383. // inserted, before any life-cycles like componentDidMount gets called.
  53384. // TODO: findDOMNode doesn't rely on this any more but isMounted does
  53385. // and isMounted is deprecated anyway so we should be able to kill this.
  53386. nextEffect.effectTag &= ~Placement;
  53387. break;
  53388. }
  53389. case PlacementAndUpdate:
  53390. {
  53391. // Placement
  53392. commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
  53393. // inserted, before any life-cycles like componentDidMount gets called.
  53394. nextEffect.effectTag &= ~Placement; // Update
  53395. var _current = nextEffect.alternate;
  53396. commitWork(_current, nextEffect);
  53397. break;
  53398. }
  53399. case Hydrating:
  53400. {
  53401. nextEffect.effectTag &= ~Hydrating;
  53402. break;
  53403. }
  53404. case HydratingAndUpdate:
  53405. {
  53406. nextEffect.effectTag &= ~Hydrating; // Update
  53407. var _current2 = nextEffect.alternate;
  53408. commitWork(_current2, nextEffect);
  53409. break;
  53410. }
  53411. case Update:
  53412. {
  53413. var _current3 = nextEffect.alternate;
  53414. commitWork(_current3, nextEffect);
  53415. break;
  53416. }
  53417. case Deletion:
  53418. {
  53419. commitDeletion(root, nextEffect, renderPriorityLevel);
  53420. break;
  53421. }
  53422. } // TODO: Only record a mutation effect if primaryEffectTag is non-zero.
  53423. recordEffect();
  53424. resetCurrentFiber();
  53425. nextEffect = nextEffect.nextEffect;
  53426. }
  53427. }
  53428. function commitLayoutEffects(root, committedExpirationTime) {
  53429. // TODO: Should probably move the bulk of this function to commitWork.
  53430. while (nextEffect !== null) {
  53431. setCurrentFiber(nextEffect);
  53432. var effectTag = nextEffect.effectTag;
  53433. if (effectTag & (Update | Callback)) {
  53434. recordEffect();
  53435. var current$$1 = nextEffect.alternate;
  53436. commitLifeCycles(root, current$$1, nextEffect, committedExpirationTime);
  53437. }
  53438. if (effectTag & Ref) {
  53439. recordEffect();
  53440. commitAttachRef(nextEffect);
  53441. }
  53442. resetCurrentFiber();
  53443. nextEffect = nextEffect.nextEffect;
  53444. }
  53445. }
  53446. function flushPassiveEffects() {
  53447. if (pendingPassiveEffectsRenderPriority !== NoPriority) {
  53448. var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority ? NormalPriority : pendingPassiveEffectsRenderPriority;
  53449. pendingPassiveEffectsRenderPriority = NoPriority;
  53450. return runWithPriority$2(priorityLevel, flushPassiveEffectsImpl);
  53451. }
  53452. }
  53453. function flushPassiveEffectsImpl() {
  53454. if (rootWithPendingPassiveEffects === null) {
  53455. return false;
  53456. }
  53457. var root = rootWithPendingPassiveEffects;
  53458. var expirationTime = pendingPassiveEffectsExpirationTime;
  53459. rootWithPendingPassiveEffects = null;
  53460. pendingPassiveEffectsExpirationTime = NoWork;
  53461. (function () {
  53462. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  53463. {
  53464. throw ReactError(Error("Cannot flush passive effects while already rendering."));
  53465. }
  53466. }
  53467. })();
  53468. var prevExecutionContext = executionContext;
  53469. executionContext |= CommitContext;
  53470. var prevInteractions = pushInteractions(root); // Note: This currently assumes there are no passive effects on the root
  53471. // fiber, because the root is not part of its own effect list. This could
  53472. // change in the future.
  53473. var effect = root.current.firstEffect;
  53474. while (effect !== null) {
  53475. {
  53476. setCurrentFiber(effect);
  53477. invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
  53478. if (hasCaughtError()) {
  53479. (function () {
  53480. if (!(effect !== null)) {
  53481. {
  53482. throw ReactError(Error("Should be working on an effect."));
  53483. }
  53484. }
  53485. })();
  53486. var error = clearCaughtError();
  53487. captureCommitPhaseError(effect, error);
  53488. }
  53489. resetCurrentFiber();
  53490. }
  53491. var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC
  53492. effect.nextEffect = null;
  53493. effect = nextNextEffect;
  53494. }
  53495. if (enableSchedulerTracing) {
  53496. popInteractions(prevInteractions);
  53497. finishPendingInteractions(root, expirationTime);
  53498. }
  53499. executionContext = prevExecutionContext;
  53500. flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this
  53501. // exceeds the limit, we'll fire a warning.
  53502. nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
  53503. return true;
  53504. }
  53505. function isAlreadyFailedLegacyErrorBoundary(instance) {
  53506. return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
  53507. }
  53508. function markLegacyErrorBoundaryAsFailed(instance) {
  53509. if (legacyErrorBoundariesThatAlreadyFailed === null) {
  53510. legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
  53511. } else {
  53512. legacyErrorBoundariesThatAlreadyFailed.add(instance);
  53513. }
  53514. }
  53515. function prepareToThrowUncaughtError(error) {
  53516. if (!hasUncaughtError) {
  53517. hasUncaughtError = true;
  53518. firstUncaughtError = error;
  53519. }
  53520. }
  53521. var onUncaughtError = prepareToThrowUncaughtError;
  53522. function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
  53523. var errorInfo = createCapturedValue(error, sourceFiber);
  53524. var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
  53525. enqueueUpdate(rootFiber, update);
  53526. var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
  53527. if (root !== null) {
  53528. ensureRootIsScheduled(root);
  53529. schedulePendingInteractions(root, Sync);
  53530. }
  53531. }
  53532. function captureCommitPhaseError(sourceFiber, error) {
  53533. if (sourceFiber.tag === HostRoot) {
  53534. // Error was thrown at the root. There is no parent, so the root
  53535. // itself should capture it.
  53536. captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
  53537. return;
  53538. }
  53539. var fiber = sourceFiber.return;
  53540. while (fiber !== null) {
  53541. if (fiber.tag === HostRoot) {
  53542. captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
  53543. return;
  53544. } else if (fiber.tag === ClassComponent) {
  53545. var ctor = fiber.type;
  53546. var instance = fiber.stateNode;
  53547. if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
  53548. var errorInfo = createCapturedValue(error, sourceFiber);
  53549. var update = createClassErrorUpdate(fiber, errorInfo, // TODO: This is always sync
  53550. Sync);
  53551. enqueueUpdate(fiber, update);
  53552. var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
  53553. if (root !== null) {
  53554. ensureRootIsScheduled(root);
  53555. schedulePendingInteractions(root, Sync);
  53556. }
  53557. return;
  53558. }
  53559. }
  53560. fiber = fiber.return;
  53561. }
  53562. }
  53563. function pingSuspendedRoot(root, thenable, suspendedTime) {
  53564. var pingCache = root.pingCache;
  53565. if (pingCache !== null) {
  53566. // The thenable resolved, so we no longer need to memoize, because it will
  53567. // never be thrown again.
  53568. pingCache.delete(thenable);
  53569. }
  53570. if (workInProgressRoot === root && renderExpirationTime === suspendedTime) {
  53571. // Received a ping at the same priority level at which we're currently
  53572. // rendering. We might want to restart this render. This should mirror
  53573. // the logic of whether or not a root suspends once it completes.
  53574. // TODO: If we're rendering sync either due to Sync, Batched or expired,
  53575. // we should probably never restart.
  53576. // If we're suspended with delay, we'll always suspend so we can always
  53577. // restart. If we're suspended without any updates, it might be a retry.
  53578. // If it's early in the retry we can restart. We can't know for sure
  53579. // whether we'll eventually process an update during this render pass,
  53580. // but it's somewhat unlikely that we get to a ping before that, since
  53581. // getting to the root most update is usually very fast.
  53582. if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
  53583. // Restart from the root. Don't need to schedule a ping because
  53584. // we're already working on this tree.
  53585. prepareFreshStack(root, renderExpirationTime);
  53586. } else {
  53587. // Even though we can't restart right now, we might get an
  53588. // opportunity later. So we mark this render as having a ping.
  53589. workInProgressRootHasPendingPing = true;
  53590. }
  53591. return;
  53592. }
  53593. if (!isRootSuspendedAtTime(root, suspendedTime)) {
  53594. // The root is no longer suspended at this time.
  53595. return;
  53596. }
  53597. var lastPingedTime = root.lastPingedTime;
  53598. if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) {
  53599. // There's already a lower priority ping scheduled.
  53600. return;
  53601. } // Mark the time at which this ping was scheduled.
  53602. root.lastPingedTime = suspendedTime;
  53603. if (root.finishedExpirationTime === suspendedTime) {
  53604. // If there's a pending fallback waiting to commit, throw it away.
  53605. root.finishedExpirationTime = NoWork;
  53606. root.finishedWork = null;
  53607. }
  53608. ensureRootIsScheduled(root);
  53609. schedulePendingInteractions(root, suspendedTime);
  53610. }
  53611. function retryTimedOutBoundary(boundaryFiber, retryTime) {
  53612. // The boundary fiber (a Suspense component or SuspenseList component)
  53613. // previously was rendered in its fallback state. One of the promises that
  53614. // suspended it has resolved, which means at least part of the tree was
  53615. // likely unblocked. Try rendering again, at a new expiration time.
  53616. if (retryTime === Never) {
  53617. var suspenseConfig = null; // Retries don't carry over the already committed update.
  53618. var currentTime = requestCurrentTime();
  53619. retryTime = computeExpirationForFiber(currentTime, boundaryFiber, suspenseConfig);
  53620. } // TODO: Special case idle priority?
  53621. var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
  53622. if (root !== null) {
  53623. ensureRootIsScheduled(root);
  53624. schedulePendingInteractions(root, retryTime);
  53625. }
  53626. }
  53627. function retryDehydratedSuspenseBoundary(boundaryFiber) {
  53628. var suspenseState = boundaryFiber.memoizedState;
  53629. var retryTime = Never;
  53630. if (suspenseState !== null) {
  53631. retryTime = suspenseState.retryTime;
  53632. }
  53633. retryTimedOutBoundary(boundaryFiber, retryTime);
  53634. }
  53635. function resolveRetryThenable(boundaryFiber, thenable) {
  53636. var retryTime = Never; // Default
  53637. var retryCache;
  53638. if (enableSuspenseServerRenderer) {
  53639. switch (boundaryFiber.tag) {
  53640. case SuspenseComponent:
  53641. retryCache = boundaryFiber.stateNode;
  53642. var suspenseState = boundaryFiber.memoizedState;
  53643. if (suspenseState !== null) {
  53644. retryTime = suspenseState.retryTime;
  53645. }
  53646. break;
  53647. case SuspenseListComponent:
  53648. retryCache = boundaryFiber.stateNode;
  53649. break;
  53650. default:
  53651. (function () {
  53652. {
  53653. {
  53654. throw ReactError(Error("Pinged unknown suspense boundary type. This is probably a bug in React."));
  53655. }
  53656. }
  53657. })();
  53658. }
  53659. } else {
  53660. retryCache = boundaryFiber.stateNode;
  53661. }
  53662. if (retryCache !== null) {
  53663. // The thenable resolved, so we no longer need to memoize, because it will
  53664. // never be thrown again.
  53665. retryCache.delete(thenable);
  53666. }
  53667. retryTimedOutBoundary(boundaryFiber, retryTime);
  53668. } // Computes the next Just Noticeable Difference (JND) boundary.
  53669. // The theory is that a person can't tell the difference between small differences in time.
  53670. // Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
  53671. // difference in the experience. However, waiting for longer might mean that we can avoid
  53672. // showing an intermediate loading state. The longer we have already waited, the harder it
  53673. // is to tell small differences in time. Therefore, the longer we've already waited,
  53674. // the longer we can wait additionally. At some point we have to give up though.
  53675. // We pick a train model where the next boundary commits at a consistent schedule.
  53676. // These particular numbers are vague estimates. We expect to adjust them based on research.
  53677. function jnd(timeElapsed) {
  53678. return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
  53679. }
  53680. function computeMsUntilSuspenseLoadingDelay(mostRecentEventTime, committedExpirationTime, suspenseConfig) {
  53681. var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
  53682. if (busyMinDurationMs <= 0) {
  53683. return 0;
  53684. }
  53685. var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire.
  53686. var currentTimeMs = now();
  53687. var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(mostRecentEventTime, suspenseConfig);
  53688. var timeElapsed = currentTimeMs - eventTimeMs;
  53689. if (timeElapsed <= busyDelayMs) {
  53690. // If we haven't yet waited longer than the initial delay, we don't
  53691. // have to wait any additional time.
  53692. return 0;
  53693. }
  53694. var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`.
  53695. return msUntilTimeout;
  53696. }
  53697. function checkForNestedUpdates() {
  53698. if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
  53699. nestedUpdateCount = 0;
  53700. rootWithNestedUpdates = null;
  53701. (function () {
  53702. {
  53703. {
  53704. throw ReactError(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."));
  53705. }
  53706. }
  53707. })();
  53708. }
  53709. {
  53710. if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
  53711. nestedPassiveUpdateCount = 0;
  53712. warning$1(false, '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.');
  53713. }
  53714. }
  53715. }
  53716. function flushRenderPhaseStrictModeWarningsInDEV() {
  53717. {
  53718. ReactStrictModeWarnings.flushLegacyContextWarning();
  53719. if (warnAboutDeprecatedLifecycles) {
  53720. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
  53721. }
  53722. }
  53723. }
  53724. function stopFinishedWorkLoopTimer() {
  53725. var didCompleteRoot = true;
  53726. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  53727. interruptedBy = null;
  53728. }
  53729. function stopInterruptedWorkLoopTimer() {
  53730. // TODO: Track which fiber caused the interruption.
  53731. var didCompleteRoot = false;
  53732. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  53733. interruptedBy = null;
  53734. }
  53735. function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
  53736. if (enableUserTimingAPI && workInProgressRoot !== null && updateExpirationTime > renderExpirationTime) {
  53737. interruptedBy = fiberThatReceivedUpdate;
  53738. }
  53739. }
  53740. var didWarnStateUpdateForUnmountedComponent = null;
  53741. function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
  53742. {
  53743. var tag = fiber.tag;
  53744. if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent) {
  53745. // Only warn for user-defined components, not internal ones like Suspense.
  53746. return;
  53747. } // We show the whole stack but dedupe on the top component's name because
  53748. // the problematic code almost always lies inside that component.
  53749. var componentName = getComponentName(fiber.type) || 'ReactComponent';
  53750. if (didWarnStateUpdateForUnmountedComponent !== null) {
  53751. if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
  53752. return;
  53753. }
  53754. didWarnStateUpdateForUnmountedComponent.add(componentName);
  53755. } else {
  53756. didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
  53757. }
  53758. warningWithoutStack$1(false, "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));
  53759. }
  53760. }
  53761. var beginWork$$1;
  53762. if ( true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  53763. var dummyFiber = null;
  53764. beginWork$$1 = function (current$$1, unitOfWork, expirationTime) {
  53765. // If a component throws an error, we replay it again in a synchronously
  53766. // dispatched event, so that the debugger will treat it as an uncaught
  53767. // error See ReactErrorUtils for more information.
  53768. // Before entering the begin phase, copy the work-in-progress onto a dummy
  53769. // fiber. If beginWork throws, we'll use this to reset the state.
  53770. var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
  53771. try {
  53772. return beginWork$1(current$$1, unitOfWork, expirationTime);
  53773. } catch (originalError) {
  53774. if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') {
  53775. // Don't replay promises. Treat everything else like an error.
  53776. throw originalError;
  53777. } // Keep this code in sync with renderRoot; any changes here must have
  53778. // corresponding changes there.
  53779. resetContextDependencies();
  53780. resetHooks(); // Unwind the failed stack frame
  53781. unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
  53782. assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
  53783. if (enableProfilerTimer && unitOfWork.mode & ProfileMode) {
  53784. // Reset the profiler timer.
  53785. startProfilerTimer(unitOfWork);
  53786. } // Run beginWork again.
  53787. invokeGuardedCallback(null, beginWork$1, null, current$$1, unitOfWork, expirationTime);
  53788. if (hasCaughtError()) {
  53789. var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
  53790. // Rethrow this error instead of the original one.
  53791. throw replayError;
  53792. } else {
  53793. // This branch is reachable if the render phase is impure.
  53794. throw originalError;
  53795. }
  53796. }
  53797. };
  53798. } else {
  53799. beginWork$$1 = beginWork$1;
  53800. }
  53801. var didWarnAboutUpdateInRender = false;
  53802. var didWarnAboutUpdateInGetChildContext = false;
  53803. function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) {
  53804. {
  53805. if (fiber.tag === ClassComponent) {
  53806. switch (phase) {
  53807. case 'getChildContext':
  53808. if (didWarnAboutUpdateInGetChildContext) {
  53809. return;
  53810. }
  53811. warningWithoutStack$1(false, 'setState(...): Cannot call setState() inside getChildContext()');
  53812. didWarnAboutUpdateInGetChildContext = true;
  53813. break;
  53814. case 'render':
  53815. if (didWarnAboutUpdateInRender) {
  53816. return;
  53817. }
  53818. warningWithoutStack$1(false, 'Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure function of ' + 'props and state.');
  53819. didWarnAboutUpdateInRender = true;
  53820. break;
  53821. }
  53822. }
  53823. }
  53824. } // a 'shared' variable that changes when act() opens/closes in tests.
  53825. var IsThisRendererActing = {
  53826. current: false
  53827. };
  53828. function warnIfNotScopedWithMatchingAct(fiber) {
  53829. {
  53830. if (warnsIfNotActing === true && IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) {
  53831. warningWithoutStack$1(false, "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));
  53832. }
  53833. }
  53834. }
  53835. function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
  53836. {
  53837. if (warnsIfNotActing === true && (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
  53838. warningWithoutStack$1(false, '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));
  53839. }
  53840. }
  53841. }
  53842. function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
  53843. {
  53844. if (warnsIfNotActing === true && executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
  53845. warningWithoutStack$1(false, '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));
  53846. }
  53847. }
  53848. }
  53849. var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler.
  53850. var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked
  53851. // scheduler is the actual recommendation. The alternative could be a testing build,
  53852. // a new lib, or whatever; we dunno just yet. This message is for early adopters
  53853. // to get their tests right.
  53854. function warnIfUnmockedScheduler(fiber) {
  53855. {
  53856. if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) {
  53857. if (fiber.mode & BatchedMode || fiber.mode & ConcurrentMode) {
  53858. didWarnAboutUnmockedScheduler = true;
  53859. warningWithoutStack$1(false, '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');
  53860. } else if (warnAboutUnmockedScheduler === true) {
  53861. didWarnAboutUnmockedScheduler = true;
  53862. warningWithoutStack$1(false, 'Starting from React v17, the "scheduler" module will need 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');
  53863. }
  53864. }
  53865. }
  53866. }
  53867. var componentsThatTriggeredHighPriSuspend = null;
  53868. function checkForWrongSuspensePriorityInDEV(sourceFiber) {
  53869. {
  53870. var currentPriorityLevel = getCurrentPriorityLevel();
  53871. if ((sourceFiber.mode & ConcurrentMode) !== NoEffect && (currentPriorityLevel === UserBlockingPriority$2 || currentPriorityLevel === ImmediatePriority)) {
  53872. var workInProgressNode = sourceFiber;
  53873. while (workInProgressNode !== null) {
  53874. // Add the component that triggered the suspense
  53875. var current$$1 = workInProgressNode.alternate;
  53876. if (current$$1 !== null) {
  53877. // TODO: warn component that triggers the high priority
  53878. // suspend is the HostRoot
  53879. switch (workInProgressNode.tag) {
  53880. case ClassComponent:
  53881. // Loop through the component's update queue and see whether the component
  53882. // has triggered any high priority updates
  53883. var updateQueue = current$$1.updateQueue;
  53884. if (updateQueue !== null) {
  53885. var update = updateQueue.firstUpdate;
  53886. while (update !== null) {
  53887. var priorityLevel = update.priority;
  53888. if (priorityLevel === UserBlockingPriority$2 || priorityLevel === ImmediatePriority) {
  53889. if (componentsThatTriggeredHighPriSuspend === null) {
  53890. componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
  53891. } else {
  53892. componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
  53893. }
  53894. break;
  53895. }
  53896. update = update.next;
  53897. }
  53898. }
  53899. break;
  53900. case FunctionComponent:
  53901. case ForwardRef:
  53902. case SimpleMemoComponent:
  53903. if (workInProgressNode.memoizedState !== null && workInProgressNode.memoizedState.baseUpdate !== null) {
  53904. var _update = workInProgressNode.memoizedState.baseUpdate; // Loop through the functional component's memoized state to see whether
  53905. // the component has triggered any high pri updates
  53906. while (_update !== null) {
  53907. var priority = _update.priority;
  53908. if (priority === UserBlockingPriority$2 || priority === ImmediatePriority) {
  53909. if (componentsThatTriggeredHighPriSuspend === null) {
  53910. componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
  53911. } else {
  53912. componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
  53913. }
  53914. break;
  53915. }
  53916. if (_update.next === workInProgressNode.memoizedState.baseUpdate) {
  53917. break;
  53918. }
  53919. _update = _update.next;
  53920. }
  53921. }
  53922. break;
  53923. default:
  53924. break;
  53925. }
  53926. }
  53927. workInProgressNode = workInProgressNode.return;
  53928. }
  53929. }
  53930. }
  53931. }
  53932. function flushSuspensePriorityWarningInDEV() {
  53933. {
  53934. if (componentsThatTriggeredHighPriSuspend !== null) {
  53935. var componentNames = [];
  53936. componentsThatTriggeredHighPriSuspend.forEach(function (name) {
  53937. return componentNames.push(name);
  53938. });
  53939. componentsThatTriggeredHighPriSuspend = null;
  53940. if (componentNames.length > 0) {
  53941. warningWithoutStack$1(false, '%s triggered a user-blocking update that suspended.' + '\n\n' + 'The fix is to split the update into multiple parts: a user-blocking ' + 'update to provide immediate feedback, and another update that ' + 'triggers the bulk of the changes.' + '\n\n' + 'Refer to the documentation for useSuspenseTransition to learn how ' + 'to implement this pattern.', // TODO: Add link to React docs with more information, once it exists
  53942. componentNames.sort().join(', '));
  53943. }
  53944. }
  53945. }
  53946. }
  53947. function computeThreadID(root, expirationTime) {
  53948. // Interaction threads are unique per root and expiration time.
  53949. return expirationTime * 1000 + root.interactionThreadID;
  53950. }
  53951. function markSpawnedWork(expirationTime) {
  53952. if (!enableSchedulerTracing) {
  53953. return;
  53954. }
  53955. if (spawnedWorkDuringRender === null) {
  53956. spawnedWorkDuringRender = [expirationTime];
  53957. } else {
  53958. spawnedWorkDuringRender.push(expirationTime);
  53959. }
  53960. }
  53961. function scheduleInteractions(root, expirationTime, interactions) {
  53962. if (!enableSchedulerTracing) {
  53963. return;
  53964. }
  53965. if (interactions.size > 0) {
  53966. var pendingInteractionMap = root.pendingInteractionMap;
  53967. var pendingInteractions = pendingInteractionMap.get(expirationTime);
  53968. if (pendingInteractions != null) {
  53969. interactions.forEach(function (interaction) {
  53970. if (!pendingInteractions.has(interaction)) {
  53971. // Update the pending async work count for previously unscheduled interaction.
  53972. interaction.__count++;
  53973. }
  53974. pendingInteractions.add(interaction);
  53975. });
  53976. } else {
  53977. pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions.
  53978. interactions.forEach(function (interaction) {
  53979. interaction.__count++;
  53980. });
  53981. }
  53982. var subscriber = tracing.__subscriberRef.current;
  53983. if (subscriber !== null) {
  53984. var threadID = computeThreadID(root, expirationTime);
  53985. subscriber.onWorkScheduled(interactions, threadID);
  53986. }
  53987. }
  53988. }
  53989. function schedulePendingInteractions(root, expirationTime) {
  53990. // This is called when work is scheduled on a root.
  53991. // It associates the current interactions with the newly-scheduled expiration.
  53992. // They will be restored when that expiration is later committed.
  53993. if (!enableSchedulerTracing) {
  53994. return;
  53995. }
  53996. scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current);
  53997. }
  53998. function startWorkOnPendingInteractions(root, expirationTime) {
  53999. // This is called when new work is started on a root.
  54000. if (!enableSchedulerTracing) {
  54001. return;
  54002. } // Determine which interactions this batch of work currently includes, So that
  54003. // we can accurately attribute time spent working on it, And so that cascading
  54004. // work triggered during the render phase will be associated with it.
  54005. var interactions = new Set();
  54006. root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
  54007. if (scheduledExpirationTime >= expirationTime) {
  54008. scheduledInteractions.forEach(function (interaction) {
  54009. return interactions.add(interaction);
  54010. });
  54011. }
  54012. }); // Store the current set of interactions on the FiberRoot for a few reasons:
  54013. // We can re-use it in hot functions like renderRoot() without having to
  54014. // recalculate it. We will also use it in commitWork() to pass to any Profiler
  54015. // onRender() hooks. This also provides DevTools with a way to access it when
  54016. // the onCommitRoot() hook is called.
  54017. root.memoizedInteractions = interactions;
  54018. if (interactions.size > 0) {
  54019. var subscriber = tracing.__subscriberRef.current;
  54020. if (subscriber !== null) {
  54021. var threadID = computeThreadID(root, expirationTime);
  54022. try {
  54023. subscriber.onWorkStarted(interactions, threadID);
  54024. } catch (error) {
  54025. // If the subscriber throws, rethrow it in a separate task
  54026. scheduleCallback(ImmediatePriority, function () {
  54027. throw error;
  54028. });
  54029. }
  54030. }
  54031. }
  54032. }
  54033. function finishPendingInteractions(root, committedExpirationTime) {
  54034. if (!enableSchedulerTracing) {
  54035. return;
  54036. }
  54037. var earliestRemainingTimeAfterCommit = root.firstPendingTime;
  54038. var subscriber;
  54039. try {
  54040. subscriber = tracing.__subscriberRef.current;
  54041. if (subscriber !== null && root.memoizedInteractions.size > 0) {
  54042. var threadID = computeThreadID(root, committedExpirationTime);
  54043. subscriber.onWorkStopped(root.memoizedInteractions, threadID);
  54044. }
  54045. } catch (error) {
  54046. // If the subscriber throws, rethrow it in a separate task
  54047. scheduleCallback(ImmediatePriority, function () {
  54048. throw error;
  54049. });
  54050. } finally {
  54051. // Clear completed interactions from the pending Map.
  54052. // Unless the render was suspended or cascading work was scheduled,
  54053. // In which case– leave pending interactions until the subsequent render.
  54054. var pendingInteractionMap = root.pendingInteractionMap;
  54055. pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
  54056. // Only decrement the pending interaction count if we're done.
  54057. // If there's still work at the current priority,
  54058. // That indicates that we are waiting for suspense data.
  54059. if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
  54060. pendingInteractionMap.delete(scheduledExpirationTime);
  54061. scheduledInteractions.forEach(function (interaction) {
  54062. interaction.__count--;
  54063. if (subscriber !== null && interaction.__count === 0) {
  54064. try {
  54065. subscriber.onInteractionScheduledWorkCompleted(interaction);
  54066. } catch (error) {
  54067. // If the subscriber throws, rethrow it in a separate task
  54068. scheduleCallback(ImmediatePriority, function () {
  54069. throw error;
  54070. });
  54071. }
  54072. }
  54073. });
  54074. }
  54075. });
  54076. }
  54077. }
  54078. var onCommitFiberRoot = null;
  54079. var onCommitFiberUnmount = null;
  54080. var hasLoggedError = false;
  54081. var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
  54082. function injectInternals(internals) {
  54083. if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
  54084. // No DevTools
  54085. return false;
  54086. }
  54087. var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
  54088. if (hook.isDisabled) {
  54089. // This isn't a real property on the hook, but it can be set to opt out
  54090. // of DevTools integration and associated warnings and logs.
  54091. // https://github.com/facebook/react/issues/3877
  54092. return true;
  54093. }
  54094. if (!hook.supportsFiber) {
  54095. {
  54096. warningWithoutStack$1(false, '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');
  54097. } // DevTools exists, even though it doesn't support Fiber.
  54098. return true;
  54099. }
  54100. try {
  54101. var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
  54102. onCommitFiberRoot = function (root, expirationTime) {
  54103. try {
  54104. var didError = (root.current.effectTag & DidCapture) === DidCapture;
  54105. if (enableProfilerTimer) {
  54106. var currentTime = requestCurrentTime();
  54107. var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime);
  54108. hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
  54109. } else {
  54110. hook.onCommitFiberRoot(rendererID, root, undefined, didError);
  54111. }
  54112. } catch (err) {
  54113. if ( true && !hasLoggedError) {
  54114. hasLoggedError = true;
  54115. warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
  54116. }
  54117. }
  54118. };
  54119. onCommitFiberUnmount = function (fiber) {
  54120. try {
  54121. hook.onCommitFiberUnmount(rendererID, fiber);
  54122. } catch (err) {
  54123. if ( true && !hasLoggedError) {
  54124. hasLoggedError = true;
  54125. warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
  54126. }
  54127. }
  54128. };
  54129. } catch (err) {
  54130. // Catch all errors because it is unsafe to throw during initialization.
  54131. {
  54132. warningWithoutStack$1(false, 'React DevTools encountered an error: %s.', err);
  54133. }
  54134. } // DevTools exists
  54135. return true;
  54136. }
  54137. function onCommitRoot(root, expirationTime) {
  54138. if (typeof onCommitFiberRoot === 'function') {
  54139. onCommitFiberRoot(root, expirationTime);
  54140. }
  54141. }
  54142. function onCommitUnmount(fiber) {
  54143. if (typeof onCommitFiberUnmount === 'function') {
  54144. onCommitFiberUnmount(fiber);
  54145. }
  54146. }
  54147. var hasBadMapPolyfill;
  54148. {
  54149. hasBadMapPolyfill = false;
  54150. try {
  54151. var nonExtensibleObject = Object.preventExtensions({});
  54152. var testMap = new Map([[nonExtensibleObject, null]]);
  54153. var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused.
  54154. // https://github.com/rollup/rollup/issues/1771
  54155. // TODO: we can remove these if Rollup fixes the bug.
  54156. testMap.set(0, 0);
  54157. testSet.add(0);
  54158. } catch (e) {
  54159. // TODO: Consider warning about bad polyfills
  54160. hasBadMapPolyfill = true;
  54161. }
  54162. }
  54163. var debugCounter = 1;
  54164. function FiberNode(tag, pendingProps, key, mode) {
  54165. // Instance
  54166. this.tag = tag;
  54167. this.key = key;
  54168. this.elementType = null;
  54169. this.type = null;
  54170. this.stateNode = null; // Fiber
  54171. this.return = null;
  54172. this.child = null;
  54173. this.sibling = null;
  54174. this.index = 0;
  54175. this.ref = null;
  54176. this.pendingProps = pendingProps;
  54177. this.memoizedProps = null;
  54178. this.updateQueue = null;
  54179. this.memoizedState = null;
  54180. this.dependencies = null;
  54181. this.mode = mode; // Effects
  54182. this.effectTag = NoEffect;
  54183. this.nextEffect = null;
  54184. this.firstEffect = null;
  54185. this.lastEffect = null;
  54186. this.expirationTime = NoWork;
  54187. this.childExpirationTime = NoWork;
  54188. this.alternate = null;
  54189. if (enableProfilerTimer) {
  54190. // Note: The following is done to avoid a v8 performance cliff.
  54191. //
  54192. // Initializing the fields below to smis and later updating them with
  54193. // double values will cause Fibers to end up having separate shapes.
  54194. // This behavior/bug has something to do with Object.preventExtension().
  54195. // Fortunately this only impacts DEV builds.
  54196. // Unfortunately it makes React unusably slow for some applications.
  54197. // To work around this, initialize the fields below with doubles.
  54198. //
  54199. // Learn more about this here:
  54200. // https://github.com/facebook/react/issues/14365
  54201. // https://bugs.chromium.org/p/v8/issues/detail?id=8538
  54202. this.actualDuration = Number.NaN;
  54203. this.actualStartTime = Number.NaN;
  54204. this.selfBaseDuration = Number.NaN;
  54205. this.treeBaseDuration = Number.NaN; // It's okay to replace the initial doubles with smis after initialization.
  54206. // This won't trigger the performance cliff mentioned above,
  54207. // and it simplifies other profiler code (including DevTools).
  54208. this.actualDuration = 0;
  54209. this.actualStartTime = -1;
  54210. this.selfBaseDuration = 0;
  54211. this.treeBaseDuration = 0;
  54212. } // This is normally DEV-only except www when it adds listeners.
  54213. // TODO: remove the User Timing integration in favor of Root Events.
  54214. if (enableUserTimingAPI) {
  54215. this._debugID = debugCounter++;
  54216. this._debugIsCurrentlyTiming = false;
  54217. }
  54218. {
  54219. this._debugSource = null;
  54220. this._debugOwner = null;
  54221. this._debugNeedsRemount = false;
  54222. this._debugHookTypes = null;
  54223. if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
  54224. Object.preventExtensions(this);
  54225. }
  54226. }
  54227. } // This is a constructor function, rather than a POJO constructor, still
  54228. // please ensure we do the following:
  54229. // 1) Nobody should add any instance methods on this. Instance methods can be
  54230. // more difficult to predict when they get optimized and they are almost
  54231. // never inlined properly in static compilers.
  54232. // 2) Nobody should rely on `instanceof Fiber` for type testing. We should
  54233. // always know when it is a fiber.
  54234. // 3) We might want to experiment with using numeric keys since they are easier
  54235. // to optimize in a non-JIT environment.
  54236. // 4) We can easily go from a constructor to a createFiber object literal if that
  54237. // is faster.
  54238. // 5) It should be easy to port this to a C struct and keep a C implementation
  54239. // compatible.
  54240. var createFiber = function (tag, pendingProps, key, mode) {
  54241. // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
  54242. return new FiberNode(tag, pendingProps, key, mode);
  54243. };
  54244. function shouldConstruct(Component) {
  54245. var prototype = Component.prototype;
  54246. return !!(prototype && prototype.isReactComponent);
  54247. }
  54248. function isSimpleFunctionComponent(type) {
  54249. return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
  54250. }
  54251. function resolveLazyComponentTag(Component) {
  54252. if (typeof Component === 'function') {
  54253. return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
  54254. } else if (Component !== undefined && Component !== null) {
  54255. var $$typeof = Component.$$typeof;
  54256. if ($$typeof === REACT_FORWARD_REF_TYPE) {
  54257. return ForwardRef;
  54258. }
  54259. if ($$typeof === REACT_MEMO_TYPE) {
  54260. return MemoComponent;
  54261. }
  54262. }
  54263. return IndeterminateComponent;
  54264. } // This is used to create an alternate fiber to do work on.
  54265. function createWorkInProgress(current, pendingProps, expirationTime) {
  54266. var workInProgress = current.alternate;
  54267. if (workInProgress === null) {
  54268. // We use a double buffering pooling technique because we know that we'll
  54269. // only ever need at most two versions of a tree. We pool the "other" unused
  54270. // node that we're free to reuse. This is lazily created to avoid allocating
  54271. // extra objects for things that are never updated. It also allow us to
  54272. // reclaim the extra memory if needed.
  54273. workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
  54274. workInProgress.elementType = current.elementType;
  54275. workInProgress.type = current.type;
  54276. workInProgress.stateNode = current.stateNode;
  54277. {
  54278. // DEV-only fields
  54279. workInProgress._debugID = current._debugID;
  54280. workInProgress._debugSource = current._debugSource;
  54281. workInProgress._debugOwner = current._debugOwner;
  54282. workInProgress._debugHookTypes = current._debugHookTypes;
  54283. }
  54284. workInProgress.alternate = current;
  54285. current.alternate = workInProgress;
  54286. } else {
  54287. workInProgress.pendingProps = pendingProps; // We already have an alternate.
  54288. // Reset the effect tag.
  54289. workInProgress.effectTag = NoEffect; // The effect list is no longer valid.
  54290. workInProgress.nextEffect = null;
  54291. workInProgress.firstEffect = null;
  54292. workInProgress.lastEffect = null;
  54293. if (enableProfilerTimer) {
  54294. // We intentionally reset, rather than copy, actualDuration & actualStartTime.
  54295. // This prevents time from endlessly accumulating in new commits.
  54296. // This has the downside of resetting values for different priority renders,
  54297. // But works for yielding (the common case) and should support resuming.
  54298. workInProgress.actualDuration = 0;
  54299. workInProgress.actualStartTime = -1;
  54300. }
  54301. }
  54302. workInProgress.childExpirationTime = current.childExpirationTime;
  54303. workInProgress.expirationTime = current.expirationTime;
  54304. workInProgress.child = current.child;
  54305. workInProgress.memoizedProps = current.memoizedProps;
  54306. workInProgress.memoizedState = current.memoizedState;
  54307. workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
  54308. // it cannot be shared with the current fiber.
  54309. var currentDependencies = current.dependencies;
  54310. workInProgress.dependencies = currentDependencies === null ? null : {
  54311. expirationTime: currentDependencies.expirationTime,
  54312. firstContext: currentDependencies.firstContext,
  54313. responders: currentDependencies.responders
  54314. }; // These will be overridden during the parent's reconciliation
  54315. workInProgress.sibling = current.sibling;
  54316. workInProgress.index = current.index;
  54317. workInProgress.ref = current.ref;
  54318. if (enableProfilerTimer) {
  54319. workInProgress.selfBaseDuration = current.selfBaseDuration;
  54320. workInProgress.treeBaseDuration = current.treeBaseDuration;
  54321. }
  54322. {
  54323. workInProgress._debugNeedsRemount = current._debugNeedsRemount;
  54324. switch (workInProgress.tag) {
  54325. case IndeterminateComponent:
  54326. case FunctionComponent:
  54327. case SimpleMemoComponent:
  54328. workInProgress.type = resolveFunctionForHotReloading(current.type);
  54329. break;
  54330. case ClassComponent:
  54331. workInProgress.type = resolveClassForHotReloading(current.type);
  54332. break;
  54333. case ForwardRef:
  54334. workInProgress.type = resolveForwardRefForHotReloading(current.type);
  54335. break;
  54336. default:
  54337. break;
  54338. }
  54339. }
  54340. return workInProgress;
  54341. } // Used to reuse a Fiber for a second pass.
  54342. function resetWorkInProgress(workInProgress, renderExpirationTime) {
  54343. // This resets the Fiber to what createFiber or createWorkInProgress would
  54344. // have set the values to before during the first pass. Ideally this wouldn't
  54345. // be necessary but unfortunately many code paths reads from the workInProgress
  54346. // when they should be reading from current and writing to workInProgress.
  54347. // We assume pendingProps, index, key, ref, return are still untouched to
  54348. // avoid doing another reconciliation.
  54349. // Reset the effect tag but keep any Placement tags, since that's something
  54350. // that child fiber is setting, not the reconciliation.
  54351. workInProgress.effectTag &= Placement; // The effect list is no longer valid.
  54352. workInProgress.nextEffect = null;
  54353. workInProgress.firstEffect = null;
  54354. workInProgress.lastEffect = null;
  54355. var current = workInProgress.alternate;
  54356. if (current === null) {
  54357. // Reset to createFiber's initial values.
  54358. workInProgress.childExpirationTime = NoWork;
  54359. workInProgress.expirationTime = renderExpirationTime;
  54360. workInProgress.child = null;
  54361. workInProgress.memoizedProps = null;
  54362. workInProgress.memoizedState = null;
  54363. workInProgress.updateQueue = null;
  54364. workInProgress.dependencies = null;
  54365. if (enableProfilerTimer) {
  54366. // Note: We don't reset the actualTime counts. It's useful to accumulate
  54367. // actual time across multiple render passes.
  54368. workInProgress.selfBaseDuration = 0;
  54369. workInProgress.treeBaseDuration = 0;
  54370. }
  54371. } else {
  54372. // Reset to the cloned values that createWorkInProgress would've.
  54373. workInProgress.childExpirationTime = current.childExpirationTime;
  54374. workInProgress.expirationTime = current.expirationTime;
  54375. workInProgress.child = current.child;
  54376. workInProgress.memoizedProps = current.memoizedProps;
  54377. workInProgress.memoizedState = current.memoizedState;
  54378. workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
  54379. // it cannot be shared with the current fiber.
  54380. var currentDependencies = current.dependencies;
  54381. workInProgress.dependencies = currentDependencies === null ? null : {
  54382. expirationTime: currentDependencies.expirationTime,
  54383. firstContext: currentDependencies.firstContext,
  54384. responders: currentDependencies.responders
  54385. };
  54386. if (enableProfilerTimer) {
  54387. // Note: We don't reset the actualTime counts. It's useful to accumulate
  54388. // actual time across multiple render passes.
  54389. workInProgress.selfBaseDuration = current.selfBaseDuration;
  54390. workInProgress.treeBaseDuration = current.treeBaseDuration;
  54391. }
  54392. }
  54393. return workInProgress;
  54394. }
  54395. function createHostRootFiber(tag) {
  54396. var mode;
  54397. if (tag === ConcurrentRoot) {
  54398. mode = ConcurrentMode | BatchedMode | StrictMode;
  54399. } else if (tag === BatchedRoot) {
  54400. mode = BatchedMode | StrictMode;
  54401. } else {
  54402. mode = NoMode;
  54403. }
  54404. if (enableProfilerTimer && isDevToolsPresent) {
  54405. // Always collect profile timings when DevTools are present.
  54406. // This enables DevTools to start capturing timing at any point–
  54407. // Without some nodes in the tree having empty base times.
  54408. mode |= ProfileMode;
  54409. }
  54410. return createFiber(HostRoot, null, null, mode);
  54411. }
  54412. function createFiberFromTypeAndProps(type, // React$ElementType
  54413. key, pendingProps, owner, mode, expirationTime) {
  54414. var fiber;
  54415. var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
  54416. var resolvedType = type;
  54417. if (typeof type === 'function') {
  54418. if (shouldConstruct(type)) {
  54419. fiberTag = ClassComponent;
  54420. {
  54421. resolvedType = resolveClassForHotReloading(resolvedType);
  54422. }
  54423. } else {
  54424. {
  54425. resolvedType = resolveFunctionForHotReloading(resolvedType);
  54426. }
  54427. }
  54428. } else if (typeof type === 'string') {
  54429. fiberTag = HostComponent;
  54430. } else {
  54431. getTag: switch (type) {
  54432. case REACT_FRAGMENT_TYPE:
  54433. return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
  54434. case REACT_CONCURRENT_MODE_TYPE:
  54435. fiberTag = Mode;
  54436. mode |= ConcurrentMode | BatchedMode | StrictMode;
  54437. break;
  54438. case REACT_STRICT_MODE_TYPE:
  54439. fiberTag = Mode;
  54440. mode |= StrictMode;
  54441. break;
  54442. case REACT_PROFILER_TYPE:
  54443. return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
  54444. case REACT_SUSPENSE_TYPE:
  54445. return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
  54446. case REACT_SUSPENSE_LIST_TYPE:
  54447. return createFiberFromSuspenseList(pendingProps, mode, expirationTime, key);
  54448. default:
  54449. {
  54450. if (typeof type === 'object' && type !== null) {
  54451. switch (type.$$typeof) {
  54452. case REACT_PROVIDER_TYPE:
  54453. fiberTag = ContextProvider;
  54454. break getTag;
  54455. case REACT_CONTEXT_TYPE:
  54456. // This is a consumer
  54457. fiberTag = ContextConsumer;
  54458. break getTag;
  54459. case REACT_FORWARD_REF_TYPE:
  54460. fiberTag = ForwardRef;
  54461. {
  54462. resolvedType = resolveForwardRefForHotReloading(resolvedType);
  54463. }
  54464. break getTag;
  54465. case REACT_MEMO_TYPE:
  54466. fiberTag = MemoComponent;
  54467. break getTag;
  54468. case REACT_LAZY_TYPE:
  54469. fiberTag = LazyComponent;
  54470. resolvedType = null;
  54471. break getTag;
  54472. case REACT_FUNDAMENTAL_TYPE:
  54473. if (enableFundamentalAPI) {
  54474. return createFiberFromFundamental(type, pendingProps, mode, expirationTime, key);
  54475. }
  54476. break;
  54477. case REACT_SCOPE_TYPE:
  54478. if (enableScopeAPI) {
  54479. return createFiberFromScope(type, pendingProps, mode, expirationTime, key);
  54480. }
  54481. }
  54482. }
  54483. var info = '';
  54484. {
  54485. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  54486. 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.';
  54487. }
  54488. var ownerName = owner ? getComponentName(owner.type) : null;
  54489. if (ownerName) {
  54490. info += '\n\nCheck the render method of `' + ownerName + '`.';
  54491. }
  54492. }
  54493. (function () {
  54494. {
  54495. {
  54496. throw ReactError(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));
  54497. }
  54498. }
  54499. })();
  54500. }
  54501. }
  54502. }
  54503. fiber = createFiber(fiberTag, pendingProps, key, mode);
  54504. fiber.elementType = type;
  54505. fiber.type = resolvedType;
  54506. fiber.expirationTime = expirationTime;
  54507. return fiber;
  54508. }
  54509. function createFiberFromElement(element, mode, expirationTime) {
  54510. var owner = null;
  54511. {
  54512. owner = element._owner;
  54513. }
  54514. var type = element.type;
  54515. var key = element.key;
  54516. var pendingProps = element.props;
  54517. var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
  54518. {
  54519. fiber._debugSource = element._source;
  54520. fiber._debugOwner = element._owner;
  54521. }
  54522. return fiber;
  54523. }
  54524. function createFiberFromFragment(elements, mode, expirationTime, key) {
  54525. var fiber = createFiber(Fragment, elements, key, mode);
  54526. fiber.expirationTime = expirationTime;
  54527. return fiber;
  54528. }
  54529. function createFiberFromFundamental(fundamentalComponent, pendingProps, mode, expirationTime, key) {
  54530. var fiber = createFiber(FundamentalComponent, pendingProps, key, mode);
  54531. fiber.elementType = fundamentalComponent;
  54532. fiber.type = fundamentalComponent;
  54533. fiber.expirationTime = expirationTime;
  54534. return fiber;
  54535. }
  54536. function createFiberFromScope(scope, pendingProps, mode, expirationTime, key) {
  54537. var fiber = createFiber(ScopeComponent, pendingProps, key, mode);
  54538. fiber.type = scope;
  54539. fiber.elementType = scope;
  54540. fiber.expirationTime = expirationTime;
  54541. return fiber;
  54542. }
  54543. function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
  54544. {
  54545. if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
  54546. warningWithoutStack$1(false, 'Profiler must specify an "id" string and "onRender" function as props');
  54547. }
  54548. }
  54549. var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); // TODO: The Profiler fiber shouldn't have a type. It has a tag.
  54550. fiber.elementType = REACT_PROFILER_TYPE;
  54551. fiber.type = REACT_PROFILER_TYPE;
  54552. fiber.expirationTime = expirationTime;
  54553. return fiber;
  54554. }
  54555. function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
  54556. var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
  54557. // This needs to be fixed in getComponentName so that it relies on the tag
  54558. // instead.
  54559. fiber.type = REACT_SUSPENSE_TYPE;
  54560. fiber.elementType = REACT_SUSPENSE_TYPE;
  54561. fiber.expirationTime = expirationTime;
  54562. return fiber;
  54563. }
  54564. function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
  54565. var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
  54566. {
  54567. // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag.
  54568. // This needs to be fixed in getComponentName so that it relies on the tag
  54569. // instead.
  54570. fiber.type = REACT_SUSPENSE_LIST_TYPE;
  54571. }
  54572. fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
  54573. fiber.expirationTime = expirationTime;
  54574. return fiber;
  54575. }
  54576. function createFiberFromText(content, mode, expirationTime) {
  54577. var fiber = createFiber(HostText, content, null, mode);
  54578. fiber.expirationTime = expirationTime;
  54579. return fiber;
  54580. }
  54581. function createFiberFromHostInstanceForDeletion() {
  54582. var fiber = createFiber(HostComponent, null, null, NoMode); // TODO: These should not need a type.
  54583. fiber.elementType = 'DELETED';
  54584. fiber.type = 'DELETED';
  54585. return fiber;
  54586. }
  54587. function createFiberFromDehydratedFragment(dehydratedNode) {
  54588. var fiber = createFiber(DehydratedFragment, null, null, NoMode);
  54589. fiber.stateNode = dehydratedNode;
  54590. return fiber;
  54591. }
  54592. function createFiberFromPortal(portal, mode, expirationTime) {
  54593. var pendingProps = portal.children !== null ? portal.children : [];
  54594. var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
  54595. fiber.expirationTime = expirationTime;
  54596. fiber.stateNode = {
  54597. containerInfo: portal.containerInfo,
  54598. pendingChildren: null,
  54599. // Used by persistent updates
  54600. implementation: portal.implementation
  54601. };
  54602. return fiber;
  54603. } // Used for stashing WIP properties to replay failed work in DEV.
  54604. function assignFiberPropertiesInDEV(target, source) {
  54605. if (target === null) {
  54606. // This Fiber's initial properties will always be overwritten.
  54607. // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
  54608. target = createFiber(IndeterminateComponent, null, null, NoMode);
  54609. } // This is intentionally written as a list of all properties.
  54610. // We tried to use Object.assign() instead but this is called in
  54611. // the hottest path, and Object.assign() was too slow:
  54612. // https://github.com/facebook/react/issues/12502
  54613. // This code is DEV-only so size is not a concern.
  54614. target.tag = source.tag;
  54615. target.key = source.key;
  54616. target.elementType = source.elementType;
  54617. target.type = source.type;
  54618. target.stateNode = source.stateNode;
  54619. target.return = source.return;
  54620. target.child = source.child;
  54621. target.sibling = source.sibling;
  54622. target.index = source.index;
  54623. target.ref = source.ref;
  54624. target.pendingProps = source.pendingProps;
  54625. target.memoizedProps = source.memoizedProps;
  54626. target.updateQueue = source.updateQueue;
  54627. target.memoizedState = source.memoizedState;
  54628. target.dependencies = source.dependencies;
  54629. target.mode = source.mode;
  54630. target.effectTag = source.effectTag;
  54631. target.nextEffect = source.nextEffect;
  54632. target.firstEffect = source.firstEffect;
  54633. target.lastEffect = source.lastEffect;
  54634. target.expirationTime = source.expirationTime;
  54635. target.childExpirationTime = source.childExpirationTime;
  54636. target.alternate = source.alternate;
  54637. if (enableProfilerTimer) {
  54638. target.actualDuration = source.actualDuration;
  54639. target.actualStartTime = source.actualStartTime;
  54640. target.selfBaseDuration = source.selfBaseDuration;
  54641. target.treeBaseDuration = source.treeBaseDuration;
  54642. }
  54643. target._debugID = source._debugID;
  54644. target._debugSource = source._debugSource;
  54645. target._debugOwner = source._debugOwner;
  54646. target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
  54647. target._debugNeedsRemount = source._debugNeedsRemount;
  54648. target._debugHookTypes = source._debugHookTypes;
  54649. return target;
  54650. }
  54651. function FiberRootNode(containerInfo, tag, hydrate) {
  54652. this.tag = tag;
  54653. this.current = null;
  54654. this.containerInfo = containerInfo;
  54655. this.pendingChildren = null;
  54656. this.pingCache = null;
  54657. this.finishedExpirationTime = NoWork;
  54658. this.finishedWork = null;
  54659. this.timeoutHandle = noTimeout;
  54660. this.context = null;
  54661. this.pendingContext = null;
  54662. this.hydrate = hydrate;
  54663. this.firstBatch = null;
  54664. this.callbackNode = null;
  54665. this.callbackPriority = NoPriority;
  54666. this.firstPendingTime = NoWork;
  54667. this.firstSuspendedTime = NoWork;
  54668. this.lastSuspendedTime = NoWork;
  54669. this.nextKnownPendingLevel = NoWork;
  54670. this.lastPingedTime = NoWork;
  54671. this.lastExpiredTime = NoWork;
  54672. if (enableSchedulerTracing) {
  54673. this.interactionThreadID = tracing.unstable_getThreadID();
  54674. this.memoizedInteractions = new Set();
  54675. this.pendingInteractionMap = new Map();
  54676. }
  54677. if (enableSuspenseCallback) {
  54678. this.hydrationCallbacks = null;
  54679. }
  54680. }
  54681. function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
  54682. var root = new FiberRootNode(containerInfo, tag, hydrate);
  54683. if (enableSuspenseCallback) {
  54684. root.hydrationCallbacks = hydrationCallbacks;
  54685. } // Cyclic construction. This cheats the type system right now because
  54686. // stateNode is any.
  54687. var uninitializedFiber = createHostRootFiber(tag);
  54688. root.current = uninitializedFiber;
  54689. uninitializedFiber.stateNode = root;
  54690. return root;
  54691. }
  54692. function isRootSuspendedAtTime(root, expirationTime) {
  54693. var firstSuspendedTime = root.firstSuspendedTime;
  54694. var lastSuspendedTime = root.lastSuspendedTime;
  54695. return firstSuspendedTime !== NoWork && firstSuspendedTime >= expirationTime && lastSuspendedTime <= expirationTime;
  54696. }
  54697. function markRootSuspendedAtTime(root, expirationTime) {
  54698. var firstSuspendedTime = root.firstSuspendedTime;
  54699. var lastSuspendedTime = root.lastSuspendedTime;
  54700. if (firstSuspendedTime < expirationTime) {
  54701. root.firstSuspendedTime = expirationTime;
  54702. }
  54703. if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) {
  54704. root.lastSuspendedTime = expirationTime;
  54705. }
  54706. if (expirationTime <= root.lastPingedTime) {
  54707. root.lastPingedTime = NoWork;
  54708. }
  54709. if (expirationTime <= root.lastExpiredTime) {
  54710. root.lastExpiredTime = NoWork;
  54711. }
  54712. }
  54713. function markRootUpdatedAtTime(root, expirationTime) {
  54714. // Update the range of pending times
  54715. var firstPendingTime = root.firstPendingTime;
  54716. if (expirationTime > firstPendingTime) {
  54717. root.firstPendingTime = expirationTime;
  54718. } // Update the range of suspended times. Treat everything lower priority or
  54719. // equal to this update as unsuspended.
  54720. var firstSuspendedTime = root.firstSuspendedTime;
  54721. if (firstSuspendedTime !== NoWork) {
  54722. if (expirationTime >= firstSuspendedTime) {
  54723. // The entire suspended range is now unsuspended.
  54724. root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
  54725. } else if (expirationTime >= root.lastSuspendedTime) {
  54726. root.lastSuspendedTime = expirationTime + 1;
  54727. } // This is a pending level. Check if it's higher priority than the next
  54728. // known pending level.
  54729. if (expirationTime > root.nextKnownPendingLevel) {
  54730. root.nextKnownPendingLevel = expirationTime;
  54731. }
  54732. }
  54733. }
  54734. function markRootFinishedAtTime(root, finishedExpirationTime, remainingExpirationTime) {
  54735. // Update the range of pending times
  54736. root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or
  54737. // equal to this update as unsuspended.
  54738. if (finishedExpirationTime <= root.lastSuspendedTime) {
  54739. // The entire suspended range is now unsuspended.
  54740. root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
  54741. } else if (finishedExpirationTime <= root.firstSuspendedTime) {
  54742. // Part of the suspended range is now unsuspended. Narrow the range to
  54743. // include everything between the unsuspended time (non-inclusive) and the
  54744. // last suspended time.
  54745. root.firstSuspendedTime = finishedExpirationTime - 1;
  54746. }
  54747. if (finishedExpirationTime <= root.lastPingedTime) {
  54748. // Clear the pinged time
  54749. root.lastPingedTime = NoWork;
  54750. }
  54751. if (finishedExpirationTime <= root.lastExpiredTime) {
  54752. // Clear the expired time
  54753. root.lastExpiredTime = NoWork;
  54754. }
  54755. }
  54756. function markRootExpiredAtTime(root, expirationTime) {
  54757. var lastExpiredTime = root.lastExpiredTime;
  54758. if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) {
  54759. root.lastExpiredTime = expirationTime;
  54760. }
  54761. }
  54762. // This lets us hook into Fiber to debug what it's doing.
  54763. // See https://github.com/facebook/react/pull/8033.
  54764. // This is not part of the public API, not even for React DevTools.
  54765. // You may only inject a debugTool if you work on React Fiber itself.
  54766. var ReactFiberInstrumentation = {
  54767. debugTool: null
  54768. };
  54769. var ReactFiberInstrumentation_1 = ReactFiberInstrumentation;
  54770. var didWarnAboutNestedUpdates;
  54771. var didWarnAboutFindNodeInStrictMode;
  54772. {
  54773. didWarnAboutNestedUpdates = false;
  54774. didWarnAboutFindNodeInStrictMode = {};
  54775. }
  54776. function getContextForSubtree(parentComponent) {
  54777. if (!parentComponent) {
  54778. return emptyContextObject;
  54779. }
  54780. var fiber = get(parentComponent);
  54781. var parentContext = findCurrentUnmaskedContext(fiber);
  54782. if (fiber.tag === ClassComponent) {
  54783. var Component = fiber.type;
  54784. if (isContextProvider(Component)) {
  54785. return processChildContext(fiber, Component, parentContext);
  54786. }
  54787. }
  54788. return parentContext;
  54789. }
  54790. function scheduleRootUpdate(current$$1, element, expirationTime, suspenseConfig, callback) {
  54791. {
  54792. if (phase === 'render' && current !== null && !didWarnAboutNestedUpdates) {
  54793. didWarnAboutNestedUpdates = true;
  54794. warningWithoutStack$1(false, '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');
  54795. }
  54796. }
  54797. var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property
  54798. // being called "element".
  54799. update.payload = {
  54800. element: element
  54801. };
  54802. callback = callback === undefined ? null : callback;
  54803. if (callback !== null) {
  54804. !(typeof callback === 'function') ? warningWithoutStack$1(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
  54805. update.callback = callback;
  54806. }
  54807. enqueueUpdate(current$$1, update);
  54808. scheduleWork(current$$1, expirationTime);
  54809. return expirationTime;
  54810. }
  54811. function updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, suspenseConfig, callback) {
  54812. // TODO: If this is a nested container, this won't be the root.
  54813. var current$$1 = container.current;
  54814. {
  54815. if (ReactFiberInstrumentation_1.debugTool) {
  54816. if (current$$1.alternate === null) {
  54817. ReactFiberInstrumentation_1.debugTool.onMountContainer(container);
  54818. } else if (element === null) {
  54819. ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container);
  54820. } else {
  54821. ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container);
  54822. }
  54823. }
  54824. }
  54825. var context = getContextForSubtree(parentComponent);
  54826. if (container.context === null) {
  54827. container.context = context;
  54828. } else {
  54829. container.pendingContext = context;
  54830. }
  54831. return scheduleRootUpdate(current$$1, element, expirationTime, suspenseConfig, callback);
  54832. }
  54833. function findHostInstance(component) {
  54834. var fiber = get(component);
  54835. if (fiber === undefined) {
  54836. if (typeof component.render === 'function') {
  54837. (function () {
  54838. {
  54839. {
  54840. throw ReactError(Error("Unable to find node on an unmounted component."));
  54841. }
  54842. }
  54843. })();
  54844. } else {
  54845. (function () {
  54846. {
  54847. {
  54848. throw ReactError(Error("Argument appears to not be a ReactComponent. Keys: " + Object.keys(component)));
  54849. }
  54850. }
  54851. })();
  54852. }
  54853. }
  54854. var hostFiber = findCurrentHostFiber(fiber);
  54855. if (hostFiber === null) {
  54856. return null;
  54857. }
  54858. return hostFiber.stateNode;
  54859. }
  54860. function findHostInstanceWithWarning(component, methodName) {
  54861. {
  54862. var fiber = get(component);
  54863. if (fiber === undefined) {
  54864. if (typeof component.render === 'function') {
  54865. (function () {
  54866. {
  54867. {
  54868. throw ReactError(Error("Unable to find node on an unmounted component."));
  54869. }
  54870. }
  54871. })();
  54872. } else {
  54873. (function () {
  54874. {
  54875. {
  54876. throw ReactError(Error("Argument appears to not be a ReactComponent. Keys: " + Object.keys(component)));
  54877. }
  54878. }
  54879. })();
  54880. }
  54881. }
  54882. var hostFiber = findCurrentHostFiber(fiber);
  54883. if (hostFiber === null) {
  54884. return null;
  54885. }
  54886. if (hostFiber.mode & StrictMode) {
  54887. var componentName = getComponentName(fiber.type) || 'Component';
  54888. if (!didWarnAboutFindNodeInStrictMode[componentName]) {
  54889. didWarnAboutFindNodeInStrictMode[componentName] = true;
  54890. if (fiber.mode & StrictMode) {
  54891. warningWithoutStack$1(false, '%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));
  54892. } else {
  54893. warningWithoutStack$1(false, '%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));
  54894. }
  54895. }
  54896. }
  54897. return hostFiber.stateNode;
  54898. }
  54899. return findHostInstance(component);
  54900. }
  54901. function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) {
  54902. return createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks);
  54903. }
  54904. function updateContainer(element, container, parentComponent, callback) {
  54905. var current$$1 = container.current;
  54906. var currentTime = requestCurrentTime();
  54907. {
  54908. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  54909. if ('undefined' !== typeof jest) {
  54910. warnIfUnmockedScheduler(current$$1);
  54911. warnIfNotScopedWithMatchingAct(current$$1);
  54912. }
  54913. }
  54914. var suspenseConfig = requestCurrentSuspenseConfig();
  54915. var expirationTime = computeExpirationForFiber(currentTime, current$$1, suspenseConfig);
  54916. return updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, suspenseConfig, callback);
  54917. }
  54918. function getPublicRootInstance(container) {
  54919. var containerFiber = container.current;
  54920. if (!containerFiber.child) {
  54921. return null;
  54922. }
  54923. switch (containerFiber.child.tag) {
  54924. case HostComponent:
  54925. return getPublicInstance(containerFiber.child.stateNode);
  54926. default:
  54927. return containerFiber.child.stateNode;
  54928. }
  54929. }
  54930. function attemptSynchronousHydration$1(fiber) {
  54931. switch (fiber.tag) {
  54932. case HostRoot:
  54933. var root = fiber.stateNode;
  54934. if (root.hydrate) {
  54935. // Flush the first scheduled "update".
  54936. flushRoot(root, root.firstPendingTime);
  54937. }
  54938. break;
  54939. case SuspenseComponent:
  54940. flushSync(function () {
  54941. return scheduleWork(fiber, Sync);
  54942. });
  54943. break;
  54944. }
  54945. }
  54946. function findHostInstanceWithNoPortals(fiber) {
  54947. var hostFiber = findCurrentHostFiberWithNoPortals(fiber);
  54948. if (hostFiber === null) {
  54949. return null;
  54950. }
  54951. if (hostFiber.tag === FundamentalComponent) {
  54952. return hostFiber.stateNode.instance;
  54953. }
  54954. return hostFiber.stateNode;
  54955. }
  54956. var shouldSuspendImpl = function (fiber) {
  54957. return false;
  54958. };
  54959. function shouldSuspend(fiber) {
  54960. return shouldSuspendImpl(fiber);
  54961. }
  54962. var overrideHookState = null;
  54963. var overrideProps = null;
  54964. var scheduleUpdate = null;
  54965. var setSuspenseHandler = null;
  54966. {
  54967. var copyWithSetImpl = function (obj, path, idx, value) {
  54968. if (idx >= path.length) {
  54969. return value;
  54970. }
  54971. var key = path[idx];
  54972. var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); // $FlowFixMe number or string is fine here
  54973. updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
  54974. return updated;
  54975. };
  54976. var copyWithSet = function (obj, path, value) {
  54977. return copyWithSetImpl(obj, path, 0, value);
  54978. }; // Support DevTools editable values for useState and useReducer.
  54979. overrideHookState = function (fiber, id, path, value) {
  54980. // For now, the "id" of stateful hooks is just the stateful hook index.
  54981. // This may change in the future with e.g. nested hooks.
  54982. var currentHook = fiber.memoizedState;
  54983. while (currentHook !== null && id > 0) {
  54984. currentHook = currentHook.next;
  54985. id--;
  54986. }
  54987. if (currentHook !== null) {
  54988. var newState = copyWithSet(currentHook.memoizedState, path, value);
  54989. currentHook.memoizedState = newState;
  54990. currentHook.baseState = newState; // We aren't actually adding an update to the queue,
  54991. // because there is no update we can add for useReducer hooks that won't trigger an error.
  54992. // (There's no appropriate action type for DevTools overrides.)
  54993. // As a result though, React will see the scheduled update as a noop and bailout.
  54994. // Shallow cloning props works as a workaround for now to bypass the bailout check.
  54995. fiber.memoizedProps = _assign({}, fiber.memoizedProps);
  54996. scheduleWork(fiber, Sync);
  54997. }
  54998. }; // Support DevTools props for function components, forwardRef, memo, host components, etc.
  54999. overrideProps = function (fiber, path, value) {
  55000. fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
  55001. if (fiber.alternate) {
  55002. fiber.alternate.pendingProps = fiber.pendingProps;
  55003. }
  55004. scheduleWork(fiber, Sync);
  55005. };
  55006. scheduleUpdate = function (fiber) {
  55007. scheduleWork(fiber, Sync);
  55008. };
  55009. setSuspenseHandler = function (newShouldSuspendImpl) {
  55010. shouldSuspendImpl = newShouldSuspendImpl;
  55011. };
  55012. }
  55013. function injectIntoDevTools(devToolsConfig) {
  55014. var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
  55015. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  55016. return injectInternals(_assign({}, devToolsConfig, {
  55017. overrideHookState: overrideHookState,
  55018. overrideProps: overrideProps,
  55019. setSuspenseHandler: setSuspenseHandler,
  55020. scheduleUpdate: scheduleUpdate,
  55021. currentDispatcherRef: ReactCurrentDispatcher,
  55022. findHostInstanceByFiber: function (fiber) {
  55023. var hostFiber = findCurrentHostFiber(fiber);
  55024. if (hostFiber === null) {
  55025. return null;
  55026. }
  55027. return hostFiber.stateNode;
  55028. },
  55029. findFiberByHostInstance: function (instance) {
  55030. if (!findFiberByHostInstance) {
  55031. // Might not be implemented by the renderer.
  55032. return null;
  55033. }
  55034. return findFiberByHostInstance(instance);
  55035. },
  55036. // React Refresh
  55037. findHostInstancesForRefresh: findHostInstancesForRefresh,
  55038. scheduleRefresh: scheduleRefresh,
  55039. scheduleRoot: scheduleRoot,
  55040. setRefreshHandler: setRefreshHandler,
  55041. // Enables DevTools to append owner stacks to error messages in DEV mode.
  55042. getCurrentFiber: function () {
  55043. return current;
  55044. }
  55045. }));
  55046. }
  55047. // This file intentionally does *not* have the Flow annotation.
  55048. // Don't add it. See `./inline-typed.js` for an explanation.
  55049. function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
  55050. implementation) {
  55051. var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  55052. return {
  55053. // This tag allow us to uniquely identify this as a React Portal
  55054. $$typeof: REACT_PORTAL_TYPE,
  55055. key: key == null ? null : '' + key,
  55056. children: children,
  55057. containerInfo: containerInfo,
  55058. implementation: implementation
  55059. };
  55060. }
  55061. // TODO: this is special because it gets imported during build.
  55062. var ReactVersion = '16.10.1';
  55063. // TODO: This type is shared between the reconciler and ReactDOM, but will
  55064. // eventually be lifted out to the renderer.
  55065. setAttemptSynchronousHydration(attemptSynchronousHydration$1);
  55066. var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
  55067. var topLevelUpdateWarnings;
  55068. var warnOnInvalidCallback;
  55069. var didWarnAboutUnstableCreatePortal = false;
  55070. {
  55071. if (typeof Map !== 'function' || // $FlowIssue Flow incorrectly thinks Map has no prototype
  55072. Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || // $FlowIssue Flow incorrectly thinks Set has no prototype
  55073. Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') {
  55074. warningWithoutStack$1(false, 'React depends on Map and Set built-in types. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  55075. }
  55076. topLevelUpdateWarnings = function (container) {
  55077. if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
  55078. var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current);
  55079. if (hostInstance) {
  55080. !(hostInstance.parentNode === container) ? warningWithoutStack$1(false, '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.') : void 0;
  55081. }
  55082. }
  55083. var isRootRenderedBySomeReact = !!container._reactRootContainer;
  55084. var rootEl = getReactRootElementInContainer(container);
  55085. var hasNonRootReactChild = !!(rootEl && getInstanceFromNode$1(rootEl));
  55086. !(!hasNonRootReactChild || isRootRenderedBySomeReact) ? warningWithoutStack$1(false, '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.') : void 0;
  55087. !(container.nodeType !== ELEMENT_NODE || !container.tagName || container.tagName.toUpperCase() !== 'BODY') ? warningWithoutStack$1(false, '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.') : void 0;
  55088. };
  55089. warnOnInvalidCallback = function (callback, callerName) {
  55090. !(callback === null || typeof callback === 'function') ? warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback) : void 0;
  55091. };
  55092. }
  55093. setRestoreImplementation(restoreControlledState$$1);
  55094. function ReactBatch(root) {
  55095. var expirationTime = computeUniqueAsyncExpiration();
  55096. this._expirationTime = expirationTime;
  55097. this._root = root;
  55098. this._next = null;
  55099. this._callbacks = null;
  55100. this._didComplete = false;
  55101. this._hasChildren = false;
  55102. this._children = null;
  55103. this._defer = true;
  55104. }
  55105. ReactBatch.prototype.render = function (children) {
  55106. var _this = this;
  55107. (function () {
  55108. if (!_this._defer) {
  55109. {
  55110. throw ReactError(Error("batch.render: Cannot render a batch that already committed."));
  55111. }
  55112. }
  55113. })();
  55114. this._hasChildren = true;
  55115. this._children = children;
  55116. var internalRoot = this._root._internalRoot;
  55117. var expirationTime = this._expirationTime;
  55118. var work = new ReactWork();
  55119. updateContainerAtExpirationTime(children, internalRoot, null, expirationTime, null, work._onCommit);
  55120. return work;
  55121. };
  55122. ReactBatch.prototype.then = function (onComplete) {
  55123. if (this._didComplete) {
  55124. onComplete();
  55125. return;
  55126. }
  55127. var callbacks = this._callbacks;
  55128. if (callbacks === null) {
  55129. callbacks = this._callbacks = [];
  55130. }
  55131. callbacks.push(onComplete);
  55132. };
  55133. ReactBatch.prototype.commit = function () {
  55134. var _this2 = this;
  55135. var internalRoot = this._root._internalRoot;
  55136. var firstBatch = internalRoot.firstBatch;
  55137. (function () {
  55138. if (!(_this2._defer && firstBatch !== null)) {
  55139. {
  55140. throw ReactError(Error("batch.commit: Cannot commit a batch multiple times."));
  55141. }
  55142. }
  55143. })();
  55144. if (!this._hasChildren) {
  55145. // This batch is empty. Return.
  55146. this._next = null;
  55147. this._defer = false;
  55148. return;
  55149. }
  55150. var expirationTime = this._expirationTime; // Ensure this is the first batch in the list.
  55151. if (firstBatch !== this) {
  55152. // This batch is not the earliest batch. We need to move it to the front.
  55153. // Update its expiration time to be the expiration time of the earliest
  55154. // batch, so that we can flush it without flushing the other batches.
  55155. if (this._hasChildren) {
  55156. expirationTime = this._expirationTime = firstBatch._expirationTime; // Rendering this batch again ensures its children will be the final state
  55157. // when we flush (updates are processed in insertion order: last
  55158. // update wins).
  55159. // TODO: This forces a restart. Should we print a warning?
  55160. this.render(this._children);
  55161. } // Remove the batch from the list.
  55162. var previous = null;
  55163. var batch = firstBatch;
  55164. while (batch !== this) {
  55165. previous = batch;
  55166. batch = batch._next;
  55167. }
  55168. (function () {
  55169. if (!(previous !== null)) {
  55170. {
  55171. throw ReactError(Error("batch.commit: Cannot commit a batch multiple times."));
  55172. }
  55173. }
  55174. })();
  55175. previous._next = batch._next; // Add it to the front.
  55176. this._next = firstBatch;
  55177. firstBatch = internalRoot.firstBatch = this;
  55178. } // Synchronously flush all the work up to this batch's expiration time.
  55179. this._defer = false;
  55180. flushRoot(internalRoot, expirationTime); // Pop the batch from the list.
  55181. var next = this._next;
  55182. this._next = null;
  55183. firstBatch = internalRoot.firstBatch = next; // Append the next earliest batch's children to the update queue.
  55184. if (firstBatch !== null && firstBatch._hasChildren) {
  55185. firstBatch.render(firstBatch._children);
  55186. }
  55187. };
  55188. ReactBatch.prototype._onComplete = function () {
  55189. if (this._didComplete) {
  55190. return;
  55191. }
  55192. this._didComplete = true;
  55193. var callbacks = this._callbacks;
  55194. if (callbacks === null) {
  55195. return;
  55196. } // TODO: Error handling.
  55197. for (var i = 0; i < callbacks.length; i++) {
  55198. var _callback = callbacks[i];
  55199. _callback();
  55200. }
  55201. };
  55202. function ReactWork() {
  55203. this._callbacks = null;
  55204. this._didCommit = false; // TODO: Avoid need to bind by replacing callbacks in the update queue with
  55205. // list of Work objects.
  55206. this._onCommit = this._onCommit.bind(this);
  55207. }
  55208. ReactWork.prototype.then = function (onCommit) {
  55209. if (this._didCommit) {
  55210. onCommit();
  55211. return;
  55212. }
  55213. var callbacks = this._callbacks;
  55214. if (callbacks === null) {
  55215. callbacks = this._callbacks = [];
  55216. }
  55217. callbacks.push(onCommit);
  55218. };
  55219. ReactWork.prototype._onCommit = function () {
  55220. if (this._didCommit) {
  55221. return;
  55222. }
  55223. this._didCommit = true;
  55224. var callbacks = this._callbacks;
  55225. if (callbacks === null) {
  55226. return;
  55227. } // TODO: Error handling.
  55228. for (var i = 0; i < callbacks.length; i++) {
  55229. var _callback2 = callbacks[i];
  55230. (function () {
  55231. if (!(typeof _callback2 === 'function')) {
  55232. {
  55233. throw ReactError(Error("Invalid argument passed as callback. Expected a function. Instead received: " + _callback2));
  55234. }
  55235. }
  55236. })();
  55237. _callback2();
  55238. }
  55239. };
  55240. function createRootImpl(container, tag, options) {
  55241. // Tag is either LegacyRoot or Concurrent Root
  55242. var hydrate = options != null && options.hydrate === true;
  55243. var hydrationCallbacks = options != null && options.hydrationOptions || null;
  55244. var root = createContainer(container, tag, hydrate, hydrationCallbacks);
  55245. markContainerAsRoot(root.current, container);
  55246. if (hydrate && tag !== LegacyRoot) {
  55247. var doc = container.nodeType === DOCUMENT_NODE ? container : container.ownerDocument;
  55248. eagerlyTrapReplayableEvents(doc);
  55249. }
  55250. return root;
  55251. }
  55252. function ReactSyncRoot(container, tag, options) {
  55253. this._internalRoot = createRootImpl(container, tag, options);
  55254. }
  55255. function ReactRoot(container, options) {
  55256. this._internalRoot = createRootImpl(container, ConcurrentRoot, options);
  55257. }
  55258. ReactRoot.prototype.render = ReactSyncRoot.prototype.render = function (children, callback) {
  55259. var root = this._internalRoot;
  55260. var work = new ReactWork();
  55261. callback = callback === undefined ? null : callback;
  55262. {
  55263. warnOnInvalidCallback(callback, 'render');
  55264. }
  55265. if (callback !== null) {
  55266. work.then(callback);
  55267. }
  55268. updateContainer(children, root, null, work._onCommit);
  55269. return work;
  55270. };
  55271. ReactRoot.prototype.unmount = ReactSyncRoot.prototype.unmount = function (callback) {
  55272. var root = this._internalRoot;
  55273. var work = new ReactWork();
  55274. callback = callback === undefined ? null : callback;
  55275. {
  55276. warnOnInvalidCallback(callback, 'render');
  55277. }
  55278. if (callback !== null) {
  55279. work.then(callback);
  55280. }
  55281. updateContainer(null, root, null, work._onCommit);
  55282. return work;
  55283. }; // Sync roots cannot create batches. Only concurrent ones.
  55284. ReactRoot.prototype.createBatch = function () {
  55285. var batch = new ReactBatch(this);
  55286. var expirationTime = batch._expirationTime;
  55287. var internalRoot = this._internalRoot;
  55288. var firstBatch = internalRoot.firstBatch;
  55289. if (firstBatch === null) {
  55290. internalRoot.firstBatch = batch;
  55291. batch._next = null;
  55292. } else {
  55293. // Insert sorted by expiration time then insertion order
  55294. var insertAfter = null;
  55295. var insertBefore = firstBatch;
  55296. while (insertBefore !== null && insertBefore._expirationTime >= expirationTime) {
  55297. insertAfter = insertBefore;
  55298. insertBefore = insertBefore._next;
  55299. }
  55300. batch._next = insertBefore;
  55301. if (insertAfter !== null) {
  55302. insertAfter._next = batch;
  55303. }
  55304. }
  55305. return batch;
  55306. };
  55307. /**
  55308. * True if the supplied DOM node is a valid node element.
  55309. *
  55310. * @param {?DOMElement} node The candidate DOM node.
  55311. * @return {boolean} True if the DOM is a valid DOM node.
  55312. * @internal
  55313. */
  55314. function isValidContainer(node) {
  55315. 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 '));
  55316. }
  55317. function getReactRootElementInContainer(container) {
  55318. if (!container) {
  55319. return null;
  55320. }
  55321. if (container.nodeType === DOCUMENT_NODE) {
  55322. return container.documentElement;
  55323. } else {
  55324. return container.firstChild;
  55325. }
  55326. }
  55327. function shouldHydrateDueToLegacyHeuristic(container) {
  55328. var rootElement = getReactRootElementInContainer(container);
  55329. return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME));
  55330. }
  55331. setBatchingImplementation(batchedUpdates$1, discreteUpdates$1, flushDiscreteUpdates, batchedEventUpdates$1);
  55332. var warnedAboutHydrateAPI = false;
  55333. function legacyCreateRootFromDOMContainer(container, forceHydrate) {
  55334. var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container); // First clear any existing content.
  55335. if (!shouldHydrate) {
  55336. var warned = false;
  55337. var rootSibling;
  55338. while (rootSibling = container.lastChild) {
  55339. {
  55340. if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) {
  55341. warned = true;
  55342. warningWithoutStack$1(false, '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.');
  55343. }
  55344. }
  55345. container.removeChild(rootSibling);
  55346. }
  55347. }
  55348. {
  55349. if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) {
  55350. warnedAboutHydrateAPI = true;
  55351. lowPriorityWarningWithoutStack$1(false, '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.');
  55352. }
  55353. } // Legacy roots are not batched.
  55354. return new ReactSyncRoot(container, LegacyRoot, shouldHydrate ? {
  55355. hydrate: true
  55356. } : undefined);
  55357. }
  55358. function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) {
  55359. {
  55360. topLevelUpdateWarnings(container);
  55361. warnOnInvalidCallback(callback === undefined ? null : callback, 'render');
  55362. } // TODO: Without `any` type, Flow says "Property cannot be accessed on any
  55363. // member of intersection type." Whyyyyyy.
  55364. var root = container._reactRootContainer;
  55365. var fiberRoot;
  55366. if (!root) {
  55367. // Initial mount
  55368. root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate);
  55369. fiberRoot = root._internalRoot;
  55370. if (typeof callback === 'function') {
  55371. var originalCallback = callback;
  55372. callback = function () {
  55373. var instance = getPublicRootInstance(fiberRoot);
  55374. originalCallback.call(instance);
  55375. };
  55376. } // Initial mount should not be batched.
  55377. unbatchedUpdates(function () {
  55378. updateContainer(children, fiberRoot, parentComponent, callback);
  55379. });
  55380. } else {
  55381. fiberRoot = root._internalRoot;
  55382. if (typeof callback === 'function') {
  55383. var _originalCallback = callback;
  55384. callback = function () {
  55385. var instance = getPublicRootInstance(fiberRoot);
  55386. _originalCallback.call(instance);
  55387. };
  55388. } // Update
  55389. updateContainer(children, fiberRoot, parentComponent, callback);
  55390. }
  55391. return getPublicRootInstance(fiberRoot);
  55392. }
  55393. function createPortal$$1(children, container) {
  55394. var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  55395. (function () {
  55396. if (!isValidContainer(container)) {
  55397. {
  55398. throw ReactError(Error("Target container is not a DOM element."));
  55399. }
  55400. }
  55401. })(); // TODO: pass ReactDOM portal implementation as third argument
  55402. return createPortal$1(children, container, null, key);
  55403. }
  55404. var ReactDOM = {
  55405. createPortal: createPortal$$1,
  55406. findDOMNode: function (componentOrElement) {
  55407. {
  55408. var owner = ReactCurrentOwner.current;
  55409. if (owner !== null && owner.stateNode !== null) {
  55410. var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender;
  55411. !warnedAboutRefsInRender ? warningWithoutStack$1(false, '%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') : void 0;
  55412. owner.stateNode._warnedAboutRefsInRender = true;
  55413. }
  55414. }
  55415. if (componentOrElement == null) {
  55416. return null;
  55417. }
  55418. if (componentOrElement.nodeType === ELEMENT_NODE) {
  55419. return componentOrElement;
  55420. }
  55421. {
  55422. return findHostInstanceWithWarning(componentOrElement, 'findDOMNode');
  55423. }
  55424. return findHostInstance(componentOrElement);
  55425. },
  55426. hydrate: function (element, container, callback) {
  55427. (function () {
  55428. if (!isValidContainer(container)) {
  55429. {
  55430. throw ReactError(Error("Target container is not a DOM element."));
  55431. }
  55432. }
  55433. })();
  55434. {
  55435. !!container._reactHasBeenPassedToCreateRootDEV ? warningWithoutStack$1(false, 'You are calling ReactDOM.hydrate() on a container that was previously ' + 'passed to ReactDOM.%s(). This is not supported. ' + 'Did you mean to call createRoot(container, {hydrate: true}).render(element)?', enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot') : void 0;
  55436. } // TODO: throw or warn if we couldn't hydrate?
  55437. return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);
  55438. },
  55439. render: function (element, container, callback) {
  55440. (function () {
  55441. if (!isValidContainer(container)) {
  55442. {
  55443. throw ReactError(Error("Target container is not a DOM element."));
  55444. }
  55445. }
  55446. })();
  55447. {
  55448. !!container._reactHasBeenPassedToCreateRootDEV ? warningWithoutStack$1(false, 'You are calling ReactDOM.render() on a container that was previously ' + 'passed to ReactDOM.%s(). This is not supported. ' + 'Did you mean to call root.render(element)?', enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot') : void 0;
  55449. }
  55450. return legacyRenderSubtreeIntoContainer(null, element, container, false, callback);
  55451. },
  55452. unstable_renderSubtreeIntoContainer: function (parentComponent, element, containerNode, callback) {
  55453. (function () {
  55454. if (!isValidContainer(containerNode)) {
  55455. {
  55456. throw ReactError(Error("Target container is not a DOM element."));
  55457. }
  55458. }
  55459. })();
  55460. (function () {
  55461. if (!(parentComponent != null && has(parentComponent))) {
  55462. {
  55463. throw ReactError(Error("parentComponent must be a valid React Component"));
  55464. }
  55465. }
  55466. })();
  55467. return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback);
  55468. },
  55469. unmountComponentAtNode: function (container) {
  55470. (function () {
  55471. if (!isValidContainer(container)) {
  55472. {
  55473. throw ReactError(Error("unmountComponentAtNode(...): Target container is not a DOM element."));
  55474. }
  55475. }
  55476. })();
  55477. {
  55478. !!container._reactHasBeenPassedToCreateRootDEV ? warningWithoutStack$1(false, 'You are calling ReactDOM.unmountComponentAtNode() on a container that was previously ' + 'passed to ReactDOM.%s(). This is not supported. Did you mean to call root.unmount()?', enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot') : void 0;
  55479. }
  55480. if (container._reactRootContainer) {
  55481. {
  55482. var rootEl = getReactRootElementInContainer(container);
  55483. var renderedByDifferentReact = rootEl && !getInstanceFromNode$1(rootEl);
  55484. !!renderedByDifferentReact ? warningWithoutStack$1(false, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.') : void 0;
  55485. } // Unmount should not be batched.
  55486. unbatchedUpdates(function () {
  55487. legacyRenderSubtreeIntoContainer(null, null, container, false, function () {
  55488. container._reactRootContainer = null;
  55489. });
  55490. }); // If you call unmountComponentAtNode twice in quick succession, you'll
  55491. // get `true` twice. That's probably fine?
  55492. return true;
  55493. } else {
  55494. {
  55495. var _rootEl = getReactRootElementInContainer(container);
  55496. var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode$1(_rootEl)); // Check if the container itself is a React root node.
  55497. var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer;
  55498. !!hasNonRootReactChild ? warningWithoutStack$1(false, "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.') : void 0;
  55499. }
  55500. return false;
  55501. }
  55502. },
  55503. // Temporary alias since we already shipped React 16 RC with it.
  55504. // TODO: remove in React 17.
  55505. unstable_createPortal: function () {
  55506. if (!didWarnAboutUnstableCreatePortal) {
  55507. didWarnAboutUnstableCreatePortal = true;
  55508. lowPriorityWarningWithoutStack$1(false, '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.');
  55509. }
  55510. return createPortal$$1.apply(void 0, arguments);
  55511. },
  55512. unstable_batchedUpdates: batchedUpdates$1,
  55513. // TODO remove this legacy method, unstable_discreteUpdates replaces it
  55514. unstable_interactiveUpdates: function (fn, a, b, c) {
  55515. flushDiscreteUpdates();
  55516. return discreteUpdates$1(fn, a, b, c);
  55517. },
  55518. unstable_discreteUpdates: discreteUpdates$1,
  55519. unstable_flushDiscreteUpdates: flushDiscreteUpdates,
  55520. flushSync: flushSync,
  55521. unstable_createRoot: createRoot,
  55522. unstable_createSyncRoot: createSyncRoot,
  55523. unstable_flushControlled: flushControlled,
  55524. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
  55525. // Keep in sync with ReactDOMUnstableNativeDependencies.js
  55526. // ReactTestUtils.js, and ReactTestUtilsAct.js. This is an array for better minification.
  55527. Events: [getInstanceFromNode$1, getNodeFromInstance$1, getFiberCurrentPropsFromNode$1, injection.injectEventPluginsByName, eventNameDispatchConfigs, accumulateTwoPhaseDispatches, accumulateDirectDispatches, enqueueStateRestore, restoreStateIfNeeded, dispatchEvent, runEventsInBatch, flushPassiveEffects, IsThisRendererActing]
  55528. }
  55529. };
  55530. function createRoot(container, options) {
  55531. var functionName = enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot';
  55532. (function () {
  55533. if (!isValidContainer(container)) {
  55534. {
  55535. throw ReactError(Error(functionName + "(...): Target container is not a DOM element."));
  55536. }
  55537. }
  55538. })();
  55539. warnIfReactDOMContainerInDEV(container);
  55540. return new ReactRoot(container, options);
  55541. }
  55542. function createSyncRoot(container, options) {
  55543. var functionName = enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot';
  55544. (function () {
  55545. if (!isValidContainer(container)) {
  55546. {
  55547. throw ReactError(Error(functionName + "(...): Target container is not a DOM element."));
  55548. }
  55549. }
  55550. })();
  55551. warnIfReactDOMContainerInDEV(container);
  55552. return new ReactSyncRoot(container, BatchedRoot, options);
  55553. }
  55554. function warnIfReactDOMContainerInDEV(container) {
  55555. {
  55556. !!container._reactRootContainer ? warningWithoutStack$1(false, 'You are calling ReactDOM.%s() on a container that was previously ' + 'passed to ReactDOM.render(). This is not supported.', enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot') : void 0;
  55557. container._reactHasBeenPassedToCreateRootDEV = true;
  55558. }
  55559. }
  55560. if (enableStableConcurrentModeAPIs) {
  55561. ReactDOM.createRoot = createRoot;
  55562. ReactDOM.createSyncRoot = createSyncRoot;
  55563. }
  55564. var foundDevTools = injectIntoDevTools({
  55565. findFiberByHostInstance: getClosestInstanceFromNode,
  55566. bundleType: 1,
  55567. version: ReactVersion,
  55568. rendererPackageName: 'react-dom'
  55569. });
  55570. {
  55571. if (!foundDevTools && canUseDOM && window.top === window.self) {
  55572. // If we're in Chrome or Firefox, provide a download link if not installed.
  55573. if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) {
  55574. var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension://.
  55575. if (/^(https?|file):$/.test(protocol)) {
  55576. 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');
  55577. }
  55578. }
  55579. }
  55580. }
  55581. var ReactDOM$2 = Object.freeze({
  55582. default: ReactDOM
  55583. });
  55584. var ReactDOM$3 = ( ReactDOM$2 && ReactDOM ) || ReactDOM$2;
  55585. // TODO: decide on the top-level export form.
  55586. // This is hacky but makes it work with both Rollup and Jest.
  55587. var reactDom = ReactDOM$3.default || ReactDOM$3;
  55588. module.exports = reactDom;
  55589. })();
  55590. }
  55591. /***/ }),
  55592. /***/ "./node_modules/react-dom/index.js":
  55593. /*!*****************************************!*\
  55594. !*** ./node_modules/react-dom/index.js ***!
  55595. \*****************************************/
  55596. /*! no static exports found */
  55597. /***/ (function(module, exports, __webpack_require__) {
  55598. "use strict";
  55599. function checkDCE() {
  55600. /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
  55601. if (
  55602. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' ||
  55603. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function'
  55604. ) {
  55605. return;
  55606. }
  55607. if (true) {
  55608. // This branch is unreachable because this function is only called
  55609. // in production, but the condition is true only in development.
  55610. // Therefore if the branch is still here, dead code elimination wasn't
  55611. // properly applied.
  55612. // Don't change the message. React DevTools relies on it. Also make sure
  55613. // this message doesn't occur elsewhere in this function, or it will cause
  55614. // a false positive.
  55615. throw new Error('^_^');
  55616. }
  55617. try {
  55618. // Verify that the code above has been dead code eliminated (DCE'd).
  55619. __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);
  55620. } catch (err) {
  55621. // DevTools shouldn't crash React, no matter what.
  55622. // We should still report in case we break this code.
  55623. console.error(err);
  55624. }
  55625. }
  55626. if (false) {} else {
  55627. module.exports = __webpack_require__(/*! ./cjs/react-dom.development.js */ "./node_modules/react-dom/cjs/react-dom.development.js");
  55628. }
  55629. /***/ }),
  55630. /***/ "./node_modules/react/cjs/react.development.js":
  55631. /*!*****************************************************!*\
  55632. !*** ./node_modules/react/cjs/react.development.js ***!
  55633. \*****************************************************/
  55634. /*! no static exports found */
  55635. /***/ (function(module, exports, __webpack_require__) {
  55636. "use strict";
  55637. /** @license React v16.10.1
  55638. * react.development.js
  55639. *
  55640. * Copyright (c) Facebook, Inc. and its affiliates.
  55641. *
  55642. * This source code is licensed under the MIT license found in the
  55643. * LICENSE file in the root directory of this source tree.
  55644. */
  55645. if (true) {
  55646. (function() {
  55647. 'use strict';
  55648. var _assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js");
  55649. var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "./node_modules/prop-types/checkPropTypes.js");
  55650. // TODO: this is special because it gets imported during build.
  55651. var ReactVersion = '16.10.1';
  55652. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  55653. // nor polyfill, then a plain number is used for performance.
  55654. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  55655. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  55656. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  55657. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  55658. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  55659. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  55660. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  55661. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  55662. // (unstable) APIs that have been removed. Can we remove the symbols?
  55663. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  55664. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  55665. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  55666. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  55667. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  55668. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  55669. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  55670. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  55671. var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
  55672. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  55673. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  55674. function getIteratorFn(maybeIterable) {
  55675. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  55676. return null;
  55677. }
  55678. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  55679. if (typeof maybeIterator === 'function') {
  55680. return maybeIterator;
  55681. }
  55682. return null;
  55683. }
  55684. // Do not require this module directly! Use normal `invariant` calls with
  55685. // template literal strings. The messages will be converted to ReactError during
  55686. // build, and in production they will be minified.
  55687. // Do not require this module directly! Use normal `invariant` calls with
  55688. // template literal strings. The messages will be converted to ReactError during
  55689. // build, and in production they will be minified.
  55690. function ReactError(error) {
  55691. error.name = 'Invariant Violation';
  55692. return error;
  55693. }
  55694. /**
  55695. * Use invariant() to assert state which your program assumes to be true.
  55696. *
  55697. * Provide sprintf-style format (only %s is supported) and arguments
  55698. * to provide information about what broke and what you were
  55699. * expecting.
  55700. *
  55701. * The invariant message will be stripped in production, but the invariant
  55702. * will remain to ensure logic does not differ in production.
  55703. */
  55704. /**
  55705. * Forked from fbjs/warning:
  55706. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  55707. *
  55708. * Only change is we use console.warn instead of console.error,
  55709. * and do nothing when 'console' is not supported.
  55710. * This really simplifies the code.
  55711. * ---
  55712. * Similar to invariant but only logs a warning if the condition is not met.
  55713. * This can be used to log issues in development environments in critical
  55714. * paths. Removing the logging code for production environments will keep the
  55715. * same logic and follow the same code paths.
  55716. */
  55717. var lowPriorityWarningWithoutStack = function () {};
  55718. {
  55719. var printWarning = function (format) {
  55720. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  55721. args[_key - 1] = arguments[_key];
  55722. }
  55723. var argIndex = 0;
  55724. var message = 'Warning: ' + format.replace(/%s/g, function () {
  55725. return args[argIndex++];
  55726. });
  55727. if (typeof console !== 'undefined') {
  55728. console.warn(message);
  55729. }
  55730. try {
  55731. // --- Welcome to debugging React ---
  55732. // This error was thrown as a convenience so that you can use this stack
  55733. // to find the callsite that caused this warning to fire.
  55734. throw new Error(message);
  55735. } catch (x) {}
  55736. };
  55737. lowPriorityWarningWithoutStack = function (condition, format) {
  55738. if (format === undefined) {
  55739. throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
  55740. }
  55741. if (!condition) {
  55742. for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  55743. args[_key2 - 2] = arguments[_key2];
  55744. }
  55745. printWarning.apply(void 0, [format].concat(args));
  55746. }
  55747. };
  55748. }
  55749. var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
  55750. /**
  55751. * Similar to invariant but only logs a warning if the condition is not met.
  55752. * This can be used to log issues in development environments in critical
  55753. * paths. Removing the logging code for production environments will keep the
  55754. * same logic and follow the same code paths.
  55755. */
  55756. var warningWithoutStack = function () {};
  55757. {
  55758. warningWithoutStack = function (condition, format) {
  55759. for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  55760. args[_key - 2] = arguments[_key];
  55761. }
  55762. if (format === undefined) {
  55763. throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
  55764. }
  55765. if (args.length > 8) {
  55766. // Check before the condition to catch violations early.
  55767. throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
  55768. }
  55769. if (condition) {
  55770. return;
  55771. }
  55772. if (typeof console !== 'undefined') {
  55773. var argsWithFormat = args.map(function (item) {
  55774. return '' + item;
  55775. });
  55776. argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
  55777. // breaks IE9: https://github.com/facebook/react/issues/13610
  55778. Function.prototype.apply.call(console.error, console, argsWithFormat);
  55779. }
  55780. try {
  55781. // --- Welcome to debugging React ---
  55782. // This error was thrown as a convenience so that you can use this stack
  55783. // to find the callsite that caused this warning to fire.
  55784. var argIndex = 0;
  55785. var message = 'Warning: ' + format.replace(/%s/g, function () {
  55786. return args[argIndex++];
  55787. });
  55788. throw new Error(message);
  55789. } catch (x) {}
  55790. };
  55791. }
  55792. var warningWithoutStack$1 = warningWithoutStack;
  55793. var didWarnStateUpdateForUnmountedComponent = {};
  55794. function warnNoop(publicInstance, callerName) {
  55795. {
  55796. var _constructor = publicInstance.constructor;
  55797. var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
  55798. var warningKey = componentName + "." + callerName;
  55799. if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
  55800. return;
  55801. }
  55802. warningWithoutStack$1(false, "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);
  55803. didWarnStateUpdateForUnmountedComponent[warningKey] = true;
  55804. }
  55805. }
  55806. /**
  55807. * This is the abstract API for an update queue.
  55808. */
  55809. var ReactNoopUpdateQueue = {
  55810. /**
  55811. * Checks whether or not this composite component is mounted.
  55812. * @param {ReactClass} publicInstance The instance we want to test.
  55813. * @return {boolean} True if mounted, false otherwise.
  55814. * @protected
  55815. * @final
  55816. */
  55817. isMounted: function (publicInstance) {
  55818. return false;
  55819. },
  55820. /**
  55821. * Forces an update. This should only be invoked when it is known with
  55822. * certainty that we are **not** in a DOM transaction.
  55823. *
  55824. * You may want to call this when you know that some deeper aspect of the
  55825. * component's state has changed but `setState` was not called.
  55826. *
  55827. * This will not invoke `shouldComponentUpdate`, but it will invoke
  55828. * `componentWillUpdate` and `componentDidUpdate`.
  55829. *
  55830. * @param {ReactClass} publicInstance The instance that should rerender.
  55831. * @param {?function} callback Called after component is updated.
  55832. * @param {?string} callerName name of the calling function in the public API.
  55833. * @internal
  55834. */
  55835. enqueueForceUpdate: function (publicInstance, callback, callerName) {
  55836. warnNoop(publicInstance, 'forceUpdate');
  55837. },
  55838. /**
  55839. * Replaces all of the state. Always use this or `setState` to mutate state.
  55840. * You should treat `this.state` as immutable.
  55841. *
  55842. * There is no guarantee that `this.state` will be immediately updated, so
  55843. * accessing `this.state` after calling this method may return the old value.
  55844. *
  55845. * @param {ReactClass} publicInstance The instance that should rerender.
  55846. * @param {object} completeState Next state.
  55847. * @param {?function} callback Called after component is updated.
  55848. * @param {?string} callerName name of the calling function in the public API.
  55849. * @internal
  55850. */
  55851. enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
  55852. warnNoop(publicInstance, 'replaceState');
  55853. },
  55854. /**
  55855. * Sets a subset of the state. This only exists because _pendingState is
  55856. * internal. This provides a merging strategy that is not available to deep
  55857. * properties which is confusing. TODO: Expose pendingState or don't use it
  55858. * during the merge.
  55859. *
  55860. * @param {ReactClass} publicInstance The instance that should rerender.
  55861. * @param {object} partialState Next partial state to be merged with state.
  55862. * @param {?function} callback Called after component is updated.
  55863. * @param {?string} Name of the calling function in the public API.
  55864. * @internal
  55865. */
  55866. enqueueSetState: function (publicInstance, partialState, callback, callerName) {
  55867. warnNoop(publicInstance, 'setState');
  55868. }
  55869. };
  55870. var emptyObject = {};
  55871. {
  55872. Object.freeze(emptyObject);
  55873. }
  55874. /**
  55875. * Base class helpers for the updating state of a component.
  55876. */
  55877. function Component(props, context, updater) {
  55878. this.props = props;
  55879. this.context = context; // If a component has string refs, we will assign a different object later.
  55880. this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
  55881. // renderer.
  55882. this.updater = updater || ReactNoopUpdateQueue;
  55883. }
  55884. Component.prototype.isReactComponent = {};
  55885. /**
  55886. * Sets a subset of the state. Always use this to mutate
  55887. * state. You should treat `this.state` as immutable.
  55888. *
  55889. * There is no guarantee that `this.state` will be immediately updated, so
  55890. * accessing `this.state` after calling this method may return the old value.
  55891. *
  55892. * There is no guarantee that calls to `setState` will run synchronously,
  55893. * as they may eventually be batched together. You can provide an optional
  55894. * callback that will be executed when the call to setState is actually
  55895. * completed.
  55896. *
  55897. * When a function is provided to setState, it will be called at some point in
  55898. * the future (not synchronously). It will be called with the up to date
  55899. * component arguments (state, props, context). These values can be different
  55900. * from this.* because your function may be called after receiveProps but before
  55901. * shouldComponentUpdate, and this new state, props, and context will not yet be
  55902. * assigned to this.
  55903. *
  55904. * @param {object|function} partialState Next partial state or function to
  55905. * produce next partial state to be merged with current state.
  55906. * @param {?function} callback Called after state is updated.
  55907. * @final
  55908. * @protected
  55909. */
  55910. Component.prototype.setState = function (partialState, callback) {
  55911. (function () {
  55912. if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) {
  55913. {
  55914. throw ReactError(Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables."));
  55915. }
  55916. }
  55917. })();
  55918. this.updater.enqueueSetState(this, partialState, callback, 'setState');
  55919. };
  55920. /**
  55921. * Forces an update. This should only be invoked when it is known with
  55922. * certainty that we are **not** in a DOM transaction.
  55923. *
  55924. * You may want to call this when you know that some deeper aspect of the
  55925. * component's state has changed but `setState` was not called.
  55926. *
  55927. * This will not invoke `shouldComponentUpdate`, but it will invoke
  55928. * `componentWillUpdate` and `componentDidUpdate`.
  55929. *
  55930. * @param {?function} callback Called after update is complete.
  55931. * @final
  55932. * @protected
  55933. */
  55934. Component.prototype.forceUpdate = function (callback) {
  55935. this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
  55936. };
  55937. /**
  55938. * Deprecated APIs. These APIs used to exist on classic React classes but since
  55939. * we would like to deprecate them, we're not going to move them over to this
  55940. * modern base class. Instead, we define a getter that warns if it's accessed.
  55941. */
  55942. {
  55943. var deprecatedAPIs = {
  55944. isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
  55945. replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
  55946. };
  55947. var defineDeprecationWarning = function (methodName, info) {
  55948. Object.defineProperty(Component.prototype, methodName, {
  55949. get: function () {
  55950. lowPriorityWarningWithoutStack$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
  55951. return undefined;
  55952. }
  55953. });
  55954. };
  55955. for (var fnName in deprecatedAPIs) {
  55956. if (deprecatedAPIs.hasOwnProperty(fnName)) {
  55957. defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
  55958. }
  55959. }
  55960. }
  55961. function ComponentDummy() {}
  55962. ComponentDummy.prototype = Component.prototype;
  55963. /**
  55964. * Convenience component with default shallow equality check for sCU.
  55965. */
  55966. function PureComponent(props, context, updater) {
  55967. this.props = props;
  55968. this.context = context; // If a component has string refs, we will assign a different object later.
  55969. this.refs = emptyObject;
  55970. this.updater = updater || ReactNoopUpdateQueue;
  55971. }
  55972. var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
  55973. pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.
  55974. _assign(pureComponentPrototype, Component.prototype);
  55975. pureComponentPrototype.isPureReactComponent = true;
  55976. // an immutable object with a single mutable value
  55977. function createRef() {
  55978. var refObject = {
  55979. current: null
  55980. };
  55981. {
  55982. Object.seal(refObject);
  55983. }
  55984. return refObject;
  55985. }
  55986. /**
  55987. * Keeps track of the current dispatcher.
  55988. */
  55989. var ReactCurrentDispatcher = {
  55990. /**
  55991. * @internal
  55992. * @type {ReactComponent}
  55993. */
  55994. current: null
  55995. };
  55996. /**
  55997. * Keeps track of the current batch's configuration such as how long an update
  55998. * should suspend for if it needs to.
  55999. */
  56000. var ReactCurrentBatchConfig = {
  56001. suspense: null
  56002. };
  56003. /**
  56004. * Keeps track of the current owner.
  56005. *
  56006. * The current owner is the component who should own any components that are
  56007. * currently being constructed.
  56008. */
  56009. var ReactCurrentOwner = {
  56010. /**
  56011. * @internal
  56012. * @type {ReactComponent}
  56013. */
  56014. current: null
  56015. };
  56016. var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
  56017. var describeComponentFrame = function (name, source, ownerName) {
  56018. var sourceInfo = '';
  56019. if (source) {
  56020. var path = source.fileName;
  56021. var fileName = path.replace(BEFORE_SLASH_RE, '');
  56022. {
  56023. // In DEV, include code for a common special case:
  56024. // prefer "folder/index.js" instead of just "index.js".
  56025. if (/^index\./.test(fileName)) {
  56026. var match = path.match(BEFORE_SLASH_RE);
  56027. if (match) {
  56028. var pathBeforeSlash = match[1];
  56029. if (pathBeforeSlash) {
  56030. var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
  56031. fileName = folderName + '/' + fileName;
  56032. }
  56033. }
  56034. }
  56035. }
  56036. sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
  56037. } else if (ownerName) {
  56038. sourceInfo = ' (created by ' + ownerName + ')';
  56039. }
  56040. return '\n in ' + (name || 'Unknown') + sourceInfo;
  56041. };
  56042. var Resolved = 1;
  56043. function refineResolvedLazyComponent(lazyComponent) {
  56044. return lazyComponent._status === Resolved ? lazyComponent._result : null;
  56045. }
  56046. function getWrappedName(outerType, innerType, wrapperName) {
  56047. var functionName = innerType.displayName || innerType.name || '';
  56048. return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
  56049. }
  56050. function getComponentName(type) {
  56051. if (type == null) {
  56052. // Host root, text node or just invalid type.
  56053. return null;
  56054. }
  56055. {
  56056. if (typeof type.tag === 'number') {
  56057. warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  56058. }
  56059. }
  56060. if (typeof type === 'function') {
  56061. return type.displayName || type.name || null;
  56062. }
  56063. if (typeof type === 'string') {
  56064. return type;
  56065. }
  56066. switch (type) {
  56067. case REACT_FRAGMENT_TYPE:
  56068. return 'Fragment';
  56069. case REACT_PORTAL_TYPE:
  56070. return 'Portal';
  56071. case REACT_PROFILER_TYPE:
  56072. return "Profiler";
  56073. case REACT_STRICT_MODE_TYPE:
  56074. return 'StrictMode';
  56075. case REACT_SUSPENSE_TYPE:
  56076. return 'Suspense';
  56077. case REACT_SUSPENSE_LIST_TYPE:
  56078. return 'SuspenseList';
  56079. }
  56080. if (typeof type === 'object') {
  56081. switch (type.$$typeof) {
  56082. case REACT_CONTEXT_TYPE:
  56083. return 'Context.Consumer';
  56084. case REACT_PROVIDER_TYPE:
  56085. return 'Context.Provider';
  56086. case REACT_FORWARD_REF_TYPE:
  56087. return getWrappedName(type, type.render, 'ForwardRef');
  56088. case REACT_MEMO_TYPE:
  56089. return getComponentName(type.type);
  56090. case REACT_LAZY_TYPE:
  56091. {
  56092. var thenable = type;
  56093. var resolvedThenable = refineResolvedLazyComponent(thenable);
  56094. if (resolvedThenable) {
  56095. return getComponentName(resolvedThenable);
  56096. }
  56097. break;
  56098. }
  56099. }
  56100. }
  56101. return null;
  56102. }
  56103. var ReactDebugCurrentFrame = {};
  56104. var currentlyValidatingElement = null;
  56105. function setCurrentlyValidatingElement(element) {
  56106. {
  56107. currentlyValidatingElement = element;
  56108. }
  56109. }
  56110. {
  56111. // Stack implementation injected by the current renderer.
  56112. ReactDebugCurrentFrame.getCurrentStack = null;
  56113. ReactDebugCurrentFrame.getStackAddendum = function () {
  56114. var stack = ''; // Add an extra top frame while an element is being validated
  56115. if (currentlyValidatingElement) {
  56116. var name = getComponentName(currentlyValidatingElement.type);
  56117. var owner = currentlyValidatingElement._owner;
  56118. stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
  56119. } // Delegate to the injected renderer-specific implementation
  56120. var impl = ReactDebugCurrentFrame.getCurrentStack;
  56121. if (impl) {
  56122. stack += impl() || '';
  56123. }
  56124. return stack;
  56125. };
  56126. }
  56127. /**
  56128. * Used by act() to track whether you're inside an act() scope.
  56129. */
  56130. var IsSomeRendererActing = {
  56131. current: false
  56132. };
  56133. var ReactSharedInternals = {
  56134. ReactCurrentDispatcher: ReactCurrentDispatcher,
  56135. ReactCurrentBatchConfig: ReactCurrentBatchConfig,
  56136. ReactCurrentOwner: ReactCurrentOwner,
  56137. IsSomeRendererActing: IsSomeRendererActing,
  56138. // Used by renderers to avoid bundling object-assign twice in UMD bundles:
  56139. assign: _assign
  56140. };
  56141. {
  56142. _assign(ReactSharedInternals, {
  56143. // These should not be included in production.
  56144. ReactDebugCurrentFrame: ReactDebugCurrentFrame,
  56145. // Shim for React DOM 16.0.0 which still destructured (but not used) this.
  56146. // TODO: remove in React 17.0.
  56147. ReactComponentTreeHook: {}
  56148. });
  56149. }
  56150. /**
  56151. * Similar to invariant but only logs a warning if the condition is not met.
  56152. * This can be used to log issues in development environments in critical
  56153. * paths. Removing the logging code for production environments will keep the
  56154. * same logic and follow the same code paths.
  56155. */
  56156. var warning = warningWithoutStack$1;
  56157. {
  56158. warning = function (condition, format) {
  56159. if (condition) {
  56160. return;
  56161. }
  56162. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  56163. var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args
  56164. for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  56165. args[_key - 2] = arguments[_key];
  56166. }
  56167. warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack]));
  56168. };
  56169. }
  56170. var warning$1 = warning;
  56171. var hasOwnProperty = Object.prototype.hasOwnProperty;
  56172. var RESERVED_PROPS = {
  56173. key: true,
  56174. ref: true,
  56175. __self: true,
  56176. __source: true
  56177. };
  56178. var specialPropKeyWarningShown;
  56179. var specialPropRefWarningShown;
  56180. function hasValidRef(config) {
  56181. {
  56182. if (hasOwnProperty.call(config, 'ref')) {
  56183. var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
  56184. if (getter && getter.isReactWarning) {
  56185. return false;
  56186. }
  56187. }
  56188. }
  56189. return config.ref !== undefined;
  56190. }
  56191. function hasValidKey(config) {
  56192. {
  56193. if (hasOwnProperty.call(config, 'key')) {
  56194. var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
  56195. if (getter && getter.isReactWarning) {
  56196. return false;
  56197. }
  56198. }
  56199. }
  56200. return config.key !== undefined;
  56201. }
  56202. function defineKeyPropWarningGetter(props, displayName) {
  56203. var warnAboutAccessingKey = function () {
  56204. if (!specialPropKeyWarningShown) {
  56205. specialPropKeyWarningShown = true;
  56206. warningWithoutStack$1(false, '%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);
  56207. }
  56208. };
  56209. warnAboutAccessingKey.isReactWarning = true;
  56210. Object.defineProperty(props, 'key', {
  56211. get: warnAboutAccessingKey,
  56212. configurable: true
  56213. });
  56214. }
  56215. function defineRefPropWarningGetter(props, displayName) {
  56216. var warnAboutAccessingRef = function () {
  56217. if (!specialPropRefWarningShown) {
  56218. specialPropRefWarningShown = true;
  56219. warningWithoutStack$1(false, '%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);
  56220. }
  56221. };
  56222. warnAboutAccessingRef.isReactWarning = true;
  56223. Object.defineProperty(props, 'ref', {
  56224. get: warnAboutAccessingRef,
  56225. configurable: true
  56226. });
  56227. }
  56228. /**
  56229. * Factory method to create a new React element. This no longer adheres to
  56230. * the class pattern, so do not use new to call it. Also, no instanceof check
  56231. * will work. Instead test $$typeof field against Symbol.for('react.element') to check
  56232. * if something is a React Element.
  56233. *
  56234. * @param {*} type
  56235. * @param {*} props
  56236. * @param {*} key
  56237. * @param {string|object} ref
  56238. * @param {*} owner
  56239. * @param {*} self A *temporary* helper to detect places where `this` is
  56240. * different from the `owner` when React.createElement is called, so that we
  56241. * can warn. We want to get rid of owner and replace string `ref`s with arrow
  56242. * functions, and as long as `this` and owner are the same, there will be no
  56243. * change in behavior.
  56244. * @param {*} source An annotation object (added by a transpiler or otherwise)
  56245. * indicating filename, line number, and/or other information.
  56246. * @internal
  56247. */
  56248. var ReactElement = function (type, key, ref, self, source, owner, props) {
  56249. var element = {
  56250. // This tag allows us to uniquely identify this as a React Element
  56251. $$typeof: REACT_ELEMENT_TYPE,
  56252. // Built-in properties that belong on the element
  56253. type: type,
  56254. key: key,
  56255. ref: ref,
  56256. props: props,
  56257. // Record the component responsible for creating this element.
  56258. _owner: owner
  56259. };
  56260. {
  56261. // The validation flag is currently mutative. We put it on
  56262. // an external backing store so that we can freeze the whole object.
  56263. // This can be replaced with a WeakMap once they are implemented in
  56264. // commonly used development environments.
  56265. element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
  56266. // the validation flag non-enumerable (where possible, which should
  56267. // include every environment we run tests in), so the test framework
  56268. // ignores it.
  56269. Object.defineProperty(element._store, 'validated', {
  56270. configurable: false,
  56271. enumerable: false,
  56272. writable: true,
  56273. value: false
  56274. }); // self and source are DEV only properties.
  56275. Object.defineProperty(element, '_self', {
  56276. configurable: false,
  56277. enumerable: false,
  56278. writable: false,
  56279. value: self
  56280. }); // Two elements created in two different places should be considered
  56281. // equal for testing purposes and therefore we hide it from enumeration.
  56282. Object.defineProperty(element, '_source', {
  56283. configurable: false,
  56284. enumerable: false,
  56285. writable: false,
  56286. value: source
  56287. });
  56288. if (Object.freeze) {
  56289. Object.freeze(element.props);
  56290. Object.freeze(element);
  56291. }
  56292. }
  56293. return element;
  56294. };
  56295. /**
  56296. * https://github.com/reactjs/rfcs/pull/107
  56297. * @param {*} type
  56298. * @param {object} props
  56299. * @param {string} key
  56300. */
  56301. /**
  56302. * https://github.com/reactjs/rfcs/pull/107
  56303. * @param {*} type
  56304. * @param {object} props
  56305. * @param {string} key
  56306. */
  56307. function jsxDEV(type, config, maybeKey, source, self) {
  56308. var propName; // Reserved names are extracted
  56309. var props = {};
  56310. var key = null;
  56311. var ref = null; // Currently, key can be spread in as a prop. This causes a potential
  56312. // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
  56313. // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
  56314. // but as an intermediary step, we will use jsxDEV for everything except
  56315. // <div {...props} key="Hi" />, because we aren't currently able to tell if
  56316. // key is explicitly declared to be undefined or not.
  56317. if (maybeKey !== undefined) {
  56318. key = '' + maybeKey;
  56319. }
  56320. if (hasValidKey(config)) {
  56321. key = '' + config.key;
  56322. }
  56323. if (hasValidRef(config)) {
  56324. ref = config.ref;
  56325. } // Remaining properties are added to a new props object
  56326. for (propName in config) {
  56327. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  56328. props[propName] = config[propName];
  56329. }
  56330. } // Resolve default props
  56331. if (type && type.defaultProps) {
  56332. var defaultProps = type.defaultProps;
  56333. for (propName in defaultProps) {
  56334. if (props[propName] === undefined) {
  56335. props[propName] = defaultProps[propName];
  56336. }
  56337. }
  56338. }
  56339. if (key || ref) {
  56340. var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
  56341. if (key) {
  56342. defineKeyPropWarningGetter(props, displayName);
  56343. }
  56344. if (ref) {
  56345. defineRefPropWarningGetter(props, displayName);
  56346. }
  56347. }
  56348. return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
  56349. }
  56350. /**
  56351. * Create and return a new ReactElement of the given type.
  56352. * See https://reactjs.org/docs/react-api.html#createelement
  56353. */
  56354. function createElement(type, config, children) {
  56355. var propName; // Reserved names are extracted
  56356. var props = {};
  56357. var key = null;
  56358. var ref = null;
  56359. var self = null;
  56360. var source = null;
  56361. if (config != null) {
  56362. if (hasValidRef(config)) {
  56363. ref = config.ref;
  56364. }
  56365. if (hasValidKey(config)) {
  56366. key = '' + config.key;
  56367. }
  56368. self = config.__self === undefined ? null : config.__self;
  56369. source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object
  56370. for (propName in config) {
  56371. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  56372. props[propName] = config[propName];
  56373. }
  56374. }
  56375. } // Children can be more than one argument, and those are transferred onto
  56376. // the newly allocated props object.
  56377. var childrenLength = arguments.length - 2;
  56378. if (childrenLength === 1) {
  56379. props.children = children;
  56380. } else if (childrenLength > 1) {
  56381. var childArray = Array(childrenLength);
  56382. for (var i = 0; i < childrenLength; i++) {
  56383. childArray[i] = arguments[i + 2];
  56384. }
  56385. {
  56386. if (Object.freeze) {
  56387. Object.freeze(childArray);
  56388. }
  56389. }
  56390. props.children = childArray;
  56391. } // Resolve default props
  56392. if (type && type.defaultProps) {
  56393. var defaultProps = type.defaultProps;
  56394. for (propName in defaultProps) {
  56395. if (props[propName] === undefined) {
  56396. props[propName] = defaultProps[propName];
  56397. }
  56398. }
  56399. }
  56400. {
  56401. if (key || ref) {
  56402. var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
  56403. if (key) {
  56404. defineKeyPropWarningGetter(props, displayName);
  56405. }
  56406. if (ref) {
  56407. defineRefPropWarningGetter(props, displayName);
  56408. }
  56409. }
  56410. }
  56411. return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
  56412. }
  56413. /**
  56414. * Return a function that produces ReactElements of a given type.
  56415. * See https://reactjs.org/docs/react-api.html#createfactory
  56416. */
  56417. function cloneAndReplaceKey(oldElement, newKey) {
  56418. var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
  56419. return newElement;
  56420. }
  56421. /**
  56422. * Clone and return a new ReactElement using element as the starting point.
  56423. * See https://reactjs.org/docs/react-api.html#cloneelement
  56424. */
  56425. function cloneElement(element, config, children) {
  56426. (function () {
  56427. if (!!(element === null || element === undefined)) {
  56428. {
  56429. throw ReactError(Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + "."));
  56430. }
  56431. }
  56432. })();
  56433. var propName; // Original props are copied
  56434. var props = _assign({}, element.props); // Reserved names are extracted
  56435. var key = element.key;
  56436. var ref = element.ref; // Self is preserved since the owner is preserved.
  56437. var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a
  56438. // transpiler, and the original source is probably a better indicator of the
  56439. // true owner.
  56440. var source = element._source; // Owner will be preserved, unless ref is overridden
  56441. var owner = element._owner;
  56442. if (config != null) {
  56443. if (hasValidRef(config)) {
  56444. // Silently steal the ref from the parent.
  56445. ref = config.ref;
  56446. owner = ReactCurrentOwner.current;
  56447. }
  56448. if (hasValidKey(config)) {
  56449. key = '' + config.key;
  56450. } // Remaining properties override existing props
  56451. var defaultProps;
  56452. if (element.type && element.type.defaultProps) {
  56453. defaultProps = element.type.defaultProps;
  56454. }
  56455. for (propName in config) {
  56456. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  56457. if (config[propName] === undefined && defaultProps !== undefined) {
  56458. // Resolve default props
  56459. props[propName] = defaultProps[propName];
  56460. } else {
  56461. props[propName] = config[propName];
  56462. }
  56463. }
  56464. }
  56465. } // Children can be more than one argument, and those are transferred onto
  56466. // the newly allocated props object.
  56467. var childrenLength = arguments.length - 2;
  56468. if (childrenLength === 1) {
  56469. props.children = children;
  56470. } else if (childrenLength > 1) {
  56471. var childArray = Array(childrenLength);
  56472. for (var i = 0; i < childrenLength; i++) {
  56473. childArray[i] = arguments[i + 2];
  56474. }
  56475. props.children = childArray;
  56476. }
  56477. return ReactElement(element.type, key, ref, self, source, owner, props);
  56478. }
  56479. /**
  56480. * Verifies the object is a ReactElement.
  56481. * See https://reactjs.org/docs/react-api.html#isvalidelement
  56482. * @param {?object} object
  56483. * @return {boolean} True if `object` is a ReactElement.
  56484. * @final
  56485. */
  56486. function isValidElement(object) {
  56487. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  56488. }
  56489. var SEPARATOR = '.';
  56490. var SUBSEPARATOR = ':';
  56491. /**
  56492. * Escape and wrap key so it is safe to use as a reactid
  56493. *
  56494. * @param {string} key to be escaped.
  56495. * @return {string} the escaped key.
  56496. */
  56497. function escape(key) {
  56498. var escapeRegex = /[=:]/g;
  56499. var escaperLookup = {
  56500. '=': '=0',
  56501. ':': '=2'
  56502. };
  56503. var escapedString = ('' + key).replace(escapeRegex, function (match) {
  56504. return escaperLookup[match];
  56505. });
  56506. return '$' + escapedString;
  56507. }
  56508. /**
  56509. * TODO: Test that a single child and an array with one item have the same key
  56510. * pattern.
  56511. */
  56512. var didWarnAboutMaps = false;
  56513. var userProvidedKeyEscapeRegex = /\/+/g;
  56514. function escapeUserProvidedKey(text) {
  56515. return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
  56516. }
  56517. var POOL_SIZE = 10;
  56518. var traverseContextPool = [];
  56519. function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
  56520. if (traverseContextPool.length) {
  56521. var traverseContext = traverseContextPool.pop();
  56522. traverseContext.result = mapResult;
  56523. traverseContext.keyPrefix = keyPrefix;
  56524. traverseContext.func = mapFunction;
  56525. traverseContext.context = mapContext;
  56526. traverseContext.count = 0;
  56527. return traverseContext;
  56528. } else {
  56529. return {
  56530. result: mapResult,
  56531. keyPrefix: keyPrefix,
  56532. func: mapFunction,
  56533. context: mapContext,
  56534. count: 0
  56535. };
  56536. }
  56537. }
  56538. function releaseTraverseContext(traverseContext) {
  56539. traverseContext.result = null;
  56540. traverseContext.keyPrefix = null;
  56541. traverseContext.func = null;
  56542. traverseContext.context = null;
  56543. traverseContext.count = 0;
  56544. if (traverseContextPool.length < POOL_SIZE) {
  56545. traverseContextPool.push(traverseContext);
  56546. }
  56547. }
  56548. /**
  56549. * @param {?*} children Children tree container.
  56550. * @param {!string} nameSoFar Name of the key path so far.
  56551. * @param {!function} callback Callback to invoke with each child found.
  56552. * @param {?*} traverseContext Used to pass information throughout the traversal
  56553. * process.
  56554. * @return {!number} The number of children in this subtree.
  56555. */
  56556. function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
  56557. var type = typeof children;
  56558. if (type === 'undefined' || type === 'boolean') {
  56559. // All of the above are perceived as null.
  56560. children = null;
  56561. }
  56562. var invokeCallback = false;
  56563. if (children === null) {
  56564. invokeCallback = true;
  56565. } else {
  56566. switch (type) {
  56567. case 'string':
  56568. case 'number':
  56569. invokeCallback = true;
  56570. break;
  56571. case 'object':
  56572. switch (children.$$typeof) {
  56573. case REACT_ELEMENT_TYPE:
  56574. case REACT_PORTAL_TYPE:
  56575. invokeCallback = true;
  56576. }
  56577. }
  56578. }
  56579. if (invokeCallback) {
  56580. callback(traverseContext, children, // If it's the only child, treat the name as if it was wrapped in an array
  56581. // so that it's consistent if the number of children grows.
  56582. nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
  56583. return 1;
  56584. }
  56585. var child;
  56586. var nextName;
  56587. var subtreeCount = 0; // Count of children found in the current subtree.
  56588. var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
  56589. if (Array.isArray(children)) {
  56590. for (var i = 0; i < children.length; i++) {
  56591. child = children[i];
  56592. nextName = nextNamePrefix + getComponentKey(child, i);
  56593. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  56594. }
  56595. } else {
  56596. var iteratorFn = getIteratorFn(children);
  56597. if (typeof iteratorFn === 'function') {
  56598. {
  56599. // Warn about using Maps as children
  56600. if (iteratorFn === children.entries) {
  56601. !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
  56602. didWarnAboutMaps = true;
  56603. }
  56604. }
  56605. var iterator = iteratorFn.call(children);
  56606. var step;
  56607. var ii = 0;
  56608. while (!(step = iterator.next()).done) {
  56609. child = step.value;
  56610. nextName = nextNamePrefix + getComponentKey(child, ii++);
  56611. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  56612. }
  56613. } else if (type === 'object') {
  56614. var addendum = '';
  56615. {
  56616. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
  56617. }
  56618. var childrenString = '' + children;
  56619. (function () {
  56620. {
  56621. {
  56622. throw ReactError(Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ")." + addendum));
  56623. }
  56624. }
  56625. })();
  56626. }
  56627. }
  56628. return subtreeCount;
  56629. }
  56630. /**
  56631. * Traverses children that are typically specified as `props.children`, but
  56632. * might also be specified through attributes:
  56633. *
  56634. * - `traverseAllChildren(this.props.children, ...)`
  56635. * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
  56636. *
  56637. * The `traverseContext` is an optional argument that is passed through the
  56638. * entire traversal. It can be used to store accumulations or anything else that
  56639. * the callback might find relevant.
  56640. *
  56641. * @param {?*} children Children tree object.
  56642. * @param {!function} callback To invoke upon traversing each child.
  56643. * @param {?*} traverseContext Context for traversal.
  56644. * @return {!number} The number of children in this subtree.
  56645. */
  56646. function traverseAllChildren(children, callback, traverseContext) {
  56647. if (children == null) {
  56648. return 0;
  56649. }
  56650. return traverseAllChildrenImpl(children, '', callback, traverseContext);
  56651. }
  56652. /**
  56653. * Generate a key string that identifies a component within a set.
  56654. *
  56655. * @param {*} component A component that could contain a manual key.
  56656. * @param {number} index Index that is used if a manual key is not provided.
  56657. * @return {string}
  56658. */
  56659. function getComponentKey(component, index) {
  56660. // Do some typechecking here since we call this blindly. We want to ensure
  56661. // that we don't block potential future ES APIs.
  56662. if (typeof component === 'object' && component !== null && component.key != null) {
  56663. // Explicit key
  56664. return escape(component.key);
  56665. } // Implicit key determined by the index in the set
  56666. return index.toString(36);
  56667. }
  56668. function forEachSingleChild(bookKeeping, child, name) {
  56669. var func = bookKeeping.func,
  56670. context = bookKeeping.context;
  56671. func.call(context, child, bookKeeping.count++);
  56672. }
  56673. /**
  56674. * Iterates through children that are typically specified as `props.children`.
  56675. *
  56676. * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
  56677. *
  56678. * The provided forEachFunc(child, index) will be called for each
  56679. * leaf child.
  56680. *
  56681. * @param {?*} children Children tree container.
  56682. * @param {function(*, int)} forEachFunc
  56683. * @param {*} forEachContext Context for forEachContext.
  56684. */
  56685. function forEachChildren(children, forEachFunc, forEachContext) {
  56686. if (children == null) {
  56687. return children;
  56688. }
  56689. var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
  56690. traverseAllChildren(children, forEachSingleChild, traverseContext);
  56691. releaseTraverseContext(traverseContext);
  56692. }
  56693. function mapSingleChildIntoContext(bookKeeping, child, childKey) {
  56694. var result = bookKeeping.result,
  56695. keyPrefix = bookKeeping.keyPrefix,
  56696. func = bookKeeping.func,
  56697. context = bookKeeping.context;
  56698. var mappedChild = func.call(context, child, bookKeeping.count++);
  56699. if (Array.isArray(mappedChild)) {
  56700. mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
  56701. return c;
  56702. });
  56703. } else if (mappedChild != null) {
  56704. if (isValidElement(mappedChild)) {
  56705. mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
  56706. // traverseAllChildren used to do for objects as children
  56707. keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
  56708. }
  56709. result.push(mappedChild);
  56710. }
  56711. }
  56712. function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
  56713. var escapedPrefix = '';
  56714. if (prefix != null) {
  56715. escapedPrefix = escapeUserProvidedKey(prefix) + '/';
  56716. }
  56717. var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
  56718. traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
  56719. releaseTraverseContext(traverseContext);
  56720. }
  56721. /**
  56722. * Maps children that are typically specified as `props.children`.
  56723. *
  56724. * See https://reactjs.org/docs/react-api.html#reactchildrenmap
  56725. *
  56726. * The provided mapFunction(child, key, index) will be called for each
  56727. * leaf child.
  56728. *
  56729. * @param {?*} children Children tree container.
  56730. * @param {function(*, int)} func The map function.
  56731. * @param {*} context Context for mapFunction.
  56732. * @return {object} Object containing the ordered map of results.
  56733. */
  56734. function mapChildren(children, func, context) {
  56735. if (children == null) {
  56736. return children;
  56737. }
  56738. var result = [];
  56739. mapIntoWithKeyPrefixInternal(children, result, null, func, context);
  56740. return result;
  56741. }
  56742. /**
  56743. * Count the number of children that are typically specified as
  56744. * `props.children`.
  56745. *
  56746. * See https://reactjs.org/docs/react-api.html#reactchildrencount
  56747. *
  56748. * @param {?*} children Children tree container.
  56749. * @return {number} The number of children.
  56750. */
  56751. function countChildren(children) {
  56752. return traverseAllChildren(children, function () {
  56753. return null;
  56754. }, null);
  56755. }
  56756. /**
  56757. * Flatten a children object (typically specified as `props.children`) and
  56758. * return an array with appropriately re-keyed children.
  56759. *
  56760. * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
  56761. */
  56762. function toArray(children) {
  56763. var result = [];
  56764. mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
  56765. return child;
  56766. });
  56767. return result;
  56768. }
  56769. /**
  56770. * Returns the first child in a collection of children and verifies that there
  56771. * is only one child in the collection.
  56772. *
  56773. * See https://reactjs.org/docs/react-api.html#reactchildrenonly
  56774. *
  56775. * The current implementation of this function assumes that a single child gets
  56776. * passed without a wrapper, but the purpose of this helper function is to
  56777. * abstract away the particular structure of children.
  56778. *
  56779. * @param {?object} children Child collection structure.
  56780. * @return {ReactElement} The first and only `ReactElement` contained in the
  56781. * structure.
  56782. */
  56783. function onlyChild(children) {
  56784. (function () {
  56785. if (!isValidElement(children)) {
  56786. {
  56787. throw ReactError(Error("React.Children.only expected to receive a single React element child."));
  56788. }
  56789. }
  56790. })();
  56791. return children;
  56792. }
  56793. function createContext(defaultValue, calculateChangedBits) {
  56794. if (calculateChangedBits === undefined) {
  56795. calculateChangedBits = null;
  56796. } else {
  56797. {
  56798. !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
  56799. }
  56800. }
  56801. var context = {
  56802. $$typeof: REACT_CONTEXT_TYPE,
  56803. _calculateChangedBits: calculateChangedBits,
  56804. // As a workaround to support multiple concurrent renderers, we categorize
  56805. // some renderers as primary and others as secondary. We only expect
  56806. // there to be two concurrent renderers at most: React Native (primary) and
  56807. // Fabric (secondary); React DOM (primary) and React ART (secondary).
  56808. // Secondary renderers store their context values on separate fields.
  56809. _currentValue: defaultValue,
  56810. _currentValue2: defaultValue,
  56811. // Used to track how many concurrent renderers this context currently
  56812. // supports within in a single renderer. Such as parallel server rendering.
  56813. _threadCount: 0,
  56814. // These are circular
  56815. Provider: null,
  56816. Consumer: null
  56817. };
  56818. context.Provider = {
  56819. $$typeof: REACT_PROVIDER_TYPE,
  56820. _context: context
  56821. };
  56822. var hasWarnedAboutUsingNestedContextConsumers = false;
  56823. var hasWarnedAboutUsingConsumerProvider = false;
  56824. {
  56825. // A separate object, but proxies back to the original context object for
  56826. // backwards compatibility. It has a different $$typeof, so we can properly
  56827. // warn for the incorrect usage of Context as a Consumer.
  56828. var Consumer = {
  56829. $$typeof: REACT_CONTEXT_TYPE,
  56830. _context: context,
  56831. _calculateChangedBits: context._calculateChangedBits
  56832. }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
  56833. Object.defineProperties(Consumer, {
  56834. Provider: {
  56835. get: function () {
  56836. if (!hasWarnedAboutUsingConsumerProvider) {
  56837. hasWarnedAboutUsingConsumerProvider = true;
  56838. warning$1(false, 'Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
  56839. }
  56840. return context.Provider;
  56841. },
  56842. set: function (_Provider) {
  56843. context.Provider = _Provider;
  56844. }
  56845. },
  56846. _currentValue: {
  56847. get: function () {
  56848. return context._currentValue;
  56849. },
  56850. set: function (_currentValue) {
  56851. context._currentValue = _currentValue;
  56852. }
  56853. },
  56854. _currentValue2: {
  56855. get: function () {
  56856. return context._currentValue2;
  56857. },
  56858. set: function (_currentValue2) {
  56859. context._currentValue2 = _currentValue2;
  56860. }
  56861. },
  56862. _threadCount: {
  56863. get: function () {
  56864. return context._threadCount;
  56865. },
  56866. set: function (_threadCount) {
  56867. context._threadCount = _threadCount;
  56868. }
  56869. },
  56870. Consumer: {
  56871. get: function () {
  56872. if (!hasWarnedAboutUsingNestedContextConsumers) {
  56873. hasWarnedAboutUsingNestedContextConsumers = true;
  56874. warning$1(false, 'Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
  56875. }
  56876. return context.Consumer;
  56877. }
  56878. }
  56879. }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
  56880. context.Consumer = Consumer;
  56881. }
  56882. {
  56883. context._currentRenderer = null;
  56884. context._currentRenderer2 = null;
  56885. }
  56886. return context;
  56887. }
  56888. function lazy(ctor) {
  56889. var lazyType = {
  56890. $$typeof: REACT_LAZY_TYPE,
  56891. _ctor: ctor,
  56892. // React uses these fields to store the result.
  56893. _status: -1,
  56894. _result: null
  56895. };
  56896. {
  56897. // In production, this would just set it on the object.
  56898. var defaultProps;
  56899. var propTypes;
  56900. Object.defineProperties(lazyType, {
  56901. defaultProps: {
  56902. configurable: true,
  56903. get: function () {
  56904. return defaultProps;
  56905. },
  56906. set: function (newDefaultProps) {
  56907. warning$1(false, '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.');
  56908. defaultProps = newDefaultProps; // Match production behavior more closely:
  56909. Object.defineProperty(lazyType, 'defaultProps', {
  56910. enumerable: true
  56911. });
  56912. }
  56913. },
  56914. propTypes: {
  56915. configurable: true,
  56916. get: function () {
  56917. return propTypes;
  56918. },
  56919. set: function (newPropTypes) {
  56920. warning$1(false, '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.');
  56921. propTypes = newPropTypes; // Match production behavior more closely:
  56922. Object.defineProperty(lazyType, 'propTypes', {
  56923. enumerable: true
  56924. });
  56925. }
  56926. }
  56927. });
  56928. }
  56929. return lazyType;
  56930. }
  56931. function forwardRef(render) {
  56932. {
  56933. if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
  56934. warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
  56935. } else if (typeof render !== 'function') {
  56936. warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
  56937. } else {
  56938. !( // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
  56939. render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, '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.') : void 0;
  56940. }
  56941. if (render != null) {
  56942. !(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
  56943. }
  56944. }
  56945. return {
  56946. $$typeof: REACT_FORWARD_REF_TYPE,
  56947. render: render
  56948. };
  56949. }
  56950. function isValidElementType(type) {
  56951. return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  56952. 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);
  56953. }
  56954. function memo(type, compare) {
  56955. {
  56956. if (!isValidElementType(type)) {
  56957. warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
  56958. }
  56959. }
  56960. return {
  56961. $$typeof: REACT_MEMO_TYPE,
  56962. type: type,
  56963. compare: compare === undefined ? null : compare
  56964. };
  56965. }
  56966. function resolveDispatcher() {
  56967. var dispatcher = ReactCurrentDispatcher.current;
  56968. (function () {
  56969. if (!(dispatcher !== null)) {
  56970. {
  56971. throw ReactError(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."));
  56972. }
  56973. }
  56974. })();
  56975. return dispatcher;
  56976. }
  56977. function useContext(Context, unstable_observedBits) {
  56978. var dispatcher = resolveDispatcher();
  56979. {
  56980. !(unstable_observedBits === undefined) ? warning$1(false, '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' : '') : void 0; // TODO: add a more generic warning for invalid values.
  56981. if (Context._context !== undefined) {
  56982. var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
  56983. // and nobody should be using this in existing code.
  56984. if (realContext.Consumer === Context) {
  56985. warning$1(false, '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?');
  56986. } else if (realContext.Provider === Context) {
  56987. warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
  56988. }
  56989. }
  56990. }
  56991. return dispatcher.useContext(Context, unstable_observedBits);
  56992. }
  56993. function useState(initialState) {
  56994. var dispatcher = resolveDispatcher();
  56995. return dispatcher.useState(initialState);
  56996. }
  56997. function useReducer(reducer, initialArg, init) {
  56998. var dispatcher = resolveDispatcher();
  56999. return dispatcher.useReducer(reducer, initialArg, init);
  57000. }
  57001. function useRef(initialValue) {
  57002. var dispatcher = resolveDispatcher();
  57003. return dispatcher.useRef(initialValue);
  57004. }
  57005. function useEffect(create, inputs) {
  57006. var dispatcher = resolveDispatcher();
  57007. return dispatcher.useEffect(create, inputs);
  57008. }
  57009. function useLayoutEffect(create, inputs) {
  57010. var dispatcher = resolveDispatcher();
  57011. return dispatcher.useLayoutEffect(create, inputs);
  57012. }
  57013. function useCallback(callback, inputs) {
  57014. var dispatcher = resolveDispatcher();
  57015. return dispatcher.useCallback(callback, inputs);
  57016. }
  57017. function useMemo(create, inputs) {
  57018. var dispatcher = resolveDispatcher();
  57019. return dispatcher.useMemo(create, inputs);
  57020. }
  57021. function useImperativeHandle(ref, create, inputs) {
  57022. var dispatcher = resolveDispatcher();
  57023. return dispatcher.useImperativeHandle(ref, create, inputs);
  57024. }
  57025. function useDebugValue(value, formatterFn) {
  57026. {
  57027. var dispatcher = resolveDispatcher();
  57028. return dispatcher.useDebugValue(value, formatterFn);
  57029. }
  57030. }
  57031. var emptyObject$1 = {};
  57032. function useResponder(responder, listenerProps) {
  57033. var dispatcher = resolveDispatcher();
  57034. {
  57035. if (responder == null || responder.$$typeof !== REACT_RESPONDER_TYPE) {
  57036. warning$1(false, 'useResponder: invalid first argument. Expected an event responder, but instead got %s', responder);
  57037. return;
  57038. }
  57039. }
  57040. return dispatcher.useResponder(responder, listenerProps || emptyObject$1);
  57041. }
  57042. function withSuspenseConfig(scope, config) {
  57043. var previousConfig = ReactCurrentBatchConfig.suspense;
  57044. ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
  57045. try {
  57046. scope();
  57047. } finally {
  57048. ReactCurrentBatchConfig.suspense = previousConfig;
  57049. }
  57050. }
  57051. /**
  57052. * ReactElementValidator provides a wrapper around a element factory
  57053. * which validates the props passed to the element. This is intended to be
  57054. * used only in DEV and could be replaced by a static type checker for languages
  57055. * that support it.
  57056. */
  57057. var propTypesMisspellWarningShown;
  57058. {
  57059. propTypesMisspellWarningShown = false;
  57060. }
  57061. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  57062. function getDeclarationErrorAddendum() {
  57063. if (ReactCurrentOwner.current) {
  57064. var name = getComponentName(ReactCurrentOwner.current.type);
  57065. if (name) {
  57066. return '\n\nCheck the render method of `' + name + '`.';
  57067. }
  57068. }
  57069. return '';
  57070. }
  57071. function getSourceInfoErrorAddendum(source) {
  57072. if (source !== undefined) {
  57073. var fileName = source.fileName.replace(/^.*[\\\/]/, '');
  57074. var lineNumber = source.lineNumber;
  57075. return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
  57076. }
  57077. return '';
  57078. }
  57079. function getSourceInfoErrorAddendumForProps(elementProps) {
  57080. if (elementProps !== null && elementProps !== undefined) {
  57081. return getSourceInfoErrorAddendum(elementProps.__source);
  57082. }
  57083. return '';
  57084. }
  57085. /**
  57086. * Warn if there's no key explicitly set on dynamic arrays of children or
  57087. * object keys are not valid. This allows us to keep track of children between
  57088. * updates.
  57089. */
  57090. var ownerHasKeyUseWarning = {};
  57091. function getCurrentComponentErrorInfo(parentType) {
  57092. var info = getDeclarationErrorAddendum();
  57093. if (!info) {
  57094. var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
  57095. if (parentName) {
  57096. info = "\n\nCheck the top-level render call using <" + parentName + ">.";
  57097. }
  57098. }
  57099. return info;
  57100. }
  57101. /**
  57102. * Warn if the element doesn't have an explicit key assigned to it.
  57103. * This element is in an array. The array could grow and shrink or be
  57104. * reordered. All children that haven't already been validated are required to
  57105. * have a "key" property assigned to it. Error statuses are cached so a warning
  57106. * will only be shown once.
  57107. *
  57108. * @internal
  57109. * @param {ReactElement} element Element that requires a key.
  57110. * @param {*} parentType element's parent's type.
  57111. */
  57112. function validateExplicitKey(element, parentType) {
  57113. if (!element._store || element._store.validated || element.key != null) {
  57114. return;
  57115. }
  57116. element._store.validated = true;
  57117. var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
  57118. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  57119. return;
  57120. }
  57121. ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
  57122. // property, it may be the creator of the child that's responsible for
  57123. // assigning it a key.
  57124. var childOwner = '';
  57125. if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
  57126. // Give the component that originally created this child.
  57127. childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
  57128. }
  57129. setCurrentlyValidatingElement(element);
  57130. {
  57131. warning$1(false, '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);
  57132. }
  57133. setCurrentlyValidatingElement(null);
  57134. }
  57135. /**
  57136. * Ensure that every element either is passed in a static location, in an
  57137. * array with an explicit keys property defined, or in an object literal
  57138. * with valid key property.
  57139. *
  57140. * @internal
  57141. * @param {ReactNode} node Statically passed child of any type.
  57142. * @param {*} parentType node's parent's type.
  57143. */
  57144. function validateChildKeys(node, parentType) {
  57145. if (typeof node !== 'object') {
  57146. return;
  57147. }
  57148. if (Array.isArray(node)) {
  57149. for (var i = 0; i < node.length; i++) {
  57150. var child = node[i];
  57151. if (isValidElement(child)) {
  57152. validateExplicitKey(child, parentType);
  57153. }
  57154. }
  57155. } else if (isValidElement(node)) {
  57156. // This element was passed in a valid location.
  57157. if (node._store) {
  57158. node._store.validated = true;
  57159. }
  57160. } else if (node) {
  57161. var iteratorFn = getIteratorFn(node);
  57162. if (typeof iteratorFn === 'function') {
  57163. // Entry iterators used to provide implicit keys,
  57164. // but now we print a separate warning for them later.
  57165. if (iteratorFn !== node.entries) {
  57166. var iterator = iteratorFn.call(node);
  57167. var step;
  57168. while (!(step = iterator.next()).done) {
  57169. if (isValidElement(step.value)) {
  57170. validateExplicitKey(step.value, parentType);
  57171. }
  57172. }
  57173. }
  57174. }
  57175. }
  57176. }
  57177. /**
  57178. * Given an element, validate that its props follow the propTypes definition,
  57179. * provided by the type.
  57180. *
  57181. * @param {ReactElement} element
  57182. */
  57183. function validatePropTypes(element) {
  57184. var type = element.type;
  57185. if (type === null || type === undefined || typeof type === 'string') {
  57186. return;
  57187. }
  57188. var name = getComponentName(type);
  57189. var propTypes;
  57190. if (typeof type === 'function') {
  57191. propTypes = type.propTypes;
  57192. } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
  57193. // Inner props are checked in the reconciler.
  57194. type.$$typeof === REACT_MEMO_TYPE)) {
  57195. propTypes = type.propTypes;
  57196. } else {
  57197. return;
  57198. }
  57199. if (propTypes) {
  57200. setCurrentlyValidatingElement(element);
  57201. checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
  57202. setCurrentlyValidatingElement(null);
  57203. } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
  57204. propTypesMisspellWarningShown = true;
  57205. warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
  57206. }
  57207. if (typeof type.getDefaultProps === 'function') {
  57208. !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
  57209. }
  57210. }
  57211. /**
  57212. * Given a fragment, validate that it can only be provided with fragment props
  57213. * @param {ReactElement} fragment
  57214. */
  57215. function validateFragmentProps(fragment) {
  57216. setCurrentlyValidatingElement(fragment);
  57217. var keys = Object.keys(fragment.props);
  57218. for (var i = 0; i < keys.length; i++) {
  57219. var key = keys[i];
  57220. if (key !== 'children' && key !== 'key') {
  57221. warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
  57222. break;
  57223. }
  57224. }
  57225. if (fragment.ref !== null) {
  57226. warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
  57227. }
  57228. setCurrentlyValidatingElement(null);
  57229. }
  57230. function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
  57231. var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
  57232. // succeed and there will likely be errors in render.
  57233. if (!validType) {
  57234. var info = '';
  57235. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  57236. 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.";
  57237. }
  57238. var sourceInfo = getSourceInfoErrorAddendum(source);
  57239. if (sourceInfo) {
  57240. info += sourceInfo;
  57241. } else {
  57242. info += getDeclarationErrorAddendum();
  57243. }
  57244. var typeString;
  57245. if (type === null) {
  57246. typeString = 'null';
  57247. } else if (Array.isArray(type)) {
  57248. typeString = 'array';
  57249. } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
  57250. typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
  57251. info = ' Did you accidentally export a JSX literal instead of a component?';
  57252. } else {
  57253. typeString = typeof type;
  57254. }
  57255. warning$1(false, 'React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
  57256. }
  57257. var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
  57258. // TODO: Drop this when these are no longer allowed as the type argument.
  57259. if (element == null) {
  57260. return element;
  57261. } // Skip key warning if the type isn't valid since our key validation logic
  57262. // doesn't expect a non-string/function type and can throw confusing errors.
  57263. // We don't want exception behavior to differ between dev and prod.
  57264. // (Rendering will throw with a helpful message and as soon as the type is
  57265. // fixed, the key warnings will appear.)
  57266. if (validType) {
  57267. var children = props.children;
  57268. if (children !== undefined) {
  57269. if (isStaticChildren) {
  57270. if (Array.isArray(children)) {
  57271. for (var i = 0; i < children.length; i++) {
  57272. validateChildKeys(children[i], type);
  57273. }
  57274. if (Object.freeze) {
  57275. Object.freeze(children);
  57276. }
  57277. } else {
  57278. warning$1(false, 'React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
  57279. }
  57280. } else {
  57281. validateChildKeys(children, type);
  57282. }
  57283. }
  57284. }
  57285. if (hasOwnProperty$1.call(props, 'key')) {
  57286. warning$1(false, 'React.jsx: Spreading a key to JSX is a deprecated pattern. ' + 'Explicitly pass a key after spreading props in your JSX call. ' + 'E.g. <ComponentName {...props} key={key} />');
  57287. }
  57288. if (type === REACT_FRAGMENT_TYPE) {
  57289. validateFragmentProps(element);
  57290. } else {
  57291. validatePropTypes(element);
  57292. }
  57293. return element;
  57294. } // These two functions exist to still get child warnings in dev
  57295. // even with the prod transform. This means that jsxDEV is purely
  57296. // opt-in behavior for better messages but that we won't stop
  57297. // giving you warnings if you use production apis.
  57298. function jsxWithValidationStatic(type, props, key) {
  57299. return jsxWithValidation(type, props, key, true);
  57300. }
  57301. function jsxWithValidationDynamic(type, props, key) {
  57302. return jsxWithValidation(type, props, key, false);
  57303. }
  57304. function createElementWithValidation(type, props, children) {
  57305. var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
  57306. // succeed and there will likely be errors in render.
  57307. if (!validType) {
  57308. var info = '';
  57309. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  57310. 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.";
  57311. }
  57312. var sourceInfo = getSourceInfoErrorAddendumForProps(props);
  57313. if (sourceInfo) {
  57314. info += sourceInfo;
  57315. } else {
  57316. info += getDeclarationErrorAddendum();
  57317. }
  57318. var typeString;
  57319. if (type === null) {
  57320. typeString = 'null';
  57321. } else if (Array.isArray(type)) {
  57322. typeString = 'array';
  57323. } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
  57324. typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
  57325. info = ' Did you accidentally export a JSX literal instead of a component?';
  57326. } else {
  57327. typeString = typeof type;
  57328. }
  57329. warning$1(false, '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);
  57330. }
  57331. var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
  57332. // TODO: Drop this when these are no longer allowed as the type argument.
  57333. if (element == null) {
  57334. return element;
  57335. } // Skip key warning if the type isn't valid since our key validation logic
  57336. // doesn't expect a non-string/function type and can throw confusing errors.
  57337. // We don't want exception behavior to differ between dev and prod.
  57338. // (Rendering will throw with a helpful message and as soon as the type is
  57339. // fixed, the key warnings will appear.)
  57340. if (validType) {
  57341. for (var i = 2; i < arguments.length; i++) {
  57342. validateChildKeys(arguments[i], type);
  57343. }
  57344. }
  57345. if (type === REACT_FRAGMENT_TYPE) {
  57346. validateFragmentProps(element);
  57347. } else {
  57348. validatePropTypes(element);
  57349. }
  57350. return element;
  57351. }
  57352. function createFactoryWithValidation(type) {
  57353. var validatedFactory = createElementWithValidation.bind(null, type);
  57354. validatedFactory.type = type; // Legacy hook: remove it
  57355. {
  57356. Object.defineProperty(validatedFactory, 'type', {
  57357. enumerable: false,
  57358. get: function () {
  57359. lowPriorityWarningWithoutStack$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
  57360. Object.defineProperty(this, 'type', {
  57361. value: type
  57362. });
  57363. return type;
  57364. }
  57365. });
  57366. }
  57367. return validatedFactory;
  57368. }
  57369. function cloneElementWithValidation(element, props, children) {
  57370. var newElement = cloneElement.apply(this, arguments);
  57371. for (var i = 2; i < arguments.length; i++) {
  57372. validateChildKeys(arguments[i], newElement.type);
  57373. }
  57374. validatePropTypes(newElement);
  57375. return newElement;
  57376. }
  57377. var hasBadMapPolyfill;
  57378. {
  57379. hasBadMapPolyfill = false;
  57380. try {
  57381. var frozenObject = Object.freeze({});
  57382. var testMap = new Map([[frozenObject, null]]);
  57383. var testSet = new Set([frozenObject]); // This is necessary for Rollup to not consider these unused.
  57384. // https://github.com/rollup/rollup/issues/1771
  57385. // TODO: we can remove these if Rollup fixes the bug.
  57386. testMap.set(0, 0);
  57387. testSet.add(0);
  57388. } catch (e) {
  57389. // TODO: Consider warning about bad polyfills
  57390. hasBadMapPolyfill = true;
  57391. }
  57392. }
  57393. function createFundamentalComponent(impl) {
  57394. // We use responder as a Map key later on. When we have a bad
  57395. // polyfill, then we can't use it as a key as the polyfill tries
  57396. // to add a property to the object.
  57397. if ( true && !hasBadMapPolyfill) {
  57398. Object.freeze(impl);
  57399. }
  57400. var fundamantalComponent = {
  57401. $$typeof: REACT_FUNDAMENTAL_TYPE,
  57402. impl: impl
  57403. };
  57404. {
  57405. Object.freeze(fundamantalComponent);
  57406. }
  57407. return fundamantalComponent;
  57408. }
  57409. function createEventResponder(displayName, responderConfig) {
  57410. var getInitialState = responderConfig.getInitialState,
  57411. onEvent = responderConfig.onEvent,
  57412. onMount = responderConfig.onMount,
  57413. onUnmount = responderConfig.onUnmount,
  57414. onRootEvent = responderConfig.onRootEvent,
  57415. rootEventTypes = responderConfig.rootEventTypes,
  57416. targetEventTypes = responderConfig.targetEventTypes,
  57417. targetPortalPropagation = responderConfig.targetPortalPropagation;
  57418. var eventResponder = {
  57419. $$typeof: REACT_RESPONDER_TYPE,
  57420. displayName: displayName,
  57421. getInitialState: getInitialState || null,
  57422. onEvent: onEvent || null,
  57423. onMount: onMount || null,
  57424. onRootEvent: onRootEvent || null,
  57425. onUnmount: onUnmount || null,
  57426. rootEventTypes: rootEventTypes || null,
  57427. targetEventTypes: targetEventTypes || null,
  57428. targetPortalPropagation: targetPortalPropagation || false
  57429. }; // We use responder as a Map key later on. When we have a bad
  57430. // polyfill, then we can't use it as a key as the polyfill tries
  57431. // to add a property to the object.
  57432. if ( true && !hasBadMapPolyfill) {
  57433. Object.freeze(eventResponder);
  57434. }
  57435. return eventResponder;
  57436. }
  57437. function createScope(fn) {
  57438. var scopeComponent = {
  57439. $$typeof: REACT_SCOPE_TYPE,
  57440. fn: fn
  57441. };
  57442. {
  57443. Object.freeze(scopeComponent);
  57444. }
  57445. return scopeComponent;
  57446. }
  57447. // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
  57448. // In some cases, StrictMode should also double-render lifecycles.
  57449. // This can be confusing for tests though,
  57450. // And it can be bad for performance in production.
  57451. // This feature flag can be used to control the behavior:
  57452. // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  57453. // replay the begin phase of a failed component inside invokeGuardedCallback.
  57454. // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  57455. // Gather advanced timing metrics for Profiler subtrees.
  57456. // Trace which interactions trigger each commit.
  57457. // Only used in www builds.
  57458. // TODO: true? Here it might just be false.
  57459. // Only used in www builds.
  57460. // Only used in www builds.
  57461. // Disable javascript: URL strings in href for XSS protection.
  57462. // React Fire: prevent the value and checked attributes from syncing
  57463. // with their related DOM properties
  57464. // These APIs will no longer be "unstable" in the upcoming 16.7 release,
  57465. // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
  57466. // See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
  57467. // This is a flag so we can fix warnings in RN core before turning it on
  57468. // Experimental React Flare event system and event components support.
  57469. var enableFlareAPI = false; // Experimental Host Component support.
  57470. var enableFundamentalAPI = false; // Experimental Scope support.
  57471. var enableScopeAPI = false; // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
  57472. var enableJSXTransformAPI = false; // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
  57473. // Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
  57474. // For tests, we flush suspense fallbacks in an act scope;
  57475. // *except* in some of our own tests, where we test incremental loading states.
  57476. // Changes priority of some events like mousemove to user-blocking priority,
  57477. // but without making them discrete. The flag exists in case it causes
  57478. // starvation problems.
  57479. // Add a callback property to suspense to notify which promises are currently
  57480. // in the update queue. This allows reporting and tracing of what is causing
  57481. // the user to see a loading state.
  57482. // Also allows hydration callbacks to fire when a dehydrated boundary gets
  57483. // hydrated or deleted.
  57484. // Part of the simplification of React.createElement so we can eventually move
  57485. // from React.createElement to React.jsx
  57486. // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
  57487. var React = {
  57488. Children: {
  57489. map: mapChildren,
  57490. forEach: forEachChildren,
  57491. count: countChildren,
  57492. toArray: toArray,
  57493. only: onlyChild
  57494. },
  57495. createRef: createRef,
  57496. Component: Component,
  57497. PureComponent: PureComponent,
  57498. createContext: createContext,
  57499. forwardRef: forwardRef,
  57500. lazy: lazy,
  57501. memo: memo,
  57502. useCallback: useCallback,
  57503. useContext: useContext,
  57504. useEffect: useEffect,
  57505. useImperativeHandle: useImperativeHandle,
  57506. useDebugValue: useDebugValue,
  57507. useLayoutEffect: useLayoutEffect,
  57508. useMemo: useMemo,
  57509. useReducer: useReducer,
  57510. useRef: useRef,
  57511. useState: useState,
  57512. Fragment: REACT_FRAGMENT_TYPE,
  57513. Profiler: REACT_PROFILER_TYPE,
  57514. StrictMode: REACT_STRICT_MODE_TYPE,
  57515. Suspense: REACT_SUSPENSE_TYPE,
  57516. unstable_SuspenseList: REACT_SUSPENSE_LIST_TYPE,
  57517. createElement: createElementWithValidation,
  57518. cloneElement: cloneElementWithValidation,
  57519. createFactory: createFactoryWithValidation,
  57520. isValidElement: isValidElement,
  57521. version: ReactVersion,
  57522. unstable_withSuspenseConfig: withSuspenseConfig,
  57523. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
  57524. };
  57525. if (enableFlareAPI) {
  57526. React.unstable_useResponder = useResponder;
  57527. React.unstable_createResponder = createEventResponder;
  57528. }
  57529. if (enableFundamentalAPI) {
  57530. React.unstable_createFundamental = createFundamentalComponent;
  57531. }
  57532. if (enableScopeAPI) {
  57533. React.unstable_createScope = createScope;
  57534. } // Note: some APIs are added with feature flags.
  57535. // Make sure that stable builds for open source
  57536. // don't modify the React object to avoid deopts.
  57537. // Also let's not expose their names in stable builds.
  57538. if (enableJSXTransformAPI) {
  57539. {
  57540. React.jsxDEV = jsxWithValidation;
  57541. React.jsx = jsxWithValidationDynamic;
  57542. React.jsxs = jsxWithValidationStatic;
  57543. }
  57544. }
  57545. var React$2 = Object.freeze({
  57546. default: React
  57547. });
  57548. var React$3 = ( React$2 && React ) || React$2;
  57549. // TODO: decide on the top-level export form.
  57550. // This is hacky but makes it work with both Rollup and Jest.
  57551. var react = React$3.default || React$3;
  57552. module.exports = react;
  57553. })();
  57554. }
  57555. /***/ }),
  57556. /***/ "./node_modules/react/index.js":
  57557. /*!*************************************!*\
  57558. !*** ./node_modules/react/index.js ***!
  57559. \*************************************/
  57560. /*! no static exports found */
  57561. /***/ (function(module, exports, __webpack_require__) {
  57562. "use strict";
  57563. if (false) {} else {
  57564. module.exports = __webpack_require__(/*! ./cjs/react.development.js */ "./node_modules/react/cjs/react.development.js");
  57565. }
  57566. /***/ }),
  57567. /***/ "./node_modules/scheduler/cjs/scheduler-tracing.development.js":
  57568. /*!*********************************************************************!*\
  57569. !*** ./node_modules/scheduler/cjs/scheduler-tracing.development.js ***!
  57570. \*********************************************************************/
  57571. /*! no static exports found */
  57572. /***/ (function(module, exports, __webpack_require__) {
  57573. "use strict";
  57574. /** @license React v0.16.1
  57575. * scheduler-tracing.development.js
  57576. *
  57577. * Copyright (c) Facebook, Inc. and its affiliates.
  57578. *
  57579. * This source code is licensed under the MIT license found in the
  57580. * LICENSE file in the root directory of this source tree.
  57581. */
  57582. if (true) {
  57583. (function() {
  57584. 'use strict';
  57585. Object.defineProperty(exports, '__esModule', { value: true });
  57586. // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
  57587. // In some cases, StrictMode should also double-render lifecycles.
  57588. // This can be confusing for tests though,
  57589. // And it can be bad for performance in production.
  57590. // This feature flag can be used to control the behavior:
  57591. // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  57592. // replay the begin phase of a failed component inside invokeGuardedCallback.
  57593. // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  57594. // Gather advanced timing metrics for Profiler subtrees.
  57595. // Trace which interactions trigger each commit.
  57596. var enableSchedulerTracing = true; // Only used in www builds.
  57597. // TODO: true? Here it might just be false.
  57598. // Only used in www builds.
  57599. // Only used in www builds.
  57600. // Disable javascript: URL strings in href for XSS protection.
  57601. // React Fire: prevent the value and checked attributes from syncing
  57602. // with their related DOM properties
  57603. // These APIs will no longer be "unstable" in the upcoming 16.7 release,
  57604. // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
  57605. // See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
  57606. // This is a flag so we can fix warnings in RN core before turning it on
  57607. // Experimental React Flare event system and event components support.
  57608. // Experimental Host Component support.
  57609. // Experimental Scope support.
  57610. // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
  57611. // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
  57612. // Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
  57613. // For tests, we flush suspense fallbacks in an act scope;
  57614. // *except* in some of our own tests, where we test incremental loading states.
  57615. // Changes priority of some events like mousemove to user-blocking priority,
  57616. // but without making them discrete. The flag exists in case it causes
  57617. // starvation problems.
  57618. // Add a callback property to suspense to notify which promises are currently
  57619. // in the update queue. This allows reporting and tracing of what is causing
  57620. // the user to see a loading state.
  57621. // Also allows hydration callbacks to fire when a dehydrated boundary gets
  57622. // hydrated or deleted.
  57623. // Part of the simplification of React.createElement so we can eventually move
  57624. // from React.createElement to React.jsx
  57625. // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
  57626. var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs.
  57627. var interactionIDCounter = 0;
  57628. var threadIDCounter = 0; // Set of currently traced interactions.
  57629. // Interactions "stack"–
  57630. // Meaning that newly traced interactions are appended to the previously active set.
  57631. // When an interaction goes out of scope, the previous set (if any) is restored.
  57632. exports.__interactionsRef = null; // Listener(s) to notify when interactions begin and end.
  57633. exports.__subscriberRef = null;
  57634. if (enableSchedulerTracing) {
  57635. exports.__interactionsRef = {
  57636. current: new Set()
  57637. };
  57638. exports.__subscriberRef = {
  57639. current: null
  57640. };
  57641. }
  57642. function unstable_clear(callback) {
  57643. if (!enableSchedulerTracing) {
  57644. return callback();
  57645. }
  57646. var prevInteractions = exports.__interactionsRef.current;
  57647. exports.__interactionsRef.current = new Set();
  57648. try {
  57649. return callback();
  57650. } finally {
  57651. exports.__interactionsRef.current = prevInteractions;
  57652. }
  57653. }
  57654. function unstable_getCurrent() {
  57655. if (!enableSchedulerTracing) {
  57656. return null;
  57657. } else {
  57658. return exports.__interactionsRef.current;
  57659. }
  57660. }
  57661. function unstable_getThreadID() {
  57662. return ++threadIDCounter;
  57663. }
  57664. function unstable_trace(name, timestamp, callback) {
  57665. var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
  57666. if (!enableSchedulerTracing) {
  57667. return callback();
  57668. }
  57669. var interaction = {
  57670. __count: 1,
  57671. id: interactionIDCounter++,
  57672. name: name,
  57673. timestamp: timestamp
  57674. };
  57675. var prevInteractions = exports.__interactionsRef.current; // Traced interactions should stack/accumulate.
  57676. // To do that, clone the current interactions.
  57677. // The previous set will be restored upon completion.
  57678. var interactions = new Set(prevInteractions);
  57679. interactions.add(interaction);
  57680. exports.__interactionsRef.current = interactions;
  57681. var subscriber = exports.__subscriberRef.current;
  57682. var returnValue;
  57683. try {
  57684. if (subscriber !== null) {
  57685. subscriber.onInteractionTraced(interaction);
  57686. }
  57687. } finally {
  57688. try {
  57689. if (subscriber !== null) {
  57690. subscriber.onWorkStarted(interactions, threadID);
  57691. }
  57692. } finally {
  57693. try {
  57694. returnValue = callback();
  57695. } finally {
  57696. exports.__interactionsRef.current = prevInteractions;
  57697. try {
  57698. if (subscriber !== null) {
  57699. subscriber.onWorkStopped(interactions, threadID);
  57700. }
  57701. } finally {
  57702. interaction.__count--; // If no async work was scheduled for this interaction,
  57703. // Notify subscribers that it's completed.
  57704. if (subscriber !== null && interaction.__count === 0) {
  57705. subscriber.onInteractionScheduledWorkCompleted(interaction);
  57706. }
  57707. }
  57708. }
  57709. }
  57710. }
  57711. return returnValue;
  57712. }
  57713. function unstable_wrap(callback) {
  57714. var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
  57715. if (!enableSchedulerTracing) {
  57716. return callback;
  57717. }
  57718. var wrappedInteractions = exports.__interactionsRef.current;
  57719. var subscriber = exports.__subscriberRef.current;
  57720. if (subscriber !== null) {
  57721. subscriber.onWorkScheduled(wrappedInteractions, threadID);
  57722. } // Update the pending async work count for the current interactions.
  57723. // Update after calling subscribers in case of error.
  57724. wrappedInteractions.forEach(function (interaction) {
  57725. interaction.__count++;
  57726. });
  57727. var hasRun = false;
  57728. function wrapped() {
  57729. var prevInteractions = exports.__interactionsRef.current;
  57730. exports.__interactionsRef.current = wrappedInteractions;
  57731. subscriber = exports.__subscriberRef.current;
  57732. try {
  57733. var returnValue;
  57734. try {
  57735. if (subscriber !== null) {
  57736. subscriber.onWorkStarted(wrappedInteractions, threadID);
  57737. }
  57738. } finally {
  57739. try {
  57740. returnValue = callback.apply(undefined, arguments);
  57741. } finally {
  57742. exports.__interactionsRef.current = prevInteractions;
  57743. if (subscriber !== null) {
  57744. subscriber.onWorkStopped(wrappedInteractions, threadID);
  57745. }
  57746. }
  57747. }
  57748. return returnValue;
  57749. } finally {
  57750. if (!hasRun) {
  57751. // We only expect a wrapped function to be executed once,
  57752. // But in the event that it's executed more than once–
  57753. // Only decrement the outstanding interaction counts once.
  57754. hasRun = true; // Update pending async counts for all wrapped interactions.
  57755. // If this was the last scheduled async work for any of them,
  57756. // Mark them as completed.
  57757. wrappedInteractions.forEach(function (interaction) {
  57758. interaction.__count--;
  57759. if (subscriber !== null && interaction.__count === 0) {
  57760. subscriber.onInteractionScheduledWorkCompleted(interaction);
  57761. }
  57762. });
  57763. }
  57764. }
  57765. }
  57766. wrapped.cancel = function cancel() {
  57767. subscriber = exports.__subscriberRef.current;
  57768. try {
  57769. if (subscriber !== null) {
  57770. subscriber.onWorkCanceled(wrappedInteractions, threadID);
  57771. }
  57772. } finally {
  57773. // Update pending async counts for all wrapped interactions.
  57774. // If this was the last scheduled async work for any of them,
  57775. // Mark them as completed.
  57776. wrappedInteractions.forEach(function (interaction) {
  57777. interaction.__count--;
  57778. if (subscriber && interaction.__count === 0) {
  57779. subscriber.onInteractionScheduledWorkCompleted(interaction);
  57780. }
  57781. });
  57782. }
  57783. };
  57784. return wrapped;
  57785. }
  57786. var subscribers = null;
  57787. if (enableSchedulerTracing) {
  57788. subscribers = new Set();
  57789. }
  57790. function unstable_subscribe(subscriber) {
  57791. if (enableSchedulerTracing) {
  57792. subscribers.add(subscriber);
  57793. if (subscribers.size === 1) {
  57794. exports.__subscriberRef.current = {
  57795. onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
  57796. onInteractionTraced: onInteractionTraced,
  57797. onWorkCanceled: onWorkCanceled,
  57798. onWorkScheduled: onWorkScheduled,
  57799. onWorkStarted: onWorkStarted,
  57800. onWorkStopped: onWorkStopped
  57801. };
  57802. }
  57803. }
  57804. }
  57805. function unstable_unsubscribe(subscriber) {
  57806. if (enableSchedulerTracing) {
  57807. subscribers.delete(subscriber);
  57808. if (subscribers.size === 0) {
  57809. exports.__subscriberRef.current = null;
  57810. }
  57811. }
  57812. }
  57813. function onInteractionTraced(interaction) {
  57814. var didCatchError = false;
  57815. var caughtError = null;
  57816. subscribers.forEach(function (subscriber) {
  57817. try {
  57818. subscriber.onInteractionTraced(interaction);
  57819. } catch (error) {
  57820. if (!didCatchError) {
  57821. didCatchError = true;
  57822. caughtError = error;
  57823. }
  57824. }
  57825. });
  57826. if (didCatchError) {
  57827. throw caughtError;
  57828. }
  57829. }
  57830. function onInteractionScheduledWorkCompleted(interaction) {
  57831. var didCatchError = false;
  57832. var caughtError = null;
  57833. subscribers.forEach(function (subscriber) {
  57834. try {
  57835. subscriber.onInteractionScheduledWorkCompleted(interaction);
  57836. } catch (error) {
  57837. if (!didCatchError) {
  57838. didCatchError = true;
  57839. caughtError = error;
  57840. }
  57841. }
  57842. });
  57843. if (didCatchError) {
  57844. throw caughtError;
  57845. }
  57846. }
  57847. function onWorkScheduled(interactions, threadID) {
  57848. var didCatchError = false;
  57849. var caughtError = null;
  57850. subscribers.forEach(function (subscriber) {
  57851. try {
  57852. subscriber.onWorkScheduled(interactions, threadID);
  57853. } catch (error) {
  57854. if (!didCatchError) {
  57855. didCatchError = true;
  57856. caughtError = error;
  57857. }
  57858. }
  57859. });
  57860. if (didCatchError) {
  57861. throw caughtError;
  57862. }
  57863. }
  57864. function onWorkStarted(interactions, threadID) {
  57865. var didCatchError = false;
  57866. var caughtError = null;
  57867. subscribers.forEach(function (subscriber) {
  57868. try {
  57869. subscriber.onWorkStarted(interactions, threadID);
  57870. } catch (error) {
  57871. if (!didCatchError) {
  57872. didCatchError = true;
  57873. caughtError = error;
  57874. }
  57875. }
  57876. });
  57877. if (didCatchError) {
  57878. throw caughtError;
  57879. }
  57880. }
  57881. function onWorkStopped(interactions, threadID) {
  57882. var didCatchError = false;
  57883. var caughtError = null;
  57884. subscribers.forEach(function (subscriber) {
  57885. try {
  57886. subscriber.onWorkStopped(interactions, threadID);
  57887. } catch (error) {
  57888. if (!didCatchError) {
  57889. didCatchError = true;
  57890. caughtError = error;
  57891. }
  57892. }
  57893. });
  57894. if (didCatchError) {
  57895. throw caughtError;
  57896. }
  57897. }
  57898. function onWorkCanceled(interactions, threadID) {
  57899. var didCatchError = false;
  57900. var caughtError = null;
  57901. subscribers.forEach(function (subscriber) {
  57902. try {
  57903. subscriber.onWorkCanceled(interactions, threadID);
  57904. } catch (error) {
  57905. if (!didCatchError) {
  57906. didCatchError = true;
  57907. caughtError = error;
  57908. }
  57909. }
  57910. });
  57911. if (didCatchError) {
  57912. throw caughtError;
  57913. }
  57914. }
  57915. exports.unstable_clear = unstable_clear;
  57916. exports.unstable_getCurrent = unstable_getCurrent;
  57917. exports.unstable_getThreadID = unstable_getThreadID;
  57918. exports.unstable_trace = unstable_trace;
  57919. exports.unstable_wrap = unstable_wrap;
  57920. exports.unstable_subscribe = unstable_subscribe;
  57921. exports.unstable_unsubscribe = unstable_unsubscribe;
  57922. })();
  57923. }
  57924. /***/ }),
  57925. /***/ "./node_modules/scheduler/cjs/scheduler.development.js":
  57926. /*!*************************************************************!*\
  57927. !*** ./node_modules/scheduler/cjs/scheduler.development.js ***!
  57928. \*************************************************************/
  57929. /*! no static exports found */
  57930. /***/ (function(module, exports, __webpack_require__) {
  57931. "use strict";
  57932. /** @license React v0.16.1
  57933. * scheduler.development.js
  57934. *
  57935. * Copyright (c) Facebook, Inc. and its affiliates.
  57936. *
  57937. * This source code is licensed under the MIT license found in the
  57938. * LICENSE file in the root directory of this source tree.
  57939. */
  57940. if (true) {
  57941. (function() {
  57942. 'use strict';
  57943. Object.defineProperty(exports, '__esModule', { value: true });
  57944. var enableSchedulerDebugging = false;
  57945. var enableIsInputPending = false;
  57946. var enableMessageLoopImplementation = true;
  57947. var enableProfiling = true;
  57948. // works by scheduling a requestAnimationFrame, storing the time for the start
  57949. // of the frame, then scheduling a postMessage which gets scheduled after paint.
  57950. // Within the postMessage handler do as much work as possible until time + frame
  57951. // rate. By separating the idle call into a separate event tick we ensure that
  57952. // layout, paint and other browser work is counted against the available time.
  57953. // The frame rate is dynamically adjusted.
  57954. var requestHostCallback;
  57955. var requestHostTimeout;
  57956. var cancelHostTimeout;
  57957. var shouldYieldToHost;
  57958. var requestPaint;
  57959. if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive
  57960. // implementation using setTimeout.
  57961. typeof window === 'undefined' || // Check if MessageChannel is supported, too.
  57962. typeof MessageChannel !== 'function') {
  57963. // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
  57964. // fallback to a naive implementation.
  57965. var _callback = null;
  57966. var _timeoutID = null;
  57967. var _flushCallback = function () {
  57968. if (_callback !== null) {
  57969. try {
  57970. var currentTime = exports.unstable_now();
  57971. var hasRemainingTime = true;
  57972. _callback(hasRemainingTime, currentTime);
  57973. _callback = null;
  57974. } catch (e) {
  57975. setTimeout(_flushCallback, 0);
  57976. throw e;
  57977. }
  57978. }
  57979. };
  57980. var initialTime = Date.now();
  57981. exports.unstable_now = function () {
  57982. return Date.now() - initialTime;
  57983. };
  57984. requestHostCallback = function (cb) {
  57985. if (_callback !== null) {
  57986. // Protect against re-entrancy.
  57987. setTimeout(requestHostCallback, 0, cb);
  57988. } else {
  57989. _callback = cb;
  57990. setTimeout(_flushCallback, 0);
  57991. }
  57992. };
  57993. requestHostTimeout = function (cb, ms) {
  57994. _timeoutID = setTimeout(cb, ms);
  57995. };
  57996. cancelHostTimeout = function () {
  57997. clearTimeout(_timeoutID);
  57998. };
  57999. shouldYieldToHost = function () {
  58000. return false;
  58001. };
  58002. requestPaint = exports.unstable_forceFrameRate = function () {};
  58003. } else {
  58004. // Capture local references to native APIs, in case a polyfill overrides them.
  58005. var performance = window.performance;
  58006. var _Date = window.Date;
  58007. var _setTimeout = window.setTimeout;
  58008. var _clearTimeout = window.clearTimeout;
  58009. var requestAnimationFrame = window.requestAnimationFrame;
  58010. var cancelAnimationFrame = window.cancelAnimationFrame;
  58011. if (typeof console !== 'undefined') {
  58012. // TODO: Remove fb.me link
  58013. if (typeof requestAnimationFrame !== 'function') {
  58014. console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  58015. }
  58016. if (typeof cancelAnimationFrame !== 'function') {
  58017. console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  58018. }
  58019. }
  58020. if (typeof performance === 'object' && typeof performance.now === 'function') {
  58021. exports.unstable_now = function () {
  58022. return performance.now();
  58023. };
  58024. } else {
  58025. var _initialTime = _Date.now();
  58026. exports.unstable_now = function () {
  58027. return _Date.now() - _initialTime;
  58028. };
  58029. }
  58030. var isRAFLoopRunning = false;
  58031. var isMessageLoopRunning = false;
  58032. var scheduledHostCallback = null;
  58033. var rAFTimeoutID = -1;
  58034. var taskTimeoutID = -1;
  58035. var frameLength = enableMessageLoopImplementation ? // We won't attempt to align with the vsync. Instead we'll yield multiple
  58036. // times per frame, often enough to keep it responsive even at really
  58037. // high frame rates > 120.
  58038. 5 : // Use a heuristic to measure the frame rate and yield at the end of the
  58039. // frame. We start out assuming that we run at 30fps but then the
  58040. // heuristic tracking will adjust this value to a faster fps if we get
  58041. // more frequent animation frames.
  58042. 33.33;
  58043. var prevRAFTime = -1;
  58044. var prevRAFInterval = -1;
  58045. var frameDeadline = 0;
  58046. var fpsLocked = false; // TODO: Make this configurable
  58047. // TODO: Adjust this based on priority?
  58048. var maxFrameLength = 300;
  58049. var needsPaint = false;
  58050. if (enableIsInputPending && navigator !== undefined && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined) {
  58051. var scheduling = navigator.scheduling;
  58052. shouldYieldToHost = function () {
  58053. var currentTime = exports.unstable_now();
  58054. if (currentTime >= frameDeadline) {
  58055. // There's no time left in the frame. We may want to yield control of
  58056. // the main thread, so the browser can perform high priority tasks. The
  58057. // main ones are painting and user input. If there's a pending paint or
  58058. // a pending input, then we should yield. But if there's neither, then
  58059. // we can yield less often while remaining responsive. We'll eventually
  58060. // yield regardless, since there could be a pending paint that wasn't
  58061. // accompanied by a call to `requestPaint`, or other main thread tasks
  58062. // like network events.
  58063. if (needsPaint || scheduling.isInputPending()) {
  58064. // There is either a pending paint or a pending input.
  58065. return true;
  58066. } // There's no pending input. Only yield if we've reached the max
  58067. // frame length.
  58068. return currentTime >= frameDeadline + maxFrameLength;
  58069. } else {
  58070. // There's still time left in the frame.
  58071. return false;
  58072. }
  58073. };
  58074. requestPaint = function () {
  58075. needsPaint = true;
  58076. };
  58077. } else {
  58078. // `isInputPending` is not available. Since we have no way of knowing if
  58079. // there's pending input, always yield at the end of the frame.
  58080. shouldYieldToHost = function () {
  58081. return exports.unstable_now() >= frameDeadline;
  58082. }; // Since we yield every frame regardless, `requestPaint` has no effect.
  58083. requestPaint = function () {};
  58084. }
  58085. exports.unstable_forceFrameRate = function (fps) {
  58086. if (fps < 0 || fps > 125) {
  58087. console.error('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing framerates higher than 125 fps is not unsupported');
  58088. return;
  58089. }
  58090. if (fps > 0) {
  58091. frameLength = Math.floor(1000 / fps);
  58092. fpsLocked = true;
  58093. } else {
  58094. // reset the framerate
  58095. frameLength = 33.33;
  58096. fpsLocked = false;
  58097. }
  58098. };
  58099. var performWorkUntilDeadline = function () {
  58100. if (enableMessageLoopImplementation) {
  58101. if (scheduledHostCallback !== null) {
  58102. var currentTime = exports.unstable_now(); // Yield after `frameLength` ms, regardless of where we are in the vsync
  58103. // cycle. This means there's always time remaining at the beginning of
  58104. // the message event.
  58105. frameDeadline = currentTime + frameLength;
  58106. var hasTimeRemaining = true;
  58107. try {
  58108. var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
  58109. if (!hasMoreWork) {
  58110. isMessageLoopRunning = false;
  58111. scheduledHostCallback = null;
  58112. } else {
  58113. // If there's more work, schedule the next message event at the end
  58114. // of the preceding one.
  58115. port.postMessage(null);
  58116. }
  58117. } catch (error) {
  58118. // If a scheduler task throws, exit the current browser task so the
  58119. // error can be observed.
  58120. port.postMessage(null);
  58121. throw error;
  58122. }
  58123. } else {
  58124. isMessageLoopRunning = false;
  58125. } // Yielding to the browser will give it a chance to paint, so we can
  58126. // reset this.
  58127. needsPaint = false;
  58128. } else {
  58129. if (scheduledHostCallback !== null) {
  58130. var _currentTime = exports.unstable_now();
  58131. var _hasTimeRemaining = frameDeadline - _currentTime > 0;
  58132. try {
  58133. var _hasMoreWork = scheduledHostCallback(_hasTimeRemaining, _currentTime);
  58134. if (!_hasMoreWork) {
  58135. scheduledHostCallback = null;
  58136. }
  58137. } catch (error) {
  58138. // If a scheduler task throws, exit the current browser task so the
  58139. // error can be observed, and post a new task as soon as possible
  58140. // so we can continue where we left off.
  58141. port.postMessage(null);
  58142. throw error;
  58143. }
  58144. } // Yielding to the browser will give it a chance to paint, so we can
  58145. // reset this.
  58146. needsPaint = false;
  58147. }
  58148. };
  58149. var channel = new MessageChannel();
  58150. var port = channel.port2;
  58151. channel.port1.onmessage = performWorkUntilDeadline;
  58152. var onAnimationFrame = function (rAFTime) {
  58153. if (scheduledHostCallback === null) {
  58154. // No scheduled work. Exit.
  58155. prevRAFTime = -1;
  58156. prevRAFInterval = -1;
  58157. isRAFLoopRunning = false;
  58158. return;
  58159. } // Eagerly schedule the next animation callback at the beginning of the
  58160. // frame. If the scheduler queue is not empty at the end of the frame, it
  58161. // will continue flushing inside that callback. If the queue *is* empty,
  58162. // then it will exit immediately. Posting the callback at the start of the
  58163. // frame ensures it's fired within the earliest possible frame. If we
  58164. // waited until the end of the frame to post the callback, we risk the
  58165. // browser skipping a frame and not firing the callback until the frame
  58166. // after that.
  58167. isRAFLoopRunning = true;
  58168. requestAnimationFrame(function (nextRAFTime) {
  58169. _clearTimeout(rAFTimeoutID);
  58170. onAnimationFrame(nextRAFTime);
  58171. }); // requestAnimationFrame is throttled when the tab is backgrounded. We
  58172. // don't want to stop working entirely. So we'll fallback to a timeout loop.
  58173. // TODO: Need a better heuristic for backgrounded work.
  58174. var onTimeout = function () {
  58175. frameDeadline = exports.unstable_now() + frameLength / 2;
  58176. performWorkUntilDeadline();
  58177. rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3);
  58178. };
  58179. rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3);
  58180. if (prevRAFTime !== -1 && // Make sure this rAF time is different from the previous one. This check
  58181. // could fail if two rAFs fire in the same frame.
  58182. rAFTime - prevRAFTime > 0.1) {
  58183. var rAFInterval = rAFTime - prevRAFTime;
  58184. if (!fpsLocked && prevRAFInterval !== -1) {
  58185. // We've observed two consecutive frame intervals. We'll use this to
  58186. // dynamically adjust the frame rate.
  58187. //
  58188. // If one frame goes long, then the next one can be short to catch up.
  58189. // If two frames are short in a row, then that's an indication that we
  58190. // actually have a higher frame rate than what we're currently
  58191. // optimizing. For example, if we're running on 120hz display or 90hz VR
  58192. // display. Take the max of the two in case one of them was an anomaly
  58193. // due to missed frame deadlines.
  58194. if (rAFInterval < frameLength && prevRAFInterval < frameLength) {
  58195. frameLength = rAFInterval < prevRAFInterval ? prevRAFInterval : rAFInterval;
  58196. if (frameLength < 8.33) {
  58197. // Defensive coding. We don't support higher frame rates than 120hz.
  58198. // If the calculated frame length gets lower than 8, it is probably
  58199. // a bug.
  58200. frameLength = 8.33;
  58201. }
  58202. }
  58203. }
  58204. prevRAFInterval = rAFInterval;
  58205. }
  58206. prevRAFTime = rAFTime;
  58207. frameDeadline = rAFTime + frameLength; // We use the postMessage trick to defer idle work until after the repaint.
  58208. port.postMessage(null);
  58209. };
  58210. requestHostCallback = function (callback) {
  58211. scheduledHostCallback = callback;
  58212. if (enableMessageLoopImplementation) {
  58213. if (!isMessageLoopRunning) {
  58214. isMessageLoopRunning = true;
  58215. port.postMessage(null);
  58216. }
  58217. } else {
  58218. if (!isRAFLoopRunning) {
  58219. // Start a rAF loop.
  58220. isRAFLoopRunning = true;
  58221. requestAnimationFrame(function (rAFTime) {
  58222. onAnimationFrame(rAFTime);
  58223. });
  58224. }
  58225. }
  58226. };
  58227. requestHostTimeout = function (callback, ms) {
  58228. taskTimeoutID = _setTimeout(function () {
  58229. callback(exports.unstable_now());
  58230. }, ms);
  58231. };
  58232. cancelHostTimeout = function () {
  58233. _clearTimeout(taskTimeoutID);
  58234. taskTimeoutID = -1;
  58235. };
  58236. }
  58237. function push(heap, node) {
  58238. var index = heap.length;
  58239. heap.push(node);
  58240. siftUp(heap, node, index);
  58241. }
  58242. function peek(heap) {
  58243. var first = heap[0];
  58244. return first === undefined ? null : first;
  58245. }
  58246. function pop(heap) {
  58247. var first = heap[0];
  58248. if (first !== undefined) {
  58249. var last = heap.pop();
  58250. if (last !== first) {
  58251. heap[0] = last;
  58252. siftDown(heap, last, 0);
  58253. }
  58254. return first;
  58255. } else {
  58256. return null;
  58257. }
  58258. }
  58259. function siftUp(heap, node, i) {
  58260. var index = i;
  58261. while (true) {
  58262. var parentIndex = Math.floor((index - 1) / 2);
  58263. var parent = heap[parentIndex];
  58264. if (parent !== undefined && compare(parent, node) > 0) {
  58265. // The parent is larger. Swap positions.
  58266. heap[parentIndex] = node;
  58267. heap[index] = parent;
  58268. index = parentIndex;
  58269. } else {
  58270. // The parent is smaller. Exit.
  58271. return;
  58272. }
  58273. }
  58274. }
  58275. function siftDown(heap, node, i) {
  58276. var index = i;
  58277. var length = heap.length;
  58278. while (index < length) {
  58279. var leftIndex = (index + 1) * 2 - 1;
  58280. var left = heap[leftIndex];
  58281. var rightIndex = leftIndex + 1;
  58282. var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
  58283. if (left !== undefined && compare(left, node) < 0) {
  58284. if (right !== undefined && compare(right, left) < 0) {
  58285. heap[index] = right;
  58286. heap[rightIndex] = node;
  58287. index = rightIndex;
  58288. } else {
  58289. heap[index] = left;
  58290. heap[leftIndex] = node;
  58291. index = leftIndex;
  58292. }
  58293. } else if (right !== undefined && compare(right, node) < 0) {
  58294. heap[index] = right;
  58295. heap[rightIndex] = node;
  58296. index = rightIndex;
  58297. } else {
  58298. // Neither child is smaller. Exit.
  58299. return;
  58300. }
  58301. }
  58302. }
  58303. function compare(a, b) {
  58304. // Compare sort index first, then task id.
  58305. var diff = a.sortIndex - b.sortIndex;
  58306. return diff !== 0 ? diff : a.id - b.id;
  58307. }
  58308. // TODO: Use symbols?
  58309. var NoPriority = 0;
  58310. var ImmediatePriority = 1;
  58311. var UserBlockingPriority = 2;
  58312. var NormalPriority = 3;
  58313. var LowPriority = 4;
  58314. var IdlePriority = 5;
  58315. var runIdCounter = 0;
  58316. var mainThreadIdCounter = 0;
  58317. var profilingStateSize = 4;
  58318. var sharedProfilingBuffer = enableProfiling ? // $FlowFixMe Flow doesn't know about SharedArrayBuffer
  58319. typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
  58320. typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
  58321. : null;
  58322. var profilingState = enableProfiling && sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
  58323. var PRIORITY = 0;
  58324. var CURRENT_TASK_ID = 1;
  58325. var CURRENT_RUN_ID = 2;
  58326. var QUEUE_SIZE = 3;
  58327. if (enableProfiling) {
  58328. profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
  58329. // array might include canceled tasks.
  58330. profilingState[QUEUE_SIZE] = 0;
  58331. profilingState[CURRENT_TASK_ID] = 0;
  58332. } // Bytes per element is 4
  58333. var INITIAL_EVENT_LOG_SIZE = 131072;
  58334. var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
  58335. var eventLogSize = 0;
  58336. var eventLogBuffer = null;
  58337. var eventLog = null;
  58338. var eventLogIndex = 0;
  58339. var TaskStartEvent = 1;
  58340. var TaskCompleteEvent = 2;
  58341. var TaskErrorEvent = 3;
  58342. var TaskCancelEvent = 4;
  58343. var TaskRunEvent = 5;
  58344. var TaskYieldEvent = 6;
  58345. var SchedulerSuspendEvent = 7;
  58346. var SchedulerResumeEvent = 8;
  58347. function logEvent(entries) {
  58348. if (eventLog !== null) {
  58349. var offset = eventLogIndex;
  58350. eventLogIndex += entries.length;
  58351. if (eventLogIndex + 1 > eventLogSize) {
  58352. eventLogSize *= 2;
  58353. if (eventLogSize > MAX_EVENT_LOG_SIZE) {
  58354. console.error("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
  58355. stopLoggingProfilingEvents();
  58356. return;
  58357. }
  58358. var newEventLog = new Int32Array(eventLogSize * 4);
  58359. newEventLog.set(eventLog);
  58360. eventLogBuffer = newEventLog.buffer;
  58361. eventLog = newEventLog;
  58362. }
  58363. eventLog.set(entries, offset);
  58364. }
  58365. }
  58366. function startLoggingProfilingEvents() {
  58367. eventLogSize = INITIAL_EVENT_LOG_SIZE;
  58368. eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
  58369. eventLog = new Int32Array(eventLogBuffer);
  58370. eventLogIndex = 0;
  58371. }
  58372. function stopLoggingProfilingEvents() {
  58373. var buffer = eventLogBuffer;
  58374. eventLogSize = 0;
  58375. eventLogBuffer = null;
  58376. eventLog = null;
  58377. eventLogIndex = 0;
  58378. return buffer;
  58379. }
  58380. function markTaskStart(task, time) {
  58381. if (enableProfiling) {
  58382. profilingState[QUEUE_SIZE]++;
  58383. if (eventLog !== null) {
  58384. logEvent([TaskStartEvent, time, task.id, task.priorityLevel]);
  58385. }
  58386. }
  58387. }
  58388. function markTaskCompleted(task, time) {
  58389. if (enableProfiling) {
  58390. profilingState[PRIORITY] = NoPriority;
  58391. profilingState[CURRENT_TASK_ID] = 0;
  58392. profilingState[QUEUE_SIZE]--;
  58393. if (eventLog !== null) {
  58394. logEvent([TaskCompleteEvent, time, task.id]);
  58395. }
  58396. }
  58397. }
  58398. function markTaskCanceled(task, time) {
  58399. if (enableProfiling) {
  58400. profilingState[QUEUE_SIZE]--;
  58401. if (eventLog !== null) {
  58402. logEvent([TaskCancelEvent, time, task.id]);
  58403. }
  58404. }
  58405. }
  58406. function markTaskErrored(task, time) {
  58407. if (enableProfiling) {
  58408. profilingState[PRIORITY] = NoPriority;
  58409. profilingState[CURRENT_TASK_ID] = 0;
  58410. profilingState[QUEUE_SIZE]--;
  58411. if (eventLog !== null) {
  58412. logEvent([TaskErrorEvent, time, task.id]);
  58413. }
  58414. }
  58415. }
  58416. function markTaskRun(task, time) {
  58417. if (enableProfiling) {
  58418. runIdCounter++;
  58419. profilingState[PRIORITY] = task.priorityLevel;
  58420. profilingState[CURRENT_TASK_ID] = task.id;
  58421. profilingState[CURRENT_RUN_ID] = runIdCounter;
  58422. if (eventLog !== null) {
  58423. logEvent([TaskRunEvent, time, task.id, runIdCounter]);
  58424. }
  58425. }
  58426. }
  58427. function markTaskYield(task, time) {
  58428. if (enableProfiling) {
  58429. profilingState[PRIORITY] = NoPriority;
  58430. profilingState[CURRENT_TASK_ID] = 0;
  58431. profilingState[CURRENT_RUN_ID] = 0;
  58432. if (eventLog !== null) {
  58433. logEvent([TaskYieldEvent, time, task.id, runIdCounter]);
  58434. }
  58435. }
  58436. }
  58437. function markSchedulerSuspended(time) {
  58438. if (enableProfiling) {
  58439. mainThreadIdCounter++;
  58440. if (eventLog !== null) {
  58441. logEvent([SchedulerSuspendEvent, time, mainThreadIdCounter]);
  58442. }
  58443. }
  58444. }
  58445. function markSchedulerUnsuspended(time) {
  58446. if (enableProfiling) {
  58447. if (eventLog !== null) {
  58448. logEvent([SchedulerResumeEvent, time, mainThreadIdCounter]);
  58449. }
  58450. }
  58451. }
  58452. /* eslint-disable no-var */
  58453. // Math.pow(2, 30) - 1
  58454. // 0b111111111111111111111111111111
  58455. var maxSigned31BitInt = 1073741823; // Times out immediately
  58456. var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out
  58457. var USER_BLOCKING_PRIORITY = 250;
  58458. var NORMAL_PRIORITY_TIMEOUT = 5000;
  58459. var LOW_PRIORITY_TIMEOUT = 10000; // Never times out
  58460. var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap
  58461. var taskQueue = [];
  58462. var timerQueue = []; // Incrementing id counter. Used to maintain insertion order.
  58463. var taskIdCounter = 1; // Pausing the scheduler is useful for debugging.
  58464. var isSchedulerPaused = false;
  58465. var currentTask = null;
  58466. var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy.
  58467. var isPerformingWork = false;
  58468. var isHostCallbackScheduled = false;
  58469. var isHostTimeoutScheduled = false;
  58470. function advanceTimers(currentTime) {
  58471. // Check for tasks that are no longer delayed and add them to the queue.
  58472. var timer = peek(timerQueue);
  58473. while (timer !== null) {
  58474. if (timer.callback === null) {
  58475. // Timer was cancelled.
  58476. pop(timerQueue);
  58477. } else if (timer.startTime <= currentTime) {
  58478. // Timer fired. Transfer to the task queue.
  58479. pop(timerQueue);
  58480. timer.sortIndex = timer.expirationTime;
  58481. push(taskQueue, timer);
  58482. if (enableProfiling) {
  58483. markTaskStart(timer, currentTime);
  58484. timer.isQueued = true;
  58485. }
  58486. } else {
  58487. // Remaining timers are pending.
  58488. return;
  58489. }
  58490. timer = peek(timerQueue);
  58491. }
  58492. }
  58493. function handleTimeout(currentTime) {
  58494. isHostTimeoutScheduled = false;
  58495. advanceTimers(currentTime);
  58496. if (!isHostCallbackScheduled) {
  58497. if (peek(taskQueue) !== null) {
  58498. isHostCallbackScheduled = true;
  58499. requestHostCallback(flushWork);
  58500. } else {
  58501. var firstTimer = peek(timerQueue);
  58502. if (firstTimer !== null) {
  58503. requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
  58504. }
  58505. }
  58506. }
  58507. }
  58508. function flushWork(hasTimeRemaining, initialTime) {
  58509. if (enableProfiling) {
  58510. markSchedulerUnsuspended(initialTime);
  58511. } // We'll need a host callback the next time work is scheduled.
  58512. isHostCallbackScheduled = false;
  58513. if (isHostTimeoutScheduled) {
  58514. // We scheduled a timeout but it's no longer needed. Cancel it.
  58515. isHostTimeoutScheduled = false;
  58516. cancelHostTimeout();
  58517. }
  58518. isPerformingWork = true;
  58519. var previousPriorityLevel = currentPriorityLevel;
  58520. try {
  58521. if (enableProfiling) {
  58522. try {
  58523. return workLoop(hasTimeRemaining, initialTime);
  58524. } catch (error) {
  58525. if (currentTask !== null) {
  58526. var currentTime = exports.unstable_now();
  58527. markTaskErrored(currentTask, currentTime);
  58528. currentTask.isQueued = false;
  58529. }
  58530. throw error;
  58531. }
  58532. } else {
  58533. // No catch in prod codepath.
  58534. return workLoop(hasTimeRemaining, initialTime);
  58535. }
  58536. } finally {
  58537. currentTask = null;
  58538. currentPriorityLevel = previousPriorityLevel;
  58539. isPerformingWork = false;
  58540. if (enableProfiling) {
  58541. var _currentTime = exports.unstable_now();
  58542. markSchedulerSuspended(_currentTime);
  58543. }
  58544. }
  58545. }
  58546. function workLoop(hasTimeRemaining, initialTime) {
  58547. var currentTime = initialTime;
  58548. advanceTimers(currentTime);
  58549. currentTask = peek(taskQueue);
  58550. while (currentTask !== null && !(enableSchedulerDebugging && isSchedulerPaused)) {
  58551. if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {
  58552. // This currentTask hasn't expired, and we've reached the deadline.
  58553. break;
  58554. }
  58555. var callback = currentTask.callback;
  58556. if (callback !== null) {
  58557. currentTask.callback = null;
  58558. currentPriorityLevel = currentTask.priorityLevel;
  58559. var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
  58560. markTaskRun(currentTask, currentTime);
  58561. var continuationCallback = callback(didUserCallbackTimeout);
  58562. currentTime = exports.unstable_now();
  58563. if (typeof continuationCallback === 'function') {
  58564. currentTask.callback = continuationCallback;
  58565. markTaskYield(currentTask, currentTime);
  58566. } else {
  58567. if (enableProfiling) {
  58568. markTaskCompleted(currentTask, currentTime);
  58569. currentTask.isQueued = false;
  58570. }
  58571. if (currentTask === peek(taskQueue)) {
  58572. pop(taskQueue);
  58573. }
  58574. }
  58575. advanceTimers(currentTime);
  58576. } else {
  58577. pop(taskQueue);
  58578. }
  58579. currentTask = peek(taskQueue);
  58580. } // Return whether there's additional work
  58581. if (currentTask !== null) {
  58582. return true;
  58583. } else {
  58584. var firstTimer = peek(timerQueue);
  58585. if (firstTimer !== null) {
  58586. requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
  58587. }
  58588. return false;
  58589. }
  58590. }
  58591. function unstable_runWithPriority(priorityLevel, eventHandler) {
  58592. switch (priorityLevel) {
  58593. case ImmediatePriority:
  58594. case UserBlockingPriority:
  58595. case NormalPriority:
  58596. case LowPriority:
  58597. case IdlePriority:
  58598. break;
  58599. default:
  58600. priorityLevel = NormalPriority;
  58601. }
  58602. var previousPriorityLevel = currentPriorityLevel;
  58603. currentPriorityLevel = priorityLevel;
  58604. try {
  58605. return eventHandler();
  58606. } finally {
  58607. currentPriorityLevel = previousPriorityLevel;
  58608. }
  58609. }
  58610. function unstable_next(eventHandler) {
  58611. var priorityLevel;
  58612. switch (currentPriorityLevel) {
  58613. case ImmediatePriority:
  58614. case UserBlockingPriority:
  58615. case NormalPriority:
  58616. // Shift down to normal priority
  58617. priorityLevel = NormalPriority;
  58618. break;
  58619. default:
  58620. // Anything lower than normal priority should remain at the current level.
  58621. priorityLevel = currentPriorityLevel;
  58622. break;
  58623. }
  58624. var previousPriorityLevel = currentPriorityLevel;
  58625. currentPriorityLevel = priorityLevel;
  58626. try {
  58627. return eventHandler();
  58628. } finally {
  58629. currentPriorityLevel = previousPriorityLevel;
  58630. }
  58631. }
  58632. function unstable_wrapCallback(callback) {
  58633. var parentPriorityLevel = currentPriorityLevel;
  58634. return function () {
  58635. // This is a fork of runWithPriority, inlined for performance.
  58636. var previousPriorityLevel = currentPriorityLevel;
  58637. currentPriorityLevel = parentPriorityLevel;
  58638. try {
  58639. return callback.apply(this, arguments);
  58640. } finally {
  58641. currentPriorityLevel = previousPriorityLevel;
  58642. }
  58643. };
  58644. }
  58645. function timeoutForPriorityLevel(priorityLevel) {
  58646. switch (priorityLevel) {
  58647. case ImmediatePriority:
  58648. return IMMEDIATE_PRIORITY_TIMEOUT;
  58649. case UserBlockingPriority:
  58650. return USER_BLOCKING_PRIORITY;
  58651. case IdlePriority:
  58652. return IDLE_PRIORITY;
  58653. case LowPriority:
  58654. return LOW_PRIORITY_TIMEOUT;
  58655. case NormalPriority:
  58656. default:
  58657. return NORMAL_PRIORITY_TIMEOUT;
  58658. }
  58659. }
  58660. function unstable_scheduleCallback(priorityLevel, callback, options) {
  58661. var currentTime = exports.unstable_now();
  58662. var startTime;
  58663. var timeout;
  58664. if (typeof options === 'object' && options !== null) {
  58665. var delay = options.delay;
  58666. if (typeof delay === 'number' && delay > 0) {
  58667. startTime = currentTime + delay;
  58668. } else {
  58669. startTime = currentTime;
  58670. }
  58671. timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel);
  58672. } else {
  58673. timeout = timeoutForPriorityLevel(priorityLevel);
  58674. startTime = currentTime;
  58675. }
  58676. var expirationTime = startTime + timeout;
  58677. var newTask = {
  58678. id: taskIdCounter++,
  58679. callback: callback,
  58680. priorityLevel: priorityLevel,
  58681. startTime: startTime,
  58682. expirationTime: expirationTime,
  58683. sortIndex: -1
  58684. };
  58685. if (enableProfiling) {
  58686. newTask.isQueued = false;
  58687. }
  58688. if (startTime > currentTime) {
  58689. // This is a delayed task.
  58690. newTask.sortIndex = startTime;
  58691. push(timerQueue, newTask);
  58692. if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
  58693. // All tasks are delayed, and this is the task with the earliest delay.
  58694. if (isHostTimeoutScheduled) {
  58695. // Cancel an existing timeout.
  58696. cancelHostTimeout();
  58697. } else {
  58698. isHostTimeoutScheduled = true;
  58699. } // Schedule a timeout.
  58700. requestHostTimeout(handleTimeout, startTime - currentTime);
  58701. }
  58702. } else {
  58703. newTask.sortIndex = expirationTime;
  58704. push(taskQueue, newTask);
  58705. if (enableProfiling) {
  58706. markTaskStart(newTask, currentTime);
  58707. newTask.isQueued = true;
  58708. } // Schedule a host callback, if needed. If we're already performing work,
  58709. // wait until the next time we yield.
  58710. if (!isHostCallbackScheduled && !isPerformingWork) {
  58711. isHostCallbackScheduled = true;
  58712. requestHostCallback(flushWork);
  58713. }
  58714. }
  58715. return newTask;
  58716. }
  58717. function unstable_pauseExecution() {
  58718. isSchedulerPaused = true;
  58719. }
  58720. function unstable_continueExecution() {
  58721. isSchedulerPaused = false;
  58722. if (!isHostCallbackScheduled && !isPerformingWork) {
  58723. isHostCallbackScheduled = true;
  58724. requestHostCallback(flushWork);
  58725. }
  58726. }
  58727. function unstable_getFirstCallbackNode() {
  58728. return peek(taskQueue);
  58729. }
  58730. function unstable_cancelCallback(task) {
  58731. if (enableProfiling) {
  58732. if (task.isQueued) {
  58733. var currentTime = exports.unstable_now();
  58734. markTaskCanceled(task, currentTime);
  58735. task.isQueued = false;
  58736. }
  58737. } // Null out the callback to indicate the task has been canceled. (Can't
  58738. // remove from the queue because you can't remove arbitrary nodes from an
  58739. // array based heap, only the first one.)
  58740. task.callback = null;
  58741. }
  58742. function unstable_getCurrentPriorityLevel() {
  58743. return currentPriorityLevel;
  58744. }
  58745. function unstable_shouldYield() {
  58746. var currentTime = exports.unstable_now();
  58747. advanceTimers(currentTime);
  58748. var firstTask = peek(taskQueue);
  58749. return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost();
  58750. }
  58751. var unstable_requestPaint = requestPaint;
  58752. var unstable_Profiling = enableProfiling ? {
  58753. startLoggingProfilingEvents: startLoggingProfilingEvents,
  58754. stopLoggingProfilingEvents: stopLoggingProfilingEvents,
  58755. sharedProfilingBuffer: sharedProfilingBuffer
  58756. } : null;
  58757. exports.unstable_ImmediatePriority = ImmediatePriority;
  58758. exports.unstable_UserBlockingPriority = UserBlockingPriority;
  58759. exports.unstable_NormalPriority = NormalPriority;
  58760. exports.unstable_IdlePriority = IdlePriority;
  58761. exports.unstable_LowPriority = LowPriority;
  58762. exports.unstable_runWithPriority = unstable_runWithPriority;
  58763. exports.unstable_next = unstable_next;
  58764. exports.unstable_scheduleCallback = unstable_scheduleCallback;
  58765. exports.unstable_cancelCallback = unstable_cancelCallback;
  58766. exports.unstable_wrapCallback = unstable_wrapCallback;
  58767. exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;
  58768. exports.unstable_shouldYield = unstable_shouldYield;
  58769. exports.unstable_requestPaint = unstable_requestPaint;
  58770. exports.unstable_continueExecution = unstable_continueExecution;
  58771. exports.unstable_pauseExecution = unstable_pauseExecution;
  58772. exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode;
  58773. exports.unstable_Profiling = unstable_Profiling;
  58774. })();
  58775. }
  58776. /***/ }),
  58777. /***/ "./node_modules/scheduler/index.js":
  58778. /*!*****************************************!*\
  58779. !*** ./node_modules/scheduler/index.js ***!
  58780. \*****************************************/
  58781. /*! no static exports found */
  58782. /***/ (function(module, exports, __webpack_require__) {
  58783. "use strict";
  58784. if (false) {} else {
  58785. module.exports = __webpack_require__(/*! ./cjs/scheduler.development.js */ "./node_modules/scheduler/cjs/scheduler.development.js");
  58786. }
  58787. /***/ }),
  58788. /***/ "./node_modules/scheduler/tracing.js":
  58789. /*!*******************************************!*\
  58790. !*** ./node_modules/scheduler/tracing.js ***!
  58791. \*******************************************/
  58792. /*! no static exports found */
  58793. /***/ (function(module, exports, __webpack_require__) {
  58794. "use strict";
  58795. if (false) {} else {
  58796. module.exports = __webpack_require__(/*! ./cjs/scheduler-tracing.development.js */ "./node_modules/scheduler/cjs/scheduler-tracing.development.js");
  58797. }
  58798. /***/ }),
  58799. /***/ "./node_modules/webpack/buildin/global.js":
  58800. /*!***********************************!*\
  58801. !*** (webpack)/buildin/global.js ***!
  58802. \***********************************/
  58803. /*! no static exports found */
  58804. /***/ (function(module, exports) {
  58805. var g;
  58806. // This works in non-strict mode
  58807. g = (function() {
  58808. return this;
  58809. })();
  58810. try {
  58811. // This works if eval is allowed (see CSP)
  58812. g = g || new Function("return this")();
  58813. } catch (e) {
  58814. // This works if the window reference is available
  58815. if (typeof window === "object") g = window;
  58816. }
  58817. // g can still be undefined, but nothing to do about it...
  58818. // We return undefined, instead of nothing here, so it's
  58819. // easier to handle this case. if(!global) { ...}
  58820. module.exports = g;
  58821. /***/ }),
  58822. /***/ "./node_modules/webpack/buildin/module.js":
  58823. /*!***********************************!*\
  58824. !*** (webpack)/buildin/module.js ***!
  58825. \***********************************/
  58826. /*! no static exports found */
  58827. /***/ (function(module, exports) {
  58828. module.exports = function(module) {
  58829. if (!module.webpackPolyfill) {
  58830. module.deprecate = function() {};
  58831. module.paths = [];
  58832. // module.parent = undefined by default
  58833. if (!module.children) module.children = [];
  58834. Object.defineProperty(module, "loaded", {
  58835. enumerable: true,
  58836. get: function() {
  58837. return module.l;
  58838. }
  58839. });
  58840. Object.defineProperty(module, "id", {
  58841. enumerable: true,
  58842. get: function() {
  58843. return module.i;
  58844. }
  58845. });
  58846. module.webpackPolyfill = 1;
  58847. }
  58848. return module;
  58849. };
  58850. /***/ }),
  58851. /***/ "./resources/js/app.js":
  58852. /*!*****************************!*\
  58853. !*** ./resources/js/app.js ***!
  58854. \*****************************/
  58855. /*! no static exports found */
  58856. /***/ (function(module, exports, __webpack_require__) {
  58857. /**
  58858. * First we will load all of this project's JavaScript dependencies which
  58859. * includes React and other helpers. It's a great starting point while
  58860. * building robust, powerful web applications using React + Laravel.
  58861. */
  58862. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  58863. /**
  58864. * Next, we will create a fresh React component instance and attach it to
  58865. * the page. Then, you may begin adding components to this application
  58866. * or customize the JavaScript scaffolding to fit your unique needs.
  58867. */
  58868. __webpack_require__(/*! ./components/Example */ "./resources/js/components/Example.js");
  58869. /***/ }),
  58870. /***/ "./resources/js/bootstrap.js":
  58871. /*!***********************************!*\
  58872. !*** ./resources/js/bootstrap.js ***!
  58873. \***********************************/
  58874. /*! no static exports found */
  58875. /***/ (function(module, exports, __webpack_require__) {
  58876. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  58877. /**
  58878. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  58879. * for JavaScript based Bootstrap features such as modals and tabs. This
  58880. * code may be modified to fit the specific needs of your application.
  58881. */
  58882. try {
  58883. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  58884. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  58885. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  58886. } catch (e) {}
  58887. /**
  58888. * We'll load the axios HTTP library which allows us to easily issue requests
  58889. * to our Laravel back-end. This library automatically handles sending the
  58890. * CSRF token as a header based on the value of the "XSRF" token cookie.
  58891. */
  58892. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  58893. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  58894. /**
  58895. * Next we will register the CSRF Token as a common header with Axios so that
  58896. * all outgoing HTTP requests automatically have it attached. This is just
  58897. * a simple convenience so we don't have to attach every token manually.
  58898. */
  58899. var token = document.head.querySelector('meta[name="csrf-token"]');
  58900. if (token) {
  58901. window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
  58902. } else {
  58903. console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
  58904. }
  58905. /**
  58906. * Echo exposes an expressive API for subscribing to channels and listening
  58907. * for events that are broadcast by Laravel. Echo and event broadcasting
  58908. * allows your team to easily build robust real-time web applications.
  58909. */
  58910. // import Echo from 'laravel-echo'
  58911. // window.Pusher = require('pusher-js');
  58912. // window.Echo = new Echo({
  58913. // broadcaster: 'pusher',
  58914. // key: process.env.MIX_PUSHER_APP_KEY,
  58915. // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  58916. // encrypted: true
  58917. // });
  58918. /***/ }),
  58919. /***/ "./resources/js/components/Example.js":
  58920. /*!********************************************!*\
  58921. !*** ./resources/js/components/Example.js ***!
  58922. \********************************************/
  58923. /*! exports provided: default */
  58924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58925. "use strict";
  58926. __webpack_require__.r(__webpack_exports__);
  58927. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "./node_modules/react/index.js");
  58928. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
  58929. /* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js");
  58930. /* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
  58931. function Example() {
  58932. return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
  58933. className: "container"
  58934. }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
  58935. className: "row justify-content-center"
  58936. }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
  58937. className: "col-md-8"
  58938. }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
  58939. className: "card"
  58940. }, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
  58941. className: "card-header"
  58942. }, "Example Component"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
  58943. className: "card-body"
  58944. }, "I'm an example component!")))));
  58945. }
  58946. /* harmony default export */ __webpack_exports__["default"] = (Example);
  58947. if (document.getElementById('example')) {
  58948. react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render(react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(Example, null), document.getElementById('example'));
  58949. }
  58950. /***/ }),
  58951. /***/ "./resources/sass/app.scss":
  58952. /*!*********************************!*\
  58953. !*** ./resources/sass/app.scss ***!
  58954. \*********************************/
  58955. /*! no static exports found */
  58956. /***/ (function(module, exports) {
  58957. // removed by extract-text-webpack-plugin
  58958. /***/ }),
  58959. /***/ 0:
  58960. /*!*************************************************************!*\
  58961. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  58962. \*************************************************************/
  58963. /*! no static exports found */
  58964. /***/ (function(module, exports, __webpack_require__) {
  58965. __webpack_require__(/*! F:\xampp\htdocs\testLaravel\resources\js\app.js */"./resources/js/app.js");
  58966. module.exports = __webpack_require__(/*! F:\xampp\htdocs\testLaravel\resources\sass\app.scss */"./resources/sass/app.scss");
  58967. /***/ })
  58968. /******/ });